@fluidframework/routerlicious-driver 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +10 -12
- package/.mocharc.js +2 -2
- package/README.md +1 -1
- package/api-extractor.json +2 -2
- package/dist/cache.d.ts +3 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +6 -4
- package/dist/cache.js.map +1 -1
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +4 -2
- package/dist/createNewUtils.js.map +1 -1
- package/dist/defaultTokenProvider.d.ts.map +1 -1
- package/dist/defaultTokenProvider.js.map +1 -1
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js.map +1 -1
- package/dist/deltaStorageService.d.ts.map +1 -1
- package/dist/deltaStorageService.js +4 -1
- package/dist/deltaStorageService.js.map +1 -1
- package/dist/documentDeltaConnection.d.ts.map +1 -1
- package/dist/documentDeltaConnection.js.map +1 -1
- package/dist/documentService.d.ts +4 -2
- package/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +28 -41
- package/dist/documentService.js.map +1 -1
- package/dist/documentServiceFactory.d.ts +0 -1
- package/dist/documentServiceFactory.d.ts.map +1 -1
- package/dist/documentServiceFactory.js +26 -13
- package/dist/documentServiceFactory.js.map +1 -1
- package/dist/documentStorageService.d.ts +1 -1
- package/dist/documentStorageService.d.ts.map +1 -1
- package/dist/documentStorageService.js +8 -6
- package/dist/documentStorageService.js.map +1 -1
- package/dist/errorUtils.d.ts +11 -3
- package/dist/errorUtils.d.ts.map +1 -1
- package/dist/errorUtils.js +19 -6
- package/dist/errorUtils.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/mapWithExpiration.d.ts +34 -0
- package/dist/mapWithExpiration.d.ts.map +1 -0
- package/dist/mapWithExpiration.js +105 -0
- package/dist/mapWithExpiration.js.map +1 -0
- package/dist/nullBlobStorageService.d.ts.map +1 -1
- package/dist/nullBlobStorageService.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/policies.d.ts.map +1 -1
- package/dist/policies.js.map +1 -1
- package/dist/restWrapper.d.ts +8 -5
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapper.js +38 -44
- package/dist/restWrapper.js.map +1 -1
- package/dist/retriableGitManager.d.ts.map +1 -1
- package/dist/retriableGitManager.js.map +1 -1
- package/dist/shreddedSummaryDocumentStorageService.d.ts +1 -1
- package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/shreddedSummaryDocumentStorageService.js +9 -5
- package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/dist/tokens.d.ts +24 -7
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js.map +1 -1
- package/dist/treeUtils.d.ts +51 -0
- package/dist/treeUtils.d.ts.map +1 -0
- package/dist/treeUtils.js +85 -0
- package/dist/treeUtils.js.map +1 -0
- package/dist/urlUtils.d.ts.map +1 -1
- package/dist/urlUtils.js.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.d.ts +1 -1
- package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.js +30 -17
- package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
- package/lib/cache.d.ts +3 -0
- package/lib/cache.d.ts.map +1 -1
- package/lib/cache.js +6 -4
- package/lib/cache.js.map +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +4 -2
- package/lib/createNewUtils.js.map +1 -1
- package/lib/defaultTokenProvider.d.ts.map +1 -1
- package/lib/defaultTokenProvider.js.map +1 -1
- package/lib/definitions.d.ts.map +1 -1
- package/lib/definitions.js.map +1 -1
- package/lib/deltaStorageService.d.ts.map +1 -1
- package/lib/deltaStorageService.js +4 -1
- package/lib/deltaStorageService.js.map +1 -1
- package/lib/documentDeltaConnection.d.ts.map +1 -1
- package/lib/documentDeltaConnection.js.map +1 -1
- package/lib/documentService.d.ts +4 -2
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +30 -24
- package/lib/documentService.js.map +1 -1
- package/lib/documentServiceFactory.d.ts +0 -1
- package/lib/documentServiceFactory.d.ts.map +1 -1
- package/lib/documentServiceFactory.js +27 -14
- package/lib/documentServiceFactory.js.map +1 -1
- package/lib/documentStorageService.d.ts +1 -1
- package/lib/documentStorageService.d.ts.map +1 -1
- package/lib/documentStorageService.js +9 -7
- package/lib/documentStorageService.js.map +1 -1
- package/lib/errorUtils.d.ts +11 -3
- package/lib/errorUtils.d.ts.map +1 -1
- package/lib/errorUtils.js +18 -5
- package/lib/errorUtils.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/mapWithExpiration.d.ts +34 -0
- package/lib/mapWithExpiration.d.ts.map +1 -0
- package/lib/mapWithExpiration.js +101 -0
- package/lib/mapWithExpiration.js.map +1 -0
- package/lib/nullBlobStorageService.d.ts.map +1 -1
- package/lib/nullBlobStorageService.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/policies.d.ts.map +1 -1
- package/lib/policies.js.map +1 -1
- package/lib/restWrapper.d.ts +8 -5
- package/lib/restWrapper.d.ts.map +1 -1
- package/lib/restWrapper.js +38 -44
- package/lib/restWrapper.js.map +1 -1
- package/lib/retriableGitManager.d.ts.map +1 -1
- package/lib/retriableGitManager.js.map +1 -1
- package/lib/shreddedSummaryDocumentStorageService.d.ts +1 -1
- package/lib/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/shreddedSummaryDocumentStorageService.js +10 -6
- package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/lib/tokens.d.ts +24 -7
- package/lib/tokens.d.ts.map +1 -1
- package/lib/tokens.js.map +1 -1
- package/lib/treeUtils.d.ts +51 -0
- package/lib/treeUtils.d.ts.map +1 -0
- package/lib/treeUtils.js +80 -0
- package/lib/treeUtils.js.map +1 -0
- package/lib/urlUtils.d.ts.map +1 -1
- package/lib/urlUtils.js.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.js +30 -17
- package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
- package/package.json +55 -52
- package/prettier.config.cjs +1 -1
- package/src/cache.ts +21 -14
- package/src/createNewUtils.ts +24 -22
- package/src/defaultTokenProvider.ts +13 -15
- package/src/definitions.ts +2 -2
- package/src/deltaStorageService.ts +99 -95
- package/src/documentDeltaConnection.ts +53 -47
- package/src/documentService.ts +260 -241
- package/src/documentServiceFactory.ts +268 -237
- package/src/documentStorageService.ts +87 -83
- package/src/errorUtils.ts +91 -76
- package/src/index.ts +7 -1
- package/src/mapWithExpiration.ts +124 -0
- package/src/nullBlobStorageService.ts +24 -21
- package/src/packageVersion.ts +1 -1
- package/src/policies.ts +44 -44
- package/src/restWrapper.ts +270 -208
- package/src/retriableGitManager.ts +152 -151
- package/src/shreddedSummaryDocumentStorageService.ts +202 -194
- package/src/tokens.ts +69 -44
- package/src/treeUtils.ts +107 -0
- package/src/urlUtils.ts +26 -23
- package/src/wholeSummaryDocumentStorageService.ts +248 -228
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
package/.eslintrc.js
CHANGED
|
@@ -4,15 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
}
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
|
|
8
|
+
parserOptions: {
|
|
9
|
+
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
13
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
14
|
+
"no-case-declarations": "off",
|
|
15
|
+
},
|
|
16
|
+
};
|
package/.mocharc.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
"use strict";
|
|
7
7
|
|
|
8
|
-
const getFluidTestMochaConfig = require(
|
|
8
|
+
const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
|
|
9
9
|
|
|
10
10
|
const packageDir = __dirname;
|
|
11
11
|
const config = getFluidTestMochaConfig(packageDir);
|
package/README.md
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
This is an implementation of a driver which provides a DocumentService which uses routerlicious to interact
|
|
4
4
|
with different endpoints like Document Storage, Delta Storage and Delta stream.
|
|
5
|
-
It also provides implementation of Document Storage, Delta Storage and Delta stream.
|
|
5
|
+
It also provides implementation of Document Storage, Delta Storage and Delta stream.
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-common-report.json"
|
|
4
4
|
}
|
package/dist/cache.d.ts
CHANGED
|
@@ -6,11 +6,14 @@ export interface ICache<T> {
|
|
|
6
6
|
get(key: string): Promise<T | undefined>;
|
|
7
7
|
put(key: string, value: T): Promise<void>;
|
|
8
8
|
}
|
|
9
|
+
/** A basic in-memory cache that optionally supports expiring entries after a period of inactivity */
|
|
9
10
|
export declare class InMemoryCache<T> implements ICache<T> {
|
|
10
11
|
private readonly cache;
|
|
12
|
+
constructor(expirationMs?: number);
|
|
11
13
|
get(key: string): Promise<T | undefined>;
|
|
12
14
|
put(key: string, value: T): Promise<void>;
|
|
13
15
|
}
|
|
16
|
+
/** This "cache" does nothing on put, and get always returns undefined */
|
|
14
17
|
export declare class NullCache<T> implements ICache<T> {
|
|
15
18
|
get(key: string): Promise<T | undefined>;
|
|
16
19
|
put(key: string, value: T): Promise<void>;
|
package/dist/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,MAAM,CAAC,CAAC;IACxB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,qGAAqG;AACrG,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,MAAM,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiB;gBAE3B,YAAY,CAAC,EAAE,MAAM;IAIpB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAIxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtD;AAED,yEAAyE;AACzE,qBAAa,SAAS,CAAC,CAAC,CAAE,YAAW,MAAM,CAAC,CAAC,CAAC;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAIxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CACtD"}
|
package/dist/cache.js
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.NullCache = exports.InMemoryCache = void 0;
|
|
8
|
+
const mapWithExpiration_1 = require("./mapWithExpiration");
|
|
9
|
+
/** A basic in-memory cache that optionally supports expiring entries after a period of inactivity */
|
|
8
10
|
class InMemoryCache {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.cache = new Map();
|
|
11
|
+
constructor(expirationMs) {
|
|
12
|
+
this.cache = expirationMs !== undefined ? new mapWithExpiration_1.MapWithExpiration(expirationMs) : new Map();
|
|
11
13
|
}
|
|
12
14
|
async get(key) {
|
|
13
15
|
return this.cache.get(key);
|
|
@@ -17,12 +19,12 @@ class InMemoryCache {
|
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
exports.InMemoryCache = InMemoryCache;
|
|
22
|
+
/** This "cache" does nothing on put, and get always returns undefined */
|
|
20
23
|
class NullCache {
|
|
21
24
|
async get(key) {
|
|
22
25
|
return undefined;
|
|
23
26
|
}
|
|
24
|
-
async put(key, value) {
|
|
25
|
-
}
|
|
27
|
+
async put(key, value) { }
|
|
26
28
|
}
|
|
27
29
|
exports.NullCache = NullCache;
|
|
28
30
|
//# sourceMappingURL=cache.js.map
|
package/dist/cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAwD;AAOxD,qGAAqG;AACrG,MAAa,aAAa;IAGzB,YAAY,YAAqB;QAChC,IAAI,CAAC,KAAK,GAAG,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,qCAAiB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IAC3F,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAQ;QACrC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;CACD;AAdD,sCAcC;AAED,yEAAyE;AACzE,MAAa,SAAS;IACd,KAAK,CAAC,GAAG,CAAC,GAAW;QAC3B,OAAO,SAAS,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAQ,IAAkB,CAAC;CACzD;AAND,8BAMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { MapWithExpiration } from \"./mapWithExpiration\";\n\nexport interface ICache<T> {\n\tget(key: string): Promise<T | undefined>;\n\tput(key: string, value: T): Promise<void>;\n}\n\n/** A basic in-memory cache that optionally supports expiring entries after a period of inactivity */\nexport class InMemoryCache<T> implements ICache<T> {\n\tprivate readonly cache: Map<string, T>;\n\n\tconstructor(expirationMs?: number) {\n\t\tthis.cache = expirationMs !== undefined ? new MapWithExpiration(expirationMs) : new Map();\n\t}\n\n\tpublic async get(key: string): Promise<T | undefined> {\n\t\treturn this.cache.get(key);\n\t}\n\n\tpublic async put(key: string, value: T): Promise<void> {\n\t\tthis.cache.set(key, value);\n\t}\n}\n\n/** This \"cache\" does nothing on put, and get always returns undefined */\nexport class NullCache<T> implements ICache<T> {\n\tpublic async get(key: string): Promise<T | undefined> {\n\t\treturn undefined;\n\t}\n\n\tpublic async put(key: string, value: T): Promise<void> {}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAe,MAAM,sCAAsC,CAAC;AAEjF;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAe,MAAM,sCAAsC,CAAC;AAEjF;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CA2BpF"}
|
package/dist/createNewUtils.js
CHANGED
|
@@ -22,8 +22,10 @@ function convertSummaryToCreateNewSummary(summary) {
|
|
|
22
22
|
break;
|
|
23
23
|
}
|
|
24
24
|
case protocol_definitions_1.SummaryType.Blob: {
|
|
25
|
-
summaryObject.content =
|
|
26
|
-
summaryObject.content
|
|
25
|
+
summaryObject.content =
|
|
26
|
+
typeof summaryObject.content === "string"
|
|
27
|
+
? summaryObject.content
|
|
28
|
+
: (0, common_utils_1.Uint8ArrayToString)(summaryObject.content, "utf8");
|
|
27
29
|
break;
|
|
28
30
|
}
|
|
29
31
|
case protocol_definitions_1.SummaryType.Handle: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAkE;AAClE,+EAAiF;AAEjF;;;;GAIG;AACH,SAAgB,gCAAgC,CAAC,OAAqB;
|
|
1
|
+
{"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAkE;AAClE,+EAAiF;AAEjF;;;;GAIG;AACH,SAAgB,gCAAgC,CAAC,OAAqB;IACrE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACvB,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAExC,QAAQ,aAAa,CAAC,IAAI,EAAE;YAC3B,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,gCAAgC,CAAC,aAAa,CAAC,CAAC;gBACpE,MAAM;aACN;YACD,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,aAAa,CAAC,OAAO;oBACpB,OAAO,aAAa,CAAC,OAAO,KAAK,QAAQ;wBACxC,CAAC,CAAC,aAAa,CAAC,OAAO;wBACvB,CAAC,CAAC,IAAA,iCAAkB,EAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBACtD,MAAM;aACN;YACD,KAAK,kCAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;aACnE;YACD,OAAO,CAAC,CAAC;gBACR,MAAM,IAAI,KAAK,CAAC,qBAAqB,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;aAC3D;SACD;KACD;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AA3BD,4EA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { ISummaryTree, SummaryType } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Utility api to convert ISummaryTree to a summary tree where blob contents are only utf8 strings.\n * @param summary - Summary supplied by the runtime to upload.\n * @returns - Modified summary tree where the blob contents could be utf8 string only.\n */\nexport function convertSummaryToCreateNewSummary(summary: ISummaryTree): ISummaryTree {\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\tsummary.tree[key] = convertSummaryToCreateNewSummary(summaryObject);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tsummaryObject.content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"utf8\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn summary;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultTokenProvider.d.ts","sourceRoot":"","sources":["../src/defaultTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1D;;GAEG;AAEH,qBAAa,oBAAqB,YAAW,cAAc;
|
|
1
|
+
{"version":3,"file":"defaultTokenProvider.d.ts","sourceRoot":"","sources":["../src/defaultTokenProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1D;;GAEG;AAEH,qBAAa,oBAAqB,YAAW,cAAc;IAC9C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,MAAM;IAE3B,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IAO5C,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;CAMzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultTokenProvider.js","sourceRoot":"","sources":["../src/defaultTokenProvider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AAEH,MAAa,oBAAoB;
|
|
1
|
+
{"version":3,"file":"defaultTokenProvider.js","sourceRoot":"","sources":["../src/defaultTokenProvider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AAEH,MAAa,oBAAoB;IAChC,YAA6B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAErC,KAAK,CAAC,iBAAiB;QAC7B,OAAO;YACN,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;SACb,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,iBAAiB;QAC7B,OAAO;YACN,SAAS,EAAE,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;SACb,CAAC;IACH,CAAC;CACD;AAhBD,oDAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITokenProvider, ITokenResponse } from \"./tokens\";\n\n/**\n * Default token provider in case the host does not provide one. It simply caches the provided jwt and returns it back.\n */\n\nexport class DefaultTokenProvider implements ITokenProvider {\n\tconstructor(private readonly jwt: string) {}\n\n\tpublic async fetchOrdererToken(): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tfromCache: true,\n\t\t\tjwt: this.jwt,\n\t\t};\n\t}\n\n\tpublic async fetchStorageToken(): Promise<ITokenResponse> {\n\t\treturn {\n\t\t\tfromCache: true,\n\t\t\tjwt: this.jwt,\n\t\t};\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../src/definitions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,MAAM,WAAW,oBAAoB;
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../src/definitions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,MAAM,WAAW,oBAAoB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,aAAa,CAAC;CAC5B"}
|
package/dist/definitions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../src/definitions.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\nexport interface ISnapshotTreeVersion {\n
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../src/definitions.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\nexport interface ISnapshotTreeVersion {\n\tid: string;\n\tsnapshotTree: ISnapshotTree;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaStorageService.d.ts","sourceRoot":"","sources":["../src/deltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"deltaStorageService.d.ts","sourceRoot":"","sources":["../src/deltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,OAAO,EACP,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OA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EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EAAE,YAAY;IAC1B,EAAE,EAAE,MAAM,GACR,OAAO,CAAC,kBAAkB,CAAC;CA0B9B"}
|
|
@@ -78,7 +78,10 @@ class DeltaStorageService {
|
|
|
78
78
|
}, async (event) => {
|
|
79
79
|
const restWrapper = await this.getRestWrapper();
|
|
80
80
|
const url = this.getDeltaStorageUrl();
|
|
81
|
-
const response = await restWrapper.get(url, {
|
|
81
|
+
const response = await restWrapper.get(url, {
|
|
82
|
+
from: from - 1,
|
|
83
|
+
to,
|
|
84
|
+
});
|
|
82
85
|
event.end({
|
|
83
86
|
count: response.length,
|
|
84
87
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltaStorageService.js","sourceRoot":"","sources":["../src/deltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,+DAA4F;AAE5F,qEAAwF;AAIxF,MAAM,cAAc,GAAG,IAAI,CAAC,CAAC,+CAA+C;AAE5E;;GAEG;AACH,MAAa,2BAA2B;
|
|
1
|
+
{"version":3,"file":"deltaStorageService.js","sourceRoot":"","sources":["../src/deltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,+DAA4F;AAE5F,qEAAwF;AAIxF,MAAM,cAAc,GAAG,IAAI,CAAC,CAAC,+CAA+C;AAE5E;;GAEG;AACH,MAAa,2BAA2B;IACvC,YACkB,QAAgB,EAChB,EAAU,EACV,mBAAyC,EACzC,sBAA8C,EAC9C,MAAwB;QAJxB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,OAAE,GAAF,EAAE,CAAQ;QACV,wBAAmB,GAAnB,mBAAmB,CAAsB;QACzC,2BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,WAAM,GAAN,MAAM,CAAkB;QAGlC,eAAU,GAAuB,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC;IAF7E,CAAC;IAIJ,aAAa,CACZ,IAAY,EACZ,EAAsB,EACtB,WAAyB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,CAAC;QACjB,CAAC,CACD,CAAC;QAEF,oGAAoG;QACpG,4GAA4G;QAC5G,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IAChD,CAAC;CACD;AAxCD,kDAwCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDeltaStorageService,\n\tIDocumentDeltaStorageService,\n\tIDeltasFetchResult,\n\tIStream,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { readAndParse, requestOps, emptyMessageStream } from \"@fluidframework/driver-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { PerformanceEvent, TelemetryNullLogger } from \"@fluidframework/telemetry-utils\";\nimport { RestWrapper } from \"@fluidframework/server-services-client\";\nimport { DocumentStorageService } from \"./documentStorageService\";\n\nconst MaxBatchDeltas = 2000; // Maximum number of ops we can fetch at a time\n\n/**\n * Storage service limited to only being able to fetch documents for a specific document\n */\nexport class DocumentDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly deltaStorageService: IDeltaStorageService,\n\t\tprivate readonly documentStorageService: DocumentStorageService,\n\t\tprivate readonly logger: ITelemetryLogger,\n\t) {}\n\n\tprivate logtailSha: string | undefined = this.documentStorageService.logTailSha;\n\n\tfetchMessages(\n\t\tfrom: number,\n\t\tto: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t\tfetchReason?: string,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\tif (cachedOnly) {\n\t\t\treturn emptyMessageStream;\n\t\t}\n\t\treturn requestOps(\n\t\t\tthis.getCore.bind(this),\n\t\t\t// Staging: starting with no concurrency, listening for feedback first.\n\t\t\t// In future releases we will switch to actual concurrency\n\t\t\t1, // concurrency\n\t\t\tfrom, // inclusive\n\t\t\tto, // exclusive\n\t\t\tMaxBatchDeltas,\n\t\t\tnew TelemetryNullLogger(),\n\t\t\tabortSignal,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate async getCore(from: number, to: number): Promise<IDeltasFetchResult> {\n\t\tconst opsFromLogTail = this.logtailSha\n\t\t\t? await readAndParse<ISequencedDocumentMessage[]>(\n\t\t\t\t\tthis.documentStorageService,\n\t\t\t\t\tthis.logtailSha,\n\t\t\t )\n\t\t\t: [];\n\n\t\tthis.logtailSha = undefined;\n\t\tif (opsFromLogTail.length > 0) {\n\t\t\ttry {\n\t\t\t\tconst messages = opsFromLogTail.filter((op, i) => {\n\t\t\t\t\t// throw if the sequence numbers in logtail are not contiguous\n\t\t\t\t\tif (i > 0 && op.sequenceNumber !== opsFromLogTail[i - 1].sequenceNumber + 1) {\n\t\t\t\t\t\tthrow new Error(\"Log tail ops are not contiguous\");\n\t\t\t\t\t}\n\t\t\t\t\treturn op.sequenceNumber >= from;\n\t\t\t\t});\n\n\t\t\t\tif (messages.length > 0 && messages[0].sequenceNumber === from) {\n\t\t\t\t\treturn { messages, partialResult: true };\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"LogTailReadError\" }, error);\n\t\t\t}\n\t\t}\n\n\t\treturn this.deltaStorageService.get(this.tenantId, this.id, from, to);\n\t}\n}\n\n/**\n * Provides access to the underlying delta storage on the server for routerlicious driver.\n */\nexport class DeltaStorageService implements IDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly url: string,\n\t\tprivate readonly restWrapper: RestWrapper,\n\t\tprivate readonly logger: ITelemetryLogger,\n\t\tprivate readonly getRestWrapper: () => Promise<RestWrapper> = async () => this.restWrapper,\n\t\tprivate readonly getDeltaStorageUrl: () => string = () => this.url,\n\t) {}\n\n\tpublic async get(\n\t\ttenantId: string,\n\t\tid: string,\n\t\tfrom: number, // inclusive\n\t\tto: number, // exclusive\n\t): Promise<IDeltasFetchResult> {\n\t\tconst ops = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getDeltas\",\n\t\t\t\tfrom,\n\t\t\t\tto,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst restWrapper = await this.getRestWrapper();\n\t\t\t\tconst url = this.getDeltaStorageUrl();\n\t\t\t\tconst response = await restWrapper.get<ISequencedDocumentMessage[]>(url, {\n\t\t\t\t\tfrom: from - 1,\n\t\t\t\t\tto,\n\t\t\t\t});\n\t\t\t\tevent.end({\n\t\t\t\t\tcount: response.length,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\n\t\t// It is assumed that server always returns all the ops that it has in the range that was requested.\n\t\t// This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n\t\treturn { messages: ops, partialResult: false };\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAY,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,EAAE,IAAI,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAMnE;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,uBAAuB;
|
|
1
|
+
{"version":3,"file":"documentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAY,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,EAAE,IAAI,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAMnE;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,uBAAuB;WACnD,MAAM,CACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,EAAE,EAAE,OAAO,oBAAoB,EAC/B,MAAM,EAAE,OAAO,EACf,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,gBAAgB,EACxB,SAAS,SAAQ,GACf,OAAO,CAAC,wBAAwB,CAAC;IAqCpC;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,UAAO,GAAG,eAAe;CAQ3F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentDeltaConnection.js","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6DAAsE;AAItE,6CAA4E;AAC5E,qDAA+D;AAE/D,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAElE;;GAEG;AACH,MAAa,2BAA4B,SAAQ,qCAAuB;
|
|
1
|
+
{"version":3,"file":"documentDeltaConnection.js","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6DAAsE;AAItE,6CAA4E;AAC5E,qDAA+D;AAE/D,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAElE;;GAEG;AACH,MAAa,2BA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uCAA0B,EAAC,KAAyB,EAAE,OAAO,CAAC;YAChE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;CACD;AA1DD,kEA0DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base\";\nimport { IAnyDriverError, IDocumentDeltaConnection } from \"@fluidframework/driver-definitions\";\nimport { IClient, IConnect } from \"@fluidframework/protocol-definitions\";\nimport type { io as SocketIOClientStatic } from \"socket.io-client\";\nimport { errorObjectFromSocketError, IR11sSocketError } from \"./errorUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\nconst protocolVersions = [\"^0.4.0\", \"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\n\n/**\n * Wrapper over the shared one for driver specific translation.\n */\nexport class R11sDocumentDeltaConnection extends DocumentDeltaConnection {\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tid: string,\n\t\ttoken: string | null,\n\t\tio: typeof SocketIOClientStatic,\n\t\tclient: IClient,\n\t\turl: string,\n\t\tlogger: ITelemetryLogger,\n\t\ttimeoutMs = 20000,\n\t): Promise<IDocumentDeltaConnection> {\n\t\tconst socket = io(url, {\n\t\t\tquery: {\n\t\t\t\tdocumentId: id,\n\t\t\t\ttenantId,\n\t\t\t},\n\t\t\treconnection: false,\n\t\t\t// Default to websocket connection, with long-polling disabled\n\t\t\ttransports: [\"websocket\"],\n\t\t\ttimeout: timeoutMs,\n\t\t});\n\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: protocolVersions,\n\t\t\trelayUserAgent: [client.details.environment, ` driverVersion:${driverVersion}`].join(\n\t\t\t\t\";\",\n\t\t\t),\n\t\t};\n\n\t\t// TODO: expose to host at factory level\n\t\tconst enableLongPollingDowngrades = true;\n\t\tconst deltaConnection = new R11sDocumentDeltaConnection(\n\t\t\tsocket,\n\t\t\tid,\n\t\t\tlogger,\n\t\t\tenableLongPollingDowngrades,\n\t\t);\n\n\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\treturn deltaConnection;\n\t}\n\n\t/**\n\t * Error raising for socket.io issues\n\t */\n\tprotected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {\n\t\t// Note: we suspect the incoming error object is either:\n\t\t// - a socketError: add it to the R11sError object for driver to be able to parse it and reason over it.\n\t\t// - anything else: let base class handle it\n\t\treturn canRetry && Number.isInteger(error?.code) && typeof error?.message === \"string\"\n\t\t\t? errorObjectFromSocketError(error as IR11sSocketError, handler)\n\t\t\t: super.createErrorObject(handler, error, canRetry);\n\t}\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import * as api from "@fluidframework/driver-definitions";
|
|
|
6
6
|
import { IClient } from "@fluidframework/protocol-definitions";
|
|
7
7
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
8
8
|
import { ITokenProvider } from "./tokens";
|
|
9
|
+
import { RouterliciousOrdererRestWrapper } from "./restWrapper";
|
|
9
10
|
import { IRouterliciousDriverPolicies } from "./policies";
|
|
10
11
|
import { ICache } from "./cache";
|
|
11
12
|
import { ISnapshotTreeVersion } from "./definitions";
|
|
@@ -23,6 +24,8 @@ export declare class DocumentService implements api.IDocumentService {
|
|
|
23
24
|
protected tokenProvider: ITokenProvider;
|
|
24
25
|
protected tenantId: string;
|
|
25
26
|
protected documentId: string;
|
|
27
|
+
protected ordererRestWrapper: RouterliciousOrdererRestWrapper;
|
|
28
|
+
private readonly documentStorageServicePolicies;
|
|
26
29
|
private readonly driverPolicies;
|
|
27
30
|
private readonly blobCache;
|
|
28
31
|
private readonly snapshotTreeCache;
|
|
@@ -31,9 +34,8 @@ export declare class DocumentService implements api.IDocumentService {
|
|
|
31
34
|
private discoverP;
|
|
32
35
|
private storageManager;
|
|
33
36
|
private noCacheStorageManager;
|
|
34
|
-
private ordererRestWrapper;
|
|
35
37
|
get resolvedUrl(): api.IResolvedUrl;
|
|
36
|
-
constructor(_resolvedUrl: api.IResolvedUrl, ordererUrl: string, deltaStorageUrl: string, deltaStreamUrl: string, storageUrl: string, logger: ITelemetryLogger, tokenProvider: ITokenProvider, tenantId: string, documentId: string, driverPolicies: IRouterliciousDriverPolicies, blobCache: ICache<ArrayBufferLike>, snapshotTreeCache: ICache<ISnapshotTreeVersion>, discoverFluidResolvedUrl: () => Promise<api.IFluidResolvedUrl>);
|
|
38
|
+
constructor(_resolvedUrl: api.IResolvedUrl, ordererUrl: string, deltaStorageUrl: string, deltaStreamUrl: string, storageUrl: string, logger: ITelemetryLogger, tokenProvider: ITokenProvider, tenantId: string, documentId: string, ordererRestWrapper: RouterliciousOrdererRestWrapper, documentStorageServicePolicies: api.IDocumentStorageServicePolicies, driverPolicies: IRouterliciousDriverPolicies, blobCache: ICache<ArrayBufferLike>, snapshotTreeCache: ICache<ISnapshotTreeVersion>, discoverFluidResolvedUrl: () => Promise<api.IFluidResolvedUrl>);
|
|
37
39
|
private documentStorageService;
|
|
38
40
|
dispose(): void;
|
|
39
41
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentService.d.ts","sourceRoot":"","sources":["../src/documentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,GAAG,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"documentService.d.ts","sourceRoot":"","sources":["../src/documentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,GAAG,MAAM,oCAAoC,CAAC;AAG1D,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAI/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAKtE,OA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B,kBAAkB,EAAE,+BAA+B,EAC5C,8BAA8B,EAAE,GAAG,CAAC,+BAA+B,EACnE,cAAc,EAAE,4BAA4B,EAC5C,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,EAClC,iBAAiB,EAAE,MAAM,CAAC,oBAAoB,CAAC,EAC/C,wBAAwB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAGhF,OAAO,CAAC,sBAAsB,CAAqC;IAE5D,OAAO;IAEd;;;;OAIG;IACU,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;IA6DrE;;;;OAIG;IACU,qBAAqB,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;IAwC/E;;;;OAIG;IACU,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IA6EzF;;OAEG;YACW,gBAAgB;YAahB,oBAAoB;IASlC;;OAEG;IACH,OAAO,CAAC,iCAAiC;CAsBzC"}
|
package/dist/documentService.js
CHANGED
|
@@ -3,32 +3,13 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
6
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
8
|
};
|
|
28
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
10
|
exports.DocumentService = void 0;
|
|
30
11
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
31
|
-
const
|
|
12
|
+
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
32
13
|
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
33
14
|
const server_services_client_1 = require("@fluidframework/server-services-client");
|
|
34
15
|
const socket_io_client_1 = __importDefault(require("socket.io-client"));
|
|
@@ -38,6 +19,7 @@ const documentStorageService_1 = require("./documentStorageService");
|
|
|
38
19
|
const documentDeltaConnection_1 = require("./documentDeltaConnection");
|
|
39
20
|
const nullBlobStorageService_1 = require("./nullBlobStorageService");
|
|
40
21
|
const restWrapper_1 = require("./restWrapper");
|
|
22
|
+
const packageVersion_1 = require("./packageVersion");
|
|
41
23
|
/**
|
|
42
24
|
* Amount of time between discoveries within which we don't need to rediscover on re-connect.
|
|
43
25
|
* Currently, R11s defines session length at 10 minutes. To avoid any weird unknown edge-cases though,
|
|
@@ -51,7 +33,7 @@ const RediscoverAfterTimeSinceDiscoveryMs = 5 * 60000; // 5 minute
|
|
|
51
33
|
*/
|
|
52
34
|
// eslint-disable-next-line import/namespace
|
|
53
35
|
class DocumentService {
|
|
54
|
-
constructor(_resolvedUrl, ordererUrl, deltaStorageUrl, deltaStreamUrl, storageUrl, logger, tokenProvider, tenantId, documentId, driverPolicies, blobCache, snapshotTreeCache, discoverFluidResolvedUrl) {
|
|
36
|
+
constructor(_resolvedUrl, ordererUrl, deltaStorageUrl, deltaStreamUrl, storageUrl, logger, tokenProvider, tenantId, documentId, ordererRestWrapper, documentStorageServicePolicies, driverPolicies, blobCache, snapshotTreeCache, discoverFluidResolvedUrl) {
|
|
55
37
|
this._resolvedUrl = _resolvedUrl;
|
|
56
38
|
this.ordererUrl = ordererUrl;
|
|
57
39
|
this.deltaStorageUrl = deltaStorageUrl;
|
|
@@ -61,6 +43,8 @@ class DocumentService {
|
|
|
61
43
|
this.tokenProvider = tokenProvider;
|
|
62
44
|
this.tenantId = tenantId;
|
|
63
45
|
this.documentId = documentId;
|
|
46
|
+
this.ordererRestWrapper = ordererRestWrapper;
|
|
47
|
+
this.documentStorageServicePolicies = documentStorageServicePolicies;
|
|
64
48
|
this.driverPolicies = driverPolicies;
|
|
65
49
|
this.blobCache = blobCache;
|
|
66
50
|
this.snapshotTreeCache = snapshotTreeCache;
|
|
@@ -88,7 +72,9 @@ class DocumentService {
|
|
|
88
72
|
if (shouldUpdateDiscoveredSessionInfo) {
|
|
89
73
|
await this.refreshDiscovery();
|
|
90
74
|
}
|
|
91
|
-
if (!this.storageManager ||
|
|
75
|
+
if (!this.storageManager ||
|
|
76
|
+
!this.noCacheStorageManager ||
|
|
77
|
+
shouldUpdateDiscoveredSessionInfo) {
|
|
92
78
|
const rateLimiter = new driver_utils_1.RateLimiter(this.driverPolicies.maxConcurrentStorageRequests);
|
|
93
79
|
const storageRestWrapper = await restWrapper_1.RouterliciousStorageRestWrapper.load(this.tenantId, this.documentId, this.tokenProvider, this.logger, rateLimiter, this.driverPolicies.enableRestLess, this.storageUrl);
|
|
94
80
|
const historian = new server_services_client_1.Historian(this.storageUrl, true, false, storageRestWrapper);
|
|
@@ -101,13 +87,7 @@ class DocumentService {
|
|
|
101
87
|
// Initialize storageManager and noCacheStorageManager
|
|
102
88
|
const storageManager = await getStorageManager();
|
|
103
89
|
const noCacheStorageManager = await getStorageManager(true);
|
|
104
|
-
|
|
105
|
-
caching: this.driverPolicies.enablePrefetch
|
|
106
|
-
? api.LoaderCachingPolicy.Prefetch
|
|
107
|
-
: api.LoaderCachingPolicy.NoCaching,
|
|
108
|
-
minBlobSize: this.driverPolicies.aggregateBlobsSmallerThanBytes,
|
|
109
|
-
};
|
|
110
|
-
this.documentStorageService = new documentStorageService_1.DocumentStorageService(this.documentId, storageManager, this.logger, documentStorageServicePolicies, this.driverPolicies, this.blobCache, this.snapshotTreeCache, noCacheStorageManager, getStorageManager);
|
|
90
|
+
this.documentStorageService = new documentStorageService_1.DocumentStorageService(this.documentId, storageManager, this.logger, this.documentStorageServicePolicies, this.driverPolicies, this.blobCache, this.snapshotTreeCache, noCacheStorageManager, getStorageManager);
|
|
111
91
|
return this.documentStorageService;
|
|
112
92
|
}
|
|
113
93
|
/**
|
|
@@ -122,8 +102,6 @@ class DocumentService {
|
|
|
122
102
|
const shouldUpdateDiscoveredSessionInfo = this.shouldUpdateDiscoveredSessionInfo();
|
|
123
103
|
if (shouldUpdateDiscoveredSessionInfo) {
|
|
124
104
|
await this.refreshDiscovery();
|
|
125
|
-
}
|
|
126
|
-
if (!this.ordererRestWrapper || shouldUpdateDiscoveredSessionInfo) {
|
|
127
105
|
const rateLimiter = new driver_utils_1.RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);
|
|
128
106
|
this.ordererRestWrapper = await restWrapper_1.RouterliciousOrdererRestWrapper.load(this.tenantId, this.documentId, this.tokenProvider, this.logger, rateLimiter, this.driverPolicies.enableRestLess);
|
|
129
107
|
}
|
|
@@ -140,18 +118,27 @@ class DocumentService {
|
|
|
140
118
|
*/
|
|
141
119
|
async connectToDeltaStream(client) {
|
|
142
120
|
const connect = async (refreshToken) => {
|
|
121
|
+
let ordererToken = this.ordererRestWrapper.getToken();
|
|
143
122
|
if (this.shouldUpdateDiscoveredSessionInfo()) {
|
|
144
123
|
await this.refreshDiscovery();
|
|
145
124
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
125
|
+
if (refreshToken) {
|
|
126
|
+
ordererToken = await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
|
|
127
|
+
eventName: "GetDeltaStreamToken",
|
|
128
|
+
docId: this.documentId,
|
|
129
|
+
details: JSON.stringify({
|
|
130
|
+
refreshToken,
|
|
131
|
+
}),
|
|
132
|
+
}, async () => this.tokenProvider
|
|
133
|
+
.fetchOrdererToken(this.tenantId, this.documentId, refreshToken)
|
|
134
|
+
.then((newOrdererToken) => {
|
|
135
|
+
this.ordererRestWrapper.setToken(newOrdererToken);
|
|
136
|
+
return newOrdererToken;
|
|
137
|
+
}, (error) => {
|
|
138
|
+
const tokenError = (0, telemetry_utils_1.wrapError)(error, (errorMessage) => new driver_utils_1.NetworkErrorBasic(`The Host-provided token fetcher threw an error`, driver_definitions_1.DriverErrorType.fetchTokenError, (0, driver_utils_1.canRetryOnError)(error), { errorMessage, driverVersion: packageVersion_1.pkgVersion }));
|
|
139
|
+
throw tokenError;
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
155
142
|
return telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
|
|
156
143
|
eventName: "ConnectToDeltaStream",
|
|
157
144
|
docId: this.documentId,
|
|
@@ -205,7 +192,7 @@ class DocumentService {
|
|
|
205
192
|
// without re-doing discovery on the next attempt to connect.
|
|
206
193
|
// Disconnect event is not so reliable in local testing. To ensure re-discovery when necessary,
|
|
207
194
|
// re-discover if enough time has passed since last discovery.
|
|
208
|
-
const pastLastDiscoveryTimeThreshold =
|
|
195
|
+
const pastLastDiscoveryTimeThreshold = now - this.lastDiscoveredAt > RediscoverAfterTimeSinceDiscoveryMs;
|
|
209
196
|
if (pastLastDiscoveryTimeThreshold) {
|
|
210
197
|
// Reset discover promise and refresh discovery.
|
|
211
198
|
this.lastDiscoveredAt = Date.now();
|
|
@@ -1 +1 @@
|
|
|
1
|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QACxD,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC,SAAS,CAAC,eAAe,CAAC;QAClE,IAAI,CAAC,cAAc,GAAG,gBAAgB,CAAC,SAAS,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC;IACvF,CAAC;IAED;;OAEG;IACK,iCAAiC;QACrC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE;YACtC,OAAO,KAAK,CAAC;SAChB;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,oGAAoG;QACpG,6DAA6D;QAC7D,+FAA+F;QAC/F,8DAA8D;QAC9D,MAAM,8BAA8B,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,mCAAmC,CAAC;QAC3G,IAAI,8BAA8B,EAAE;YAChC,gDAAgD;YAChD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;YAC3B,IAAI,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;gBAC/B,oEAAoE;gBACpE,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;SACN;QACD,OAAO,8BAA8B,CAAC;IAC1C,CAAC;CACJ;AAnQD,0CAmQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport * as api from \"@fluidframework/driver-definitions\";\nimport { RateLimiter } from \"@fluidframework/driver-utils\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { GitManager, Historian, RestWrapper } from \"@fluidframework/server-services-client\";\nimport io from \"socket.io-client\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { DeltaStorageService, DocumentDeltaStorageService } from \"./deltaStorageService\";\nimport { DocumentStorageService } from \"./documentStorageService\";\nimport { R11sDocumentDeltaConnection } from \"./documentDeltaConnection\";\nimport { NullBlobStorageService } from \"./nullBlobStorageService\";\nimport { ITokenProvider } from \"./tokens\";\nimport { RouterliciousOrdererRestWrapper, RouterliciousStorageRestWrapper } from \"./restWrapper\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache } from \"./cache\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\n\n/**\n * Amount of time between discoveries within which we don't need to rediscover on re-connect.\n * Currently, R11s defines session length at 10 minutes. To avoid any weird unknown edge-cases though,\n * we set the limit to 5 minutes here.\n * In the future, we likely want to retrieve this information from service's \"inactive session\" definition.\n */\nconst RediscoverAfterTimeSinceDiscoveryMs = 5 * 60000; // 5 minute\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients.\n */\n// eslint-disable-next-line import/namespace\nexport class DocumentService implements api.IDocumentService {\n private lastDiscoveredAt: number = Date.now();\n private discoverP: Promise<void> | undefined;\n\n private storageManager: GitManager | undefined;\n private noCacheStorageManager: GitManager | undefined;\n private ordererRestWrapper: RestWrapper | undefined;\n\n public get resolvedUrl() {\n return this._resolvedUrl;\n }\n\n constructor(\n private _resolvedUrl: api.IResolvedUrl,\n protected ordererUrl: string,\n private deltaStorageUrl: string,\n private deltaStreamUrl: string,\n private storageUrl: string,\n private readonly logger: ITelemetryLogger,\n protected tokenProvider: ITokenProvider,\n protected tenantId: string,\n protected documentId: string,\n private readonly driverPolicies: IRouterliciousDriverPolicies,\n private readonly blobCache: ICache<ArrayBufferLike>,\n private readonly snapshotTreeCache: ICache<ISnapshotTreeVersion>,\n private readonly discoverFluidResolvedUrl: () => Promise<api.IFluidResolvedUrl>,\n ) {\n }\n\n private documentStorageService: DocumentStorageService | undefined;\n\n public dispose() { }\n\n /**\n * Connects to a storage endpoint for snapshot service.\n *\n * @returns returns the document storage service for routerlicious driver.\n */\n public async connectToStorage(): Promise<api.IDocumentStorageService> {\n if (this.documentStorageService !== undefined) {\n return this.documentStorageService;\n }\n\n if (this.storageUrl === undefined) {\n return new NullBlobStorageService();\n }\n\n const getStorageManager = async (disableCache?: boolean): Promise<GitManager> => {\n const shouldUpdateDiscoveredSessionInfo = this.shouldUpdateDiscoveredSessionInfo();\n if (shouldUpdateDiscoveredSessionInfo) {\n await this.refreshDiscovery();\n }\n if (!this.storageManager || !this.noCacheStorageManager || shouldUpdateDiscoveredSessionInfo) {\n const rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentStorageRequests);\n const storageRestWrapper = await RouterliciousStorageRestWrapper.load(\n this.tenantId,\n this.documentId,\n this.tokenProvider,\n this.logger,\n rateLimiter,\n this.driverPolicies.enableRestLess,\n this.storageUrl,\n );\n const historian = new Historian(\n this.storageUrl,\n true,\n false,\n storageRestWrapper);\n this.storageManager = new GitManager(historian);\n const noCacheHistorian = new Historian(\n this.storageUrl,\n true,\n true,\n storageRestWrapper);\n this.noCacheStorageManager = new GitManager(noCacheHistorian);\n }\n\n return disableCache ? this.noCacheStorageManager : this.storageManager;\n };\n // Initialize storageManager and noCacheStorageManager\n const storageManager = await getStorageManager();\n const noCacheStorageManager = await getStorageManager(true);\n const documentStorageServicePolicies: api.IDocumentStorageServicePolicies = {\n caching: this.driverPolicies.enablePrefetch\n ? api.LoaderCachingPolicy.Prefetch\n : api.LoaderCachingPolicy.NoCaching,\n minBlobSize: this.driverPolicies.aggregateBlobsSmallerThanBytes,\n };\n\n this.documentStorageService = new DocumentStorageService(\n this.documentId,\n storageManager,\n this.logger,\n documentStorageServicePolicies,\n this.driverPolicies,\n this.blobCache,\n this.snapshotTreeCache,\n noCacheStorageManager,\n getStorageManager);\n return this.documentStorageService;\n }\n\n /**\n * Connects to a delta storage endpoint for getting ops between a range.\n *\n * @returns returns the document delta storage service for routerlicious driver.\n */\n public async connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService> {\n await this.connectToStorage();\n assert(!!this.documentStorageService, 0x0b1 /* \"Storage service not initialized\" */);\n\n const getRestWrapper = async (): Promise<RestWrapper> => {\n const shouldUpdateDiscoveredSessionInfo = this.shouldUpdateDiscoveredSessionInfo();\n if (shouldUpdateDiscoveredSessionInfo) {\n await this.refreshDiscovery();\n }\n if (!this.ordererRestWrapper || shouldUpdateDiscoveredSessionInfo) {\n const rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n this.ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n this.tenantId,\n this.documentId,\n this.tokenProvider,\n this.logger,\n rateLimiter,\n this.driverPolicies.enableRestLess,\n );\n }\n return this.ordererRestWrapper;\n };\n const restWrapper = await getRestWrapper();\n const deltaStorageService = new DeltaStorageService(\n this.deltaStorageUrl,\n restWrapper,\n this.logger,\n getRestWrapper,\n () => this.deltaStorageUrl,\n );\n return new DocumentDeltaStorageService(\n this.tenantId,\n this.documentId,\n deltaStorageService,\n this.documentStorageService,\n this.logger,\n );\n }\n\n /**\n * Connects to a delta stream endpoint for emitting ops.\n *\n * @returns returns the document delta stream service for routerlicious driver.\n */\n public async connectToDeltaStream(client: IClient): Promise<api.IDocumentDeltaConnection> {\n const connect = async (refreshToken?: boolean) => {\n if (this.shouldUpdateDiscoveredSessionInfo()) {\n await this.refreshDiscovery();\n }\n\n const ordererToken = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"GetDeltaStreamToken\",\n docId: this.documentId,\n details: JSON.stringify({\n refreshToken,\n }),\n },\n async () => {\n return this.tokenProvider.fetchOrdererToken(\n this.tenantId,\n this.documentId,\n refreshToken,\n );\n }\n );\n\n return PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"ConnectToDeltaStream\",\n docId: this.documentId,\n },\n async () => {\n return R11sDocumentDeltaConnection.create(\n this.tenantId,\n this.documentId,\n ordererToken.jwt,\n io,\n client,\n this.deltaStreamUrl,\n this.logger,\n );\n }\n );\n };\n\n // Attempt to establish connection.\n // Retry with new token on authorization error; otherwise, allow container layer to handle.\n try {\n const connection = await connect();\n return connection;\n } catch (error: any) {\n if (error?.statusCode === 401) {\n // Fetch new token and retry once,\n // otherwise 401 will be bubbled up as non-retriable AuthorizationError.\n return connect(true /* refreshToken */);\n }\n throw error;\n }\n }\n\n /**\n * Re-discover session URLs if necessary.\n */\n private async refreshDiscovery(): Promise<void> {\n if (!this.discoverP) {\n this.discoverP = PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"RefreshDiscovery\",\n },\n async () => this.refreshDiscoveryCore(),\n );\n }\n return this.discoverP;\n }\n\n private async refreshDiscoveryCore(): Promise<void> {\n const fluidResolvedUrl = await this.discoverFluidResolvedUrl();\n this._resolvedUrl = fluidResolvedUrl;\n this.storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n this.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n this.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n this.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || this.ordererUrl;\n }\n\n /**\n * Whether enough time has passed since last disconnect to warrant a new discovery call on reconnect.\n */\n private shouldUpdateDiscoveredSessionInfo(): boolean {\n if (!this.driverPolicies.enableDiscovery) {\n return false;\n }\n const now = Date.now();\n // When connection is disconnected, we cannot know if session has moved or document has been deleted\n // without re-doing discovery on the next attempt to connect.\n // Disconnect event is not so reliable in local testing. To ensure re-discovery when necessary,\n // re-discover if enough time has passed since last discovery.\n const pastLastDiscoveryTimeThreshold = (now - this.lastDiscoveredAt) > RediscoverAfterTimeSinceDiscoveryMs;\n if (pastLastDiscoveryTimeThreshold) {\n // Reset discover promise and refresh discovery.\n this.lastDiscoveredAt = Date.now();\n this.discoverP = undefined;\n this.refreshDiscovery().catch(() => {\n // Undo discovery time set on failure, so that next check refreshes.\n this.lastDiscoveredAt = 0;\n });\n }\n return pastLastDiscoveryTimeThreshold;\n }\n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;CACD;AApRD,0CAoRC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport * as api from \"@fluidframework/driver-definitions\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { RateLimiter, NetworkErrorBasic, canRetryOnError } from \"@fluidframework/driver-utils\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { GitManager, Historian, RestWrapper } from \"@fluidframework/server-services-client\";\nimport io from \"socket.io-client\";\nimport { PerformanceEvent, wrapError } from \"@fluidframework/telemetry-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { DeltaStorageService, DocumentDeltaStorageService } from \"./deltaStorageService\";\nimport { DocumentStorageService } from \"./documentStorageService\";\nimport { R11sDocumentDeltaConnection } from \"./documentDeltaConnection\";\nimport { NullBlobStorageService } from \"./nullBlobStorageService\";\nimport { ITokenProvider } from \"./tokens\";\nimport { RouterliciousOrdererRestWrapper, RouterliciousStorageRestWrapper } from \"./restWrapper\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache } from \"./cache\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * Amount of time between discoveries within which we don't need to rediscover on re-connect.\n * Currently, R11s defines session length at 10 minutes. To avoid any weird unknown edge-cases though,\n * we set the limit to 5 minutes here.\n * In the future, we likely want to retrieve this information from service's \"inactive session\" definition.\n */\nconst RediscoverAfterTimeSinceDiscoveryMs = 5 * 60000; // 5 minute\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients.\n */\n// eslint-disable-next-line import/namespace\nexport class DocumentService implements api.IDocumentService {\n\tprivate lastDiscoveredAt: number = Date.now();\n\tprivate discoverP: Promise<void> | undefined;\n\n\tprivate storageManager: GitManager | undefined;\n\tprivate noCacheStorageManager: GitManager | undefined;\n\n\tpublic get resolvedUrl() {\n\t\treturn this._resolvedUrl;\n\t}\n\n\tconstructor(\n\t\tprivate _resolvedUrl: api.IResolvedUrl,\n\t\tprotected ordererUrl: string,\n\t\tprivate deltaStorageUrl: string,\n\t\tprivate deltaStreamUrl: string,\n\t\tprivate storageUrl: string,\n\t\tprivate readonly logger: ITelemetryLogger,\n\t\tprotected tokenProvider: ITokenProvider,\n\t\tprotected tenantId: string,\n\t\tprotected documentId: string,\n\t\tprotected ordererRestWrapper: RouterliciousOrdererRestWrapper,\n\t\tprivate readonly documentStorageServicePolicies: api.IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike>,\n\t\tprivate readonly snapshotTreeCache: ICache<ISnapshotTreeVersion>,\n\t\tprivate readonly discoverFluidResolvedUrl: () => Promise<api.IFluidResolvedUrl>,\n\t) {}\n\n\tprivate documentStorageService: DocumentStorageService | undefined;\n\n\tpublic dispose() {}\n\n\t/**\n\t * Connects to a storage endpoint for snapshot service.\n\t *\n\t * @returns returns the document storage service for routerlicious driver.\n\t */\n\tpublic async connectToStorage(): Promise<api.IDocumentStorageService> {\n\t\tif (this.documentStorageService !== undefined) {\n\t\t\treturn this.documentStorageService;\n\t\t}\n\n\t\tif (this.storageUrl === undefined) {\n\t\t\treturn new NullBlobStorageService();\n\t\t}\n\n\t\tconst getStorageManager = async (disableCache?: boolean): Promise<GitManager> => {\n\t\t\tconst shouldUpdateDiscoveredSessionInfo = this.shouldUpdateDiscoveredSessionInfo();\n\t\t\tif (shouldUpdateDiscoveredSessionInfo) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!this.storageManager ||\n\t\t\t\t!this.noCacheStorageManager ||\n\t\t\t\tshouldUpdateDiscoveredSessionInfo\n\t\t\t) {\n\t\t\t\tconst rateLimiter = new RateLimiter(\n\t\t\t\t\tthis.driverPolicies.maxConcurrentStorageRequests,\n\t\t\t\t);\n\t\t\t\tconst storageRestWrapper = await RouterliciousStorageRestWrapper.load(\n\t\t\t\t\tthis.tenantId,\n\t\t\t\t\tthis.documentId,\n\t\t\t\t\tthis.tokenProvider,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\trateLimiter,\n\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t\tthis.storageUrl,\n\t\t\t\t);\n\t\t\t\tconst historian = new Historian(this.storageUrl, true, false, storageRestWrapper);\n\t\t\t\tthis.storageManager = new GitManager(historian);\n\t\t\t\tconst noCacheHistorian = new Historian(\n\t\t\t\t\tthis.storageUrl,\n\t\t\t\t\ttrue,\n\t\t\t\t\ttrue,\n\t\t\t\t\tstorageRestWrapper,\n\t\t\t\t);\n\t\t\t\tthis.noCacheStorageManager = new GitManager(noCacheHistorian);\n\t\t\t}\n\n\t\t\treturn disableCache ? this.noCacheStorageManager : this.storageManager;\n\t\t};\n\t\t// Initialize storageManager and noCacheStorageManager\n\t\tconst storageManager = await getStorageManager();\n\t\tconst noCacheStorageManager = await getStorageManager(true);\n\t\tthis.documentStorageService = new DocumentStorageService(\n\t\t\tthis.documentId,\n\t\t\tstorageManager,\n\t\t\tthis.logger,\n\t\t\tthis.documentStorageServicePolicies,\n\t\t\tthis.driverPolicies,\n\t\t\tthis.blobCache,\n\t\t\tthis.snapshotTreeCache,\n\t\t\tnoCacheStorageManager,\n\t\t\tgetStorageManager,\n\t\t);\n\t\treturn this.documentStorageService;\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint for getting ops between a range.\n\t *\n\t * @returns returns the document delta storage service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService> {\n\t\tawait this.connectToStorage();\n\t\tassert(!!this.documentStorageService, 0x0b1 /* \"Storage service not initialized\" */);\n\n\t\tconst getRestWrapper = async (): Promise<RestWrapper> => {\n\t\t\tconst shouldUpdateDiscoveredSessionInfo = this.shouldUpdateDiscoveredSessionInfo();\n\n\t\t\tif (shouldUpdateDiscoveredSessionInfo) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t\tconst rateLimiter = new RateLimiter(\n\t\t\t\t\tthis.driverPolicies.maxConcurrentOrdererRequests,\n\t\t\t\t);\n\t\t\t\tthis.ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\t\t\tthis.tenantId,\n\t\t\t\t\tthis.documentId,\n\t\t\t\t\tthis.tokenProvider,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\trateLimiter,\n\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.ordererRestWrapper;\n\t\t};\n\t\tconst restWrapper = await getRestWrapper();\n\t\tconst deltaStorageService = new DeltaStorageService(\n\t\t\tthis.deltaStorageUrl,\n\t\t\trestWrapper,\n\t\t\tthis.logger,\n\t\t\tgetRestWrapper,\n\t\t\t() => this.deltaStorageUrl,\n\t\t);\n\t\treturn new DocumentDeltaStorageService(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tdeltaStorageService,\n\t\t\tthis.documentStorageService,\n\t\t\tthis.logger,\n\t\t);\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<api.IDocumentDeltaConnection> {\n\t\tconst connect = async (refreshToken?: boolean) => {\n\t\t\tlet ordererToken = this.ordererRestWrapper.getToken();\n\t\t\tif (this.shouldUpdateDiscoveredSessionInfo()) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t}\n\n\t\t\tif (refreshToken) {\n\t\t\t\tordererToken = await PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"GetDeltaStreamToken\",\n\t\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\trefreshToken,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tthis.tokenProvider\n\t\t\t\t\t\t\t.fetchOrdererToken(this.tenantId, this.documentId, refreshToken)\n\t\t\t\t\t\t\t.then(\n\t\t\t\t\t\t\t\t(newOrdererToken) => {\n\t\t\t\t\t\t\t\t\tthis.ordererRestWrapper.setToken(newOrdererToken);\n\t\t\t\t\t\t\t\t\treturn newOrdererToken;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\t\t\t\tDriverErrorType.fetchTokenError,\n\t\t\t\t\t\t\t\t\t\t\t\tcanRetryOnError(error),\n\t\t\t\t\t\t\t\t\t\t\t\t{ errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"ConnectToDeltaStream\",\n\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\treturn R11sDocumentDeltaConnection.create(\n\t\t\t\t\t\tthis.tenantId,\n\t\t\t\t\t\tthis.documentId,\n\t\t\t\t\t\tordererToken.jwt,\n\t\t\t\t\t\tio,\n\t\t\t\t\t\tclient,\n\t\t\t\t\t\tthis.deltaStreamUrl,\n\t\t\t\t\t\tthis.logger,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\t// Attempt to establish connection.\n\t\t// Retry with new token on authorization error; otherwise, allow container layer to handle.\n\t\ttry {\n\t\t\tconst connection = await connect();\n\t\t\treturn connection;\n\t\t} catch (error: any) {\n\t\t\tif (error?.statusCode === 401) {\n\t\t\t\t// Fetch new token and retry once,\n\t\t\t\t// otherwise 401 will be bubbled up as non-retriable AuthorizationError.\n\t\t\t\treturn connect(true /* refreshToken */);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Re-discover session URLs if necessary.\n\t */\n\tprivate async refreshDiscovery(): Promise<void> {\n\t\tif (!this.discoverP) {\n\t\t\tthis.discoverP = PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"RefreshDiscovery\",\n\t\t\t\t},\n\t\t\t\tasync () => this.refreshDiscoveryCore(),\n\t\t\t);\n\t\t}\n\t\treturn this.discoverP;\n\t}\n\n\tprivate async refreshDiscoveryCore(): Promise<void> {\n\t\tconst fluidResolvedUrl = await this.discoverFluidResolvedUrl();\n\t\tthis._resolvedUrl = fluidResolvedUrl;\n\t\tthis.storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n\t\tthis.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n\t\tthis.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n\t\tthis.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || this.ordererUrl;\n\t}\n\n\t/**\n\t * Whether enough time has passed since last disconnect to warrant a new discovery call on reconnect.\n\t */\n\tprivate shouldUpdateDiscoveredSessionInfo(): boolean {\n\t\tif (!this.driverPolicies.enableDiscovery) {\n\t\t\treturn false;\n\t\t}\n\t\tconst now = Date.now();\n\t\t// When connection is disconnected, we cannot know if session has moved or document has been deleted\n\t\t// without re-doing discovery on the next attempt to connect.\n\t\t// Disconnect event is not so reliable in local testing. To ensure re-discovery when necessary,\n\t\t// re-discover if enough time has passed since last discovery.\n\t\tconst pastLastDiscoveryTimeThreshold =\n\t\t\tnow - this.lastDiscoveredAt > RediscoverAfterTimeSinceDiscoveryMs;\n\t\tif (pastLastDiscoveryTimeThreshold) {\n\t\t\t// Reset discover promise and refresh discovery.\n\t\t\tthis.lastDiscoveredAt = Date.now();\n\t\t\tthis.discoverP = undefined;\n\t\t\tthis.refreshDiscovery().catch(() => {\n\t\t\t\t// Undo discovery time set on failure, so that next check refreshes.\n\t\t\t\tthis.lastDiscoveredAt = 0;\n\t\t\t});\n\t\t}\n\t\treturn pastLastDiscoveryTimeThreshold;\n\t}\n}\n"]}
|
|
@@ -14,7 +14,6 @@ import { ITokenProvider } from "./tokens";
|
|
|
14
14
|
*/
|
|
15
15
|
export declare class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {
|
|
16
16
|
private readonly tokenProvider;
|
|
17
|
-
readonly protocolName = "fluid:";
|
|
18
17
|
private readonly driverPolicies;
|
|
19
18
|
private readonly blobCache;
|
|
20
19
|
private readonly snapshotTreeCache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentServiceFactory.d.ts","sourceRoot":"","sources":["../src/documentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"documentServiceFactory.d.ts","sourceRoot":"","sources":["../src/documentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEN,gBAAgB,EAChB,uBAAuB,EAGvB,YAAY,EAEZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AASpE,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAElE,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC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