@fluidframework/routerlicious-driver 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191258
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +4 -3
- package/dist/contracts.d.ts +28 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/createNewUtils.d.ts +1 -1
- package/dist/createNewUtils.js +3 -3
- package/dist/createNewUtils.js.map +1 -1
- package/dist/deltaStorageService.d.ts.map +1 -1
- package/dist/deltaStorageService.js +17 -6
- package/dist/deltaStorageService.js.map +1 -1
- package/dist/documentDeltaConnection.js +1 -1
- package/dist/documentDeltaConnection.js.map +1 -1
- package/dist/documentService.d.ts +3 -3
- package/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +4 -4
- package/dist/documentService.js.map +1 -1
- package/dist/documentServiceFactory.d.ts.map +1 -1
- package/dist/documentServiceFactory.js +32 -10
- package/dist/documentServiceFactory.js.map +1 -1
- package/dist/documentStorageService.d.ts +2 -2
- package/dist/documentStorageService.d.ts.map +1 -1
- package/dist/documentStorageService.js +2 -2
- package/dist/documentStorageService.js.map +1 -1
- package/dist/errorUtils.d.ts +38 -6
- package/dist/errorUtils.d.ts.map +1 -1
- package/dist/errorUtils.js +32 -16
- package/dist/errorUtils.js.map +1 -1
- package/dist/gitManager.d.ts +3 -2
- package/dist/gitManager.d.ts.map +1 -1
- package/dist/gitManager.js +2 -2
- package/dist/gitManager.js.map +1 -1
- package/dist/historian.d.ts +3 -2
- package/dist/historian.d.ts.map +1 -1
- package/dist/historian.js +13 -6
- package/dist/historian.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mapWithExpiration.js +2 -2
- package/dist/mapWithExpiration.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 +7 -1
- package/dist/policies.d.ts.map +1 -1
- package/dist/policies.js.map +1 -1
- package/dist/r11sSnapshotParser.d.ts +4 -5
- package/dist/r11sSnapshotParser.d.ts.map +1 -1
- package/dist/r11sSnapshotParser.js +13 -15
- package/dist/r11sSnapshotParser.js.map +1 -1
- package/dist/restWrapper.d.ts +3 -3
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapper.js +53 -36
- package/dist/restWrapper.js.map +1 -1
- package/dist/restWrapperBase.js +39 -5
- package/dist/restWrapperBase.js.map +1 -1
- package/dist/retriableGitManager.d.ts +3 -2
- package/dist/retriableGitManager.d.ts.map +1 -1
- package/dist/retriableGitManager.js +2 -2
- package/dist/retriableGitManager.js.map +1 -1
- package/dist/shreddedSummaryDocumentStorageService.js +13 -16
- package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/dist/storageContracts.d.ts +4 -3
- package/dist/storageContracts.d.ts.map +1 -1
- package/dist/storageContracts.js.map +1 -1
- package/dist/summaryTreeUploadManager.d.ts.map +1 -1
- package/dist/summaryTreeUploadManager.js +11 -11
- package/dist/summaryTreeUploadManager.js.map +1 -1
- package/dist/treeUtils.d.ts +2 -2
- package/dist/treeUtils.d.ts.map +1 -1
- package/dist/treeUtils.js +8 -8
- package/dist/treeUtils.js.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.d.ts +2 -2
- package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.js +27 -22
- package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
- package/dist/wholeSummaryUploadManager.js +1 -2
- package/dist/wholeSummaryUploadManager.js.map +1 -1
- package/lib/contracts.d.ts +28 -1
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/createNewUtils.d.ts +1 -1
- package/lib/createNewUtils.js +2 -2
- package/lib/createNewUtils.js.map +1 -1
- package/lib/deltaStorageService.d.ts.map +1 -1
- package/lib/deltaStorageService.js +17 -6
- package/lib/deltaStorageService.js.map +1 -1
- package/lib/documentDeltaConnection.js +1 -1
- package/lib/documentDeltaConnection.js.map +1 -1
- package/lib/documentService.d.ts +3 -3
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +4 -4
- package/lib/documentService.js.map +1 -1
- package/lib/documentServiceFactory.d.ts.map +1 -1
- package/lib/documentServiceFactory.js +32 -10
- package/lib/documentServiceFactory.js.map +1 -1
- package/lib/documentStorageService.d.ts +2 -2
- package/lib/documentStorageService.d.ts.map +1 -1
- package/lib/documentStorageService.js +2 -2
- package/lib/documentStorageService.js.map +1 -1
- package/lib/errorUtils.d.ts +38 -6
- package/lib/errorUtils.d.ts.map +1 -1
- package/lib/errorUtils.js +31 -15
- package/lib/errorUtils.js.map +1 -1
- package/lib/gitManager.d.ts +3 -2
- package/lib/gitManager.d.ts.map +1 -1
- package/lib/gitManager.js +2 -2
- package/lib/gitManager.js.map +1 -1
- package/lib/historian.d.ts +3 -2
- package/lib/historian.d.ts.map +1 -1
- package/lib/historian.js +12 -5
- package/lib/historian.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/mapWithExpiration.js +1 -1
- package/lib/mapWithExpiration.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 +7 -1
- package/lib/policies.d.ts.map +1 -1
- package/lib/policies.js.map +1 -1
- package/lib/r11sSnapshotParser.d.ts +4 -5
- package/lib/r11sSnapshotParser.d.ts.map +1 -1
- package/lib/r11sSnapshotParser.js +11 -13
- package/lib/r11sSnapshotParser.js.map +1 -1
- package/lib/restWrapper.d.ts +3 -3
- package/lib/restWrapper.d.ts.map +1 -1
- package/lib/restWrapper.js +48 -31
- package/lib/restWrapper.js.map +1 -1
- package/lib/restWrapperBase.js +39 -5
- package/lib/restWrapperBase.js.map +1 -1
- package/lib/retriableGitManager.d.ts +3 -2
- package/lib/retriableGitManager.d.ts.map +1 -1
- package/lib/retriableGitManager.js +2 -2
- package/lib/retriableGitManager.js.map +1 -1
- package/lib/shreddedSummaryDocumentStorageService.js +12 -15
- package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
- package/lib/storageContracts.d.ts +4 -3
- package/lib/storageContracts.d.ts.map +1 -1
- package/lib/storageContracts.js.map +1 -1
- package/lib/summaryTreeUploadManager.d.ts.map +1 -1
- package/lib/summaryTreeUploadManager.js +4 -4
- package/lib/summaryTreeUploadManager.js.map +1 -1
- package/lib/treeUtils.d.ts +2 -2
- package/lib/treeUtils.d.ts.map +1 -1
- package/lib/treeUtils.js +4 -4
- package/lib/treeUtils.js.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts +2 -2
- package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.js +23 -18
- package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
- package/lib/wholeSummaryUploadManager.js +1 -2
- package/lib/wholeSummaryUploadManager.js.map +1 -1
- package/package.json +26 -28
- package/src/contracts.ts +45 -1
- package/src/createNewUtils.ts +2 -2
- package/src/deltaStorageService.ts +8 -1
- package/src/documentService.ts +5 -5
- package/src/documentServiceFactory.ts +21 -11
- package/src/documentStorageService.ts +3 -3
- package/src/errorUtils.ts +48 -30
- package/src/gitManager.ts +3 -3
- package/src/historian.ts +5 -5
- package/src/index.ts +1 -1
- package/src/mapWithExpiration.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/policies.ts +7 -1
- package/src/r11sSnapshotParser.ts +14 -15
- package/src/restWrapper.ts +34 -21
- package/src/retriableGitManager.ts +3 -3
- package/src/shreddedSummaryDocumentStorageService.ts +3 -3
- package/src/storageContracts.ts +3 -3
- package/src/summaryTreeUploadManager.ts +2 -7
- package/src/treeUtils.ts +4 -3
- package/src/wholeSummaryDocumentStorageService.ts +14 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/routerlicious-driver",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.6.4.0.191258",
|
|
4
4
|
"description": "Socket.IO + Git implementation of Fluid service API",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"module": "lib/index.js",
|
|
16
16
|
"types": "dist/index.d.ts",
|
|
17
|
-
"
|
|
17
|
+
"c8": {
|
|
18
18
|
"all": true,
|
|
19
19
|
"cache-dir": "nyc/.cache",
|
|
20
20
|
"exclude": [
|
|
@@ -35,39 +35,39 @@
|
|
|
35
35
|
"temp-directory": "nyc/.nyc_output"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@fluidframework/
|
|
40
|
-
"@fluidframework/core-
|
|
41
|
-
"@fluidframework/driver-base": "2.0.0-dev.
|
|
42
|
-
"@fluidframework/driver-definitions": "2.0.0-dev.
|
|
43
|
-
"@fluidframework/driver-utils": "2.0.0-dev.
|
|
44
|
-
"@fluidframework/gitresources": "^0.
|
|
45
|
-
"@fluidframework/protocol-base": "^0.
|
|
38
|
+
"@fluid-internal/client-utils": "2.0.0-dev.6.4.0.191258",
|
|
39
|
+
"@fluidframework/core-interfaces": "2.0.0-dev.6.4.0.191258",
|
|
40
|
+
"@fluidframework/core-utils": "2.0.0-dev.6.4.0.191258",
|
|
41
|
+
"@fluidframework/driver-base": "2.0.0-dev.6.4.0.191258",
|
|
42
|
+
"@fluidframework/driver-definitions": "2.0.0-dev.6.4.0.191258",
|
|
43
|
+
"@fluidframework/driver-utils": "2.0.0-dev.6.4.0.191258",
|
|
44
|
+
"@fluidframework/gitresources": "^1.0.1",
|
|
45
|
+
"@fluidframework/protocol-base": "^1.0.1",
|
|
46
46
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
47
|
-
"@fluidframework/server-services-client": "^0.
|
|
48
|
-
"@fluidframework/telemetry-utils": "2.0.0-dev.
|
|
47
|
+
"@fluidframework/server-services-client": "^1.0.1",
|
|
48
|
+
"@fluidframework/telemetry-utils": "2.0.0-dev.6.4.0.191258",
|
|
49
49
|
"cross-fetch": "^3.1.5",
|
|
50
50
|
"json-stringify-safe": "5.0.1",
|
|
51
51
|
"socket.io-client": "^4.6.1",
|
|
52
52
|
"url-parse": "^1.5.8",
|
|
53
|
-
"uuid": "^
|
|
53
|
+
"uuid": "^9.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@fluid-tools/build-cli": "^0.
|
|
57
|
-
"@fluidframework/build-common": "^
|
|
58
|
-
"@fluidframework/build-tools": "^0.
|
|
59
|
-
"@fluidframework/eslint-config-fluid": "^2.
|
|
60
|
-
"@fluidframework/mocha-test-setup": "2.0.0-dev.
|
|
61
|
-
"@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@2.0.0-internal.
|
|
56
|
+
"@fluid-tools/build-cli": "^0.22.0",
|
|
57
|
+
"@fluidframework/build-common": "^2.0.0",
|
|
58
|
+
"@fluidframework/build-tools": "^0.22.0",
|
|
59
|
+
"@fluidframework/eslint-config-fluid": "^2.1.0",
|
|
60
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev.6.4.0.191258",
|
|
61
|
+
"@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@2.0.0-internal.6.3.0",
|
|
62
62
|
"@microsoft/api-extractor": "^7.34.4",
|
|
63
63
|
"@types/mocha": "^9.1.1",
|
|
64
64
|
"@types/nock": "^9.3.0",
|
|
65
|
-
"@types/node": "^
|
|
65
|
+
"@types/node": "^16.18.38",
|
|
66
66
|
"@types/sinon": "^7.0.13",
|
|
67
67
|
"@types/url-parse": "1.4.4",
|
|
68
|
-
"@types/uuid": "^
|
|
68
|
+
"@types/uuid": "^9.0.2",
|
|
69
69
|
"axios": "^0.26.0",
|
|
70
|
-
"
|
|
70
|
+
"c8": "^7.7.1",
|
|
71
71
|
"copyfiles": "^2.4.1",
|
|
72
72
|
"cross-env": "^7.0.3",
|
|
73
73
|
"eslint": "~8.6.0",
|
|
@@ -75,8 +75,7 @@
|
|
|
75
75
|
"mocha-json-output-reporter": "^2.0.1",
|
|
76
76
|
"mocha-multi-reporters": "^1.5.1",
|
|
77
77
|
"moment": "^2.21.0",
|
|
78
|
-
"nock": "^
|
|
79
|
-
"nyc": "^15.1.0",
|
|
78
|
+
"nock": "^13.3.3",
|
|
80
79
|
"prettier": "~2.6.2",
|
|
81
80
|
"rimraf": "^4.4.0",
|
|
82
81
|
"sinon": "^7.4.2",
|
|
@@ -94,7 +93,7 @@
|
|
|
94
93
|
"build:genver": "gen-version",
|
|
95
94
|
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
96
95
|
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
97
|
-
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
96
|
+
"clean": "rimraf --glob 'dist' 'lib' '*.tsbuildinfo' '*.build.log' '_api-extractor-temp' 'nyc'",
|
|
98
97
|
"eslint": "eslint --format stylish src",
|
|
99
98
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
100
99
|
"format": "npm run prettier:fix",
|
|
@@ -103,9 +102,8 @@
|
|
|
103
102
|
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
104
103
|
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
105
104
|
"test": "npm run test:mocha",
|
|
106
|
-
"test:coverage": "
|
|
107
|
-
"test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup
|
|
108
|
-
"test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
|
|
105
|
+
"test:coverage": "c8 npm test",
|
|
106
|
+
"test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
|
|
109
107
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
110
108
|
"tsc": "tsc",
|
|
111
109
|
"typetests:gen": "fluid-type-test-generator",
|
package/src/contracts.ts
CHANGED
|
@@ -5,10 +5,54 @@
|
|
|
5
5
|
|
|
6
6
|
import { ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
7
7
|
|
|
8
|
+
/*
|
|
9
|
+
*
|
|
10
|
+
* Whole Snapshot Download Data Structures
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export interface IWholeFlatSnapshotTreeEntryTree {
|
|
15
|
+
path: string;
|
|
16
|
+
type: "tree";
|
|
17
|
+
// Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.
|
|
18
|
+
unreferenced?: true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface IWholeFlatSnapshotTreeEntryBlob {
|
|
22
|
+
id: string;
|
|
23
|
+
path: string;
|
|
24
|
+
type: "blob";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type IWholeFlatSnapshotTreeEntry =
|
|
28
|
+
| IWholeFlatSnapshotTreeEntryTree
|
|
29
|
+
| IWholeFlatSnapshotTreeEntryBlob;
|
|
30
|
+
|
|
31
|
+
export interface IWholeFlatSnapshotTree {
|
|
32
|
+
entries: IWholeFlatSnapshotTreeEntry[];
|
|
33
|
+
id: string;
|
|
34
|
+
sequenceNumber: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface IWholeFlatSnapshotBlob {
|
|
38
|
+
content: string;
|
|
39
|
+
encoding: "base64" | "utf-8";
|
|
40
|
+
id: string;
|
|
41
|
+
size: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface IWholeFlatSnapshot {
|
|
45
|
+
// The same as the id of the first snapshot tree in the trees array.
|
|
46
|
+
id: string;
|
|
47
|
+
// Receive an array of snapshot trees for future-proofing, however, always length 1 for now.
|
|
48
|
+
trees: IWholeFlatSnapshotTree[];
|
|
49
|
+
blobs?: IWholeFlatSnapshotBlob[];
|
|
50
|
+
}
|
|
51
|
+
|
|
8
52
|
/**
|
|
9
53
|
* Normalized Whole Summary with decoded blobs and unflattened snapshot tree.
|
|
10
54
|
*/
|
|
11
|
-
export interface
|
|
55
|
+
export interface INormalizedWholeSnapshot {
|
|
12
56
|
blobs: Map<string, ArrayBuffer>;
|
|
13
57
|
snapshotTree: ISnapshotTree;
|
|
14
58
|
sequenceNumber: number | undefined;
|
package/src/createNewUtils.ts
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Uint8ArrayToString } from "@
|
|
6
|
+
import { Uint8ArrayToString } from "@fluid-internal/client-utils";
|
|
7
7
|
import { ISummaryTree, SummaryType } from "@fluidframework/protocol-definitions";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Utility api to convert ISummaryTree to a summary tree where blob contents are only utf8 strings.
|
|
11
11
|
* @param summary - Summary supplied by the runtime to upload.
|
|
12
|
-
* @returns
|
|
12
|
+
* @returns Modified summary tree where the blob contents could be utf8 string only.
|
|
13
13
|
*/
|
|
14
14
|
export function convertSummaryToCreateNewSummary(summary: ISummaryTree): ISummaryTree {
|
|
15
15
|
const keys = Object.keys(summary.tree);
|
|
@@ -22,7 +22,14 @@ import { ITelemetryLoggerExt, PerformanceEvent } from "@fluidframework/telemetry
|
|
|
22
22
|
import { DocumentStorageService } from "./documentStorageService";
|
|
23
23
|
import { RestWrapper } from "./restWrapperBase";
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Maximum number of ops we can fetch at a time. This should be kept at 2k, as
|
|
27
|
+
* server determines whether to try to fallback to long-term storage if the ops range requested is larger than
|
|
28
|
+
* what they have locally available in short-term storage. So if we request 2k ops, they know it is not a
|
|
29
|
+
* specific request and they don't fall to long term storage which takes time.
|
|
30
|
+
* Please coordinate to AFR team if this value need to be changed.
|
|
31
|
+
*/
|
|
32
|
+
const MaxBatchDeltas = 2000;
|
|
26
33
|
|
|
27
34
|
/**
|
|
28
35
|
* Storage service limited to only being able to fetch documents for a specific document
|
package/src/documentService.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert } from "@fluidframework/
|
|
6
|
+
import { assert } from "@fluidframework/core-utils";
|
|
7
7
|
import * as api from "@fluidframework/driver-definitions";
|
|
8
|
-
import {
|
|
8
|
+
import { DriverErrorTypes } from "@fluidframework/driver-definitions";
|
|
9
9
|
import { RateLimiter, NetworkErrorBasic, canRetryOnError } from "@fluidframework/driver-utils";
|
|
10
10
|
import { IClient } from "@fluidframework/protocol-definitions";
|
|
11
11
|
import io from "socket.io-client";
|
|
@@ -27,7 +27,7 @@ import { pkgVersion as driverVersion } from "./packageVersion";
|
|
|
27
27
|
import { GitManager } from "./gitManager";
|
|
28
28
|
import { Historian } from "./historian";
|
|
29
29
|
import { RestWrapper } from "./restWrapperBase";
|
|
30
|
-
import {
|
|
30
|
+
import { INormalizedWholeSnapshot } from "./contracts";
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Amount of time between discoveries within which we don't need to rediscover on re-connect.
|
|
@@ -67,7 +67,7 @@ export class DocumentService implements api.IDocumentService {
|
|
|
67
67
|
private readonly documentStorageServicePolicies: api.IDocumentStorageServicePolicies,
|
|
68
68
|
private readonly driverPolicies: IRouterliciousDriverPolicies,
|
|
69
69
|
private readonly blobCache: ICache<ArrayBufferLike>,
|
|
70
|
-
private readonly wholeSnapshotTreeCache: ICache<
|
|
70
|
+
private readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot>,
|
|
71
71
|
private readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion>,
|
|
72
72
|
private readonly discoverFluidResolvedUrl: () => Promise<api.IResolvedUrl>,
|
|
73
73
|
private storageRestWrapper: RouterliciousStorageRestWrapper,
|
|
@@ -221,7 +221,7 @@ export class DocumentService implements api.IDocumentService {
|
|
|
221
221
|
(errorMessage) =>
|
|
222
222
|
new NetworkErrorBasic(
|
|
223
223
|
`The Host-provided token fetcher threw an error`,
|
|
224
|
-
|
|
224
|
+
DriverErrorTypes.fetchTokenError,
|
|
225
225
|
canRetryOnError(error),
|
|
226
226
|
{ errorMessage, driverVersion },
|
|
227
227
|
),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert } from "@fluidframework/
|
|
6
|
+
import { assert } from "@fluidframework/core-utils";
|
|
7
7
|
import { getW3CData } from "@fluidframework/driver-base";
|
|
8
8
|
import {
|
|
9
9
|
FiveDaysMs,
|
|
@@ -21,8 +21,11 @@ import {
|
|
|
21
21
|
isCombinedAppAndProtocolSummary,
|
|
22
22
|
RateLimiter,
|
|
23
23
|
} from "@fluidframework/driver-utils";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
24
|
+
import { createChildLogger, PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
25
|
+
import {
|
|
26
|
+
ISession,
|
|
27
|
+
convertSummaryTreeToWholeSummaryTree,
|
|
28
|
+
} from "@fluidframework/server-services-client";
|
|
26
29
|
import { DocumentService } from "./documentService";
|
|
27
30
|
import { IRouterliciousDriverPolicies } from "./policies";
|
|
28
31
|
import { ITokenProvider } from "./tokens";
|
|
@@ -32,12 +35,11 @@ import {
|
|
|
32
35
|
toInstrumentedR11sOrdererTokenFetcher,
|
|
33
36
|
toInstrumentedR11sStorageTokenFetcher,
|
|
34
37
|
} from "./restWrapper";
|
|
35
|
-
import { convertSummaryToCreateNewSummary } from "./createNewUtils";
|
|
36
38
|
import { parseFluidUrl, replaceDocumentIdInPath, getDiscoveredFluidResolvedUrl } from "./urlUtils";
|
|
37
39
|
import { ICache, InMemoryCache, NullCache } from "./cache";
|
|
38
40
|
import { pkgVersion as driverVersion } from "./packageVersion";
|
|
39
41
|
import { ISnapshotTreeVersion } from "./definitions";
|
|
40
|
-
import {
|
|
42
|
+
import { INormalizedWholeSnapshot } from "./contracts";
|
|
41
43
|
|
|
42
44
|
const maximumSnapshotCacheDurationMs: FiveDaysMs = 432_000_000; // 5 days in ms
|
|
43
45
|
|
|
@@ -51,6 +53,7 @@ const defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {
|
|
|
51
53
|
enableRestLess: true,
|
|
52
54
|
enableInternalSummaryCaching: true,
|
|
53
55
|
enableLongPollingDowngrade: true,
|
|
56
|
+
isEphemeralContainer: false,
|
|
54
57
|
};
|
|
55
58
|
|
|
56
59
|
/**
|
|
@@ -60,7 +63,7 @@ const defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {
|
|
|
60
63
|
export class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {
|
|
61
64
|
private readonly driverPolicies: IRouterliciousDriverPolicies;
|
|
62
65
|
private readonly blobCache: ICache<ArrayBufferLike>;
|
|
63
|
-
private readonly wholeSnapshotTreeCache: ICache<
|
|
66
|
+
private readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot> = new NullCache();
|
|
64
67
|
private readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion> = new NullCache();
|
|
65
68
|
|
|
66
69
|
constructor(
|
|
@@ -77,7 +80,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
77
80
|
this.blobCache = new InMemoryCache<ArrayBufferLike>();
|
|
78
81
|
if (this.driverPolicies.enableInternalSummaryCaching) {
|
|
79
82
|
if (this.driverPolicies.enableWholeSummaryUpload) {
|
|
80
|
-
this.wholeSnapshotTreeCache = new InMemoryCache<
|
|
83
|
+
this.wholeSnapshotTreeCache = new InMemoryCache<INormalizedWholeSnapshot>(
|
|
81
84
|
snapshotCacheExpiryMs,
|
|
82
85
|
);
|
|
83
86
|
} else {
|
|
@@ -119,7 +122,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
119
122
|
const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);
|
|
120
123
|
const quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);
|
|
121
124
|
|
|
122
|
-
const logger2 =
|
|
125
|
+
const logger2 = createChildLogger({ logger, namespace: "RouterliciousDriver" });
|
|
123
126
|
const ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(
|
|
124
127
|
tenantId,
|
|
125
128
|
undefined /* documentId */,
|
|
@@ -142,6 +145,7 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
142
145
|
details: JSON.stringify({
|
|
143
146
|
enableDiscovery: this.driverPolicies.enableDiscovery,
|
|
144
147
|
sequenceNumber: documentAttributes.sequenceNumber,
|
|
148
|
+
isEphemeralContainer: this.driverPolicies.isEphemeralContainer,
|
|
145
149
|
}),
|
|
146
150
|
},
|
|
147
151
|
async (event) => {
|
|
@@ -150,11 +154,13 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
150
154
|
await ordererRestWrapper.post<
|
|
151
155
|
{ id: string; token?: string; session?: ISession } | string
|
|
152
156
|
>(`/documents/${tenantId}`, {
|
|
153
|
-
summary:
|
|
157
|
+
summary: convertSummaryTreeToWholeSummaryTree(undefined, appSummary),
|
|
154
158
|
sequenceNumber: documentAttributes.sequenceNumber,
|
|
155
159
|
values: quorumValues,
|
|
156
160
|
enableDiscovery: this.driverPolicies.enableDiscovery,
|
|
157
161
|
generateToken: this.tokenProvider.documentPostCreateCallback !== undefined,
|
|
162
|
+
isEphemeralContainer: this.driverPolicies.isEphemeralContainer,
|
|
163
|
+
enableAnyBinaryBlobOnFirstSummary: true,
|
|
158
164
|
})
|
|
159
165
|
).content;
|
|
160
166
|
|
|
@@ -247,8 +253,12 @@ export class RouterliciousDocumentServiceFactory implements IDocumentServiceFact
|
|
|
247
253
|
`Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`,
|
|
248
254
|
);
|
|
249
255
|
}
|
|
250
|
-
const logger2 =
|
|
251
|
-
|
|
256
|
+
const logger2 = createChildLogger({
|
|
257
|
+
logger,
|
|
258
|
+
namespace: "RouterliciousDriver",
|
|
259
|
+
properties: {
|
|
260
|
+
all: { driverVersion },
|
|
261
|
+
},
|
|
252
262
|
});
|
|
253
263
|
|
|
254
264
|
const ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(
|
|
@@ -20,7 +20,7 @@ import { WholeSummaryDocumentStorageService } from "./wholeSummaryDocumentStorag
|
|
|
20
20
|
import { ShreddedSummaryDocumentStorageService } from "./shreddedSummaryDocumentStorageService";
|
|
21
21
|
import { GitManager } from "./gitManager";
|
|
22
22
|
import { ISnapshotTreeVersion } from "./definitions";
|
|
23
|
-
import {
|
|
23
|
+
import { INormalizedWholeSnapshot } from "./contracts";
|
|
24
24
|
|
|
25
25
|
export class DocumentStorageService extends DocumentStorageServiceProxy {
|
|
26
26
|
private _logTailSha: string | undefined = undefined;
|
|
@@ -36,7 +36,7 @@ export class DocumentStorageService extends DocumentStorageServiceProxy {
|
|
|
36
36
|
policies: IDocumentStorageServicePolicies,
|
|
37
37
|
driverPolicies?: IRouterliciousDriverPolicies,
|
|
38
38
|
blobCache?: ICache<ArrayBufferLike>,
|
|
39
|
-
snapshotTreeCache?: ICache<
|
|
39
|
+
snapshotTreeCache?: ICache<INormalizedWholeSnapshot>,
|
|
40
40
|
shreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,
|
|
41
41
|
noCacheGitManager?: GitManager,
|
|
42
42
|
getStorageManager?: (disableCache?: boolean) => Promise<GitManager>,
|
|
@@ -80,7 +80,7 @@ export class DocumentStorageService extends DocumentStorageServiceProxy {
|
|
|
80
80
|
policies: IDocumentStorageServicePolicies,
|
|
81
81
|
driverPolicies?: IRouterliciousDriverPolicies,
|
|
82
82
|
blobCache?: ICache<ArrayBufferLike>,
|
|
83
|
-
snapshotTreeCache?: ICache<
|
|
83
|
+
snapshotTreeCache?: ICache<INormalizedWholeSnapshot>,
|
|
84
84
|
shreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,
|
|
85
85
|
public noCacheGitManager?: GitManager,
|
|
86
86
|
getStorageManager?: (disableCache?: boolean) => Promise<GitManager>,
|
package/src/errorUtils.ts
CHANGED
|
@@ -3,25 +3,51 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
DriverError,
|
|
8
|
+
IDriverErrorBase,
|
|
9
|
+
DriverErrorTypes,
|
|
10
|
+
} from "@fluidframework/driver-definitions";
|
|
7
11
|
import {
|
|
8
12
|
NonRetryableError,
|
|
9
13
|
GenericNetworkError,
|
|
10
14
|
createGenericNetworkError,
|
|
11
15
|
AuthorizationError,
|
|
12
16
|
} from "@fluidframework/driver-utils";
|
|
17
|
+
import { IFluidErrorBase } from "@fluidframework/telemetry-utils";
|
|
13
18
|
import { pkgVersion as driverVersion } from "./packageVersion";
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
21
|
* Routerlicious Error types
|
|
17
22
|
* Different error types that may be thrown by the routerlicious driver
|
|
18
23
|
*/
|
|
24
|
+
export const RouterliciousErrorTypes = {
|
|
25
|
+
// Inherit base driver error types
|
|
26
|
+
...DriverErrorTypes,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* SSL Certificate Error.
|
|
30
|
+
*/
|
|
31
|
+
sslCertError: "sslCertError",
|
|
32
|
+
} as const;
|
|
33
|
+
export type RouterliciousErrorTypes =
|
|
34
|
+
typeof RouterliciousErrorTypes[keyof typeof RouterliciousErrorTypes];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Routerlicious Error types
|
|
38
|
+
* Different error types that may be thrown by the routerlicious driver
|
|
39
|
+
*
|
|
40
|
+
* @deprecated Use {@link (RouterliciousErrorTypes:variable)} instead.
|
|
41
|
+
*/
|
|
19
42
|
export enum RouterliciousErrorType {
|
|
20
43
|
/**
|
|
21
44
|
* File not found, or file deleted during session
|
|
22
45
|
*/
|
|
23
46
|
fileNotFoundOrAccessDeniedError = "fileNotFoundOrAccessDeniedError",
|
|
24
47
|
|
|
48
|
+
/**
|
|
49
|
+
* SSL Certificate Error.
|
|
50
|
+
*/
|
|
25
51
|
sslCertError = "sslCertError",
|
|
26
52
|
}
|
|
27
53
|
|
|
@@ -55,61 +81,53 @@ export interface IR11sSocketError {
|
|
|
55
81
|
retryAfterMs?: number;
|
|
56
82
|
}
|
|
57
83
|
|
|
58
|
-
export interface IR11sError {
|
|
84
|
+
export interface IR11sError extends Omit<IDriverErrorBase, "errorType"> {
|
|
59
85
|
readonly errorType: RouterliciousErrorType;
|
|
60
|
-
readonly message: string;
|
|
61
|
-
canRetry: boolean;
|
|
62
86
|
}
|
|
63
87
|
|
|
64
88
|
export type R11sError = DriverError | IR11sError;
|
|
65
89
|
|
|
66
90
|
export function createR11sNetworkError(
|
|
67
91
|
errorMessage: string,
|
|
68
|
-
statusCode
|
|
92
|
+
statusCode: number,
|
|
69
93
|
retryAfterMs?: number,
|
|
70
|
-
): R11sError {
|
|
94
|
+
): IFluidErrorBase & R11sError {
|
|
95
|
+
let error: IFluidErrorBase & R11sError;
|
|
71
96
|
const props = { statusCode, driverVersion };
|
|
72
97
|
switch (statusCode) {
|
|
73
|
-
case undefined:
|
|
74
|
-
// If a service is temporarily down or a browser resource limit is reached, RestWrapper will throw
|
|
75
|
-
// a network error with no status code (e.g. err:ERR_CONN_REFUSED or err:ERR_FAILED) and
|
|
76
|
-
// the error message will start with NetworkError as defined in restWrapper.ts
|
|
77
|
-
// If there exists a self-signed SSL certificates error, throw a NonRetryableError
|
|
78
|
-
// TODO: instead of relying on string matching, filter error based on the error code like we do for websocket connections
|
|
79
|
-
if (errorMessage.includes("failed, reason: self signed certificate")) {
|
|
80
|
-
return new NonRetryableError(
|
|
81
|
-
errorMessage,
|
|
82
|
-
RouterliciousErrorType.sslCertError,
|
|
83
|
-
props,
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
return new GenericNetworkError(
|
|
87
|
-
errorMessage,
|
|
88
|
-
errorMessage.startsWith("NetworkError"),
|
|
89
|
-
props,
|
|
90
|
-
);
|
|
91
98
|
case 401:
|
|
92
99
|
// The first 401 is manually retried in RouterliciousRestWrapper with a refreshed token,
|
|
93
100
|
// so we treat repeat 401s the same as 403.
|
|
94
101
|
case 403:
|
|
95
|
-
|
|
102
|
+
error = new AuthorizationError(errorMessage, undefined, undefined, props);
|
|
103
|
+
break;
|
|
96
104
|
case 404:
|
|
97
105
|
const errorType = RouterliciousErrorType.fileNotFoundOrAccessDeniedError;
|
|
98
|
-
|
|
106
|
+
error = new NonRetryableError(errorMessage, errorType, props);
|
|
107
|
+
break;
|
|
99
108
|
case 429:
|
|
100
|
-
|
|
109
|
+
error = createGenericNetworkError(
|
|
110
|
+
errorMessage,
|
|
111
|
+
{ canRetry: true, retryAfterMs },
|
|
112
|
+
props,
|
|
113
|
+
);
|
|
114
|
+
break;
|
|
101
115
|
case 500:
|
|
102
116
|
case 502:
|
|
103
|
-
|
|
117
|
+
error = new GenericNetworkError(errorMessage, true, props);
|
|
118
|
+
break;
|
|
104
119
|
default:
|
|
105
120
|
const retryInfo = { canRetry: retryAfterMs !== undefined, retryAfterMs };
|
|
106
|
-
|
|
121
|
+
error = createGenericNetworkError(errorMessage, retryInfo, props);
|
|
122
|
+
break;
|
|
107
123
|
}
|
|
124
|
+
error.addTelemetryProperties({ endpointReached: true });
|
|
125
|
+
return error;
|
|
108
126
|
}
|
|
109
127
|
|
|
110
128
|
export function throwR11sNetworkError(
|
|
111
129
|
errorMessage: string,
|
|
112
|
-
statusCode
|
|
130
|
+
statusCode: number,
|
|
113
131
|
retryAfterMs?: number,
|
|
114
132
|
): never {
|
|
115
133
|
const networkError = createR11sNetworkError(errorMessage, statusCode, retryAfterMs);
|
package/src/gitManager.ts
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
import * as resources from "@fluidframework/gitresources";
|
|
7
7
|
import {
|
|
8
|
-
IWholeFlatSummary,
|
|
9
8
|
IWholeSummaryPayload,
|
|
10
9
|
IWriteSummaryResponse,
|
|
11
10
|
} from "@fluidframework/server-services-client";
|
|
12
11
|
import { IGitManager, IHistorian } from "./storageContracts";
|
|
13
12
|
import { IR11sResponse, createR11sResponseFromContent } from "./restWrapper";
|
|
13
|
+
import { IWholeFlatSnapshot } from "./contracts";
|
|
14
14
|
|
|
15
15
|
export class GitManager implements IGitManager {
|
|
16
16
|
private readonly blobCache = new Map<string, resources.IBlob>();
|
|
@@ -110,7 +110,7 @@ export class GitManager implements IGitManager {
|
|
|
110
110
|
return this.historian.createSummary(summary, initial);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
public async
|
|
114
|
-
return this.historian.
|
|
113
|
+
public async getSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>> {
|
|
114
|
+
return this.historian.getSnapshot(sha);
|
|
115
115
|
}
|
|
116
116
|
}
|
package/src/historian.ts
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { fromUtf8ToBase64 } from "@
|
|
6
|
+
import { fromUtf8ToBase64 } from "@fluid-internal/client-utils";
|
|
7
7
|
import * as git from "@fluidframework/gitresources";
|
|
8
8
|
import {
|
|
9
|
-
IWholeFlatSummary,
|
|
10
9
|
IWholeSummaryPayload,
|
|
11
10
|
IWriteSummaryResponse,
|
|
12
11
|
} from "@fluidframework/server-services-client";
|
|
13
12
|
import { QueryStringType, RestWrapper } from "./restWrapperBase";
|
|
14
13
|
import { IR11sResponse } from "./restWrapper";
|
|
15
14
|
import { IHistorian } from "./storageContracts";
|
|
15
|
+
import { IWholeFlatSnapshot } from "./contracts";
|
|
16
16
|
|
|
17
17
|
export interface ICredentials {
|
|
18
18
|
user: string;
|
|
@@ -65,7 +65,7 @@ export class Historian implements IHistorian {
|
|
|
65
65
|
): Promise<IR11sResponse<git.ICommitDetails[]>> {
|
|
66
66
|
return this.restWrapper
|
|
67
67
|
.get<git.ICommitDetails[]>(`/commits`, this.getQueryString({ count, sha }))
|
|
68
|
-
.catch((error) =>
|
|
68
|
+
.catch(async (error) =>
|
|
69
69
|
error.statusCode === 400 || error.statusCode === 404
|
|
70
70
|
? {
|
|
71
71
|
content: [],
|
|
@@ -98,8 +98,8 @@ export class Historian implements IHistorian {
|
|
|
98
98
|
);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
public async
|
|
102
|
-
return this.restWrapper.get<
|
|
101
|
+
public async getSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>> {
|
|
102
|
+
return this.restWrapper.get<IWholeFlatSnapshot>(
|
|
103
103
|
`/git/summaries/${sha}`,
|
|
104
104
|
this.getQueryString(),
|
|
105
105
|
);
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { DefaultTokenProvider } from "./defaultTokenProvider";
|
|
|
8
8
|
export { ITokenProvider, ITokenResponse, ITokenService } from "./tokens";
|
|
9
9
|
|
|
10
10
|
// Errors
|
|
11
|
-
export { RouterliciousErrorType } from "./errorUtils";
|
|
11
|
+
export { RouterliciousErrorType, RouterliciousErrorTypes } from "./errorUtils";
|
|
12
12
|
|
|
13
13
|
// Factory
|
|
14
14
|
export {
|
package/src/mapWithExpiration.ts
CHANGED
package/src/packageVersion.ts
CHANGED
package/src/policies.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface IRouterliciousDriverPolicies {
|
|
|
36
36
|
* Enable service endpoint discovery when creating or joining a session.
|
|
37
37
|
* Default: false
|
|
38
38
|
*/
|
|
39
|
-
enableDiscovery
|
|
39
|
+
enableDiscovery: boolean;
|
|
40
40
|
/**
|
|
41
41
|
* Enable using RestLess which avoids CORS preflight requests.
|
|
42
42
|
* Default: true
|
|
@@ -54,4 +54,10 @@ export interface IRouterliciousDriverPolicies {
|
|
|
54
54
|
* Default: true
|
|
55
55
|
*/
|
|
56
56
|
enableLongPollingDowngrade: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Indicates that the container is ephemeral.
|
|
59
|
+
* Artifacts relates to the container are limited to container lifetime.
|
|
60
|
+
* Default: false
|
|
61
|
+
*/
|
|
62
|
+
isEphemeralContainer: boolean;
|
|
57
63
|
}
|