@fluidframework/container-loader 2.0.0-rc.1.0.4 → 2.0.0-rc.2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.eslintrc.js → .eslintrc.cjs} +5 -6
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +48 -0
- package/README.md +3 -3
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/container-loader.api.md +2 -2
- package/dist/attachment.d.ts +115 -0
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +83 -0
- package/dist/attachment.js.map +1 -0
- package/dist/audience.d.ts +9 -4
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js +10 -4
- package/dist/audience.js.map +1 -1
- package/dist/connectionManager.d.ts +3 -3
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +17 -18
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionState.d.ts +1 -0
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionState.js +1 -0
- package/dist/connectionState.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +7 -7
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +32 -32
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container-loader-alpha.d.ts +2 -1
- package/dist/container-loader-beta.d.ts +3 -0
- package/dist/container-loader-public.d.ts +3 -0
- package/dist/container-loader-untrimmed.d.ts +5 -5
- package/dist/container.d.ts +29 -27
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +219 -284
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +3 -2
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +2 -1
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +5 -6
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +14 -21
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +3 -3
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +5 -5
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +6 -6
- package/dist/deltaManager.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +3 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +13 -17
- package/dist/loader.js.map +1 -1
- package/dist/location-redirection-utilities/index.d.ts +1 -1
- package/dist/location-redirection-utilities/index.d.ts.map +1 -1
- package/dist/location-redirection-utilities/index.js +3 -3
- package/dist/location-redirection-utilities/index.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js +1 -3
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +2 -2
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +8 -6
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/serializedStateManager.d.ts +44 -0
- package/dist/serializedStateManager.d.ts.map +1 -0
- package/dist/serializedStateManager.js +149 -0
- package/dist/serializedStateManager.js.map +1 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/utils.d.ts +16 -11
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +107 -32
- package/dist/utils.js.map +1 -1
- package/lib/attachment.d.ts +115 -0
- package/lib/attachment.d.ts.map +1 -0
- package/lib/attachment.js +79 -0
- package/lib/attachment.js.map +1 -0
- package/lib/{audience.d.mts → audience.d.ts} +14 -5
- package/lib/audience.d.ts.map +1 -0
- package/lib/{audience.mjs → audience.js} +14 -4
- package/lib/audience.js.map +1 -0
- package/lib/{catchUpMonitor.d.mts → catchUpMonitor.d.ts} +1 -1
- package/lib/catchUpMonitor.d.ts.map +1 -0
- package/lib/{catchUpMonitor.mjs → catchUpMonitor.js} +1 -1
- package/lib/catchUpMonitor.js.map +1 -0
- package/lib/{connectionManager.d.mts → connectionManager.d.ts} +4 -4
- package/lib/connectionManager.d.ts.map +1 -0
- package/lib/{connectionManager.mjs → connectionManager.js} +7 -10
- package/lib/connectionManager.js.map +1 -0
- package/lib/{connectionState.d.mts → connectionState.d.ts} +2 -1
- package/lib/connectionState.d.ts.map +1 -0
- package/lib/{connectionState.mjs → connectionState.js} +2 -1
- package/lib/connectionState.js.map +1 -0
- package/lib/{connectionStateHandler.d.mts → connectionStateHandler.d.ts} +8 -8
- package/lib/connectionStateHandler.d.ts.map +1 -0
- package/lib/{connectionStateHandler.mjs → connectionStateHandler.js} +3 -3
- package/lib/connectionStateHandler.js.map +1 -0
- package/lib/{container-loader-alpha.d.mts → container-loader-alpha.d.ts} +2 -1
- package/lib/{container-loader-beta.d.mts → container-loader-beta.d.ts} +3 -0
- package/lib/{container-loader-public.d.mts → container-loader-public.d.ts} +3 -0
- package/lib/{container-loader-untrimmed.d.mts → container-loader-untrimmed.d.ts} +5 -5
- package/lib/{container.d.mts → container.d.ts} +30 -28
- package/lib/container.d.ts.map +1 -0
- package/lib/{container.mjs → container.js} +179 -247
- package/lib/container.js.map +1 -0
- package/lib/{containerContext.d.mts → containerContext.d.ts} +4 -3
- package/lib/containerContext.d.ts.map +1 -0
- package/lib/{containerContext.mjs → containerContext.js} +3 -2
- package/lib/containerContext.js.map +1 -0
- package/lib/{containerStorageAdapter.d.mts → containerStorageAdapter.d.ts} +6 -7
- package/lib/containerStorageAdapter.d.ts.map +1 -0
- package/lib/{containerStorageAdapter.mjs → containerStorageAdapter.js} +13 -20
- package/lib/containerStorageAdapter.js.map +1 -0
- package/lib/{contracts.d.mts → contracts.d.ts} +4 -4
- package/lib/contracts.d.ts.map +1 -0
- package/lib/{contracts.mjs → contracts.js} +1 -1
- package/lib/contracts.js.map +1 -0
- package/lib/{debugLogger.d.mts → debugLogger.d.ts} +1 -1
- package/lib/debugLogger.d.ts.map +1 -0
- package/lib/{debugLogger.mjs → debugLogger.js} +2 -1
- package/lib/debugLogger.js.map +1 -0
- package/lib/{deltaManager.d.mts → deltaManager.d.ts} +6 -6
- package/lib/deltaManager.d.ts.map +1 -0
- package/lib/{deltaManager.mjs → deltaManager.js} +4 -4
- package/lib/deltaManager.js.map +1 -0
- package/lib/{deltaQueue.d.mts → deltaQueue.d.ts} +1 -1
- package/lib/deltaQueue.d.ts.map +1 -0
- package/lib/{deltaQueue.mjs → deltaQueue.js} +1 -1
- package/lib/deltaQueue.js.map +1 -0
- package/lib/{disposal.d.mts → disposal.d.ts} +1 -1
- package/lib/disposal.d.ts.map +1 -0
- package/lib/{disposal.mjs → disposal.js} +1 -1
- package/lib/disposal.js.map +1 -0
- package/lib/{error.d.mts → error.d.ts} +1 -1
- package/lib/error.d.ts.map +1 -0
- package/lib/{error.mjs → error.js} +1 -1
- package/lib/error.js.map +1 -0
- package/lib/{index.d.mts → index.d.ts} +7 -7
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/{loader.d.mts → loader.d.ts} +4 -4
- package/lib/loader.d.ts.map +1 -0
- package/lib/{loader.mjs → loader.js} +7 -11
- package/lib/loader.js.map +1 -0
- package/lib/location-redirection-utilities/{index.mjs → index.d.ts} +2 -2
- package/lib/location-redirection-utilities/index.d.ts.map +1 -0
- package/lib/location-redirection-utilities/{index.d.mts → index.js} +2 -2
- package/lib/location-redirection-utilities/index.js.map +1 -0
- package/lib/location-redirection-utilities/{resolveWithLocationRedirection.d.mts → resolveWithLocationRedirection.d.ts} +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
- package/lib/location-redirection-utilities/{resolveWithLocationRedirection.mjs → resolveWithLocationRedirection.js} +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
- package/lib/{noopHeuristic.d.mts → noopHeuristic.d.ts} +1 -1
- package/lib/noopHeuristic.d.ts.map +1 -0
- package/lib/{noopHeuristic.mjs → noopHeuristic.js} +1 -1
- package/lib/noopHeuristic.js.map +1 -0
- package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
- package/lib/packageVersion.js.map +1 -0
- package/lib/{protocol.d.mts → protocol.d.ts} +1 -1
- package/lib/protocol.d.ts.map +1 -0
- package/lib/{protocol.mjs → protocol.js} +1 -1
- package/lib/protocol.js.map +1 -0
- package/lib/{protocolTreeDocumentStorageService.d.mts → protocolTreeDocumentStorageService.d.ts} +2 -2
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -0
- package/lib/{protocolTreeDocumentStorageService.mjs → protocolTreeDocumentStorageService.js} +2 -4
- package/lib/protocolTreeDocumentStorageService.js.map +1 -0
- package/lib/{quorum.d.mts → quorum.d.ts} +5 -1
- package/lib/quorum.d.ts.map +1 -0
- package/lib/{quorum.mjs → quorum.js} +1 -1
- package/lib/quorum.js.map +1 -0
- package/lib/{retriableDocumentStorageService.d.mts → retriableDocumentStorageService.d.ts} +3 -3
- package/lib/retriableDocumentStorageService.d.ts.map +1 -0
- package/lib/{retriableDocumentStorageService.mjs → retriableDocumentStorageService.js} +10 -8
- package/lib/retriableDocumentStorageService.js.map +1 -0
- package/lib/serializedStateManager.d.ts +44 -0
- package/lib/serializedStateManager.d.ts.map +1 -0
- package/lib/serializedStateManager.js +145 -0
- package/lib/serializedStateManager.js.map +1 -0
- package/lib/test/attachment.spec.js +380 -0
- package/lib/test/attachment.spec.js.map +1 -0
- package/lib/test/catchUpMonitor.spec.js +88 -0
- package/lib/test/catchUpMonitor.spec.js.map +1 -0
- package/lib/test/connectionManager.spec.js +201 -0
- package/lib/test/connectionManager.spec.js.map +1 -0
- package/lib/test/connectionStateHandler.spec.js +555 -0
- package/lib/test/connectionStateHandler.spec.js.map +1 -0
- package/lib/test/container.spec.js +64 -0
- package/lib/test/container.spec.js.map +1 -0
- package/lib/test/deltaManager.spec.js +405 -0
- package/lib/test/deltaManager.spec.js.map +1 -0
- package/lib/test/loader.spec.js +212 -0
- package/lib/test/loader.spec.js.map +1 -0
- package/lib/test/locationRedirectionTests.spec.js +44 -0
- package/lib/test/locationRedirectionTests.spec.js.map +1 -0
- package/lib/test/serializedStateManager.spec.js +148 -0
- package/lib/test/serializedStateManager.spec.js.map +1 -0
- package/lib/test/snapshotConversionTest.spec.js +79 -0
- package/lib/test/snapshotConversionTest.spec.js.map +1 -0
- package/lib/test/types/validateContainerLoaderPrevious.generated.js +38 -0
- package/lib/test/types/validateContainerLoaderPrevious.generated.js.map +1 -0
- package/lib/test/utils.spec.js +31 -0
- package/lib/test/utils.spec.js.map +1 -0
- package/lib/{utils.d.mts → utils.d.ts} +17 -12
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +206 -0
- package/lib/utils.js.map +1 -0
- package/package.json +63 -63
- package/src/attachment.ts +222 -0
- package/src/audience.ts +9 -3
- package/src/connectionManager.ts +9 -11
- package/src/connectionState.ts +1 -0
- package/src/connectionStateHandler.ts +8 -7
- package/src/container.ts +297 -323
- package/src/containerContext.ts +2 -1
- package/src/containerStorageAdapter.ts +21 -26
- package/src/contracts.ts +3 -3
- package/src/debugLogger.ts +2 -2
- package/src/deltaManager.ts +8 -8
- package/src/error.ts +2 -2
- package/src/index.ts +6 -6
- package/src/loader.ts +9 -13
- package/src/location-redirection-utilities/index.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/protocolTreeDocumentStorageService.ts +1 -3
- package/src/retriableDocumentStorageService.ts +18 -8
- package/src/serializedStateManager.ts +217 -0
- package/src/utils.ts +140 -43
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +2 -5
- package/lib/audience.d.mts.map +0 -1
- package/lib/audience.mjs.map +0 -1
- package/lib/catchUpMonitor.d.mts.map +0 -1
- package/lib/catchUpMonitor.mjs.map +0 -1
- package/lib/connectionManager.d.mts.map +0 -1
- package/lib/connectionManager.mjs.map +0 -1
- package/lib/connectionState.d.mts.map +0 -1
- package/lib/connectionState.mjs.map +0 -1
- package/lib/connectionStateHandler.d.mts.map +0 -1
- package/lib/connectionStateHandler.mjs.map +0 -1
- package/lib/container.d.mts.map +0 -1
- package/lib/container.mjs.map +0 -1
- package/lib/containerContext.d.mts.map +0 -1
- package/lib/containerContext.mjs.map +0 -1
- package/lib/containerStorageAdapter.d.mts.map +0 -1
- package/lib/containerStorageAdapter.mjs.map +0 -1
- package/lib/contracts.d.mts.map +0 -1
- package/lib/contracts.mjs.map +0 -1
- package/lib/debugLogger.d.mts.map +0 -1
- package/lib/debugLogger.mjs.map +0 -1
- package/lib/deltaManager.d.mts.map +0 -1
- package/lib/deltaManager.mjs.map +0 -1
- package/lib/deltaQueue.d.mts.map +0 -1
- package/lib/deltaQueue.mjs.map +0 -1
- package/lib/disposal.d.mts.map +0 -1
- package/lib/disposal.mjs.map +0 -1
- package/lib/error.d.mts.map +0 -1
- package/lib/error.mjs.map +0 -1
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs +0 -10
- package/lib/index.mjs.map +0 -1
- package/lib/loader.d.mts.map +0 -1
- package/lib/loader.mjs.map +0 -1
- package/lib/location-redirection-utilities/index.d.mts.map +0 -1
- package/lib/location-redirection-utilities/index.mjs.map +0 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.mts.map +0 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs.map +0 -1
- package/lib/noopHeuristic.d.mts.map +0 -1
- package/lib/noopHeuristic.mjs.map +0 -1
- package/lib/packageVersion.d.mts.map +0 -1
- package/lib/packageVersion.mjs.map +0 -1
- package/lib/protocol.d.mts.map +0 -1
- package/lib/protocol.mjs.map +0 -1
- package/lib/protocolTreeDocumentStorageService.d.mts.map +0 -1
- package/lib/protocolTreeDocumentStorageService.mjs.map +0 -1
- package/lib/quorum.d.mts.map +0 -1
- package/lib/quorum.mjs.map +0 -1
- package/lib/retriableDocumentStorageService.d.mts.map +0 -1
- package/lib/retriableDocumentStorageService.mjs.map +0 -1
- package/lib/utils.d.mts.map +0 -1
- package/lib/utils.mjs +0 -133
- package/lib/utils.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotConversionTest.spec.js","sourceRoot":"","sources":["../../src/test/snapshotConversionTest.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAgB,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACN,4BAA4B,EAC5B,8CAA8C,GAC9C,MAAM,aAAa,CAAC;AAErB,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACpC,MAAM,eAAe,GAAiB;QACrC,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,IAAI,EAAE;YACL,UAAU,EAAE;gBACX,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;aACrC;YACD,YAAY,EAAE;gBACb,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;aACvC;SACD;KACD,CAAC;IACF,MAAM,UAAU,GAAiB;QAChC,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,IAAI,EAAE;YACL,OAAO,EAAE;gBACR,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,IAAI,EA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IT License.\n */\n\nimport { strict as assert } from \"assert\";\nimport { ISummaryTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tcombineAppAndProtocolSummary,\n\tgetSnapshotTreeAndBlobsFromSerializedContainer,\n} from \"../utils.js\";\n\ndescribe(\"Dehydrate Container\", () => {\n\tconst protocolSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\tattributes: {\n\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\tcontent: JSON.stringify(\"attributes\"),\n\t\t\t},\n\t\t\tquorumValues: {\n\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\tcontent: JSON.stringify(\"quorumValues\"),\n\t\t\t},\n\t\t},\n\t};\n\tconst appSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\tdefault: {\n\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\ttree: {\n\t\t\t\t\t\".component\": {\n\t\t\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\t\t\tcontent: JSON.stringify(\"defaultDataStore\"),\n\t\t\t\t\t},\n\t\t\t\t\t\"root\": {\n\t\t\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\t\t\ttree: {\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\t\t\t\t\tcontent: JSON.stringify(\"rootattributes\"),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t\"unref\": {\n\t\t\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\t\t\ttree: {},\n\t\t\t\t\t\tunreferenced: true,\n\t\t\t\t\t},\n\t\t\t\t\t\"groupId\": {\n\t\t\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\t\t\ttree: {},\n\t\t\t\t\t\tgroupId: \"group\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n\n\tit(\"Summary to snapshottree and snapshotBlobs conversion\", async () => {\n\t\tconst combinedSummary = combineAppAndProtocolSummary(appSummary, protocolSummary);\n\t\tconst { tree, blobs } = getSnapshotTreeAndBlobsFromSerializedContainer(combinedSummary);\n\n\t\tassert.strictEqual(Object.keys(tree.trees).length, 2, \"2 trees should be there\");\n\t\tassert.strictEqual(\n\t\t\tObject.keys(tree.trees[\".protocol\"].blobs).length,\n\t\t\t2,\n\t\t\t\"2 protocol blobs should be there.\",\n\t\t);\n\n\t\t// Validate the \".component\" blob.\n\t\tconst defaultDataStoreBlobId = tree.trees.default.blobs[\".component\"];\n\t\tconst defaultDataStoreBlob = blobs[defaultDataStoreBlobId];\n\t\tassert.strict(defaultDataStoreBlob, \"defaultDataStoreBlob undefined\");\n\t\tassert.strictEqual(\n\t\t\tJSON.parse(defaultDataStoreBlob),\n\t\t\t\"defaultDataStore\",\n\t\t\t\"The .component blob's content is incorrect\",\n\t\t);\n\n\t\t// Validate \"root\" sub-tree.\n\t\tconst rootAttributesBlobId = tree.trees.default.trees.root.blobs.attributes;\n\t\tconst rootAttributesBlob = blobs[rootAttributesBlobId];\n\t\tassert.strict(rootAttributesBlob, \"rootAttributesBlob undefined\");\n\t\tassert.strictEqual(\n\t\t\tJSON.parse(rootAttributesBlob),\n\t\t\t\"rootattributes\",\n\t\t\t\"The root sub-tree's content is incorrect\",\n\t\t);\n\t\tassert.strictEqual(\n\t\t\ttree.trees.default.trees.root.unreferenced,\n\t\t\tundefined,\n\t\t\t\"The root sub-tree should not be marked as unreferenced\",\n\t\t);\n\n\t\t// Validate \"unref\" sub-tree.\n\t\tassert.strictEqual(\n\t\t\ttree.trees.default.trees.unref.unreferenced,\n\t\t\ttrue,\n\t\t\t\"The unref sub-tree should be marked as unreferenced\",\n\t\t);\n\n\t\t// Validate \"groupId\" sub-tree.\n\t\tassert.strictEqual(\n\t\t\ttree.trees.default.trees.groupId.groupId,\n\t\t\t\"group\",\n\t\t\t\"The groupId sub-tree should have a groupId\",\n\t\t);\n\n\t\t// Validate \"groupId\" sub-tree.\n\t\tassert.strictEqual(\n\t\t\ttree.trees.default.trees.groupId.groupId,\n\t\t\t\"group\",\n\t\t\t\"The groupId sub-tree should have a groupId\",\n\t\t);\n\t});\n});\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
use_current_EnumDeclaration_ConnectionState(get_old_EnumDeclaration_ConnectionState());
|
|
2
|
+
use_old_EnumDeclaration_ConnectionState(get_current_EnumDeclaration_ConnectionState());
|
|
3
|
+
use_current_InterfaceDeclaration_ICodeDetailsLoader(get_old_InterfaceDeclaration_ICodeDetailsLoader());
|
|
4
|
+
use_old_InterfaceDeclaration_ICodeDetailsLoader(get_current_InterfaceDeclaration_ICodeDetailsLoader());
|
|
5
|
+
use_current_InterfaceDeclaration_IContainerExperimental(
|
|
6
|
+
// @ts-expect-error compatibility expected to be broken
|
|
7
|
+
get_old_InterfaceDeclaration_IContainerExperimental());
|
|
8
|
+
use_old_InterfaceDeclaration_IContainerExperimental(get_current_InterfaceDeclaration_IContainerExperimental());
|
|
9
|
+
use_current_TypeAliasDeclaration_IDetachedBlobStorage(get_old_TypeAliasDeclaration_IDetachedBlobStorage());
|
|
10
|
+
use_old_TypeAliasDeclaration_IDetachedBlobStorage(get_current_TypeAliasDeclaration_IDetachedBlobStorage());
|
|
11
|
+
use_current_InterfaceDeclaration_IFluidModuleWithDetails(get_old_InterfaceDeclaration_IFluidModuleWithDetails());
|
|
12
|
+
use_old_InterfaceDeclaration_IFluidModuleWithDetails(get_current_InterfaceDeclaration_IFluidModuleWithDetails());
|
|
13
|
+
use_current_InterfaceDeclaration_ILoaderOptions(get_old_InterfaceDeclaration_ILoaderOptions());
|
|
14
|
+
use_old_InterfaceDeclaration_ILoaderOptions(get_current_InterfaceDeclaration_ILoaderOptions());
|
|
15
|
+
use_current_InterfaceDeclaration_ILoaderProps(get_old_InterfaceDeclaration_ILoaderProps());
|
|
16
|
+
use_old_InterfaceDeclaration_ILoaderProps(get_current_InterfaceDeclaration_ILoaderProps());
|
|
17
|
+
use_current_InterfaceDeclaration_ILoaderServices(get_old_InterfaceDeclaration_ILoaderServices());
|
|
18
|
+
use_old_InterfaceDeclaration_ILoaderServices(get_current_InterfaceDeclaration_ILoaderServices());
|
|
19
|
+
use_current_InterfaceDeclaration_IParsedUrl(
|
|
20
|
+
// @ts-expect-error compatibility expected to be broken
|
|
21
|
+
get_old_InterfaceDeclaration_IParsedUrl());
|
|
22
|
+
use_old_InterfaceDeclaration_IParsedUrl(get_current_InterfaceDeclaration_IParsedUrl());
|
|
23
|
+
use_current_InterfaceDeclaration_IProtocolHandler(get_old_InterfaceDeclaration_IProtocolHandler());
|
|
24
|
+
use_old_InterfaceDeclaration_IProtocolHandler(get_current_InterfaceDeclaration_IProtocolHandler());
|
|
25
|
+
use_current_ClassDeclaration_Loader(get_old_ClassDeclaration_Loader());
|
|
26
|
+
use_old_ClassDeclaration_Loader(get_current_ClassDeclaration_Loader());
|
|
27
|
+
use_current_TypeAliasDeclaration_ProtocolHandlerBuilder(get_old_TypeAliasDeclaration_ProtocolHandlerBuilder());
|
|
28
|
+
use_old_TypeAliasDeclaration_ProtocolHandlerBuilder(get_current_TypeAliasDeclaration_ProtocolHandlerBuilder());
|
|
29
|
+
use_current_FunctionDeclaration_isLocationRedirectionError(get_old_FunctionDeclaration_isLocationRedirectionError());
|
|
30
|
+
use_old_FunctionDeclaration_isLocationRedirectionError(get_current_FunctionDeclaration_isLocationRedirectionError());
|
|
31
|
+
use_current_FunctionDeclaration_resolveWithLocationRedirectionHandling(get_old_FunctionDeclaration_resolveWithLocationRedirectionHandling());
|
|
32
|
+
use_old_FunctionDeclaration_resolveWithLocationRedirectionHandling(get_current_FunctionDeclaration_resolveWithLocationRedirectionHandling());
|
|
33
|
+
use_current_FunctionDeclaration_tryParseCompatibleResolvedUrl(get_old_FunctionDeclaration_tryParseCompatibleResolvedUrl());
|
|
34
|
+
use_old_FunctionDeclaration_tryParseCompatibleResolvedUrl(get_current_FunctionDeclaration_tryParseCompatibleResolvedUrl());
|
|
35
|
+
use_current_FunctionDeclaration_waitContainerToCatchUp(get_old_FunctionDeclaration_waitContainerToCatchUp());
|
|
36
|
+
use_old_FunctionDeclaration_waitContainerToCatchUp(get_current_FunctionDeclaration_waitContainerToCatchUp());
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=validateContainerLoaderPrevious.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateContainerLoaderPrevious.generated.js","sourceRoot":"","sources":["../../../src/test/types/validateContainerLoaderPrevious.generated.ts"],"names":[],"mappings":"AAgCA,2CAA2C,CACvC,uCAAuC,EAAE,CAAC,CAAC;AAW/C,uCAAuC,CACnC,2CAA2C,EAAE,CAAC,CAAC;AAWnD,mDAAmD,CAC/C,+CAA+C,EAAE,CAAC,CAAC;AAWvD,+CAA+C,CAC3C,mDAAmD,EAAE,CAAC,CAAC;AAW3D,uDAAuD;AACnD,uDAAuD;AACvD,mDAAmD,EAAE,CAAC,CAAC;AAW3D,mDAAmD,CAC/C,uDAAuD,EAAE,CAAC,CAAC;AAW/D,qDAAqD,CACjD,iDAAiD,EAAE,CAAC,CAAC;AAWzD,iDAAiD,CAC7C,qDAAqD,EAAE,CAAC,CAAC;AAW7D,wDAAwD,CACpD,oDAAoD,EAAE,CAAC,CAAC;AAW5D,oDAAoD,CAChD,wDAAwD,EAAE,CAAC,CAAC;AAWhE,+CAA+C,CAC3C,2CAA2C,EAAE,CAAC,CAAC;AAWnD,2CAA2C,CACvC,+CAA+C,EAAE,CAAC,CAAC;AAWvD,6CAA6C,CACzC,yCAAyC,EAAE,CAAC,CAAC;AAWjD,yCAAyC,CACrC,6CAA6C,EAAE,CAAC,CAAC;AAWrD,gDAAgD,CAC5C,4CAA4C,EAAE,CAAC,CAAC;AAWpD,4CAA4C,CACxC,gDAAgD,EAAE,CAAC,CAAC;AAWxD,2CAA2C;AACvC,uDAAuD;AACvD,uCAAuC,EAAE,CAAC,CAAC;AAW/C,uCAAuC,CACnC,2CAA2C,EAAE,CAAC,CAAC;AAWnD,iDAAiD,CAC7C,6CAA6C,EAAE,CAAC,CAAC;AAWrD,6CAA6C,CACzC,iDAAiD,EAAE,CAAC,CAAC;AAWzD,mCAAmC,CAC/B,+BAA+B,EAAE,CAAC,CAAC;AAWvC,+BAA+B,CAC3B,mCAAmC,EAAE,CAAC,CAAC;AAW3C,uDAAuD,CACnD,mDAAmD,EAAE,CAAC,CAAC;AAW3D,mDAAmD,CAC/C,uDAAuD,EAAE,CAAC,CAAC;AAW/D,0DAA0D,CACtD,sDAAsD,EAAE,CAAC,CAAC;AAW9D,sDAAsD,CAClD,0DAA0D,EAAE,CAAC,CAAC;AAWlE,sEAAsE,CAClE,kEAAkE,EAAE,CAAC,CAAC;AAW1E,kEAAkE,CAC9D,sEAAsE,EAAE,CAAC,CAAC;AAW9E,6DAA6D,CACzD,yDAAyD,EAAE,CAAC,CAAC;AAWjE,yDAAyD,CACrD,6DAA6D,EAAE,CAAC,CAAC;AAWrE,sDAAsD,CAClD,kDAAkD,EAAE,CAAC,CAAC;AAW1D,kDAAkD,CAC9C,sDAAsD,EAAE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/*\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n * Generated by fluid-type-test-generator in @fluidframework/build-tools.\n */\nimport type * as old from \"@fluidframework/container-loader-previous\";\nimport type * as current from \"../../index.js\";\n\n\n// See 'build-tools/src/type-test-generator/compatibility.ts' for more information.\ntype TypeOnly<T> = T extends number\n\t? number\n\t: T extends string\n\t? string\n\t: T extends boolean | bigint | symbol\n\t? T\n\t: {\n\t\t\t[P in keyof T]: TypeOnly<T[P]>;\n\t };\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"EnumDeclaration_ConnectionState\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_EnumDeclaration_ConnectionState():\n TypeOnly<old.ConnectionState>;\ndeclare function use_current_EnumDeclaration_ConnectionState(\n use: TypeOnly<current.ConnectionState>): void;\nuse_current_EnumDeclaration_ConnectionState(\n get_old_EnumDeclaration_ConnectionState());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"EnumDeclaration_ConnectionState\": {\"backCompat\": false}\n*/\ndeclare function get_current_EnumDeclaration_ConnectionState():\n TypeOnly<current.ConnectionState>;\ndeclare function use_old_EnumDeclaration_ConnectionState(\n use: TypeOnly<old.ConnectionState>): void;\nuse_old_EnumDeclaration_ConnectionState(\n get_current_EnumDeclaration_ConnectionState());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ICodeDetailsLoader\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_ICodeDetailsLoader():\n TypeOnly<old.ICodeDetailsLoader>;\ndeclare function use_current_InterfaceDeclaration_ICodeDetailsLoader(\n use: TypeOnly<current.ICodeDetailsLoader>): void;\nuse_current_InterfaceDeclaration_ICodeDetailsLoader(\n get_old_InterfaceDeclaration_ICodeDetailsLoader());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ICodeDetailsLoader\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_ICodeDetailsLoader():\n TypeOnly<current.ICodeDetailsLoader>;\ndeclare function use_old_InterfaceDeclaration_ICodeDetailsLoader(\n use: TypeOnly<old.ICodeDetailsLoader>): void;\nuse_old_InterfaceDeclaration_ICodeDetailsLoader(\n get_current_InterfaceDeclaration_ICodeDetailsLoader());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IContainerExperimental\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_IContainerExperimental():\n TypeOnly<old.IContainerExperimental>;\ndeclare function use_current_InterfaceDeclaration_IContainerExperimental(\n use: TypeOnly<current.IContainerExperimental>): void;\nuse_current_InterfaceDeclaration_IContainerExperimental(\n // @ts-expect-error compatibility expected to be broken\n get_old_InterfaceDeclaration_IContainerExperimental());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IContainerExperimental\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_IContainerExperimental():\n TypeOnly<current.IContainerExperimental>;\ndeclare function use_old_InterfaceDeclaration_IContainerExperimental(\n use: TypeOnly<old.IContainerExperimental>): void;\nuse_old_InterfaceDeclaration_IContainerExperimental(\n get_current_InterfaceDeclaration_IContainerExperimental());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"TypeAliasDeclaration_IDetachedBlobStorage\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_TypeAliasDeclaration_IDetachedBlobStorage():\n TypeOnly<old.IDetachedBlobStorage>;\ndeclare function use_current_TypeAliasDeclaration_IDetachedBlobStorage(\n use: TypeOnly<current.IDetachedBlobStorage>): void;\nuse_current_TypeAliasDeclaration_IDetachedBlobStorage(\n get_old_TypeAliasDeclaration_IDetachedBlobStorage());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"TypeAliasDeclaration_IDetachedBlobStorage\": {\"backCompat\": false}\n*/\ndeclare function get_current_TypeAliasDeclaration_IDetachedBlobStorage():\n TypeOnly<current.IDetachedBlobStorage>;\ndeclare function use_old_TypeAliasDeclaration_IDetachedBlobStorage(\n use: TypeOnly<old.IDetachedBlobStorage>): void;\nuse_old_TypeAliasDeclaration_IDetachedBlobStorage(\n get_current_TypeAliasDeclaration_IDetachedBlobStorage());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IFluidModuleWithDetails\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_IFluidModuleWithDetails():\n TypeOnly<old.IFluidModuleWithDetails>;\ndeclare function use_current_InterfaceDeclaration_IFluidModuleWithDetails(\n use: TypeOnly<current.IFluidModuleWithDetails>): void;\nuse_current_InterfaceDeclaration_IFluidModuleWithDetails(\n get_old_InterfaceDeclaration_IFluidModuleWithDetails());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IFluidModuleWithDetails\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_IFluidModuleWithDetails():\n TypeOnly<current.IFluidModuleWithDetails>;\ndeclare function use_old_InterfaceDeclaration_IFluidModuleWithDetails(\n use: TypeOnly<old.IFluidModuleWithDetails>): void;\nuse_old_InterfaceDeclaration_IFluidModuleWithDetails(\n get_current_InterfaceDeclaration_IFluidModuleWithDetails());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ILoaderOptions\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_ILoaderOptions():\n TypeOnly<old.ILoaderOptions>;\ndeclare function use_current_InterfaceDeclaration_ILoaderOptions(\n use: TypeOnly<current.ILoaderOptions>): void;\nuse_current_InterfaceDeclaration_ILoaderOptions(\n get_old_InterfaceDeclaration_ILoaderOptions());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ILoaderOptions\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_ILoaderOptions():\n TypeOnly<current.ILoaderOptions>;\ndeclare function use_old_InterfaceDeclaration_ILoaderOptions(\n use: TypeOnly<old.ILoaderOptions>): void;\nuse_old_InterfaceDeclaration_ILoaderOptions(\n get_current_InterfaceDeclaration_ILoaderOptions());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ILoaderProps\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_ILoaderProps():\n TypeOnly<old.ILoaderProps>;\ndeclare function use_current_InterfaceDeclaration_ILoaderProps(\n use: TypeOnly<current.ILoaderProps>): void;\nuse_current_InterfaceDeclaration_ILoaderProps(\n get_old_InterfaceDeclaration_ILoaderProps());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ILoaderProps\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_ILoaderProps():\n TypeOnly<current.ILoaderProps>;\ndeclare function use_old_InterfaceDeclaration_ILoaderProps(\n use: TypeOnly<old.ILoaderProps>): void;\nuse_old_InterfaceDeclaration_ILoaderProps(\n get_current_InterfaceDeclaration_ILoaderProps());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ILoaderServices\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_ILoaderServices():\n TypeOnly<old.ILoaderServices>;\ndeclare function use_current_InterfaceDeclaration_ILoaderServices(\n use: TypeOnly<current.ILoaderServices>): void;\nuse_current_InterfaceDeclaration_ILoaderServices(\n get_old_InterfaceDeclaration_ILoaderServices());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_ILoaderServices\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_ILoaderServices():\n TypeOnly<current.ILoaderServices>;\ndeclare function use_old_InterfaceDeclaration_ILoaderServices(\n use: TypeOnly<old.ILoaderServices>): void;\nuse_old_InterfaceDeclaration_ILoaderServices(\n get_current_InterfaceDeclaration_ILoaderServices());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IParsedUrl\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_IParsedUrl():\n TypeOnly<old.IParsedUrl>;\ndeclare function use_current_InterfaceDeclaration_IParsedUrl(\n use: TypeOnly<current.IParsedUrl>): void;\nuse_current_InterfaceDeclaration_IParsedUrl(\n // @ts-expect-error compatibility expected to be broken\n get_old_InterfaceDeclaration_IParsedUrl());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IParsedUrl\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_IParsedUrl():\n TypeOnly<current.IParsedUrl>;\ndeclare function use_old_InterfaceDeclaration_IParsedUrl(\n use: TypeOnly<old.IParsedUrl>): void;\nuse_old_InterfaceDeclaration_IParsedUrl(\n get_current_InterfaceDeclaration_IParsedUrl());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IProtocolHandler\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_InterfaceDeclaration_IProtocolHandler():\n TypeOnly<old.IProtocolHandler>;\ndeclare function use_current_InterfaceDeclaration_IProtocolHandler(\n use: TypeOnly<current.IProtocolHandler>): void;\nuse_current_InterfaceDeclaration_IProtocolHandler(\n get_old_InterfaceDeclaration_IProtocolHandler());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"InterfaceDeclaration_IProtocolHandler\": {\"backCompat\": false}\n*/\ndeclare function get_current_InterfaceDeclaration_IProtocolHandler():\n TypeOnly<current.IProtocolHandler>;\ndeclare function use_old_InterfaceDeclaration_IProtocolHandler(\n use: TypeOnly<old.IProtocolHandler>): void;\nuse_old_InterfaceDeclaration_IProtocolHandler(\n get_current_InterfaceDeclaration_IProtocolHandler());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_Loader\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_ClassDeclaration_Loader():\n TypeOnly<old.Loader>;\ndeclare function use_current_ClassDeclaration_Loader(\n use: TypeOnly<current.Loader>): void;\nuse_current_ClassDeclaration_Loader(\n get_old_ClassDeclaration_Loader());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"ClassDeclaration_Loader\": {\"backCompat\": false}\n*/\ndeclare function get_current_ClassDeclaration_Loader():\n TypeOnly<current.Loader>;\ndeclare function use_old_ClassDeclaration_Loader(\n use: TypeOnly<old.Loader>): void;\nuse_old_ClassDeclaration_Loader(\n get_current_ClassDeclaration_Loader());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"TypeAliasDeclaration_ProtocolHandlerBuilder\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_TypeAliasDeclaration_ProtocolHandlerBuilder():\n TypeOnly<old.ProtocolHandlerBuilder>;\ndeclare function use_current_TypeAliasDeclaration_ProtocolHandlerBuilder(\n use: TypeOnly<current.ProtocolHandlerBuilder>): void;\nuse_current_TypeAliasDeclaration_ProtocolHandlerBuilder(\n get_old_TypeAliasDeclaration_ProtocolHandlerBuilder());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"TypeAliasDeclaration_ProtocolHandlerBuilder\": {\"backCompat\": false}\n*/\ndeclare function get_current_TypeAliasDeclaration_ProtocolHandlerBuilder():\n TypeOnly<current.ProtocolHandlerBuilder>;\ndeclare function use_old_TypeAliasDeclaration_ProtocolHandlerBuilder(\n use: TypeOnly<old.ProtocolHandlerBuilder>): void;\nuse_old_TypeAliasDeclaration_ProtocolHandlerBuilder(\n get_current_TypeAliasDeclaration_ProtocolHandlerBuilder());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"FunctionDeclaration_isLocationRedirectionError\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_FunctionDeclaration_isLocationRedirectionError():\n TypeOnly<typeof old.isLocationRedirectionError>;\ndeclare function use_current_FunctionDeclaration_isLocationRedirectionError(\n use: TypeOnly<typeof current.isLocationRedirectionError>): void;\nuse_current_FunctionDeclaration_isLocationRedirectionError(\n get_old_FunctionDeclaration_isLocationRedirectionError());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"FunctionDeclaration_isLocationRedirectionError\": {\"backCompat\": false}\n*/\ndeclare function get_current_FunctionDeclaration_isLocationRedirectionError():\n TypeOnly<typeof current.isLocationRedirectionError>;\ndeclare function use_old_FunctionDeclaration_isLocationRedirectionError(\n use: TypeOnly<typeof old.isLocationRedirectionError>): void;\nuse_old_FunctionDeclaration_isLocationRedirectionError(\n get_current_FunctionDeclaration_isLocationRedirectionError());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"FunctionDeclaration_resolveWithLocationRedirectionHandling\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_FunctionDeclaration_resolveWithLocationRedirectionHandling():\n TypeOnly<typeof old.resolveWithLocationRedirectionHandling>;\ndeclare function use_current_FunctionDeclaration_resolveWithLocationRedirectionHandling(\n use: TypeOnly<typeof current.resolveWithLocationRedirectionHandling>): void;\nuse_current_FunctionDeclaration_resolveWithLocationRedirectionHandling(\n get_old_FunctionDeclaration_resolveWithLocationRedirectionHandling());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"FunctionDeclaration_resolveWithLocationRedirectionHandling\": {\"backCompat\": false}\n*/\ndeclare function get_current_FunctionDeclaration_resolveWithLocationRedirectionHandling():\n TypeOnly<typeof current.resolveWithLocationRedirectionHandling>;\ndeclare function use_old_FunctionDeclaration_resolveWithLocationRedirectionHandling(\n use: TypeOnly<typeof old.resolveWithLocationRedirectionHandling>): void;\nuse_old_FunctionDeclaration_resolveWithLocationRedirectionHandling(\n get_current_FunctionDeclaration_resolveWithLocationRedirectionHandling());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"FunctionDeclaration_tryParseCompatibleResolvedUrl\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_FunctionDeclaration_tryParseCompatibleResolvedUrl():\n TypeOnly<typeof old.tryParseCompatibleResolvedUrl>;\ndeclare function use_current_FunctionDeclaration_tryParseCompatibleResolvedUrl(\n use: TypeOnly<typeof current.tryParseCompatibleResolvedUrl>): void;\nuse_current_FunctionDeclaration_tryParseCompatibleResolvedUrl(\n get_old_FunctionDeclaration_tryParseCompatibleResolvedUrl());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"FunctionDeclaration_tryParseCompatibleResolvedUrl\": {\"backCompat\": false}\n*/\ndeclare function get_current_FunctionDeclaration_tryParseCompatibleResolvedUrl():\n TypeOnly<typeof current.tryParseCompatibleResolvedUrl>;\ndeclare function use_old_FunctionDeclaration_tryParseCompatibleResolvedUrl(\n use: TypeOnly<typeof old.tryParseCompatibleResolvedUrl>): void;\nuse_old_FunctionDeclaration_tryParseCompatibleResolvedUrl(\n get_current_FunctionDeclaration_tryParseCompatibleResolvedUrl());\n\n/*\n* Validate forward compat by using old type in place of current type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"FunctionDeclaration_waitContainerToCatchUp\": {\"forwardCompat\": false}\n*/\ndeclare function get_old_FunctionDeclaration_waitContainerToCatchUp():\n TypeOnly<typeof old.waitContainerToCatchUp>;\ndeclare function use_current_FunctionDeclaration_waitContainerToCatchUp(\n use: TypeOnly<typeof current.waitContainerToCatchUp>): void;\nuse_current_FunctionDeclaration_waitContainerToCatchUp(\n get_old_FunctionDeclaration_waitContainerToCatchUp());\n\n/*\n* Validate back compat by using current type in place of old type\n* If breaking change required, add in package.json under typeValidation.broken:\n* \"FunctionDeclaration_waitContainerToCatchUp\": {\"backCompat\": false}\n*/\ndeclare function get_current_FunctionDeclaration_waitContainerToCatchUp():\n TypeOnly<typeof current.waitContainerToCatchUp>;\ndeclare function use_old_FunctionDeclaration_waitContainerToCatchUp(\n use: TypeOnly<typeof old.waitContainerToCatchUp>): void;\nuse_old_FunctionDeclaration_waitContainerToCatchUp(\n get_current_FunctionDeclaration_waitContainerToCatchUp());\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { strict as assert } from "assert";
|
|
6
|
+
import { runSingle } from "../utils.js";
|
|
7
|
+
describe("container-loader utils", () => {
|
|
8
|
+
describe("runSingle", () => {
|
|
9
|
+
it("correctly calls internal func", async () => {
|
|
10
|
+
const wrappedFunc = runSingle(async (base, plus) => base + plus);
|
|
11
|
+
assert.strictEqual(await wrappedFunc(4, 1), 5);
|
|
12
|
+
});
|
|
13
|
+
it("returns same promise for same args", async () => {
|
|
14
|
+
const wrappedFunc = runSingle(async (base, plus) => base + plus);
|
|
15
|
+
const [p1, p2] = [wrappedFunc(4, 1), wrappedFunc(4, 1)];
|
|
16
|
+
assert.strictEqual(p2, p1);
|
|
17
|
+
assert.strictEqual(await p1, 5);
|
|
18
|
+
assert.strictEqual(await p2, 5);
|
|
19
|
+
});
|
|
20
|
+
it("fails for different args", async () => {
|
|
21
|
+
const wrappedFunc = runSingle(async (base, plus) => base + plus);
|
|
22
|
+
const [p1, p2] = [wrappedFunc(4, 1), wrappedFunc(4, 2)];
|
|
23
|
+
assert.notStrictEqual(p2, p1);
|
|
24
|
+
assert.strictEqual(await p1, 5);
|
|
25
|
+
await p2
|
|
26
|
+
.then(() => assert.fail("should fail"))
|
|
27
|
+
.catch((e) => assert.strictEqual(e.message, "Subsequent calls cannot use different arguments."));
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//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AG,SAAS,CAAC,KAAK,EAAE,IAAY,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;YAEjF,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAExD,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAC9B,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;YAChC,MAAM,EAAE;iBACN,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;iBACtC,KAAK,CAAC,CAAC,CAAQ,EAAE,EAAE,CACnB,MAAM,CAAC,WAAW,CACjB,CAAC,CAAC,OAAO,EACT,kDAAkD,CAClD,CACD,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"assert\";\nimport { runSingle } from \"../utils.js\";\n\ndescribe(\"container-loader utils\", () => {\n\tdescribe(\"runSingle\", () => {\n\t\tit(\"correctly calls internal func\", async () => {\n\t\t\tconst wrappedFunc = runSingle(async (base: number, plus: number) => base + plus);\n\n\t\t\tassert.strictEqual(await wrappedFunc(4, 1), 5);\n\t\t});\n\n\t\tit(\"returns same promise for same args\", async () => {\n\t\t\tconst wrappedFunc = runSingle(async (base: number, plus: number) => base + plus);\n\n\t\t\tconst [p1, p2] = [wrappedFunc(4, 1), wrappedFunc(4, 1)];\n\n\t\t\tassert.strictEqual(p2, p1);\n\t\t\tassert.strictEqual(await p1, 5);\n\t\t\tassert.strictEqual(await p2, 5);\n\t\t});\n\n\t\tit(\"fails for different args\", async () => {\n\t\t\tconst wrappedFunc = runSingle(async (base: number, plus: number) => base + plus);\n\n\t\t\tconst [p1, p2] = [wrappedFunc(4, 1), wrappedFunc(4, 2)];\n\n\t\t\tassert.notStrictEqual(p2, p1);\n\t\t\tassert.strictEqual(await p1, 5);\n\t\t\tawait p2\n\t\t\t\t.then(() => assert.fail(\"should fail\"))\n\t\t\t\t.catch((e: Error) =>\n\t\t\t\t\tassert.strictEqual(\n\t\t\t\t\t\te.message,\n\t\t\t\t\t\t\"Subsequent calls cannot use different arguments.\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t});\n\t});\n});\n"]}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ISummaryTree, ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
6
6
|
import { CombinedAppAndProtocolSummary, DeltaStreamConnectionForbiddenError } from "@fluidframework/driver-utils";
|
|
7
|
+
import { ISerializableBlobContents } from "./containerStorageAdapter.js";
|
|
8
|
+
import { IPendingDetachedContainerState } from "./container.js";
|
|
7
9
|
export interface ISnapshotTreeWithBlobContents extends ISnapshotTree {
|
|
8
10
|
blobsContents: {
|
|
9
11
|
[path: string]: ArrayBufferLike;
|
|
@@ -32,11 +34,10 @@ export interface IParsedUrl {
|
|
|
32
34
|
*/
|
|
33
35
|
query: string;
|
|
34
36
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* If needed, can add undefined which is treated by Container.load() as load latest snapshot.
|
|
37
|
+
* Undefined means load latest snapshot, otherwise it's version ID passed to IDocumentStorageService.getVersions()
|
|
38
|
+
* to figure out what snapshot to use.
|
|
38
39
|
*/
|
|
39
|
-
version: string |
|
|
40
|
+
version: string | undefined;
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
42
43
|
* Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get
|
|
@@ -55,13 +56,17 @@ export declare function tryParseCompatibleResolvedUrl(url: string): IParsedUrl |
|
|
|
55
56
|
* @internal
|
|
56
57
|
*/
|
|
57
58
|
export declare function combineAppAndProtocolSummary(appSummary: ISummaryTree, protocolSummary: ISummaryTree): CombinedAppAndProtocolSummary;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*/
|
|
63
|
-
export declare function convertProtocolAndAppSummaryToSnapshotTree(protocolSummaryTree: ISummaryTree, appSummaryTree: ISummaryTree): ISnapshotTreeWithBlobContents;
|
|
64
|
-
export declare const getSnapshotTreeFromSerializedContainer: (detachedContainerSnapshot: ISummaryTree) => ISnapshotTreeWithBlobContents;
|
|
59
|
+
export declare const getSnapshotTreeAndBlobsFromSerializedContainer: (detachedContainerSnapshot: ISummaryTree) => {
|
|
60
|
+
tree: ISnapshotTree;
|
|
61
|
+
blobs: ISerializableBlobContents;
|
|
62
|
+
};
|
|
65
63
|
export declare function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree;
|
|
64
|
+
export declare const combineSnapshotTreeAndSnapshotBlobs: (baseSnapshot: ISnapshotTree, snapshotBlobs: ISerializableBlobContents) => ISnapshotTreeWithBlobContents;
|
|
66
65
|
export declare function isDeltaStreamConnectionForbiddenError(error: any): error is DeltaStreamConnectionForbiddenError;
|
|
67
|
-
|
|
66
|
+
export declare function getDetachedContainerStateFromSerializedContainer(serializedContainer: string): IPendingDetachedContainerState;
|
|
67
|
+
/**
|
|
68
|
+
* Ensures only a single instance of the provided async function is running.
|
|
69
|
+
* If there are multiple calls they will all get the same promise to wait on.
|
|
70
|
+
*/
|
|
71
|
+
export declare const runSingle: <A extends any[], R>(func: (...args: A) => Promise<R>) => (...args: A) => Promise<R>;
|
|
72
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAe,MAAM,sCAAsC,CAAC;AAEhG,OAAO,EACN,6BA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eAAO,MAAM,SAAS,sFAsBrB,CAAC"}
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { v4 as uuid } from "uuid";
|
|
6
|
+
import { Uint8ArrayToString, stringToBuffer } from "@fluid-internal/client-utils";
|
|
7
|
+
import { assert, compareArrays, unreachableCase } from "@fluidframework/core-utils";
|
|
8
|
+
import { SummaryType } from "@fluidframework/protocol-definitions";
|
|
9
|
+
import { LoggingError, UsageError } from "@fluidframework/telemetry-utils";
|
|
10
|
+
import { isCombinedAppAndProtocolSummary, } from "@fluidframework/driver-utils";
|
|
11
|
+
import { DriverErrorTypes } from "@fluidframework/driver-definitions";
|
|
12
|
+
/**
|
|
13
|
+
* Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get
|
|
14
|
+
* deep link info etc.
|
|
15
|
+
* Warning - This function may not be compatible with any Url Resolver's resolved url. It works
|
|
16
|
+
* with urls of type: protocol://<string>/.../..?<querystring>
|
|
17
|
+
* @param url - This is the IResolvedUrl.url part of the resolved url.
|
|
18
|
+
* @returns The IParsedUrl representing the input URL, or undefined if the format was not supported
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export function tryParseCompatibleResolvedUrl(url) {
|
|
22
|
+
const parsed = new URL(url);
|
|
23
|
+
if (typeof parsed.pathname !== "string") {
|
|
24
|
+
throw new LoggingError("Failed to parse pathname");
|
|
25
|
+
}
|
|
26
|
+
const query = parsed.search ?? "";
|
|
27
|
+
const regex = /^\/([^/]*\/[^/]*)(\/?.*)$/;
|
|
28
|
+
const match = regex.exec(parsed.pathname);
|
|
29
|
+
return match?.length === 3
|
|
30
|
+
? {
|
|
31
|
+
id: match[1],
|
|
32
|
+
path: match[2],
|
|
33
|
+
query,
|
|
34
|
+
// URLSearchParams returns null if the param is not provided.
|
|
35
|
+
version: parsed.searchParams.get("version") ?? undefined,
|
|
36
|
+
}
|
|
37
|
+
: undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Combine the app summary and protocol summary in 1 tree.
|
|
41
|
+
* @param appSummary - Summary of the app.
|
|
42
|
+
* @param protocolSummary - Summary of the protocol.
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export function combineAppAndProtocolSummary(appSummary, protocolSummary) {
|
|
46
|
+
assert(!isCombinedAppAndProtocolSummary(appSummary), 0x5a8 /* app summary is already a combined tree! */);
|
|
47
|
+
assert(!isCombinedAppAndProtocolSummary(protocolSummary), 0x5a9 /* protocol summary is already a combined tree! */);
|
|
48
|
+
const createNewSummary = {
|
|
49
|
+
type: SummaryType.Tree,
|
|
50
|
+
tree: {
|
|
51
|
+
".protocol": protocolSummary,
|
|
52
|
+
".app": appSummary,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
return createNewSummary;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Converts a summary to snapshot tree and separate its blob contents
|
|
59
|
+
* to align detached container format with IPendingContainerState
|
|
60
|
+
* @param summary - ISummaryTree
|
|
61
|
+
*/
|
|
62
|
+
function convertSummaryToSnapshotAndBlobs(summary) {
|
|
63
|
+
let blobContents = {};
|
|
64
|
+
const treeNode = {
|
|
65
|
+
blobs: {},
|
|
66
|
+
trees: {},
|
|
67
|
+
id: uuid(),
|
|
68
|
+
unreferenced: summary.unreferenced,
|
|
69
|
+
groupId: summary.groupId,
|
|
70
|
+
};
|
|
71
|
+
const keys = Object.keys(summary.tree);
|
|
72
|
+
for (const key of keys) {
|
|
73
|
+
const summaryObject = summary.tree[key];
|
|
74
|
+
switch (summaryObject.type) {
|
|
75
|
+
case SummaryType.Tree: {
|
|
76
|
+
const { tree, blobs } = convertSummaryToSnapshotAndBlobs(summaryObject);
|
|
77
|
+
treeNode.trees[key] = tree;
|
|
78
|
+
blobContents = { ...blobContents, ...blobs };
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case SummaryType.Attachment:
|
|
82
|
+
treeNode.blobs[key] = summaryObject.id;
|
|
83
|
+
break;
|
|
84
|
+
case SummaryType.Blob: {
|
|
85
|
+
const blobId = uuid();
|
|
86
|
+
treeNode.blobs[key] = blobId;
|
|
87
|
+
const contentString = summaryObject.content instanceof Uint8Array
|
|
88
|
+
? Uint8ArrayToString(summaryObject.content)
|
|
89
|
+
: summaryObject.content;
|
|
90
|
+
blobContents[blobId] = contentString;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case SummaryType.Handle:
|
|
94
|
+
throw new LoggingError("No handles should be there in summary in detached container!!");
|
|
95
|
+
break;
|
|
96
|
+
default: {
|
|
97
|
+
unreachableCase(summaryObject, `Unknown tree type ${summaryObject.type}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return { tree: treeNode, blobs: blobContents };
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Converts summary parts into a SnapshotTree and its blob contents.
|
|
105
|
+
* @param protocolSummaryTree - Protocol Summary Tree
|
|
106
|
+
* @param appSummaryTree - App Summary Tree
|
|
107
|
+
*/
|
|
108
|
+
function convertProtocolAndAppSummaryToSnapshotAndBlobs(protocolSummaryTree, appSummaryTree) {
|
|
109
|
+
const combinedSummary = {
|
|
110
|
+
type: SummaryType.Tree,
|
|
111
|
+
tree: { ...appSummaryTree.tree },
|
|
112
|
+
};
|
|
113
|
+
combinedSummary.tree[".protocol"] = protocolSummaryTree;
|
|
114
|
+
const snapshotTreeWithBlobContents = convertSummaryToSnapshotAndBlobs(combinedSummary);
|
|
115
|
+
return snapshotTreeWithBlobContents;
|
|
116
|
+
}
|
|
117
|
+
export const getSnapshotTreeAndBlobsFromSerializedContainer = (detachedContainerSnapshot) => {
|
|
118
|
+
assert(isCombinedAppAndProtocolSummary(detachedContainerSnapshot), 0x8e6 /* Protocol and App summary trees should be present */);
|
|
119
|
+
const protocolSummaryTree = detachedContainerSnapshot.tree[".protocol"];
|
|
120
|
+
const appSummaryTree = detachedContainerSnapshot.tree[".app"];
|
|
121
|
+
const snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotAndBlobs(protocolSummaryTree, appSummaryTree);
|
|
122
|
+
return snapshotTreeWithBlobContents;
|
|
123
|
+
};
|
|
124
|
+
export function getProtocolSnapshotTree(snapshot) {
|
|
125
|
+
return ".protocol" in snapshot.trees ? snapshot.trees[".protocol"] : snapshot;
|
|
126
|
+
}
|
|
127
|
+
export const combineSnapshotTreeAndSnapshotBlobs = (baseSnapshot, snapshotBlobs) => {
|
|
128
|
+
const blobsContents = {};
|
|
129
|
+
// Process blobs in the current level
|
|
130
|
+
for (const [, id] of Object.entries(baseSnapshot.blobs)) {
|
|
131
|
+
if (snapshotBlobs[id]) {
|
|
132
|
+
blobsContents[id] = stringToBuffer(snapshotBlobs[id], "utf8");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Recursively process trees in the current level
|
|
136
|
+
const trees = {};
|
|
137
|
+
for (const [path, tree] of Object.entries(baseSnapshot.trees)) {
|
|
138
|
+
trees[path] = combineSnapshotTreeAndSnapshotBlobs(tree, snapshotBlobs);
|
|
139
|
+
}
|
|
140
|
+
// Create a new snapshot tree with blob contents and processed trees
|
|
141
|
+
const snapshotTreeWithBlobContents = {
|
|
142
|
+
...baseSnapshot,
|
|
143
|
+
blobsContents,
|
|
144
|
+
trees,
|
|
145
|
+
};
|
|
146
|
+
return snapshotTreeWithBlobContents;
|
|
147
|
+
};
|
|
148
|
+
export function isDeltaStreamConnectionForbiddenError(error) {
|
|
149
|
+
return (typeof error === "object" &&
|
|
150
|
+
error !== null &&
|
|
151
|
+
error?.errorType === DriverErrorTypes.deltaStreamConnectionForbidden);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Validates format in parsed string get from detached container
|
|
155
|
+
* serialization using IPendingDetachedContainerState format.
|
|
156
|
+
*/
|
|
157
|
+
function isPendingDetachedContainerState(detachedContainerState) {
|
|
158
|
+
if (detachedContainerState?.attached === undefined ||
|
|
159
|
+
detachedContainerState?.baseSnapshot === undefined ||
|
|
160
|
+
detachedContainerState?.snapshotBlobs === undefined ||
|
|
161
|
+
detachedContainerState?.hasAttachmentBlobs === undefined) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
export function getDetachedContainerStateFromSerializedContainer(serializedContainer) {
|
|
167
|
+
const hasBlobsSummaryTree = ".hasAttachmentBlobs";
|
|
168
|
+
const parsedContainerState = JSON.parse(serializedContainer);
|
|
169
|
+
if (isPendingDetachedContainerState(parsedContainerState)) {
|
|
170
|
+
return parsedContainerState;
|
|
171
|
+
}
|
|
172
|
+
else if (isCombinedAppAndProtocolSummary(parsedContainerState)) {
|
|
173
|
+
const { tree, blobs } = getSnapshotTreeAndBlobsFromSerializedContainer(parsedContainerState);
|
|
174
|
+
const detachedContainerState = {
|
|
175
|
+
attached: false,
|
|
176
|
+
baseSnapshot: tree,
|
|
177
|
+
snapshotBlobs: blobs,
|
|
178
|
+
hasAttachmentBlobs: parsedContainerState.tree[hasBlobsSummaryTree] !== undefined,
|
|
179
|
+
};
|
|
180
|
+
return detachedContainerState;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
throw new UsageError("Cannot rehydrate detached container. Incorrect format");
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Ensures only a single instance of the provided async function is running.
|
|
188
|
+
* If there are multiple calls they will all get the same promise to wait on.
|
|
189
|
+
*/
|
|
190
|
+
export const runSingle = (func) => {
|
|
191
|
+
let running;
|
|
192
|
+
// don't mark this function async, so we return the same promise,
|
|
193
|
+
// rather than one that is wrapped due to async
|
|
194
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
195
|
+
return (...args) => {
|
|
196
|
+
if (running !== undefined) {
|
|
197
|
+
if (!compareArrays(running.args, args)) {
|
|
198
|
+
return Promise.reject(new UsageError("Subsequent calls cannot use different arguments."));
|
|
199
|
+
}
|
|
200
|
+
return running.result;
|
|
201
|
+
}
|
|
202
|
+
running = { args, result: func(...args).finally(() => (running = undefined)) };
|
|
203
|
+
return running.result;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAA+B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAGN,+BAA+B,GAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAqCtE;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAAC,GAAW;IACxD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;QACxC,MAAM,IAAI,YAAY,CAAC,0BAA0B,CAAC,CAAC;KACnD;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,2BAA2B,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,KAAK,E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I,CAAC,mBAAmB,CAAC,KAAK,SAAS;SAChF,CAAC;QACF,OAAO,sBAAsB,CAAC;KAC9B;SAAM;QACN,MAAM,IAAI,UAAU,CAAC,uDAAuD,CAAC,CAAC;KAC9E;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAqB,IAAgC,EAAE,EAAE;IACjF,IAAI,OAKQ,CAAC;IACb,iEAAiE;IACjE,+CAA+C;IAC/C,qEAAqE;IACrE,OAAO,CAAC,GAAG,IAAO,EAAE,EAAE;QACrB,IAAI,OAAO,KAAK,SAAS,EAAE;YAC1B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE;gBACvC,OAAO,OAAO,CAAC,MAAM,CACpB,IAAI,UAAU,CAAC,kDAAkD,CAAC,CAClE,CAAC;aACF;YACD,OAAO,OAAO,CAAC,MAAM,CAAC;SACtB;QACD,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC;QAC/E,OAAO,OAAO,CAAC,MAAM,CAAC;IACvB,CAAC,CAAC;AACH,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { Uint8ArrayToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, compareArrays, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISummaryTree, ISnapshotTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { LoggingError, UsageError } from \"@fluidframework/telemetry-utils\";\nimport {\n\tCombinedAppAndProtocolSummary,\n\tDeltaStreamConnectionForbiddenError,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\nimport { ISerializableBlobContents } from \"./containerStorageAdapter.js\";\nimport { IPendingDetachedContainerState } from \"./container.js\";\n\n// This is used when we rehydrate a container from the snapshot. Here we put the blob contents\n// in separate property: blobContents.\nexport interface ISnapshotTreeWithBlobContents extends ISnapshotTree {\n\tblobsContents: { [path: string]: ArrayBufferLike };\n\ttrees: { [path: string]: ISnapshotTreeWithBlobContents };\n}\n\n/**\n * Interface to represent the parsed parts of IResolvedUrl.url to help\n * in getting info about different parts of the url.\n * May not be compatible or relevant for any Url Resolver\n * @internal\n */\nexport interface IParsedUrl {\n\t/**\n\t * It is combination of tenantid/docId part of the url.\n\t */\n\tid: string;\n\t/**\n\t * It is the deep link path in the url.\n\t */\n\tpath: string;\n\t/**\n\t * Query string part of the url.\n\t */\n\tquery: string;\n\t/**\n\t * Undefined means load latest snapshot, otherwise it's version ID passed to IDocumentStorageService.getVersions()\n\t * to figure out what snapshot to use.\n\t */\n\tversion: string | undefined;\n}\n\n/**\n * Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get\n * deep link info etc.\n * Warning - This function may not be compatible with any Url Resolver's resolved url. It works\n * with urls of type: protocol://<string>/.../..?<querystring>\n * @param url - This is the IResolvedUrl.url part of the resolved url.\n * @returns The IParsedUrl representing the input URL, or undefined if the format was not supported\n * @internal\n */\nexport function tryParseCompatibleResolvedUrl(url: string): IParsedUrl | undefined {\n\tconst parsed = new URL(url);\n\tif (typeof parsed.pathname !== \"string\") {\n\t\tthrow new LoggingError(\"Failed to parse pathname\");\n\t}\n\tconst query = parsed.search ?? \"\";\n\tconst regex = /^\\/([^/]*\\/[^/]*)(\\/?.*)$/;\n\tconst match = regex.exec(parsed.pathname);\n\treturn match?.length === 3\n\t\t? {\n\t\t\t\tid: match[1],\n\t\t\t\tpath: match[2],\n\t\t\t\tquery,\n\t\t\t\t// URLSearchParams returns null if the param is not provided.\n\t\t\t\tversion: parsed.searchParams.get(\"version\") ?? undefined,\n\t\t }\n\t\t: undefined;\n}\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n * @internal\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): CombinedAppAndProtocolSummary {\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(appSummary),\n\t\t0x5a8 /* app summary is already a combined tree! */,\n\t);\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(protocolSummary),\n\t\t0x5a9 /* protocol summary is already a combined tree! */,\n\t);\n\tconst createNewSummary: CombinedAppAndProtocolSummary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Converts a summary to snapshot tree and separate its blob contents\n * to align detached container format with IPendingContainerState\n * @param summary - ISummaryTree\n */\nfunction convertSummaryToSnapshotAndBlobs(summary: ISummaryTree): {\n\ttree: ISnapshotTree;\n\tblobs: ISerializableBlobContents;\n} {\n\tlet blobContents: ISerializableBlobContents = {};\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tid: uuid(),\n\t\tunreferenced: summary.unreferenced,\n\t\tgroupId: summary.groupId,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tconst { tree, blobs } = convertSummaryToSnapshotAndBlobs(summaryObject);\n\t\t\t\ttreeNode.trees[key] = tree;\n\t\t\t\tblobContents = { ...blobContents, ...blobs };\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Attachment:\n\t\t\t\ttreeNode.blobs[key] = summaryObject.id;\n\t\t\t\tbreak;\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tconst contentString: string =\n\t\t\t\t\tsummaryObject.content instanceof Uint8Array\n\t\t\t\t\t\t? Uint8ArrayToString(summaryObject.content)\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tblobContents[blobId] = contentString;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\"No handles should be there in summary in detached container!!\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn { tree: treeNode, blobs: blobContents };\n}\n\n/**\n * Converts summary parts into a SnapshotTree and its blob contents.\n * @param protocolSummaryTree - Protocol Summary Tree\n * @param appSummaryTree - App Summary Tree\n */\nfunction convertProtocolAndAppSummaryToSnapshotAndBlobs(\n\tprotocolSummaryTree: ISummaryTree,\n\tappSummaryTree: ISummaryTree,\n): { tree: ISnapshotTree; blobs: ISerializableBlobContents } {\n\tconst combinedSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: { ...appSummaryTree.tree },\n\t};\n\n\tcombinedSummary.tree[\".protocol\"] = protocolSummaryTree;\n\tconst snapshotTreeWithBlobContents = convertSummaryToSnapshotAndBlobs(combinedSummary);\n\treturn snapshotTreeWithBlobContents;\n}\n\nexport const getSnapshotTreeAndBlobsFromSerializedContainer = (\n\tdetachedContainerSnapshot: ISummaryTree,\n): { tree: ISnapshotTree; blobs: ISerializableBlobContents } => {\n\tassert(\n\t\tisCombinedAppAndProtocolSummary(detachedContainerSnapshot),\n\t\t0x8e6 /* Protocol and App summary trees should be present */,\n\t);\n\tconst protocolSummaryTree = detachedContainerSnapshot.tree[\".protocol\"];\n\tconst appSummaryTree = detachedContainerSnapshot.tree[\".app\"];\n\tconst snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotAndBlobs(\n\t\tprotocolSummaryTree,\n\t\tappSummaryTree,\n\t);\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree {\n\treturn \".protocol\" in snapshot.trees ? snapshot.trees[\".protocol\"] : snapshot;\n}\n\nexport const combineSnapshotTreeAndSnapshotBlobs = (\n\tbaseSnapshot: ISnapshotTree,\n\tsnapshotBlobs: ISerializableBlobContents,\n): ISnapshotTreeWithBlobContents => {\n\tconst blobsContents: { [path: string]: ArrayBufferLike } = {};\n\n\t// Process blobs in the current level\n\tfor (const [, id] of Object.entries(baseSnapshot.blobs)) {\n\t\tif (snapshotBlobs[id]) {\n\t\t\tblobsContents[id] = stringToBuffer(snapshotBlobs[id], \"utf8\");\n\t\t}\n\t}\n\n\t// Recursively process trees in the current level\n\tconst trees: { [path: string]: ISnapshotTreeWithBlobContents } = {};\n\tfor (const [path, tree] of Object.entries(baseSnapshot.trees)) {\n\t\ttrees[path] = combineSnapshotTreeAndSnapshotBlobs(tree, snapshotBlobs);\n\t}\n\n\t// Create a new snapshot tree with blob contents and processed trees\n\tconst snapshotTreeWithBlobContents: ISnapshotTreeWithBlobContents = {\n\t\t...baseSnapshot,\n\t\tblobsContents,\n\t\ttrees,\n\t};\n\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function isDeltaStreamConnectionForbiddenError(\n\terror: any,\n): error is DeltaStreamConnectionForbiddenError {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\terror?.errorType === DriverErrorTypes.deltaStreamConnectionForbidden\n\t);\n}\n\n/**\n * Validates format in parsed string get from detached container\n * serialization using IPendingDetachedContainerState format.\n */\nfunction isPendingDetachedContainerState(\n\tdetachedContainerState: IPendingDetachedContainerState,\n): detachedContainerState is IPendingDetachedContainerState {\n\tif (\n\t\tdetachedContainerState?.attached === undefined ||\n\t\tdetachedContainerState?.baseSnapshot === undefined ||\n\t\tdetachedContainerState?.snapshotBlobs === undefined ||\n\t\tdetachedContainerState?.hasAttachmentBlobs === undefined\n\t) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nexport function getDetachedContainerStateFromSerializedContainer(\n\tserializedContainer: string,\n): IPendingDetachedContainerState {\n\tconst hasBlobsSummaryTree = \".hasAttachmentBlobs\";\n\tconst parsedContainerState = JSON.parse(serializedContainer);\n\tif (isPendingDetachedContainerState(parsedContainerState)) {\n\t\treturn parsedContainerState;\n\t} else if (isCombinedAppAndProtocolSummary(parsedContainerState)) {\n\t\tconst { tree, blobs } =\n\t\t\tgetSnapshotTreeAndBlobsFromSerializedContainer(parsedContainerState);\n\t\tconst detachedContainerState: IPendingDetachedContainerState = {\n\t\t\tattached: false,\n\t\t\tbaseSnapshot: tree,\n\t\t\tsnapshotBlobs: blobs,\n\t\t\thasAttachmentBlobs: parsedContainerState.tree[hasBlobsSummaryTree] !== undefined,\n\t\t};\n\t\treturn detachedContainerState;\n\t} else {\n\t\tthrow new UsageError(\"Cannot rehydrate detached container. Incorrect format\");\n\t}\n}\n\n/**\n * Ensures only a single instance of the provided async function is running.\n * If there are multiple calls they will all get the same promise to wait on.\n */\nexport const runSingle = <A extends any[], R>(func: (...args: A) => Promise<R>) => {\n\tlet running:\n\t\t| {\n\t\t\t\targs: A;\n\t\t\t\tresult: Promise<R>;\n\t\t }\n\t\t| undefined;\n\t// don't mark this function async, so we return the same promise,\n\t// rather than one that is wrapped due to async\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\treturn (...args: A) => {\n\t\tif (running !== undefined) {\n\t\t\tif (!compareArrays(running.args, args)) {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew UsageError(\"Subsequent calls cannot use different arguments.\"),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn running.result;\n\t\t}\n\t\trunning = { args, result: func(...args).finally(() => (running = undefined)) };\n\t\treturn running.result;\n\t};\n};\n"]}
|