@fluidframework/container-loader 2.0.0-internal.7.0.0 → 2.0.0-internal.7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/api-extractor.json +9 -1
- package/api-report/container-loader.api.md +153 -0
- package/dist/connectionManager.d.ts +2 -1
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +29 -20
- package/dist/connectionManager.js.map +1 -1
- package/dist/container.d.ts +6 -5
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +21 -19
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +2 -2
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +1 -1
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +3 -3
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +4 -4
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.d.ts.map +1 -1
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +1 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +8 -9
- package/dist/deltaManager.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +4 -4
- package/dist/loader.js +7 -7
- package/dist/loader.js.map +1 -1
- package/dist/location-redirection-utilities/index.d.ts +6 -0
- package/dist/location-redirection-utilities/index.d.ts.map +1 -0
- package/dist/location-redirection-utilities/index.js +11 -0
- package/dist/location-redirection-utilities/index.js.map +1 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +22 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js +51 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +3 -2
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +18 -11
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/utils.d.ts +23 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +11 -3
- package/dist/utils.js.map +1 -1
- package/lib/connectionManager.d.ts +2 -1
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +29 -20
- package/lib/connectionManager.js.map +1 -1
- package/lib/container.d.ts +6 -5
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +21 -19
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +2 -2
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +3 -3
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +4 -4
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/debugLogger.d.ts.map +1 -1
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaManager.d.ts +1 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +8 -9
- package/lib/deltaManager.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/loader.d.ts +4 -4
- package/lib/loader.js +8 -8
- package/lib/loader.js.map +1 -1
- package/lib/location-redirection-utilities/index.d.ts +6 -0
- package/lib/location-redirection-utilities/index.d.ts.map +1 -0
- package/lib/location-redirection-utilities/index.js +6 -0
- package/lib/location-redirection-utilities/index.js.map +1 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts +22 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js +46 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts +3 -2
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +18 -11
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/utils.d.ts +23 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +9 -1
- package/lib/utils.js.map +1 -1
- package/package.json +22 -30
- package/src/connectionManager.ts +33 -16
- package/src/container.ts +34 -24
- package/src/containerContext.ts +1 -1
- package/src/containerStorageAdapter.ts +3 -3
- package/src/contracts.ts +4 -4
- package/src/debugLogger.ts +4 -1
- package/src/deltaManager.ts +11 -24
- package/src/index.ts +5 -0
- package/src/loader.ts +8 -8
- package/src/location-redirection-utilities/index.ts +9 -0
- package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +59 -0
- package/src/packageVersion.ts +1 -1
- package/src/retriableDocumentStorageService.ts +29 -15
- package/src/utils.ts +23 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/location-redirection-utilities/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,0BAA0B,EAC1B,sCAAsC,GACtC,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
export { isLocationRedirectionError, resolveWithLocationRedirectionHandling, } from "./resolveWithLocationRedirection";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/location-redirection-utilities/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,0BAA0B,EAC1B,sCAAsC,GACtC,MAAM,kCAAkC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tisLocationRedirectionError,\n\tresolveWithLocationRedirectionHandling,\n} from \"./resolveWithLocationRedirection\";\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ITelemetryBaseLogger, IRequest } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { ILocationRedirectionError, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the error is location redirection error.
|
|
9
|
+
* @param error - error whose type is to be determined.
|
|
10
|
+
* @returns `true` is the error is location redirection error, otherwise `false`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isLocationRedirectionError(error: any): error is ILocationRedirectionError;
|
|
13
|
+
/**
|
|
14
|
+
* Handles location redirection while fulfilling the loader request.
|
|
15
|
+
* @param api - Callback in which user can wrap the loader.resolve or loader.request call.
|
|
16
|
+
* @param request - request to be resolved.
|
|
17
|
+
* @param urlResolver - resolver used to resolve the url.
|
|
18
|
+
* @param logger - logger to send events.
|
|
19
|
+
* @returns Response from the API call.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveWithLocationRedirectionHandling<T>(api: (request: IRequest) => Promise<T>, request: IRequest, urlResolver: IUrlResolver, logger?: ITelemetryBaseLogger): Promise<T>;
|
|
22
|
+
//# sourceMappingURL=resolveWithLocationRedirection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveWithLocationRedirection.d.ts","sourceRoot":"","sources":["../../src/location-redirection-utilities/resolveWithLocationRedirection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAEN,yBAAyB,EACzB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAG5C;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,yBAAyB,CAMzF;AAED;;;;;;;GAOG;AACH,wBAAsB,sCAAsC,CAAC,CAAC,EAC7D,GAAG,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,EACtC,OAAO,EAAE,QAAQ,EACjB,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,GAC3B,OAAO,CAAC,CAAC,CAAC,CAmBZ"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { DriverErrorTypes, } from "@fluidframework/driver-definitions";
|
|
6
|
+
import { createChildLogger } from "@fluidframework/telemetry-utils";
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the error is location redirection error.
|
|
9
|
+
* @param error - error whose type is to be determined.
|
|
10
|
+
* @returns `true` is the error is location redirection error, otherwise `false`.
|
|
11
|
+
*/
|
|
12
|
+
export function isLocationRedirectionError(error) {
|
|
13
|
+
return (typeof error === "object" &&
|
|
14
|
+
error !== null &&
|
|
15
|
+
error.errorType === DriverErrorTypes.locationRedirection);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Handles location redirection while fulfilling the loader request.
|
|
19
|
+
* @param api - Callback in which user can wrap the loader.resolve or loader.request call.
|
|
20
|
+
* @param request - request to be resolved.
|
|
21
|
+
* @param urlResolver - resolver used to resolve the url.
|
|
22
|
+
* @param logger - logger to send events.
|
|
23
|
+
* @returns Response from the API call.
|
|
24
|
+
*/
|
|
25
|
+
export async function resolveWithLocationRedirectionHandling(api, request, urlResolver, logger) {
|
|
26
|
+
let req = request;
|
|
27
|
+
const childLogger = createChildLogger({ logger, namespace: "LocationRedirection" });
|
|
28
|
+
for (;;) {
|
|
29
|
+
try {
|
|
30
|
+
return await api(req);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (!isLocationRedirectionError(error)) {
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
childLogger.sendTelemetryEvent({ eventName: "LocationRedirectionError" });
|
|
37
|
+
const resolvedUrl = error.redirectUrl;
|
|
38
|
+
// Generate the new request with new location details from the resolved url. For datastore/relative path,
|
|
39
|
+
// we don't need to pass "/" as host could have asked for a specific data store. So driver need to
|
|
40
|
+
// extract it from the resolved url.
|
|
41
|
+
const absoluteUrl = await urlResolver.getAbsoluteUrl(resolvedUrl, "", undefined);
|
|
42
|
+
req = { url: absoluteUrl, headers: req.headers };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=resolveWithLocationRedirection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveWithLocationRedirection.js","sourceRoot":"","sources":["../../src/location-redirection-utilities/resolveWithLocationRedirection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,gBAAgB,GAGhB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAU;IACpD,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,CAAC,SAAS,KAAK,gBAAgB,CAAC,mBAAmB,CACxD,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAC3D,GAAsC,EACtC,OAAiB,EACjB,WAAyB,EACzB,MAA6B;IAE7B,IAAI,GAAG,GAAa,OAAO,CAAC;IAC5B,MAAM,WAAW,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,qBAAqB,EAAE,CAAC,CAAC;IACpF,SAAS;QACR,IAAI;YACH,OAAO,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;SACtB;QAAC,OAAO,KAAU,EAAE;YACpB,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,EAAE;gBACvC,MAAM,KAAK,CAAC;aACZ;YACD,WAAW,CAAC,kBAAkB,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,CAAC,CAAC;YAC1E,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;YACtC,yGAAyG;YACzG,kGAAkG;YAClG,oCAAoC;YACpC,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,cAAc,CAAC,WAAW,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;YACjF,GAAG,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;SACjD;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger, IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tDriverErrorTypes,\n\tILocationRedirectionError,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils\";\n\n/**\n * Checks if the error is location redirection error.\n * @param error - error whose type is to be determined.\n * @returns `true` is the error is location redirection error, otherwise `false`.\n */\nexport function isLocationRedirectionError(error: any): error is ILocationRedirectionError {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\terror.errorType === DriverErrorTypes.locationRedirection\n\t);\n}\n\n/**\n * Handles location redirection while fulfilling the loader request.\n * @param api - Callback in which user can wrap the loader.resolve or loader.request call.\n * @param request - request to be resolved.\n * @param urlResolver - resolver used to resolve the url.\n * @param logger - logger to send events.\n * @returns Response from the API call.\n */\nexport async function resolveWithLocationRedirectionHandling<T>(\n\tapi: (request: IRequest) => Promise<T>,\n\trequest: IRequest,\n\turlResolver: IUrlResolver,\n\tlogger?: ITelemetryBaseLogger,\n): Promise<T> {\n\tlet req: IRequest = request;\n\tconst childLogger = createChildLogger({ logger, namespace: \"LocationRedirection\" });\n\tfor (;;) {\n\t\ttry {\n\t\t\treturn await api(req);\n\t\t} catch (error: any) {\n\t\t\tif (!isLocationRedirectionError(error)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tchildLogger.sendTelemetryEvent({ eventName: \"LocationRedirectionError\" });\n\t\t\tconst resolvedUrl = error.redirectUrl;\n\t\t\t// Generate the new request with new location details from the resolved url. For datastore/relative path,\n\t\t\t// we don't need to pass \"/\" as host could have asked for a specific data store. So driver need to\n\t\t\t// extract it from the resolved url.\n\t\t\tconst absoluteUrl = await urlResolver.getAbsoluteUrl(resolvedUrl, \"\", undefined);\n\t\t\treq = { url: absoluteUrl, headers: req.headers };\n\t\t}\n\t}\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/container-loader";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.7.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.7.2.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluidframework/container-loader";
|
|
8
|
-
export const pkgVersion = "2.0.0-internal.7.
|
|
8
|
+
export const pkgVersion = "2.0.0-internal.7.2.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"2.0.0-internal.7.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"2.0.0-internal.7.2.0\";\n"]}
|
|
@@ -7,10 +7,11 @@ import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVers
|
|
|
7
7
|
import { IDisposable } from "@fluidframework/core-interfaces";
|
|
8
8
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
9
9
|
export declare class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {
|
|
10
|
-
private readonly
|
|
10
|
+
private readonly internalStorageServiceP;
|
|
11
11
|
private readonly logger;
|
|
12
12
|
private _disposed;
|
|
13
|
-
|
|
13
|
+
private internalStorageService;
|
|
14
|
+
constructor(internalStorageServiceP: Promise<IDocumentStorageService>, logger: ITelemetryLoggerExt);
|
|
14
15
|
get policies(): IDocumentStorageServicePolicies | undefined;
|
|
15
16
|
get disposed(): boolean;
|
|
16
17
|
dispose(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retriableDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,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;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAgB,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGpF,qBAAa,+BAAgC,YAAW,uBAAuB,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"retriableDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,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;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAgB,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGpF,qBAAa,+BAAgC,YAAW,uBAAuB,EAAE,WAAW;IAI1F,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,sBAAsB,CAAsC;gBAElD,uBAAuB,EAAE,OAAO,CAAC,uBAAuB,CAAC,EACzD,MAAM,EAAE,mBAAmB;IAK7C,IAAW,QAAQ,IAAI,+BAA+B,GAAG,SAAS,CAKjE;IACD,IAAW,QAAQ,YAElB;IACM,OAAO;IAId,IAAW,aAAa,IAAI,MAAM,CAKjC;IAEY,eAAe,CAC3B,OAAO,CAAC,EAAE,QAAQ,EAClB,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAUnB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAO9C,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;IAUT,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IA8BL,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAO9D,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO5E,OAAO,CAAC,oBAAoB;YAiBd,YAAY;CAM1B"}
|
|
@@ -6,13 +6,17 @@ import { assert } from "@fluidframework/core-utils";
|
|
|
6
6
|
import { GenericError } from "@fluidframework/telemetry-utils";
|
|
7
7
|
import { runWithRetry } from "@fluidframework/driver-utils";
|
|
8
8
|
export class RetriableDocumentStorageService {
|
|
9
|
-
constructor(
|
|
10
|
-
this.
|
|
9
|
+
constructor(internalStorageServiceP, logger) {
|
|
10
|
+
this.internalStorageServiceP = internalStorageServiceP;
|
|
11
11
|
this.logger = logger;
|
|
12
12
|
this._disposed = false;
|
|
13
|
+
this.internalStorageServiceP.then((s) => (this.internalStorageService = s)).catch(() => { });
|
|
13
14
|
}
|
|
14
15
|
get policies() {
|
|
15
|
-
|
|
16
|
+
if (this.internalStorageService) {
|
|
17
|
+
return this.internalStorageService.policies;
|
|
18
|
+
}
|
|
19
|
+
throw new Error("storage service not yet instantiated");
|
|
16
20
|
}
|
|
17
21
|
get disposed() {
|
|
18
22
|
return this._disposed;
|
|
@@ -21,16 +25,19 @@ export class RetriableDocumentStorageService {
|
|
|
21
25
|
this._disposed = true;
|
|
22
26
|
}
|
|
23
27
|
get repositoryUrl() {
|
|
24
|
-
|
|
28
|
+
if (this.internalStorageService) {
|
|
29
|
+
return this.internalStorageService.repositoryUrl;
|
|
30
|
+
}
|
|
31
|
+
throw new Error("storage service not yet instantiated");
|
|
25
32
|
}
|
|
26
33
|
async getSnapshotTree(version, scenarioName) {
|
|
27
|
-
return this.runWithRetry(async () => this.
|
|
34
|
+
return this.runWithRetry(async () => this.internalStorageServiceP.then(async (s) => s.getSnapshotTree(version, scenarioName)), "storage_getSnapshotTree");
|
|
28
35
|
}
|
|
29
36
|
async readBlob(id) {
|
|
30
|
-
return this.runWithRetry(async () => this.
|
|
37
|
+
return this.runWithRetry(async () => this.internalStorageServiceP.then(async (s) => s.readBlob(id)), "storage_readBlob");
|
|
31
38
|
}
|
|
32
39
|
async getVersions(versionId, count, scenarioName, fetchSource) {
|
|
33
|
-
return this.runWithRetry(async () => this.
|
|
40
|
+
return this.runWithRetry(async () => this.internalStorageServiceP.then(async (s) => s.getVersions(versionId, count, scenarioName, fetchSource)), "storage_getVersions");
|
|
34
41
|
}
|
|
35
42
|
async uploadSummaryWithContext(summary, context) {
|
|
36
43
|
// Not using retry loop here. Couple reasons:
|
|
@@ -44,16 +51,16 @@ export class RetriableDocumentStorageService {
|
|
|
44
51
|
// But retry loop is required for creation flow (Container.attach)
|
|
45
52
|
assert((context.referenceSequenceNumber === 0) === (context.ackHandle === undefined), 0x251 /* "creation summary has to have seq=0 && handle === undefined" */);
|
|
46
53
|
if (context.referenceSequenceNumber !== 0) {
|
|
47
|
-
return this.
|
|
54
|
+
return this.internalStorageServiceP.then(async (s) => s.uploadSummaryWithContext(summary, context));
|
|
48
55
|
}
|
|
49
56
|
// Creation flow with attachment blobs - need to do retries!
|
|
50
|
-
return this.runWithRetry(async () => this.
|
|
57
|
+
return this.runWithRetry(async () => this.internalStorageServiceP.then(async (s) => s.uploadSummaryWithContext(summary, context)), "storage_uploadSummaryWithContext");
|
|
51
58
|
}
|
|
52
59
|
async downloadSummary(handle) {
|
|
53
|
-
return this.runWithRetry(async () => this.
|
|
60
|
+
return this.runWithRetry(async () => this.internalStorageServiceP.then(async (s) => s.downloadSummary(handle)), "storage_downloadSummary");
|
|
54
61
|
}
|
|
55
62
|
async createBlob(file) {
|
|
56
|
-
return this.runWithRetry(async () => this.
|
|
63
|
+
return this.runWithRetry(async () => this.internalStorageServiceP.then(async (s) => s.createBlob(file)), "storage_createBlob");
|
|
57
64
|
}
|
|
58
65
|
checkStorageDisposed(callName, error) {
|
|
59
66
|
if (this._disposed) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAepD,OAAO,EAAE,YAAY,EAAuB,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,OAAO,+BAA+B;
|
|
1
|
+
{"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAepD,OAAO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C;IACJ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\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\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { GenericError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { runWithRetry } from \"@fluidframework/driver-utils\";\n\nexport class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {\n\tprivate _disposed = false;\n\tprivate internalStorageService: IDocumentStorageService | undefined;\n\tconstructor(\n\t\tprivate readonly internalStorageServiceP: Promise<IDocumentStorageService>,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tthis.internalStorageServiceP.then((s) => (this.internalStorageService = s)).catch(() => {});\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\tif (this.internalStorageService) {\n\t\t\treturn this.internalStorageService.policies;\n\t\t}\n\t\tthrow new Error(\"storage service not yet instantiated\");\n\t}\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\tif (this.internalStorageService) {\n\t\t\treturn this.internalStorageService.repositoryUrl;\n\t\t}\n\t\tthrow new Error(\"storage service not yet instantiated\");\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.getSnapshotTree(version, scenarioName),\n\t\t\t\t),\n\t\t\t\"storage_getSnapshotTree\",\n\t\t);\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.readBlob(id)),\n\t\t\t\"storage_readBlob\",\n\t\t);\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.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.getVersions(versionId, count, scenarioName, fetchSource),\n\t\t\t\t),\n\t\t\t\"storage_getVersions\",\n\t\t);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\t// Not using retry loop here. Couple reasons:\n\t\t// 1. If client lost connectivity, then retry loop will result in uploading stale summary\n\t\t// by stale summarizer after connectivity comes back. It will cause failures for this client and for\n\t\t// real (new) summarizer. This problem in particular should be solved in future by supplying abort handle\n\t\t// on all APIs and caller (ContainerRuntime.submitSummary) aborting call on loss of connectivity\n\t\t// 2. Similar, if we get 429 with retryAfter = 10 minutes, it's likely not the right call to retry summary\n\t\t// upload in 10 minutes - it's better to keep processing ops and retry later. Though caller needs to take\n\t\t// retryAfter into account!\n\t\t// But retry loop is required for creation flow (Container.attach)\n\t\tassert(\n\t\t\t(context.referenceSequenceNumber === 0) === (context.ackHandle === undefined),\n\t\t\t0x251 /* \"creation summary has to have seq=0 && handle === undefined\" */,\n\t\t);\n\t\tif (context.referenceSequenceNumber !== 0) {\n\t\t\treturn this.internalStorageServiceP.then(async (s) =>\n\t\t\t\ts.uploadSummaryWithContext(summary, context),\n\t\t\t);\n\t\t}\n\n\t\t// Creation flow with attachment blobs - need to do retries!\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageServiceP.then(async (s) =>\n\t\t\t\t\ts.uploadSummaryWithContext(summary, context),\n\t\t\t\t),\n\t\t\t\"storage_uploadSummaryWithContext\",\n\t\t);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.downloadSummary(handle)),\n\t\t\t\"storage_downloadSummary\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageServiceP.then(async (s) => s.createBlob(file)),\n\t\t\t\"storage_createBlob\",\n\t\t);\n\t}\n\n\tprivate checkStorageDisposed(callName: string, error: unknown) {\n\t\tif (this._disposed) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: `${callName}_abortedStorageDisposed`,\n\t\t\t\t\tfetchCallName: callName, // fetchCallName matches logs in runWithRetry.ts\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\t// pre-0.58 error message: storageServiceDisposedCannotRetry\n\t\t\tthrow new GenericError(\"Storage Service is disposed. Cannot retry\", {\n\t\t\t\tcanRetry: false,\n\t\t\t});\n\t\t}\n\t\treturn;\n\t}\n\n\tprivate async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n\t\treturn runWithRetry(api, callName, this.logger, {\n\t\t\tonRetry: (_delayInMs: number, error: unknown) =>\n\t\t\t\tthis.checkStorageDisposed(callName, error),\n\t\t});\n\t}\n}\n"]}
|
package/lib/utils.d.ts
CHANGED
|
@@ -12,9 +12,23 @@ export interface ISnapshotTreeWithBlobContents extends ISnapshotTree {
|
|
|
12
12
|
[path: string]: ISnapshotTreeWithBlobContents;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Interface to represent the parsed parts of IResolvedUrl.url to help
|
|
17
|
+
* in getting info about different parts of the url.
|
|
18
|
+
* May not be compatible or relevant for any Url Resolver
|
|
19
|
+
*/
|
|
15
20
|
export interface IParsedUrl {
|
|
21
|
+
/**
|
|
22
|
+
* It is combination of tenantid/docId part of the url.
|
|
23
|
+
*/
|
|
16
24
|
id: string;
|
|
25
|
+
/**
|
|
26
|
+
* It is the deep link path in the url.
|
|
27
|
+
*/
|
|
17
28
|
path: string;
|
|
29
|
+
/**
|
|
30
|
+
* Query string part of the url.
|
|
31
|
+
*/
|
|
18
32
|
query: string;
|
|
19
33
|
/**
|
|
20
34
|
* Null means do not use snapshots, undefined means load latest snapshot
|
|
@@ -23,7 +37,15 @@ export interface IParsedUrl {
|
|
|
23
37
|
*/
|
|
24
38
|
version: string | null | undefined;
|
|
25
39
|
}
|
|
26
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get
|
|
42
|
+
* deep link info etc.
|
|
43
|
+
* Warning - This function may not be compatible with any Url Resolver's resolved url. It works
|
|
44
|
+
* with urls of type: protocol://<string>/.../..?<querystring>
|
|
45
|
+
* @param url - This is the IResolvedUrl.url part of the resolved url.
|
|
46
|
+
* @returns The IParsedUrl representing the input URL, or undefined if the format was not supported
|
|
47
|
+
*/
|
|
48
|
+
export declare function tryParseCompatibleResolvedUrl(url: string): IParsedUrl | undefined;
|
|
27
49
|
/**
|
|
28
50
|
* Combine the app summary and protocol summary in 1 tree.
|
|
29
51
|
* @param appSummary - Summary of the app.
|
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAe,MAAM,sCAAsC,CAAC;AAEhG,OAAO,EACN,6BAA6B,EAC7B,mCAAmC,EAEnC,MAAM,8BAA8B,CAAC;AAKtC,MAAM,WAAW,6BAA8B,SAAQ,aAAa;IAC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A0DD;;;;GAIG;AACH,wBAAgB,0CAA0C,CACzD,mBAAmB,EAAE,YAAY,EACjC,cAAc,EAAE,YAAY,GAC1B,6BAA6B,CAW/B;AAID,eAAO,MAAM,sCAAsC,8BACvB,YAAY,KACrC,6BAYF,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,CAE9E;AAED,wBAAgB,qCAAqC,CACpD,KAAK,EAAE,GAAG,GACR,KAAK,IAAI,mCAAmC,CAM9C"}
|
package/lib/utils.js
CHANGED
|
@@ -10,7 +10,15 @@ import { SummaryType } from "@fluidframework/protocol-definitions";
|
|
|
10
10
|
import { LoggingError } from "@fluidframework/telemetry-utils";
|
|
11
11
|
import { isCombinedAppAndProtocolSummary, } from "@fluidframework/driver-utils";
|
|
12
12
|
import { DriverErrorTypes } from "@fluidframework/driver-definitions";
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get
|
|
15
|
+
* deep link info etc.
|
|
16
|
+
* Warning - This function may not be compatible with any Url Resolver's resolved url. It works
|
|
17
|
+
* with urls of type: protocol://<string>/.../..?<querystring>
|
|
18
|
+
* @param url - This is the IResolvedUrl.url part of the resolved url.
|
|
19
|
+
* @returns The IParsedUrl representing the input URL, or undefined if the format was not supported
|
|
20
|
+
*/
|
|
21
|
+
export function tryParseCompatibleResolvedUrl(url) {
|
|
14
22
|
const parsed = parse(url, true);
|
|
15
23
|
if (typeof parsed.pathname !== "string") {
|
|
16
24
|
throw new LoggingError("Failed to parse pathname");
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAC5B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EA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AAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,qCAAqC,CACpD,KAAU;IAEV,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,EAAE,SAAS,KAAK,gBAAgB,CAAC,8BAA8B,CACpE,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { v4 as uuid } from \"uuid\";\nimport { stringToBuffer, Uint8ArrayToArrayBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISummaryTree, ISnapshotTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { LoggingError } from \"@fluidframework/telemetry-utils\";\nimport {\n\tCombinedAppAndProtocolSummary,\n\tDeltaStreamConnectionForbiddenError,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\n\n// This is used when we rehydrate a container from the snapshot. Here we put the blob contents\n// in separate property: blobContents.\nexport interface ISnapshotTreeWithBlobContents extends ISnapshotTree {\n\tblobsContents: { [path: string]: ArrayBufferLike };\n\ttrees: { [path: string]: ISnapshotTreeWithBlobContents };\n}\n\nexport interface IParsedUrl {\n\tid: string;\n\tpath: string;\n\tquery: string;\n\t/**\n\t * Null means do not use snapshots, undefined means load latest snapshot\n\t * otherwise it's version ID passed to IDocumentStorageService.getVersions() to figure out what snapshot to use.\n\t * If needed, can add undefined which is treated by Container.load() as load latest snapshot.\n\t */\n\tversion: string | null | undefined;\n}\n\nexport function parseUrl(url: string): IParsedUrl | undefined {\n\tconst parsed = parse(url, true);\n\tif (typeof parsed.pathname !== \"string\") {\n\t\tthrow new LoggingError(\"Failed to parse pathname\");\n\t}\n\tconst query = parsed.search ?? \"\";\n\tconst regex = /^\\/([^/]*\\/[^/]*)(\\/?.*)$/;\n\tconst match = regex.exec(parsed.pathname);\n\treturn match?.length === 3\n\t\t? { id: match[1], path: match[2], query, version: parsed.query.version as string }\n\t\t: undefined;\n}\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n * @internal\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): CombinedAppAndProtocolSummary {\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(appSummary),\n\t\t0x5a8 /* app summary is already a combined tree! */,\n\t);\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(protocolSummary),\n\t\t0x5a9 /* protocol summary is already a combined tree! */,\n\t);\n\tconst createNewSummary: CombinedAppAndProtocolSummary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Converts summary tree (for upload) to snapshot tree (for download).\n * Summary tree blobs contain contents, but snapshot tree blobs normally\n * contain IDs pointing to storage. This will create 2 blob entries in the\n * snapshot tree for each blob in the summary tree. One will be the regular\n * path pointing to a uniquely generated ID. Then there will be another\n * entry with the path as that uniquely generated ID, and value as the\n * blob contents as a base-64 string.\n * @param summary - summary to convert\n */\nfunction convertSummaryToSnapshotWithEmbeddedBlobContents(\n\tsummary: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\tconst treeNode: ISnapshotTreeWithBlobContents = {\n\t\tblobs: {},\n\t\tblobsContents: {},\n\t\ttrees: {},\n\t\tid: uuid(),\n\t\tunreferenced: summary.unreferenced,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] =\n\t\t\t\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(summaryObject);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Attachment:\n\t\t\t\ttreeNode.blobs[key] = summaryObject.id;\n\t\t\t\tbreak;\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: Uint8ArrayToArrayBuffer(summaryObject.content);\n\t\t\t\ttreeNode.blobsContents[blobId] = contentBuffer;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\"No handles should be there in summary in detached container!!\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\n/**\n * Combine and convert protocol and app summary tree to format which is readable by container while rehydrating.\n * @param protocolSummaryTree - Protocol Summary Tree\n * @param appSummaryTree - App Summary Tree\n */\nexport function convertProtocolAndAppSummaryToSnapshotTree(\n\tprotocolSummaryTree: ISummaryTree,\n\tappSummaryTree: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\t// Shallow copy is fine, since we are doing a deep clone below.\n\tconst combinedSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: { ...appSummaryTree.tree },\n\t};\n\n\tcombinedSummary.tree[\".protocol\"] = protocolSummaryTree;\n\tconst snapshotTreeWithBlobContents =\n\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(combinedSummary);\n\treturn snapshotTreeWithBlobContents;\n}\n\n// This function converts the snapshot taken in detached container(by serialize api) to snapshotTree with which\n// a detached container can be rehydrated.\nexport const getSnapshotTreeFromSerializedContainer = (\n\tdetachedContainerSnapshot: ISummaryTree,\n): ISnapshotTreeWithBlobContents => {\n\tassert(\n\t\tisCombinedAppAndProtocolSummary(detachedContainerSnapshot),\n\t\t0x1e0 /* \"Protocol and App summary trees should be present\" */,\n\t);\n\tconst protocolSummaryTree = detachedContainerSnapshot.tree[\".protocol\"];\n\tconst appSummaryTree = detachedContainerSnapshot.tree[\".app\"];\n\tconst snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotTree(\n\t\tprotocolSummaryTree,\n\t\tappSummaryTree,\n\t);\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree {\n\treturn \".protocol\" in snapshot.trees ? snapshot.trees[\".protocol\"] : snapshot;\n}\n\nexport function isDeltaStreamConnectionForbiddenError(\n\terror: any,\n): error is DeltaStreamConnectionForbiddenError {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\terror?.errorType === DriverErrorTypes.deltaStreamConnectionForbidden\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAC5B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAA+B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAGN,+BAA+B,GAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAmCtE;;;;;;;G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IT License.\n */\n\nimport { parse } from \"url\";\nimport { v4 as uuid } from \"uuid\";\nimport { stringToBuffer, Uint8ArrayToArrayBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISummaryTree, ISnapshotTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { LoggingError } from \"@fluidframework/telemetry-utils\";\nimport {\n\tCombinedAppAndProtocolSummary,\n\tDeltaStreamConnectionForbiddenError,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\n\n// This is used when we rehydrate a container from the snapshot. Here we put the blob contents\n// in separate property: blobContents.\nexport interface ISnapshotTreeWithBlobContents extends ISnapshotTree {\n\tblobsContents: { [path: string]: ArrayBufferLike };\n\ttrees: { [path: string]: ISnapshotTreeWithBlobContents };\n}\n\n/**\n * Interface to represent the parsed parts of IResolvedUrl.url to help\n * in getting info about different parts of the url.\n * May not be compatible or relevant for any Url Resolver\n */\nexport interface IParsedUrl {\n\t/**\n\t * It is combination of tenantid/docId part of the url.\n\t */\n\tid: string;\n\t/**\n\t * It is the deep link path in the url.\n\t */\n\tpath: string;\n\t/**\n\t * Query string part of the url.\n\t */\n\tquery: string;\n\t/**\n\t * Null means do not use snapshots, undefined means load latest snapshot\n\t * otherwise it's version ID passed to IDocumentStorageService.getVersions() to figure out what snapshot to use.\n\t * If needed, can add undefined which is treated by Container.load() as load latest snapshot.\n\t */\n\tversion: string | null | undefined;\n}\n\n/**\n * Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get\n * deep link info etc.\n * Warning - This function may not be compatible with any Url Resolver's resolved url. It works\n * with urls of type: protocol://<string>/.../..?<querystring>\n * @param url - This is the IResolvedUrl.url part of the resolved url.\n * @returns The IParsedUrl representing the input URL, or undefined if the format was not supported\n */\nexport function tryParseCompatibleResolvedUrl(url: string): IParsedUrl | undefined {\n\tconst parsed = parse(url, true);\n\tif (typeof parsed.pathname !== \"string\") {\n\t\tthrow new LoggingError(\"Failed to parse pathname\");\n\t}\n\tconst query = parsed.search ?? \"\";\n\tconst regex = /^\\/([^/]*\\/[^/]*)(\\/?.*)$/;\n\tconst match = regex.exec(parsed.pathname);\n\treturn match?.length === 3\n\t\t? { id: match[1], path: match[2], query, version: parsed.query.version as string }\n\t\t: undefined;\n}\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n * @internal\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): CombinedAppAndProtocolSummary {\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(appSummary),\n\t\t0x5a8 /* app summary is already a combined tree! */,\n\t);\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(protocolSummary),\n\t\t0x5a9 /* protocol summary is already a combined tree! */,\n\t);\n\tconst createNewSummary: CombinedAppAndProtocolSummary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Converts summary tree (for upload) to snapshot tree (for download).\n * Summary tree blobs contain contents, but snapshot tree blobs normally\n * contain IDs pointing to storage. This will create 2 blob entries in the\n * snapshot tree for each blob in the summary tree. One will be the regular\n * path pointing to a uniquely generated ID. Then there will be another\n * entry with the path as that uniquely generated ID, and value as the\n * blob contents as a base-64 string.\n * @param summary - summary to convert\n */\nfunction convertSummaryToSnapshotWithEmbeddedBlobContents(\n\tsummary: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\tconst treeNode: ISnapshotTreeWithBlobContents = {\n\t\tblobs: {},\n\t\tblobsContents: {},\n\t\ttrees: {},\n\t\tid: uuid(),\n\t\tunreferenced: summary.unreferenced,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] =\n\t\t\t\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(summaryObject);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Attachment:\n\t\t\t\ttreeNode.blobs[key] = summaryObject.id;\n\t\t\t\tbreak;\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: Uint8ArrayToArrayBuffer(summaryObject.content);\n\t\t\t\ttreeNode.blobsContents[blobId] = contentBuffer;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\"No handles should be there in summary in detached container!!\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\n/**\n * Combine and convert protocol and app summary tree to format which is readable by container while rehydrating.\n * @param protocolSummaryTree - Protocol Summary Tree\n * @param appSummaryTree - App Summary Tree\n */\nexport function convertProtocolAndAppSummaryToSnapshotTree(\n\tprotocolSummaryTree: ISummaryTree,\n\tappSummaryTree: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\t// Shallow copy is fine, since we are doing a deep clone below.\n\tconst combinedSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: { ...appSummaryTree.tree },\n\t};\n\n\tcombinedSummary.tree[\".protocol\"] = protocolSummaryTree;\n\tconst snapshotTreeWithBlobContents =\n\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(combinedSummary);\n\treturn snapshotTreeWithBlobContents;\n}\n\n// This function converts the snapshot taken in detached container(by serialize api) to snapshotTree with which\n// a detached container can be rehydrated.\nexport const getSnapshotTreeFromSerializedContainer = (\n\tdetachedContainerSnapshot: ISummaryTree,\n): ISnapshotTreeWithBlobContents => {\n\tassert(\n\t\tisCombinedAppAndProtocolSummary(detachedContainerSnapshot),\n\t\t0x1e0 /* \"Protocol and App summary trees should be present\" */,\n\t);\n\tconst protocolSummaryTree = detachedContainerSnapshot.tree[\".protocol\"];\n\tconst appSummaryTree = detachedContainerSnapshot.tree[\".app\"];\n\tconst snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotTree(\n\t\tprotocolSummaryTree,\n\t\tappSummaryTree,\n\t);\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree {\n\treturn \".protocol\" in snapshot.trees ? snapshot.trees[\".protocol\"] : snapshot;\n}\n\nexport function isDeltaStreamConnectionForbiddenError(\n\terror: any,\n): error is DeltaStreamConnectionForbiddenError {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\terror?.errorType === DriverErrorTypes.deltaStreamConnectionForbidden\n\t);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/container-loader",
|
|
3
|
-
"version": "2.0.0-internal.7.
|
|
3
|
+
"version": "2.0.0-internal.7.2.0",
|
|
4
4
|
"description": "Fluid container loader",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"temp-directory": "nyc/.nyc_output"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fluid-internal/client-utils": ">=2.0.0-internal.7.
|
|
39
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.7.
|
|
40
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.
|
|
41
|
-
"@fluidframework/core-utils": ">=2.0.0-internal.7.
|
|
42
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.7.
|
|
43
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.7.
|
|
38
|
+
"@fluid-internal/client-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
39
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
40
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
41
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
42
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
43
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
44
44
|
"@fluidframework/protocol-base": "^2.0.1",
|
|
45
45
|
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
46
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.7.
|
|
47
|
-
"debug": "^4.
|
|
46
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
47
|
+
"debug": "^4.3.4",
|
|
48
48
|
"double-ended-queue": "^2.1.0-0",
|
|
49
49
|
"events": "^3.1.0",
|
|
50
50
|
"lodash": "^4.17.21",
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"uuid": "^9.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@fluid-internal/test-loader-utils": ">=2.0.0-internal.7.
|
|
56
|
-
"@fluid-tools/build-cli": "^0.
|
|
57
|
-
"@fluidframework/build-common": "^2.0.
|
|
58
|
-
"@fluidframework/build-tools": "^0.
|
|
59
|
-
"@fluidframework/container-loader-previous": "npm:@fluidframework/container-loader@2.0.0-internal.
|
|
60
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
61
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.
|
|
55
|
+
"@fluid-internal/test-loader-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
56
|
+
"@fluid-tools/build-cli": "^0.26.1",
|
|
57
|
+
"@fluidframework/build-common": "^2.0.3",
|
|
58
|
+
"@fluidframework/build-tools": "^0.26.1",
|
|
59
|
+
"@fluidframework/container-loader-previous": "npm:@fluidframework/container-loader@2.0.0-internal.7.1.0",
|
|
60
|
+
"@fluidframework/eslint-config-fluid": "^3.0.0",
|
|
61
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
62
62
|
"@microsoft/api-extractor": "^7.37.0",
|
|
63
63
|
"@types/double-ended-queue": "^2.1.0",
|
|
64
64
|
"@types/events": "^3.0.0",
|
|
@@ -67,38 +67,30 @@
|
|
|
67
67
|
"@types/node": "^16.18.38",
|
|
68
68
|
"@types/sinon": "^7.0.13",
|
|
69
69
|
"c8": "^7.7.1",
|
|
70
|
-
"copyfiles": "^2.4.1",
|
|
71
70
|
"cross-env": "^7.0.3",
|
|
72
|
-
"eslint": "~8.
|
|
71
|
+
"eslint": "~8.50.0",
|
|
73
72
|
"mocha": "^10.2.0",
|
|
74
73
|
"mocha-json-output-reporter": "^2.0.1",
|
|
75
74
|
"mocha-multi-reporters": "^1.5.1",
|
|
76
75
|
"moment": "^2.21.0",
|
|
77
|
-
"prettier": "~
|
|
76
|
+
"prettier": "~3.0.3",
|
|
78
77
|
"rimraf": "^4.4.0",
|
|
79
78
|
"sinon": "^7.4.2",
|
|
80
79
|
"typescript": "~5.1.6"
|
|
81
80
|
},
|
|
82
81
|
"typeValidation": {
|
|
83
|
-
"broken": {
|
|
84
|
-
"InterfaceDeclaration_IContainerExperimental": {
|
|
85
|
-
"forwardCompat": false
|
|
86
|
-
},
|
|
87
|
-
"InterfaceDeclaration_IProtocolHandler": {
|
|
88
|
-
"backCompat": false
|
|
89
|
-
}
|
|
90
|
-
}
|
|
82
|
+
"broken": {}
|
|
91
83
|
},
|
|
92
84
|
"scripts": {
|
|
93
85
|
"build": "fluid-build . --task build",
|
|
94
86
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
95
87
|
"build:compile": "fluid-build . --task compile",
|
|
96
|
-
"build:docs": "api-extractor run --local
|
|
88
|
+
"build:docs": "api-extractor run --local",
|
|
97
89
|
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
98
90
|
"build:genver": "gen-version",
|
|
99
91
|
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
100
|
-
"ci:build:docs": "api-extractor run
|
|
101
|
-
"clean": "rimraf --glob
|
|
92
|
+
"ci:build:docs": "api-extractor run",
|
|
93
|
+
"clean": "rimraf --glob dist lib \"*.tsbuildinfo\" \"*.build.log\" _api-extractor-temp nyc",
|
|
102
94
|
"eslint": "eslint --format stylish src",
|
|
103
95
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
104
96
|
"format": "npm run prettier:fix",
|
package/src/connectionManager.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IDisposable, ITelemetryProperties } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { IDisposable, ITelemetryProperties, LogLevel } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { assert } from "@fluidframework/core-utils";
|
|
8
8
|
import { performance, TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
9
9
|
import {
|
|
@@ -585,6 +585,14 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
585
585
|
this.logger.sendTelemetryEvent({ eventName: "ReceivedClosedConnection" });
|
|
586
586
|
connection = undefined;
|
|
587
587
|
}
|
|
588
|
+
this.logger.sendTelemetryEvent(
|
|
589
|
+
{
|
|
590
|
+
eventName: "ConnectionReceived",
|
|
591
|
+
connected: connection !== undefined && connection.disposed === false,
|
|
592
|
+
},
|
|
593
|
+
undefined,
|
|
594
|
+
LogLevel.verbose,
|
|
595
|
+
);
|
|
588
596
|
} catch (origError: any) {
|
|
589
597
|
if (isDeltaStreamConnectionForbiddenError(origError)) {
|
|
590
598
|
connection = new NoDeltaStream(origError.storageOnlyReason, {
|
|
@@ -674,8 +682,8 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
674
682
|
);
|
|
675
683
|
}
|
|
676
684
|
|
|
677
|
-
// Check for abort signal after while loop as well
|
|
678
|
-
if (abortSignal.aborted === true) {
|
|
685
|
+
// Check for abort signal after while loop as well or we've been disposed
|
|
686
|
+
if (abortSignal.aborted === true || this._disposed) {
|
|
679
687
|
connection.dispose();
|
|
680
688
|
this.logger.sendTelemetryEvent({
|
|
681
689
|
eventName: "ConnectionAttemptCancelled",
|
|
@@ -736,7 +744,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
736
744
|
|
|
737
745
|
// Remove listeners first so we don't try to retrigger this flow accidentally through reconnectOnError
|
|
738
746
|
connection.off("op", this.opHandler);
|
|
739
|
-
connection.off("signal", this.
|
|
747
|
+
connection.off("signal", this.signalHandler);
|
|
740
748
|
connection.off("nack", this.nackHandler);
|
|
741
749
|
connection.off("disconnect", this.disconnectHandlerInternal);
|
|
742
750
|
connection.off("error", this.errorHandler);
|
|
@@ -834,7 +842,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
834
842
|
this._outbound.resume();
|
|
835
843
|
|
|
836
844
|
connection.on("op", this.opHandler);
|
|
837
|
-
connection.on("signal", this.
|
|
845
|
+
connection.on("signal", this.signalHandler);
|
|
838
846
|
connection.on("nack", this.nackHandler);
|
|
839
847
|
connection.on("disconnect", this.disconnectHandlerInternal);
|
|
840
848
|
connection.on("error", this.errorHandler);
|
|
@@ -900,28 +908,32 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
900
908
|
type: SignalType.Clear,
|
|
901
909
|
}),
|
|
902
910
|
};
|
|
903
|
-
this.props.signalHandler(clearSignal);
|
|
904
911
|
|
|
905
|
-
|
|
906
|
-
|
|
912
|
+
// list of signals to process due to this new connection
|
|
913
|
+
let signalsToProcess: ISignalMessage[] = [clearSignal];
|
|
914
|
+
|
|
915
|
+
const clientJoinSignals: ISignalMessage[] = (connection.initialClients ?? []).map(
|
|
916
|
+
(priorClient) => ({
|
|
907
917
|
clientId: null, // system signal
|
|
908
918
|
content: JSON.stringify({
|
|
909
919
|
type: SignalType.ClientJoin,
|
|
910
920
|
content: priorClient, // ISignalClient
|
|
911
921
|
}),
|
|
912
|
-
}
|
|
913
|
-
|
|
922
|
+
}),
|
|
923
|
+
);
|
|
924
|
+
if (clientJoinSignals.length > 0) {
|
|
925
|
+
signalsToProcess = signalsToProcess.concat(clientJoinSignals);
|
|
914
926
|
}
|
|
915
927
|
|
|
916
928
|
// Unfortunately, there is no defined order between initialSignals (including join & leave signals)
|
|
917
929
|
// and connection.initialClients. In practice, connection.initialSignals quite often contains join signal
|
|
918
930
|
// for "self" and connection.initialClients does not contain "self", so we have to process them after
|
|
919
931
|
// "clear" signal above.
|
|
920
|
-
if (connection.initialSignals !== undefined) {
|
|
921
|
-
|
|
922
|
-
this.props.signalHandler(signal);
|
|
923
|
-
}
|
|
932
|
+
if (connection.initialSignals !== undefined && connection.initialSignals.length > 0) {
|
|
933
|
+
signalsToProcess = signalsToProcess.concat(connection.initialSignals);
|
|
924
934
|
}
|
|
935
|
+
|
|
936
|
+
this.props.signalHandler(signalsToProcess);
|
|
925
937
|
}
|
|
926
938
|
|
|
927
939
|
/**
|
|
@@ -1047,9 +1059,9 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
1047
1059
|
};
|
|
1048
1060
|
}
|
|
1049
1061
|
|
|
1050
|
-
public submitSignal(content: any) {
|
|
1062
|
+
public submitSignal(content: any, targetClientId?: string) {
|
|
1051
1063
|
if (this.connection !== undefined) {
|
|
1052
|
-
this.connection.submitSignal(content);
|
|
1064
|
+
this.connection.submitSignal(content, targetClientId);
|
|
1053
1065
|
} else {
|
|
1054
1066
|
this.logger.sendErrorEvent({ eventName: "submitSignalDisconnected" });
|
|
1055
1067
|
}
|
|
@@ -1139,6 +1151,11 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
1139
1151
|
this.props.incomingOpHandler(messages, "opHandler");
|
|
1140
1152
|
};
|
|
1141
1153
|
|
|
1154
|
+
private readonly signalHandler = (signalsArg: ISignalMessage | ISignalMessage[]) => {
|
|
1155
|
+
const signals = Array.isArray(signalsArg) ? signalsArg : [signalsArg];
|
|
1156
|
+
this.props.signalHandler(signals);
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1142
1159
|
// Always connect in write mode after getting nacked.
|
|
1143
1160
|
private readonly nackHandler = (documentId: string, messages: INack[]) => {
|
|
1144
1161
|
const message = messages[0];
|