@fluidframework/driver-utils 2.0.0-internal.3.0.1 → 2.0.0-internal.3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +17 -19
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/blobAggregationStorage.d.ts +2 -2
- package/dist/blobAggregationStorage.d.ts.map +1 -1
- package/dist/blobAggregationStorage.js +11 -6
- package/dist/blobAggregationStorage.js.map +1 -1
- package/dist/blobCacheStorageService.d.ts.map +1 -1
- package/dist/blobCacheStorageService.js.map +1 -1
- package/dist/buildSnapshotTree.d.ts.map +1 -1
- package/dist/buildSnapshotTree.js.map +1 -1
- package/dist/documentStorageServiceProxy.d.ts.map +1 -1
- package/dist/documentStorageServiceProxy.js.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/fluidResolvedUrl.d.ts.map +1 -1
- package/dist/fluidResolvedUrl.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/insecureUrlResolver.d.ts.map +1 -1
- package/dist/insecureUrlResolver.js +2 -1
- package/dist/insecureUrlResolver.js.map +1 -1
- package/dist/mapWithExpiration.d.ts.map +1 -1
- package/dist/mapWithExpiration.js +5 -3
- package/dist/mapWithExpiration.js.map +1 -1
- package/dist/messageRecognition.d.ts.map +1 -1
- package/dist/messageRecognition.js.map +1 -1
- package/dist/multiDocumentServiceFactory.d.ts.map +1 -1
- package/dist/multiDocumentServiceFactory.js.map +1 -1
- package/dist/multiUrlResolver.d.ts.map +1 -1
- package/dist/multiUrlResolver.js.map +1 -1
- package/dist/network.d.ts +1 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +4 -3
- package/dist/network.js.map +1 -1
- package/dist/networkUtils.d.ts.map +1 -1
- package/dist/networkUtils.js +2 -3
- package/dist/networkUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/parallelRequests.d.ts.map +1 -1
- package/dist/parallelRequests.js +19 -9
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/rateLimiter.d.ts.map +1 -1
- package/dist/rateLimiter.js.map +1 -1
- package/dist/readAndParse.d.ts.map +1 -1
- package/dist/readAndParse.js.map +1 -1
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/runWithRetry.js.map +1 -1
- package/dist/summaryForCreateNew.d.ts.map +1 -1
- package/dist/summaryForCreateNew.js.map +1 -1
- package/dist/treeConversions.d.ts.map +1 -1
- package/dist/treeConversions.js +1 -4
- package/dist/treeConversions.js.map +1 -1
- package/dist/treeUtils.d.ts +10 -10
- package/dist/treeUtils.d.ts.map +1 -1
- package/dist/treeUtils.js +10 -10
- package/dist/treeUtils.js.map +1 -1
- package/lib/blobAggregationStorage.d.ts +2 -2
- package/lib/blobAggregationStorage.d.ts.map +1 -1
- package/lib/blobAggregationStorage.js +11 -6
- package/lib/blobAggregationStorage.js.map +1 -1
- package/lib/blobCacheStorageService.d.ts.map +1 -1
- package/lib/blobCacheStorageService.js.map +1 -1
- package/lib/buildSnapshotTree.d.ts.map +1 -1
- package/lib/buildSnapshotTree.js.map +1 -1
- package/lib/documentStorageServiceProxy.d.ts.map +1 -1
- package/lib/documentStorageServiceProxy.js.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.js.map +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js.map +1 -1
- package/lib/fluidResolvedUrl.d.ts.map +1 -1
- package/lib/fluidResolvedUrl.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/insecureUrlResolver.d.ts.map +1 -1
- package/lib/insecureUrlResolver.js +2 -1
- package/lib/insecureUrlResolver.js.map +1 -1
- package/lib/mapWithExpiration.d.ts.map +1 -1
- package/lib/mapWithExpiration.js +5 -3
- package/lib/mapWithExpiration.js.map +1 -1
- package/lib/messageRecognition.d.ts.map +1 -1
- package/lib/messageRecognition.js +1 -1
- package/lib/messageRecognition.js.map +1 -1
- package/lib/multiDocumentServiceFactory.d.ts.map +1 -1
- package/lib/multiDocumentServiceFactory.js.map +1 -1
- package/lib/multiUrlResolver.d.ts.map +1 -1
- package/lib/multiUrlResolver.js.map +1 -1
- package/lib/network.d.ts +1 -1
- package/lib/network.d.ts.map +1 -1
- package/lib/network.js +4 -3
- package/lib/network.js.map +1 -1
- package/lib/networkUtils.d.ts.map +1 -1
- package/lib/networkUtils.js +2 -3
- package/lib/networkUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/parallelRequests.d.ts.map +1 -1
- package/lib/parallelRequests.js +19 -9
- package/lib/parallelRequests.js.map +1 -1
- package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
- package/lib/prefetchDocumentStorageService.js.map +1 -1
- package/lib/rateLimiter.d.ts.map +1 -1
- package/lib/rateLimiter.js.map +1 -1
- package/lib/readAndParse.d.ts.map +1 -1
- package/lib/readAndParse.js.map +1 -1
- package/lib/runWithRetry.d.ts.map +1 -1
- package/lib/runWithRetry.js.map +1 -1
- package/lib/summaryForCreateNew.d.ts.map +1 -1
- package/lib/summaryForCreateNew.js.map +1 -1
- package/lib/treeConversions.d.ts.map +1 -1
- package/lib/treeConversions.js +4 -7
- package/lib/treeConversions.js.map +1 -1
- package/lib/treeUtils.d.ts +10 -10
- package/lib/treeUtils.d.ts.map +1 -1
- package/lib/treeUtils.js +11 -11
- package/lib/treeUtils.js.map +1 -1
- package/package.json +128 -105
- package/prettier.config.cjs +1 -1
- package/src/blobAggregationStorage.ts +374 -322
- package/src/blobCacheStorageService.ts +20 -17
- package/src/buildSnapshotTree.ts +54 -51
- package/src/documentStorageServiceProxy.ts +49 -43
- package/src/emptyDocumentDeltaStorageService.ts +11 -10
- package/src/error.ts +5 -7
- package/src/fluidResolvedUrl.ts +9 -6
- package/src/index.ts +5 -1
- package/src/insecureUrlResolver.ts +127 -116
- package/src/mapWithExpiration.ts +111 -104
- package/src/messageRecognition.ts +25 -19
- package/src/multiDocumentServiceFactory.ts +73 -62
- package/src/multiUrlResolver.ts +26 -29
- package/src/network.ts +114 -112
- package/src/networkUtils.ts +37 -34
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +571 -509
- package/src/prefetchDocumentStorageService.ts +76 -74
- package/src/rateLimiter.ts +29 -29
- package/src/readAndParse.ts +7 -4
- package/src/runWithRetry.ts +105 -94
- package/src/summaryForCreateNew.ts +27 -24
- package/src/treeConversions.ts +48 -70
- package/src/treeUtils.ts +70 -74
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/.eslintrc.js
CHANGED
|
@@ -4,22 +4,20 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
]
|
|
25
|
-
}
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
|
|
8
|
+
parserOptions: {
|
|
9
|
+
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
"import/no-nodejs-modules": ["error", { allow: ["url"] }],
|
|
13
|
+
},
|
|
14
|
+
overrides: [
|
|
15
|
+
{
|
|
16
|
+
// Rules only for test files
|
|
17
|
+
files: ["*.spec.ts", "src/test/**"],
|
|
18
|
+
rules: {
|
|
19
|
+
"import/no-nodejs-modules": "off", // Node libraries are OK for test files.
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
package/.mocharc.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
"use strict";
|
|
7
7
|
|
|
8
|
-
const getFluidTestMochaConfig = require(
|
|
8
|
+
const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
|
|
9
9
|
|
|
10
10
|
const packageDir = __dirname;
|
|
11
11
|
const config = getFluidTestMochaConfig(packageDir);
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-common-report.json"
|
|
4
4
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
|
|
5
|
+
import { FetchSource, IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
|
|
6
6
|
import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
|
|
7
7
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
8
8
|
export declare abstract class SnapshotExtractor {
|
|
@@ -31,7 +31,7 @@ export declare class BlobAggregationStorage extends SnapshotExtractor implements
|
|
|
31
31
|
setBlob(id: string, tree: ISnapshotTree, content: string): void;
|
|
32
32
|
getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike>;
|
|
33
33
|
get repositoryUrl(): string;
|
|
34
|
-
getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
|
|
34
|
+
getVersions(versionId: string | null, count: number, scenarioName?: string, fetchSource?: FetchSource): Promise<IVersion[]>;
|
|
35
35
|
downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree>;
|
|
36
36
|
createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;
|
|
37
37
|
getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobAggregationStorage.d.ts","sourceRoot":"","sources":["../src/blobAggregationStorage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"blobAggregationStorage.d.ts","sourceRoot":"","sources":["../src/blobAggregationStorage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,WAAW,EACX,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EAER,MAAM,sCAAsC,CAAC;AAS9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AA0CtE,8BAAsB,iBAAiB;IACtC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,WAAW;IAChD,SAAS,CAAC,QAAQ,CAAC,eAAe,QAAQ;IAG1C,SAAS,CAAC,gBAAgB,SAAK;IAC/B,SAAS,CAAC,gBAAgB;IAI1B,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;IAC3E,Q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,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW;IAKb,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAM9D,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI/D,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAQlE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAiB9C,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;YAiBJ,kBAAkB;IAkHhC,SAAS,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;CAG9C"}
|
|
@@ -11,9 +11,10 @@ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
|
11
11
|
/*
|
|
12
12
|
* Work around for bufferToString having a bug - it can't consume IsoBuffer!
|
|
13
13
|
* To be removed once bufferToString is fixed!
|
|
14
|
-
*/
|
|
14
|
+
*/
|
|
15
15
|
function bufferToString2(blob, encoding) {
|
|
16
|
-
if (blob instanceof Uint8Array) {
|
|
16
|
+
if (blob instanceof Uint8Array) {
|
|
17
|
+
// IsoBuffer does not have ctor, so it's not in proto chain :(
|
|
17
18
|
return (0, common_utils_1.Uint8ArrayToString)(blob, encoding);
|
|
18
19
|
}
|
|
19
20
|
return (0, common_utils_1.bufferToString)(blob, encoding);
|
|
@@ -168,9 +169,11 @@ class BlobAggregationStorage extends SnapshotExtractor {
|
|
|
168
169
|
throw error;
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
|
-
get repositoryUrl() {
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
get repositoryUrl() {
|
|
173
|
+
return this.storage.repositoryUrl;
|
|
174
|
+
}
|
|
175
|
+
async getVersions(versionId, count, scenarioName, fetchSource) {
|
|
176
|
+
return this.storage.getVersions(versionId, count, scenarioName, fetchSource);
|
|
174
177
|
}
|
|
175
178
|
async downloadSummary(handle) {
|
|
176
179
|
throw new Error("NYI");
|
|
@@ -254,7 +257,9 @@ class BlobAggregationStorage extends SnapshotExtractor {
|
|
|
254
257
|
}
|
|
255
258
|
break;
|
|
256
259
|
case protocol_definitions_1.SummaryType.Blob:
|
|
257
|
-
if (aggregator &&
|
|
260
|
+
if (aggregator &&
|
|
261
|
+
typeof obj.content == "string" &&
|
|
262
|
+
obj.content.length < this.blobCutOffSize) {
|
|
258
263
|
aggregator.addBlob(newPath, obj.content);
|
|
259
264
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
260
265
|
delete newSummary.tree[key];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobAggregationStorage.js","sourceRoot":"","sources":["../src/blobAggregationStorage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,+EAO8C;AAC9C,+DAOuC;AAEvC,qEAA4E;AAE5E;;;EAGE;AACF,SAAS,eAAe,CAAC,IAAqB,EAAE,QAA4B;IACxE,IAAI,IAAI,YAAY,UAAU,EAAE,EAAE,8DAA8D;QAC5F,OAAO,IAAA,iCAAkB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;KAC7C;IACD,OAAO,IAAA,6BAAc,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAEA;;GAEG;AACJ,MAAM,cAAc;IAApB;QACqB,YAAO,GAAuB,EAAE,CAAC;IAiBtD,CAAC;IAfU,OAAO,CAAC,GAAW,EAAE,OAAe;QACvC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;IACtC,CAAC;IAEM,wBAAwB;QAC3B,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,OAAO,SAAS,CAAC;SACpB;QACD,OAAO,IAAI,CAAC,S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V,CAAC;aACL;SACJ;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAES,eAAe,CAAC,EAAU;QAChC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAChD,CAAC;;AAlOL,wDAmOC;AAlOG,6FAA6F;AAC7F,8BAA8B;AAC9B,uGAAuG;AACvG,yGAAyG;AACzG,4FAA4F;AAC5F,qGAAqG;AACrG,oGAAoG;AACpG,mCAAmC;AACnC,yGAAyG;AACzG,mFAAmF;AACnE,6CAAsB,GAAG,IAAI,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IDocumentStorageService,\n IDocumentStorageServicePolicies,\n ISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n ICreateBlobResponse,\n ISnapshotTree,\n ISummaryHandle,\n ISummaryTree,\n IVersion,\n SummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n assert,\n bufferToString,\n stringToBuffer,\n unreachableCase,\n fromUtf8ToBase64,\n Uint8ArrayToString,\n } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { loggerToMonitoringContext } from \"@fluidframework/telemetry-utils\";\n\n/*\n * Work around for bufferToString having a bug - it can't consume IsoBuffer!\n * To be removed once bufferToString is fixed!\n*/\nfunction bufferToString2(blob: ArrayBufferLike, encoding: \"utf-8\" | \"base64\"): string {\n if (blob instanceof Uint8Array) { // IsoBuffer does not have ctor, so it's not in proto chain :(\n return Uint8ArrayToString(blob, encoding);\n }\n return bufferToString(blob, encoding);\n}\n\n /**\n * Class responsible for aggregating smaller blobs into one and unpacking it later on.\n */\nclass BlobAggregator {\n private readonly content: [string, string][] = [];\n\n public addBlob(key: string, content: string) {\n this.content.push([key, content]);\n }\n\n public getAggregatedBlobContent() {\n if (this.content.length === 0) {\n return undefined;\n }\n return JSON.stringify(this.content);\n }\n\n static load(input: ArrayBufferLike) {\n const data = bufferToString2(input, \"utf-8\");\n return JSON.parse(data) as [string, string][];\n }\n}\n\n/*\n * Base class that deals with unpacking snapshots (in place) containing aggregated blobs\n * It relies on abstract methods for reads and storing unpacked blobs.\n */\nexport abstract class SnapshotExtractor {\n protected readonly aggregatedBlobName = \"__big\";\n protected readonly virtualIdPrefix = \"__\";\n\n // counter for generation of virtual storage IDs\n protected virtualIdCounter = 0;\n protected getNextVirtualId() {\n return `${this.virtualIdPrefix}${++this.virtualIdCounter}`;\n }\n\n abstract getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike>;\n abstract setBlob(id: string, tree: ISnapshotTree, content: string);\n\n public async unpackSnapshotCore(snapshot: ISnapshotTree, level = 0): Promise<void> {\n for (const key of Object.keys(snapshot.trees)) {\n const obj = snapshot.trees[key];\n await this.unpackSnapshotCore(obj, level + 1);\n }\n\n // For future proof, we will support multiple aggregated blobs with any name\n // that starts with this.aggregatedBlobName\n for (const key of Object.keys(snapshot.blobs)) {\n if (!key.startsWith(this.aggregatedBlobName)) { continue; }\n const blobId = snapshot.blobs[key];\n if (blobId !== undefined) {\n const blob = await this.getBlob(blobId, snapshot);\n for (const [path, value] of BlobAggregator.load(blob)) {\n const id = this.getNextVirtualId();\n this.setBlob(id, snapshot, value);\n const pathSplit = path.split(\"/\");\n let subTree = snapshot;\n for (const subPath of pathSplit.slice(0, pathSplit.length - 1)) {\n if (subTree.trees[subPath] === undefined) {\n subTree.trees[subPath] = { blobs: {}, trees: {} };\n }\n subTree = subTree.trees[subPath];\n }\n const blobName = pathSplit[pathSplit.length - 1];\n assert(subTree.blobs[blobName] === undefined, 0x0f6 /* \"real blob ID exists\" */);\n subTree.blobs[blobName] = id;\n }\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete snapshot.blobs[this.aggregatedBlobName];\n }\n }\n }\n}\n\n/*\n * Snapshot extractor class that works in place, i.e. patches snapshot that has\n * blob content in ISnapshotTree.blobs itself, not in storage.\n * As result, it implements reading and writing of blobs to/from snapshot itself.\n * It follows existing pattern that mixes concerns - ISnapshotTree.blobs is used for two\n * purposes:\n * 1. map path name to blob ID\n * 2. map blob ID to blob content\n * #2 is what storage (IDocumentStorageService) is for, but in places where we do not have it\n * (like loading serialized earlier draft content), blob content is put directly into snapshot.\n * Ideally this should be fixed by using BlobCacheStorageService or something similar and\n * fixing existing flows to allow switching of storage.\n */\nclass SnapshotExtractorInPlace extends SnapshotExtractor {\n public async getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike> {\n const blob = tree.blobs[id];\n assert(blob !== undefined, 0x0f7 /* \"aggregate blob missing\" */);\n return stringToBuffer(blob, \"base64\");\n }\n\n public setBlob(id: string, tree: ISnapshotTree, content: string) {\n assert(tree.blobs[id] === undefined, 0x0f8 /* \"blob from aggregate blob exists on its own\" */);\n tree.blobs[id] = fromUtf8ToBase64(content);\n }\n}\n\n/*\n * Snapshot packer and extractor.\n * When summary is written it will find and aggregate small blobs into bigger blobs\n * When snapshot is read, it will unpack aggregated blobs and provide them transparently to caller.\n */\nexport class BlobAggregationStorage extends SnapshotExtractor implements IDocumentStorageService {\n // Tells data store if it can use incremental summary (i.e. reuse DDSes from previous summary\n // when only one DDS changed).\n // The answer has to be know long before we enable actual packing. The reason for the is the following:\n // A the moment when we enable packing, we should assume that all clients out there wil already have bits\n // that can unpack properly (i.e. enough time passed since we deployed bits that can unpack)\n // But we can still have clients where some of them already pack, and some do not. If one summary was\n // using packing, then it relies on non-incremental summaries going forward, even if next client who\n // produced summary is not packing!\n // This can have slight improvement by enabling it per file (based on \"did summary we loaded from contain\n // aggregated blobs\"), but that's harder to make reliable, so going for simplicity.\n static readonly fullDataStoreSummaries = true;\n\n protected loadedFromSummary = false;\n\n protected virtualBlobs = new Map<string, ArrayBufferLike>();\n\n static wrap(\n storage: IDocumentStorageService,\n logger: ITelemetryLogger,\n allowPacking?: boolean,\n packingLevel = 2,\n ) {\n if (storage instanceof BlobAggregationStorage) {\n return storage;\n }\n const mc = loggerToMonitoringContext(logger);\n const realAllowPackaging = mc.config.getBoolean(\"FluidAggregateBlobs\") ?? allowPacking ?? false;\n\n // Always create BlobAggregationStorage even if storage is not asking for packing.\n // This is mostly to avoid cases where future changes in policy would result in inability to\n // load old files that were created with aggregation on.\n const minBlobSize = storage.policies?.minBlobSize;\n return new BlobAggregationStorage(storage, logger, realAllowPackaging, packingLevel, minBlobSize);\n }\n\n static async unpackSnapshot(snapshot: ISnapshotTree) {\n const converter = new SnapshotExtractorInPlace();\n await converter.unpackSnapshotCore(snapshot);\n }\n\n public get policies(): IDocumentStorageServicePolicies | undefined {\n const policies = this.storage.policies;\n if (policies) {\n return { ...policies, minBlobSize: undefined };\n }\n }\n\n public async unpackSnapshot(snapshot: ISnapshotTree) {\n // SummarizerNodeWithGC.refreshLatestSummary can call it when this.loadedFromSummary === false\n // (I assumed after file was created)\n // assert(!this.loadedFromSummary, \"unpack without summary\");\n\n this.loadedFromSummary = true;\n await this.unpackSnapshotCore(snapshot);\n }\n\n protected constructor(\n private readonly storage: IDocumentStorageService,\n private readonly logger: ITelemetryLogger,\n private readonly allowPacking: boolean,\n private readonly packingLevel: number,\n private readonly blobCutOffSize?: number) {\n super();\n }\n\n public setBlob(id: string, tree: ISnapshotTree, content: string) {\n this.virtualBlobs.set(id, stringToBuffer(content, \"utf-8\"));\n }\n\n public async getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike> {\n return this.readBlob(id).catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"BlobDedupNoAggregateBlob\" }, error);\n throw error;\n });\n }\n\n public get repositoryUrl() { return this.storage.repositoryUrl; }\n public async getVersions(versionId: string | null, count: number) {\n return this.storage.getVersions(versionId, count);\n }\n\n public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n throw new Error(\"NYI\");\n }\n\n // for now we are not optimizing these blobs, with assumption that this API is used only\n // for big blobs (images)\n public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n return this.storage.createBlob(file);\n }\n\n public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n const tree = await this.storage.getSnapshotTree(version);\n if (tree) {\n await this.unpackSnapshot(tree);\n }\n return tree;\n }\n\n public async readBlob(id: string): Promise<ArrayBufferLike> {\n if (this.isRealStorageId(id)) {\n return this.storage.readBlob(id);\n }\n // We support only reading blobs from the summary we loaded from.\n // This may need to be extended to any general summary in the future as runtime usage pattern\n // of storage changes (for example, data stores start to load from recent summary, not from original\n // summary whole container loaded from)\n\n // are there other ways we can get here? createFile is one flow, but we should not be reading blobs\n // in such flow\n assert(this.loadedFromSummary, 0x0f9 /* \"never read summary\" */);\n const blob = this.virtualBlobs.get(id);\n assert(blob !== undefined, 0x0fa /* \"virtual blob not found\" */);\n return blob;\n }\n\n public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\n const summaryNew = this.allowPacking ? await this.compressSmallBlobs(summary) : summary;\n return this.storage.uploadSummaryWithContext(summaryNew, context);\n }\n\n // For simplification, we assume that\n // - blob aggregation is done at data store level only for now\n // - data store either reuses previous summary, or generates full summary, i.e. there is no partial (some DDS)\n // summary produced by data stores.\n // These simplifications allow us not to touch handles, as they are self-contained (either do not use aggregated\n // blob Or contain aggregated blob that stays relevant for that sub-tree)\n // Note:\n // From perf perspective, it makes sense to place aggregated blobs one level up in the tree not to create extra\n // tree nodes (i.e. have shallow tree with less edges). But that creates problems with reusability of trees at\n // incremental summary time - we would need to understand handles and parse them. In current design we can skip\n // that step because if data store is reused, the hole sub-tree is reused included aggregated blob embedded into it\n // and that means we can do nothing and be correct!\n private async compressSmallBlobs(\n summary: ISummaryTree,\n path = \"\",\n level = 0,\n aggregatorArg?: BlobAggregator): Promise<ISummaryTree> {\n if (this.blobCutOffSize === undefined || this.blobCutOffSize < 0) {\n return summary;\n }\n\n let shouldCompress: boolean = false;\n\n let aggregator = aggregatorArg;\n // checking if this is a dataStore tree, since we only pack at data store level\n if (Object.keys(summary.tree).includes(\".component\")) {\n assert(aggregator === undefined, 0x0fb /* \"logic err with aggregator\" */);\n assert(level === this.packingLevel, 0x23b /* \"we are not packing at the right level\" */);\n aggregator = new BlobAggregator();\n shouldCompress = true;\n } else {\n assert(level !== this.packingLevel, 0x23c /* \"we are not packing at the right level\" */);\n }\n\n const newSummary: ISummaryTree = { ...summary };\n newSummary.tree = { ...newSummary.tree };\n for (const key of Object.keys(summary.tree)) {\n const obj = summary.tree[key];\n // Get path relative to root of data store (where we do aggregation)\n const newPath = shouldCompress ? key : `${path}/${key}`;\n switch (obj.type) {\n case SummaryType.Tree:\n // If client created empty tree, keep it as is\n // Also do not package search blobs - they are part of storage contract\n if (obj.tree !== {} && key !== \"__search\") {\n const tree = await this.compressSmallBlobs(obj, newPath, level + 1, aggregator);\n newSummary.tree[key] = tree;\n if (tree.tree === {}) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete newSummary.tree[key];\n }\n }\n break;\n case SummaryType.Blob:\n if (aggregator && typeof obj.content == \"string\" && obj.content.length < this.blobCutOffSize) {\n aggregator.addBlob(newPath, obj.content);\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete newSummary.tree[key];\n }\n break;\n case SummaryType.Handle: {\n // Would be nice to:\n // Trees: expand the tree\n // Blobs: parse handle and ensure it points to real blob, not virtual blob.\n // We can avoid it for now given data store is the granularity of incremental summaries.\n let handlePath = obj.handle;\n if (handlePath.startsWith(\"/\")) {\n handlePath = handlePath.substr(1);\n }\n // Ensure only whole data stores can be reused, no reusing at deeper level!\n assert(level === 0, 0x0fc /* \"tree reuse at lower level\" */);\n assert(!handlePath.includes(\"/\"),\n 0x0fd /* \"data stores are writing incremental summaries!\" */);\n break;\n }\n case SummaryType.Attachment:\n assert(this.isRealStorageId(obj.id), 0x0fe /* \"attachment is aggregate blob\" */);\n break;\n default:\n unreachableCase(obj, `Unknown type: ${(obj as any).type}`);\n }\n }\n\n assert(newSummary.tree[this.aggregatedBlobName] === undefined, 0x0ff /* \"duplicate aggregate blob\" */);\n if (shouldCompress) {\n // Note: It would be great to add code here to unpack aggregate blob back to normal blobs\n // If only one blob made it into aggregate. Currently that does not happen as we always have\n // at least one .component blob and at least one DDS that has .attributes blob, so it's not an issue.\n // But it's possible that in future that would be great addition!\n // Good news - it's backward compatible change.\n assert(aggregator !== undefined, 0x100 /* \"logic error\" */);\n const content = aggregator.getAggregatedBlobContent();\n if (content !== undefined) {\n newSummary.tree[this.aggregatedBlobName] = {\n type: SummaryType.Blob,\n content,\n };\n }\n }\n return newSummary;\n }\n\n protected isRealStorageId(id: string): boolean {\n return !id.startsWith(this.virtualIdPrefix);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"blobAggregationStorage.js","sourceRoot":"","sources":["../src/blobAggregationStorage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,+EAO8C;AAC9C,+DAOsC;AAEtC,qEAA4E;AAE5E;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAqB,EAAE,QAA4B;IAC3E,IAAI,IAAI,YAAY,UAAU,EAAE;QAC/B,8DAA8D;QAC9D,OAAO,IAAA,iCAAkB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;KAC1C;IACD,OAAO,IAAA,6BAAc,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,cAAc;IAApB;QACkB,YAAO,GAAuB,EAAE,CAAC;IAiBnD,CAAC;IAfO,OAAO,CAAC,GAAW,EAAE,OAAe;QAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;IACnC,CAAC;IAEM,wBAAwB;QAC9B,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,OAAO,SAAS,CAAC;SACjB;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAA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;IAES,eAAe,CAAC,EAAU;QACnC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC7C,CAAC;;AA5QF,wDA6QC;AA5QA,6FAA6F;AAC7F,8BAA8B;AAC9B,uGAAuG;AACvG,yGAAyG;AACzG,4FAA4F;AAC5F,qGAAqG;AACrG,oGAAoG;AACpG,mCAAmC;AACnC,yGAAyG;AACzG,mFAAmF;AACnE,6CAAsB,GAAG,IAAI,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tassert,\n\tbufferToString,\n\tstringToBuffer,\n\tunreachableCase,\n\tfromUtf8ToBase64,\n\tUint8ArrayToString,\n} from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { loggerToMonitoringContext } from \"@fluidframework/telemetry-utils\";\n\n/*\n * Work around for bufferToString having a bug - it can't consume IsoBuffer!\n * To be removed once bufferToString is fixed!\n */\nfunction bufferToString2(blob: ArrayBufferLike, encoding: \"utf-8\" | \"base64\"): string {\n\tif (blob instanceof Uint8Array) {\n\t\t// IsoBuffer does not have ctor, so it's not in proto chain :(\n\t\treturn Uint8ArrayToString(blob, encoding);\n\t}\n\treturn bufferToString(blob, encoding);\n}\n\n/**\n * Class responsible for aggregating smaller blobs into one and unpacking it later on.\n */\nclass BlobAggregator {\n\tprivate readonly content: [string, string][] = [];\n\n\tpublic addBlob(key: string, content: string) {\n\t\tthis.content.push([key, content]);\n\t}\n\n\tpublic getAggregatedBlobContent() {\n\t\tif (this.content.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn JSON.stringify(this.content);\n\t}\n\n\tstatic load(input: ArrayBufferLike) {\n\t\tconst data = bufferToString2(input, \"utf-8\");\n\t\treturn JSON.parse(data) as [string, string][];\n\t}\n}\n\n/*\n * Base class that deals with unpacking snapshots (in place) containing aggregated blobs\n * It relies on abstract methods for reads and storing unpacked blobs.\n */\nexport abstract class SnapshotExtractor {\n\tprotected readonly aggregatedBlobName = \"__big\";\n\tprotected readonly virtualIdPrefix = \"__\";\n\n\t// counter for generation of virtual storage IDs\n\tprotected virtualIdCounter = 0;\n\tprotected getNextVirtualId() {\n\t\treturn `${this.virtualIdPrefix}${++this.virtualIdCounter}`;\n\t}\n\n\tabstract getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike>;\n\tabstract setBlob(id: string, tree: ISnapshotTree, content: string);\n\n\tpublic async unpackSnapshotCore(snapshot: ISnapshotTree, level = 0): Promise<void> {\n\t\tfor (const key of Object.keys(snapshot.trees)) {\n\t\t\tconst obj = snapshot.trees[key];\n\t\t\tawait this.unpackSnapshotCore(obj, level + 1);\n\t\t}\n\n\t\t// For future proof, we will support multiple aggregated blobs with any name\n\t\t// that starts with this.aggregatedBlobName\n\t\tfor (const key of Object.keys(snapshot.blobs)) {\n\t\t\tif (!key.startsWith(this.aggregatedBlobName)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst blobId = snapshot.blobs[key];\n\t\t\tif (blobId !== undefined) {\n\t\t\t\tconst blob = await this.getBlob(blobId, snapshot);\n\t\t\t\tfor (const [path, value] of BlobAggregator.load(blob)) {\n\t\t\t\t\tconst id = this.getNextVirtualId();\n\t\t\t\t\tthis.setBlob(id, snapshot, value);\n\t\t\t\t\tconst pathSplit = path.split(\"/\");\n\t\t\t\t\tlet subTree = snapshot;\n\t\t\t\t\tfor (const subPath of pathSplit.slice(0, pathSplit.length - 1)) {\n\t\t\t\t\t\tif (subTree.trees[subPath] === undefined) {\n\t\t\t\t\t\t\tsubTree.trees[subPath] = { blobs: {}, trees: {} };\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsubTree = subTree.trees[subPath];\n\t\t\t\t\t}\n\t\t\t\t\tconst blobName = pathSplit[pathSplit.length - 1];\n\t\t\t\t\tassert(\n\t\t\t\t\t\tsubTree.blobs[blobName] === undefined,\n\t\t\t\t\t\t0x0f6 /* \"real blob ID exists\" */,\n\t\t\t\t\t);\n\t\t\t\t\tsubTree.blobs[blobName] = id;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete snapshot.blobs[this.aggregatedBlobName];\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n * Snapshot extractor class that works in place, i.e. patches snapshot that has\n * blob content in ISnapshotTree.blobs itself, not in storage.\n * As result, it implements reading and writing of blobs to/from snapshot itself.\n * It follows existing pattern that mixes concerns - ISnapshotTree.blobs is used for two\n * purposes:\n * 1. map path name to blob ID\n * 2. map blob ID to blob content\n * #2 is what storage (IDocumentStorageService) is for, but in places where we do not have it\n * (like loading serialized earlier draft content), blob content is put directly into snapshot.\n * Ideally this should be fixed by using BlobCacheStorageService or something similar and\n * fixing existing flows to allow switching of storage.\n */\nclass SnapshotExtractorInPlace extends SnapshotExtractor {\n\tpublic async getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike> {\n\t\tconst blob = tree.blobs[id];\n\t\tassert(blob !== undefined, 0x0f7 /* \"aggregate blob missing\" */);\n\t\treturn stringToBuffer(blob, \"base64\");\n\t}\n\n\tpublic setBlob(id: string, tree: ISnapshotTree, content: string) {\n\t\tassert(\n\t\t\ttree.blobs[id] === undefined,\n\t\t\t0x0f8 /* \"blob from aggregate blob exists on its own\" */,\n\t\t);\n\t\ttree.blobs[id] = fromUtf8ToBase64(content);\n\t}\n}\n\n/*\n * Snapshot packer and extractor.\n * When summary is written it will find and aggregate small blobs into bigger blobs\n * When snapshot is read, it will unpack aggregated blobs and provide them transparently to caller.\n */\nexport class BlobAggregationStorage extends SnapshotExtractor implements IDocumentStorageService {\n\t// Tells data store if it can use incremental summary (i.e. reuse DDSes from previous summary\n\t// when only one DDS changed).\n\t// The answer has to be know long before we enable actual packing. The reason for the is the following:\n\t// A the moment when we enable packing, we should assume that all clients out there wil already have bits\n\t// that can unpack properly (i.e. enough time passed since we deployed bits that can unpack)\n\t// But we can still have clients where some of them already pack, and some do not. If one summary was\n\t// using packing, then it relies on non-incremental summaries going forward, even if next client who\n\t// produced summary is not packing!\n\t// This can have slight improvement by enabling it per file (based on \"did summary we loaded from contain\n\t// aggregated blobs\"), but that's harder to make reliable, so going for simplicity.\n\tstatic readonly fullDataStoreSummaries = true;\n\n\tprotected loadedFromSummary = false;\n\n\tprotected virtualBlobs = new Map<string, ArrayBufferLike>();\n\n\tstatic wrap(\n\t\tstorage: IDocumentStorageService,\n\t\tlogger: ITelemetryLogger,\n\t\tallowPacking?: boolean,\n\t\tpackingLevel = 2,\n\t) {\n\t\tif (storage instanceof BlobAggregationStorage) {\n\t\t\treturn storage;\n\t\t}\n\t\tconst mc = loggerToMonitoringContext(logger);\n\t\tconst realAllowPackaging =\n\t\t\tmc.config.getBoolean(\"FluidAggregateBlobs\") ?? allowPacking ?? false;\n\n\t\t// Always create BlobAggregationStorage even if storage is not asking for packing.\n\t\t// This is mostly to avoid cases where future changes in policy would result in inability to\n\t\t// load old files that were created with aggregation on.\n\t\tconst minBlobSize = storage.policies?.minBlobSize;\n\t\treturn new BlobAggregationStorage(\n\t\t\tstorage,\n\t\t\tlogger,\n\t\t\trealAllowPackaging,\n\t\t\tpackingLevel,\n\t\t\tminBlobSize,\n\t\t);\n\t}\n\n\tstatic async unpackSnapshot(snapshot: ISnapshotTree) {\n\t\tconst converter = new SnapshotExtractorInPlace();\n\t\tawait converter.unpackSnapshotCore(snapshot);\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\tconst policies = this.storage.policies;\n\t\tif (policies) {\n\t\t\treturn { ...policies, minBlobSize: undefined };\n\t\t}\n\t}\n\n\tpublic async unpackSnapshot(snapshot: ISnapshotTree) {\n\t\t// SummarizerNodeWithGC.refreshLatestSummary can call it when this.loadedFromSummary === false\n\t\t// (I assumed after file was created)\n\t\t// assert(!this.loadedFromSummary, \"unpack without summary\");\n\n\t\tthis.loadedFromSummary = true;\n\t\tawait this.unpackSnapshotCore(snapshot);\n\t}\n\n\tprotected constructor(\n\t\tprivate readonly storage: IDocumentStorageService,\n\t\tprivate readonly logger: ITelemetryLogger,\n\t\tprivate readonly allowPacking: boolean,\n\t\tprivate readonly packingLevel: number,\n\t\tprivate readonly blobCutOffSize?: number,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic setBlob(id: string, tree: ISnapshotTree, content: string) {\n\t\tthis.virtualBlobs.set(id, stringToBuffer(content, \"utf-8\"));\n\t}\n\n\tpublic async getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike> {\n\t\treturn this.readBlob(id).catch((error) => {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"BlobDedupNoAggregateBlob\" }, error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tpublic get repositoryUrl() {\n\t\treturn this.storage.repositoryUrl;\n\t}\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t) {\n\t\treturn this.storage.getVersions(versionId, count, scenarioName, fetchSource);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NYI\");\n\t}\n\n\t// for now we are not optimizing these blobs, with assumption that this API is used only\n\t// for big blobs (images)\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.storage.createBlob(file);\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tconst tree = await this.storage.getSnapshotTree(version);\n\t\tif (tree) {\n\t\t\tawait this.unpackSnapshot(tree);\n\t\t}\n\t\treturn tree;\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tif (this.isRealStorageId(id)) {\n\t\t\treturn this.storage.readBlob(id);\n\t\t}\n\t\t// We support only reading blobs from the summary we loaded from.\n\t\t// This may need to be extended to any general summary in the future as runtime usage pattern\n\t\t// of storage changes (for example, data stores start to load from recent summary, not from original\n\t\t// summary whole container loaded from)\n\n\t\t// are there other ways we can get here? createFile is one flow, but we should not be reading blobs\n\t\t// in such flow\n\t\tassert(this.loadedFromSummary, 0x0f9 /* \"never read summary\" */);\n\t\tconst blob = this.virtualBlobs.get(id);\n\t\tassert(blob !== undefined, 0x0fa /* \"virtual blob not found\" */);\n\t\treturn blob;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryNew = this.allowPacking ? await this.compressSmallBlobs(summary) : summary;\n\t\treturn this.storage.uploadSummaryWithContext(summaryNew, context);\n\t}\n\n\t// For simplification, we assume that\n\t// - blob aggregation is done at data store level only for now\n\t// - data store either reuses previous summary, or generates full summary, i.e. there is no partial (some DDS)\n\t// summary produced by data stores.\n\t// These simplifications allow us not to touch handles, as they are self-contained (either do not use aggregated\n\t// blob Or contain aggregated blob that stays relevant for that sub-tree)\n\t// Note:\n\t// From perf perspective, it makes sense to place aggregated blobs one level up in the tree not to create extra\n\t// tree nodes (i.e. have shallow tree with less edges). But that creates problems with reusability of trees at\n\t// incremental summary time - we would need to understand handles and parse them. In current design we can skip\n\t// that step because if data store is reused, the hole sub-tree is reused included aggregated blob embedded into it\n\t// and that means we can do nothing and be correct!\n\tprivate async compressSmallBlobs(\n\t\tsummary: ISummaryTree,\n\t\tpath = \"\",\n\t\tlevel = 0,\n\t\taggregatorArg?: BlobAggregator,\n\t): Promise<ISummaryTree> {\n\t\tif (this.blobCutOffSize === undefined || this.blobCutOffSize < 0) {\n\t\t\treturn summary;\n\t\t}\n\n\t\tlet shouldCompress: boolean = false;\n\n\t\tlet aggregator = aggregatorArg;\n\t\t// checking if this is a dataStore tree, since we only pack at data store level\n\t\tif (Object.keys(summary.tree).includes(\".component\")) {\n\t\t\tassert(aggregator === undefined, 0x0fb /* \"logic err with aggregator\" */);\n\t\t\tassert(\n\t\t\t\tlevel === this.packingLevel,\n\t\t\t\t0x23b /* \"we are not packing at the right level\" */,\n\t\t\t);\n\t\t\taggregator = new BlobAggregator();\n\t\t\tshouldCompress = true;\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tlevel !== this.packingLevel,\n\t\t\t\t0x23c /* \"we are not packing at the right level\" */,\n\t\t\t);\n\t\t}\n\n\t\tconst newSummary: ISummaryTree = { ...summary };\n\t\tnewSummary.tree = { ...newSummary.tree };\n\t\tfor (const key of Object.keys(summary.tree)) {\n\t\t\tconst obj = summary.tree[key];\n\t\t\t// Get path relative to root of data store (where we do aggregation)\n\t\t\tconst newPath = shouldCompress ? key : `${path}/${key}`;\n\t\t\tswitch (obj.type) {\n\t\t\t\tcase SummaryType.Tree:\n\t\t\t\t\t// If client created empty tree, keep it as is\n\t\t\t\t\t// Also do not package search blobs - they are part of storage contract\n\t\t\t\t\tif (obj.tree !== {} && key !== \"__search\") {\n\t\t\t\t\t\tconst tree = await this.compressSmallBlobs(\n\t\t\t\t\t\t\tobj,\n\t\t\t\t\t\t\tnewPath,\n\t\t\t\t\t\t\tlevel + 1,\n\t\t\t\t\t\t\taggregator,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tnewSummary.tree[key] = tree;\n\t\t\t\t\t\tif (tree.tree === {}) {\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\t\t\t\tdelete newSummary.tree[key];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase SummaryType.Blob:\n\t\t\t\t\tif (\n\t\t\t\t\t\taggregator &&\n\t\t\t\t\t\ttypeof obj.content == \"string\" &&\n\t\t\t\t\t\tobj.content.length < this.blobCutOffSize\n\t\t\t\t\t) {\n\t\t\t\t\t\taggregator.addBlob(newPath, obj.content);\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\t\t\tdelete newSummary.tree[key];\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase SummaryType.Handle: {\n\t\t\t\t\t// Would be nice to:\n\t\t\t\t\t// Trees: expand the tree\n\t\t\t\t\t// Blobs: parse handle and ensure it points to real blob, not virtual blob.\n\t\t\t\t\t// We can avoid it for now given data store is the granularity of incremental summaries.\n\t\t\t\t\tlet handlePath = obj.handle;\n\t\t\t\t\tif (handlePath.startsWith(\"/\")) {\n\t\t\t\t\t\thandlePath = handlePath.substr(1);\n\t\t\t\t\t}\n\t\t\t\t\t// Ensure only whole data stores can be reused, no reusing at deeper level!\n\t\t\t\t\tassert(level === 0, 0x0fc /* \"tree reuse at lower level\" */);\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!handlePath.includes(\"/\"),\n\t\t\t\t\t\t0x0fd /* \"data stores are writing incremental summaries!\" */,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase SummaryType.Attachment:\n\t\t\t\t\tassert(\n\t\t\t\t\t\tthis.isRealStorageId(obj.id),\n\t\t\t\t\t\t0x0fe /* \"attachment is aggregate blob\" */,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(obj, `Unknown type: ${(obj as any).type}`);\n\t\t\t}\n\t\t}\n\n\t\tassert(\n\t\t\tnewSummary.tree[this.aggregatedBlobName] === undefined,\n\t\t\t0x0ff /* \"duplicate aggregate blob\" */,\n\t\t);\n\t\tif (shouldCompress) {\n\t\t\t// Note: It would be great to add code here to unpack aggregate blob back to normal blobs\n\t\t\t// If only one blob made it into aggregate. Currently that does not happen as we always have\n\t\t\t// at least one .component blob and at least one DDS that has .attributes blob, so it's not an issue.\n\t\t\t// But it's possible that in future that would be great addition!\n\t\t\t// Good news - it's backward compatible change.\n\t\t\tassert(aggregator !== undefined, 0x100 /* \"logic error\" */);\n\t\t\tconst content = aggregator.getAggregatedBlobContent();\n\t\t\tif (content !== undefined) {\n\t\t\t\tnewSummary.tree[this.aggregatedBlobName] = {\n\t\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\t\tcontent,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn newSummary;\n\t}\n\n\tprotected isRealStorageId(id: string): boolean {\n\t\treturn !id.startsWith(this.virtualIdPrefix);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobCacheStorageService.d.ts","sourceRoot":"","sources":["../src/blobCacheStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"blobCacheStorageService.d.ts","sourceRoot":"","sources":["../src/blobCacheStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,uBAAuB,EACvB,+BAA+B,EAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,2BAA2B;IAGtE,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADtB,sBAAsB,EAAE,uBAAuB,EAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC;IAKrD,IAAW,QAAQ,IAAI,+BAA+B,GAAG,SAAS,CAEjE;IAEY,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAQ3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobCacheStorageService.js","sourceRoot":"","sources":["../src/blobCacheStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"blobCacheStorageService.js","sourceRoot":"","sources":["../src/blobCacheStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,+EAA4E;AAE5E;;GAEG;AACH,MAAa,uBAAwB,SAAQ,yDAA2B;IACvE,YACC,sBAA+C,EAC9B,KAAmC;QAEpD,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAFb,UAAK,GAAL,KAAK,CAA8B;IAGrD,CAAC;IAED,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,EAAU;QAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,IAAI,KAAK,SAAS,EAAE;YACvB,OAAO,IAAI,CAAC;SACZ;QAED,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC;CACD;AApBD,0DAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy\";\n\n/**\n * IDocumentStorageService adapter with pre-cached blobs.\n */\nexport class BlobCacheStorageService extends DocumentStorageServiceProxy {\n\tconstructor(\n\t\tinternalStorageService: IDocumentStorageService,\n\t\tprivate readonly blobs: Map<string, ArrayBufferLike>,\n\t) {\n\t\tsuper(internalStorageService);\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.internalStorageService.policies;\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst blob = this.blobs.get(id);\n\t\tif (blob !== undefined) {\n\t\t\treturn blob;\n\t\t}\n\n\t\treturn this.internalStorageService.readBlob(id);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildSnapshotTree.d.ts","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"buildSnapshotTree.d.ts","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,aAAa,EACb,UAAU,EAEV,MAAM,sCAAsC,CAAC;AAoE9C;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,UAAU,EAAE,EACrB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GACnC,aAAa,CAGf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildSnapshotTree.js","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsE;AAEtE,+EAK8C;AAC9C,iEAA+D;AAC/D,+BAAkC;AAElC,SAAS,WAAW,
|
|
1
|
+
{"version":3,"file":"buildSnapshotTree.js","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsE;AAEtE,+EAK8C;AAC9C,iEAA+D;AAC/D,+BAAkC;AAElC,SAAS,WAAW,CACnB,IAAY,EACZ,WAAyB,EACzB,OAAqC;IAErC,MAAM,OAAO,GAAqB,EAAE,CAAC;IACrC,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE;QACpC,MAAM,OAAO,GAAG,GAAG,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QAE3C,IAAI,SAAS,CAAC,IAAI,KAAK,gCAAS,CAAC,IAAI,EAAE;YACtC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC;YAC7B,MAAM,MAAM,GAAG,IAAA,6BAAc,EAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAA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C,OAAO;QACN,GAAG,EAAE,EAAE;QACP,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,EAAE;KACP,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAChC,OAAqB,EACrB,OAAqC;IAErC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,IAAA,8BAAc,EAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAND,8CAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, stringToBuffer } from \"@fluidframework/common-utils\";\nimport * as git from \"@fluidframework/gitresources\";\nimport {\n\tFileMode,\n\tISnapshotTree,\n\tITreeEntry,\n\tTreeEntry,\n} from \"@fluidframework/protocol-definitions\";\nimport { buildHierarchy } from \"@fluidframework/protocol-base\";\nimport { v4 as uuid } from \"uuid\";\n\nfunction flattenCore(\n\tpath: string,\n\ttreeEntries: ITreeEntry[],\n\tblobMap: Map<string, ArrayBufferLike>,\n): git.ITreeEntry[] {\n\tconst entries: git.ITreeEntry[] = [];\n\tfor (const treeEntry of treeEntries) {\n\t\tconst subPath = `${path}${treeEntry.path}`;\n\n\t\tif (treeEntry.type === TreeEntry.Blob) {\n\t\t\tconst blob = treeEntry.value;\n\t\t\tconst buffer = stringToBuffer(blob.contents, blob.encoding);\n\t\t\tconst id = uuid();\n\t\t\tblobMap.set(id, buffer);\n\n\t\t\tconst entry: git.ITreeEntry = {\n\t\t\t\tmode: FileMode[treeEntry.mode],\n\t\t\t\tpath: subPath,\n\t\t\t\tsha: id,\n\t\t\t\tsize: 0,\n\t\t\t\ttype: \"blob\",\n\t\t\t\turl: \"\",\n\t\t\t};\n\t\t\tentries.push(entry);\n\t\t} else if (treeEntry.type === TreeEntry.Tree) {\n\t\t\tassert(\n\t\t\t\ttreeEntry.type === TreeEntry.Tree,\n\t\t\t\t0x101 /* \"Unexpected tree entry type on flatten!\" */,\n\t\t\t);\n\t\t\tconst t = treeEntry.value;\n\t\t\tconst entry: git.ITreeEntry = {\n\t\t\t\tmode: FileMode[treeEntry.mode],\n\t\t\t\tpath: subPath,\n\t\t\t\tsha: \"\",\n\t\t\t\tsize: -1,\n\t\t\t\ttype: \"tree\",\n\t\t\t\turl: \"\",\n\t\t\t};\n\t\t\tentries.push(entry);\n\n\t\t\tconst subTreeEntries = flattenCore(`${subPath}/`, t.entries, blobMap);\n\t\t\tentries.push(...subTreeEntries);\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Create a flatten view of an array of ITreeEntry\n *\n * @param tree - an array of ITreeEntry to flatten\n * @param blobMap - a map of blob's sha1 to content\n * @returns A flatten with of the ITreeEntry\n */\nfunction flatten(tree: ITreeEntry[], blobMap: Map<string, ArrayBufferLike>): git.ITree {\n\tconst entries = flattenCore(\"\", tree, blobMap);\n\treturn {\n\t\tsha: \"\",\n\t\ttree: entries,\n\t\turl: \"\",\n\t};\n}\n\n/**\n * Build a tree hierarchy base on an array of ITreeEntry\n *\n * @param entries - an array of ITreeEntry to flatten\n * @param blobMap - a map of blob's sha1 to content that gets filled with content from entries\n * NOTE: blobMap's validity is contingent on the returned promise's resolution\n * @returns the hierarchical tree\n */\nexport function buildSnapshotTree(\n\tentries: ITreeEntry[],\n\tblobMap: Map<string, ArrayBufferLike>,\n): ISnapshotTree {\n\tconst flattened = flatten(entries, blobMap);\n\treturn buildHierarchy(flattened);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentStorageServiceProxy.d.ts","sourceRoot":"","sources":["../src/documentStorageServiceProxy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"documentStorageServiceProxy.d.ts","sourceRoot":"","sources":["../src/documentStorageServiceProxy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,WAAW,EACX,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAE9C,qBAAa,2BAA4B,YAAW,uBAAuB;IAe9D,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,uBAAuB;IAd9E,OAAO,CAAC,SAAS,CAA8C;IAE/D,IAAW,QAAQ,CAAC,QAAQ,EAAE,+BAA+B,GAAG,SAAS,EAExE;IAED,IAAW,QAAQ,IAJW,+BAA+B,GAAG,SAAS,CAMxE;IAED,IAAW,aAAa,IAAI,MAAM,CAEjC;gBAE8B,sBAAsB,EAAE,uBAAuB;IAEjE,eAAe,CAC3B,OAAO,CAAC,EAAE,QAAQ,EAClB,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAInB,WAAW,CACvB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIT,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAIL,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAI9D,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI/D,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAG/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentStorageServiceProxy.js","sourceRoot":"","sources":["../src/documentStorageServiceProxy.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgBH,MAAa,2BAA2B;
|
|
1
|
+
{"version":3,"file":"documentStorageServiceProxy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,CAAC,sBAAsB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;CACD;AAnDD,kEAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\n\nexport class DocumentStorageServiceProxy implements IDocumentStorageService {\n\tprivate _policies: IDocumentStorageServicePolicies | undefined;\n\n\tpublic set policies(policies: IDocumentStorageServicePolicies | undefined) {\n\t\tthis._policies = policies;\n\t}\n\n\tpublic get policies() {\n\t\treturn this._policies ?? this.internalStorageService.policies;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this.internalStorageService.repositoryUrl;\n\t}\n\n\tconstructor(protected readonly internalStorageService: IDocumentStorageService) {}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.internalStorageService.getSnapshotTree(version, scenarioName);\n\t}\n\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this.internalStorageService.getVersions(versionId, count, scenarioName, fetchSource);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this.internalStorageService.uploadSummaryWithContext(summary, context);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.internalStorageService.downloadSummary(handle);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.internalStorageService.createBlob(file);\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.internalStorageService.readBlob(blobId);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emptyDocumentDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/emptyDocumentDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF;;GAEG;AACH,qBAAa,gCAAiC,YAAW,4BAA4B;
|
|
1
|
+
{"version":3,"file":"emptyDocumentDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/emptyDocumentDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF;;GAEG;AACH,qBAAa,gCAAiC,YAAW,4BAA4B;IAC7E,aAAa,CACnB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,YAAY,CAAC,EAAE,WAAW,EAC1B,WAAW,CAAC,EAAE,OAAO,EACrB,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,yBAAyB,EAAE,CAAC;CAKvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emptyDocumentDeltaStorageService.js","sourceRoot":"","sources":["../src/emptyDocumentDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,yDAA2C;AAE3C;;GAEG;AACH,MAAa,gCAAgC;
|
|
1
|
+
{"version":3,"file":"emptyDocumentDeltaStorageService.js","sourceRoot":"","sources":["../src/emptyDocumentDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,yDAA2C;AAE3C;;GAEG;AACH,MAAa,gCAAgC;IACrC,aAAa,CACnB,IAAY,EACZ,GAAuB,EACvB,YAA0B,EAC1B,WAAqB,EACrB,YAAqB;QAErB,MAAM,KAAK,GAAG,IAAI,wBAAK,EAA+B,CAAC;QACvD,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AAZD,4EAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentDeltaStorageService, IStream } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { Queue } from \"./parallelRequests\";\n\n/**\n * Implementation of IDocumentDeltaStorageService that will always return an empty message queue when fetching messages\n */\nexport class EmptyDocumentDeltaStorageService implements IDocumentDeltaStorageService {\n\tpublic fetchMessages(\n\t\tfrom: number,\n\t\t_to: number | undefined,\n\t\t_abortSignal?: AbortSignal,\n\t\t_cachedOnly?: boolean,\n\t\t_fetchReason?: string,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\tconst queue = new Queue<ISequencedDocumentMessage[]>();\n\t\tqueue.pushDone();\n\t\treturn queue;\n\t}\n}\n"]}
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEhF,0FAA0F;AAC1F,qBAAa,UAAW,SAAQ,YAAa,YAAW,gBAAgB,EAAE,eAAe;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEhF,0FAA0F;AAC1F,qBAAa,UAAW,SAAQ,YAAa,YAAW,gBAAgB,EAAE,eAAe;IACxF,QAAQ,CAAC,SAAS,8BAA8B;IAChD,QAAQ,CAAC,QAAQ,SAAS;gBAEd,OAAO,EAAE,MAAM;CAG3B"}
|
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2EAAuF;AACvF,qEAAgF;AAEhF,0FAA0F;AAC1F,MAAa,UAAW,SAAQ,8BAAY;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2EAAuF;AACvF,qEAAgF;AAEhF,0FAA0F;AAC1F,MAAa,UAAW,SAAQ,8BAAY;IAI3C,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAJ7B,cAAS,GAAG,oCAAe,CAAC,UAAU,CAAC;QACvC,aAAQ,GAAG,KAAK,CAAC;IAI1B,CAAC;CACD;AAPD,gCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DriverErrorType, IDriverErrorBase } from \"@fluidframework/driver-definitions\";\nimport { IFluidErrorBase, LoggingError } from \"@fluidframework/telemetry-utils\";\n\n/** Error indicating an API is being used improperly resulting in an invalid operation. */\nexport class UsageError extends LoggingError implements IDriverErrorBase, IFluidErrorBase {\n\treadonly errorType = DriverErrorType.usageError;\n\treadonly canRetry = false;\n\n\tconstructor(message: string) {\n\t\tsuper(message, { usageError: true });\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidResolvedUrl.d.ts","sourceRoot":"","sources":["../src/fluidResolvedUrl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAErF,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"fluidResolvedUrl.d.ts","sourceRoot":"","sources":["../src/fluidResolvedUrl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAErF,eAAO,MAAM,kBAAkB,aACpB,YAAY,GAAG,SAAS,kCAC2B,CAAC;AAE/D,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,YAAY,GAAG,SAAS,GAChC,OAAO,CAAC,QAAQ,IAAI,iBAAiB,CAIvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidResolvedUrl.js","sourceRoot":"","sources":["../src/fluidResolvedUrl.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAII,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"fluidResolvedUrl.js","sourceRoot":"","sources":["../src/fluidResolvedUrl.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAII,MAAM,kBAAkB,GAAG,CACjC,QAAkC,EACF,EAAE,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,OAAO,CAAC;AAFlD,QAAA,kBAAkB,sBAEgC;AAE/D,SAAgB,sBAAsB,CACrC,QAAkC;IAElC,IAAI,CAAC,IAAA,0BAAkB,EAAC,QAAQ,CAAC,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE,CAAC,CAAC;KACxE;AACF,CAAC;AAND,wDAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResolvedUrl, IFluidResolvedUrl } from \"@fluidframework/driver-definitions\";\n\nexport const isFluidResolvedUrl = (\n\tresolved: IResolvedUrl | undefined,\n): resolved is IFluidResolvedUrl => resolved?.type === \"fluid\";\n\nexport function ensureFluidResolvedUrl(\n\tresolved: IResolvedUrl | undefined,\n): asserts resolved is IFluidResolvedUrl {\n\tif (!isFluidResolvedUrl(resolved)) {\n\t\tthrow new Error(`resolved is not a Fluid url. Type: ${resolved?.type}`);\n\t}\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,5 +23,5 @@ export { readAndParse } from "./readAndParse";
|
|
|
23
23
|
export { IProgress, runWithRetry } from "./runWithRetry";
|
|
24
24
|
export { combineAppAndProtocolSummary, getDocAttributesFromProtocolSummary, getQuorumValuesFromProtocolSummary, } from "./summaryForCreateNew";
|
|
25
25
|
export { convertSummaryTreeToSnapshotITree } from "./treeConversions";
|
|
26
|
-
export { convertSnapshotAndBlobsToSummaryTree, ISummaryTreeAssemblerProps, SummaryTreeAssembler } from "./treeUtils";
|
|
26
|
+
export { convertSnapshotAndBlobsToSummaryTree, ISummaryTreeAssemblerProps, SummaryTreeAssembler, } from "./treeUtils";
|
|
27
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC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yGAAA,KAAK,OAAA;AACL,8GAAA,UAAU,OAAA;AACV,sHAAA,kBAAkB,OAAA;AAClB,kHAAA,cAAc,OAAA;AAEf,mFAAkF;AAAzE,gJAAA,8BAA8B,OAAA;AACvC,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,+CAAyD;AAArC,4GAAA,YAAY,OAAA;AAChC,6DAI+B;AAH9B,mIAAA,4BAA4B,OAAA;AAC5B,0IAAA,mCAAmC,OAAA;AACnC,yIAAA,kCAAkC,OAAA;AAEnC,qDAAsE;AAA7D,oIAAA,iCAAiC,OAAA;AAC1C,yCAIqB;AAHpB,iIAAA,oCAAoC,OAAA;AAEpC,iHAAA,oBAAoB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { BlobAggregationStorage, SnapshotExtractor } from \"./blobAggregationStorage\";\nexport { BlobCacheStorageService } from \"./blobCacheStorageService\";\nexport { buildSnapshotTree } from \"./buildSnapshotTree\";\nexport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy\";\nexport { EmptyDocumentDeltaStorageService } from \"./emptyDocumentDeltaStorageService\";\nexport { UsageError } from \"./error\";\nexport { ensureFluidResolvedUrl, isFluidResolvedUrl } from \"./fluidResolvedUrl\";\nexport { InsecureUrlResolver } from \"./insecureUrlResolver\";\nexport { MapWithExpiration } from \"./mapWithExpiration\";\nexport {\n\tcanBeCoalescedByService,\n\tisRuntimeMessage,\n\tisUnpackedRuntimeMessage,\n\tMessageType2,\n} from \"./messageRecognition\";\nexport { MultiDocumentServiceFactory } from \"./multiDocumentServiceFactory\";\nexport { configurableUrlResolver, MultiUrlResolver } from \"./multiUrlResolver\";\nexport {\n\tAuthorizationError,\n\tcanRetryOnError,\n\tcreateGenericNetworkError,\n\tcreateWriteError,\n\tDeltaStreamConnectionForbiddenError,\n\tDriverErrorTelemetryProps,\n\tFluidInvalidSchemaError,\n\tGenericNetworkError,\n\tgetRetryDelayFromError,\n\tgetRetryDelaySecondsFromError,\n\tIAnyDriverError,\n\tisOnline,\n\tLocationRedirectionError,\n\tNetworkErrorBasic,\n\tNonRetryableError,\n\tOnlineStatus,\n\tRetryableError,\n\tThrottlingError,\n} from \"./network\";\nexport { logNetworkFailure, waitForConnectedState } from \"./networkUtils\";\nexport {\n\temptyMessageStream,\n\tParallelRequests,\n\tQueue,\n\trequestOps,\n\tstreamFromMessages,\n\tstreamObserver,\n} from \"./parallelRequests\";\nexport { PrefetchDocumentStorageService } from \"./prefetchDocumentStorageService\";\nexport { RateLimiter } from \"./rateLimiter\";\nexport { readAndParse } from \"./readAndParse\";\nexport { IProgress, runWithRetry } from \"./runWithRetry\";\nexport {\n\tcombineAppAndProtocolSummary,\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n} from \"./summaryForCreateNew\";\nexport { convertSummaryTreeToSnapshotITree } from \"./treeConversions\";\nexport {\n\tconvertSnapshotAndBlobsToSummaryTree,\n\tISummaryTreeAssemblerProps,\n\tSummaryTreeAssembler,\n} from \"./treeUtils\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureUrlResolver.d.ts","sourceRoot":"","sources":["../src/insecureUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"insecureUrlResolver.d.ts","sourceRoot":"","sources":["../src/insecureUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAEN,YAAY,EACZ,YAAY,EAEZ,MAAM,oCAAoC,CAAC;AAG5C;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAoB,YAAW,YAAY;IAItD,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAR/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4C;gBAGhD,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,aAAa,GAAE,OAAe;IAGnC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IA+C1E,OAAO,CAAC,aAAa;IAiDR,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBrF,sBAAsB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ;CAU1D"}
|
|
@@ -99,7 +99,8 @@ class InsecureUrlResolver {
|
|
|
99
99
|
}
|
|
100
100
|
const encodedDocId = encodeURIComponent(documentId);
|
|
101
101
|
const relativePath = !documentRelativePath || documentRelativePath.startsWith("/")
|
|
102
|
-
? documentRelativePath
|
|
102
|
+
? documentRelativePath
|
|
103
|
+
: `/${documentRelativePath}`;
|
|
103
104
|
const documentUrl = `fluid://${host}/${encodedTenantId}/${encodedDocId}${relativePath}${queryParams}`;
|
|
104
105
|
const deltaStorageUrl = `${this.ordererUrl}/deltas/${encodedTenantId}/${encodedDocId}`;
|
|
105
106
|
const storageUrl = `${this.storageUrl}/repos/${encodedTenantId}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insecureUrlResolver.js","sourceRoot":"","sources":["../src/insecureUrlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,6BAA4B;AAC5B,+DAAsD;AAEtD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AAG,EAAE,WAAW;SACnB,CAAC;QACF,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,WAAyB,EAAE,WAAmB;;QACtE,MAAM,gBAAgB,GAAG,WAAgC,CAAC;QAE1D,MAAM,SAAS,GAAG,IAAA,WAAK,EAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,CAAC,EAAE,AAAD,EAAG,UAAU,CAAC,GAAG,MAAA,MAAA,SAAS,CAAC,QAAQ,0CAAE,KAAK,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;QAC9D,yEAAyE;QACzE,IAAA,qBAAM,EAAC,CAAC,CAAC,UAAU,EAAE,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAExE,IAAI,GAAG,GAAG,WAAW,CAAC;QACtB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACrB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACvB;QAED,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,kBAAkB,CACxC,IAAI,CAAC,QAAQ,CAAC,IAAI,kBAAkB,CAAC,UAAU,CAAC,IAAI,GAAG,EAAE,CAAC;IAClE,CAAC;IAEM,sBAAsB,CAAC,QAAiB;QAC3C,MAAM,gBAAgB,GAAa;YAC/B,yEAAyE;YACzE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,aAAa,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;YACrE,OAAO,EAAE;gBACL,CAAC,iCAAY,CAAC,SAAS,CAAC,EAAE,IAAI;aACjC;SACJ,CAAC;QACF,OAAO,gBAAgB,CAAC;IAC5B,CAAC;CACJ;AA7HD,kDA6HC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n IFluidResolvedUrl,\n IResolvedUrl,\n IUrlResolver,\n DriverHeader,\n} from \"@fluidframework/driver-definitions\";\nimport Axios from \"axios\";\n\n/**\n * As the name implies this is not secure and should not be used in production. It simply makes the example easier\n * to get up and running.\n *\n * In our example we run a simple web server via webpack-dev-server. This defines a URL format of the form\n * http://localhost:8080/<documentId>/<path>.\n *\n * We then need to map that to a Fluid based URL. These are of the form\n * fluid://orderingUrl/<tenantId>/<documentId>/<path>.\n *\n * The tenantId/documentId pair defines the 'full' document ID the service makes use of. The path is then an optional\n * part of the URL that the document interprets and maps to a data store. It's exactly similar to how a web service\n * works or a router inside of a single page app framework.\n */\nexport class InsecureUrlResolver implements IUrlResolver {\n private readonly cache = new Map<string, Promise<IResolvedUrl>>();\n\n constructor(\n private readonly hostUrl: string,\n private readonly ordererUrl: string,\n private readonly storageUrl: string,\n private readonly tenantId: string,\n private readonly bearer: string,\n private readonly isForNodeTest: boolean = false,\n ) { }\n\n public async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (request.headers?.[DriverHeader.createNew]) {\n const [, queryString] = request.url.split(\"?\");\n const searchParams = new URLSearchParams(queryString);\n const fileName = searchParams.get(\"fileName\");\n return this.resolveHelper(fileName);\n }\n const parsedUrl = new URL(request.url);\n // If hosts match then we use the local tenant information. Otherwise we make a REST call out to the hosting\n // service using our bearer token.\n if (this.isForNodeTest) {\n const [, documentId, tmpRelativePath] = parsedUrl.pathname.substr(1).split(\"/\");\n const relativePath = tmpRelativePath === undefined ? \"\" : tmpRelativePath;\n return this.resolveHelper(documentId, relativePath, parsedUrl.search);\n } else if (parsedUrl.host === window.location.host) {\n const fullPath = parsedUrl.pathname.substr(1);\n const documentId = fullPath.split(\"/\")[0];\n const documentRelativePath = fullPath.slice(documentId.length);\n return this.resolveHelper(documentId, documentRelativePath);\n } else {\n const maybeResolvedUrl = this.cache.get(request.url);\n if (maybeResolvedUrl) {\n return maybeResolvedUrl;\n }\n\n const headers = {\n Authorization: `Bearer ${this.bearer}`,\n };\n const resolvedP = Axios.post<IResolvedUrl>(\n `${this.hostUrl}/api/v1/load`,\n {\n url: request.url,\n },\n {\n headers,\n });\n this.cache.set(request.url, resolvedP.then((resolved) => resolved.data));\n\n return this.cache.get(request.url);\n }\n }\n\n private resolveHelper(documentId: string | null, documentRelativePath: string = \"\", queryParams: string = \"\") {\n const encodedTenantId = encodeURIComponent(this.tenantId);\n const host = new URL(this.ordererUrl).host;\n // when the document ID is not provided we need to resolve a special create new document URL.\n // the actual container ID will be generated by the driver.\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (!documentId) {\n const createNewResponse: IFluidResolvedUrl = {\n endpoints: {\n deltaStorageUrl: `${this.ordererUrl}/deltas/${encodedTenantId}/new`,\n ordererUrl: this.ordererUrl,\n storageUrl: `${this.storageUrl}/repos/${encodedTenantId}`,\n },\n // document ID is ignored by the driver for new container requests\n id: \"\",\n tokens: {},\n type: \"fluid\",\n url: `fluid://${host}/${encodedTenantId}/new`,\n };\n return createNewResponse;\n }\n const encodedDocId = encodeURIComponent(documentId);\n const relativePath = !documentRelativePath || documentRelativePath.startsWith(\"/\")\n ? documentRelativePath : `/${documentRelativePath}`;\n const documentUrl = `fluid://${host}/${encodedTenantId}/${encodedDocId}${relativePath}${queryParams}`;\n\n const deltaStorageUrl = `${this.ordererUrl}/deltas/${encodedTenantId}/${encodedDocId}`;\n const storageUrl = `${this.storageUrl}/repos/${encodedTenantId}`;\n\n const response: IFluidResolvedUrl = {\n endpoints: {\n deltaStorageUrl,\n ordererUrl: this.ordererUrl,\n storageUrl,\n },\n id: documentId,\n tokens: {},\n type: \"fluid\",\n url: documentUrl,\n };\n return response;\n }\n\n public async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n const fluidResolvedUrl = resolvedUrl as IFluidResolvedUrl;\n\n const parsedUrl = parse(fluidResolvedUrl.url);\n const [, , documentId] = parsedUrl.pathname?.split(\"/\") ?? [];\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n assert(!!documentId, 0x273 /* \"Invalid document id from parsed URL\" */);\n\n let url = relativeUrl;\n if (url.startsWith(\"/\")) {\n url = url.substr(1);\n }\n\n return `${this.hostUrl}/${encodeURIComponent(\n this.tenantId)}/${encodeURIComponent(documentId)}/${url}`;\n }\n\n public createCreateNewRequest(fileName?: string): IRequest {\n const createNewRequest: IRequest = {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n url: fileName ? `${this.hostUrl}?fileName=${fileName}` : this.hostUrl,\n headers: {\n [DriverHeader.createNew]: true,\n },\n };\n return createNewRequest;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"insecureUrlResolver.js","sourceRoot":"","sources":["../src/insecureUrlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,6BAA4B;AAC5B,+DAAsD;AAEtD,2EAK4C;AAC5C,kDAA0B;AAE1B;;;;;;;;;;;;;GAaG;AACH,MAAa,mBAAmB;IAG/B,YACkB,OAAe,EACf,UAAkB,EAClB,UAAkB,EAClB,QAAgB,EAChB,MAAc,EACd,gBAAyB,KAAK;QAL9B,YAAO,GAAP,OAAO,CAAQ;QACf,eAAU,GAAV,UAAU,CAAQ;QAClB,eAAU,GAAV,UAAU,CAAQ;QAClB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,kBAAa,GAAb,aAAa,CAAiB;QAR/B,UAAK,GAAG,IAAI,GAAG,EAAiC,CAAC;IAS/D,CAAC;IAEG,KAAK,CAAC,OAAO,CAAC,OAAiB;;QACrC,yEAAyE;QACzE,IAAI,MAAA,OAAO,CAAC,OAAO,0CAAG,iCAAY,CAAC,SAAS,CAAC,EAAE;YAC9C,MAAM,CAAC,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GA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pB;QAED,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,kBAAkB,CAChF,UAAU,CACV,IAAI,GAAG,EAAE,CAAC;IACZ,CAAC;IAEM,sBAAsB,CAAC,QAAiB;QAC9C,MAAM,gBAAgB,GAAa;YAClC,yEAAyE;YACzE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,aAAa,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;YACrE,OAAO,EAAE;gBACR,CAAC,iCAAY,CAAC,SAAS,CAAC,EAAE,IAAI;aAC9B;SACD,CAAC;QACF,OAAO,gBAAgB,CAAC;IACzB,CAAC;CACD;AAxID,kDAwIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidResolvedUrl,\n\tIResolvedUrl,\n\tIUrlResolver,\n\tDriverHeader,\n} from \"@fluidframework/driver-definitions\";\nimport Axios from \"axios\";\n\n/**\n * As the name implies this is not secure and should not be used in production. It simply makes the example easier\n * to get up and running.\n *\n * In our example we run a simple web server via webpack-dev-server. This defines a URL format of the form\n * http://localhost:8080/<documentId>/<path>.\n *\n * We then need to map that to a Fluid based URL. These are of the form\n * fluid://orderingUrl/<tenantId>/<documentId>/<path>.\n *\n * The tenantId/documentId pair defines the 'full' document ID the service makes use of. The path is then an optional\n * part of the URL that the document interprets and maps to a data store. It's exactly similar to how a web service\n * works or a router inside of a single page app framework.\n */\nexport class InsecureUrlResolver implements IUrlResolver {\n\tprivate readonly cache = new Map<string, Promise<IResolvedUrl>>();\n\n\tconstructor(\n\t\tprivate readonly hostUrl: string,\n\t\tprivate readonly ordererUrl: string,\n\t\tprivate readonly storageUrl: string,\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly bearer: string,\n\t\tprivate readonly isForNodeTest: boolean = false,\n\t) {}\n\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\tif (request.headers?.[DriverHeader.createNew]) {\n\t\t\tconst [, queryString] = request.url.split(\"?\");\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst fileName = searchParams.get(\"fileName\");\n\t\t\treturn this.resolveHelper(fileName);\n\t\t}\n\t\tconst parsedUrl = new URL(request.url);\n\t\t// If hosts match then we use the local tenant information. Otherwise we make a REST call out to the hosting\n\t\t// service using our bearer token.\n\t\tif (this.isForNodeTest) {\n\t\t\tconst [, documentId, tmpRelativePath] = parsedUrl.pathname.substr(1).split(\"/\");\n\t\t\tconst relativePath = tmpRelativePath === undefined ? \"\" : tmpRelativePath;\n\t\t\treturn this.resolveHelper(documentId, relativePath, parsedUrl.search);\n\t\t} else if (parsedUrl.host === window.location.host) {\n\t\t\tconst fullPath = parsedUrl.pathname.substr(1);\n\t\t\tconst documentId = fullPath.split(\"/\")[0];\n\t\t\tconst documentRelativePath = fullPath.slice(documentId.length);\n\t\t\treturn this.resolveHelper(documentId, documentRelativePath);\n\t\t} else {\n\t\t\tconst maybeResolvedUrl = this.cache.get(request.url);\n\t\t\tif (maybeResolvedUrl) {\n\t\t\t\treturn maybeResolvedUrl;\n\t\t\t}\n\n\t\t\tconst headers = {\n\t\t\t\tAuthorization: `Bearer ${this.bearer}`,\n\t\t\t};\n\t\t\tconst resolvedP = Axios.post<IResolvedUrl>(\n\t\t\t\t`${this.hostUrl}/api/v1/load`,\n\t\t\t\t{\n\t\t\t\t\turl: request.url,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\theaders,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.cache.set(\n\t\t\t\trequest.url,\n\t\t\t\tresolvedP.then((resolved) => resolved.data),\n\t\t\t);\n\n\t\t\treturn this.cache.get(request.url);\n\t\t}\n\t}\n\n\tprivate resolveHelper(\n\t\tdocumentId: string | null,\n\t\tdocumentRelativePath: string = \"\",\n\t\tqueryParams: string = \"\",\n\t) {\n\t\tconst encodedTenantId = encodeURIComponent(this.tenantId);\n\t\tconst host = new URL(this.ordererUrl).host;\n\t\t// when the document ID is not provided we need to resolve a special create new document URL.\n\t\t// the actual container ID will be generated by the driver.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\tif (!documentId) {\n\t\t\tconst createNewResponse: IFluidResolvedUrl = {\n\t\t\t\tendpoints: {\n\t\t\t\t\tdeltaStorageUrl: `${this.ordererUrl}/deltas/${encodedTenantId}/new`,\n\t\t\t\t\tordererUrl: this.ordererUrl,\n\t\t\t\t\tstorageUrl: `${this.storageUrl}/repos/${encodedTenantId}`,\n\t\t\t\t},\n\t\t\t\t// document ID is ignored by the driver for new container requests\n\t\t\t\tid: \"\",\n\t\t\t\ttokens: {},\n\t\t\t\ttype: \"fluid\",\n\t\t\t\turl: `fluid://${host}/${encodedTenantId}/new`,\n\t\t\t};\n\t\t\treturn createNewResponse;\n\t\t}\n\t\tconst encodedDocId = encodeURIComponent(documentId);\n\t\tconst relativePath =\n\t\t\t!documentRelativePath || documentRelativePath.startsWith(\"/\")\n\t\t\t\t? documentRelativePath\n\t\t\t\t: `/${documentRelativePath}`;\n\t\tconst documentUrl = `fluid://${host}/${encodedTenantId}/${encodedDocId}${relativePath}${queryParams}`;\n\n\t\tconst deltaStorageUrl = `${this.ordererUrl}/deltas/${encodedTenantId}/${encodedDocId}`;\n\t\tconst storageUrl = `${this.storageUrl}/repos/${encodedTenantId}`;\n\n\t\tconst response: IFluidResolvedUrl = {\n\t\t\tendpoints: {\n\t\t\t\tdeltaStorageUrl,\n\t\t\t\tordererUrl: this.ordererUrl,\n\t\t\t\tstorageUrl,\n\t\t\t},\n\t\t\tid: documentId,\n\t\t\ttokens: {},\n\t\t\ttype: \"fluid\",\n\t\t\turl: documentUrl,\n\t\t};\n\t\treturn response;\n\t}\n\n\tpublic async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n\t\tconst fluidResolvedUrl = resolvedUrl as IFluidResolvedUrl;\n\n\t\tconst parsedUrl = parse(fluidResolvedUrl.url);\n\t\tconst [, , documentId] = parsedUrl.pathname?.split(\"/\") ?? [];\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\tassert(!!documentId, 0x273 /* \"Invalid document id from parsed URL\" */);\n\n\t\tlet url = relativeUrl;\n\t\tif (url.startsWith(\"/\")) {\n\t\t\turl = url.substr(1);\n\t\t}\n\n\t\treturn `${this.hostUrl}/${encodeURIComponent(this.tenantId)}/${encodeURIComponent(\n\t\t\tdocumentId,\n\t\t)}/${url}`;\n\t}\n\n\tpublic createCreateNewRequest(fileName?: string): IRequest {\n\t\tconst createNewRequest: IRequest = {\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\turl: fileName ? `${this.hostUrl}?fileName=${fileName}` : this.hostUrl,\n\t\t\theaders: {\n\t\t\t\t[DriverHeader.createNew]: true,\n\t\t\t},\n\t\t};\n\t\treturn createNewRequest;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapWithExpiration.d.ts","sourceRoot":"","sources":["../src/mapWithExpiration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,qBAAa,iBAAiB,CAAC,IAAI,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG,CAAE,SAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"mapWithExpiration.d.ts","sourceRoot":"","sources":["../src/mapWithExpiration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,qBAAa,iBAAiB,CAAC,IAAI,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG,CAAE,SAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC;IAIrE,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAHrC,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA2B;gBAEjC,QAAQ,EAAE,MAAM;IAI7C,OAAO,CAAC,OAAO;IAIf;;;OAGG;IACH,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,mBAAmB;IAK3B,IAAI,IAAI,IAAI,MAAM,CAGjB;IAED,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO;IAKvB,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS;IAKlC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAMnC,MAAM,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO;IAK1B,KAAK,IAAI,IAAI;IAKb,OAAO,CACN,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,IAAI,EACtE,OAAO,CAAC,EAAE,GAAG,GACX,IAAI;IAmBP,OAAO,IAAI,gBAAgB,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAI3C,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC;IAI9B,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAIlC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAKrD,OAAO;CAIP"}
|
|
@@ -18,7 +18,7 @@ class MapWithExpiration extends Map {
|
|
|
18
18
|
this.lastRefreshedTimes = new Map();
|
|
19
19
|
}
|
|
20
20
|
refresh(key) {
|
|
21
|
-
this.lastRefreshedTimes.set(key,
|
|
21
|
+
this.lastRefreshedTimes.set(key, new Date().valueOf());
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Returns true if the key is present and expired, false if it's not expired, and undefined if it's not found
|
|
@@ -30,7 +30,7 @@ class MapWithExpiration extends Map {
|
|
|
30
30
|
if (refreshTime === undefined) {
|
|
31
31
|
return undefined;
|
|
32
32
|
}
|
|
33
|
-
const expired =
|
|
33
|
+
const expired = new Date().valueOf() - refreshTime >= this.expiryMs;
|
|
34
34
|
if (expired && cleanUp) {
|
|
35
35
|
this.delete(key);
|
|
36
36
|
}
|
|
@@ -76,7 +76,9 @@ class MapWithExpiration extends Map {
|
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
// Clean up keys we know are expired now that we're done iterating
|
|
79
|
-
expiredKeys.forEach((key) => {
|
|
79
|
+
expiredKeys.forEach((key) => {
|
|
80
|
+
this.delete(key);
|
|
81
|
+
});
|
|
80
82
|
}
|
|
81
83
|
entries() {
|
|
82
84
|
this.clearExpiredEntries();
|