@fluidframework/driver-utils 2.0.0-rc.2.0.1 → 2.0.0-rc.3.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/CHANGELOG.md +23 -0
- package/api-report/driver-utils.api.md +18 -18
- package/dist/adapters/compression/documentServiceCompressionAdapter.d.ts +1 -1
- package/dist/adapters/compression/documentServiceCompressionAdapter.d.ts.map +1 -1
- package/dist/adapters/compression/documentServiceCompressionAdapter.js.map +1 -1
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts +1 -1
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts.map +1 -1
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.js +1 -1
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.js.map +1 -1
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +2 -2
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +7 -7
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
- package/dist/adapters/predefinedAdapters.d.ts +1 -1
- package/dist/adapters/predefinedAdapters.d.ts.map +1 -1
- package/dist/adapters/predefinedAdapters.js +2 -2
- package/dist/adapters/predefinedAdapters.js.map +1 -1
- package/dist/blob.d.ts +1 -1
- package/dist/blob.d.ts.map +1 -1
- package/dist/blob.js.map +1 -1
- package/dist/buildSnapshotTree.d.ts.map +1 -1
- package/dist/buildSnapshotTree.js +3 -3
- package/dist/buildSnapshotTree.js.map +1 -1
- package/dist/documentServiceFactoryProxy.d.ts +1 -1
- package/dist/documentServiceFactoryProxy.d.ts.map +1 -1
- package/dist/documentServiceFactoryProxy.js.map +1 -1
- package/dist/documentServiceProxy.d.ts +1 -1
- package/dist/documentServiceProxy.d.ts.map +1 -1
- package/dist/documentServiceProxy.js.map +1 -1
- package/dist/documentStorageServiceProxy.d.ts +1 -1
- package/dist/documentStorageServiceProxy.d.ts.map +1 -1
- package/dist/documentStorageServiceProxy.js +2 -2
- package/dist/documentStorageServiceProxy.js.map +1 -1
- package/dist/error.d.ts +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +2 -2
- package/dist/error.js.map +1 -1
- package/dist/insecureUrlResolver.d.ts +1 -1
- package/dist/insecureUrlResolver.d.ts.map +1 -1
- package/dist/insecureUrlResolver.js +5 -5
- package/dist/insecureUrlResolver.js.map +1 -1
- package/dist/legacy.d.ts +18 -0
- package/dist/messageRecognition.d.ts.map +1 -1
- package/dist/messageRecognition.js +2 -2
- package/dist/messageRecognition.js.map +1 -1
- package/dist/network.d.ts +3 -2
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +8 -8
- package/dist/network.js.map +1 -1
- package/dist/networkUtils.d.ts +1 -1
- package/dist/networkUtils.d.ts.map +1 -1
- package/dist/networkUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/parallelRequests.d.ts +6 -2
- package/dist/parallelRequests.d.ts.map +1 -1
- package/dist/parallelRequests.js +31 -31
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.d.ts +1 -1
- package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
- package/dist/prefetchDocumentStorageService.js +4 -4
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/public.d.ts +15 -0
- package/dist/rateLimiter.js +2 -2
- package/dist/rateLimiter.js.map +1 -1
- package/dist/readAndParse.d.ts +1 -1
- package/dist/readAndParse.d.ts.map +1 -1
- package/dist/readAndParse.js.map +1 -1
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/runWithRetry.js +4 -4
- package/dist/runWithRetry.js.map +1 -1
- package/dist/storageUtils.d.ts +1 -1
- package/dist/storageUtils.d.ts.map +1 -1
- package/dist/storageUtils.js.map +1 -1
- package/dist/summaryForCreateNew.d.ts +1 -1
- package/dist/summaryForCreateNew.d.ts.map +1 -1
- package/dist/summaryForCreateNew.js.map +1 -1
- package/dist/treeConversions.d.ts.map +1 -1
- package/dist/treeConversions.js +2 -2
- package/dist/treeConversions.js.map +1 -1
- package/internal.d.ts +11 -0
- package/legacy.d.ts +11 -0
- package/lib/adapters/compression/documentServiceCompressionAdapter.d.ts +1 -1
- package/lib/adapters/compression/documentServiceCompressionAdapter.d.ts.map +1 -1
- package/lib/adapters/compression/documentServiceCompressionAdapter.js.map +1 -1
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts +1 -1
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.d.ts.map +1 -1
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.js +1 -1
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.js.map +1 -1
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +2 -2
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +2 -2
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
- package/lib/adapters/predefinedAdapters.d.ts +1 -1
- package/lib/adapters/predefinedAdapters.d.ts.map +1 -1
- package/lib/adapters/predefinedAdapters.js +2 -2
- package/lib/adapters/predefinedAdapters.js.map +1 -1
- package/lib/blob.d.ts +1 -1
- package/lib/blob.d.ts.map +1 -1
- package/lib/blob.js.map +1 -1
- package/lib/buildSnapshotTree.d.ts.map +1 -1
- package/lib/buildSnapshotTree.js +2 -2
- package/lib/buildSnapshotTree.js.map +1 -1
- package/lib/documentServiceFactoryProxy.d.ts +1 -1
- package/lib/documentServiceFactoryProxy.d.ts.map +1 -1
- package/lib/documentServiceFactoryProxy.js.map +1 -1
- package/lib/documentServiceProxy.d.ts +1 -1
- package/lib/documentServiceProxy.d.ts.map +1 -1
- package/lib/documentServiceProxy.js.map +1 -1
- package/lib/documentStorageServiceProxy.d.ts +1 -1
- package/lib/documentStorageServiceProxy.d.ts.map +1 -1
- package/lib/documentStorageServiceProxy.js +1 -1
- package/lib/documentStorageServiceProxy.js.map +1 -1
- package/lib/error.d.ts +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js +1 -1
- package/lib/error.js.map +1 -1
- package/lib/insecureUrlResolver.d.ts +1 -1
- package/lib/insecureUrlResolver.d.ts.map +1 -1
- package/lib/insecureUrlResolver.js +2 -2
- package/lib/insecureUrlResolver.js.map +1 -1
- package/lib/legacy.d.ts +18 -0
- package/lib/messageRecognition.d.ts.map +1 -1
- package/lib/messageRecognition.js.map +1 -1
- package/lib/network.d.ts +3 -2
- package/lib/network.d.ts.map +1 -1
- package/lib/network.js +2 -2
- package/lib/network.js.map +1 -1
- package/lib/networkUtils.d.ts +1 -1
- package/lib/networkUtils.d.ts.map +1 -1
- package/lib/networkUtils.js +1 -1
- package/lib/networkUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/parallelRequests.d.ts +6 -2
- package/lib/parallelRequests.d.ts.map +1 -1
- package/lib/parallelRequests.js +3 -3
- package/lib/parallelRequests.js.map +1 -1
- package/lib/prefetchDocumentStorageService.d.ts +1 -1
- package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
- package/lib/prefetchDocumentStorageService.js +1 -1
- package/lib/prefetchDocumentStorageService.js.map +1 -1
- package/lib/public.d.ts +15 -0
- package/lib/rateLimiter.js +1 -1
- package/lib/rateLimiter.js.map +1 -1
- package/lib/readAndParse.d.ts +1 -1
- package/lib/readAndParse.d.ts.map +1 -1
- package/lib/readAndParse.js.map +1 -1
- package/lib/runWithRetry.d.ts.map +1 -1
- package/lib/runWithRetry.js +3 -3
- package/lib/runWithRetry.js.map +1 -1
- package/lib/storageUtils.d.ts +1 -1
- package/lib/storageUtils.d.ts.map +1 -1
- package/lib/storageUtils.js.map +1 -1
- package/lib/summaryForCreateNew.d.ts +1 -1
- package/lib/summaryForCreateNew.d.ts.map +1 -1
- package/lib/summaryForCreateNew.js.map +1 -1
- package/lib/treeConversions.d.ts.map +1 -1
- package/lib/treeConversions.js +1 -1
- package/lib/treeConversions.js.map +1 -1
- package/package.json +29 -50
- package/src/adapters/compression/documentServiceCompressionAdapter.ts +7 -2
- package/src/adapters/compression/documentServiceFactoryCompressionAdapter.ts +4 -2
- package/src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts +7 -3
- package/src/adapters/predefinedAdapters.ts +4 -3
- package/src/blob.ts +1 -1
- package/src/buildSnapshotTree.ts +2 -2
- package/src/documentServiceFactoryProxy.ts +1 -1
- package/src/documentServiceProxy.ts +1 -1
- package/src/documentStorageServiceProxy.ts +2 -2
- package/src/error.ts +1 -1
- package/src/insecureUrlResolver.ts +6 -2
- package/src/messageRecognition.ts +1 -0
- package/src/network.ts +5 -6
- package/src/networkUtils.ts +3 -2
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +11 -4
- package/src/prefetchDocumentStorageService.ts +3 -1
- package/src/rateLimiter.ts +1 -1
- package/src/readAndParse.ts +1 -1
- package/src/runWithRetry.ts +5 -3
- package/src/storageUtils.ts +1 -1
- package/src/summaryForCreateNew.ts +3 -3
- package/src/treeConversions.ts +2 -1
- package/api-extractor-cjs.json +0 -8
- package/dist/driver-utils-alpha.d.ts +0 -167
- package/dist/driver-utils-beta.d.ts +0 -186
- package/dist/driver-utils-public.d.ts +0 -186
- package/dist/driver-utils-untrimmed.d.ts +0 -603
- package/lib/driver-utils-alpha.d.ts +0 -167
- package/lib/driver-utils-beta.d.ts +0 -186
- package/lib/driver-utils-public.d.ts +0 -186
- package/lib/driver-utils-untrimmed.d.ts +0 -603
- package/lib/test/insecureUrlResolverTest.spec.js +0 -101
- package/lib/test/insecureUrlResolverTest.spec.js.map +0 -1
- package/lib/test/parallelRequests.spec.js +0 -186
- package/lib/test/parallelRequests.spec.js.map +0 -1
- package/lib/test/rateLimiter.spec.js +0 -85
- package/lib/test/rateLimiter.spec.js.map +0 -1
- package/lib/test/runWithRetry.spec.js +0 -180
- package/lib/test/runWithRetry.spec.js.map +0 -1
- package/lib/test/summaryCompressionData.js +0 -170
- package/lib/test/summaryCompressionData.js.map +0 -1
- package/lib/test/summaryCompresssionTester.spec.js +0 -429
- package/lib/test/summaryCompresssionTester.spec.js.map +0 -1
- package/lib/test/types/validateDriverUtilsPrevious.generated.js +0 -108
- package/lib/test/types/validateDriverUtilsPrevious.generated.js.map +0 -1
- /package/{dist → lib}/tsdoc-metadata.json +0 -0
package/dist/runWithRetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH
|
|
1
|
+
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA2D;AAC3D,kEAA4D;AAC5D,2EAAsE;AAEtE,uEAAwE;AAExE,6CAA0F;AAC1F,2DAAiD;AAmCjD;;GAEG;AACI,KAAK,UAAU,YAAY,CACjC,GAAyC,EACzC,aAAqB,EACrB,MAA2B,EAC3B,QAAmB;IAEnB,IAAI,MAAqB,CAAC;IAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,8GAA8G;IAC9G,IAAI,YAAY,GAAG,GAAG,CAAC,CAAC,sBAAsB;IAC9C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,SAAS,GAAG,0BAAW,CAAC,GAAG,EAAE,CAAC;IACpC,IAAI,SAAc,CAAC;IACnB,GAAG;QACF,IAAI;YACH,MAAM,GAAG,MAAM,GAAG,CAAC,Q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AAY,EAAE,GAAG,CAAC,CAAC;YACvD,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACrB,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;aACpC;YACD,MAAM,IAAA,gBAAK,EAAC,YAAY,CAAC,CAAC;SAC1B;KACD,QAAQ,CAAC,OAAO,EAAE;IACnB,IAAI,UAAU,GAAG,CAAC,EAAE;QACnB,MAAM,CAAC,kBAAkB,CACxB;YACC,SAAS,EAAE,GAAG,aAAa,YAAY;YACvC,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;YACvC,aAAa;SACb,EACD,SAAS,CACT,CAAC;KACF;IACD,oEAAoE;IACpE,OAAO,MAAO,CAAC;AAChB,CAAC;AA3FD,oCA2FC;AAED,MAAM,4CAA4C,GAAG,KAAK,CAAC;AAC3D,MAAM,+CAA+C,GAAG,IAAI,CAAC;AAE7D;;;;;;;;;GASG;AACH,SAAgB,oBAAoB,CAAC,OAAe,EAAE,KAAc;IACnE,MAAM,mBAAmB,GAAG,IAAA,mCAAsB,EAAC,KAAK,CAAC,CAAC;IAC1D,IAAI,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,mBAAmB,IAAI,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;IACjE,UAAU,GAAG,IAAI,CAAC,GAAG,CACpB,UAAU,EACV,IAAA,uBAAY,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,sBAAsB,EAAE,CAAC,eAAe,KAAK,IAAI;QAC7E,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,+CAA+C,CAClD,CAAC;IACF,OAAO,UAAU,CAAC;AACnB,CAAC;AAVD,oDAUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { delay } from \"@fluidframework/core-utils/internal\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { isFluidError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { NonRetryableError, canRetryOnError, getRetryDelayFromError } from \"./network.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Interface describing an object passed to various network APIs.\n * It allows caller to control cancellation, as well as learn about any delays.\n * @internal\n */\nexport interface IProgress {\n\t/**\n\t * Abort signal used to cancel operation.\n\t *\n\t * @remarks Note that most of the layers do not use this signal yet. We need to change that over time.\n\t * Please consult with API documentation / implementation.\n\t * Note that number of layers may not check this signal while holding this request in a queue,\n\t * so it may take a while it takes effect. This can be improved in the future.\n\t *\n\t * The layers in question are:\n\t *\n\t * - driver (RateLimiter)\n\t *\n\t * - runWithRetry\n\t */\n\tcancel?: AbortSignal;\n\n\t/**\n\t * Called whenever api returns cancellable error and the call is going to be retried.\n\t * Any exception thrown from this call back result in cancellation of operation\n\t * and propagation of thrown exception.\n\t * @param delayInMs - delay before next retry. This value will depend on internal back-off logic,\n\t * as well as information provided by service (like 429 error asking to wait for some time before retry)\n\t * @param error - error object returned from the call.\n\t */\n\tonRetry?(delayInMs: number, error: any): void;\n}\n\n/**\n * @internal\n */\nexport async function runWithRetry<T>(\n\tapi: (cancel?: AbortSignal) => Promise<T>,\n\tfetchCallName: string,\n\tlogger: ITelemetryLoggerExt,\n\tprogress: IProgress,\n): Promise<T> {\n\tlet result: T | undefined;\n\tlet success = false;\n\t// We double this value in first try in when we calculate time to wait for in \"calculateMaxWaitTime\" function.\n\tlet retryAfterMs = 500; // has to be positive!\n\tlet numRetries = 0;\n\tconst startTime = performance.now();\n\tlet lastError: any;\n\tdo {\n\t\ttry {\n\t\t\tresult = await api(progress.cancel);\n\t\t\tsuccess = true;\n\t\t} catch (err) {\n\t\t\t// If it is not retriable, then just throw the error.\n\t\t\tif (!canRetryOnError(err)) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_cancel`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow err;\n\t\t\t}\n\n\t\t\tif (progress.cancel?.aborted === true) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_runWithRetryAborted`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\treason: progress.cancel.reason,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"runWithRetry was Aborted\",\n\t\t\t\t\tDriverErrorTypes.genericError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\treason: progress.cancel.reason,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// logging the first failed retry instead of every attempt. We want to avoid filling telemetry\n\t\t\t// when we have tight loop of retrying in offline mode, but we also want to know what caused\n\t\t\t// the failure in the first place\n\t\t\tif (numRetries === 0) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_firstFailed`,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tnumRetries++;\n\t\t\tlastError = err;\n\t\t\t// Wait for the calculated time before retrying.\n\t\t\tretryAfterMs = calculateMaxWaitTime(retryAfterMs, err);\n\t\t\tif (progress.onRetry) {\n\t\t\t\tprogress.onRetry(retryAfterMs, err);\n\t\t\t}\n\t\t\tawait delay(retryAfterMs);\n\t\t}\n\t} while (!success);\n\tif (numRetries > 0) {\n\t\tlogger.sendTelemetryEvent(\n\t\t\t{\n\t\t\t\teventName: `${fetchCallName}_lastError`,\n\t\t\t\tretry: numRetries,\n\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\tfetchCallName,\n\t\t\t},\n\t\t\tlastError,\n\t\t);\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\treturn result!;\n}\n\nconst MaxReconnectDelayInMsWhenEndpointIsReachable = 60000;\nconst MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;\n\n/**\n * Calculates time to wait for after an error based on the error and wait time for previous iteration.\n * In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some\n * transient error not related to endpoint, in that case we want to try at faster pace and hence the\n * max wait is lesser 8s as compared to when endpoint is reachable in which case it is 60s.\n * @param delayMs - wait time for previous iteration\n * @param error - error based on which we decide wait time.\n * @returns Wait time to wait for.\n * @internal\n */\nexport function calculateMaxWaitTime(delayMs: number, error: unknown): number {\n\tconst retryDelayFromError = getRetryDelayFromError(error);\n\tlet newDelayMs = Math.max(retryDelayFromError ?? 0, delayMs * 2);\n\tnewDelayMs = Math.min(\n\t\tnewDelayMs,\n\t\tisFluidError(error) && error.getTelemetryProperties().endpointReached === true\n\t\t\t? MaxReconnectDelayInMsWhenEndpointIsReachable\n\t\t\t: MaxReconnectDelayInMsWhenEndpointIsNotReachable,\n\t);\n\treturn newDelayMs;\n}\n"]}
|
package/dist/storageUtils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISnapshot } from "@fluidframework/driver-definitions";
|
|
5
|
+
import { ISnapshot } from "@fluidframework/driver-definitions/internal";
|
|
6
6
|
import { ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
7
7
|
/**
|
|
8
8
|
* Utility API to check if the type of snapshot contents is `ISnapshot`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storageUtils.d.ts","sourceRoot":"","sources":["../src/storageUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"storageUtils.d.ts","sourceRoot":"","sources":["../src/storageUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE;;;;GAIG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,aAAa,GAAG,SAAS,GAAG,SAAS,GACxC,GAAG,IAAI,SAAS,CAElB"}
|
package/dist/storageUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storageUtils.js","sourceRoot":"","sources":["../src/storageUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH;;;;GAIG;AACH,SAAgB,qBAAqB,CACpC,GAA0C;IAE1C,OAAO,GAAG,KAAK,SAAS,IAAI,iBAAiB,IAAI,GAAG,IAAI,GAAG,CAAC,eAAe,KAAK,CAAC,CAAC;AACnF,CAAC;AAJD,sDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshot } from \"@fluidframework/driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Utility API to check if the type of snapshot contents is `ISnapshot`.\n * @internal\n * @param obj - obj whose type needs to be identified.\n */\nexport function isInstanceOfISnapshot(\n\tobj: ISnapshotTree | ISnapshot | undefined,\n): obj is ISnapshot {\n\treturn obj !== undefined && \"snapshotFormatV\" in obj && obj.snapshotFormatV === 1;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storageUtils.js","sourceRoot":"","sources":["../src/storageUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH;;;;GAIG;AACH,SAAgB,qBAAqB,CACpC,GAA0C;IAE1C,OAAO,GAAG,KAAK,SAAS,IAAI,iBAAiB,IAAI,GAAG,IAAI,GAAG,CAAC,eAAe,KAAK,CAAC,CAAC;AACnF,CAAC;AAJD,sDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshot } from \"@fluidframework/driver-definitions/internal\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Utility API to check if the type of snapshot contents is `ISnapshot`.\n * @internal\n * @param obj - obj whose type needs to be identified.\n */\nexport function isInstanceOfISnapshot(\n\tobj: ISnapshotTree | ISnapshot | undefined,\n): obj is ISnapshot {\n\treturn obj !== undefined && \"snapshotFormatV\" in obj && obj.snapshotFormatV === 1;\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { ICommittedProposal, IDocumentAttributes, ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
6
6
|
/**
|
|
7
7
|
* Defines the current layout of an .app + .protocol summary tree
|
|
8
8
|
* this is used internally for create new, and single commit summary
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryForCreateNew.d.ts","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,
|
|
1
|
+
{"version":3,"file":"summaryForCreateNew.d.ts","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EAEnB,YAAY,EAEZ,MAAM,sCAAsC,CAAC;AAE9C;;;;G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AAO,IAAI,CAAC;AACb,CAAC;AAhBD,0EAgBC;AAED;;;;GAIG;AACH,SAAgB,mCAAmC,CAClD,eAA6B;IAE7B,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,UAA0B,CAAC;IACvE,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAiB,CAAwB,CAAC;AAC5E,CAAC;AALD,kFAKC;AAED;;;;GAIG;AACH,SAAgB,kCAAkC,CACjD,eAA6B;IAE7B,MAAM,gBAAgB,GAAG,eAAe,CAAC,IAAI,CAAC,YAA4B,CAAC;IAC3E,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAiB,CAG/D,CAAC;IACJ,OAAO,YAAY,CAAC;AACrB,CAAC;AATD,gFASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\
|
|
1
|
+
{"version":3,"file":"summaryForCreateNew.js","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+EAM8C;AAc9C;;;;GAIG;AACH,SAAgB,+BAA+B,CAC9C,OAAiC,EACjC,GAAG,iBAA2B;IAE9B,IACC,OAAO,EAAE,IAAI,KAAK,SAAS;QAC3B,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,KAAK,kCAAW,CAAC,IAAI;QACjD,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,KAAK,kCAAW,CAAC,IAAI,EACrD;QACD,OAAO,KAAK,CAAC;KACb;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACzF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,OAAO,KAAK,CAAC;KACb;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAhBD,0EAgBC;AAED;;;;GAIG;AACH,SAAgB,mCAAmC,CAClD,eAA6B;IAE7B,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,UAA0B,CAAC;IACvE,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAiB,CAAwB,CAAC;AAC5E,CAAC;AALD,kFAKC;AAED;;;;GAIG;AACH,SAAgB,kCAAkC,CACjD,eAA6B;IAE7B,MAAM,gBAAgB,GAAG,eAAe,CAAC,IAAI,CAAC,YAA4B,CAAC;IAC3E,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAiB,CAG/D,CAAC;IACJ,OAAO,YAAY,CAAC;AACrB,CAAC;AATD,gFASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tICommittedProposal,\n\tIDocumentAttributes,\n\tISummaryBlob,\n\tISummaryTree,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Defines the current layout of an .app + .protocol summary tree\n * this is used internally for create new, and single commit summary\n * @internal\n */\nexport interface CombinedAppAndProtocolSummary extends ISummaryTree {\n\ttree: {\n\t\t[\".app\"]: ISummaryTree;\n\t\t[\".protocol\"]: ISummaryTree;\n\t};\n}\n\n/**\n * Validates the current layout of an .app + .protocol summary tree\n * this is used internally for create new, and single commit summary\n * @internal\n */\nexport function isCombinedAppAndProtocolSummary(\n\tsummary: ISummaryTree | undefined,\n\t...optionalRootTrees: string[]\n): summary is CombinedAppAndProtocolSummary {\n\tif (\n\t\tsummary?.tree === undefined ||\n\t\tsummary.tree?.[\".app\"]?.type !== SummaryType.Tree ||\n\t\tsummary.tree?.[\".protocol\"]?.type !== SummaryType.Tree\n\t) {\n\t\treturn false;\n\t}\n\tconst treeKeys = Object.keys(summary.tree).filter((t) => !optionalRootTrees.includes(t));\n\tif (treeKeys.length !== 2) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Extract the attributes from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n * @internal\n */\nexport function getDocAttributesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): IDocumentAttributes {\n\tconst attributesBlob = protocolSummary.tree.attributes as ISummaryBlob;\n\treturn JSON.parse(attributesBlob.content as string) as IDocumentAttributes;\n}\n\n/**\n * Extract quorum values from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n * @internal\n */\nexport function getQuorumValuesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): [string, ICommittedProposal][] {\n\tconst quorumValuesBlob = protocolSummary.tree.quorumValues as ISummaryBlob;\n\tconst quorumValues = JSON.parse(quorumValuesBlob.content as string) as [\n\t\tstring,\n\t\tICommittedProposal,\n\t][];\n\treturn quorumValues;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeConversions.d.ts","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,KAAK,EAA2B,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"treeConversions.d.ts","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,KAAK,EAA2B,MAAM,sCAAsC,CAAC;AAKpG;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAiDlF"}
|
package/dist/treeConversions.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.convertSummaryTreeToSnapshotITree = void 0;
|
|
8
8
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
|
-
const
|
|
9
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
10
10
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
11
11
|
const blob_js_1 = require("./blob.js");
|
|
12
12
|
const summaryForCreateNew_js_1 = require("./summaryForCreateNew.js");
|
|
@@ -52,7 +52,7 @@ function convertSummaryTreeToSnapshotITree(summaryTree) {
|
|
|
52
52
|
throw new Error("Should not have Handle type in summary tree");
|
|
53
53
|
}
|
|
54
54
|
default:
|
|
55
|
-
(0,
|
|
55
|
+
(0, internal_1.unreachableCase)(value, "Unexpected summary tree type");
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAkE;AAClE,
|
|
1
|
+
{"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAkE;AAClE,kEAAsE;AACtE,+EAAoG;AAEpG,uCAA8E;AAC9E,qEAA2E;AAE3E;;;;GAIG;AACH,SAAgB,iCAAiC,CAAC,WAAyB;IAC1E,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,MAAM,gBAAgB,GAAG,IAAA,wDAA+B,EAAC,WAAW,CAAC,CAAC;IACtE,MAAM,iBAAiB,GAAG,gBAAgB;QACzC,CAAC,CAAC;YACA,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;YACrD,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;SAC/C;QACH,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,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C5B,CAAC;AACH,CAAC;AAjDD,8EAiDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryTree, ITree, ITreeEntry, SummaryType } from \"@fluidframework/protocol-definitions\";\n\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"./blob.js\";\nimport { isCombinedAppAndProtocolSummary } from \"./summaryForCreateNew.js\";\n\n/**\n * Converts ISummaryTree to ITree format.\n * @param summaryTree - summary tree in ISummaryTree format\n * @internal\n */\nexport function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tconst adaptSummaryTree = isCombinedAppAndProtocolSummary(summaryTree);\n\tconst allSummaryEntries = adaptSummaryTree\n\t\t? [\n\t\t\t\t...Object.entries(summaryTree.tree[\".protocol\"].tree),\n\t\t\t\t...Object.entries(summaryTree.tree[\".app\"].tree),\n\t\t ]\n\t\t: Object.entries(summaryTree.tree);\n\n\tfor (const [key, value] of allSummaryEntries) {\n\t\tconst k = adaptSummaryTree && key === \"attributes\" ? \".attributes\" : key;\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(k, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(k, convertSummaryTreeToSnapshotITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(k, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t\tgroupId: summaryTree.groupId,\n\t};\n}\n"]}
|
package/internal.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
+
* Generated by "flub generate entrypoints" in @fluidframework/build-tools.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export * from "./lib/index.js";
|
package/legacy.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
+
* Generated by "flub generate entrypoints" in @fluidframework/build-tools.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export * from "./lib/legacy.js";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IDocumentService, IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
5
|
+
import { IDocumentService, IDocumentStorageService } from "@fluidframework/driver-definitions/internal";
|
|
6
6
|
import { DocumentServiceProxy } from "../../documentServiceProxy.js";
|
|
7
7
|
import { ICompressionStorageConfig } from "./compressionTypes.js";
|
|
8
8
|
export declare class DocumentServiceCompressionAdapter extends DocumentServiceProxy {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentServiceCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"documentServiceCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAGlE,qBAAa,iCAAkC,SAAQ,oBAAoB;IAGzE,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADxB,OAAO,EAAE,gBAAgB,EACR,OAAO,EAAE,yBAAyB;IAWvC,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC;CASjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentServiceCompressionAdapter.js","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"documentServiceCompressionAdapter.js","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAGrE,OAAO,EAAE,wCAAwC,IAAI,mDAAmD,EAAE,MAAM,wBAAwB,CAAC;AAEzI,MAAM,OAAO,iCAAkC,SAAQ,oBAAoB;IAC1E,YACC,OAAyB,EACR,OAAkC;QAEnD,KAAK,CAAC,OAAO,CAAC,CAAC;QAFE,YAAO,GAAP,OAAO,CAA2B;QAGnD,yBAAyB;QACzB,IAAI,OAAO,CAAC,EAAE,KAAK,SAAS,EAAE;YAC7B,OAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,QAAgC,EAAE,EAAE,CACjE,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CACrC,CAAC;SACF;IACF,CAAC;IAEM,KAAK,CAAC,gBAAgB;QAC5B,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,MAAM,OAAO,GAAG,IAAI,mDAAmD,CACtE,OAAO,EACP,IAAI,CAAC,OAAO,CACZ,CAAC;QACF,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentService,\n\tIDocumentStorageService,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { DocumentServiceProxy } from \"../../documentServiceProxy.js\";\n\nimport { ICompressionStorageConfig } from \"./compressionTypes.js\";\nimport { DocumentStorageServiceCompressionAdapter as DocumentStorageServiceSummaryBlobCompressionAdapter } from \"./summaryblob/index.js\";\n\nexport class DocumentServiceCompressionAdapter extends DocumentServiceProxy {\n\tconstructor(\n\t\tservice: IDocumentService,\n\t\tprivate readonly _config: ICompressionStorageConfig,\n\t) {\n\t\tsuper(service);\n\t\t// Back-compat Old driver\n\t\tif (service.on !== undefined) {\n\t\t\tservice.on(\"metadataUpdate\", (metadata: Record<string, string>) =>\n\t\t\t\tthis.emit(\"metadataUpdate\", metadata),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\tconst storage = await super.connectToStorage();\n\t\tconst wrapped = new DocumentStorageServiceSummaryBlobCompressionAdapter(\n\t\t\tstorage,\n\t\t\tthis._config,\n\t\t);\n\t\tawait wrapped.getSnapshotTree();\n\t\treturn wrapped;\n\t}\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { IDocumentService, IDocumentServiceFactory, IResolvedUrl } from "@fluidframework/driver-definitions";
|
|
6
|
+
import { IDocumentService, IDocumentServiceFactory, IResolvedUrl } from "@fluidframework/driver-definitions/internal";
|
|
7
7
|
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
8
8
|
import { DocumentServiceFactoryProxy } from "../../documentServiceFactoryProxy.js";
|
|
9
9
|
import { ICompressionStorageConfig } from "./compressionTypes.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentServiceFactoryCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceFactoryCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACZ,MAAM,
|
|
1
|
+
{"version":3,"file":"documentServiceFactoryCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceFactoryCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAEnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAIlE,qBAAa,wCAAyC,SAAQ,2BAA2B;IAGvF,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADxB,cAAc,EAAE,uBAAuB,EACtB,OAAO,EAAE,yBAAyB;IAKvC,eAAe,CAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,oBAAoB,EAAE,YAAY,EAClC,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IAmBf,qBAAqB,CAAC,WAAW,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAIxF"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { DocumentServiceFactoryProxy } from "../../documentServiceFactoryProxy.js";
|
|
6
|
-
import { DocumentStorageServiceCompressionAdapter as DocumentStorageServiceSummaryBlobCompressionAdapter } from "./summaryblob/index.js";
|
|
7
6
|
import { DocumentServiceCompressionAdapter } from "./documentServiceCompressionAdapter.js";
|
|
7
|
+
import { DocumentStorageServiceCompressionAdapter as DocumentStorageServiceSummaryBlobCompressionAdapter } from "./summaryblob/index.js";
|
|
8
8
|
export class DocumentServiceFactoryCompressionAdapter extends DocumentServiceFactoryProxy {
|
|
9
9
|
constructor(serviceFactory, _config) {
|
|
10
10
|
super(serviceFactory);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentServiceFactoryCompressionAdapter.js","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceFactoryCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"documentServiceFactoryCompressionAdapter.js","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceFactoryCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAGnF,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,wCAAwC,IAAI,mDAAmD,EAAE,MAAM,wBAAwB,CAAC;AAEzI,MAAM,OAAO,wCAAyC,SAAQ,2BAA2B;IACxF,YACC,cAAuC,EACtB,OAAkC;QAEnD,KAAK,CAAC,cAAc,CAAC,CAAC;QAFL,YAAO,GAAP,OAAO,CAA2B;IAGpD,CAAC;IAEM,KAAK,CAAC,eAAe,CAC3B,gBAA0C,EAC1C,oBAAkC,EAClC,MAA6B,EAC7B,kBAA4B;QAE5B,IAAI,gBAAgB,KAAK,SAAS,EAAE;YACnC,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC;YACtC,MAAM,YAAY,GACjB,mDAAmD,CAAC,eAAe,CAClE,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAiB,EAC7C,gBAAgB,CAChB,CAAC;YACH,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC;SAC7C;QACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CACxD,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,EACN,kBAAkB,CAClB,CAAC;QACF,OAAO,IAAI,iCAAiC,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAAC,WAAyB;QAC3D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;QAC7E,OAAO,IAAI,iCAAiC,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\n\nimport { DocumentServiceFactoryProxy } from \"../../documentServiceFactoryProxy.js\";\n\nimport { ICompressionStorageConfig } from \"./compressionTypes.js\";\nimport { DocumentServiceCompressionAdapter } from \"./documentServiceCompressionAdapter.js\";\nimport { DocumentStorageServiceCompressionAdapter as DocumentStorageServiceSummaryBlobCompressionAdapter } from \"./summaryblob/index.js\";\n\nexport class DocumentServiceFactoryCompressionAdapter extends DocumentServiceFactoryProxy {\n\tconstructor(\n\t\tserviceFactory: IDocumentServiceFactory,\n\t\tprivate readonly _config: ICompressionStorageConfig,\n\t) {\n\t\tsuper(serviceFactory);\n\t}\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tcreateNewResolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (createNewSummary !== undefined) {\n\t\t\tconst configForInitial = this._config;\n\t\t\tconst newAppSumary =\n\t\t\t\tDocumentStorageServiceSummaryBlobCompressionAdapter.compressSummary(\n\t\t\t\t\tcreateNewSummary.tree[\".app\"] as ISummaryTree,\n\t\t\t\t\tconfigForInitial,\n\t\t\t\t);\n\t\t\tcreateNewSummary.tree[\".app\"] = newAppSumary;\n\t\t}\n\t\tconst service = await this.serviceFactory.createContainer(\n\t\t\tcreateNewSummary,\n\t\t\tcreateNewResolvedUrl,\n\t\t\tlogger,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t\treturn new DocumentServiceCompressionAdapter(service, this._config);\n\t}\n\n\tpublic async createDocumentService(resolvedUrl: IResolvedUrl): Promise<IDocumentService> {\n\t\tconst service = await this.serviceFactory.createDocumentService(resolvedUrl);\n\t\treturn new DocumentServiceCompressionAdapter(service, this._config);\n\t}\n}\n"]}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IDocumentStorageService, ISummaryContext } from "@fluidframework/driver-definitions";
|
|
5
|
+
import { IDocumentStorageService, ISummaryContext } from "@fluidframework/driver-definitions/internal";
|
|
6
6
|
import { ISnapshotTree, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
|
|
7
|
-
import { DocumentStorageServiceProxy } from "../../../documentStorageServiceProxy.js";
|
|
8
7
|
import { ICompressionStorageConfig } from "..//index.js";
|
|
8
|
+
import { DocumentStorageServiceProxy } from "../../../documentStorageServiceProxy.js";
|
|
9
9
|
/**
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentStorageServiceSummaryBlobCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../../src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"documentStorageServiceSummaryBlobCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../../src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,aAAa,EAEb,cAAc,EACd,YAAY,EACZ,QAAQ,EAGR,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,yBAAyB,EAA+B,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF;;GAEG;AACH,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAG3D;;;;;;;;;;;GAWG;AACH,qBAAa,wCAAyC,SAAQ,2BAA2B;IAKvF,OAAO,CAAC,Q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MAAM,GAAG,SAAS,GAE/B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAShC;;;;;OAKG;IACmB,wBAAwB,CAC7C,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAQlB;;;;OAIG;IACmB,eAAe,CAAC,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;CAYhF"}
|
package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { IsoBuffer } from "@fluid-internal/client-utils";
|
|
6
|
-
import { assert } from "@fluidframework/core-utils";
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { SummaryType, } from "@fluidframework/protocol-definitions";
|
|
8
8
|
import { compress, decompress } from "lz4js";
|
|
9
|
-
import { DocumentStorageServiceProxy } from "../../../documentStorageServiceProxy.js";
|
|
10
9
|
import { SummaryCompressionAlgorithm } from "..//index.js";
|
|
10
|
+
import { DocumentStorageServiceProxy } from "../../../documentStorageServiceProxy.js";
|
|
11
11
|
/**
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentStorageServiceSummaryBlobCompressionAdapter.js","sourceRoot":"","sources":["../../../../src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAON,WAAW,GACX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,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ACrF,QAAQ,EACR,MAAM,CACN,CAAC;QACF,MAAM,cAAc,GAAG;YACtB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;SAClC,CAAC;QACF,OAAO,cAAc,CAAC;KACtB;SAAM;QACN,OAAO,KAAK,CAAC;KACb;AACF,CAAC,AApBkC,CAoBjC;AAEF;;;;GAIG;AACqB,oDAAW,GAAG,CAAC,KAAoB,EAAiB,EAAE;IAC7E,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE;QACpC,MAAM,WAAW,GAAiB,KAAK,CAAC;QACxC,MAAM,QAAQ,GAAe,wCAAwC,CAAC,aAAa,CAClF,WAAW,CAAC,OAAO,CACnB,CAAC;QACF,MAAM,SAAS,GACd,wCAAwC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC/D,MAAM,cAAc,GAAG;YACtB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;SAClC,CAAC;QACF,OAAO,cAAc,CAAC;KACtB;SAAM;QACN,OAAO,KAAK,CAAC;KACb;AACF,CAAC,AAhBkC,CAgBjC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport {\n\tISnapshotTree,\n\tISummaryBlob,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n\tSummaryObject,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport { compress, decompress } from \"lz4js\";\nimport { DocumentStorageServiceProxy } from \"../../../documentStorageServiceProxy.js\";\nimport { ICompressionStorageConfig, SummaryCompressionAlgorithm } from \"..//index.js\";\n\n/**\n * @internal\n */\nexport const blobHeadersBlobName = \".metadata.blobHeaders\";\nconst metadataBlobName = \".metadata\";\n\n/**\n * This class is a proxy for the IDocumentStorageService that compresses and decompresses blobs in the summary.\n * The identification of the compressed blobs is done by adding a compression markup blob to the summary.\n * Even if the markup blob is present, it does not mean that all blobs are compressed. The blob,\n * which is compressed also contain the compression algorithm enumerated value from the\n * SummaryCompressionAlgorithm enumeration in the first byte . If the blob is not\n * commpressed, it contains the first byte equals to SummaryCompressionAlgorithm.None .\n * In case, the markup blob is present, it is expected that the first byte of the markup blob\n * will contain the info about the compression. If the first byte is not present, it is assumed\n * that the compression is not enabled and no first prefix byte is present in the blobs.\n * @public\n */\nexport class DocumentStorageServiceCompressionAdapter extends DocumentStorageServiceProxy {\n\tprivate _isCompressionEnabled: boolean = false;\n\n\tconstructor(\n\t\tservice: IDocumentStorageService,\n\t\tprivate readonly _config: ICompressionStorageConfig,\n\t) {\n\t\tsuper(service);\n\t}\n\n\tpublic get service(): IDocumentStorageService {\n\t\treturn this.internalStorageService;\n\t}\n\n\t/**\n\t * This method returns `true` if there is a compression markup byte in the blob, otherwise `false`.\n\t * @param blob - The blob to compress.\n\t * @returns `true` if there is a compression markup byte in the blob, otherwise `false`.\n\t */\n\tprivate static hasPrefix(blob: ArrayBufferLike): boolean {\n\t\tconst firstByte = IsoBuffer.from(blob)[0];\n\t\t// eslint-disable-next-line no-bitwise\n\t\treturn (firstByte & 0xf0) === 0xb0;\n\t}\n\n\t/**\n\t * This method reads the first byte from the given blob and maps that byte to the compression algorithm.\n\t * @param blob - The maybe compressed blob.\n\t */\n\tprivate static readAlgorithmFromBlob(blob: ArrayBufferLike): number {\n\t\treturn !this.hasPrefix(blob)\n\t\t\t? SummaryCompressionAlgorithm.None\n\t\t\t: // eslint-disable-next-line no-bitwise\n\t\t\t IsoBuffer.from(blob)[0] & 0x0f;\n\t}\n\n\t/**\n\t * This method writes the given algorithm to the blob as the first byte.\n\t * @param blob - The blob to write the algorithm to.\n\t * @param algorithm - The algorithm to write.\n\t * @returns The blob with the algorithm as the first byte.\n\t */\n\tprivate static writeAlgorithmToBlob(blob: ArrayBufferLike, algorithm: number): ArrayBufferLike {\n\t\tif (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tconst firstByte = IsoBuffer.from(blob)[0];\n\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\tif ((firstByte & 0xf0) !== 0xb0) {\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t}\n\t\tassert(algorithm < 0x10, 0x6f5 /* Algorithm should be less than 0x10 */);\n\t\tconst blobView = new Uint8Array(blob);\n\t\tconst blobLength = blobView.length;\n\t\tconst newBlob = new Uint8Array(blobLength + 1);\n\t\t// eslint-disable-next-line no-bitwise\n\t\tconst prefix = 0xb0 | algorithm;\n\t\tnewBlob[0] = prefix;\n\t\tnewBlob.set(blobView, 1);\n\t\treturn IsoBuffer.from(newBlob);\n\t}\n\n\t/**\n\t * This method removes the algorithm markup prefix from the blob (1 byte)\n\t * @param blob - The blob to remove the prefix from.\n\t * @returns The blob without the prefix.\n\t */\n\tprivate static removePrefixFromBlobIfPresent(blob: ArrayBufferLike): ArrayBufferLike {\n\t\tconst blobView = new Uint8Array(blob);\n\t\treturn this.hasPrefix(blob) ? IsoBuffer.from(blobView.subarray(1)) : blob;\n\t}\n\n\t/**\n\t * This method converts the given argument to Uint8Array. If the parameter is already Uint8Array,\n\t * it is just returned as is. If the parameter is string, it is converted to Uint8Array using\n\t * TextEncoder.\n\t * @param input - The input to convert to Uint8Array.\n\t * @returns The Uint8Array representation of the input.\n\t */\n\tprivate static toBinaryArray(input: string | Uint8Array): Uint8Array {\n\t\treturn typeof input === \"string\" ? new TextEncoder().encode(input) : input;\n\t}\n\n\t/**\n\t * This method encodes the blob inside the given summary object of the SummaryType.Blob type using the given config\n\t * containing the compression algorithm.\n\t * @param input - The summary object to encode.\n\t * @param config - The config containing the compression algorithm.\n\t * @returns The summary object with the encoded blob.\n\t */\n\tprivate static readonly blobEncoder = (\n\t\tinput: SummaryObject,\n\t\tconfig: ICompressionStorageConfig,\n\t): SummaryObject => {\n\t\tif (input.type === SummaryType.Blob) {\n\t\t\tconst summaryBlob: ISummaryBlob = input;\n\t\t\tconst original: ArrayBufferLike =\n\t\t\t\tDocumentStorageServiceCompressionAdapter.toBinaryArray(summaryBlob.content);\n\t\t\tconst processed: ArrayBufferLike = DocumentStorageServiceCompressionAdapter.encodeBlob(\n\t\t\t\toriginal,\n\t\t\t\tconfig,\n\t\t\t);\n\t\t\tconst newSummaryBlob = {\n\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\tcontent: IsoBuffer.from(processed),\n\t\t\t};\n\t\t\treturn newSummaryBlob;\n\t\t} else {\n\t\t\treturn input;\n\t\t}\n\t};\n\n\t/**\n\t * This method decodes the blob inside the given summary object of the SummaryType.Blob type.\n\t * @param input - The summary object to decode.\n\t * @returns The summary object with the decoded blob.\n\t */\n\tprivate static readonly blobDecoder = (input: SummaryObject): SummaryObject => {\n\t\tif (input.type === SummaryType.Blob) {\n\t\t\tconst summaryBlob: ISummaryBlob = input;\n\t\t\tconst original: Uint8Array = DocumentStorageServiceCompressionAdapter.toBinaryArray(\n\t\t\t\tsummaryBlob.content,\n\t\t\t);\n\t\t\tconst processed: ArrayBufferLike =\n\t\t\t\tDocumentStorageServiceCompressionAdapter.decodeBlob(original);\n\t\t\tconst newSummaryBlob = {\n\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\tcontent: IsoBuffer.from(processed),\n\t\t\t};\n\t\t\treturn newSummaryBlob;\n\t\t} else {\n\t\t\treturn input;\n\t\t}\n\t};\n\n\t/**\n\t * This method encodes the given blob according to the given config.\n\t * @param file - The blob to encode.\n\t * @param config - The config to use for encoding.\n\t * @returns The encoded blob.\n\t */\n\tprivate static encodeBlob(\n\t\tfile: ArrayBufferLike,\n\t\tconfig: ICompressionStorageConfig,\n\t): ArrayBufferLike {\n\t\tlet maybeCompressed: ArrayBufferLike;\n\t\tlet algorithm = config.algorithm;\n\t\tif (new Uint8Array(file).length < config.minSizeToCompress) {\n\t\t\tmaybeCompressed = file;\n\t\t\talgorithm = SummaryCompressionAlgorithm.None;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tmaybeCompressed = file;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.LZ4) {\n\t\t\tconst compressed = compress(file) as ArrayBufferLike;\n\t\t\tmaybeCompressed = compressed;\n\t\t} else {\n\t\t\tthrow new Error(`Unknown Algorithm ${config.algorithm}`);\n\t\t}\n\t\tmaybeCompressed = DocumentStorageServiceCompressionAdapter.writeAlgorithmToBlob(\n\t\t\tmaybeCompressed,\n\t\t\talgorithm,\n\t\t);\n\t\treturn maybeCompressed;\n\t}\n\n\t/**\n\t * This method decodes the given blob.\n\t * @param file - The blob to decode.\n\t * @returns The decoded blob.\n\t */\n\tprivate static decodeBlob(file: ArrayBufferLike): ArrayBufferLike {\n\t\tlet decompressed: ArrayBufferLike;\n\t\tlet originalBlob;\n\t\tlet algorithm;\n\t\tif (this.hasPrefix(file)) {\n\t\t\talgorithm = DocumentStorageServiceCompressionAdapter.readAlgorithmFromBlob(file);\n\t\t\toriginalBlob = this.removePrefixFromBlobIfPresent(file);\n\t\t} else {\n\t\t\talgorithm = SummaryCompressionAlgorithm.None;\n\t\t\toriginalBlob = file;\n\t\t}\n\t\tif (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tdecompressed = originalBlob;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.LZ4) {\n\t\t\tdecompressed = decompress(originalBlob) as ArrayBufferLike;\n\t\t} else {\n\t\t\tthrow new Error(`Unknown Algorithm ${algorithm}`);\n\t\t}\n\t\treturn decompressed;\n\t}\n\n\t/**\n\t * This method traverses the SummaryObject recursively. If it finds the ISummaryBlob object,\n\t * it applies encoding/decoding on it according to the given isEncode flag.\n\t * @param isEncode - True if the encoding should be applied, false if the decoding should be applied.\n\t * @param input - The summary object to traverse.\n\t * @param encoder - The encoder function to use.\n\t * @param decoder - The decoder function to use.\n\t * @param config - The config to use for encoding.\n\t * @param context - The summary context.\n\t * @returns The summary object with the encoded/decoded blob.\n\t */\n\tprivate static recursivelyReplace(\n\t\tisEncode: boolean,\n\t\tinput: SummaryObject,\n\t\tencoder: (input: SummaryObject, config: ICompressionStorageConfig) => SummaryObject,\n\t\tdecoder: (input: SummaryObject) => SummaryObject,\n\t\tconfig: ICompressionStorageConfig,\n\t\tcontext?: ISummaryContext,\n\t): SummaryObject {\n\t\tassert(typeof input === \"object\", 0x6f6 /* input must be a non-null object */);\n\t\tconst maybeReplaced = isEncode ? encoder(input, config) : decoder(input);\n\n\t\tif (maybeReplaced !== input) {\n\t\t\treturn maybeReplaced;\n\t\t}\n\t\tlet clone: object | undefined;\n\t\tfor (const key of Object.keys(input)) {\n\t\t\tconst value = input[key];\n\n\t\t\tif (Boolean(value) && typeof value === \"object\") {\n\t\t\t\tconst replaced = this.recursivelyReplace(\n\t\t\t\t\tisEncode,\n\t\t\t\t\tvalue as SummaryObject,\n\t\t\t\t\tencoder,\n\t\t\t\t\tdecoder,\n\t\t\t\t\tconfig,\n\t\t\t\t\tcontext,\n\t\t\t\t);\n\t\t\t\tif (replaced !== value) {\n\t\t\t\t\tclone = clone ?? (Array.isArray(input) ? [...input] : { ...input });\n\t\t\t\t\tclone[key] = replaced;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn (clone ?? input) as SummaryObject;\n\t}\n\n\t/**\n\t * This method traverses the SummaryTree recursively. If it finds the ISummaryBlob object with the key '.metadata',\n\t * it returns the summary tree containing that blob.\n\t *\n\t * @param summary - The summary tree to traverse.\n\t * @returns The summary tree containing the metadata blob.\n\t */\n\tprivate static findMetadataHolderSummary(summary: ISummaryTree): ISummaryTree | undefined {\n\t\tassert(typeof summary === \"object\", 0x6f7 /* summary must be a non-null object */);\n\t\tfor (const key of Object.keys(summary.tree)) {\n\t\t\tconst value = summary.tree[key];\n\n\t\t\tif (Boolean(value) && value.type === SummaryType.Tree) {\n\t\t\t\tconst found = this.findMetadataHolderSummary(value);\n\t\t\t\tif (found) {\n\t\t\t\t\treturn found;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Boolean(value) && key === metadataBlobName && value.type === SummaryType.Blob) {\n\t\t\t\treturn summary;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * This method obtains the summary tree containing the metadata blob. It returns the content\n\t * of the tree atribute.\n\t * @param summary - The summary tree to traverse.\n\t * @returns The content of the tree attribute of the summary tree containing the metadata blob.\n\t */\n\tprivate static getMetadataHolderTree(summary: ISummaryTree) {\n\t\tconst metadataHolder = this.findMetadataHolderSummary(summary);\n\t\tassert(metadataHolder !== undefined, 0x6f8 /* metadataHolder must be a non-null object */);\n\t\tconst metadataHolderTree = metadataHolder.tree;\n\t\treturn metadataHolderTree;\n\t}\n\n\t/**\n\t * This method adds the compression markup blob to the nested summary tree containing the metadata blob.\n\t * @param summary - The top summary tree to put the compression markup blob into.\n\t */\n\tprivate static putCompressionMarkup(summary: ISummaryTree): void {\n\t\tconst metadataHolderTree =\n\t\t\tDocumentStorageServiceCompressionAdapter.getMetadataHolderTree(summary);\n\t\tmetadataHolderTree[blobHeadersBlobName] = {\n\t\t\ttype: 2,\n\t\t\tcontent: \"\",\n\t\t};\n\t}\n\n\t/**\n\t * This method traverses the SnapshotTree recursively. If it finds the ISummaryBlob object with the key '.metadata',\n\t * it checks, if the SummaryTree holder of that object also contains the compression markup blob. If it is found,\n\t * it returns true, otherwise false.\n\t * @param snapshot - The snapshot tree to traverse.\n\t * @returns True if the compression markup blob is found, otherwise false.\n\t */\n\tprivate static hasCompressionMarkup(snapshot: ISnapshotTree): boolean {\n\t\tassert(typeof snapshot === \"object\", 0x6f9 /* snapshot must be a non-null object */);\n\t\tfor (const key of Object.keys(snapshot.blobs)) {\n\t\t\tif (key === metadataBlobName) {\n\t\t\t\tconst value = snapshot.blobs[blobHeadersBlobName];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const key of Object.keys(snapshot.trees)) {\n\t\t\tconst value = snapshot[key] as ISnapshotTree;\n\t\t\tif (value !== undefined) {\n\t\t\t\tconst found = this.hasCompressionMarkup(value);\n\t\t\t\tif (found) {\n\t\t\t\t\treturn found;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * This method performs compression of the blobs in the summary tree.\n\t * @param summary - The summary tree to compress.\n\t * @param config - The compression config.\n\t * @returns The compressed summary tree.\n\t */\n\tpublic static compressSummary(\n\t\tsummary: ISummaryTree,\n\t\tconfig: ICompressionStorageConfig,\n\t): ISummaryTree {\n\t\tthis.putCompressionMarkup(summary);\n\t\tconst prep = DocumentStorageServiceCompressionAdapter.recursivelyReplace(\n\t\t\ttrue,\n\t\t\tsummary,\n\t\t\tDocumentStorageServiceCompressionAdapter.blobEncoder,\n\t\t\tDocumentStorageServiceCompressionAdapter.blobDecoder,\n\t\t\tconfig,\n\t\t) as ISummaryTree;\n\t\t//\tconsole.log(`Miso summary-blob Summary Upload: ${JSON.stringify(prep).length}`);\n\t\treturn prep;\n\t}\n\n\t/**\n\t * This method read blob from the storage and decompresses it if it is compressed.\n\t * @param id - The id of the blob to read.\n\t * @returns The decompressed blob.\n\t */\n\tpublic override async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst originalBlob = await super.readBlob(id);\n\t\tif (!this._isCompressionEnabled) {\n\t\t\treturn originalBlob;\n\t\t} else {\n\t\t\tconst decompressedBlob =\n\t\t\t\tDocumentStorageServiceCompressionAdapter.decodeBlob(originalBlob);\n\t\t\t//\t\t\tconsole.log(`Miso summary-blob Blob read END : ${id} ${decompressedBlob.byteLength}`);\n\t\t\treturn decompressedBlob;\n\t\t}\n\t}\n\n\t/**\n\t * This method loads the snapshot tree from the server. It also checks, if the compression markup blob is present\n\t * and setups the compression flag accordingly. It also identifies the blobs that are not compressed and do not contain\n\t * algorithm byte prefix and store them.\n\t * @param version - The version of the snapshot tree to load.\n\t * @param scenarioName - The scenario name of the snapshot tree to load.\n\t * @returns The snapshot tree.\n\t */\n\tpublic override async getSnapshotTree(\n\t\tversion?: IVersion | undefined,\n\t\tscenarioName?: string | undefined,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\tconst snapshotTree = await super.getSnapshotTree(version, scenarioName);\n\t\tthis._isCompressionEnabled =\n\t\t\tsnapshotTree !== undefined &&\n\t\t\tsnapshotTree !== null &&\n\t\t\tDocumentStorageServiceCompressionAdapter.hasCompressionMarkup(snapshotTree);\n\t\treturn snapshotTree;\n\t}\n\n\t/**\n\t * This method uploads the summary to the storage. It performs compression of the blobs in the summary tree.\n\t * @param summary - The summary tree to upload.\n\t * @param context - The summary context.\n\t * @returns The ID of the uploaded summary.\n\t */\n\tpublic override async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst prep = DocumentStorageServiceCompressionAdapter.compressSummary(\n\t\t\tsummary,\n\t\t\tthis._config,\n\t\t);\n\t\treturn super.uploadSummaryWithContext(prep, context);\n\t}\n\n\t/**\n\t * This method downloads the summary from the storage and then applies decompression on the compressed blobs.\n\t * @param id - The ID of the summary to be downloaded\n\t * @returns The summary with decompressed blobs\n\t */\n\tpublic override async downloadSummary(id: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst summary = await super.downloadSummary(id);\n\t\treturn !this._isCompressionEnabled\n\t\t\t? summary\n\t\t\t: (DocumentStorageServiceCompressionAdapter.recursivelyReplace(\n\t\t\t\t\tfalse,\n\t\t\t\t\tsummary,\n\t\t\t\t\tDocumentStorageServiceCompressionAdapter.blobEncoder,\n\t\t\t\t\tDocumentStorageServiceCompressionAdapter.blobDecoder,\n\t\t\t\t\tthis._config,\n\t\t\t ) as ISummaryTree);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"documentStorageServiceSummaryBlobCompressionAdapter.js","sourceRoot":"","sources":["../../../../src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAK7D,OAAO,EAON,WAAW,GACX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAA6B,2BAA2B,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAC3D,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAErC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,wCAAyC,SAAQ,2BAA2B;IAGxF,YACC,OAAgC,EACf,OAAkC;QAEnD,KAAK,CAAC,OAAO,CAAC,CAAC;QAFE,YAAO,GAAP,OAAO,CAA2B;QAJ5C,0BAAqB,GAAY,KAAK,CAAC;IAO/C,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,SAAS,CAAC,IAAqB;QAC7C,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,sCAAsC;QACtC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;IACpC,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,qBAAqB,CAAC,IAAqB;QACzD,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAC3B,CAAC,CAAC,2BAA2B,CAAC,IAAI;YAClC,CAAC,CAAC,sCAAsC;gBACtC,SAAS,CA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ACpD,wCAAwC,CAAC,WAAW,EACpD,IAAI,CAAC,OAAO,CACM,CAAC;IACvB,CAAC;;AAxUD;;;;;;GAMG;AACqB,oDAAW,GAAG,CACrC,KAAoB,EACpB,MAAiC,EACjB,EAAE;IAClB,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE;QACpC,MAAM,WAAW,GAAiB,KAAK,CAAC;QACxC,MAAM,QAAQ,GACb,wCAAwC,CAAC,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC7E,MAAM,SAAS,GAAoB,wCAAwC,CAAC,UAAU,CACrF,QAAQ,EACR,MAAM,CACN,CAAC;QACF,MAAM,cAAc,GAAG;YACtB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;SAClC,CAAC;QACF,OAAO,cAAc,CAAC;KACtB;SAAM;QACN,OAAO,KAAK,CAAC;KACb;AACF,CAAC,AApBkC,CAoBjC;AAEF;;;;GAIG;AACqB,oDAAW,GAAG,CAAC,KAAoB,EAAiB,EAAE;IAC7E,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE;QACpC,MAAM,WAAW,GAAiB,KAAK,CAAC;QACxC,MAAM,QAAQ,GAAe,wCAAwC,CAAC,aAAa,CAClF,WAAW,CAAC,OAAO,CACnB,CAAC;QACF,MAAM,SAAS,GACd,wCAAwC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC/D,MAAM,cAAc,GAAG;YACtB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;SAClC,CAAC;QACF,OAAO,cAAc,CAAC;KACtB;SAAM;QACN,OAAO,KAAK,CAAC;KACb;AACF,CAAC,AAhBkC,CAgBjC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tISnapshotTree,\n\tISummaryBlob,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n\tSummaryObject,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport { compress, decompress } from \"lz4js\";\n\nimport { ICompressionStorageConfig, SummaryCompressionAlgorithm } from \"..//index.js\";\nimport { DocumentStorageServiceProxy } from \"../../../documentStorageServiceProxy.js\";\n\n/**\n * @internal\n */\nexport const blobHeadersBlobName = \".metadata.blobHeaders\";\nconst metadataBlobName = \".metadata\";\n\n/**\n * This class is a proxy for the IDocumentStorageService that compresses and decompresses blobs in the summary.\n * The identification of the compressed blobs is done by adding a compression markup blob to the summary.\n * Even if the markup blob is present, it does not mean that all blobs are compressed. The blob,\n * which is compressed also contain the compression algorithm enumerated value from the\n * SummaryCompressionAlgorithm enumeration in the first byte . If the blob is not\n * commpressed, it contains the first byte equals to SummaryCompressionAlgorithm.None .\n * In case, the markup blob is present, it is expected that the first byte of the markup blob\n * will contain the info about the compression. If the first byte is not present, it is assumed\n * that the compression is not enabled and no first prefix byte is present in the blobs.\n * @public\n */\nexport class DocumentStorageServiceCompressionAdapter extends DocumentStorageServiceProxy {\n\tprivate _isCompressionEnabled: boolean = false;\n\n\tconstructor(\n\t\tservice: IDocumentStorageService,\n\t\tprivate readonly _config: ICompressionStorageConfig,\n\t) {\n\t\tsuper(service);\n\t}\n\n\tpublic get service(): IDocumentStorageService {\n\t\treturn this.internalStorageService;\n\t}\n\n\t/**\n\t * This method returns `true` if there is a compression markup byte in the blob, otherwise `false`.\n\t * @param blob - The blob to compress.\n\t * @returns `true` if there is a compression markup byte in the blob, otherwise `false`.\n\t */\n\tprivate static hasPrefix(blob: ArrayBufferLike): boolean {\n\t\tconst firstByte = IsoBuffer.from(blob)[0];\n\t\t// eslint-disable-next-line no-bitwise\n\t\treturn (firstByte & 0xf0) === 0xb0;\n\t}\n\n\t/**\n\t * This method reads the first byte from the given blob and maps that byte to the compression algorithm.\n\t * @param blob - The maybe compressed blob.\n\t */\n\tprivate static readAlgorithmFromBlob(blob: ArrayBufferLike): number {\n\t\treturn !this.hasPrefix(blob)\n\t\t\t? SummaryCompressionAlgorithm.None\n\t\t\t: // eslint-disable-next-line no-bitwise\n\t\t\t IsoBuffer.from(blob)[0] & 0x0f;\n\t}\n\n\t/**\n\t * This method writes the given algorithm to the blob as the first byte.\n\t * @param blob - The blob to write the algorithm to.\n\t * @param algorithm - The algorithm to write.\n\t * @returns The blob with the algorithm as the first byte.\n\t */\n\tprivate static writeAlgorithmToBlob(blob: ArrayBufferLike, algorithm: number): ArrayBufferLike {\n\t\tif (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tconst firstByte = IsoBuffer.from(blob)[0];\n\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\tif ((firstByte & 0xf0) !== 0xb0) {\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t}\n\t\tassert(algorithm < 0x10, 0x6f5 /* Algorithm should be less than 0x10 */);\n\t\tconst blobView = new Uint8Array(blob);\n\t\tconst blobLength = blobView.length;\n\t\tconst newBlob = new Uint8Array(blobLength + 1);\n\t\t// eslint-disable-next-line no-bitwise\n\t\tconst prefix = 0xb0 | algorithm;\n\t\tnewBlob[0] = prefix;\n\t\tnewBlob.set(blobView, 1);\n\t\treturn IsoBuffer.from(newBlob);\n\t}\n\n\t/**\n\t * This method removes the algorithm markup prefix from the blob (1 byte)\n\t * @param blob - The blob to remove the prefix from.\n\t * @returns The blob without the prefix.\n\t */\n\tprivate static removePrefixFromBlobIfPresent(blob: ArrayBufferLike): ArrayBufferLike {\n\t\tconst blobView = new Uint8Array(blob);\n\t\treturn this.hasPrefix(blob) ? IsoBuffer.from(blobView.subarray(1)) : blob;\n\t}\n\n\t/**\n\t * This method converts the given argument to Uint8Array. If the parameter is already Uint8Array,\n\t * it is just returned as is. If the parameter is string, it is converted to Uint8Array using\n\t * TextEncoder.\n\t * @param input - The input to convert to Uint8Array.\n\t * @returns The Uint8Array representation of the input.\n\t */\n\tprivate static toBinaryArray(input: string | Uint8Array): Uint8Array {\n\t\treturn typeof input === \"string\" ? new TextEncoder().encode(input) : input;\n\t}\n\n\t/**\n\t * This method encodes the blob inside the given summary object of the SummaryType.Blob type using the given config\n\t * containing the compression algorithm.\n\t * @param input - The summary object to encode.\n\t * @param config - The config containing the compression algorithm.\n\t * @returns The summary object with the encoded blob.\n\t */\n\tprivate static readonly blobEncoder = (\n\t\tinput: SummaryObject,\n\t\tconfig: ICompressionStorageConfig,\n\t): SummaryObject => {\n\t\tif (input.type === SummaryType.Blob) {\n\t\t\tconst summaryBlob: ISummaryBlob = input;\n\t\t\tconst original: ArrayBufferLike =\n\t\t\t\tDocumentStorageServiceCompressionAdapter.toBinaryArray(summaryBlob.content);\n\t\t\tconst processed: ArrayBufferLike = DocumentStorageServiceCompressionAdapter.encodeBlob(\n\t\t\t\toriginal,\n\t\t\t\tconfig,\n\t\t\t);\n\t\t\tconst newSummaryBlob = {\n\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\tcontent: IsoBuffer.from(processed),\n\t\t\t};\n\t\t\treturn newSummaryBlob;\n\t\t} else {\n\t\t\treturn input;\n\t\t}\n\t};\n\n\t/**\n\t * This method decodes the blob inside the given summary object of the SummaryType.Blob type.\n\t * @param input - The summary object to decode.\n\t * @returns The summary object with the decoded blob.\n\t */\n\tprivate static readonly blobDecoder = (input: SummaryObject): SummaryObject => {\n\t\tif (input.type === SummaryType.Blob) {\n\t\t\tconst summaryBlob: ISummaryBlob = input;\n\t\t\tconst original: Uint8Array = DocumentStorageServiceCompressionAdapter.toBinaryArray(\n\t\t\t\tsummaryBlob.content,\n\t\t\t);\n\t\t\tconst processed: ArrayBufferLike =\n\t\t\t\tDocumentStorageServiceCompressionAdapter.decodeBlob(original);\n\t\t\tconst newSummaryBlob = {\n\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\tcontent: IsoBuffer.from(processed),\n\t\t\t};\n\t\t\treturn newSummaryBlob;\n\t\t} else {\n\t\t\treturn input;\n\t\t}\n\t};\n\n\t/**\n\t * This method encodes the given blob according to the given config.\n\t * @param file - The blob to encode.\n\t * @param config - The config to use for encoding.\n\t * @returns The encoded blob.\n\t */\n\tprivate static encodeBlob(\n\t\tfile: ArrayBufferLike,\n\t\tconfig: ICompressionStorageConfig,\n\t): ArrayBufferLike {\n\t\tlet maybeCompressed: ArrayBufferLike;\n\t\tlet algorithm = config.algorithm;\n\t\tif (new Uint8Array(file).length < config.minSizeToCompress) {\n\t\t\tmaybeCompressed = file;\n\t\t\talgorithm = SummaryCompressionAlgorithm.None;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tmaybeCompressed = file;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.LZ4) {\n\t\t\tconst compressed = compress(file) as ArrayBufferLike;\n\t\t\tmaybeCompressed = compressed;\n\t\t} else {\n\t\t\tthrow new Error(`Unknown Algorithm ${config.algorithm}`);\n\t\t}\n\t\tmaybeCompressed = DocumentStorageServiceCompressionAdapter.writeAlgorithmToBlob(\n\t\t\tmaybeCompressed,\n\t\t\talgorithm,\n\t\t);\n\t\treturn maybeCompressed;\n\t}\n\n\t/**\n\t * This method decodes the given blob.\n\t * @param file - The blob to decode.\n\t * @returns The decoded blob.\n\t */\n\tprivate static decodeBlob(file: ArrayBufferLike): ArrayBufferLike {\n\t\tlet decompressed: ArrayBufferLike;\n\t\tlet originalBlob;\n\t\tlet algorithm;\n\t\tif (this.hasPrefix(file)) {\n\t\t\talgorithm = DocumentStorageServiceCompressionAdapter.readAlgorithmFromBlob(file);\n\t\t\toriginalBlob = this.removePrefixFromBlobIfPresent(file);\n\t\t} else {\n\t\t\talgorithm = SummaryCompressionAlgorithm.None;\n\t\t\toriginalBlob = file;\n\t\t}\n\t\tif (algorithm === SummaryCompressionAlgorithm.None) {\n\t\t\tdecompressed = originalBlob;\n\t\t} else if (algorithm === SummaryCompressionAlgorithm.LZ4) {\n\t\t\tdecompressed = decompress(originalBlob) as ArrayBufferLike;\n\t\t} else {\n\t\t\tthrow new Error(`Unknown Algorithm ${algorithm}`);\n\t\t}\n\t\treturn decompressed;\n\t}\n\n\t/**\n\t * This method traverses the SummaryObject recursively. If it finds the ISummaryBlob object,\n\t * it applies encoding/decoding on it according to the given isEncode flag.\n\t * @param isEncode - True if the encoding should be applied, false if the decoding should be applied.\n\t * @param input - The summary object to traverse.\n\t * @param encoder - The encoder function to use.\n\t * @param decoder - The decoder function to use.\n\t * @param config - The config to use for encoding.\n\t * @param context - The summary context.\n\t * @returns The summary object with the encoded/decoded blob.\n\t */\n\tprivate static recursivelyReplace(\n\t\tisEncode: boolean,\n\t\tinput: SummaryObject,\n\t\tencoder: (input: SummaryObject, config: ICompressionStorageConfig) => SummaryObject,\n\t\tdecoder: (input: SummaryObject) => SummaryObject,\n\t\tconfig: ICompressionStorageConfig,\n\t\tcontext?: ISummaryContext,\n\t): SummaryObject {\n\t\tassert(typeof input === \"object\", 0x6f6 /* input must be a non-null object */);\n\t\tconst maybeReplaced = isEncode ? encoder(input, config) : decoder(input);\n\n\t\tif (maybeReplaced !== input) {\n\t\t\treturn maybeReplaced;\n\t\t}\n\t\tlet clone: object | undefined;\n\t\tfor (const key of Object.keys(input)) {\n\t\t\tconst value = input[key];\n\n\t\t\tif (Boolean(value) && typeof value === \"object\") {\n\t\t\t\tconst replaced = this.recursivelyReplace(\n\t\t\t\t\tisEncode,\n\t\t\t\t\tvalue as SummaryObject,\n\t\t\t\t\tencoder,\n\t\t\t\t\tdecoder,\n\t\t\t\t\tconfig,\n\t\t\t\t\tcontext,\n\t\t\t\t);\n\t\t\t\tif (replaced !== value) {\n\t\t\t\t\tclone = clone ?? (Array.isArray(input) ? [...input] : { ...input });\n\t\t\t\t\tclone[key] = replaced;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn (clone ?? input) as SummaryObject;\n\t}\n\n\t/**\n\t * This method traverses the SummaryTree recursively. If it finds the ISummaryBlob object with the key '.metadata',\n\t * it returns the summary tree containing that blob.\n\t *\n\t * @param summary - The summary tree to traverse.\n\t * @returns The summary tree containing the metadata blob.\n\t */\n\tprivate static findMetadataHolderSummary(summary: ISummaryTree): ISummaryTree | undefined {\n\t\tassert(typeof summary === \"object\", 0x6f7 /* summary must be a non-null object */);\n\t\tfor (const key of Object.keys(summary.tree)) {\n\t\t\tconst value = summary.tree[key];\n\n\t\t\tif (Boolean(value) && value.type === SummaryType.Tree) {\n\t\t\t\tconst found = this.findMetadataHolderSummary(value);\n\t\t\t\tif (found) {\n\t\t\t\t\treturn found;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Boolean(value) && key === metadataBlobName && value.type === SummaryType.Blob) {\n\t\t\t\treturn summary;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * This method obtains the summary tree containing the metadata blob. It returns the content\n\t * of the tree atribute.\n\t * @param summary - The summary tree to traverse.\n\t * @returns The content of the tree attribute of the summary tree containing the metadata blob.\n\t */\n\tprivate static getMetadataHolderTree(summary: ISummaryTree) {\n\t\tconst metadataHolder = this.findMetadataHolderSummary(summary);\n\t\tassert(metadataHolder !== undefined, 0x6f8 /* metadataHolder must be a non-null object */);\n\t\tconst metadataHolderTree = metadataHolder.tree;\n\t\treturn metadataHolderTree;\n\t}\n\n\t/**\n\t * This method adds the compression markup blob to the nested summary tree containing the metadata blob.\n\t * @param summary - The top summary tree to put the compression markup blob into.\n\t */\n\tprivate static putCompressionMarkup(summary: ISummaryTree): void {\n\t\tconst metadataHolderTree =\n\t\t\tDocumentStorageServiceCompressionAdapter.getMetadataHolderTree(summary);\n\t\tmetadataHolderTree[blobHeadersBlobName] = {\n\t\t\ttype: 2,\n\t\t\tcontent: \"\",\n\t\t};\n\t}\n\n\t/**\n\t * This method traverses the SnapshotTree recursively. If it finds the ISummaryBlob object with the key '.metadata',\n\t * it checks, if the SummaryTree holder of that object also contains the compression markup blob. If it is found,\n\t * it returns true, otherwise false.\n\t * @param snapshot - The snapshot tree to traverse.\n\t * @returns True if the compression markup blob is found, otherwise false.\n\t */\n\tprivate static hasCompressionMarkup(snapshot: ISnapshotTree): boolean {\n\t\tassert(typeof snapshot === \"object\", 0x6f9 /* snapshot must be a non-null object */);\n\t\tfor (const key of Object.keys(snapshot.blobs)) {\n\t\t\tif (key === metadataBlobName) {\n\t\t\t\tconst value = snapshot.blobs[blobHeadersBlobName];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const key of Object.keys(snapshot.trees)) {\n\t\t\tconst value = snapshot[key] as ISnapshotTree;\n\t\t\tif (value !== undefined) {\n\t\t\t\tconst found = this.hasCompressionMarkup(value);\n\t\t\t\tif (found) {\n\t\t\t\t\treturn found;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * This method performs compression of the blobs in the summary tree.\n\t * @param summary - The summary tree to compress.\n\t * @param config - The compression config.\n\t * @returns The compressed summary tree.\n\t */\n\tpublic static compressSummary(\n\t\tsummary: ISummaryTree,\n\t\tconfig: ICompressionStorageConfig,\n\t): ISummaryTree {\n\t\tthis.putCompressionMarkup(summary);\n\t\tconst prep = DocumentStorageServiceCompressionAdapter.recursivelyReplace(\n\t\t\ttrue,\n\t\t\tsummary,\n\t\t\tDocumentStorageServiceCompressionAdapter.blobEncoder,\n\t\t\tDocumentStorageServiceCompressionAdapter.blobDecoder,\n\t\t\tconfig,\n\t\t) as ISummaryTree;\n\t\t//\tconsole.log(`Miso summary-blob Summary Upload: ${JSON.stringify(prep).length}`);\n\t\treturn prep;\n\t}\n\n\t/**\n\t * This method read blob from the storage and decompresses it if it is compressed.\n\t * @param id - The id of the blob to read.\n\t * @returns The decompressed blob.\n\t */\n\tpublic override async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst originalBlob = await super.readBlob(id);\n\t\tif (!this._isCompressionEnabled) {\n\t\t\treturn originalBlob;\n\t\t} else {\n\t\t\tconst decompressedBlob =\n\t\t\t\tDocumentStorageServiceCompressionAdapter.decodeBlob(originalBlob);\n\t\t\t//\t\t\tconsole.log(`Miso summary-blob Blob read END : ${id} ${decompressedBlob.byteLength}`);\n\t\t\treturn decompressedBlob;\n\t\t}\n\t}\n\n\t/**\n\t * This method loads the snapshot tree from the server. It also checks, if the compression markup blob is present\n\t * and setups the compression flag accordingly. It also identifies the blobs that are not compressed and do not contain\n\t * algorithm byte prefix and store them.\n\t * @param version - The version of the snapshot tree to load.\n\t * @param scenarioName - The scenario name of the snapshot tree to load.\n\t * @returns The snapshot tree.\n\t */\n\tpublic override async getSnapshotTree(\n\t\tversion?: IVersion | undefined,\n\t\tscenarioName?: string | undefined,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\tconst snapshotTree = await super.getSnapshotTree(version, scenarioName);\n\t\tthis._isCompressionEnabled =\n\t\t\tsnapshotTree !== undefined &&\n\t\t\tsnapshotTree !== null &&\n\t\t\tDocumentStorageServiceCompressionAdapter.hasCompressionMarkup(snapshotTree);\n\t\treturn snapshotTree;\n\t}\n\n\t/**\n\t * This method uploads the summary to the storage. It performs compression of the blobs in the summary tree.\n\t * @param summary - The summary tree to upload.\n\t * @param context - The summary context.\n\t * @returns The ID of the uploaded summary.\n\t */\n\tpublic override async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst prep = DocumentStorageServiceCompressionAdapter.compressSummary(\n\t\t\tsummary,\n\t\t\tthis._config,\n\t\t);\n\t\treturn super.uploadSummaryWithContext(prep, context);\n\t}\n\n\t/**\n\t * This method downloads the summary from the storage and then applies decompression on the compressed blobs.\n\t * @param id - The ID of the summary to be downloaded\n\t * @returns The summary with decompressed blobs\n\t */\n\tpublic override async downloadSummary(id: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst summary = await super.downloadSummary(id);\n\t\treturn !this._isCompressionEnabled\n\t\t\t? summary\n\t\t\t: (DocumentStorageServiceCompressionAdapter.recursivelyReplace(\n\t\t\t\t\tfalse,\n\t\t\t\t\tsummary,\n\t\t\t\t\tDocumentStorageServiceCompressionAdapter.blobEncoder,\n\t\t\t\t\tDocumentStorageServiceCompressionAdapter.blobDecoder,\n\t\t\t\t\tthis._config,\n\t\t\t ) as ISummaryTree);\n\t}\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IDocumentServiceFactory } from "@fluidframework/driver-definitions";
|
|
5
|
+
import { IDocumentServiceFactory } from "@fluidframework/driver-definitions/internal";
|
|
6
6
|
import { ICompressionStorageConfig } from "./compression/index.js";
|
|
7
7
|
/**
|
|
8
8
|
* This method optionally applies compression to the given document service factory. The compression
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predefinedAdapters.d.ts","sourceRoot":"","sources":["../../src/adapters/predefinedAdapters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"predefinedAdapters.d.ts","sourceRoot":"","sources":["../../src/adapters/predefinedAdapters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAEtF,OAAO,EAGN,yBAAyB,EACzB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACtC,sBAAsB,EAAE,uBAAuB,EAC/C,MAAM,CAAC,EAAE,yBAAyB,GAAG,OAAO,GAC1C,uBAAuB,CAgBzB;AAwBD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,yBAAyB,CAKpF"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { assert } from "@fluidframework/core-utils";
|
|
6
|
-
import {
|
|
5
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { DefaultCompressionStorageConfig, DocumentServiceFactoryCompressionAdapter, } from "./compression/index.js";
|
|
7
7
|
/**
|
|
8
8
|
* This method optionally applies compression to the given document service factory. The compression
|
|
9
9
|
* must be enabled by setting the config to true or by passing a compression config object.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predefinedAdapters.js","sourceRoot":"","sources":["../../src/adapters/predefinedAdapters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"predefinedAdapters.js","sourceRoot":"","sources":["../../src/adapters/predefinedAdapters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EACN,+BAA+B,EAC/B,wCAAwC,GAExC,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACtC,sBAA+C,EAC/C,MAA4C;IAE5C,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,KAAK,EAAE;QAC7C,OAAO,sBAAsB,CAAC;KAC9B;SAAM,IAAI,MAAM,KAAK,IAAI,EAAE;QAC3B,OAAO,+BAA+B,CACrC,wCAAwC,EACxC,sBAAsB,CACtB,CAAC;KACF;SAAM;QACN,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAC5E,OAAO,+BAA+B,CACrC,wCAAwC,EACxC,sBAAsB,EACtB,MAAM,CACN,CAAC;KACF;AACF,CAAC;AAED;;;;;GAKG;AACH,SAAS,+BAA+B,CACvC,WAK4B,EAC5B,sBAA+C,EAC/C,SAAoC,+BAA+B;IAEnE,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE;QACnC,OAAO,sBAAsB,CAAC;KAC9B;IACD,OAAO,IAAI,WAAW,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAW;IAC9C,OAAO,CACN,MAAM,KAAK,SAAS;QACpB,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,MAAM,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAC1E,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\n\nimport {\n\tDefaultCompressionStorageConfig,\n\tDocumentServiceFactoryCompressionAdapter,\n\tICompressionStorageConfig,\n} from \"./compression/index.js\";\n\n/**\n * This method optionally applies compression to the given document service factory. The compression\n * must be enabled by setting the config to true or by passing a compression config object.\n * @param documentServiceFactory - The document service factory to apply compression to.\n * @param config - The compression configuration.\n * @returns The document service factory possibly with compression applied.\n * @internal\n */\nexport function applyStorageCompression(\n\tdocumentServiceFactory: IDocumentServiceFactory,\n\tconfig?: ICompressionStorageConfig | boolean,\n): IDocumentServiceFactory {\n\tif (config === undefined || config === false) {\n\t\treturn documentServiceFactory;\n\t} else if (config === true) {\n\t\treturn applyStorageCompressionInternal(\n\t\t\tDocumentServiceFactoryCompressionAdapter,\n\t\t\tdocumentServiceFactory,\n\t\t);\n\t} else {\n\t\tassert(isCompressionConfig(config), 0x6f4 /* Invalid compression config */);\n\t\treturn applyStorageCompressionInternal(\n\t\t\tDocumentServiceFactoryCompressionAdapter,\n\t\t\tdocumentServiceFactory,\n\t\t\tconfig,\n\t\t);\n\t}\n}\n\n/**\n * This method applies compression to the given document service factory.\n * @param documentServiceFactory - The document service factory to apply compression to.\n * @param config - The compression configuration.\n * @returns The document service factory with compression applied.\n */\nfunction applyStorageCompressionInternal(\n\tconstructor: new (\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\tdocumentServiceFactory: IDocumentServiceFactory,\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\tconfig: ICompressionStorageConfig,\n\t) => IDocumentServiceFactory,\n\tdocumentServiceFactory: IDocumentServiceFactory,\n\tconfig: ICompressionStorageConfig = DefaultCompressionStorageConfig,\n): IDocumentServiceFactory {\n\tif (config.algorithm === undefined) {\n\t\treturn documentServiceFactory;\n\t}\n\treturn new constructor(documentServiceFactory, config);\n}\n\n/**\n * This method checks whether given objects contains\n * a properties expected for the interface ICompressionStorageConfig.\n */\nexport function isCompressionConfig(config: any): config is ICompressionStorageConfig {\n\treturn (\n\t\tconfig !== undefined &&\n\t\t(config.algorithm !== undefined || config.minSizeToCompress !== undefined)\n\t);\n}\n"]}
|
package/lib/blob.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { FileMode,
|
|
5
|
+
import { FileMode, IAttachment, IBlob, ITree, TreeEntry } from "@fluidframework/protocol-definitions";
|
|
6
6
|
/**
|
|
7
7
|
* Basic implementation of a blob ITreeEntry
|
|
8
8
|
* @internal
|
package/lib/blob.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../src/blob.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../src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C;QACrB,SAAI,GAAG,SAAS,CAAC,IAAI,CAAC;QAcrC,IAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrC,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,aAAa;IAIzB;;;;OAIG;IACH,YACiB,IAAY,EACZ,KAAY;QADZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAO;QAVb,SAAI,GAAG,QAAQ,CAAC,SAAS,CAAC;QAC1B,SAAI,GAAG,SAAS,CAAC,IAAI,CAAC;IAUnC,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAK/B;;;;OAIG;IACH,YACiB,IAAY,EACZ,EAAU;QADV,SAAI,GAAJ,IAAI,CAAQ;QACZ,OAAE,GAAF,EAAE,CAAQ;QAXX,SAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;QACrB,SAAI,GAAG,SAAS,CAAC,UAAU,CAAC;QAY3C,IAAI,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC;IACrB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tFileMode,\n\
|
|
1
|
+
{"version":3,"file":"blob.js","sourceRoot":"","sources":["../src/blob.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,QAAQ,EAIR,SAAS,GACT,MAAM,sCAAsC,CAAC;AAE9C;;;GAGG;AACH,MAAM,OAAO,aAAa;IAKzB;;;;;OAKG;IACH,YACiB,IAAY,EAC5B,QAAgB,EAChB,WAA+B,OAAO;QAFtB,SAAI,GAAJ,IAAI,CAAQ;QAXb,SAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;QACrB,SAAI,GAAG,SAAS,CAAC,IAAI,CAAC;QAcrC,IAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrC,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,aAAa;IAIzB;;;;OAIG;IACH,YACiB,IAAY,EACZ,KAAY;QADZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAO;QAVb,SAAI,GAAG,QAAQ,CAAC,SAAS,CAAC;QAC1B,SAAI,GAAG,SAAS,CAAC,IAAI,CAAC;IAUnC,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAK/B;;;;OAIG;IACH,YACiB,IAAY,EACZ,EAAU;QADV,SAAI,GAAJ,IAAI,CAAQ;QACZ,OAAE,GAAF,EAAE,CAAQ;QAXX,SAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;QACrB,SAAI,GAAG,SAAS,CAAC,UAAU,CAAC;QAY3C,IAAI,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC;IACrB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tFileMode,\n\tIAttachment,\n\tIBlob,\n\tITree,\n\tTreeEntry,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Basic implementation of a blob ITreeEntry\n * @internal\n */\nexport class BlobTreeEntry {\n\tpublic readonly mode = FileMode.File;\n\tpublic readonly type = TreeEntry.Blob;\n\tpublic readonly value: IBlob;\n\n\t/**\n\t * Creates a blob ITreeEntry\n\t * @param path - path of entry\n\t * @param contents - blob contents\n\t * @param encoding - encoding of contents; defaults to utf-8\n\t */\n\tconstructor(\n\t\tpublic readonly path: string,\n\t\tcontents: string,\n\t\tencoding: \"utf-8\" | \"base64\" = \"utf-8\",\n\t) {\n\t\tthis.value = { contents, encoding };\n\t}\n}\n\n/**\n * Basic implementation of a tree ITreeEntry\n * @internal\n */\nexport class TreeTreeEntry {\n\tpublic readonly mode = FileMode.Directory;\n\tpublic readonly type = TreeEntry.Tree;\n\n\t/**\n\t * Creates a tree ITreeEntry\n\t * @param path - path of entry\n\t * @param value - subtree\n\t */\n\tconstructor(\n\t\tpublic readonly path: string,\n\t\tpublic readonly value: ITree,\n\t) {}\n}\n\n/**\n * Basic implementation of an attachment ITreeEntry\n * @internal\n */\nexport class AttachmentTreeEntry {\n\tpublic readonly mode = FileMode.File;\n\tpublic readonly type = TreeEntry.Attachment;\n\tpublic readonly value: IAttachment;\n\n\t/**\n\t * Creates an attachment ITreeEntry\n\t * @param path - path of entry\n\t * @param id - id of external blob attachment\n\t */\n\tconstructor(\n\t\tpublic readonly path: string,\n\t\tpublic readonly id: string,\n\t) {\n\t\tthis.value = { id };\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildSnapshotTree.d.ts","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"buildSnapshotTree.d.ts","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAEN,aAAa,EACb,UAAU,EAEV,MAAM,sCAAsC,CAAC;AAmE9C;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,UAAU,EAAE,EACrB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GACnC,aAAa,CAGf"}
|
package/lib/buildSnapshotTree.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { stringToBuffer } from "@fluid-internal/client-utils";
|
|
6
|
-
import { assert } from "@fluidframework/core-utils";
|
|
7
|
-
import { FileMode, TreeEntry, } from "@fluidframework/protocol-definitions";
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
7
|
import { buildGitTreeHierarchy } from "@fluidframework/protocol-base";
|
|
8
|
+
import { FileMode, TreeEntry, } from "@fluidframework/protocol-definitions";
|
|
9
9
|
import { v4 as uuid } from "uuid";
|
|
10
10
|
function flattenCore(path, treeEntries, blobMap) {
|
|
11
11
|
const entries = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildSnapshotTree.js","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"buildSnapshotTree.js","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EACN,QAAQ,EAGR,SAAS,GACT,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,SAAS,WAAW,CACnB,IAAY,EACZ,WAAyB,EACzB,OAAqC;IAErC,MAAM,OAAO,GAAqB,EAAE,CAAC;IACrC,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE;QACpC,MAAM,OAAO,GAAG,GAAG,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QAE3C,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE;YACtC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC;YAC7B,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5D,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;YAClB,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YAExB,MAAM,KAAK,GAAmB;gBAC7B,IAAI,EAAE,QAA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,GAAG,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,qBAAqB,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport * as git from \"@fluidframework/gitresources\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport {\n\tFileMode,\n\tISnapshotTree,\n\tITreeEntry,\n\tTreeEntry,\n} from \"@fluidframework/protocol-definitions\";\nimport { v4 as uuid } from \"uuid\";\n\nfunction flattenCore(\n\tpath: string,\n\ttreeEntries: ITreeEntry[],\n\tblobMap: Map<string, ArrayBufferLike>,\n): git.ITreeEntry[] {\n\tconst entries: git.ITreeEntry[] = [];\n\tfor (const treeEntry of treeEntries) {\n\t\tconst subPath = `${path}${treeEntry.path}`;\n\n\t\tif (treeEntry.type === TreeEntry.Blob) {\n\t\t\tconst blob = treeEntry.value;\n\t\t\tconst buffer = stringToBuffer(blob.contents, blob.encoding);\n\t\t\tconst id = uuid();\n\t\t\tblobMap.set(id, buffer);\n\n\t\t\tconst entry: git.ITreeEntry = {\n\t\t\t\tmode: FileMode[treeEntry.mode],\n\t\t\t\tpath: subPath,\n\t\t\t\tsha: id,\n\t\t\t\tsize: 0,\n\t\t\t\ttype: \"blob\",\n\t\t\t\turl: \"\",\n\t\t\t};\n\t\t\tentries.push(entry);\n\t\t} else if (treeEntry.type === TreeEntry.Tree) {\n\t\t\tassert(\n\t\t\t\ttreeEntry.type === TreeEntry.Tree,\n\t\t\t\t0x101 /* \"Unexpected tree entry type on flatten!\" */,\n\t\t\t);\n\t\t\tconst t = treeEntry.value;\n\t\t\tconst entry: git.ITreeEntry = {\n\t\t\t\tmode: FileMode[treeEntry.mode],\n\t\t\t\tpath: subPath,\n\t\t\t\tsha: \"\",\n\t\t\t\tsize: -1,\n\t\t\t\ttype: \"tree\",\n\t\t\t\turl: \"\",\n\t\t\t};\n\t\t\tentries.push(entry);\n\n\t\t\tconst subTreeEntries = flattenCore(`${subPath}/`, t.entries, blobMap);\n\t\t\tentries.push(...subTreeEntries);\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Create a flatten view of an array of ITreeEntry\n *\n * @param tree - an array of ITreeEntry to flatten\n * @param blobMap - a map of blob's sha1 to content\n * @returns A flatten with of the ITreeEntry\n */\nfunction flatten(tree: ITreeEntry[], blobMap: Map<string, ArrayBufferLike>): git.ITree {\n\tconst entries = flattenCore(\"\", tree, blobMap);\n\treturn {\n\t\tsha: \"\",\n\t\ttree: entries,\n\t\turl: \"\",\n\t};\n}\n\n/**\n * Build a tree hierarchy base on an array of ITreeEntry\n *\n * @param entries - an array of ITreeEntry to flatten\n * @param blobMap - a map of blob's sha1 to content that gets filled with content from entries\n * NOTE: blobMap's validity is contingent on the returned promise's resolution\n * @returns the hierarchical tree\n * @internal\n */\nexport function buildSnapshotTree(\n\tentries: ITreeEntry[],\n\tblobMap: Map<string, ArrayBufferLike>,\n): ISnapshotTree {\n\tconst flattened = flatten(entries, blobMap);\n\treturn buildGitTreeHierarchy(flattened);\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { IDocumentService, IDocumentServiceFactory, IResolvedUrl } from "@fluidframework/driver-definitions";
|
|
6
|
+
import { IDocumentService, IDocumentServiceFactory, IResolvedUrl } from "@fluidframework/driver-definitions/internal";
|
|
7
7
|
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
8
8
|
/**
|
|
9
9
|
* This abstract class implements IDocumentServiceFactory interface. It uses delegation pattern.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentServiceFactoryProxy.d.ts","sourceRoot":"","sources":["../src/documentServiceFactoryProxy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACZ,MAAM,
|
|
1
|
+
{"version":3,"file":"documentServiceFactoryProxy.d.ts","sourceRoot":"","sources":["../src/documentServiceFactoryProxy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE;;;GAGG;AAEH,8BAAsB,2BAA4B,YAAW,uBAAuB;IACvE,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAAf,eAAe,EAAE,uBAAuB;IAErE,IAAW,cAAc,IAAI,uBAAuB,CAEnD;IAEY,eAAe,CAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,oBAAoB,EAAE,YAAY,EAClC,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IASf,qBAAqB,CACjC,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;CAG5B"}
|