diff --git a/packages/loader/container-loader/src/utils11.ts b/packages/loader/container-loader/src/utils11.ts new file mode 100644 index 000000000000..61a124169017 --- /dev/null +++ b/packages/loader/container-loader/src/utils11.ts @@ -0,0 +1,106 @@ +/*! + * Copyright (c) Microsoft Corporation and contributors. All rights reserved. + * Licensed under the MIT License. + */ + +import { stringToBuffer } from "@fluid-internal/client-utils"; +import type { IErrorBase } from "@fluidframework/container-definitions/internal"; +import { ISnapshotTree } from "@fluidframework/driver-definitions/internal"; + +import { ISerializableBlobContents } from "./containerStorageAdapter.js"; + +// This is used when we rehydrate a container from the snapshot. Here we put the blob contents +// in separate property: blobContents. +export interface ISnapshotTreeWithBlobContents extends ISnapshotTree { + blobsContents: { [path: string]: ArrayBufferLike }; + trees: { [path: string]: ISnapshotTreeWithBlobContents }; +} + +export interface IConnectionStateChangeReason { + text: string; + error?: T; +} + +/** + * Interface to represent the parsed parts of IResolvedUrl.url to help + * in getting info about different parts of the url. + * May not be compatible or relevant for any Url Resolver + * @legacy + * @alpha + */ +export interface IParsedUrl { + /** + * It is combination of tenantid/docId part of the url. + */ + id: string; + /** + * It is the deep link path in the url. + */ + path: string; + /** + * Query string part of the url. + */ + query: string; + /** + * Undefined means load latest snapshot, otherwise it's version ID passed to IDocumentStorageService.getVersions() + * to figure out what snapshot to use. + */ + version: string | undefined; +} + +export const combineSnapshotTreeAndSnapshotBlobs = ( + baseSnapshot: ISnapshotTree, + snapshotBlobs: ISerializableBlobContents, +): ISnapshotTreeWithBlobContents => { + const blobsContents: { [path: string]: ArrayBufferLike } = {}; + + // Process blobs in the current level + for (const [, id] of Object.entries(baseSnapshot.blobs)) { + if (snapshotBlobs[id]) { + blobsContents[id] = stringToBuffer(snapshotBlobs[id], "utf8"); + } + } + + // Recursively process trees in the current level + const trees: { [path: string]: ISnapshotTreeWithBlobContents } = {}; + for (const [path, tree] of Object.entries(baseSnapshot.trees)) { + trees[path] = combineSnapshotTreeAndSnapshotBlobs(tree, snapshotBlobs); + } + + // Create a new snapshot tree with blob contents and processed trees + const snapshotTreeWithBlobContents: ISnapshotTreeWithBlobContents = { + ...baseSnapshot, + blobsContents, + trees, + }; + + return snapshotTreeWithBlobContents; +}; + +export function combineSnapshotTreeAndSnapshotBlobs2( + baseSnapshot: ISnapshotTree, + snapshotBlobs: ISerializableBlobContents, +): ISnapshotTreeWithBlobContents { + const blobsContents: { [path: string]: ArrayBufferLike } = {}; + + if (snapshotBlobs.id) { + blobsContents.id = stringToBuffer(snapshotBlobs.id, "utf8"); + } else { + blobsContents.x = stringToBuffer(snapshotBlobs.id, "utf8"); + } + + // Recursively process trees in the current level + const trees: { [path: string]: ISnapshotTreeWithBlobContents } = {}; + for (const [path, tree] of Object.entries(baseSnapshot.trees)) { + trees[path] = combineSnapshotTreeAndSnapshotBlobs(tree, snapshotBlobs); + } + + // Create a new snapshot tree with blob contents and processed trees + const snapshotTreeWithBlobContents: ISnapshotTreeWithBlobContents = { + ...baseSnapshot, + blobsContents, + trees, + }; + + return snapshotTreeWithBlobContents; +} diff --git a/tools/pipelines/templates/build-npm-client-package.yml b/tools/pipelines/templates/build-npm-client-package.yml index 57d1f7d2ed11..ed9c1373a378 100644 --- a/tools/pipelines/templates/build-npm-client-package.yml +++ b/tools/pipelines/templates/build-npm-client-package.yml @@ -637,13 +637,25 @@ extends: script: | set -eu -o pipefail sed -e 's/\(filename=\".*[\\/]external .*\)"\(.*\)""/\1\"\2\""/' cobertura-coverage.xml > cobertura-coverage-patched.xml - + sed -e 's/\(filename=\".*[\\/]external .*\)"\(.*\)""/\1\"\2\""/' clover.xml > clover-patched.xml - task: PublishCodeCoverageResults@2 - displayName: Publish Code Coverage + displayName: Publish Code Coverage(Cobertura) condition: and(succeededOrFailed(), eq(variables['ReportDirExists'], 'true')) inputs: summaryFileLocation: ${{ parameters.buildDirectory }}/nyc/report/cobertura-coverage-patched.xml failIfCoverageEmpty: true + - task: PublishCodeCoverageResults@2 + displayName: Publish Code Coverage(Clover) + condition: and(succeededOrFailed(), eq(variables['ReportDirExists'], 'true')) + inputs: + summaryFileLocation: ${{ parameters.buildDirectory }}/nyc/report/clover-patched.xml + failIfCoverageEmpty: true + - task: PublishCodeCoverageResults@2 + displayName: Publish Code Coverage(Json-Summary) + condition: and(succeededOrFailed(), eq(variables['ReportDirExists'], 'true')) + inputs: + summaryFileLocation: ${{ parameters.buildDirectory }}/nyc/report/coverage-summary.json + failIfCoverageEmpty: true - task: CopyFiles@2 displayName: Copy code coverage report to artifact staging directory condition: and(succeededOrFailed(), eq(variables['ReportDirExists'], 'true')) diff --git a/tools/pipelines/templates/build-npm-package.yml b/tools/pipelines/templates/build-npm-package.yml index c308fe9dfc14..38ca411ecb55 100644 --- a/tools/pipelines/templates/build-npm-package.yml +++ b/tools/pipelines/templates/build-npm-package.yml @@ -403,7 +403,7 @@ extends: set -eu -o pipefail sed -e 's/\(filename=\".*[\\/]external .*\)"\(.*\)""/\1\"\2\""/' cobertura-coverage.xml > cobertura-coverage-patched.xml - task: PublishCodeCoverageResults@2 - displayName: Publish Code Coverage + displayName: Publish Code Coverage(Cobertura) condition: and(succeededOrFailed(), eq(variables['ReportDirExists'], 'true')) inputs: summaryFileLocation: ${{ parameters.buildDirectory }}/nyc/report/cobertura-coverage-patched.xml