@fluidframework/routerlicious-driver 2.0.0-internal.8.0.1 → 2.0.0-rc.1.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 +34 -0
- package/README.md +0 -6
- package/api-extractor-esm.json +4 -0
- package/api-extractor-lint.json +1 -10
- package/api-extractor.json +1 -9
- package/api-report/routerlicious-driver.api.md +2 -2
- package/dist/{cache.cjs → cache.js} +2 -2
- package/dist/cache.js.map +1 -0
- package/dist/{policies.cjs → contracts.js} +1 -1
- package/dist/contracts.js.map +1 -0
- package/dist/{createNewUtils.cjs → createNewUtils.js} +1 -1
- package/dist/createNewUtils.js.map +1 -0
- package/dist/{defaultTokenProvider.cjs → defaultTokenProvider.js} +1 -1
- package/dist/defaultTokenProvider.js.map +1 -0
- package/dist/{definitions.cjs → definitions.js} +1 -1
- package/dist/definitions.js.map +1 -0
- package/dist/{deltaStorageService.cjs → deltaStorageService.js} +1 -1
- package/dist/deltaStorageService.js.map +1 -0
- package/dist/{documentDeltaConnection.cjs → documentDeltaConnection.js} +3 -3
- package/dist/documentDeltaConnection.js.map +1 -0
- package/dist/{documentService.cjs → documentService.js} +9 -9
- package/dist/documentService.js.map +1 -0
- package/dist/{documentServiceFactory.cjs → documentServiceFactory.js} +6 -6
- package/dist/documentServiceFactory.js.map +1 -0
- package/dist/{documentStorageService.cjs → documentStorageService.js} +3 -3
- package/dist/documentStorageService.js.map +1 -0
- package/dist/errorUtils.d.ts +0 -7
- package/dist/errorUtils.d.ts.map +1 -1
- package/dist/{errorUtils.cjs → errorUtils.js} +2 -2
- package/dist/errorUtils.js.map +1 -0
- package/dist/{gitManager.cjs → gitManager.js} +1 -1
- package/dist/gitManager.js.map +1 -0
- package/dist/{historian.cjs → historian.js} +1 -1
- package/dist/historian.js.map +1 -0
- package/dist/{index.cjs → index.js} +4 -4
- package/dist/index.js.map +1 -0
- package/dist/{mapWithExpiration.cjs → mapWithExpiration.js} +1 -1
- package/dist/mapWithExpiration.js.map +1 -0
- package/dist/{nullBlobStorageService.cjs → nullBlobStorageService.js} +1 -1
- package/dist/nullBlobStorageService.js.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/{packageVersion.cjs → packageVersion.js} +2 -2
- package/dist/packageVersion.js.map +1 -0
- package/dist/{contracts.cjs → policies.js} +1 -1
- package/dist/policies.js.map +1 -0
- package/dist/{r11sSnapshotParser.cjs → r11sSnapshotParser.js} +1 -1
- package/dist/r11sSnapshotParser.js.map +1 -0
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/{restWrapper.cjs → restWrapper.js} +4 -4
- package/dist/restWrapper.js.map +1 -0
- package/dist/{restWrapperBase.cjs → restWrapperBase.js} +1 -1
- package/dist/restWrapperBase.js.map +1 -0
- package/dist/{retriableGitManager.cjs → retriableGitManager.js} +1 -1
- package/dist/retriableGitManager.js.map +1 -0
- package/dist/routerlicious-driver-alpha.d.ts +2 -2
- package/dist/routerlicious-driver-beta.d.ts +67 -4
- package/dist/routerlicious-driver-public.d.ts +67 -4
- package/dist/routerlicious-driver-untrimmed.d.ts +2 -9
- package/dist/{shreddedSummaryDocumentStorageService.cjs → shreddedSummaryDocumentStorageService.js} +4 -4
- package/dist/shreddedSummaryDocumentStorageService.js.map +1 -0
- package/dist/storageContracts.js +7 -0
- package/dist/storageContracts.js.map +1 -0
- package/dist/{summaryTreeUploadManager.cjs → summaryTreeUploadManager.js} +1 -1
- package/dist/summaryTreeUploadManager.js.map +1 -0
- package/dist/tokens.d.ts +2 -2
- package/dist/{tokens.cjs → tokens.js} +1 -1
- package/dist/tokens.js.map +1 -0
- package/dist/{treeUtils.cjs → treeUtils.js} +1 -1
- package/dist/treeUtils.js.map +1 -0
- package/dist/{urlUtils.cjs → urlUtils.js} +1 -1
- package/dist/urlUtils.js.map +1 -0
- package/dist/{wholeSummaryDocumentStorageService.cjs → wholeSummaryDocumentStorageService.js} +5 -5
- package/dist/wholeSummaryDocumentStorageService.js.map +1 -0
- package/dist/{wholeSummaryUploadManager.cjs → wholeSummaryUploadManager.js} +1 -1
- package/dist/wholeSummaryUploadManager.js.map +1 -0
- package/lib/{cache.d.ts → cache.d.mts} +1 -1
- package/lib/cache.d.mts.map +1 -0
- package/lib/{contracts.d.ts → contracts.d.mts} +1 -1
- package/lib/contracts.d.mts.map +1 -0
- package/lib/{createNewUtils.d.ts → createNewUtils.d.mts} +1 -1
- package/lib/createNewUtils.d.mts.map +1 -0
- package/lib/{defaultTokenProvider.d.ts → defaultTokenProvider.d.mts} +1 -1
- package/lib/defaultTokenProvider.d.mts.map +1 -0
- package/lib/{definitions.d.ts → definitions.d.mts} +1 -1
- package/lib/definitions.d.mts.map +1 -0
- package/lib/{deltaStorageService.d.ts → deltaStorageService.d.mts} +1 -1
- package/lib/deltaStorageService.d.mts.map +1 -0
- package/lib/{documentDeltaConnection.d.ts → documentDeltaConnection.d.mts} +1 -1
- package/lib/documentDeltaConnection.d.mts.map +1 -0
- package/lib/{documentService.d.ts → documentService.d.mts} +1 -1
- package/lib/documentService.d.mts.map +1 -0
- package/lib/{documentServiceFactory.d.ts → documentServiceFactory.d.mts} +1 -1
- package/lib/documentServiceFactory.d.mts.map +1 -0
- package/lib/{documentStorageService.d.ts → documentStorageService.d.mts} +1 -1
- package/lib/documentStorageService.d.mts.map +1 -0
- package/lib/{errorUtils.d.ts → errorUtils.d.mts} +1 -8
- package/lib/errorUtils.d.mts.map +1 -0
- package/lib/{gitManager.d.ts → gitManager.d.mts} +1 -1
- package/lib/gitManager.d.mts.map +1 -0
- package/lib/{historian.d.ts → historian.d.mts} +1 -1
- package/lib/historian.d.mts.map +1 -0
- package/lib/{index.d.ts → index.d.mts} +1 -1
- package/lib/index.d.mts.map +1 -0
- package/lib/{mapWithExpiration.d.ts → mapWithExpiration.d.mts} +1 -1
- package/lib/mapWithExpiration.d.mts.map +1 -0
- package/lib/{nullBlobStorageService.d.ts → nullBlobStorageService.d.mts} +1 -1
- package/lib/nullBlobStorageService.d.mts.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +2 -2
- package/lib/packageVersion.d.mts.map +1 -0
- package/lib/packageVersion.mjs +1 -1
- package/lib/packageVersion.mjs.map +1 -1
- package/lib/{policies.d.ts → policies.d.mts} +1 -1
- package/lib/policies.d.mts.map +1 -0
- package/lib/{r11sSnapshotParser.d.ts → r11sSnapshotParser.d.mts} +1 -1
- package/lib/r11sSnapshotParser.d.mts.map +1 -0
- package/lib/{restWrapper.d.ts → restWrapper.d.mts} +1 -1
- package/lib/restWrapper.d.mts.map +1 -0
- package/lib/restWrapper.mjs.map +1 -1
- package/lib/{restWrapperBase.d.ts → restWrapperBase.d.mts} +1 -1
- package/lib/restWrapperBase.d.mts.map +1 -0
- package/lib/{retriableGitManager.d.ts → retriableGitManager.d.mts} +1 -1
- package/lib/retriableGitManager.d.mts.map +1 -0
- package/lib/{routerlicious-driver-alpha.d.ts → routerlicious-driver-alpha.d.mts} +2 -2
- package/lib/routerlicious-driver-beta.d.mts +98 -0
- package/lib/routerlicious-driver-public.d.mts +98 -0
- package/lib/{routerlicious-driver-untrimmed.d.ts → routerlicious-driver-untrimmed.d.mts} +2 -9
- package/lib/{shreddedSummaryDocumentStorageService.d.ts → shreddedSummaryDocumentStorageService.d.mts} +1 -1
- package/lib/shreddedSummaryDocumentStorageService.d.mts.map +1 -0
- package/lib/{storageContracts.d.ts → storageContracts.d.mts} +1 -1
- package/lib/storageContracts.d.mts.map +1 -0
- package/lib/{summaryTreeUploadManager.d.ts → summaryTreeUploadManager.d.mts} +1 -1
- package/lib/summaryTreeUploadManager.d.mts.map +1 -0
- package/lib/{tokens.d.ts → tokens.d.mts} +3 -3
- package/lib/tokens.d.mts.map +1 -0
- package/lib/tokens.mjs.map +1 -1
- package/lib/{treeUtils.d.ts → treeUtils.d.mts} +1 -1
- package/lib/treeUtils.d.mts.map +1 -0
- package/lib/{urlUtils.d.ts → urlUtils.d.mts} +1 -1
- package/lib/urlUtils.d.mts.map +1 -0
- package/lib/{wholeSummaryDocumentStorageService.d.ts → wholeSummaryDocumentStorageService.d.mts} +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.mts.map +1 -0
- package/lib/{wholeSummaryUploadManager.d.ts → wholeSummaryUploadManager.d.mts} +1 -1
- package/lib/wholeSummaryUploadManager.d.mts.map +1 -0
- package/package.json +80 -28
- package/src/packageVersion.ts +1 -1
- package/src/restWrapper.ts +4 -4
- package/src/tokens.ts +2 -2
- package/dist/cache.cjs.map +0 -1
- package/dist/contracts.cjs.map +0 -1
- package/dist/createNewUtils.cjs.map +0 -1
- package/dist/defaultTokenProvider.cjs.map +0 -1
- package/dist/definitions.cjs.map +0 -1
- package/dist/deltaStorageService.cjs.map +0 -1
- package/dist/documentDeltaConnection.cjs.map +0 -1
- package/dist/documentService.cjs.map +0 -1
- package/dist/documentServiceFactory.cjs.map +0 -1
- package/dist/documentStorageService.cjs.map +0 -1
- package/dist/errorUtils.cjs.map +0 -1
- package/dist/gitManager.cjs.map +0 -1
- package/dist/historian.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/mapWithExpiration.cjs.map +0 -1
- package/dist/nullBlobStorageService.cjs.map +0 -1
- package/dist/packageVersion.cjs.map +0 -1
- package/dist/policies.cjs.map +0 -1
- package/dist/r11sSnapshotParser.cjs.map +0 -1
- package/dist/restWrapper.cjs.map +0 -1
- package/dist/restWrapperBase.cjs.map +0 -1
- package/dist/retriableGitManager.cjs.map +0 -1
- package/dist/shreddedSummaryDocumentStorageService.cjs.map +0 -1
- package/dist/storageContracts.cjs +0 -7
- package/dist/storageContracts.cjs.map +0 -1
- package/dist/summaryTreeUploadManager.cjs.map +0 -1
- package/dist/tokens.cjs.map +0 -1
- package/dist/treeUtils.cjs.map +0 -1
- package/dist/urlUtils.cjs.map +0 -1
- package/dist/wholeSummaryDocumentStorageService.cjs.map +0 -1
- package/dist/wholeSummaryUploadManager.cjs.map +0 -1
- package/lib/cache.d.ts.map +0 -1
- package/lib/contracts.d.ts.map +0 -1
- package/lib/createNewUtils.d.ts.map +0 -1
- package/lib/defaultTokenProvider.d.ts.map +0 -1
- package/lib/definitions.d.ts.map +0 -1
- package/lib/deltaStorageService.d.ts.map +0 -1
- package/lib/documentDeltaConnection.d.ts.map +0 -1
- package/lib/documentService.d.ts.map +0 -1
- package/lib/documentServiceFactory.d.ts.map +0 -1
- package/lib/documentStorageService.d.ts.map +0 -1
- package/lib/errorUtils.d.ts.map +0 -1
- package/lib/gitManager.d.ts.map +0 -1
- package/lib/historian.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/mapWithExpiration.d.ts.map +0 -1
- package/lib/nullBlobStorageService.d.ts.map +0 -1
- package/lib/packageVersion.d.ts.map +0 -1
- package/lib/policies.d.ts.map +0 -1
- package/lib/r11sSnapshotParser.d.ts.map +0 -1
- package/lib/restWrapper.d.ts.map +0 -1
- package/lib/restWrapperBase.d.ts.map +0 -1
- package/lib/retriableGitManager.d.ts.map +0 -1
- package/lib/routerlicious-driver-beta.d.ts +0 -35
- package/lib/routerlicious-driver-public.d.ts +0 -35
- package/lib/shreddedSummaryDocumentStorageService.d.ts.map +0 -1
- package/lib/storageContracts.d.ts.map +0 -1
- package/lib/summaryTreeUploadManager.d.ts.map +0 -1
- package/lib/tokens.d.ts.map +0 -1
- package/lib/treeUtils.d.ts.map +0 -1
- package/lib/urlUtils.d.ts.map +0 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts.map +0 -1
- package/lib/wholeSummaryUploadManager.d.ts.map +0 -1
- package/tsc-multi.test.json +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullBlobStorageService.js","sourceRoot":"","sources":["../src/nullBlobStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH;;;GAGG;AACH,MAAa,sBAAsB;IAClC,IAAW,aAAa;QACvB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACtC,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,OAAsB;QAClD,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxE,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,SAAwB,EAAE,KAAa;QAC/D,OAAO,EAAE,CAAC;IACX,CAAC;IAEM,KAAK,CAAC,wBAAwB,CACpC,OAAyB,EACzB,OAAwB;QAExB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACtC,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAA0B;QACtD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACtC,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC1D,CAAC;IACM,KAAK,CAAC,QAAQ,CAAC,MAAc;QACnC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACxD,CAAC;CACD;AA9BD,wDA8BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport * as api from \"@fluidframework/protocol-definitions\";\n\n/**\n * Document access to underlying storage. It is default implementation of a storage service.\n * Does not read/write anything.\n */\nexport class NullBlobStorageService implements IDocumentStorageService {\n\tpublic get repositoryUrl(): string {\n\t\tthrow new Error(\"Invalid operation\");\n\t}\n\n\tpublic async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n\t\treturn version ? Promise.reject(new Error(\"Invalid operation\")) : null;\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n\t\treturn [];\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: api.ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tthrow new Error(\"Invalid operation\");\n\t}\n\n\tpublic async downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree> {\n\t\tthrow new Error(\"Invalid operation\");\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse> {\n\t\tthrow new Error(\"Null blob storage can not create blob\");\n\t}\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tthrow new Error(\"Null blob storage can not read blob\");\n\t}\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/routerlicious-driver";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-
|
|
8
|
+
export declare const pkgVersion = "2.0.0-rc.1.0.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yCAAyC,CAAC;AAC9D,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yCAAyC,CAAC;AAC9D,eAAO,MAAM,UAAU,mBAAmB,CAAC"}
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/routerlicious-driver";
|
|
11
|
-
exports.pkgVersion = "2.0.0-
|
|
12
|
-
//# sourceMappingURL=packageVersion.
|
|
11
|
+
exports.pkgVersion = "2.0.0-rc.1.0.0";
|
|
12
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sCAAsC,CAAC;AACjD,QAAA,UAAU,GAAG,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/routerlicious-driver\";\nexport const pkgVersion = \"2.0.0-rc.1.0.0\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @internal\n */\nexport interface IRouterliciousDriverPolicies {\n\t/**\n\t * Enable prefetching entire snapshot tree into memory before it is loaded by the runtime.\n\t * Default: true\n\t */\n\tenablePrefetch: boolean;\n\t/**\n\t * Rate limit concurrent storage requests.\n\t * Default: 100\n\t */\n\tmaxConcurrentStorageRequests: number;\n\t/**\n\t * Rate limit concurrent orderer requests.\n\t * Default: 100\n\t */\n\tmaxConcurrentOrdererRequests: number;\n\t/**\n\t * Enable uploading entire summary tree as a IWholeSummaryPayload to storage.\n\t * Default: false\n\t */\n\tenableWholeSummaryUpload: boolean;\n\t/**\n\t * Enable service endpoint discovery when creating or joining a session.\n\t * Default: false\n\t */\n\tenableDiscovery: boolean;\n\t/**\n\t * Enable using RestLess which avoids CORS preflight requests.\n\t * Default: true\n\t */\n\tenableRestLess: boolean;\n\t/**\n\t * Enable internal cache of summaries/snapshots.\n\t * Reduces Summarizer boot time and reduces server load in E2E tests.\n\t * Default: true\n\t */\n\tenableInternalSummaryCaching: boolean;\n\t/**\n\t * Enable downgrading socket connection to long-polling\n\t * when websocket connection cannot be established.\n\t * Default: true\n\t */\n\tenableLongPollingDowngrade: boolean;\n\t/**\n\t * Indicates that the container is ephemeral.\n\t * Artifacts relates to the container are limited to container lifetime.\n\t * Default: false\n\t */\n\tisEphemeralContainer: boolean;\n}\n"]}
|
|
@@ -70,4 +70,4 @@ function convertWholeFlatSnapshotToSnapshotTreeAndBlobs(flatSnapshot, treePrefix
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
exports.convertWholeFlatSnapshotToSnapshotTreeAndBlobs = convertWholeFlatSnapshotToSnapshotTreeAndBlobs;
|
|
73
|
-
//# sourceMappingURL=r11sSnapshotParser.
|
|
73
|
+
//# sourceMappingURL=r11sSnapshotParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"r11sSnapshotParser.js","sourceRoot":"","sources":["../src/r11sSnapshotParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA8D;AAG9D;;;;;;GAMG;AACH,SAAS,cAAc,CACtB,QAAgC,EAChC,kBAA0B;IAE1B,MAAM,MAAM,GAAsC,EAAE,CAAC;IACrD,uEAAuE;IACvE,MAAM,IAAI,GAAkB,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACtE,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IAElB,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,OAAO,EAAE;QACrC,8FAA8F;QAC9F,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,kBAAkB,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QAChF,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,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AAC,CAAC,CAAC;KACH;IACD,MAAM,gBAAgB,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,cAAc,GAAG,gBAAgB,EAAE,cAAc,CAAC;IACxD,MAAM,YAAY,GAAG,cAAc,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;IAE1E,OAAO;QACN,KAAK;QACL,YAAY;QACZ,cAAc;QACd,EAAE,EAAE,YAAY,CAAC,EAAE;KACnB,CAAC;AACH,CAAC;AApBD,wGAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { INormalizedWholeSnapshot, IWholeFlatSnapshot, IWholeFlatSnapshotTree } from \"./contracts\";\n\n/**\n * Build a tree hierarchy from a flat tree.\n *\n * @param flatTree - a flat tree\n * @param treePrefixToRemove - tree prefix to strip\n * @returns the heirarchical tree\n */\nfunction buildHierarchy(\n\tflatTree: IWholeFlatSnapshotTree,\n\ttreePrefixToRemove: string,\n): ISnapshotTree {\n\tconst lookup: { [path: string]: ISnapshotTree } = {};\n\t// Root tree id will be used to determine which version was downloaded.\n\tconst root: ISnapshotTree = { id: flatTree.id, blobs: {}, trees: {} };\n\tlookup[\"\"] = root;\n\n\tfor (const entry of flatTree.entries) {\n\t\t// Strip the `treePrefixToRemove` path from tree entries such that they are stored under root.\n\t\tconst entryPath = entry.path.replace(new RegExp(`^${treePrefixToRemove}/`), \"\");\n\t\tconst lastIndex = entryPath.lastIndexOf(\"/\");\n\t\tconst entryPathDir = entryPath.slice(0, Math.max(0, lastIndex));\n\t\tconst entryPathBase = entryPath.slice(lastIndex + 1);\n\n\t\t// The flat output is breadth-first so we can assume we see tree nodes prior to their contents\n\t\tconst node = lookup[entryPathDir];\n\n\t\t// Add in either the blob or tree\n\t\tif (entry.type === \"tree\") {\n\t\t\tconst newTree: ISnapshotTree = {\n\t\t\t\tblobs: {},\n\t\t\t\ttrees: {},\n\t\t\t\tunreferenced: entry.unreferenced,\n\t\t\t};\n\t\t\tnode.trees[decodeURIComponent(entryPathBase)] = newTree;\n\t\t\tlookup[entryPath] = newTree;\n\t\t} else if (entry.type === \"blob\") {\n\t\t\tnode.blobs[decodeURIComponent(entryPathBase)] = entry.id;\n\t\t} else {\n\t\t\tthrow new Error(`Unknown entry type!!`);\n\t\t}\n\t}\n\n\treturn root;\n}\n\n/**\n * Converts existing IWholeFlatSnapshot to snapshot tree, blob array, and sequence number.\n *\n * @param flatSnapshot - flat snapshot\n * @param treePrefixToRemove - tree prefix to strip. By default we are stripping \".app\" prefix\n * @returns snapshot tree, blob array, and sequence number\n */\nexport function convertWholeFlatSnapshotToSnapshotTreeAndBlobs(\n\tflatSnapshot: IWholeFlatSnapshot,\n\ttreePrefixToRemove: string = \".app\",\n): INormalizedWholeSnapshot {\n\tconst blobs = new Map<string, ArrayBuffer>();\n\tif (flatSnapshot.blobs) {\n\t\tflatSnapshot.blobs.forEach((blob) => {\n\t\t\tblobs.set(blob.id, stringToBuffer(blob.content, blob.encoding ?? \"utf-8\"));\n\t\t});\n\t}\n\tconst flatSnapshotTree = flatSnapshot.trees?.[0];\n\tconst sequenceNumber = flatSnapshotTree?.sequenceNumber;\n\tconst snapshotTree = buildHierarchy(flatSnapshotTree, treePrefixToRemove);\n\n\treturn {\n\t\tblobs,\n\t\tsnapshotTree,\n\t\tsequenceNumber,\n\t\tid: flatSnapshot.id,\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restWrapper.d.ts","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACN,mBAAmB,EAGnB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAA0C,WAAW,EA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ED,wBAAgB,qCAAqC,CACpD,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,cAAc,EAC7B,MAAM,EAAE,mBAAmB,GACzB,YAAY,CAoBd;AAED,wBAAgB,qCAAqC,CACpD,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,cAAc,EAC7B,MAAM,EAAE,mBAAmB,GACzB,YAAY,CAqBd"}
|
|
@@ -15,9 +15,9 @@ const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
|
15
15
|
const server_services_client_1 = require("@fluidframework/server-services-client");
|
|
16
16
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
17
17
|
const json_stringify_safe_1 = __importDefault(require("json-stringify-safe"));
|
|
18
|
-
const errorUtils_1 = require("./errorUtils
|
|
19
|
-
const packageVersion_1 = require("./packageVersion
|
|
20
|
-
const restWrapperBase_1 = require("./restWrapperBase
|
|
18
|
+
const errorUtils_1 = require("./errorUtils");
|
|
19
|
+
const packageVersion_1 = require("./packageVersion");
|
|
20
|
+
const restWrapperBase_1 = require("./restWrapperBase");
|
|
21
21
|
const axiosRequestConfigToFetchRequestConfig = (requestConfig) => {
|
|
22
22
|
const requestInfo = requestConfig.baseURL !== undefined
|
|
23
23
|
? `${requestConfig.baseURL}${requestConfig.url ?? ""}`
|
|
@@ -246,4 +246,4 @@ function toInstrumentedR11sStorageTokenFetcher(tenantId, documentId, tokenProvid
|
|
|
246
246
|
return fetchStorageToken;
|
|
247
247
|
}
|
|
248
248
|
exports.toInstrumentedR11sStorageTokenFetcher = toInstrumentedR11sStorageTokenFetcher;
|
|
249
|
-
//# sourceMappingURL=restWrapper.
|
|
249
|
+
//# sourceMappingURL=restWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restWrapper.js","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH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B,CACzD,QAAQ,EACR,UAAU,EACV,YAAY,CACZ,CAAC;YAEF,OAAO,YAAY,CAAC;QACrB,CAAC,CACD,CAAC;IACH,CAAC,CAAC;IACF,OAAO,iBAAiB,CAAC;AAC1B,CAAC;AAzBD,sFAyBC;AAED,SAAgB,qCAAqC,CACpD,QAAgB,EAChB,UAAkB,EAClB,aAA6B,EAC7B,MAA2B;IAE3B,MAAM,iBAAiB,GAAG,KAAK,EAAE,YAAsB,EAA2B,EAAE;QACnF,OAAO,kCAAgB,CAAC,cAAc,CACrC,MAAM,EACN;YACC,SAAS,EAAE,mBAAmB;YAC9B,KAAK,EAAE,UAAU;SACjB,EACD,KAAK,IAAI,EAAE;YACV,8CAA8C;YAC9C,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,iBAAiB,CACzD,QAAQ,EACR,UAAU,EACV,YAAY,CACZ,CAAC;YAEF,OAAO,YAAY,CAAC;QACrB,CAAC,CACD,CAAC;IACH,CAAC,CAAC;IACF,OAAO,iBAAiB,CAAC;AAC1B,CAAC;AA1BD,sFA0BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tnumberFromString,\n} from \"@fluidframework/telemetry-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { fromUtf8ToBase64, performance } from \"@fluid-internal/client-utils\";\nimport { GenericNetworkError, NonRetryableError, RateLimiter } from \"@fluidframework/driver-utils\";\nimport {\n\tCorrelationIdHeaderName,\n\tDriverVersionHeaderName,\n\tgetAuthorizationTokenFromCredentials,\n\tRestLessClient,\n} from \"@fluidframework/server-services-client\";\nimport fetch from \"cross-fetch\";\nimport type { AxiosRequestConfig, RawAxiosRequestHeaders } from \"axios\";\nimport safeStringify from \"json-stringify-safe\";\nimport { RouterliciousErrorTypes, throwR11sNetworkError } from \"./errorUtils\";\nimport { ITokenProvider, ITokenResponse } from \"./tokens\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { QueryStringType, RestWrapper } from \"./restWrapperBase\";\n\ntype AuthorizationHeaderGetter = (token: ITokenResponse) => string;\nexport type TokenFetcher = (refresh?: boolean) => Promise<ITokenResponse>;\n\nconst axiosRequestConfigToFetchRequestConfig = (\n\trequestConfig: AxiosRequestConfig,\n): [RequestInfo, RequestInit] => {\n\tconst requestInfo: string =\n\t\trequestConfig.baseURL !== undefined\n\t\t\t? `${requestConfig.baseURL}${requestConfig.url ?? \"\"}`\n\t\t\t: requestConfig.url ?? \"\";\n\tconst requestInit: RequestInit = {\n\t\tmethod: requestConfig.method,\n\t\t// NOTE: I believe that although the Axios type permits non-string values in the header, here we are\n\t\t// guaranteed the requestConfig only has string values in its header.\n\t\theaders: requestConfig.headers as Record<string, string>,\n\t\tbody: requestConfig.data,\n\t};\n\treturn [requestInfo, requestInit];\n};\n\nexport interface IR11sResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryProperties;\n\trequestUrl: string;\n}\n\n/**\n * A utility function to create a Routerlicious response without any additional props as we might not have them always.\n * @param content - Response which is equivalent to content.\n * @returns A Routerlicious response without any extra props.\n */\nexport function createR11sResponseFromContent<T>(content: T): IR11sResponse<T> {\n\treturn {\n\t\tcontent,\n\t\theaders: new Map(),\n\t\tpropsToLog: {},\n\t\trequestUrl: \"\",\n\t};\n}\n\nfunction headersToMap(headers: Headers) {\n\tconst newHeaders = new Map<string, string>();\n\tfor (const [key, value] of headers.entries()) {\n\t\tnewHeaders.set(key, value);\n\t}\n\treturn newHeaders;\n}\n\nexport function getPropsToLogFromResponse(headers: {\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tget: (id: string) => string | undefined | null;\n}) {\n\tinterface LoggingHeader {\n\t\theaderName: string;\n\t\tlogName: string;\n\t}\n\n\t// We rename headers so that otel doesn't scrub them away. Otel doesn't allow\n\t// certain characters in headers including '-'\n\tconst headersToLog: LoggingHeader[] = [\n\t\t{ headerName: CorrelationIdHeaderName, logName: \"requestCorrelationId\" },\n\t\t{ headerName: \"content-encoding\", logName: \"contentEncoding\" },\n\t\t{ headerName: \"content-type\", logName: \"contentType\" },\n\t];\n\tconst additionalProps: ITelemetryProperties = {\n\t\tcontentsize: numberFromString(headers.get(\"content-length\")),\n\t};\n\theadersToLog.forEach((header) => {\n\t\tconst headerValue = headers.get(header.headerName);\n\t\tif (headerValue !== undefined && headerValue !== null) {\n\t\t\tadditionalProps[header.logName] = headerValue;\n\t\t}\n\t});\n\n\treturn additionalProps;\n}\n\nexport class RouterliciousRestWrapper extends RestWrapper {\n\tprivate readonly restLess = new RestLessClient();\n\tprivate token: ITokenResponse | undefined;\n\n\tconstructor(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly rateLimiter: RateLimiter,\n\t\tprivate readonly fetchRefreshedToken: TokenFetcher,\n\t\tprivate readonly getAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tprivate readonly useRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tprivate tokenP?: Promise<ITokenResponse>,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(baseurl, defaultQueryString);\n\t}\n\n\tprotected async request<T>(\n\t\trequestConfig: AxiosRequestConfig,\n\t\tstatusCode: number,\n\t\tcanRetry = true,\n\t): Promise<IR11sResponse<T>> {\n\t\tconst config = {\n\t\t\t...requestConfig,\n\t\t\theaders: await this.generateHeaders(requestConfig.headers),\n\t\t};\n\n\t\tconst translatedConfig = this.useRestLess ? this.restLess.translate(config) : config;\n\t\tconst fetchRequestConfig = axiosRequestConfigToFetchRequestConfig(translatedConfig);\n\n\t\tconst res = await this.rateLimiter.schedule(async () => {\n\t\t\tconst perfStart = performance.now();\n\t\t\tconst result = await fetch(...fetchRequestConfig).catch(async (error) => {\n\t\t\t\t// Browser Fetch throws a TypeError on network error, `node-fetch` throws a FetchError\n\t\t\t\tconst isNetworkError = [\"TypeError\", \"FetchError\"].includes(error?.name);\n\t\t\t\tconst errorMessage = isNetworkError\n\t\t\t\t\t? `NetworkError: ${error.message}`\n\t\t\t\t\t: safeStringify(error);\n\t\t\t\t// If a service is temporarily down or a browser resource limit is reached, RestWrapper will throw\n\t\t\t\t// a network error with no status code (e.g. err:ERR_CONN_REFUSED or err:ERR_FAILED) and\n\t\t\t\t// the error message will start with NetworkError as defined in restWrapper.ts\n\t\t\t\t// If there exists a self-signed SSL certificates error, throw a NonRetryableError\n\t\t\t\t// TODO: instead of relying on string matching, filter error based on the error code like we do for websocket connections\n\t\t\t\tconst err = errorMessage.includes(\"failed, reason: self signed certificate\")\n\t\t\t\t\t? new NonRetryableError(errorMessage, RouterliciousErrorTypes.sslCertError, {\n\t\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t })\n\t\t\t\t\t: new GenericNetworkError(\n\t\t\t\t\t\t\terrorMessage,\n\t\t\t\t\t\t\terrorMessage.startsWith(\"NetworkError\"),\n\t\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t );\n\t\t\t\tthrow err;\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tresponse: result,\n\t\t\t\tduration: performance.now() - perfStart,\n\t\t\t};\n\t\t});\n\n\t\tconst response = res.response;\n\n\t\tlet start = performance.now();\n\t\tconst text = await response.text();\n\t\tconst receiveContentTime = performance.now() - start;\n\n\t\tconst bodySize = text.length;\n\t\tstart = performance.now();\n\t\tconst responseBody: any = response.headers.get(\"content-type\")?.includes(\"application/json\")\n\t\t\t? JSON.parse(text)\n\t\t\t: text;\n\t\tconst parseTime = performance.now() - start;\n\n\t\t// Success\n\t\tif (response.ok || response.status === statusCode) {\n\t\t\tconst result = responseBody as T;\n\t\t\tconst headers = headersToMap(response.headers);\n\t\t\treturn {\n\t\t\t\tcontent: result,\n\t\t\t\theaders,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\t\t\trequestUrl: fetchRequestConfig[0].toString(),\n\t\t\t\tpropsToLog: {\n\t\t\t\t\t...getPropsToLogFromResponse(headers),\n\t\t\t\t\tbodySize,\n\t\t\t\t\treceiveContentTime,\n\t\t\t\t\tparseTime,\n\t\t\t\t\tfetchTime: res.duration,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\t// Failure\n\t\tif (response.status === 401 && canRetry) {\n\t\t\t// Refresh Authorization header and retry once\n\t\t\tthis.token = await this.fetchRefreshedToken(true /* refreshToken */);\n\t\t\treturn this.request<T>(config, statusCode, false);\n\t\t}\n\t\tif (response.status === 429 && responseBody?.retryAfter > 0) {\n\t\t\t// Retry based on retryAfter[Seconds]\n\t\t\treturn new Promise<IR11sResponse<T>>((resolve, reject) =>\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.request<T>(config, statusCode).then(resolve).catch(reject);\n\t\t\t\t}, responseBody.retryAfter * 1000),\n\t\t\t);\n\t\t}\n\n\t\tconst responseSummary =\n\t\t\tresponseBody !== undefined\n\t\t\t\t? typeof responseBody === \"string\"\n\t\t\t\t\t? responseBody\n\t\t\t\t\t: safeStringify(responseBody)\n\t\t\t\t: response.statusText;\n\t\tthrowR11sNetworkError(\n\t\t\t`R11s fetch error: ${responseSummary}`,\n\t\t\tresponse.status,\n\t\t\tresponseBody?.retryAfter,\n\t\t);\n\t}\n\n\tprivate async generateHeaders(\n\t\trequestHeaders?: RawAxiosRequestHeaders | undefined,\n\t): Promise<RawAxiosRequestHeaders> {\n\t\tconst token = await this.getToken();\n\t\tassert(token !== undefined, 0x679 /* token should be present */);\n\t\tconst headers: RawAxiosRequestHeaders = {\n\t\t\t...requestHeaders,\n\t\t\t[DriverVersionHeaderName]: driverVersion,\n\t\t\t// NOTE: If this.authorizationHeader is undefined, should \"Authorization\" be removed entirely?\n\t\t\tAuthorization: this.getAuthorizationHeader(token),\n\t\t};\n\t\treturn headers;\n\t}\n\n\tpublic async getToken(): Promise<ITokenResponse> {\n\t\tif (this.token !== undefined) {\n\t\t\treturn this.token;\n\t\t}\n\t\tconst token = await (this.tokenP ?? this.fetchRefreshedToken());\n\t\tthis.setToken(token);\n\t\tthis.tokenP = undefined;\n\t\treturn token;\n\t}\n\n\tpublic setToken(token: ITokenResponse) {\n\t\tthis.token = token;\n\t}\n}\n\nexport class RouterliciousStorageRestWrapper extends RouterliciousRestWrapper {\n\tprivate constructor(\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tfetchToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static async load(\n\t\ttenantId: string,\n\t\ttokenFetcher: TokenFetcher,\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t): Promise<RouterliciousStorageRestWrapper> {\n\t\tconst defaultQueryString = {\n\t\t\ttoken: `${fromUtf8ToBase64(tenantId)}`,\n\t\t};\n\n\t\tconst getAuthorizationHeader: AuthorizationHeaderGetter = (\n\t\t\ttoken: ITokenResponse,\n\t\t): string => {\n\t\t\tconst credentials = {\n\t\t\t\tpassword: token.jwt,\n\t\t\t\tuser: tenantId,\n\t\t\t};\n\t\t\treturn getAuthorizationTokenFromCredentials(credentials);\n\t\t};\n\n\t\tconst restWrapper = new RouterliciousStorageRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\ttokenFetcher,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n\nexport class RouterliciousOrdererRestWrapper extends RouterliciousRestWrapper {\n\tprivate constructor(\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tfetchToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static async load(\n\t\ttokenFetcher: TokenFetcher,\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t): Promise<RouterliciousOrdererRestWrapper> {\n\t\tconst getAuthorizationHeader: AuthorizationHeaderGetter = (\n\t\t\ttoken: ITokenResponse,\n\t\t): string => {\n\t\t\treturn `Basic ${token.jwt}`;\n\t\t};\n\n\t\tconst restWrapper = new RouterliciousOrdererRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\ttokenFetcher,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n\nexport function toInstrumentedR11sOrdererTokenFetcher(\n\ttenantId: string,\n\tdocumentId: string | undefined,\n\ttokenProvider: ITokenProvider,\n\tlogger: ITelemetryLoggerExt,\n): TokenFetcher {\n\tconst fetchOrdererToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"FetchOrdererToken\",\n\t\t\t\tdocId: documentId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst ordererToken = await tokenProvider.fetchOrdererToken(\n\t\t\t\t\ttenantId,\n\t\t\t\t\tdocumentId,\n\t\t\t\t\trefreshToken,\n\t\t\t\t);\n\n\t\t\t\treturn ordererToken;\n\t\t\t},\n\t\t);\n\t};\n\treturn fetchOrdererToken;\n}\n\nexport function toInstrumentedR11sStorageTokenFetcher(\n\ttenantId: string,\n\tdocumentId: string,\n\ttokenProvider: ITokenProvider,\n\tlogger: ITelemetryLoggerExt,\n): TokenFetcher {\n\tconst fetchStorageToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"FetchStorageToken\",\n\t\t\t\tdocId: documentId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\t// Craft credentials using tenant id and token\n\t\t\t\tconst storageToken = await tokenProvider.fetchStorageToken(\n\t\t\t\t\ttenantId,\n\t\t\t\t\tdocumentId,\n\t\t\t\t\trefreshToken,\n\t\t\t\t);\n\n\t\t\t\treturn storageToken;\n\t\t\t},\n\t\t);\n\t};\n\treturn fetchStorageToken;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restWrapperBase.js","sourceRoot":"","sources":["../src/restWrapperBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,MAAsB,WAAW;IAChC,YACoB,OAAgB,EACzB,qBAAsC,EAAE,EAC/B,gBAAgB,IAAI,GAAG,IAAI,GAAG,IAAI,EAClC,mBAAmB,IAAI,GAAG,IAAI,GAAG,IAAI;QAHrC,YAAO,GAAP,OAAO,CAAS;QACzB,uBAAkB,GAAlB,kBAAkB,CAAsB;QAC/B,kBAAa,GAAb,aAA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C;YACjD,WAAW,IAAI,GAAG,SAAS,GAAG,GAAG,IAAI,kBAAkB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;SAC5E;KACD;IAED,OAAO,WAAW,CAAC;AACpB,CAAC;AAVD,wCAUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { AxiosRequestConfig, AxiosRequestHeaders } from \"axios\";\nimport { IR11sResponse } from \"./restWrapper\";\n\nexport abstract class RestWrapper {\n\tconstructor(\n\t\tprotected readonly baseurl?: string,\n\t\tprotected defaultQueryString: QueryStringType = {},\n\t\tprotected readonly maxBodyLength = 1000 * 1024 * 1024,\n\t\tprotected readonly maxContentLength = 1000 * 1024 * 1024,\n\t) {}\n\n\tpublic async get<T>(\n\t\turl: string,\n\t\tqueryString?: QueryStringType,\n\t\theaders?: AxiosRequestHeaders,\n\t\tadditionalOptions?: Partial<\n\t\t\tOmit<\n\t\t\t\tAxiosRequestConfig,\n\t\t\t\t\"baseURL\" | \"headers\" | \"maxBodyLength\" | \"maxContentLength\" | \"method\" | \"url\"\n\t\t\t>\n\t\t>,\n\t): Promise<IR11sResponse<T>> {\n\t\tconst options: AxiosRequestConfig = {\n\t\t\t...additionalOptions,\n\t\t\tbaseURL: this.baseurl,\n\t\t\theaders,\n\t\t\tmaxBodyLength: this.maxBodyLength,\n\t\t\tmaxContentLength: this.maxContentLength,\n\t\t\tmethod: \"GET\",\n\t\t\turl: `${url}${this.generateQueryString(queryString)}`,\n\t\t};\n\t\treturn this.request<T>(options, 200);\n\t}\n\n\tpublic async post<T>(\n\t\turl: string,\n\t\trequestBody: any,\n\t\tqueryString?: QueryStringType,\n\t\theaders?: AxiosRequestHeaders,\n\t\tadditionalOptions?: Partial<\n\t\t\tOmit<\n\t\t\t\tAxiosRequestConfig,\n\t\t\t\t\"baseURL\" | \"headers\" | \"maxBodyLength\" | \"maxContentLength\" | \"method\" | \"url\"\n\t\t\t>\n\t\t>,\n\t): Promise<IR11sResponse<T>> {\n\t\tconst options: AxiosRequestConfig = {\n\t\t\t...additionalOptions,\n\t\t\tbaseURL: this.baseurl,\n\t\t\tdata: requestBody,\n\t\t\theaders,\n\t\t\tmaxBodyLength: this.maxBodyLength,\n\t\t\tmaxContentLength: this.maxContentLength,\n\t\t\tmethod: \"POST\",\n\t\t\turl: `${url}${this.generateQueryString(queryString)}`,\n\t\t};\n\t\treturn this.request<T>(options, 201);\n\t}\n\n\tpublic async delete<T>(\n\t\turl: string,\n\t\tqueryString?: QueryStringType,\n\t\theaders?: AxiosRequestHeaders,\n\t\tadditionalOptions?: Partial<\n\t\t\tOmit<\n\t\t\t\tAxiosRequestConfig,\n\t\t\t\t\"baseURL\" | \"headers\" | \"maxBodyLength\" | \"maxContentLength\" | \"method\" | \"url\"\n\t\t\t>\n\t\t>,\n\t): Promise<IR11sResponse<T>> {\n\t\tconst options: AxiosRequestConfig = {\n\t\t\t...additionalOptions,\n\t\t\tbaseURL: this.baseurl,\n\t\t\theaders,\n\t\t\tmaxBodyLength: this.maxBodyLength,\n\t\t\tmaxContentLength: this.maxContentLength,\n\t\t\tmethod: \"DELETE\",\n\t\t\turl: `${url}${this.generateQueryString(queryString)}`,\n\t\t};\n\t\treturn this.request<T>(options, 204);\n\t}\n\n\tpublic async patch<T>(\n\t\turl: string,\n\t\trequestBody: any,\n\t\tqueryString?: QueryStringType,\n\t\theaders?: AxiosRequestHeaders,\n\t\tadditionalOptions?: Partial<\n\t\t\tOmit<\n\t\t\t\tAxiosRequestConfig,\n\t\t\t\t\"baseURL\" | \"headers\" | \"maxBodyLength\" | \"maxContentLength\" | \"method\" | \"url\"\n\t\t\t>\n\t\t>,\n\t): Promise<IR11sResponse<T>> {\n\t\tconst options: AxiosRequestConfig = {\n\t\t\t...additionalOptions,\n\t\t\tbaseURL: this.baseurl,\n\t\t\tdata: requestBody,\n\t\t\theaders,\n\t\t\tmaxBodyLength: this.maxBodyLength,\n\t\t\tmaxContentLength: this.maxContentLength,\n\t\t\tmethod: \"PATCH\",\n\t\t\turl: `${url}${this.generateQueryString(queryString)}`,\n\t\t};\n\t\treturn this.request<T>(options, 200);\n\t}\n\n\tprotected abstract request<T>(\n\t\toptions: AxiosRequestConfig,\n\t\tstatusCode: number,\n\t\taddNetworkCallProps?: boolean,\n\t): Promise<IR11sResponse<T>>;\n\n\tprotected generateQueryString(queryStringValues?: QueryStringType) {\n\t\tif (this.defaultQueryString || queryStringValues) {\n\t\t\tconst queryStringMap = { ...this.defaultQueryString, ...queryStringValues };\n\n\t\t\treturn getQueryString(queryStringMap);\n\t\t}\n\n\t\treturn \"\";\n\t}\n}\n\n/**\n * Generates query string from the given query parameters.\n * @param queryParams - Query parameters from which to create a query.\n */\nexport function getQueryString(queryParams: QueryStringType): string {\n\tlet queryString = \"\";\n\tfor (const key of Object.keys(queryParams)) {\n\t\tif (queryParams[key] !== undefined) {\n\t\t\tconst startChar = queryString === \"\" ? \"?\" : \"&\";\n\t\t\tqueryString += `${startChar}${key}=${encodeURIComponent(queryParams[key])}`;\n\t\t}\n\t}\n\n\treturn queryString;\n}\n\nexport type QueryStringType = Record<string, string | number | boolean>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retriableGitManager.js","sourceRoot":"","sources":["../src/retriableGitManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,+DAA4D;AAM5D,MAAa,mBAAmB;IAC/B,YACkB,kBAA+B,EAC/B,MAA2B;QAD3B,uBAAkB,GAAlB,kBAAkB,CAAa;QAC/B,WAAM,GAAN,MAAM,CAAqB;IAC1C,CAAC;IAEG,KAAK,CAAC,UAAU,CACtB,GAAW,EACX,KAAa;QAEb,OAAO,IAAI,CAAC,YAAY,CACvB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,EAC1D,uBAAuB,CACvB,CAAC;IACH,CAAC;IAEM,KA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,EAClB,GAAG,EACH,QAAQ,EACR,IAAI,CAAC,MAAM,EACX,EAAE,CACF,CAAC;IACH,CAAC;CACD;AAvED,kDAuEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type * as git from \"@fluidframework/gitresources\";\nimport {\n\tIWholeSummaryPayload,\n\tIWriteSummaryResponse,\n} from \"@fluidframework/server-services-client\";\nimport { runWithRetry } from \"@fluidframework/driver-utils\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { IGitManager } from \"./storageContracts\";\nimport { IR11sResponse } from \"./restWrapper\";\nimport { IWholeFlatSnapshot } from \"./contracts\";\n\nexport class RetriableGitManager implements IGitManager {\n\tconstructor(\n\t\tprivate readonly internalGitManager: IGitManager,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tpublic async getCommits(\n\t\tsha: string,\n\t\tcount: number,\n\t): Promise<IR11sResponse<git.ICommitDetails[]>> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalGitManager.getCommits(sha, count),\n\t\t\t\"gitManager_getCommits\",\n\t\t);\n\t}\n\n\tpublic async getTree(root: string, recursive: boolean): Promise<IR11sResponse<git.ITree>> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalGitManager.getTree(root, recursive),\n\t\t\t\"gitManager_getTree\",\n\t\t);\n\t}\n\n\tpublic async getBlob(sha: string): Promise<IR11sResponse<git.IBlob>> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalGitManager.getBlob(sha),\n\t\t\t\"gitManager_getBlob\",\n\t\t);\n\t}\n\n\tpublic async createBlob(\n\t\tcontent: string,\n\t\tencoding: string,\n\t): Promise<IR11sResponse<git.ICreateBlobResponse>> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalGitManager.createBlob(content, encoding),\n\t\t\t\"gitManager_createBlob\",\n\t\t);\n\t}\n\n\tpublic async createGitTree(params: git.ICreateTreeParams): Promise<IR11sResponse<git.ITree>> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalGitManager.createGitTree(params),\n\t\t\t\"gitManager_createGitTree\",\n\t\t);\n\t}\n\n\tpublic async createSummary(\n\t\tsummary: IWholeSummaryPayload,\n\t): Promise<IR11sResponse<IWriteSummaryResponse>> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalGitManager.createSummary(summary),\n\t\t\t\"gitManager_createSummary\",\n\t\t);\n\t}\n\n\tpublic async getSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalGitManager.getSnapshot(sha),\n\t\t\t\"gitManager_getSummary\",\n\t\t);\n\t}\n\n\tprivate async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n\t\treturn runWithRetry(\n\t\t\tapi,\n\t\t\tcallName,\n\t\t\tthis.logger,\n\t\t\t{}, // progress\n\t\t);\n\t}\n}\n"]}
|
|
@@ -15,7 +15,7 @@ import { ITokenClaims } from '@fluidframework/protocol-definitions';
|
|
|
15
15
|
/**
|
|
16
16
|
* Abstracts the token fetching mechanism for a hosting application.
|
|
17
17
|
* The hosting application is responsible for providing an implementation.
|
|
18
|
-
* @
|
|
18
|
+
* @public
|
|
19
19
|
*/
|
|
20
20
|
export declare interface ITokenProvider {
|
|
21
21
|
/**
|
|
@@ -66,7 +66,7 @@ export declare interface ITokenProvider {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
* @
|
|
69
|
+
* @public
|
|
70
70
|
*/
|
|
71
71
|
export declare interface ITokenResponse {
|
|
72
72
|
/**
|
|
@@ -18,11 +18,74 @@ import { ITokenClaims } from '@fluidframework/protocol-definitions';
|
|
|
18
18
|
|
|
19
19
|
/* Excluded from this release type: IRouterliciousDriverPolicies */
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Abstracts the token fetching mechanism for a hosting application.
|
|
23
|
+
* The hosting application is responsible for providing an implementation.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export declare interface ITokenProvider {
|
|
27
|
+
/**
|
|
28
|
+
* Fetches the orderer token from host.
|
|
29
|
+
*
|
|
30
|
+
* @param tenantId - Tenant ID.
|
|
31
|
+
* @param documentId - Optional. Document ID is only required for document-scoped requests.
|
|
32
|
+
* @param refresh - Optional flag indicating whether token fetch must bypass local cache.
|
|
33
|
+
* This likely indicates that some previous request failed authorization due to an expired token,
|
|
34
|
+
* and so a fresh token is required.
|
|
35
|
+
*
|
|
36
|
+
* Default: `false`.
|
|
37
|
+
*
|
|
38
|
+
* NOTE: This parameter will be made required in the future.
|
|
39
|
+
*/
|
|
40
|
+
fetchOrdererToken(tenantId: string, documentId?: string, refresh?: boolean): Promise<ITokenResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Fetches the storage token from host.
|
|
43
|
+
*
|
|
44
|
+
* @param tenantId - Tenant ID.
|
|
45
|
+
* @param documentId - Document ID.
|
|
46
|
+
* @param refresh - Optional flag indicating whether token fetch must bypass local cache.
|
|
47
|
+
* This likely indicates that some previous request failed authorization due to an expired token,
|
|
48
|
+
* and so a fresh token is required.
|
|
49
|
+
*
|
|
50
|
+
* Default: `false`.
|
|
51
|
+
*
|
|
52
|
+
* NOTE: This parameter will be made required in the future.
|
|
53
|
+
*/
|
|
54
|
+
fetchStorageToken(tenantId: string, documentId: string, refresh?: boolean): Promise<ITokenResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* A callback triggered directly after creating the document. In this callback the client has the opportunity, to
|
|
57
|
+
* verify against an authorization service, if the user who claims to create the document is the same user who
|
|
58
|
+
* created it.
|
|
59
|
+
*
|
|
60
|
+
* @remarks Notes:
|
|
61
|
+
*
|
|
62
|
+
* * Using the callback may have performance impact on the document creation process.
|
|
63
|
+
*
|
|
64
|
+
* * Any exceptions thrown in the callback would fail the creation workflow
|
|
65
|
+
* (see {@link RouterliciousDocumentServiceFactory.createContainer} for more details).
|
|
66
|
+
*
|
|
67
|
+
* @param documentId - Document ID.
|
|
68
|
+
* @param creationToken - A special token that doesn't provide any kind of access, but it has the user's payload
|
|
69
|
+
* and document id. It can be used to validate the identity of the document creator.
|
|
70
|
+
*/
|
|
71
|
+
documentPostCreateCallback?(documentId: string, creationToken: string): Promise<void>;
|
|
72
|
+
}
|
|
22
73
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
74
|
+
/**
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export declare interface ITokenResponse {
|
|
78
|
+
/**
|
|
79
|
+
* {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} value.
|
|
80
|
+
*/
|
|
81
|
+
jwt: string;
|
|
82
|
+
/**
|
|
83
|
+
* A flag indicating whether token was obtained from local cache.
|
|
84
|
+
*
|
|
85
|
+
* @remarks `undefined` indicates that the source of the token could not be determined.
|
|
86
|
+
*/
|
|
87
|
+
fromCache?: boolean;
|
|
88
|
+
}
|
|
26
89
|
|
|
27
90
|
/* Excluded from this release type: ITokenService */
|
|
28
91
|
|
|
@@ -18,11 +18,74 @@ import { ITokenClaims } from '@fluidframework/protocol-definitions';
|
|
|
18
18
|
|
|
19
19
|
/* Excluded from this release type: IRouterliciousDriverPolicies */
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Abstracts the token fetching mechanism for a hosting application.
|
|
23
|
+
* The hosting application is responsible for providing an implementation.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export declare interface ITokenProvider {
|
|
27
|
+
/**
|
|
28
|
+
* Fetches the orderer token from host.
|
|
29
|
+
*
|
|
30
|
+
* @param tenantId - Tenant ID.
|
|
31
|
+
* @param documentId - Optional. Document ID is only required for document-scoped requests.
|
|
32
|
+
* @param refresh - Optional flag indicating whether token fetch must bypass local cache.
|
|
33
|
+
* This likely indicates that some previous request failed authorization due to an expired token,
|
|
34
|
+
* and so a fresh token is required.
|
|
35
|
+
*
|
|
36
|
+
* Default: `false`.
|
|
37
|
+
*
|
|
38
|
+
* NOTE: This parameter will be made required in the future.
|
|
39
|
+
*/
|
|
40
|
+
fetchOrdererToken(tenantId: string, documentId?: string, refresh?: boolean): Promise<ITokenResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Fetches the storage token from host.
|
|
43
|
+
*
|
|
44
|
+
* @param tenantId - Tenant ID.
|
|
45
|
+
* @param documentId - Document ID.
|
|
46
|
+
* @param refresh - Optional flag indicating whether token fetch must bypass local cache.
|
|
47
|
+
* This likely indicates that some previous request failed authorization due to an expired token,
|
|
48
|
+
* and so a fresh token is required.
|
|
49
|
+
*
|
|
50
|
+
* Default: `false`.
|
|
51
|
+
*
|
|
52
|
+
* NOTE: This parameter will be made required in the future.
|
|
53
|
+
*/
|
|
54
|
+
fetchStorageToken(tenantId: string, documentId: string, refresh?: boolean): Promise<ITokenResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* A callback triggered directly after creating the document. In this callback the client has the opportunity, to
|
|
57
|
+
* verify against an authorization service, if the user who claims to create the document is the same user who
|
|
58
|
+
* created it.
|
|
59
|
+
*
|
|
60
|
+
* @remarks Notes:
|
|
61
|
+
*
|
|
62
|
+
* * Using the callback may have performance impact on the document creation process.
|
|
63
|
+
*
|
|
64
|
+
* * Any exceptions thrown in the callback would fail the creation workflow
|
|
65
|
+
* (see {@link RouterliciousDocumentServiceFactory.createContainer} for more details).
|
|
66
|
+
*
|
|
67
|
+
* @param documentId - Document ID.
|
|
68
|
+
* @param creationToken - A special token that doesn't provide any kind of access, but it has the user's payload
|
|
69
|
+
* and document id. It can be used to validate the identity of the document creator.
|
|
70
|
+
*/
|
|
71
|
+
documentPostCreateCallback?(documentId: string, creationToken: string): Promise<void>;
|
|
72
|
+
}
|
|
22
73
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
74
|
+
/**
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export declare interface ITokenResponse {
|
|
78
|
+
/**
|
|
79
|
+
* {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} value.
|
|
80
|
+
*/
|
|
81
|
+
jwt: string;
|
|
82
|
+
/**
|
|
83
|
+
* A flag indicating whether token was obtained from local cache.
|
|
84
|
+
*
|
|
85
|
+
* @remarks `undefined` indicates that the source of the token could not be determined.
|
|
86
|
+
*/
|
|
87
|
+
fromCache?: boolean;
|
|
88
|
+
}
|
|
26
89
|
|
|
27
90
|
/* Excluded from this release type: ITokenService */
|
|
28
91
|
|
|
@@ -100,7 +100,7 @@ export declare interface IRouterliciousDriverPolicies {
|
|
|
100
100
|
/**
|
|
101
101
|
* Abstracts the token fetching mechanism for a hosting application.
|
|
102
102
|
* The hosting application is responsible for providing an implementation.
|
|
103
|
-
* @
|
|
103
|
+
* @public
|
|
104
104
|
*/
|
|
105
105
|
export declare interface ITokenProvider {
|
|
106
106
|
/**
|
|
@@ -151,7 +151,7 @@ export declare interface ITokenProvider {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
-
* @
|
|
154
|
+
* @public
|
|
155
155
|
*/
|
|
156
156
|
export declare interface ITokenResponse {
|
|
157
157
|
/**
|
|
@@ -237,13 +237,6 @@ export declare class RouterliciousDocumentServiceFactory implements IDocumentSer
|
|
|
237
237
|
readonly authorizationError: "authorizationError";
|
|
238
238
|
readonly fileNotFoundOrAccessDeniedError: "fileNotFoundOrAccessDeniedError";
|
|
239
239
|
readonly offlineError: "offlineError";
|
|
240
|
-
/**
|
|
241
|
-
* Routerlicious Error types
|
|
242
|
-
* Different error types that may be thrown by the routerlicious driver
|
|
243
|
-
*
|
|
244
|
-
* @deprecated Use {@link (RouterliciousErrorTypes:variable)} instead.
|
|
245
|
-
* @internal
|
|
246
|
-
*/
|
|
247
240
|
readonly unsupportedClientProtocolVersion: "unsupportedClientProtocolVersion";
|
|
248
241
|
readonly writeError: "writeError";
|
|
249
242
|
readonly fetchFailure: "fetchFailure";
|
package/dist/{shreddedSummaryDocumentStorageService.cjs → shreddedSummaryDocumentStorageService.js}
RENAMED
|
@@ -8,9 +8,9 @@ exports.ShreddedSummaryDocumentStorageService = void 0;
|
|
|
8
8
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
9
9
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
10
10
|
const protocol_base_1 = require("@fluidframework/protocol-base");
|
|
11
|
-
const cache_1 = require("./cache
|
|
12
|
-
const retriableGitManager_1 = require("./retriableGitManager
|
|
13
|
-
const summaryTreeUploadManager_1 = require("./summaryTreeUploadManager
|
|
11
|
+
const cache_1 = require("./cache");
|
|
12
|
+
const retriableGitManager_1 = require("./retriableGitManager");
|
|
13
|
+
const summaryTreeUploadManager_1 = require("./summaryTreeUploadManager");
|
|
14
14
|
const isNode = typeof window === "undefined";
|
|
15
15
|
/**
|
|
16
16
|
* Document access to underlying storage for routerlicious driver.
|
|
@@ -155,4 +155,4 @@ class ShreddedSummaryDocumentStorageService {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
exports.ShreddedSummaryDocumentStorageService = ShreddedSummaryDocumentStorageService;
|
|
158
|
-
//# sourceMappingURL=shreddedSummaryDocumentStorageService.
|
|
158
|
+
//# sourceMappingURL=shreddedSummaryDocumentStorageService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shreddedSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/shreddedSummaryDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAKyC;AACzC,+DAAkF;AAMlF,iEAAsE;AAStE,mCAAgD;AAChD,+DAA4D;AAI5D,yEAAsE;AAEtE,MAAM,MAAM,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAE7C;;;;GAIG;AACH,MAAa,qCAAqC;IAUzC,KAAK,CAAC,uBAAuB;QACpC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC/C,OAA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C,SAAS,EAAE,YAAY;YACvB,IAAI,EAAE,cAAc,CAAC,MAAM;SAC3B,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC/C,MAAM,QAAQ,GAAG,MAAM,OAAO;iBAC5B,UAAU,CAAC,IAAA,iCAAkB,EAAC,cAAc,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;iBAClE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC3D,KAAK,CAAC,GAAG,CAAC;gBACT,MAAM,EAAE,QAAQ,CAAC,EAAE;aACnB,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;QACjB,CAAC,CACD,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACpC,YAAoB;QAEpB,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1D,mEAAmE;gBACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACzC,CAAC,CAAC;YACJ,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAC/B,CAAC;CACD;AArMD,sFAqMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { stringToBuffer, Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { RetriableGitManager } from \"./retriableGitManager\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { GitManager } from \"./gitManager\";\nimport { ISummaryUploadManager } from \"./storageContracts\";\nimport { SummaryTreeUploadManager } from \"./summaryTreeUploadManager\";\n\nconst isNode = typeof window === \"undefined\";\n\n/**\n * Document access to underlying storage for routerlicious driver.\n * Uploads summaries piece-by-piece traversing the tree recursively.\n * Downloads summaries piece-by-piece on-demand, or up-front when prefetch is enabled.\n */\nexport class ShreddedSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate readonly mc: MonitoringContext;\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly blobCache: ICache<ArrayBufferLike> | undefined;\n\tprivate readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> | undefined;\n\n\tpublic readonly repositoryUrl = \"\";\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new SummaryTreeUploadManager(\n\t\t\tnew RetriableGitManager(manager, this.logger),\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tdriverPolicies?: IRouterliciousDriverPolicies,\n\t\tblobCache?: ICache<ArrayBufferLike>,\n\t\tsnapshotTreeCache?: ICache<ISnapshotTreeVersion>,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async () => this.manager,\n\t) {\n\t\tif (driverPolicies?.enableRestLess === true || isNode) {\n\t\t\tthis.blobCache = blobCache ?? new InMemoryCache();\n\t\t\tthis.snapshotTreeCache = snapshotTreeCache ?? new InMemoryCache();\n\t\t}\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger,\n\t\t});\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getVersions\",\n\t\t\t\tversionId: id,\n\t\t\t\tcount,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\treturn (await manager.getCommits(id, count)).content;\n\t\t\t},\n\t\t);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\tconst cachedSnapshotTree = await this.snapshotTreeCache?.get(\n\t\t\tthis.getCacheKey(requestVersion.treeId),\n\t\t);\n\t\tif (cachedSnapshotTree) {\n\t\t\treturn cachedSnapshotTree.snapshotTree as ISnapshotTreeEx;\n\t\t}\n\n\t\tconst rawTree = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getSnapshotTree\",\n\t\t\t\ttreeId: requestVersion.treeId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getTree(requestVersion!.treeId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.tree.length,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.snapshotTreeCache?.put(this.getCacheKey(tree.id), {\n\t\t\tid: requestVersion.id,\n\t\t\tsnapshotTree: tree,\n\t\t});\n\t\treturn tree;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst cachedBlob = await this.blobCache?.get(this.getCacheKey(blobId));\n\t\tif (cachedBlob) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\tconst value = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"readBlob\",\n\t\t\t\tblobId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getBlob(blobId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.size,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t\tundefined, // workers\n\t\t\tundefined, // recordHeapSize\n\t\t\tthis.mc.config.getNumber(\"Fluid.Driver.ReadBlobTelemetrySampling\"),\n\t\t);\n\t\tthis.blobsShaCache.set(value.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(value.content, value.encoding);\n\t\tawait this.blobCache?.put(this.getCacheKey(value.sha), bufferContent);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryHandle = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"uploadSummaryWithContext\",\n\t\t\t\tproposalHandle: context.proposalHandle,\n\t\t\t\tackHandle: context.ackHandle,\n\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryUploadManager = await this.getSummaryUploadManager();\n\t\t\t\treturn summaryUploadManager.writeSummaryTree(\n\t\t\t\t\tsummary,\n\t\t\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\t\t\"channel\",\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn summaryHandle;\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"createBlob\",\n\t\t\t\tsize: uint8ArrayFile.length,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager\n\t\t\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t\t\t.then((r) => ({ id: r.content.sha, url: r.content.url }));\n\t\t\t\tevent.end({\n\t\t\t\t\tblobId: response.id,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t })\n\t\t\t: undefined;\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storageContracts.js","sourceRoot":"","sources":["../src/storageContracts.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as git from \"@fluidframework/gitresources\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport {\n\tIWholeSummaryPayload,\n\tIWholeSummaryPayloadType,\n\tIWriteSummaryResponse,\n} from \"@fluidframework/server-services-client\";\nimport { IR11sResponse } from \"./restWrapper\";\nimport { IWholeFlatSnapshot } from \"./contracts\";\n\n/**\n * Interface to a generic Git provider\n */\nexport interface IHistorian {\n\tgetBlob(sha: string): Promise<IR11sResponse<git.IBlob>>;\n\tcreateBlob(blob: git.ICreateBlobParams): Promise<IR11sResponse<git.ICreateBlobResponse>>;\n\tgetCommits(sha: string, count: number): Promise<IR11sResponse<git.ICommitDetails[]>>;\n\tcreateTree(tree: git.ICreateTreeParams): Promise<IR11sResponse<git.ITree>>;\n\tgetTree(sha: string, recursive: boolean): Promise<IR11sResponse<git.ITree>>;\n\tcreateSummary(\n\t\tsummary: IWholeSummaryPayload,\n\t\tinitial?: boolean,\n\t): Promise<IR11sResponse<IWriteSummaryResponse>>;\n\tgetSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>>;\n}\n\nexport interface IGitManager {\n\tgetCommits(sha: string, count: number): Promise<IR11sResponse<git.ICommitDetails[]>>;\n\tgetTree(root: string, recursive: boolean): Promise<IR11sResponse<git.ITree>>;\n\tgetBlob(sha: string): Promise<IR11sResponse<git.IBlob>>;\n\tcreateBlob(content: string, encoding: string): Promise<IR11sResponse<git.ICreateBlobResponse>>;\n\tcreateGitTree(params: git.ICreateTreeParams): Promise<IR11sResponse<git.ITree>>;\n\tcreateSummary(\n\t\tsummary: IWholeSummaryPayload,\n\t\tinitial?: boolean,\n\t): Promise<IR11sResponse<IWriteSummaryResponse>>;\n\tgetSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>>;\n}\n\n/**\n * Uploads a summary to storage.\n */\nexport interface ISummaryUploadManager {\n\t/**\n\t * Writes summary tree to storage.\n\t * @param summaryTree - Summary tree to write to storage\n\t * @param parentHandle - Parent summary acked handle (if available from summary ack)\n\t * @param summaryType - type of summary being uploaded\n\t * @param sequenceNumber - optional reference sequence number of the summary\n\t * @returns Id of created tree as a string.\n\t */\n\twriteSummaryTree(\n\t\tsummaryTree: api.ISummaryTree,\n\t\tparentHandle: string,\n\t\tsummaryType: IWholeSummaryPayloadType,\n\t\tsequenceNumber?: number,\n\t): Promise<string>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summaryTreeUploadManager.js","sourceRoot":"","sources":["../src/summaryTreeUploadManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA0F;AAC1F,2DAAqE;AAErE,iEAAuE;AACvE,+EAK8C;AAI9C;;GAEG;AACH,MAAa,wBAAwB;IACpC,YACkB,OAAoB,EACpB,aAAkC,EAClC,uBAE+B;QAJ/B,YAAO,GAAP,OAAO,CAAa;QACpB,kBAAa,GAAb,aAAa,CAAqB;QAClC,4BAAuB,GAAvB,uBAAuB,CAEQ;IAC9C,CAAC;IAEG,KAAK,CAAC,gBAAgB,CAC5B,WAAyB,EACzB,YAAoB,EACpB,WAAqC,EACrC,cAAuB,EACvB,OAAiB;QAEjB,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;QAC9E,OAAO,IAAI,CAAC,oBAAoB,CAAC,WAAW,EAAE,oBAAoB,IAAI,SAAS,CAAC,CAAC;IAClF,CA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CAAC,2CAA2C,UAAU,IAAI,CAAC,CAAC;aACxE;SACD;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACvF,CAAC;CACD;AArID,4DAqIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { gitHashFile, IsoBuffer, Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ICreateTreeEntry } from \"@fluidframework/gitresources\";\nimport { getGitMode, getGitType } from \"@fluidframework/protocol-base\";\nimport {\n\tISnapshotTreeEx,\n\tISummaryTree,\n\tSummaryObject,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport { IWholeSummaryPayloadType } from \"@fluidframework/server-services-client\";\nimport { IGitManager, ISummaryUploadManager } from \"./storageContracts\";\n\n/**\n * Recursively writes summary tree as individual summary blobs.\n */\nexport class SummaryTreeUploadManager implements ISummaryUploadManager {\n\tconstructor(\n\t\tprivate readonly manager: IGitManager,\n\t\tprivate readonly blobsShaCache: Map<string, string>,\n\t\tprivate readonly getPreviousFullSnapshot: (\n\t\t\tparentHandle: string,\n\t\t) => Promise<ISnapshotTreeEx | null | undefined>,\n\t) {}\n\n\tpublic async writeSummaryTree(\n\t\tsummaryTree: ISummaryTree,\n\t\tparentHandle: string,\n\t\tsummaryType: IWholeSummaryPayloadType,\n\t\tsequenceNumber?: number,\n\t\tinitial?: boolean,\n\t): Promise<string> {\n\t\tconst previousFullSnapshot = await this.getPreviousFullSnapshot(parentHandle);\n\t\treturn this.writeSummaryTreeCore(summaryTree, previousFullSnapshot ?? undefined);\n\t}\n\n\tprivate async writeSummaryTreeCore(\n\t\tsummaryTree: ISummaryTree,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx | undefined,\n\t): Promise<string> {\n\t\tconst entries = await Promise.all(\n\t\t\tObject.keys(summaryTree.tree).map(async (key) => {\n\t\t\t\tconst entry = summaryTree.tree[key];\n\t\t\t\tconst pathHandle = await this.writeSummaryTreeObject(entry, previousFullSnapshot);\n\t\t\t\tconst treeEntry: ICreateTreeEntry = {\n\t\t\t\t\tmode: getGitMode(entry),\n\t\t\t\t\tpath: encodeURIComponent(key),\n\t\t\t\t\tsha: pathHandle,\n\t\t\t\t\ttype: getGitType(entry),\n\t\t\t\t};\n\t\t\t\treturn treeEntry;\n\t\t\t}),\n\t\t);\n\n\t\tconst treeHandle = (await this.manager.createGitTree({ tree: entries })).content;\n\t\treturn treeHandle.sha;\n\t}\n\n\tprivate async writeSummaryTreeObject(\n\t\tobject: SummaryObject,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx | undefined,\n\t): Promise<string> {\n\t\tswitch (object.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\treturn this.writeSummaryBlob(object.content);\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tif (previousFullSnapshot === undefined) {\n\t\t\t\t\tthrow Error(\"Parent summary does not exist to reference by handle.\");\n\t\t\t\t}\n\t\t\t\treturn this.getIdFromPath(object.handleType, object.handle, previousFullSnapshot);\n\t\t\t}\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\treturn this.writeSummaryTreeCore(object, previousFullSnapshot);\n\t\t\t}\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\treturn object.id;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(object, `Unknown type: ${(object as any).type}`);\n\t\t}\n\t}\n\n\tprivate async writeSummaryBlob(content: string | Uint8Array): Promise<string> {\n\t\tconst { parsedContent, encoding } =\n\t\t\ttypeof content === \"string\"\n\t\t\t\t? { parsedContent: content, encoding: \"utf-8\" }\n\t\t\t\t: { parsedContent: Uint8ArrayToString(content, \"base64\"), encoding: \"base64\" };\n\n\t\t// The gitHashFile would return the same hash as returned by the server as blob.sha\n\t\tconst hash = await gitHashFile(IsoBuffer.from(parsedContent, encoding));\n\t\tif (!this.blobsShaCache.has(hash)) {\n\t\t\tthis.blobsShaCache.set(hash, \"\");\n\t\t\tconst blob = (await this.manager.createBlob(parsedContent, encoding)).content;\n\t\t\tassert(hash === blob.sha, 0x0b6 /* \"Blob.sha and hash do not match!!\" */);\n\t\t}\n\t\treturn hash;\n\t}\n\n\tprivate getIdFromPath(\n\t\thandleType: SummaryType,\n\t\thandlePath: string,\n\t\tpreviousFullSnapshot: ISnapshotTreeEx,\n\t): string {\n\t\tconst path = handlePath.split(\"/\").map((part) => decodeURIComponent(part));\n\t\tif (path[0] === \"\") {\n\t\t\t// root of tree should be unnamed\n\t\t\tpath.shift();\n\t\t}\n\t\tif (path.length === 0) {\n\t\t\treturn previousFullSnapshot.id;\n\t\t}\n\n\t\treturn this.getIdFromPathCore(handleType, path, previousFullSnapshot);\n\t}\n\n\tprivate getIdFromPathCore(\n\t\thandleType: SummaryType,\n\t\tpath: string[],\n\t\t/** Previous snapshot, subtree relative to this path part */\n\t\tpreviousSnapshot: ISnapshotTreeEx,\n\t): string {\n\t\tassert(path.length > 0, 0x0b3 /* \"Expected at least 1 path part\" */);\n\t\tconst key = path[0];\n\t\tif (path.length === 1) {\n\t\t\tswitch (handleType) {\n\t\t\t\tcase SummaryType.Blob: {\n\t\t\t\t\tconst tryId = previousSnapshot.blobs[key];\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!tryId,\n\t\t\t\t\t\t0x0b4 /* \"Parent summary does not have blob handle for specified path.\" */,\n\t\t\t\t\t);\n\t\t\t\t\treturn tryId;\n\t\t\t\t}\n\t\t\t\tcase SummaryType.Tree: {\n\t\t\t\t\tconst tryId = previousSnapshot.trees[key]?.id;\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!tryId,\n\t\t\t\t\t\t0x0b5 /* \"Parent summary does not have tree handle for specified path.\" */,\n\t\t\t\t\t);\n\t\t\t\t\treturn tryId;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tthrow Error(`Unexpected handle summary object type: \"${handleType}\".`);\n\t\t\t}\n\t\t}\n\t\treturn this.getIdFromPathCore(handleType, path.slice(1), previousSnapshot.trees[key]);\n\t}\n}\n"]}
|
package/dist/tokens.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface ITokenService {
|
|
|
15
15
|
extractClaims(token: string): ITokenClaims;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* @
|
|
18
|
+
* @public
|
|
19
19
|
*/
|
|
20
20
|
export interface ITokenResponse {
|
|
21
21
|
/**
|
|
@@ -32,7 +32,7 @@ export interface ITokenResponse {
|
|
|
32
32
|
/**
|
|
33
33
|
* Abstracts the token fetching mechanism for a hosting application.
|
|
34
34
|
* The hosting application is responsible for providing an implementation.
|
|
35
|
-
* @
|
|
35
|
+
* @public
|
|
36
36
|
*/
|
|
37
37
|
export interface ITokenProvider {
|
|
38
38
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITokenClaims } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Abstracts the discovery of claims contained within a token.\n * @internal\n */\nexport interface ITokenService {\n\t/**\n\t * Extracts the {@link @fluidframework/protocol-definitions#ITokenClaims | token claims} from the provided\n\t * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} string representation.\n\t */\n\textractClaims(token: string): ITokenClaims;\n}\n\n/**\n * @public\n */\nexport interface ITokenResponse {\n\t/**\n\t * {@link https://jwt.io/introduction/ | JSON Web Token (JWT)} value.\n\t */\n\tjwt: string;\n\n\t/**\n\t * A flag indicating whether token was obtained from local cache.\n\t *\n\t * @remarks `undefined` indicates that the source of the token could not be determined.\n\t */\n\tfromCache?: boolean;\n}\n\n/**\n * Abstracts the token fetching mechanism for a hosting application.\n * The hosting application is responsible for providing an implementation.\n * @public\n */\nexport interface ITokenProvider {\n\t/**\n\t * Fetches the orderer token from host.\n\t *\n\t * @param tenantId - Tenant ID.\n\t * @param documentId - Optional. Document ID is only required for document-scoped requests.\n\t * @param refresh - Optional flag indicating whether token fetch must bypass local cache.\n\t * This likely indicates that some previous request failed authorization due to an expired token,\n\t * and so a fresh token is required.\n\t *\n\t * Default: `false`.\n\t *\n\t * NOTE: This parameter will be made required in the future.\n\t */\n\tfetchOrdererToken(\n\t\ttenantId: string,\n\t\tdocumentId?: string,\n\t\trefresh?: boolean,\n\t): Promise<ITokenResponse>;\n\n\t/**\n\t * Fetches the storage token from host.\n\t *\n\t * @param tenantId - Tenant ID.\n\t * @param documentId - Document ID.\n\t * @param refresh - Optional flag indicating whether token fetch must bypass local cache.\n\t * This likely indicates that some previous request failed authorization due to an expired token,\n\t * and so a fresh token is required.\n\t *\n\t * Default: `false`.\n\t *\n\t * NOTE: This parameter will be made required in the future.\n\t */\n\tfetchStorageToken(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\trefresh?: boolean,\n\t): Promise<ITokenResponse>;\n\n\t/**\n\t * A callback triggered directly after creating the document. In this callback the client has the opportunity, to\n\t * verify against an authorization service, if the user who claims to create the document is the same user who\n\t * created it.\n\t *\n\t * @remarks Notes:\n\t *\n\t * * Using the callback may have performance impact on the document creation process.\n\t *\n\t * * Any exceptions thrown in the callback would fail the creation workflow\n\t * (see {@link RouterliciousDocumentServiceFactory.createContainer} for more details).\n\t *\n\t * @param documentId - Document ID.\n\t * @param creationToken - A special token that doesn't provide any kind of access, but it has the user's payload\n\t * and document id. It can be used to validate the identity of the document creator.\n\t */\n\tdocumentPostCreateCallback?(documentId: string, creationToken: string): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeUtils.js","sourceRoot":"","sources":["../src/treeUtils.ts"],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AAQ,CAAC,KAAK,KAAK,SAAS,EAC5B,KAAK,CAAC,oDAAoD,CAC1D,CAAC;IACF,IAAA,mBAAM,EACL,QAAQ,CAAC,KAAK,KAAK,SAAS,EAC5B,KAAK,CAAC,oDAAoD,CAC1D,CAAC;AACH,CAAC;AATD,sDASC;AAED,SAAS,wBAAwB,CAAC,YAA2B;IAC5D,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QAC3D,QAAQ,IAAI,CAAC,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;KAC/C;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","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 {\n\tSummaryType,\n\tISnapshotTree,\n\tISummaryTree,\n\tSummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\n\n/**\n * Summary tree assembler props\n */\nexport interface ISummaryTreeAssemblerProps {\n\t/**\n\t * Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.\n\t */\n\tunreferenced?: true;\n}\n\n/**\n * Summary tree assembler (without stats collection).\n */\nexport class SummaryTreeAssembler {\n\tprivate attachmentCounter: number = 0;\n\tprivate readonly summaryTree: { [path: string]: SummaryObject } = {};\n\n\tconstructor(private readonly props?: ISummaryTreeAssemblerProps) {}\n\n\t/**\n\t * Get final summary\n\t */\n\tpublic get summary(): ISummaryTree {\n\t\treturn {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t\tunreferenced: this.props?.unreferenced,\n\t\t};\n\t}\n\n\t/**\n\t * Add blob to summary\n\t */\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Blob,\n\t\t\tcontent,\n\t\t};\n\t}\n\n\t/**\n\t * Add handle to summary\n\t */\n\tpublic addHandle(\n\t\tkey: string,\n\t\thandleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n\t\thandle: string,\n\t): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType,\n\t\t\thandle,\n\t\t};\n\t}\n\n\t/**\n\t * Add tree to summary\n\t */\n\tpublic addTree(key: string, summary: ISummaryTree): void {\n\t\tthis.summaryTree[key] = summary;\n\t}\n\n\t/**\n\t * Add attachment to summary\n\t */\n\tpublic addAttachment(id: string) {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n}\n\n/**\n * Helper function that converts ISnapshotTree and blobs to ISummaryTree\n * @param snapshot - Source snapshot tree\n * @param blobs - Blobs cache\n * @returns Converted snapshot in ISummaryTree format\n */\nexport function convertSnapshotAndBlobsToSummaryTree(\n\tsnapshot: ISnapshotTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISummaryTree {\n\tconst assembler = new SummaryTreeAssembler({\n\t\tunreferenced: snapshot.unreferenced,\n\t});\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tconst blob = blobs.get(id);\n\t\tassert(blob !== undefined, 0x2dd /* \"Cannot find blob for a given id\" */);\n\t\tassembler.addBlob(path, IsoBuffer.from(blob).toString(\"utf-8\"));\n\t}\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotAndBlobsToSummaryTree(tree, blobs);\n\t\tassembler.addTree(key, subtree);\n\t}\n\treturn assembler.summary;\n}\n\nexport function evalBlobsAndTrees(snapshot: INormalizedWholeSnapshot) {\n\tconst trees = countTreesInSnapshotTree(snapshot.snapshotTree);\n\tconst numBlobs = snapshot.blobs.size;\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobs) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { trees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: ISnapshotTree) {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x5d0 /* Returned r11s snapshot is malformed. No trees! */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x5d1 /* Returned r11s snapshot is malformed. No blobs! */,\n\t);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n\tlet numTrees = 0;\n\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\tnumTrees += 1 + countTreesInSnapshotTree(tree);\n\t}\n\treturn numTrees;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH,0DAAiC;AAG1B,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAY,EAAE;IAC3D,OAAO,IAAI,mBAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AAEF;;;;;GAKG;AACI,MAAM,uBAAuB,GAAG,CAAC,OAAe,EAAE,UAAkB,EAAU,EAAE,CACtF,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AADnD,QAAA,uBAAuB,2BAC4B;AAEzD,MAAM,6BAA6B,GAAG,CAC5C,WAAyB,EACzB,OAAiB,EACF,EAAE;IACjB,MAAM,oBAAoB,GAAG,IAAI,mBAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9D,MAAM,eAAe,GAAG,IAAI,mBAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAC5E,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAEvD,MAAM,oBAAoB,GAAG,IAAI,mBAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,IAAI,mBAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAClE,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAElD,MAAM,SAAS,GAAG,IAAA,qBAAa,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACjD,MAAM,qBAAqB,GAAiB;QAC3C,SAAS,EAAE;YACV,eAAe,EAAE,eAAe,CAAC,QAAQ,EAAE;YAC3C,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;SACjC;QACD,EAAE,EAAE,WAAW,CAAC,EAAE;QAClB,MAAM,EAAE,WAAW,CAAC,MAAM;QAC1B,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,GAAG,EAAE,IAAI,mBAAQ,CAAC,WAAW,oBAAoB,CAAC,IAAI,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE;KACzF,CAAC;IACF,OAAO,qBAAqB,CAAC;AAC9B,CAAC,CAAC;AA1BW,QAAA,6BAA6B,iCA0BxC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport URLParse from \"url-parse\";\nimport { ISession } from \"@fluidframework/server-services-client\";\n\nexport const parseFluidUrl = (fluidUrl: string): URLParse => {\n\treturn new URLParse(fluidUrl, true);\n};\n\n/**\n * Assume documentId is at end of url path.\n * This is true for Routerlicious' and Tinylicious' documentUrl and deltaStorageUrl.\n * Routerlicious and Tinylicious do not use documentId in storageUrl nor ordererUrl.\n * TODO: Ideally we would be able to regenerate the resolvedUrl, rather than patching the current one.\n */\nexport const replaceDocumentIdInPath = (urlPath: string, documentId: string): string =>\n\turlPath.split(\"/\").slice(0, -1).concat([documentId]).join(\"/\");\n\nexport const getDiscoveredFluidResolvedUrl = (\n\tresolvedUrl: IResolvedUrl,\n\tsession: ISession,\n): IResolvedUrl => {\n\tconst discoveredOrdererUrl = new URLParse(session.ordererUrl);\n\tconst deltaStorageUrl = new URLParse(resolvedUrl.endpoints.deltaStorageUrl);\n\tdeltaStorageUrl.set(\"host\", discoveredOrdererUrl.host);\n\n\tconst discoveredStorageUrl = new URLParse(session.historianUrl);\n\tconst storageUrl = new URLParse(resolvedUrl.endpoints.storageUrl);\n\tstorageUrl.set(\"host\", discoveredStorageUrl.host);\n\n\tconst parsedUrl = parseFluidUrl(resolvedUrl.url);\n\tconst discoveredResolvedUrl: IResolvedUrl = {\n\t\tendpoints: {\n\t\t\tdeltaStorageUrl: deltaStorageUrl.toString(),\n\t\t\tordererUrl: session.ordererUrl,\n\t\t\tdeltaStreamUrl: session.deltaStreamUrl,\n\t\t\tstorageUrl: storageUrl.toString(),\n\t\t},\n\t\tid: resolvedUrl.id,\n\t\ttokens: resolvedUrl.tokens,\n\t\ttype: resolvedUrl.type,\n\t\turl: new URLParse(`fluid://${discoveredOrdererUrl.host}${parsedUrl.pathname}`).toString(),\n\t};\n\treturn discoveredResolvedUrl;\n};\n"]}
|