@fluidframework/routerlicious-driver 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +10 -12
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +156 -0
- package/README.md +39 -1
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/routerlicious-driver.api.md +108 -0
- package/dist/cache.cjs +30 -0
- package/dist/cache.cjs.map +1 -0
- package/dist/cache.d.ts +7 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/{definitions.js → contracts.cjs} +1 -1
- package/dist/contracts.cjs.map +1 -0
- package/dist/contracts.d.ts +42 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/{createNewUtils.js → createNewUtils.cjs} +7 -5
- package/dist/createNewUtils.cjs.map +1 -0
- package/dist/createNewUtils.d.ts +1 -1
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/{defaultTokenProvider.js → defaultTokenProvider.cjs} +2 -1
- package/dist/defaultTokenProvider.cjs.map +1 -0
- package/dist/defaultTokenProvider.d.ts +1 -0
- package/dist/defaultTokenProvider.d.ts.map +1 -1
- package/dist/definitions.cjs +7 -0
- package/dist/definitions.cjs.map +1 -0
- package/dist/definitions.d.ts.map +1 -1
- package/dist/deltaStorageService.cjs +122 -0
- package/dist/deltaStorageService.cjs.map +1 -0
- package/dist/deltaStorageService.d.ts +7 -6
- package/dist/deltaStorageService.d.ts.map +1 -1
- package/dist/{documentDeltaConnection.js → documentDeltaConnection.cjs} +8 -13
- package/dist/documentDeltaConnection.cjs.map +1 -0
- package/dist/documentDeltaConnection.d.ts +3 -4
- package/dist/documentDeltaConnection.d.ts.map +1 -1
- package/dist/{documentService.js → documentService.cjs} +61 -64
- package/dist/documentService.cjs.map +1 -0
- package/dist/documentService.d.ts +12 -4
- package/dist/documentService.d.ts.map +1 -1
- package/dist/{documentServiceFactory.js → documentServiceFactory.cjs} +87 -33
- package/dist/documentServiceFactory.cjs.map +1 -0
- package/dist/documentServiceFactory.d.ts +5 -3
- package/dist/documentServiceFactory.d.ts.map +1 -1
- package/dist/{documentStorageService.js → documentStorageService.cjs} +18 -16
- package/dist/documentStorageService.cjs.map +1 -0
- package/dist/documentStorageService.d.ts +4 -3
- package/dist/documentStorageService.d.ts.map +1 -1
- package/dist/errorUtils.cjs +87 -0
- package/dist/errorUtils.cjs.map +1 -0
- package/dist/errorUtils.d.ts +56 -10
- package/dist/errorUtils.d.ts.map +1 -1
- package/dist/gitManager.cjs +46 -0
- package/dist/gitManager.cjs.map +1 -0
- package/dist/gitManager.d.ts +27 -0
- package/dist/gitManager.d.ts.map +1 -0
- package/dist/historian.cjs +72 -0
- package/dist/historian.cjs.map +1 -0
- package/dist/historian.d.ts +34 -0
- package/dist/historian.d.ts.map +1 -0
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/mapWithExpiration.cjs +105 -0
- package/dist/mapWithExpiration.cjs.map +1 -0
- package/dist/mapWithExpiration.d.ts +34 -0
- package/dist/mapWithExpiration.d.ts.map +1 -0
- package/dist/{nullBlobStorageService.js → nullBlobStorageService.cjs} +5 -5
- package/dist/nullBlobStorageService.cjs.map +1 -0
- package/dist/nullBlobStorageService.d.ts.map +1 -1
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/{policies.js → policies.cjs} +1 -1
- package/dist/policies.cjs.map +1 -0
- package/dist/policies.d.ts +22 -9
- package/dist/policies.d.ts.map +1 -1
- package/dist/r11sSnapshotParser.cjs +73 -0
- package/dist/r11sSnapshotParser.cjs.map +1 -0
- package/dist/r11sSnapshotParser.d.ts +14 -0
- package/dist/r11sSnapshotParser.d.ts.map +1 -0
- package/dist/restWrapper.cjs +249 -0
- package/dist/restWrapper.cjs.map +1 -0
- package/dist/restWrapper.d.ts +32 -12
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapperBase.cjs +89 -0
- package/dist/restWrapperBase.cjs.map +1 -0
- package/dist/restWrapperBase.d.ts +26 -0
- package/dist/restWrapperBase.d.ts.map +1 -0
- package/dist/retriableGitManager.cjs +40 -0
- package/dist/retriableGitManager.cjs.map +1 -0
- package/dist/retriableGitManager.d.ts +13 -23
- package/dist/retriableGitManager.d.ts.map +1 -1
- package/dist/routerlicious-driver-alpha.d.ts +92 -0
- package/dist/routerlicious-driver-beta.d.ts +98 -0
- package/dist/routerlicious-driver-public.d.ts +98 -0
- package/dist/routerlicious-driver-untrimmed.d.ts +261 -0
- package/dist/{shreddedSummaryDocumentStorageService.js → shreddedSummaryDocumentStorageService.cjs} +41 -34
- package/dist/shreddedSummaryDocumentStorageService.cjs.map +1 -0
- package/dist/shreddedSummaryDocumentStorageService.d.ts +6 -5
- package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/storageContracts.cjs +7 -0
- package/dist/storageContracts.cjs.map +1 -0
- package/dist/storageContracts.d.ts +45 -0
- package/dist/storageContracts.d.ts.map +1 -0
- package/dist/summaryTreeUploadManager.cjs +110 -0
- package/dist/summaryTreeUploadManager.cjs.map +1 -0
- package/dist/summaryTreeUploadManager.d.ts +23 -0
- package/dist/summaryTreeUploadManager.d.ts.map +1 -0
- package/dist/{tokens.js → tokens.cjs} +1 -1
- package/dist/tokens.cjs.map +1 -0
- package/dist/tokens.d.ts +34 -5
- package/dist/tokens.d.ts.map +1 -1
- package/dist/treeUtils.cjs +107 -0
- package/dist/treeUtils.cjs.map +1 -0
- package/dist/treeUtils.d.ts +58 -0
- package/dist/treeUtils.d.ts.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/{urlUtils.js → urlUtils.cjs} +21 -25
- package/dist/urlUtils.cjs.map +1 -0
- package/dist/urlUtils.d.ts +2 -2
- package/dist/urlUtils.d.ts.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.cjs +253 -0
- package/dist/wholeSummaryDocumentStorageService.cjs.map +1 -0
- package/dist/wholeSummaryDocumentStorageService.d.ts +10 -8
- package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/wholeSummaryUploadManager.cjs +37 -0
- package/dist/wholeSummaryUploadManager.cjs.map +1 -0
- package/dist/wholeSummaryUploadManager.d.ts +16 -0
- package/dist/wholeSummaryUploadManager.d.ts.map +1 -0
- package/lib/{cache.d.ts → cache.d.mts} +7 -0
- package/lib/cache.d.mts.map +1 -0
- package/lib/cache.mjs +25 -0
- package/lib/cache.mjs.map +1 -0
- package/lib/contracts.d.mts +42 -0
- package/lib/contracts.d.mts.map +1 -0
- package/lib/{definitions.js → contracts.mjs} +1 -1
- package/lib/contracts.mjs.map +1 -0
- package/lib/{createNewUtils.d.ts → createNewUtils.d.mts} +1 -1
- package/lib/{createNewUtils.d.ts.map → createNewUtils.d.mts.map} +1 -1
- package/lib/{createNewUtils.js → createNewUtils.mjs} +7 -5
- package/lib/createNewUtils.mjs.map +1 -0
- package/lib/{defaultTokenProvider.d.ts → defaultTokenProvider.d.mts} +2 -1
- package/lib/defaultTokenProvider.d.mts.map +1 -0
- package/lib/{defaultTokenProvider.js → defaultTokenProvider.mjs} +2 -1
- package/lib/defaultTokenProvider.mjs.map +1 -0
- package/lib/definitions.d.mts.map +1 -0
- package/lib/definitions.mjs +6 -0
- package/{dist/definitions.js.map → lib/definitions.mjs.map} +1 -1
- package/lib/{deltaStorageService.d.ts → deltaStorageService.d.mts} +8 -7
- package/lib/deltaStorageService.d.mts.map +1 -0
- package/lib/deltaStorageService.mjs +117 -0
- package/lib/deltaStorageService.mjs.map +1 -0
- package/lib/{documentDeltaConnection.d.ts → documentDeltaConnection.d.mts} +3 -4
- package/lib/documentDeltaConnection.d.mts.map +1 -0
- package/lib/{documentDeltaConnection.js → documentDeltaConnection.mjs} +8 -13
- package/lib/documentDeltaConnection.mjs.map +1 -0
- package/lib/{documentService.d.ts → documentService.d.mts} +16 -8
- package/lib/documentService.d.mts.map +1 -0
- package/lib/{documentService.js → documentService.mjs} +60 -44
- package/lib/documentService.mjs.map +1 -0
- package/lib/{documentServiceFactory.d.ts → documentServiceFactory.d.mts} +7 -5
- package/lib/documentServiceFactory.d.mts.map +1 -0
- package/lib/{documentServiceFactory.js → documentServiceFactory.mjs} +88 -34
- package/lib/documentServiceFactory.mjs.map +1 -0
- package/lib/{documentStorageService.d.ts → documentStorageService.d.mts} +7 -6
- package/lib/documentStorageService.d.mts.map +1 -0
- package/lib/{documentStorageService.js → documentStorageService.mjs} +19 -17
- package/lib/documentStorageService.mjs.map +1 -0
- package/lib/errorUtils.d.mts +93 -0
- package/lib/errorUtils.d.mts.map +1 -0
- package/lib/errorUtils.mjs +81 -0
- package/lib/errorUtils.mjs.map +1 -0
- package/lib/gitManager.d.mts +27 -0
- package/lib/gitManager.d.mts.map +1 -0
- package/lib/gitManager.mjs +42 -0
- package/lib/gitManager.mjs.map +1 -0
- package/lib/historian.d.mts +34 -0
- package/lib/historian.d.mts.map +1 -0
- package/lib/historian.mjs +67 -0
- package/lib/historian.mjs.map +1 -0
- package/lib/index.d.mts +10 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +8 -0
- package/lib/index.mjs.map +1 -0
- package/lib/mapWithExpiration.d.mts +34 -0
- package/lib/mapWithExpiration.d.mts.map +1 -0
- package/lib/mapWithExpiration.mjs +101 -0
- package/lib/mapWithExpiration.mjs.map +1 -0
- package/lib/nullBlobStorageService.d.mts.map +1 -0
- package/lib/{nullBlobStorageService.js → nullBlobStorageService.mjs} +5 -5
- package/lib/nullBlobStorageService.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/{policies.d.ts → policies.d.mts} +22 -9
- package/lib/policies.d.mts.map +1 -0
- package/lib/{policies.js → policies.mjs} +1 -1
- package/lib/policies.mjs.map +1 -0
- package/lib/r11sSnapshotParser.d.mts +14 -0
- package/lib/r11sSnapshotParser.d.mts.map +1 -0
- package/lib/r11sSnapshotParser.mjs +69 -0
- package/lib/r11sSnapshotParser.mjs.map +1 -0
- package/lib/restWrapper.d.mts +53 -0
- package/lib/restWrapper.d.mts.map +1 -0
- package/lib/restWrapper.mjs +236 -0
- package/lib/restWrapper.mjs.map +1 -0
- package/lib/restWrapperBase.d.mts +26 -0
- package/lib/restWrapperBase.d.mts.map +1 -0
- package/lib/restWrapperBase.mjs +84 -0
- package/lib/restWrapperBase.mjs.map +1 -0
- package/lib/retriableGitManager.d.mts +24 -0
- package/lib/retriableGitManager.d.mts.map +1 -0
- package/lib/retriableGitManager.mjs +36 -0
- package/lib/retriableGitManager.mjs.map +1 -0
- package/lib/routerlicious-driver-alpha.d.mts +92 -0
- package/lib/routerlicious-driver-beta.d.mts +98 -0
- package/lib/routerlicious-driver-public.d.mts +98 -0
- package/lib/routerlicious-driver-untrimmed.d.mts +261 -0
- package/lib/{shreddedSummaryDocumentStorageService.d.ts → shreddedSummaryDocumentStorageService.d.mts} +9 -8
- package/lib/shreddedSummaryDocumentStorageService.d.mts.map +1 -0
- package/lib/{shreddedSummaryDocumentStorageService.js → shreddedSummaryDocumentStorageService.mjs} +41 -34
- package/lib/shreddedSummaryDocumentStorageService.mjs.map +1 -0
- package/lib/storageContracts.d.mts +45 -0
- package/lib/storageContracts.d.mts.map +1 -0
- package/lib/storageContracts.mjs +6 -0
- package/lib/storageContracts.mjs.map +1 -0
- package/lib/summaryTreeUploadManager.d.mts +23 -0
- package/lib/summaryTreeUploadManager.d.mts.map +1 -0
- package/lib/summaryTreeUploadManager.mjs +106 -0
- package/lib/summaryTreeUploadManager.mjs.map +1 -0
- package/lib/{tokens.d.ts → tokens.d.mts} +34 -5
- package/lib/tokens.d.mts.map +1 -0
- package/lib/{tokens.js → tokens.mjs} +1 -1
- package/lib/tokens.mjs.map +1 -0
- package/lib/treeUtils.d.mts +58 -0
- package/lib/treeUtils.d.mts.map +1 -0
- package/lib/treeUtils.mjs +100 -0
- package/lib/treeUtils.mjs.map +1 -0
- package/lib/{urlUtils.d.ts → urlUtils.d.mts} +2 -2
- package/lib/urlUtils.d.mts.map +1 -0
- package/lib/urlUtils.mjs +38 -0
- package/lib/urlUtils.mjs.map +1 -0
- package/lib/{wholeSummaryDocumentStorageService.d.ts → wholeSummaryDocumentStorageService.d.mts} +12 -10
- package/lib/wholeSummaryDocumentStorageService.d.mts.map +1 -0
- package/lib/wholeSummaryDocumentStorageService.mjs +249 -0
- package/lib/wholeSummaryDocumentStorageService.mjs.map +1 -0
- package/lib/wholeSummaryUploadManager.d.mts +16 -0
- package/lib/wholeSummaryUploadManager.d.mts.map +1 -0
- package/lib/wholeSummaryUploadManager.mjs +33 -0
- package/lib/wholeSummaryUploadManager.mjs.map +1 -0
- package/package.json +104 -68
- package/prettier.config.cjs +8 -0
- package/src/cache.ts +25 -9
- package/src/contracts.ts +60 -0
- package/src/createNewUtils.ts +26 -24
- package/src/defaultTokenProvider.ts +14 -15
- package/src/definitions.ts +2 -2
- package/src/deltaStorageService.ts +145 -91
- package/src/documentDeltaConnection.ts +54 -52
- package/src/documentService.ts +272 -242
- package/src/documentServiceFactory.ts +338 -237
- package/src/documentStorageService.ts +92 -84
- package/src/errorUtils.ts +117 -79
- package/src/gitManager.ts +67 -0
- package/src/historian.ts +121 -0
- package/src/index.ts +15 -8
- package/src/mapWithExpiration.ts +124 -0
- package/src/nullBlobStorageService.ts +24 -21
- package/src/packageVersion.ts +1 -1
- package/src/policies.ts +51 -38
- package/src/r11sSnapshotParser.ts +82 -0
- package/src/restWrapper.ts +400 -216
- package/src/restWrapperBase.ts +146 -0
- package/src/retriableGitManager.ts +76 -153
- package/src/shreddedSummaryDocumentStorageService.ts +214 -195
- package/src/storageContracts.ts +63 -0
- package/src/summaryTreeUploadManager.ts +155 -0
- package/src/tokens.ts +74 -39
- package/src/treeUtils.ts +138 -0
- package/src/urlUtils.ts +27 -28
- package/src/wholeSummaryDocumentStorageService.ts +352 -252
- package/src/wholeSummaryUploadManager.ts +64 -0
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +10 -13
- package/dist/cache.js +0 -20
- package/dist/cache.js.map +0 -1
- package/dist/createNewUtils.js.map +0 -1
- package/dist/defaultTokenProvider.js.map +0 -1
- package/dist/deltaStorageService.js +0 -82
- package/dist/deltaStorageService.js.map +0 -1
- package/dist/documentDeltaConnection.js.map +0 -1
- package/dist/documentService.js.map +0 -1
- package/dist/documentServiceFactory.js.map +0 -1
- package/dist/documentStorageService.js.map +0 -1
- package/dist/errorUtils.js +0 -56
- package/dist/errorUtils.js.map +0 -1
- package/dist/index.js +0 -25
- package/dist/index.js.map +0 -1
- package/dist/nullBlobStorageService.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/policies.js.map +0 -1
- package/dist/restWrapper.js +0 -153
- package/dist/restWrapper.js.map +0 -1
- package/dist/retriableGitManager.js +0 -76
- package/dist/retriableGitManager.js.map +0 -1
- package/dist/shreddedSummaryDocumentStorageService.js.map +0 -1
- package/dist/tokens.js.map +0 -1
- package/dist/urlUtils.js.map +0 -1
- package/dist/wholeSummaryDocumentStorageService.js +0 -191
- package/dist/wholeSummaryDocumentStorageService.js.map +0 -1
- package/lib/cache.d.ts.map +0 -1
- package/lib/cache.js +0 -16
- package/lib/cache.js.map +0 -1
- package/lib/createNewUtils.js.map +0 -1
- package/lib/defaultTokenProvider.d.ts.map +0 -1
- package/lib/defaultTokenProvider.js.map +0 -1
- package/lib/definitions.d.ts.map +0 -1
- package/lib/definitions.js.map +0 -1
- package/lib/deltaStorageService.d.ts.map +0 -1
- package/lib/deltaStorageService.js +0 -77
- package/lib/deltaStorageService.js.map +0 -1
- package/lib/documentDeltaConnection.d.ts.map +0 -1
- package/lib/documentDeltaConnection.js.map +0 -1
- package/lib/documentService.d.ts.map +0 -1
- package/lib/documentService.js.map +0 -1
- package/lib/documentServiceFactory.d.ts.map +0 -1
- package/lib/documentServiceFactory.js.map +0 -1
- package/lib/documentStorageService.d.ts.map +0 -1
- package/lib/documentStorageService.js.map +0 -1
- package/lib/errorUtils.d.ts +0 -47
- package/lib/errorUtils.d.ts.map +0 -1
- package/lib/errorUtils.js +0 -50
- package/lib/errorUtils.js.map +0 -1
- package/lib/index.d.ts +0 -13
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -13
- package/lib/index.js.map +0 -1
- package/lib/nullBlobStorageService.d.ts.map +0 -1
- package/lib/nullBlobStorageService.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/policies.d.ts.map +0 -1
- package/lib/policies.js.map +0 -1
- package/lib/restWrapper.d.ts +0 -33
- package/lib/restWrapper.d.ts.map +0 -1
- package/lib/restWrapper.js +0 -144
- package/lib/restWrapper.js.map +0 -1
- package/lib/retriableGitManager.d.ts +0 -34
- package/lib/retriableGitManager.d.ts.map +0 -1
- package/lib/retriableGitManager.js +0 -72
- package/lib/retriableGitManager.js.map +0 -1
- package/lib/shreddedSummaryDocumentStorageService.d.ts.map +0 -1
- package/lib/shreddedSummaryDocumentStorageService.js.map +0 -1
- package/lib/tokens.d.ts.map +0 -1
- package/lib/tokens.js.map +0 -1
- package/lib/urlUtils.d.ts.map +0 -1
- package/lib/urlUtils.js +0 -42
- package/lib/urlUtils.js.map +0 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts.map +0 -1
- package/lib/wholeSummaryDocumentStorageService.js +0 -187
- package/lib/wholeSummaryDocumentStorageService.js.map +0 -1
- package/tsconfig.esnext.json +0 -7
- /package/lib/{definitions.d.ts → definitions.d.mts} +0 -0
- /package/lib/{nullBlobStorageService.d.ts → nullBlobStorageService.d.mts} +0 -0
|
@@ -3,267 +3,367 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
6
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
ITelemetryLoggerExt,
|
|
8
|
+
MonitoringContext,
|
|
9
|
+
PerformanceEvent,
|
|
10
|
+
createChildMonitoringContext,
|
|
11
|
+
} from "@fluidframework/telemetry-utils";
|
|
12
|
+
import { performance, stringToBuffer, Uint8ArrayToString } from "@fluid-internal/client-utils";
|
|
13
|
+
import { assert } from "@fluidframework/core-utils";
|
|
14
|
+
import { getW3CData, promiseRaceWithWinner } from "@fluidframework/driver-base";
|
|
12
15
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
IDocumentStorageService,
|
|
17
|
+
ISummaryContext,
|
|
18
|
+
IDocumentStorageServicePolicies,
|
|
16
19
|
} from "@fluidframework/driver-definitions";
|
|
17
20
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
ISummaryHandle,
|
|
24
|
-
ISummaryTree,
|
|
25
|
-
IVersion,
|
|
21
|
+
ICreateBlobResponse,
|
|
22
|
+
ISnapshotTree,
|
|
23
|
+
ISummaryHandle,
|
|
24
|
+
ISummaryTree,
|
|
25
|
+
IVersion,
|
|
26
26
|
} from "@fluidframework/protocol-definitions";
|
|
27
|
-
import {
|
|
28
|
-
convertWholeFlatSummaryToSnapshotTreeAndBlobs,
|
|
29
|
-
GitManager,
|
|
30
|
-
ISummaryUploadManager,
|
|
31
|
-
WholeSummaryUploadManager,
|
|
32
|
-
} from "@fluidframework/server-services-client";
|
|
33
|
-
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
34
27
|
import { ICache, InMemoryCache } from "./cache";
|
|
35
|
-
import { ISnapshotTreeVersion } from "./definitions";
|
|
36
28
|
import { IRouterliciousDriverPolicies } from "./policies";
|
|
29
|
+
import {
|
|
30
|
+
convertSnapshotAndBlobsToSummaryTree,
|
|
31
|
+
evalBlobsAndTrees,
|
|
32
|
+
validateBlobsAndTrees,
|
|
33
|
+
} from "./treeUtils";
|
|
34
|
+
import { GitManager } from "./gitManager";
|
|
35
|
+
import { WholeSummaryUploadManager } from "./wholeSummaryUploadManager";
|
|
36
|
+
import { ISummaryUploadManager } from "./storageContracts";
|
|
37
|
+
import { IR11sResponse } from "./restWrapper";
|
|
38
|
+
import { INormalizedWholeSnapshot, IWholeFlatSnapshot } from "./contracts";
|
|
39
|
+
import { convertWholeFlatSnapshotToSnapshotTreeAndBlobs } from "./r11sSnapshotParser";
|
|
37
40
|
|
|
38
41
|
const latestSnapshotId: string = "latest";
|
|
39
42
|
|
|
40
43
|
export class WholeSummaryDocumentStorageService implements IDocumentStorageService {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
44
|
+
private readonly mc: MonitoringContext;
|
|
45
|
+
private firstVersionsCall: boolean = true;
|
|
46
|
+
|
|
47
|
+
public readonly repositoryUrl = "";
|
|
48
|
+
|
|
49
|
+
private async getSummaryUploadManager(): Promise<ISummaryUploadManager> {
|
|
50
|
+
const manager = await this.getStorageManager();
|
|
51
|
+
return new WholeSummaryUploadManager(manager);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
constructor(
|
|
55
|
+
protected readonly id: string,
|
|
56
|
+
protected readonly manager: GitManager,
|
|
57
|
+
protected readonly logger: ITelemetryLoggerExt,
|
|
58
|
+
public readonly policies: IDocumentStorageServicePolicies,
|
|
59
|
+
private readonly driverPolicies?: IRouterliciousDriverPolicies,
|
|
60
|
+
private readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),
|
|
61
|
+
private readonly snapshotTreeCache: ICache<INormalizedWholeSnapshot> = new InMemoryCache(),
|
|
62
|
+
private readonly noCacheGitManager?: GitManager,
|
|
63
|
+
private readonly getStorageManager: (
|
|
64
|
+
disableCache?: boolean,
|
|
65
|
+
) => Promise<GitManager> = async (disableCache) =>
|
|
66
|
+
disableCache && this.noCacheGitManager !== undefined
|
|
67
|
+
? this.noCacheGitManager
|
|
68
|
+
: this.manager,
|
|
69
|
+
) {
|
|
70
|
+
this.mc = createChildMonitoringContext({
|
|
71
|
+
logger,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
|
76
|
+
public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
|
|
77
|
+
if (versionId !== this.id && versionId !== null) {
|
|
78
|
+
// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is
|
|
79
|
+
return [
|
|
80
|
+
{
|
|
81
|
+
id: versionId,
|
|
82
|
+
treeId: undefined!,
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
// If this is the first versions call for the document, we know we will want the latest summary.
|
|
87
|
+
// Fetch latest summary, cache it, and return its id.
|
|
88
|
+
if (this.firstVersionsCall && count === 1) {
|
|
89
|
+
const normalizedSnapshotContents = await PerformanceEvent.timedExecAsync(
|
|
90
|
+
this.logger,
|
|
91
|
+
{
|
|
92
|
+
eventName: "ObtainSnapshot",
|
|
93
|
+
versionId: versionId ?? undefined,
|
|
94
|
+
count,
|
|
95
|
+
enableDiscovery: this.driverPolicies?.enableDiscovery,
|
|
96
|
+
},
|
|
97
|
+
async (event) => {
|
|
98
|
+
let method: string;
|
|
99
|
+
const cachedSnapshotP = this.snapshotTreeCache.get(
|
|
100
|
+
this.getCacheKey(latestSnapshotId),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const networkSnapshotP = !this.driverPolicies?.enableDiscovery
|
|
104
|
+
? this.fetchSnapshotTree(latestSnapshotId, false, "getVersions")
|
|
105
|
+
: this.fetchSnapshotTree(latestSnapshotId, true, "getVersions");
|
|
106
|
+
|
|
107
|
+
const promiseRaceWinner = await promiseRaceWithWinner([
|
|
108
|
+
cachedSnapshotP.catch(() => undefined),
|
|
109
|
+
networkSnapshotP.catch(() => undefined),
|
|
110
|
+
]);
|
|
111
|
+
|
|
112
|
+
let retrievedSnapshot = promiseRaceWinner.value;
|
|
113
|
+
method = promiseRaceWinner.index === 0 ? "cache" : "network";
|
|
114
|
+
|
|
115
|
+
if (retrievedSnapshot === undefined) {
|
|
116
|
+
// if network failed -> wait for cache ( then return network failure)
|
|
117
|
+
// If cache returned empty or failed -> wait for network (success of failure)
|
|
118
|
+
if (promiseRaceWinner.index === 1) {
|
|
119
|
+
retrievedSnapshot = await cachedSnapshotP;
|
|
120
|
+
method = "cache";
|
|
121
|
+
}
|
|
122
|
+
if (retrievedSnapshot === undefined) {
|
|
123
|
+
retrievedSnapshot = await networkSnapshotP;
|
|
124
|
+
method = "network";
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
event.end({
|
|
128
|
+
method,
|
|
129
|
+
});
|
|
130
|
+
return retrievedSnapshot;
|
|
131
|
+
},
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const _id = await this.initializeFromSnapshot(normalizedSnapshotContents);
|
|
135
|
+
this.firstVersionsCall = false;
|
|
136
|
+
return [
|
|
137
|
+
{
|
|
138
|
+
id: _id,
|
|
139
|
+
treeId: normalizedSnapshotContents.snapshotTree.id!,
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Otherwise, get the latest version of the document as normal.
|
|
145
|
+
const id = versionId ? versionId : this.id;
|
|
146
|
+
const commits = await PerformanceEvent.timedExecAsync(
|
|
147
|
+
this.logger,
|
|
148
|
+
{
|
|
149
|
+
eventName: "getVersions",
|
|
150
|
+
versionId: id,
|
|
151
|
+
count,
|
|
152
|
+
},
|
|
153
|
+
async () => {
|
|
154
|
+
const manager = await this.getStorageManager();
|
|
155
|
+
return (await manager.getCommits(id, count)).content;
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
return commits.map((commit) => ({
|
|
159
|
+
date: commit.commit.author.date,
|
|
160
|
+
id: commit.sha,
|
|
161
|
+
treeId: commit.commit.tree.sha,
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
|
166
|
+
public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {
|
|
167
|
+
let requestVersion = version;
|
|
168
|
+
if (!requestVersion) {
|
|
169
|
+
const versions = await this.getVersions(this.id, 1);
|
|
170
|
+
if (versions.length === 0) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
requestVersion = versions[0];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
let normalizedWholeSnapshot = await this.snapshotTreeCache.get(
|
|
178
|
+
this.getCacheKey(requestVersion.id),
|
|
179
|
+
);
|
|
180
|
+
if (normalizedWholeSnapshot !== undefined) {
|
|
181
|
+
return normalizedWholeSnapshot.snapshotTree;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
normalizedWholeSnapshot = await this.fetchSnapshotTree(
|
|
185
|
+
requestVersion.id,
|
|
186
|
+
undefined,
|
|
187
|
+
"getSnapshotTree",
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
// Currently retrieving blobs from network is not supported by AFR for WholeSummaryDocumentStorageService
|
|
191
|
+
// Blobs are expected to be put in the cache
|
|
192
|
+
await this.updateBlobsCache(normalizedWholeSnapshot.blobs);
|
|
193
|
+
|
|
194
|
+
return normalizedWholeSnapshot.snapshotTree;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
public async readBlob(blobId: string): Promise<ArrayBufferLike> {
|
|
198
|
+
const cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));
|
|
199
|
+
if (cachedBlob !== undefined) {
|
|
200
|
+
return cachedBlob;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Note: AFR does not support readBlobs, but potentially other r11s like servers do
|
|
204
|
+
const blob = await PerformanceEvent.timedExecAsync(
|
|
205
|
+
this.logger,
|
|
206
|
+
{
|
|
207
|
+
eventName: "readBlob",
|
|
208
|
+
blobId,
|
|
209
|
+
},
|
|
210
|
+
async (event) => {
|
|
211
|
+
const manager = await this.getStorageManager();
|
|
212
|
+
const response = (await manager.getBlob(blobId)).content;
|
|
213
|
+
event.end({
|
|
214
|
+
size: response.size,
|
|
215
|
+
});
|
|
216
|
+
return response;
|
|
217
|
+
},
|
|
218
|
+
undefined, // workers
|
|
219
|
+
undefined, // recordHeapSize
|
|
220
|
+
this.mc.config.getNumber("Fluid.Driver.ReadBlobTelemetrySampling"),
|
|
221
|
+
);
|
|
222
|
+
const bufferValue = stringToBuffer(blob.content, blob.encoding);
|
|
223
|
+
|
|
224
|
+
await this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);
|
|
225
|
+
|
|
226
|
+
return bufferValue;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
public async uploadSummaryWithContext(
|
|
230
|
+
summary: ISummaryTree,
|
|
231
|
+
context: ISummaryContext,
|
|
232
|
+
): Promise<string> {
|
|
233
|
+
const summaryHandle = await PerformanceEvent.timedExecAsync(
|
|
234
|
+
this.logger,
|
|
235
|
+
{
|
|
236
|
+
eventName: "uploadSummaryWithContext",
|
|
237
|
+
proposalHandle: context.proposalHandle,
|
|
238
|
+
ackHandle: context.ackHandle,
|
|
239
|
+
referenceSequenceNumber: context.referenceSequenceNumber,
|
|
240
|
+
},
|
|
241
|
+
async () => {
|
|
242
|
+
const summaryUploadManager = await this.getSummaryUploadManager();
|
|
243
|
+
return summaryUploadManager.writeSummaryTree(
|
|
244
|
+
summary,
|
|
245
|
+
context.ackHandle ?? "",
|
|
246
|
+
"channel",
|
|
247
|
+
);
|
|
248
|
+
},
|
|
249
|
+
);
|
|
250
|
+
return summaryHandle;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
public async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {
|
|
254
|
+
const wholeFlatSnapshot = await PerformanceEvent.timedExecAsync(
|
|
255
|
+
this.logger,
|
|
256
|
+
{
|
|
257
|
+
eventName: "getWholeFlatSummary",
|
|
258
|
+
treeId: summaryHandle.handle,
|
|
259
|
+
},
|
|
260
|
+
async (event) => {
|
|
261
|
+
const manager = await this.getStorageManager();
|
|
262
|
+
const response = await manager.getSnapshot(summaryHandle.handle);
|
|
263
|
+
event.end({
|
|
264
|
+
size: response.content.trees[0]?.entries.length,
|
|
265
|
+
});
|
|
266
|
+
return response.content;
|
|
267
|
+
},
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
const { blobs, snapshotTree } = convertWholeFlatSnapshotToSnapshotTreeAndBlobs(
|
|
271
|
+
wholeFlatSnapshot,
|
|
272
|
+
"",
|
|
273
|
+
);
|
|
274
|
+
return convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {
|
|
278
|
+
const uint8ArrayFile = new Uint8Array(file);
|
|
279
|
+
return PerformanceEvent.timedExecAsync(
|
|
280
|
+
this.logger,
|
|
281
|
+
{
|
|
282
|
+
eventName: "createBlob",
|
|
283
|
+
size: uint8ArrayFile.length,
|
|
284
|
+
},
|
|
285
|
+
async (event) => {
|
|
286
|
+
const manager = await this.getStorageManager();
|
|
287
|
+
const response = await manager
|
|
288
|
+
.createBlob(Uint8ArrayToString(uint8ArrayFile, "base64"), "base64")
|
|
289
|
+
.then((r) => ({ id: r.content.sha, url: r.content.url }));
|
|
290
|
+
event.end({
|
|
291
|
+
blobId: response.id,
|
|
292
|
+
});
|
|
293
|
+
return response;
|
|
294
|
+
},
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
private async fetchSnapshotTree(
|
|
299
|
+
versionId: string,
|
|
300
|
+
disableCache?: boolean,
|
|
301
|
+
scenarioName?: string,
|
|
302
|
+
): Promise<INormalizedWholeSnapshot> {
|
|
303
|
+
const normalizedWholeSummary = await PerformanceEvent.timedExecAsync(
|
|
304
|
+
this.logger,
|
|
305
|
+
{
|
|
306
|
+
eventName: "getWholeFlatSummary",
|
|
307
|
+
treeId: versionId,
|
|
308
|
+
scenarioName,
|
|
309
|
+
},
|
|
310
|
+
async (event) => {
|
|
311
|
+
const manager = await this.getStorageManager(disableCache);
|
|
312
|
+
const response: IR11sResponse<IWholeFlatSnapshot> =
|
|
313
|
+
await manager.getSnapshot(versionId);
|
|
314
|
+
const start = performance.now();
|
|
315
|
+
const snapshot: INormalizedWholeSnapshot =
|
|
316
|
+
convertWholeFlatSnapshotToSnapshotTreeAndBlobs(response.content);
|
|
317
|
+
const snapshotConversionTime = performance.now() - start;
|
|
318
|
+
validateBlobsAndTrees(snapshot.snapshotTree);
|
|
319
|
+
const { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);
|
|
320
|
+
|
|
321
|
+
event.end({
|
|
322
|
+
size: response.content.trees[0]?.entries.length,
|
|
323
|
+
trees,
|
|
324
|
+
blobs: numBlobs,
|
|
325
|
+
encodedBlobsSize,
|
|
326
|
+
sequenceNumber: snapshot.sequenceNumber,
|
|
327
|
+
...response.propsToLog,
|
|
328
|
+
snapshotConversionTime,
|
|
329
|
+
...getW3CData(response.requestUrl, "xmlhttprequest"),
|
|
330
|
+
});
|
|
331
|
+
return snapshot;
|
|
332
|
+
},
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
// Also add the result into the cache.
|
|
336
|
+
await this.snapshotTreeCache
|
|
337
|
+
.put(this.getCacheKey(versionId), normalizedWholeSummary)
|
|
338
|
+
.catch(() => undefined);
|
|
339
|
+
return normalizedWholeSummary;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
private async initializeFromSnapshot(
|
|
343
|
+
normalizedWholeSummary: INormalizedWholeSnapshot,
|
|
344
|
+
): Promise<string> {
|
|
345
|
+
const snapshotId = normalizedWholeSummary.id;
|
|
346
|
+
assert(snapshotId !== undefined, 0x275 /* "Root tree should contain the id" */);
|
|
347
|
+
const cachePs: Promise<any>[] = [
|
|
348
|
+
this.snapshotTreeCache.put(this.getCacheKey(snapshotId), normalizedWholeSummary),
|
|
349
|
+
this.updateBlobsCache(normalizedWholeSummary.blobs),
|
|
350
|
+
];
|
|
351
|
+
|
|
352
|
+
await Promise.all(cachePs);
|
|
353
|
+
|
|
354
|
+
return snapshotId;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
private async updateBlobsCache(blobs: Map<string, ArrayBuffer>): Promise<void> {
|
|
358
|
+
const blobCachePutPs: Promise<void>[] = [];
|
|
359
|
+
blobs.forEach((value, id) => {
|
|
360
|
+
const cacheKey = this.getCacheKey(id);
|
|
361
|
+
blobCachePutPs.push(this.blobCache.put(cacheKey, value));
|
|
362
|
+
});
|
|
363
|
+
await Promise.all(blobCachePutPs);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
private getCacheKey(blobId: string): string {
|
|
367
|
+
return `${this.id}:${blobId}`;
|
|
368
|
+
}
|
|
269
369
|
}
|