@fluidframework/driver-utils 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191258
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 +28 -0
- package/README.md +4 -3
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.js +4 -1
- package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.js.map +1 -1
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +18 -18
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +34 -33
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
- package/dist/adapters/predefinedAdapters.d.ts +1 -1
- package/dist/adapters/predefinedAdapters.d.ts.map +1 -1
- package/dist/adapters/predefinedAdapters.js +4 -4
- package/dist/adapters/predefinedAdapters.js.map +1 -1
- package/dist/buildSnapshotTree.d.ts.map +1 -1
- package/dist/buildSnapshotTree.js +5 -4
- package/dist/buildSnapshotTree.js.map +1 -1
- package/dist/documentStorageServiceProxy.d.ts.map +1 -1
- package/dist/documentStorageServiceProxy.js +1 -3
- package/dist/documentStorageServiceProxy.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +2 -0
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/insecureUrlResolver.js +4 -6
- package/dist/insecureUrlResolver.js.map +1 -1
- package/dist/network.d.ts +1 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +11 -5
- package/dist/network.js.map +1 -1
- package/dist/networkUtils.js +3 -4
- 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 +2 -2
- package/dist/parallelRequests.d.ts.map +1 -1
- package/dist/parallelRequests.js +63 -45
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.js +1 -1
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/rateLimiter.js +2 -2
- package/dist/rateLimiter.js.map +1 -1
- package/dist/readAndParse.js +2 -2
- package/dist/readAndParse.js.map +1 -1
- package/dist/runWithRetry.d.ts +8 -0
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/runWithRetry.js +37 -13
- package/dist/runWithRetry.js.map +1 -1
- package/dist/summaryForCreateNew.d.ts +0 -9
- package/dist/summaryForCreateNew.d.ts.map +1 -1
- package/dist/summaryForCreateNew.js +4 -27
- package/dist/summaryForCreateNew.js.map +1 -1
- package/dist/treeConversions.d.ts.map +1 -1
- package/dist/treeConversions.js +4 -3
- package/dist/treeConversions.js.map +1 -1
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.js +4 -1
- package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.js.map +1 -1
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +18 -18
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +22 -21
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
- package/lib/adapters/predefinedAdapters.d.ts +1 -1
- package/lib/adapters/predefinedAdapters.d.ts.map +1 -1
- package/lib/adapters/predefinedAdapters.js +3 -3
- package/lib/adapters/predefinedAdapters.js.map +1 -1
- package/lib/buildSnapshotTree.d.ts.map +1 -1
- package/lib/buildSnapshotTree.js +4 -3
- package/lib/buildSnapshotTree.js.map +1 -1
- package/lib/documentStorageServiceProxy.d.ts.map +1 -1
- package/lib/documentStorageServiceProxy.js +1 -3
- package/lib/documentStorageServiceProxy.js.map +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js +2 -0
- package/lib/error.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/insecureUrlResolver.js +3 -5
- package/lib/insecureUrlResolver.js.map +1 -1
- package/lib/network.d.ts +1 -1
- package/lib/network.d.ts.map +1 -1
- package/lib/network.js +14 -6
- package/lib/network.js.map +1 -1
- package/lib/networkUtils.js +3 -4
- 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 +2 -2
- package/lib/parallelRequests.d.ts.map +1 -1
- package/lib/parallelRequests.js +33 -15
- package/lib/parallelRequests.js.map +1 -1
- package/lib/prefetchDocumentStorageService.js +1 -1
- package/lib/prefetchDocumentStorageService.js.map +1 -1
- package/lib/rateLimiter.js +1 -1
- package/lib/rateLimiter.js.map +1 -1
- package/lib/readAndParse.js +1 -1
- package/lib/readAndParse.js.map +1 -1
- package/lib/runWithRetry.d.ts +8 -0
- package/lib/runWithRetry.d.ts.map +1 -1
- package/lib/runWithRetry.js +30 -7
- package/lib/runWithRetry.js.map +1 -1
- package/lib/summaryForCreateNew.d.ts +0 -9
- package/lib/summaryForCreateNew.d.ts.map +1 -1
- package/lib/summaryForCreateNew.js +3 -25
- package/lib/summaryForCreateNew.js.map +1 -1
- package/lib/treeConversions.d.ts.map +1 -1
- package/lib/treeConversions.js +2 -1
- package/lib/treeConversions.js.map +1 -1
- package/package.json +21 -22
- package/src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts +20 -19
- package/src/adapters/predefinedAdapters.ts +5 -3
- package/src/buildSnapshotTree.ts +4 -3
- package/src/documentStorageServiceProxy.ts +0 -1
- package/src/error.ts +2 -0
- package/src/index.ts +1 -2
- package/src/insecureUrlResolver.ts +1 -1
- package/src/network.ts +9 -1
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +5 -4
- package/src/rateLimiter.ts +1 -1
- package/src/readAndParse.ts +1 -1
- package/src/runWithRetry.ts +32 -7
- package/src/summaryForCreateNew.ts +0 -31
- package/src/treeConversions.ts +2 -1
package/dist/runWithRetry.d.ts
CHANGED
|
@@ -34,4 +34,12 @@ export interface IProgress {
|
|
|
34
34
|
onRetry?(delayInMs: number, error: any): void;
|
|
35
35
|
}
|
|
36
36
|
export declare function runWithRetry<T>(api: (cancel?: AbortSignal) => Promise<T>, fetchCallName: string, logger: ITelemetryLoggerExt, progress: IProgress): Promise<T>;
|
|
37
|
+
/**
|
|
38
|
+
* In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error
|
|
39
|
+
* not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared
|
|
40
|
+
* to when endpoint is reachable in which case it is 30s.
|
|
41
|
+
* @param error - error based on which we decide max wait time.
|
|
42
|
+
* @returns Max wait time.
|
|
43
|
+
*/
|
|
44
|
+
export declare function calculateMaxWaitTime(error: unknown): number;
|
|
37
45
|
//# sourceMappingURL=runWithRetry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAgB,MAAM,iCAAiC,CAAC;AAQpF;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CAC9C;AAED,wBAAsB,YAAY,CAAC,CAAC,EACnC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACzC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,SAAS,GACjB,OAAO,CAAC,CAAC,CAAC,CAyFZ;AAKD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI3D"}
|
package/dist/runWithRetry.js
CHANGED
|
@@ -4,19 +4,20 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.runWithRetry = void 0;
|
|
8
|
-
const
|
|
7
|
+
exports.calculateMaxWaitTime = exports.runWithRetry = void 0;
|
|
8
|
+
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
9
|
+
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
10
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
9
11
|
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
10
12
|
const network_1 = require("./network");
|
|
11
13
|
const packageVersion_1 = require("./packageVersion");
|
|
12
14
|
const _1 = require(".");
|
|
13
15
|
async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
14
|
-
var _a, _b;
|
|
15
16
|
let result;
|
|
16
17
|
let success = false;
|
|
17
18
|
let retryAfterMs = 1000; // has to be positive!
|
|
18
19
|
let numRetries = 0;
|
|
19
|
-
const startTime =
|
|
20
|
+
const startTime = client_utils_1.performance.now();
|
|
20
21
|
let lastError;
|
|
21
22
|
do {
|
|
22
23
|
try {
|
|
@@ -29,19 +30,26 @@ async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
29
30
|
logger.sendTelemetryEvent({
|
|
30
31
|
eventName: `${fetchCallName}_cancel`,
|
|
31
32
|
retry: numRetries,
|
|
32
|
-
duration:
|
|
33
|
+
duration: client_utils_1.performance.now() - startTime,
|
|
33
34
|
fetchCallName,
|
|
34
35
|
}, err);
|
|
35
36
|
throw err;
|
|
36
37
|
}
|
|
37
|
-
if (
|
|
38
|
+
if (progress.cancel?.aborted === true) {
|
|
38
39
|
logger.sendTelemetryEvent({
|
|
39
40
|
eventName: `${fetchCallName}_runWithRetryAborted`,
|
|
40
41
|
retry: numRetries,
|
|
41
|
-
duration:
|
|
42
|
+
duration: client_utils_1.performance.now() - startTime,
|
|
42
43
|
fetchCallName,
|
|
44
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
45
|
+
reason: progress.cancel.reason,
|
|
43
46
|
}, err);
|
|
44
|
-
throw new _1.NonRetryableError("runWithRetry was Aborted", driver_definitions_1.
|
|
47
|
+
throw new _1.NonRetryableError("runWithRetry was Aborted", driver_definitions_1.DriverErrorTypes.genericError, {
|
|
48
|
+
driverVersion: packageVersion_1.pkgVersion,
|
|
49
|
+
fetchCallName,
|
|
50
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
51
|
+
reason: progress.cancel.reason,
|
|
52
|
+
});
|
|
45
53
|
}
|
|
46
54
|
// logging the first failed retry instead of every attempt. We want to avoid filling telemetry
|
|
47
55
|
// when we have tight loop of retrying in offline mode, but we also want to know what caused
|
|
@@ -49,26 +57,27 @@ async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
49
57
|
if (numRetries === 0) {
|
|
50
58
|
logger.sendTelemetryEvent({
|
|
51
59
|
eventName: `${fetchCallName}_firstFailed`,
|
|
52
|
-
duration:
|
|
60
|
+
duration: client_utils_1.performance.now() - startTime,
|
|
53
61
|
fetchCallName,
|
|
54
62
|
}, err);
|
|
55
63
|
}
|
|
56
64
|
numRetries++;
|
|
57
65
|
lastError = err;
|
|
58
66
|
// If the error is throttling error, then wait for the specified time before retrying.
|
|
59
|
-
|
|
60
|
-
|
|
67
|
+
retryAfterMs =
|
|
68
|
+
(0, network_1.getRetryDelayFromError)(err) ??
|
|
69
|
+
Math.min(retryAfterMs * 2, calculateMaxWaitTime(err));
|
|
61
70
|
if (progress.onRetry) {
|
|
62
71
|
progress.onRetry(retryAfterMs, err);
|
|
63
72
|
}
|
|
64
|
-
await (0,
|
|
73
|
+
await (0, core_utils_1.delay)(retryAfterMs);
|
|
65
74
|
}
|
|
66
75
|
} while (!success);
|
|
67
76
|
if (numRetries > 0) {
|
|
68
77
|
logger.sendTelemetryEvent({
|
|
69
78
|
eventName: `${fetchCallName}_lastError`,
|
|
70
79
|
retry: numRetries,
|
|
71
|
-
duration:
|
|
80
|
+
duration: client_utils_1.performance.now() - startTime,
|
|
72
81
|
fetchCallName,
|
|
73
82
|
}, lastError);
|
|
74
83
|
}
|
|
@@ -76,4 +85,19 @@ async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
76
85
|
return result;
|
|
77
86
|
}
|
|
78
87
|
exports.runWithRetry = runWithRetry;
|
|
88
|
+
const MaxReconnectDelayInMsWhenEndpointIsReachable = 30000;
|
|
89
|
+
const MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;
|
|
90
|
+
/**
|
|
91
|
+
* In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error
|
|
92
|
+
* not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared
|
|
93
|
+
* to when endpoint is reachable in which case it is 30s.
|
|
94
|
+
* @param error - error based on which we decide max wait time.
|
|
95
|
+
* @returns Max wait time.
|
|
96
|
+
*/
|
|
97
|
+
function calculateMaxWaitTime(error) {
|
|
98
|
+
return (0, telemetry_utils_1.isFluidError)(error) && error.getTelemetryProperties().endpointReached === true
|
|
99
|
+
? MaxReconnectDelayInMsWhenEndpointIsReachable
|
|
100
|
+
: MaxReconnectDelayInMsWhenEndpointIsNotReachable;
|
|
101
|
+
}
|
|
102
|
+
exports.calculateMaxWaitTime = calculateMaxWaitTime;
|
|
79
103
|
//# sourceMappingURL=runWithRetry.js.map
|
package/dist/runWithRetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAAoF;AACpF,+DAA2D;AAC3D,2DAAmD;AACnD,2EAAsE;AACtE,uCAAoE;AACpE,qDAA8C;AAC9C,wBAAsC;AAkC/B,KAAK,UAAU,YAAY,CACjC,GAAyC,EACzC,aAAqB,EACrB,MAA2B,EAC3B,QAAmB;IAEnB,IAAI,MAAqB,CAAC;IAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,YAAY,GAAG,IAAI,CAAC,CAAC,sBAAsB;IAC/C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,SAAS,GAAG,0BAAW,CAAC,GAAG,EAAE,CAAC;IACpC,IAAI,SAAc,CAAC;IACnB,GAAG;QACF,IAAI;YACH,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO,GAAG,IAAI,CAAC;SACf;QAAC,OAAO,GAAG,EAAE;YACb,qDAAqD;YACrD,IAAI,CAAC,IAAA,yBAAe,EAAC,GAAG,CAAC,EAAE;gBAC1B,MAAM,CAAC,kBAAkB,CACxB;oBACC,SAAS,EAAE,GAAG,aAAa,SAAS;oBACpC,KAAK,EAAE,UAAU;oBACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;oBACvC,aAAa;iBACb,EACD,GAAG,CACH,CAAC;gBACF,MAAM,GAAG,CAAC;aACV;YAED,IAAI,QAAQ,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,EAAE;gBACtC,MAAM,CAAC,k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YACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;YACvC,aAAa;SACb,EACD,SAAS,CACT,CAAC;KACF;IACD,oEAAoE;IACpE,OAAO,MAAO,CAAC;AAChB,CAAC;AA9FD,oCA8FC;AAED,MAAM,4CAA4C,GAAG,KAAK,CAAC;AAC3D,MAAM,+CAA+C,GAAG,IAAI,CAAC;AAE7D;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IAClD,OAAO,IAAA,8BAAY,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,sBAAsB,EAAE,CAAC,eAAe,KAAK,IAAI;QACpF,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,+CAA+C,CAAC;AACpD,CAAC;AAJD,oDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, isFluidError } from \"@fluidframework/telemetry-utils\";\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { delay } from \"@fluidframework/core-utils\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\nimport { canRetryOnError, getRetryDelayFromError } from \"./network\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { NonRetryableError } from \".\";\n\n/**\n * Interface describing an object passed to various network APIs.\n * It allows caller to control cancellation, as well as learn about any delays.\n */\nexport interface IProgress {\n\t/**\n\t * Abort signal used to cancel operation.\n\t *\n\t * @remarks Note that most of the layers do not use this signal yet. We need to change that over time.\n\t * Please consult with API documentation / implementation.\n\t * Note that number of layers may not check this signal while holding this request in a queue,\n\t * so it may take a while it takes effect. This can be improved in the future.\n\t *\n\t * The layers in question are:\n\t *\n\t * - driver (RateLimiter)\n\t *\n\t * - runWithRetry\n\t */\n\tcancel?: AbortSignal;\n\n\t/**\n\t * Called whenever api returns cancellable error and the call is going to be retried.\n\t * Any exception thrown from this call back result in cancellation of operation\n\t * and propagation of thrown exception.\n\t * @param delayInMs - delay before next retry. This value will depend on internal back-off logic,\n\t * as well as information provided by service (like 429 error asking to wait for some time before retry)\n\t * @param error - error object returned from the call.\n\t */\n\tonRetry?(delayInMs: number, error: any): void;\n}\n\nexport async function runWithRetry<T>(\n\tapi: (cancel?: AbortSignal) => Promise<T>,\n\tfetchCallName: string,\n\tlogger: ITelemetryLoggerExt,\n\tprogress: IProgress,\n): Promise<T> {\n\tlet result: T | undefined;\n\tlet success = false;\n\tlet retryAfterMs = 1000; // has to be positive!\n\tlet numRetries = 0;\n\tconst startTime = performance.now();\n\tlet lastError: any;\n\tdo {\n\t\ttry {\n\t\t\tresult = await api(progress.cancel);\n\t\t\tsuccess = true;\n\t\t} catch (err) {\n\t\t\t// If it is not retriable, then just throw the error.\n\t\t\tif (!canRetryOnError(err)) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_cancel`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow err;\n\t\t\t}\n\n\t\t\tif (progress.cancel?.aborted === true) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_runWithRetryAborted`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\t// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)\n\t\t\t\t\t\treason: (progress.cancel as AbortSignal & { reason: any }).reason,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"runWithRetry was Aborted\",\n\t\t\t\t\tDriverErrorTypes.genericError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\t// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)\n\t\t\t\t\t\treason: (progress.cancel as AbortSignal & { reason: any }).reason,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// logging the first failed retry instead of every attempt. We want to avoid filling telemetry\n\t\t\t// when we have tight loop of retrying in offline mode, but we also want to know what caused\n\t\t\t// the failure in the first place\n\t\t\tif (numRetries === 0) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_firstFailed`,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tnumRetries++;\n\t\t\tlastError = err;\n\t\t\t// If the error is throttling error, then wait for the specified time before retrying.\n\t\t\tretryAfterMs =\n\t\t\t\tgetRetryDelayFromError(err) ??\n\t\t\t\tMath.min(retryAfterMs * 2, calculateMaxWaitTime(err));\n\t\t\tif (progress.onRetry) {\n\t\t\t\tprogress.onRetry(retryAfterMs, err);\n\t\t\t}\n\t\t\tawait delay(retryAfterMs);\n\t\t}\n\t} while (!success);\n\tif (numRetries > 0) {\n\t\tlogger.sendTelemetryEvent(\n\t\t\t{\n\t\t\t\teventName: `${fetchCallName}_lastError`,\n\t\t\t\tretry: numRetries,\n\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\tfetchCallName,\n\t\t\t},\n\t\t\tlastError,\n\t\t);\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\treturn result!;\n}\n\nconst MaxReconnectDelayInMsWhenEndpointIsReachable = 30000;\nconst MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;\n\n/**\n * In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error\n * not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared\n * to when endpoint is reachable in which case it is 30s.\n * @param error - error based on which we decide max wait time.\n * @returns Max wait time.\n */\nexport function calculateMaxWaitTime(error: unknown): number {\n\treturn isFluidError(error) && error.getTelemetryProperties().endpointReached === true\n\t\t? MaxReconnectDelayInMsWhenEndpointIsReachable\n\t\t: MaxReconnectDelayInMsWhenEndpointIsNotReachable;\n}\n"]}
|
|
@@ -20,15 +20,6 @@ export interface CombinedAppAndProtocolSummary extends ISummaryTree {
|
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
22
|
export declare function isCombinedAppAndProtocolSummary(summary: ISummaryTree | undefined): summary is CombinedAppAndProtocolSummary;
|
|
23
|
-
/**
|
|
24
|
-
* Combine the app summary and protocol summary in 1 tree.
|
|
25
|
-
* @param appSummary - Summary of the app.
|
|
26
|
-
* @param protocolSummary - Summary of the protocol.
|
|
27
|
-
* @internal
|
|
28
|
-
*
|
|
29
|
-
* @deprecated 2.0.0-internal.3.4.0 - Not intended for public use. Will be moved to container-loader and no longer exported in an upcoming release.
|
|
30
|
-
*/
|
|
31
|
-
export declare function combineAppAndProtocolSummary(appSummary: ISummaryTree, protocolSummary: ISummaryTree): CombinedAppAndProtocolSummary;
|
|
32
23
|
/**
|
|
33
24
|
* Extract the attributes from the protocol summary.
|
|
34
25
|
* @param protocolSummary - protocol summary from which the values are to be extracted.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryForCreateNew.d.ts","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"summaryForCreateNew.d.ts","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,YAAY,EAGZ,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,sCAAsC,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,6BAA8B,SAAQ,YAAY;IAClE,IAAI,EAAE;QACL,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;QACvB,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC;KAC5B,CAAC;CACF;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC9C,OAAO,EAAE,YAAY,GAAG,SAAS,GAC/B,OAAO,IAAI,6BAA6B,CAa1C;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAClD,eAAe,EAAE,YAAY,GAC3B,mBAAmB,CAGrB;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CACjD,eAAe,EAAE,YAAY,GAC3B,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAOhC"}
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.getQuorumValuesFromProtocolSummary = exports.getDocAttributesFromProtocolSummary = exports.
|
|
8
|
-
const common_utils_1 = require("@fluidframework/common-utils");
|
|
7
|
+
exports.getQuorumValuesFromProtocolSummary = exports.getDocAttributesFromProtocolSummary = exports.isCombinedAppAndProtocolSummary = void 0;
|
|
9
8
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
10
9
|
/**
|
|
11
10
|
* Validates the current layout of an .app + .protocol summary tree
|
|
@@ -13,10 +12,9 @@ const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
|
13
12
|
* @internal
|
|
14
13
|
*/
|
|
15
14
|
function isCombinedAppAndProtocolSummary(summary) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
((_d = (_c = summary.tree) === null || _c === void 0 ? void 0 : _c[".protocol"]) === null || _d === void 0 ? void 0 : _d.type) !== protocol_definitions_1.SummaryType.Tree) {
|
|
15
|
+
if (summary?.tree === undefined ||
|
|
16
|
+
summary.tree?.[".app"]?.type !== protocol_definitions_1.SummaryType.Tree ||
|
|
17
|
+
summary.tree?.[".protocol"]?.type !== protocol_definitions_1.SummaryType.Tree) {
|
|
20
18
|
return false;
|
|
21
19
|
}
|
|
22
20
|
const treeKeys = Object.keys(summary.tree);
|
|
@@ -26,27 +24,6 @@ function isCombinedAppAndProtocolSummary(summary) {
|
|
|
26
24
|
return true;
|
|
27
25
|
}
|
|
28
26
|
exports.isCombinedAppAndProtocolSummary = isCombinedAppAndProtocolSummary;
|
|
29
|
-
/**
|
|
30
|
-
* Combine the app summary and protocol summary in 1 tree.
|
|
31
|
-
* @param appSummary - Summary of the app.
|
|
32
|
-
* @param protocolSummary - Summary of the protocol.
|
|
33
|
-
* @internal
|
|
34
|
-
*
|
|
35
|
-
* @deprecated 2.0.0-internal.3.4.0 - Not intended for public use. Will be moved to container-loader and no longer exported in an upcoming release.
|
|
36
|
-
*/
|
|
37
|
-
function combineAppAndProtocolSummary(appSummary, protocolSummary) {
|
|
38
|
-
(0, common_utils_1.assert)(!isCombinedAppAndProtocolSummary(appSummary), 0x5a8 /* app summary is already a combined tree! */);
|
|
39
|
-
(0, common_utils_1.assert)(!isCombinedAppAndProtocolSummary(protocolSummary), 0x5a9 /* protocol summary is already a combined tree! */);
|
|
40
|
-
const createNewSummary = {
|
|
41
|
-
type: protocol_definitions_1.SummaryType.Tree,
|
|
42
|
-
tree: {
|
|
43
|
-
".protocol": protocolSummary,
|
|
44
|
-
".app": appSummary,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
return createNewSummary;
|
|
48
|
-
}
|
|
49
|
-
exports.combineAppAndProtocolSummary = combineAppAndProtocolSummary;
|
|
50
27
|
/**
|
|
51
28
|
* Extract the attributes from the protocol summary.
|
|
52
29
|
* @param protocolSummary - protocol summary from which the values are to be extracted.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryForCreateNew.js","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+
|
|
1
|
+
{"version":3,"file":"summaryForCreateNew.js","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+EAM8C;AAc9C;;;;GAIG;AACH,SAAgB,+BAA+B,CAC9C,OAAiC;IAEjC,IACC,OAAO,EAAE,IAAI,KAAK,SAAS;QAC3B,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,KAAK,kCAAW,CAAC,IAAI;QACjD,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,KAAK,kCAAW,CAAC,IAAI,EACrD;QACD,OAAO,KAAK,CAAC;KACb;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,OAAO,KAAK,CAAC;KACb;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAfD,0EAeC;AAED;;;GAGG;AACH,SAAgB,mCAAmC,CAClD,eAA6B;IAE7B,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,UAA0B,CAAC;IACvE,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAiB,CAAwB,CAAC;AAC5E,CAAC;AALD,kFAKC;AAED;;;GAGG;AACH,SAAgB,kCAAkC,CACjD,eAA6B;IAE7B,MAAM,gBAAgB,GAAG,eAAe,CAAC,IAAI,CAAC,YAA4B,CAAC;IAC3E,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAiB,CAG/D,CAAC;IACJ,OAAO,YAAY,CAAC;AACrB,CAAC;AATD,gFASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tISummaryTree,\n\tSummaryType,\n\tISummaryBlob,\n\tICommittedProposal,\n\tIDocumentAttributes,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Defines the current layout of an .app + .protocol summary tree\n * this is used internally for create new, and single commit summary\n * @internal\n */\nexport interface CombinedAppAndProtocolSummary extends ISummaryTree {\n\ttree: {\n\t\t[\".app\"]: ISummaryTree;\n\t\t[\".protocol\"]: ISummaryTree;\n\t};\n}\n\n/**\n * Validates the current layout of an .app + .protocol summary tree\n * this is used internally for create new, and single commit summary\n * @internal\n */\nexport function isCombinedAppAndProtocolSummary(\n\tsummary: ISummaryTree | undefined,\n): summary is CombinedAppAndProtocolSummary {\n\tif (\n\t\tsummary?.tree === undefined ||\n\t\tsummary.tree?.[\".app\"]?.type !== SummaryType.Tree ||\n\t\tsummary.tree?.[\".protocol\"]?.type !== SummaryType.Tree\n\t) {\n\t\treturn false;\n\t}\n\tconst treeKeys = Object.keys(summary.tree);\n\tif (treeKeys.length !== 2) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Extract the attributes from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getDocAttributesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): IDocumentAttributes {\n\tconst attributesBlob = protocolSummary.tree.attributes as ISummaryBlob;\n\treturn JSON.parse(attributesBlob.content as string) as IDocumentAttributes;\n}\n\n/**\n * Extract quorum values from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getQuorumValuesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): [string, ICommittedProposal][] {\n\tconst quorumValuesBlob = protocolSummary.tree.quorumValues as ISummaryBlob;\n\tconst quorumValues = JSON.parse(quorumValuesBlob.content as string) as [\n\t\tstring,\n\t\tICommittedProposal,\n\t][];\n\treturn quorumValues;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeConversions.d.ts","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"treeConversions.d.ts","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,KAAK,EAA2B,MAAM,sCAAsC,CAAC;AAIpG;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAgDlF"}
|
package/dist/treeConversions.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.convertSummaryTreeToSnapshotITree = void 0;
|
|
8
|
-
const
|
|
8
|
+
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
9
10
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
10
11
|
const blob_1 = require("./blob");
|
|
11
12
|
const summaryForCreateNew_1 = require("./summaryForCreateNew");
|
|
@@ -32,7 +33,7 @@ function convertSummaryTreeToSnapshotITree(summaryTree) {
|
|
|
32
33
|
parsedContent = value.content;
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
|
-
parsedContent = (0,
|
|
36
|
+
parsedContent = (0, client_utils_1.Uint8ArrayToString)(value.content, "base64");
|
|
36
37
|
encoding = "base64";
|
|
37
38
|
}
|
|
38
39
|
entries.push(new blob_1.BlobTreeEntry(k, parsedContent, encoding));
|
|
@@ -50,7 +51,7 @@ function convertSummaryTreeToSnapshotITree(summaryTree) {
|
|
|
50
51
|
throw new Error("Should not have Handle type in summary tree");
|
|
51
52
|
}
|
|
52
53
|
default:
|
|
53
|
-
(0,
|
|
54
|
+
(0, core_utils_1.unreachableCase)(value, "Unexpected summary tree type");
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+
|
|
1
|
+
{"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],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AC;gBAC5D,MAAM;aACN;YAED,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,IAAI,oBAAa,CAAC,CAAC,EAAE,iCAAiC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC7E,MAAM;aACN;YAED,KAAK,kCAAW,CAAC,UAAU,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,0BAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBACnD,MAAM;aACN;YAED,KAAK,kCAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAC/D;YAED;gBACC,IAAA,4BAAe,EAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;SACxD;KACD;IACD,OAAO;QACN,OAAO;QACP,YAAY,EAAE,WAAW,CAAC,YAAY;KACtC,CAAC;AACH,CAAC;AAhDD,8EAgDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString } from \"@fluid-internal/client-utils\";\nimport { unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISummaryTree, ITree, ITreeEntry, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"./blob\";\nimport { isCombinedAppAndProtocolSummary } from \"./summaryForCreateNew\";\n\n/**\n * Converts ISummaryTree to ITree format.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tconst adaptSummaryTree = isCombinedAppAndProtocolSummary(summaryTree);\n\tconst allSummaryEntries = adaptSummaryTree\n\t\t? [\n\t\t\t\t...Object.entries(summaryTree.tree[\".protocol\"].tree),\n\t\t\t\t...Object.entries(summaryTree.tree[\".app\"].tree),\n\t\t ]\n\t\t: Object.entries(summaryTree.tree);\n\n\tfor (const [key, value] of allSummaryEntries) {\n\t\tconst k = adaptSummaryTree && key === \"attributes\" ? \".attributes\" : key;\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(k, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(k, convertSummaryTreeToSnapshotITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(k, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t};\n}\n"]}
|
|
@@ -17,7 +17,10 @@ export class DocumentServiceFactoryCompressionAdapter extends DocumentServiceFac
|
|
|
17
17
|
// of the hack at packages/drivers/routerlicious-driver/src/createNewUtils.ts
|
|
18
18
|
// where the binary blob is converted to a string using UTF-8 encoding
|
|
19
19
|
// which is producing incorrect results for compressed data.
|
|
20
|
-
const configForInitial =
|
|
20
|
+
const configForInitial = {
|
|
21
|
+
...this._config,
|
|
22
|
+
minSizeToCompress: Number.POSITIVE_INFINITY,
|
|
23
|
+
};
|
|
21
24
|
const newAppSumary = DocumentStorageServiceSummaryBlobCompressionAdapter.compressSummary(createNewSummary.tree[".app"], configForInitial);
|
|
22
25
|
createNewSummary.tree[".app"] = newAppSumary;
|
|
23
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentServiceFactoryCompressionAdapter.js","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceFactoryCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,OAAO,EAAE,wCAAwC,IAAI,mDAAmD,EAAE,MAAM,eAAe,CAAC;AAChI,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,MAAM,OAAO,wCAAyC,SAAQ,2BAA2B;IACxF,YACC,cAAuC,EACtB,OAAkC;QAEnD,KAAK,CAAC,cAAc,CAAC,CAAC;QAFL,YAAO,GAAP,OAAO,CAA2B;IAGpD,CAAC;IAEM,KAAK,CAAC,eAAe,CAC3B,gBAA0C,EAC1C,oBAAkC,EAClC,MAA6B,EAC7B,kBAA4B;QAE5B,IAAI,gBAAgB,KAAK,SAAS,EAAE;YACnC,gFAAgF;YAChF,oEAAoE;YACpE,6EAA6E;YAC7E,sEAAsE;YACtE,4DAA4D;YAC5D,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"documentServiceFactoryCompressionAdapter.js","sourceRoot":"","sources":["../../../src/adapters/compression/documentServiceFactoryCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,OAAO,EAAE,wCAAwC,IAAI,mDAAmD,EAAE,MAAM,eAAe,CAAC;AAChI,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,MAAM,OAAO,wCAAyC,SAAQ,2BAA2B;IACxF,YACC,cAAuC,EACtB,OAAkC;QAEnD,KAAK,CAAC,cAAc,CAAC,CAAC;QAFL,YAAO,GAAP,OAAO,CAA2B;IAGpD,CAAC;IAEM,KAAK,CAAC,eAAe,CAC3B,gBAA0C,EAC1C,oBAAkC,EAClC,MAA6B,EAC7B,kBAA4B;QAE5B,IAAI,gBAAgB,KAAK,SAAS,EAAE;YACnC,gFAAgF;YAChF,oEAAoE;YACpE,6EAA6E;YAC7E,sEAAsE;YACtE,4DAA4D;YAC5D,MAAM,gBAAgB,GAAG;gBACxB,GAAG,IAAI,CAAC,OAAO;gBACf,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;aAC3C,CAAC;YACF,MAAM,YAAY,GACjB,mDAAmD,CAAC,eAAe,CAClE,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAiB,EAC7C,gBAAgB,CAChB,CAAC;YACH,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC;SAC7C;QACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CACxD,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,EACN,kBAAkB,CAClB,CAAC;QACF,OAAO,IAAI,iCAAiC,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAAC,WAAyB;QAC3D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;QAC7E,OAAO,IAAI,iCAAiC,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { DocumentServiceFactoryProxy } from \"../../documentServiceFactoryProxy\";\nimport { ICompressionStorageConfig } from \"..\";\nimport { DocumentStorageServiceCompressionAdapter as DocumentStorageServiceSummaryBlobCompressionAdapter } from \"./summaryblob\";\nimport { DocumentServiceCompressionAdapter } from \"./documentServiceCompressionAdapter\";\n\nexport class DocumentServiceFactoryCompressionAdapter extends DocumentServiceFactoryProxy {\n\tconstructor(\n\t\tserviceFactory: IDocumentServiceFactory,\n\t\tprivate readonly _config: ICompressionStorageConfig,\n\t) {\n\t\tsuper(serviceFactory);\n\t}\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tcreateNewResolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (createNewSummary !== undefined) {\n\t\t\t// TODO : this is a hack to make sure that the initial summary is not compressed\n\t\t\t// We must prevent the initial summary from being compressed because\n\t\t\t// of the hack at packages/drivers/routerlicious-driver/src/createNewUtils.ts\n\t\t\t// where the binary blob is converted to a string using UTF-8 encoding\n\t\t\t// which is producing incorrect results for compressed data.\n\t\t\tconst configForInitial = {\n\t\t\t\t...this._config,\n\t\t\t\tminSizeToCompress: Number.POSITIVE_INFINITY,\n\t\t\t};\n\t\t\tconst newAppSumary =\n\t\t\t\tDocumentStorageServiceSummaryBlobCompressionAdapter.compressSummary(\n\t\t\t\t\tcreateNewSummary.tree[\".app\"] as ISummaryTree,\n\t\t\t\t\tconfigForInitial,\n\t\t\t\t);\n\t\t\tcreateNewSummary.tree[\".app\"] = newAppSumary;\n\t\t}\n\t\tconst service = await this.serviceFactory.createContainer(\n\t\t\tcreateNewSummary,\n\t\t\tcreateNewResolvedUrl,\n\t\t\tlogger,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t\treturn new DocumentServiceCompressionAdapter(service, this._config);\n\t}\n\n\tpublic async createDocumentService(resolvedUrl: IResolvedUrl): Promise<IDocumentService> {\n\t\tconst service = await this.serviceFactory.createDocumentService(resolvedUrl);\n\t\treturn new DocumentServiceCompressionAdapter(service, this._config);\n\t}\n}\n"]}
|
|
@@ -24,9 +24,9 @@ export declare class DocumentStorageServiceCompressionAdapter extends DocumentSt
|
|
|
24
24
|
constructor(service: IDocumentStorageService, _config: ICompressionStorageConfig);
|
|
25
25
|
get service(): IDocumentStorageService;
|
|
26
26
|
/**
|
|
27
|
-
* This method returns true if there is a compression markup byte in the blob, otherwise false
|
|
27
|
+
* This method returns `true` if there is a compression markup byte in the blob, otherwise `false`.
|
|
28
28
|
* @param blob - The blob to compress.
|
|
29
|
-
* @returns
|
|
29
|
+
* @returns `true` if there is a compression markup byte in the blob, otherwise `false`.
|
|
30
30
|
*/
|
|
31
31
|
private static hasPrefix;
|
|
32
32
|
/**
|
|
@@ -38,13 +38,13 @@ export declare class DocumentStorageServiceCompressionAdapter extends DocumentSt
|
|
|
38
38
|
* This method writes the given algorithm to the blob as the first byte.
|
|
39
39
|
* @param blob - The blob to write the algorithm to.
|
|
40
40
|
* @param algorithm - The algorithm to write.
|
|
41
|
-
* @returns
|
|
41
|
+
* @returns The blob with the algorithm as the first byte.
|
|
42
42
|
*/
|
|
43
43
|
private static writeAlgorithmToBlob;
|
|
44
44
|
/**
|
|
45
45
|
* This method removes the algorithm markup prefix from the blob (1 byte)
|
|
46
46
|
* @param blob - The blob to remove the prefix from.
|
|
47
|
-
* @returns
|
|
47
|
+
* @returns The blob without the prefix.
|
|
48
48
|
*/
|
|
49
49
|
private static removePrefixFromBlobIfPresent;
|
|
50
50
|
/**
|
|
@@ -52,7 +52,7 @@ export declare class DocumentStorageServiceCompressionAdapter extends DocumentSt
|
|
|
52
52
|
* it is just returned as is. If the parameter is string, it is converted to Uint8Array using
|
|
53
53
|
* TextEncoder.
|
|
54
54
|
* @param input - The input to convert to Uint8Array.
|
|
55
|
-
* @returns
|
|
55
|
+
* @returns The Uint8Array representation of the input.
|
|
56
56
|
*/
|
|
57
57
|
private static toBinaryArray;
|
|
58
58
|
/**
|
|
@@ -60,26 +60,26 @@ export declare class DocumentStorageServiceCompressionAdapter extends DocumentSt
|
|
|
60
60
|
* containing the compression algorithm.
|
|
61
61
|
* @param input - The summary object to encode.
|
|
62
62
|
* @param config - The config containing the compression algorithm.
|
|
63
|
-
* @returns
|
|
63
|
+
* @returns The summary object with the encoded blob.
|
|
64
64
|
*/
|
|
65
65
|
private static readonly blobEncoder;
|
|
66
66
|
/**
|
|
67
67
|
* This method decodes the blob inside the given summary object of the SummaryType.Blob type.
|
|
68
68
|
* @param input - The summary object to decode.
|
|
69
|
-
* @returns
|
|
69
|
+
* @returns The summary object with the decoded blob.
|
|
70
70
|
*/
|
|
71
71
|
private static readonly blobDecoder;
|
|
72
72
|
/**
|
|
73
73
|
* This method encodes the given blob according to the given config.
|
|
74
74
|
* @param file - The blob to encode.
|
|
75
75
|
* @param config - The config to use for encoding.
|
|
76
|
-
* @returns
|
|
76
|
+
* @returns The encoded blob.
|
|
77
77
|
*/
|
|
78
78
|
private static encodeBlob;
|
|
79
79
|
/**
|
|
80
80
|
* This method decodes the given blob.
|
|
81
81
|
* @param file - The blob to decode.
|
|
82
|
-
* @returns
|
|
82
|
+
* @returns The decoded blob.
|
|
83
83
|
*/
|
|
84
84
|
private static decodeBlob;
|
|
85
85
|
/**
|
|
@@ -91,7 +91,7 @@ export declare class DocumentStorageServiceCompressionAdapter extends DocumentSt
|
|
|
91
91
|
* @param decoder - The decoder function to use.
|
|
92
92
|
* @param config - The config to use for encoding.
|
|
93
93
|
* @param context - The summary context.
|
|
94
|
-
* @returns
|
|
94
|
+
* @returns The summary object with the encoded/decoded blob.
|
|
95
95
|
*/
|
|
96
96
|
private static recursivelyReplace;
|
|
97
97
|
/**
|
|
@@ -99,14 +99,14 @@ export declare class DocumentStorageServiceCompressionAdapter extends DocumentSt
|
|
|
99
99
|
* it returns the summary tree containing that blob.
|
|
100
100
|
*
|
|
101
101
|
* @param summary - The summary tree to traverse.
|
|
102
|
-
* @returns
|
|
102
|
+
* @returns The summary tree containing the metadata blob.
|
|
103
103
|
*/
|
|
104
104
|
private static findMetadataHolderSummary;
|
|
105
105
|
/**
|
|
106
106
|
* This method obtains the summary tree containing the metadata blob. It returns the content
|
|
107
107
|
* of the tree atribute.
|
|
108
108
|
* @param summary - The summary tree to traverse.
|
|
109
|
-
* @returns
|
|
109
|
+
* @returns The content of the tree attribute of the summary tree containing the metadata blob.
|
|
110
110
|
*/
|
|
111
111
|
private static getMetadataHolderTree;
|
|
112
112
|
/**
|
|
@@ -119,20 +119,20 @@ export declare class DocumentStorageServiceCompressionAdapter extends DocumentSt
|
|
|
119
119
|
* it checks, if the SummaryTree holder of that object also contains the compression markup blob. If it is found,
|
|
120
120
|
* it returns true, otherwise false.
|
|
121
121
|
* @param snapshot - The snapshot tree to traverse.
|
|
122
|
-
* @returns
|
|
122
|
+
* @returns True if the compression markup blob is found, otherwise false.
|
|
123
123
|
*/
|
|
124
124
|
private static hasCompressionMarkup;
|
|
125
125
|
/**
|
|
126
126
|
* This method performs compression of the blobs in the summary tree.
|
|
127
127
|
* @param summary - The summary tree to compress.
|
|
128
128
|
* @param config - The compression config.
|
|
129
|
-
* @returns
|
|
129
|
+
* @returns The compressed summary tree.
|
|
130
130
|
*/
|
|
131
131
|
static compressSummary(summary: ISummaryTree, config: ICompressionStorageConfig): ISummaryTree;
|
|
132
132
|
/**
|
|
133
133
|
* This method read blob from the storage and decompresses it if it is compressed.
|
|
134
134
|
* @param id - The id of the blob to read.
|
|
135
|
-
* @returns
|
|
135
|
+
* @returns The decompressed blob.
|
|
136
136
|
*/
|
|
137
137
|
readBlob(id: string): Promise<ArrayBufferLike>;
|
|
138
138
|
/**
|
|
@@ -141,20 +141,20 @@ export declare class DocumentStorageServiceCompressionAdapter extends DocumentSt
|
|
|
141
141
|
* algorithm byte prefix and store them.
|
|
142
142
|
* @param version - The version of the snapshot tree to load.
|
|
143
143
|
* @param scenarioName - The scenario name of the snapshot tree to load.
|
|
144
|
-
* @returns
|
|
144
|
+
* @returns The snapshot tree.
|
|
145
145
|
*/
|
|
146
146
|
getSnapshotTree(version?: IVersion | undefined, scenarioName?: string | undefined): Promise<ISnapshotTree | null>;
|
|
147
147
|
/**
|
|
148
148
|
* This method uploads the summary to the storage. It performs compression of the blobs in the summary tree.
|
|
149
149
|
* @param summary - The summary tree to upload.
|
|
150
150
|
* @param context - The summary context.
|
|
151
|
-
* @returns
|
|
151
|
+
* @returns The ID of the uploaded summary.
|
|
152
152
|
*/
|
|
153
153
|
uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
154
154
|
/**
|
|
155
155
|
* This method downloads the summary from the storage and then applies decompression on the compressed blobs.
|
|
156
156
|
* @param id - The ID of the summary to be downloaded
|
|
157
|
-
* @returns
|
|
157
|
+
* @returns The summary with decompressed blobs
|
|
158
158
|
*/
|
|
159
159
|
downloadSummary(id: ISummaryHandle): Promise<ISummaryTree>;
|
|
160
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentStorageServiceSummaryBlobCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../../src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"documentStorageServiceSummaryBlobCompressionAdapter.d.ts","sourceRoot":"","sources":["../../../../src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EACN,aAAa,EAEb,cAAc,EACd,YAAY,EACZ,QAAQ,EAGR,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAA+B,MAAM,KAAK,CAAC;AAE7E,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AA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