@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.
Files changed (180) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +4 -3
  3. package/dist/contracts.d.ts +28 -1
  4. package/dist/contracts.d.ts.map +1 -1
  5. package/dist/contracts.js.map +1 -1
  6. package/dist/createNewUtils.d.ts +1 -1
  7. package/dist/createNewUtils.js +3 -3
  8. package/dist/createNewUtils.js.map +1 -1
  9. package/dist/deltaStorageService.d.ts.map +1 -1
  10. package/dist/deltaStorageService.js +17 -6
  11. package/dist/deltaStorageService.js.map +1 -1
  12. package/dist/documentDeltaConnection.js +1 -1
  13. package/dist/documentDeltaConnection.js.map +1 -1
  14. package/dist/documentService.d.ts +3 -3
  15. package/dist/documentService.d.ts.map +1 -1
  16. package/dist/documentService.js +4 -4
  17. package/dist/documentService.js.map +1 -1
  18. package/dist/documentServiceFactory.d.ts.map +1 -1
  19. package/dist/documentServiceFactory.js +32 -10
  20. package/dist/documentServiceFactory.js.map +1 -1
  21. package/dist/documentStorageService.d.ts +2 -2
  22. package/dist/documentStorageService.d.ts.map +1 -1
  23. package/dist/documentStorageService.js +2 -2
  24. package/dist/documentStorageService.js.map +1 -1
  25. package/dist/errorUtils.d.ts +38 -6
  26. package/dist/errorUtils.d.ts.map +1 -1
  27. package/dist/errorUtils.js +32 -16
  28. package/dist/errorUtils.js.map +1 -1
  29. package/dist/gitManager.d.ts +3 -2
  30. package/dist/gitManager.d.ts.map +1 -1
  31. package/dist/gitManager.js +2 -2
  32. package/dist/gitManager.js.map +1 -1
  33. package/dist/historian.d.ts +3 -2
  34. package/dist/historian.d.ts.map +1 -1
  35. package/dist/historian.js +13 -6
  36. package/dist/historian.js.map +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +2 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/mapWithExpiration.js +2 -2
  42. package/dist/mapWithExpiration.js.map +1 -1
  43. package/dist/packageVersion.d.ts +1 -1
  44. package/dist/packageVersion.js +1 -1
  45. package/dist/packageVersion.js.map +1 -1
  46. package/dist/policies.d.ts +7 -1
  47. package/dist/policies.d.ts.map +1 -1
  48. package/dist/policies.js.map +1 -1
  49. package/dist/r11sSnapshotParser.d.ts +4 -5
  50. package/dist/r11sSnapshotParser.d.ts.map +1 -1
  51. package/dist/r11sSnapshotParser.js +13 -15
  52. package/dist/r11sSnapshotParser.js.map +1 -1
  53. package/dist/restWrapper.d.ts +3 -3
  54. package/dist/restWrapper.d.ts.map +1 -1
  55. package/dist/restWrapper.js +53 -36
  56. package/dist/restWrapper.js.map +1 -1
  57. package/dist/restWrapperBase.js +39 -5
  58. package/dist/restWrapperBase.js.map +1 -1
  59. package/dist/retriableGitManager.d.ts +3 -2
  60. package/dist/retriableGitManager.d.ts.map +1 -1
  61. package/dist/retriableGitManager.js +2 -2
  62. package/dist/retriableGitManager.js.map +1 -1
  63. package/dist/shreddedSummaryDocumentStorageService.js +13 -16
  64. package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
  65. package/dist/storageContracts.d.ts +4 -3
  66. package/dist/storageContracts.d.ts.map +1 -1
  67. package/dist/storageContracts.js.map +1 -1
  68. package/dist/summaryTreeUploadManager.d.ts.map +1 -1
  69. package/dist/summaryTreeUploadManager.js +11 -11
  70. package/dist/summaryTreeUploadManager.js.map +1 -1
  71. package/dist/treeUtils.d.ts +2 -2
  72. package/dist/treeUtils.d.ts.map +1 -1
  73. package/dist/treeUtils.js +8 -8
  74. package/dist/treeUtils.js.map +1 -1
  75. package/dist/wholeSummaryDocumentStorageService.d.ts +2 -2
  76. package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  77. package/dist/wholeSummaryDocumentStorageService.js +27 -22
  78. package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
  79. package/dist/wholeSummaryUploadManager.js +1 -2
  80. package/dist/wholeSummaryUploadManager.js.map +1 -1
  81. package/lib/contracts.d.ts +28 -1
  82. package/lib/contracts.d.ts.map +1 -1
  83. package/lib/contracts.js.map +1 -1
  84. package/lib/createNewUtils.d.ts +1 -1
  85. package/lib/createNewUtils.js +2 -2
  86. package/lib/createNewUtils.js.map +1 -1
  87. package/lib/deltaStorageService.d.ts.map +1 -1
  88. package/lib/deltaStorageService.js +17 -6
  89. package/lib/deltaStorageService.js.map +1 -1
  90. package/lib/documentDeltaConnection.js +1 -1
  91. package/lib/documentDeltaConnection.js.map +1 -1
  92. package/lib/documentService.d.ts +3 -3
  93. package/lib/documentService.d.ts.map +1 -1
  94. package/lib/documentService.js +4 -4
  95. package/lib/documentService.js.map +1 -1
  96. package/lib/documentServiceFactory.d.ts.map +1 -1
  97. package/lib/documentServiceFactory.js +32 -10
  98. package/lib/documentServiceFactory.js.map +1 -1
  99. package/lib/documentStorageService.d.ts +2 -2
  100. package/lib/documentStorageService.d.ts.map +1 -1
  101. package/lib/documentStorageService.js +2 -2
  102. package/lib/documentStorageService.js.map +1 -1
  103. package/lib/errorUtils.d.ts +38 -6
  104. package/lib/errorUtils.d.ts.map +1 -1
  105. package/lib/errorUtils.js +31 -15
  106. package/lib/errorUtils.js.map +1 -1
  107. package/lib/gitManager.d.ts +3 -2
  108. package/lib/gitManager.d.ts.map +1 -1
  109. package/lib/gitManager.js +2 -2
  110. package/lib/gitManager.js.map +1 -1
  111. package/lib/historian.d.ts +3 -2
  112. package/lib/historian.d.ts.map +1 -1
  113. package/lib/historian.js +12 -5
  114. package/lib/historian.js.map +1 -1
  115. package/lib/index.d.ts +1 -1
  116. package/lib/index.d.ts.map +1 -1
  117. package/lib/index.js +1 -1
  118. package/lib/index.js.map +1 -1
  119. package/lib/mapWithExpiration.js +1 -1
  120. package/lib/mapWithExpiration.js.map +1 -1
  121. package/lib/packageVersion.d.ts +1 -1
  122. package/lib/packageVersion.js +1 -1
  123. package/lib/packageVersion.js.map +1 -1
  124. package/lib/policies.d.ts +7 -1
  125. package/lib/policies.d.ts.map +1 -1
  126. package/lib/policies.js.map +1 -1
  127. package/lib/r11sSnapshotParser.d.ts +4 -5
  128. package/lib/r11sSnapshotParser.d.ts.map +1 -1
  129. package/lib/r11sSnapshotParser.js +11 -13
  130. package/lib/r11sSnapshotParser.js.map +1 -1
  131. package/lib/restWrapper.d.ts +3 -3
  132. package/lib/restWrapper.d.ts.map +1 -1
  133. package/lib/restWrapper.js +48 -31
  134. package/lib/restWrapper.js.map +1 -1
  135. package/lib/restWrapperBase.js +39 -5
  136. package/lib/restWrapperBase.js.map +1 -1
  137. package/lib/retriableGitManager.d.ts +3 -2
  138. package/lib/retriableGitManager.d.ts.map +1 -1
  139. package/lib/retriableGitManager.js +2 -2
  140. package/lib/retriableGitManager.js.map +1 -1
  141. package/lib/shreddedSummaryDocumentStorageService.js +12 -15
  142. package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
  143. package/lib/storageContracts.d.ts +4 -3
  144. package/lib/storageContracts.d.ts.map +1 -1
  145. package/lib/storageContracts.js.map +1 -1
  146. package/lib/summaryTreeUploadManager.d.ts.map +1 -1
  147. package/lib/summaryTreeUploadManager.js +4 -4
  148. package/lib/summaryTreeUploadManager.js.map +1 -1
  149. package/lib/treeUtils.d.ts +2 -2
  150. package/lib/treeUtils.d.ts.map +1 -1
  151. package/lib/treeUtils.js +4 -4
  152. package/lib/treeUtils.js.map +1 -1
  153. package/lib/wholeSummaryDocumentStorageService.d.ts +2 -2
  154. package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  155. package/lib/wholeSummaryDocumentStorageService.js +23 -18
  156. package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
  157. package/lib/wholeSummaryUploadManager.js +1 -2
  158. package/lib/wholeSummaryUploadManager.js.map +1 -1
  159. package/package.json +26 -28
  160. package/src/contracts.ts +45 -1
  161. package/src/createNewUtils.ts +2 -2
  162. package/src/deltaStorageService.ts +8 -1
  163. package/src/documentService.ts +5 -5
  164. package/src/documentServiceFactory.ts +21 -11
  165. package/src/documentStorageService.ts +3 -3
  166. package/src/errorUtils.ts +48 -30
  167. package/src/gitManager.ts +3 -3
  168. package/src/historian.ts +5 -5
  169. package/src/index.ts +1 -1
  170. package/src/mapWithExpiration.ts +1 -1
  171. package/src/packageVersion.ts +1 -1
  172. package/src/policies.ts +7 -1
  173. package/src/r11sSnapshotParser.ts +14 -15
  174. package/src/restWrapper.ts +34 -21
  175. package/src/retriableGitManager.ts +3 -3
  176. package/src/shreddedSummaryDocumentStorageService.ts +3 -3
  177. package/src/storageContracts.ts +3 -3
  178. package/src/summaryTreeUploadManager.ts +2 -7
  179. package/src/treeUtils.ts +4 -3
  180. 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.5.3.2.178189",
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
- "nyc": {
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
- "@fluidframework/common-definitions": "^0.20.1",
39
- "@fluidframework/common-utils": "^1.1.1",
40
- "@fluidframework/core-interfaces": "2.0.0-dev.5.3.2.178189",
41
- "@fluidframework/driver-base": "2.0.0-dev.5.3.2.178189",
42
- "@fluidframework/driver-definitions": "2.0.0-dev.5.3.2.178189",
43
- "@fluidframework/driver-utils": "2.0.0-dev.5.3.2.178189",
44
- "@fluidframework/gitresources": "^0.1039.1000",
45
- "@fluidframework/protocol-base": "^0.1039.1000",
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.1039.1000",
48
- "@fluidframework/telemetry-utils": "2.0.0-dev.5.3.2.178189",
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": "^8.3.1"
53
+ "uuid": "^9.0.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@fluid-tools/build-cli": "^0.21.0",
57
- "@fluidframework/build-common": "^1.2.0",
58
- "@fluidframework/build-tools": "^0.21.0",
59
- "@fluidframework/eslint-config-fluid": "^2.0.0",
60
- "@fluidframework/mocha-test-setup": "2.0.0-dev.5.3.2.178189",
61
- "@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@2.0.0-internal.5.2.0",
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": "^14.18.38",
65
+ "@types/node": "^16.18.38",
66
66
  "@types/sinon": "^7.0.13",
67
67
  "@types/url-parse": "1.4.4",
68
- "@types/uuid": "^8.3.0",
68
+ "@types/uuid": "^9.0.2",
69
69
  "axios": "^0.26.0",
70
- "concurrently": "^7.6.0",
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": "^10.0.1",
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": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
107
- "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
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 INormalizedWholeSummary {
55
+ export interface INormalizedWholeSnapshot {
12
56
  blobs: Map<string, ArrayBuffer>;
13
57
  snapshotTree: ISnapshotTree;
14
58
  sequenceNumber: number | undefined;
@@ -3,13 +3,13 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { Uint8ArrayToString } from "@fluidframework/common-utils";
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 - Modified summary tree where the blob contents could be utf8 string only.
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
- const MaxBatchDeltas = 5000; // Maximum number of ops we can fetch at a time
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
@@ -3,9 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/common-utils";
6
+ import { assert } from "@fluidframework/core-utils";
7
7
  import * as api from "@fluidframework/driver-definitions";
8
- import { DriverErrorType } from "@fluidframework/driver-definitions";
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 { INormalizedWholeSummary } from "./contracts";
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<INormalizedWholeSummary>,
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
- DriverErrorType.fetchTokenError,
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/common-utils";
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 { ChildLogger, PerformanceEvent } from "@fluidframework/telemetry-utils";
25
- import { ISession } from "@fluidframework/server-services-client";
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 { INormalizedWholeSummary } from "./contracts";
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<INormalizedWholeSummary> = new NullCache();
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<INormalizedWholeSummary>(
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 = ChildLogger.create(logger, "RouterliciousDriver");
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: convertSummaryToCreateNewSummary(appSummary),
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 = ChildLogger.create(logger, "RouterliciousDriver", {
251
- all: { driverVersion },
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 { INormalizedWholeSummary } from "./contracts";
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<INormalizedWholeSummary>,
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<INormalizedWholeSummary>,
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 { DriverError } from "@fluidframework/driver-definitions";
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?: number,
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
- return new AuthorizationError(errorMessage, undefined, undefined, props);
102
+ error = new AuthorizationError(errorMessage, undefined, undefined, props);
103
+ break;
96
104
  case 404:
97
105
  const errorType = RouterliciousErrorType.fileNotFoundOrAccessDeniedError;
98
- return new NonRetryableError(errorMessage, errorType, props);
106
+ error = new NonRetryableError(errorMessage, errorType, props);
107
+ break;
99
108
  case 429:
100
- return createGenericNetworkError(errorMessage, { canRetry: true, retryAfterMs }, props);
109
+ error = createGenericNetworkError(
110
+ errorMessage,
111
+ { canRetry: true, retryAfterMs },
112
+ props,
113
+ );
114
+ break;
101
115
  case 500:
102
116
  case 502:
103
- return new GenericNetworkError(errorMessage, true, props);
117
+ error = new GenericNetworkError(errorMessage, true, props);
118
+ break;
104
119
  default:
105
120
  const retryInfo = { canRetry: retryAfterMs !== undefined, retryAfterMs };
106
- return createGenericNetworkError(errorMessage, retryInfo, props);
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?: number,
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 getSummary(sha: string): Promise<IR11sResponse<IWholeFlatSummary>> {
114
- return this.historian.getSummary(sha);
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 "@fluidframework/common-utils";
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 getSummary(sha: string): Promise<IR11sResponse<IWholeFlatSummary>> {
102
- return this.restWrapper.get<IWholeFlatSummary>(
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 {
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/common-utils";
6
+ import { assert } from "@fluidframework/core-utils";
7
7
 
8
8
  /**
9
9
  * An extension of Map that expires (deletes) entries after a period of inactivity.
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/routerlicious-driver";
9
- export const pkgVersion = "2.0.0-dev.5.3.2.178189";
9
+ export const pkgVersion = "2.0.0-dev.6.4.0.191258";
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?: boolean;
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
  }