@fluidframework/driver-utils 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191457

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 (128) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +4 -3
  3. package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.js +4 -1
  4. package/dist/adapters/compression/documentServiceFactoryCompressionAdapter.js.map +1 -1
  5. package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +18 -18
  6. package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
  7. package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +34 -33
  8. package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
  9. package/dist/adapters/predefinedAdapters.d.ts +1 -1
  10. package/dist/adapters/predefinedAdapters.d.ts.map +1 -1
  11. package/dist/adapters/predefinedAdapters.js +4 -4
  12. package/dist/adapters/predefinedAdapters.js.map +1 -1
  13. package/dist/buildSnapshotTree.d.ts.map +1 -1
  14. package/dist/buildSnapshotTree.js +5 -4
  15. package/dist/buildSnapshotTree.js.map +1 -1
  16. package/dist/documentStorageServiceProxy.d.ts.map +1 -1
  17. package/dist/documentStorageServiceProxy.js +1 -3
  18. package/dist/documentStorageServiceProxy.js.map +1 -1
  19. package/dist/error.d.ts.map +1 -1
  20. package/dist/error.js +2 -0
  21. package/dist/error.js.map +1 -1
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +2 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/insecureUrlResolver.js +4 -6
  27. package/dist/insecureUrlResolver.js.map +1 -1
  28. package/dist/network.d.ts +1 -1
  29. package/dist/network.d.ts.map +1 -1
  30. package/dist/network.js +11 -5
  31. package/dist/network.js.map +1 -1
  32. package/dist/networkUtils.js +3 -4
  33. package/dist/networkUtils.js.map +1 -1
  34. package/dist/packageVersion.d.ts +1 -1
  35. package/dist/packageVersion.js +1 -1
  36. package/dist/packageVersion.js.map +1 -1
  37. package/dist/parallelRequests.d.ts +2 -2
  38. package/dist/parallelRequests.d.ts.map +1 -1
  39. package/dist/parallelRequests.js +63 -45
  40. package/dist/parallelRequests.js.map +1 -1
  41. package/dist/prefetchDocumentStorageService.js +1 -1
  42. package/dist/prefetchDocumentStorageService.js.map +1 -1
  43. package/dist/rateLimiter.js +2 -2
  44. package/dist/rateLimiter.js.map +1 -1
  45. package/dist/readAndParse.js +2 -2
  46. package/dist/readAndParse.js.map +1 -1
  47. package/dist/runWithRetry.d.ts +8 -0
  48. package/dist/runWithRetry.d.ts.map +1 -1
  49. package/dist/runWithRetry.js +37 -13
  50. package/dist/runWithRetry.js.map +1 -1
  51. package/dist/summaryForCreateNew.d.ts +0 -9
  52. package/dist/summaryForCreateNew.d.ts.map +1 -1
  53. package/dist/summaryForCreateNew.js +4 -27
  54. package/dist/summaryForCreateNew.js.map +1 -1
  55. package/dist/treeConversions.d.ts.map +1 -1
  56. package/dist/treeConversions.js +4 -3
  57. package/dist/treeConversions.js.map +1 -1
  58. package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.js +4 -1
  59. package/lib/adapters/compression/documentServiceFactoryCompressionAdapter.js.map +1 -1
  60. package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts +18 -18
  61. package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
  62. package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js +22 -21
  63. package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
  64. package/lib/adapters/predefinedAdapters.d.ts +1 -1
  65. package/lib/adapters/predefinedAdapters.d.ts.map +1 -1
  66. package/lib/adapters/predefinedAdapters.js +3 -3
  67. package/lib/adapters/predefinedAdapters.js.map +1 -1
  68. package/lib/buildSnapshotTree.d.ts.map +1 -1
  69. package/lib/buildSnapshotTree.js +4 -3
  70. package/lib/buildSnapshotTree.js.map +1 -1
  71. package/lib/documentStorageServiceProxy.d.ts.map +1 -1
  72. package/lib/documentStorageServiceProxy.js +1 -3
  73. package/lib/documentStorageServiceProxy.js.map +1 -1
  74. package/lib/error.d.ts.map +1 -1
  75. package/lib/error.js +2 -0
  76. package/lib/error.js.map +1 -1
  77. package/lib/index.d.ts +2 -2
  78. package/lib/index.d.ts.map +1 -1
  79. package/lib/index.js +2 -2
  80. package/lib/index.js.map +1 -1
  81. package/lib/insecureUrlResolver.js +3 -5
  82. package/lib/insecureUrlResolver.js.map +1 -1
  83. package/lib/network.d.ts +1 -1
  84. package/lib/network.d.ts.map +1 -1
  85. package/lib/network.js +14 -6
  86. package/lib/network.js.map +1 -1
  87. package/lib/networkUtils.js +3 -4
  88. package/lib/networkUtils.js.map +1 -1
  89. package/lib/packageVersion.d.ts +1 -1
  90. package/lib/packageVersion.js +1 -1
  91. package/lib/packageVersion.js.map +1 -1
  92. package/lib/parallelRequests.d.ts +2 -2
  93. package/lib/parallelRequests.d.ts.map +1 -1
  94. package/lib/parallelRequests.js +33 -15
  95. package/lib/parallelRequests.js.map +1 -1
  96. package/lib/prefetchDocumentStorageService.js +1 -1
  97. package/lib/prefetchDocumentStorageService.js.map +1 -1
  98. package/lib/rateLimiter.js +1 -1
  99. package/lib/rateLimiter.js.map +1 -1
  100. package/lib/readAndParse.js +1 -1
  101. package/lib/readAndParse.js.map +1 -1
  102. package/lib/runWithRetry.d.ts +8 -0
  103. package/lib/runWithRetry.d.ts.map +1 -1
  104. package/lib/runWithRetry.js +30 -7
  105. package/lib/runWithRetry.js.map +1 -1
  106. package/lib/summaryForCreateNew.d.ts +0 -9
  107. package/lib/summaryForCreateNew.d.ts.map +1 -1
  108. package/lib/summaryForCreateNew.js +3 -25
  109. package/lib/summaryForCreateNew.js.map +1 -1
  110. package/lib/treeConversions.d.ts.map +1 -1
  111. package/lib/treeConversions.js +2 -1
  112. package/lib/treeConversions.js.map +1 -1
  113. package/package.json +21 -22
  114. package/src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts +20 -19
  115. package/src/adapters/predefinedAdapters.ts +5 -3
  116. package/src/buildSnapshotTree.ts +4 -3
  117. package/src/documentStorageServiceProxy.ts +0 -1
  118. package/src/error.ts +2 -0
  119. package/src/index.ts +1 -2
  120. package/src/insecureUrlResolver.ts +1 -1
  121. package/src/network.ts +9 -1
  122. package/src/packageVersion.ts +1 -1
  123. package/src/parallelRequests.ts +5 -4
  124. package/src/rateLimiter.ts +1 -1
  125. package/src/readAndParse.ts +1 -1
  126. package/src/runWithRetry.ts +32 -7
  127. package/src/summaryForCreateNew.ts +0 -31
  128. package/src/treeConversions.ts +2 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/driver-utils",
3
- "version": "2.0.0-dev.5.3.2.178189",
3
+ "version": "2.0.0-dev.6.4.0.191457",
4
4
  "description": "Collection of utility functions for Fluid drivers",
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,30 +35,31 @@
35
35
  "temp-directory": "nyc/.nyc_output"
36
36
  },
37
37
  "dependencies": {
38
- "@fluidframework/common-utils": "^1.1.1",
39
- "@fluidframework/core-interfaces": "2.0.0-dev.5.3.2.178189",
40
- "@fluidframework/driver-definitions": "2.0.0-dev.5.3.2.178189",
41
- "@fluidframework/gitresources": "^0.1039.1000",
42
- "@fluidframework/protocol-base": "^0.1039.1000",
38
+ "@fluid-internal/client-utils": "2.0.0-dev.6.4.0.191457",
39
+ "@fluidframework/core-interfaces": "2.0.0-dev.6.4.0.191457",
40
+ "@fluidframework/core-utils": "2.0.0-dev.6.4.0.191457",
41
+ "@fluidframework/driver-definitions": "2.0.0-dev.6.4.0.191457",
42
+ "@fluidframework/gitresources": "^1.0.1",
43
+ "@fluidframework/protocol-base": "^1.0.1",
43
44
  "@fluidframework/protocol-definitions": "^1.1.0",
44
- "@fluidframework/telemetry-utils": "2.0.0-dev.5.3.2.178189",
45
+ "@fluidframework/telemetry-utils": "2.0.0-dev.6.4.0.191457",
45
46
  "axios": "^0.26.0",
46
47
  "lz4js": "^0.2.0",
47
48
  "url": "^0.11.0",
48
- "uuid": "^8.3.1"
49
+ "uuid": "^9.0.0"
49
50
  },
50
51
  "devDependencies": {
51
- "@fluid-tools/build-cli": "^0.21.0",
52
- "@fluidframework/build-common": "^1.2.0",
53
- "@fluidframework/build-tools": "^0.21.0",
54
- "@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@2.0.0-internal.5.2.0",
55
- "@fluidframework/eslint-config-fluid": "^2.0.0",
56
- "@fluidframework/mocha-test-setup": "2.0.0-dev.5.3.2.178189",
52
+ "@fluid-tools/build-cli": "^0.22.0",
53
+ "@fluidframework/build-common": "^2.0.0",
54
+ "@fluidframework/build-tools": "^0.22.0",
55
+ "@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@2.0.0-internal.6.3.0",
56
+ "@fluidframework/eslint-config-fluid": "^2.1.0",
57
+ "@fluidframework/mocha-test-setup": "2.0.0-dev.6.4.0.191457",
57
58
  "@microsoft/api-extractor": "^7.34.4",
58
59
  "@types/mocha": "^9.1.1",
59
- "@types/node": "^14.18.38",
60
+ "@types/node": "^16.18.38",
60
61
  "@types/sinon": "^7.0.13",
61
- "concurrently": "^7.6.0",
62
+ "c8": "^7.7.1",
62
63
  "copyfiles": "^2.4.1",
63
64
  "cross-env": "^7.0.3",
64
65
  "eslint": "~8.6.0",
@@ -66,7 +67,6 @@
66
67
  "mocha-json-output-reporter": "^2.0.1",
67
68
  "mocha-multi-reporters": "^1.5.1",
68
69
  "moment": "^2.21.0",
69
- "nyc": "^15.1.0",
70
70
  "prettier": "~2.6.2",
71
71
  "rimraf": "^4.4.0",
72
72
  "sinon": "^7.4.2",
@@ -84,7 +84,7 @@
84
84
  "build:genver": "gen-version",
85
85
  "build:test": "tsc --project ./src/test/tsconfig.json",
86
86
  "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
87
- "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
87
+ "clean": "rimraf --glob 'dist' 'lib' '*.tsbuildinfo' '*.build.log' '_api-extractor-temp' 'nyc'",
88
88
  "eslint": "eslint --format stylish src",
89
89
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
90
90
  "format": "npm run prettier:fix",
@@ -93,9 +93,8 @@
93
93
  "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
94
94
  "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
95
95
  "test": "npm run test:mocha",
96
- "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
97
- "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
98
- "test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
96
+ "test:coverage": "c8 npm test",
97
+ "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
99
98
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
100
99
  "tsc": "tsc",
101
100
  "typetests:gen": "fluid-type-test-generator",
@@ -3,7 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { IsoBuffer, assert } from "@fluidframework/common-utils";
6
+ import { IsoBuffer } from "@fluid-internal/client-utils";
7
+ import { assert } from "@fluidframework/core-utils";
7
8
  import { IDocumentStorageService, ISummaryContext } from "@fluidframework/driver-definitions";
8
9
  import {
9
10
  ISnapshotTree,
@@ -47,9 +48,9 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
47
48
  }
48
49
 
49
50
  /**
50
- * This method returns true if there is a compression markup byte in the blob, otherwise false.
51
+ * This method returns `true` if there is a compression markup byte in the blob, otherwise `false`.
51
52
  * @param blob - The blob to compress.
52
- * @returns - True if there is a compression markup byte in the blob, otherwise false.
53
+ * @returns `true` if there is a compression markup byte in the blob, otherwise `false`.
53
54
  */
54
55
  private static hasPrefix(blob: ArrayBufferLike): boolean {
55
56
  const firstByte = IsoBuffer.from(blob)[0];
@@ -72,7 +73,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
72
73
  * This method writes the given algorithm to the blob as the first byte.
73
74
  * @param blob - The blob to write the algorithm to.
74
75
  * @param algorithm - The algorithm to write.
75
- * @returns - The blob with the algorithm as the first byte.
76
+ * @returns The blob with the algorithm as the first byte.
76
77
  */
77
78
  private static writeAlgorithmToBlob(blob: ArrayBufferLike, algorithm: number): ArrayBufferLike {
78
79
  if (algorithm === SummaryCompressionAlgorithm.None) {
@@ -96,7 +97,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
96
97
  /**
97
98
  * This method removes the algorithm markup prefix from the blob (1 byte)
98
99
  * @param blob - The blob to remove the prefix from.
99
- * @returns - The blob without the prefix.
100
+ * @returns The blob without the prefix.
100
101
  */
101
102
  private static removePrefixFromBlobIfPresent(blob: ArrayBufferLike): ArrayBufferLike {
102
103
  const blobView = new Uint8Array(blob);
@@ -108,7 +109,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
108
109
  * it is just returned as is. If the parameter is string, it is converted to Uint8Array using
109
110
  * TextEncoder.
110
111
  * @param input - The input to convert to Uint8Array.
111
- * @returns - The Uint8Array representation of the input.
112
+ * @returns The Uint8Array representation of the input.
112
113
  */
113
114
  private static toBinaryArray(input: string | Uint8Array): Uint8Array {
114
115
  return typeof input === "string" ? new TextEncoder().encode(input) : input;
@@ -119,7 +120,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
119
120
  * containing the compression algorithm.
120
121
  * @param input - The summary object to encode.
121
122
  * @param config - The config containing the compression algorithm.
122
- * @returns - The summary object with the encoded blob.
123
+ * @returns The summary object with the encoded blob.
123
124
  */
124
125
  private static readonly blobEncoder = (
125
126
  input: SummaryObject,
@@ -146,7 +147,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
146
147
  /**
147
148
  * This method decodes the blob inside the given summary object of the SummaryType.Blob type.
148
149
  * @param input - The summary object to decode.
149
- * @returns - The summary object with the decoded blob.
150
+ * @returns The summary object with the decoded blob.
150
151
  */
151
152
  private static readonly blobDecoder = (input: SummaryObject): SummaryObject => {
152
153
  if (input.type === SummaryType.Blob) {
@@ -170,7 +171,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
170
171
  * This method encodes the given blob according to the given config.
171
172
  * @param file - The blob to encode.
172
173
  * @param config - The config to use for encoding.
173
- * @returns - The encoded blob.
174
+ * @returns The encoded blob.
174
175
  */
175
176
  private static encodeBlob(
176
177
  file: ArrayBufferLike,
@@ -199,7 +200,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
199
200
  /**
200
201
  * This method decodes the given blob.
201
202
  * @param file - The blob to decode.
202
- * @returns - The decoded blob.
203
+ * @returns The decoded blob.
203
204
  */
204
205
  private static decodeBlob(file: ArrayBufferLike): ArrayBufferLike {
205
206
  let decompressed: ArrayBufferLike;
@@ -231,7 +232,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
231
232
  * @param decoder - The decoder function to use.
232
233
  * @param config - The config to use for encoding.
233
234
  * @param context - The summary context.
234
- * @returns - The summary object with the encoded/decoded blob.
235
+ * @returns The summary object with the encoded/decoded blob.
235
236
  */
236
237
  private static recursivelyReplace(
237
238
  isEncode: boolean,
@@ -274,7 +275,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
274
275
  * it returns the summary tree containing that blob.
275
276
  *
276
277
  * @param summary - The summary tree to traverse.
277
- * @returns - The summary tree containing the metadata blob.
278
+ * @returns The summary tree containing the metadata blob.
278
279
  */
279
280
  private static findMetadataHolderSummary(summary: ISummaryTree): ISummaryTree | undefined {
280
281
  assert(typeof summary === "object", 0x6f7 /* summary must be a non-null object */);
@@ -298,7 +299,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
298
299
  * This method obtains the summary tree containing the metadata blob. It returns the content
299
300
  * of the tree atribute.
300
301
  * @param summary - The summary tree to traverse.
301
- * @returns - The content of the tree attribute of the summary tree containing the metadata blob.
302
+ * @returns The content of the tree attribute of the summary tree containing the metadata blob.
302
303
  */
303
304
  private static getMetadataHolderTree(summary: ISummaryTree) {
304
305
  const metadataHolder = this.findMetadataHolderSummary(summary);
@@ -325,7 +326,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
325
326
  * it checks, if the SummaryTree holder of that object also contains the compression markup blob. If it is found,
326
327
  * it returns true, otherwise false.
327
328
  * @param snapshot - The snapshot tree to traverse.
328
- * @returns - True if the compression markup blob is found, otherwise false.
329
+ * @returns True if the compression markup blob is found, otherwise false.
329
330
  */
330
331
  private static hasCompressionMarkup(snapshot: ISnapshotTree): boolean {
331
332
  assert(typeof snapshot === "object", 0x6f9 /* snapshot must be a non-null object */);
@@ -353,7 +354,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
353
354
  * This method performs compression of the blobs in the summary tree.
354
355
  * @param summary - The summary tree to compress.
355
356
  * @param config - The compression config.
356
- * @returns - The compressed summary tree.
357
+ * @returns The compressed summary tree.
357
358
  */
358
359
  public static compressSummary(
359
360
  summary: ISummaryTree,
@@ -374,7 +375,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
374
375
  /**
375
376
  * This method read blob from the storage and decompresses it if it is compressed.
376
377
  * @param id - The id of the blob to read.
377
- * @returns - The decompressed blob.
378
+ * @returns The decompressed blob.
378
379
  */
379
380
  public override async readBlob(id: string): Promise<ArrayBufferLike> {
380
381
  const originalBlob = await super.readBlob(id);
@@ -394,7 +395,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
394
395
  * algorithm byte prefix and store them.
395
396
  * @param version - The version of the snapshot tree to load.
396
397
  * @param scenarioName - The scenario name of the snapshot tree to load.
397
- * @returns - The snapshot tree.
398
+ * @returns The snapshot tree.
398
399
  */
399
400
  public override async getSnapshotTree(
400
401
  version?: IVersion | undefined,
@@ -413,7 +414,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
413
414
  * This method uploads the summary to the storage. It performs compression of the blobs in the summary tree.
414
415
  * @param summary - The summary tree to upload.
415
416
  * @param context - The summary context.
416
- * @returns - The ID of the uploaded summary.
417
+ * @returns The ID of the uploaded summary.
417
418
  */
418
419
  public override async uploadSummaryWithContext(
419
420
  summary: ISummaryTree,
@@ -429,7 +430,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
429
430
  /**
430
431
  * This method downloads the summary from the storage and then applies decompression on the compressed blobs.
431
432
  * @param id - The ID of the summary to be downloaded
432
- * @returns - The summary with decompressed blobs
433
+ * @returns The summary with decompressed blobs
433
434
  */
434
435
  public override async downloadSummary(id: ISummaryHandle): Promise<ISummaryTree> {
435
436
  const summary = await super.downloadSummary(id);
@@ -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 { IDocumentServiceFactory } from "@fluidframework/driver-definitions";
8
8
  import {
9
9
  DocumentServiceFactoryCompressionAdapter,
@@ -16,7 +16,7 @@ import {
16
16
  * must be enabled by setting the config to true or by passing a compression config object.
17
17
  * @param documentServiceFactory - The document service factory to apply compression to.
18
18
  * @param config - The compression configuration.
19
- * @returns - The document service factory possibly with compression applied.
19
+ * @returns The document service factory possibly with compression applied.
20
20
  */
21
21
  export function applyStorageCompression(
22
22
  documentServiceFactory: IDocumentServiceFactory,
@@ -43,11 +43,13 @@ export function applyStorageCompression(
43
43
  * This method applies compression to the given document service factory.
44
44
  * @param documentServiceFactory - The document service factory to apply compression to.
45
45
  * @param config - The compression configuration.
46
- * @returns - The document service factory with compression applied.
46
+ * @returns The document service factory with compression applied.
47
47
  */
48
48
  function applyStorageCompressionInternal(
49
49
  constructor: new (
50
+ // eslint-disable-next-line @typescript-eslint/no-shadow
50
51
  documentServiceFactory: IDocumentServiceFactory,
52
+ // eslint-disable-next-line @typescript-eslint/no-shadow
51
53
  config: ICompressionStorageConfig,
52
54
  ) => IDocumentServiceFactory,
53
55
  documentServiceFactory: IDocumentServiceFactory,
@@ -3,7 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert, stringToBuffer } from "@fluidframework/common-utils";
6
+ import { stringToBuffer } from "@fluid-internal/client-utils";
7
+ import { assert } from "@fluidframework/core-utils";
7
8
  import * as git from "@fluidframework/gitresources";
8
9
  import {
9
10
  FileMode,
@@ -11,7 +12,7 @@ import {
11
12
  ITreeEntry,
12
13
  TreeEntry,
13
14
  } from "@fluidframework/protocol-definitions";
14
- import { buildHierarchy } from "@fluidframework/protocol-base";
15
+ import { buildGitTreeHierarchy } from "@fluidframework/protocol-base";
15
16
  import { v4 as uuid } from "uuid";
16
17
 
17
18
  function flattenCore(
@@ -91,5 +92,5 @@ export function buildSnapshotTree(
91
92
  blobMap: Map<string, ArrayBufferLike>,
92
93
  ): ISnapshotTree {
93
94
  const flattened = flatten(entries, blobMap);
94
- return buildHierarchy(flattened);
95
+ return buildGitTreeHierarchy(flattened);
95
96
  }
@@ -54,7 +54,6 @@ export class DocumentStorageServiceProxy implements IDocumentStorageService {
54
54
  summary: ISummaryTree,
55
55
  context: ISummaryContext,
56
56
  ): Promise<string> {
57
- console.log(`Summary uploaded: ${JSON.stringify(summary).length} bytes`);
58
57
  return this.internalStorageService.uploadSummaryWithContext(summary, context);
59
58
  }
60
59
 
package/src/error.ts CHANGED
@@ -3,11 +3,13 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ // eslint-disable-next-line import/no-deprecated
6
7
  import { DriverErrorType, IDriverErrorBase } from "@fluidframework/driver-definitions";
7
8
  import { IFluidErrorBase, LoggingError } from "@fluidframework/telemetry-utils";
8
9
 
9
10
  /** Error indicating an API is being used improperly resulting in an invalid operation. */
10
11
  export class UsageError extends LoggingError implements IDriverErrorBase, IFluidErrorBase {
12
+ // eslint-disable-next-line import/no-deprecated
11
13
  readonly errorType = DriverErrorType.usageError;
12
14
  readonly canRetry = false;
13
15
 
package/src/index.ts CHANGED
@@ -40,9 +40,8 @@ export {
40
40
  export { PrefetchDocumentStorageService } from "./prefetchDocumentStorageService";
41
41
  export { RateLimiter } from "./rateLimiter";
42
42
  export { readAndParse } from "./readAndParse";
43
- export { IProgress, runWithRetry } from "./runWithRetry";
43
+ export { calculateMaxWaitTime, IProgress, runWithRetry } from "./runWithRetry";
44
44
  export {
45
- combineAppAndProtocolSummary,
46
45
  CombinedAppAndProtocolSummary,
47
46
  getDocAttributesFromProtocolSummary,
48
47
  getQuorumValuesFromProtocolSummary,
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { parse } from "url";
7
- import { assert } from "@fluidframework/common-utils";
7
+ import { assert } from "@fluidframework/core-utils";
8
8
  import { IRequest } from "@fluidframework/core-interfaces";
9
9
  import { IResolvedUrl, IUrlResolver, DriverHeader } from "@fluidframework/driver-definitions";
10
10
  import Axios from "axios";
package/src/network.ts CHANGED
@@ -7,9 +7,11 @@ import {
7
7
  IThrottlingWarning,
8
8
  IDriverErrorBase,
9
9
  IAuthorizationError,
10
+ // eslint-disable-next-line import/no-deprecated
10
11
  DriverErrorType,
11
12
  ILocationRedirectionError,
12
13
  IResolvedUrl,
14
+ DriverErrorTypes,
13
15
  } from "@fluidframework/driver-definitions";
14
16
  import { ITelemetryProperties } from "@fluidframework/core-interfaces";
15
17
  import { IFluidErrorBase, LoggingError } from "@fluidframework/telemetry-utils";
@@ -43,6 +45,7 @@ export type DriverErrorTelemetryProps = ITelemetryProperties & {
43
45
  * Generic network error class.
44
46
  */
45
47
  export class GenericNetworkError extends LoggingError implements IDriverErrorBase, IFluidErrorBase {
48
+ // eslint-disable-next-line import/no-deprecated
46
49
  readonly errorType = DriverErrorType.genericNetworkError;
47
50
 
48
51
  constructor(message: string, readonly canRetry: boolean, props: DriverErrorTelemetryProps) {
@@ -57,6 +60,7 @@ export class FluidInvalidSchemaError
57
60
  extends LoggingError
58
61
  implements IDriverErrorBase, IFluidErrorBase
59
62
  {
63
+ // eslint-disable-next-line import/no-deprecated
60
64
  readonly errorType = DriverErrorType.fluidInvalidSchema;
61
65
  readonly canRetry = false;
62
66
 
@@ -69,6 +73,7 @@ export class DeltaStreamConnectionForbiddenError
69
73
  extends LoggingError
70
74
  implements IDriverErrorBase, IFluidErrorBase
71
75
  {
76
+ // eslint-disable-next-line import/no-deprecated
72
77
  static readonly errorType = DriverErrorType.deltaStreamConnectionForbidden;
73
78
  readonly errorType = DeltaStreamConnectionForbiddenError.errorType;
74
79
  readonly canRetry = false;
@@ -84,6 +89,7 @@ export class AuthorizationError
84
89
  extends LoggingError
85
90
  implements IAuthorizationError, IFluidErrorBase
86
91
  {
92
+ // eslint-disable-next-line import/no-deprecated
87
93
  readonly errorType = DriverErrorType.authorizationError;
88
94
  readonly canRetry = false;
89
95
 
@@ -102,6 +108,7 @@ export class LocationRedirectionError
102
108
  extends LoggingError
103
109
  implements ILocationRedirectionError, IFluidErrorBase
104
110
  {
111
+ // eslint-disable-next-line import/no-deprecated
105
112
  readonly errorType = DriverErrorType.locationRedirection;
106
113
  readonly canRetry = false;
107
114
 
@@ -142,6 +149,7 @@ export class RetryableError<T extends string> extends NetworkErrorBasic<T> {
142
149
  * Throttling error class - used to communicate all throttling errors
143
150
  */
144
151
  export class ThrottlingError extends LoggingError implements IThrottlingWarning, IFluidErrorBase {
152
+ // eslint-disable-next-line import/no-deprecated
145
153
  readonly errorType = DriverErrorType.throttlingError;
146
154
  readonly canRetry = true;
147
155
 
@@ -155,7 +163,7 @@ export class ThrottlingError extends LoggingError implements IThrottlingWarning,
155
163
  }
156
164
 
157
165
  export const createWriteError = (message: string, props: DriverErrorTelemetryProps) =>
158
- new NonRetryableError(message, DriverErrorType.writeError, props);
166
+ new NonRetryableError(message, DriverErrorTypes.writeError, props);
159
167
 
160
168
  export function createGenericNetworkError(
161
169
  message: string,
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/driver-utils";
9
- export const pkgVersion = "2.0.0-dev.5.3.2.178189";
9
+ export const pkgVersion = "2.0.0-dev.6.4.0.191457";
@@ -2,8 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert, Deferred, performance } from "@fluidframework/common-utils";
5
+ import { performance } from "@fluid-internal/client-utils";
6
6
  import { ITelemetryProperties } from "@fluidframework/core-interfaces";
7
+ import { assert, Deferred } from "@fluidframework/core-utils";
7
8
  import { ITelemetryLoggerExt, PerformanceEvent } from "@fluidframework/telemetry-utils";
8
9
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
9
10
  import { IDeltasFetchResult, IStream, IStreamResult } from "@fluidframework/driver-definitions";
@@ -27,7 +28,7 @@ type WorkingState = "working" | "done" | "canceled";
27
28
  * @param payloadSize - batch size
28
29
  * @param logger - logger to use
29
30
  * @param requestCallback - callback to request batches
30
- * @returns - Queue that can be used to retrieve data
31
+ * @returns Queue that can be used to retrieve data
31
32
  */
32
33
  export class ParallelRequests<T> {
33
34
  private latestRequested: number;
@@ -404,7 +405,7 @@ const waitForOnline = async (): Promise<void> => {
404
405
  * @param logger - logger object to use to log progress & errors
405
406
  * @param signal - cancelation signal
406
407
  * @param scenarioName - reason for fetching ops
407
- * @returns - an object with resulting ops and cancellation / partial result flags
408
+ * @returns An object with resulting ops and cancellation / partial result flags
408
409
  */
409
410
  async function getSingleOpBatch(
410
411
  get: (telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,
@@ -529,7 +530,7 @@ async function getSingleOpBatch(
529
530
  * @param logger - Logger to log progress and errors
530
531
  * @param signal - Cancelation signal
531
532
  * @param scenarioName - Reason for fetching ops
532
- * @returns - Messages fetched
533
+ * @returns Messages fetched
533
534
  */
534
535
  export function requestOps(
535
536
  get: (
@@ -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
  export class RateLimiter {
9
9
  private readonly tasks: (() => void)[] = [];
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { bufferToString } from "@fluidframework/common-utils";
6
+ import { bufferToString } from "@fluid-internal/client-utils";
7
7
  import { IDocumentStorageService } from "@fluidframework/driver-definitions";
8
8
 
9
9
  /**
@@ -3,9 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
7
- import { delay, performance } from "@fluidframework/common-utils";
8
- import { DriverErrorType } from "@fluidframework/driver-definitions";
6
+ import { ITelemetryLoggerExt, isFluidError } from "@fluidframework/telemetry-utils";
7
+ import { performance } from "@fluid-internal/client-utils";
8
+ import { delay } from "@fluidframework/core-utils";
9
+ import { DriverErrorTypes } from "@fluidframework/driver-definitions";
9
10
  import { canRetryOnError, getRetryDelayFromError } from "./network";
10
11
  import { pkgVersion } from "./packageVersion";
11
12
  import { NonRetryableError } from ".";
@@ -80,13 +81,20 @@ export async function runWithRetry<T>(
80
81
  retry: numRetries,
81
82
  duration: performance.now() - startTime,
82
83
  fetchCallName,
84
+ // TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
85
+ reason: (progress.cancel as AbortSignal & { reason: any }).reason,
83
86
  },
84
87
  err,
85
88
  );
86
89
  throw new NonRetryableError(
87
90
  "runWithRetry was Aborted",
88
- DriverErrorType.genericError,
89
- { driverVersion: pkgVersion, fetchCallName },
91
+ DriverErrorTypes.genericError,
92
+ {
93
+ driverVersion: pkgVersion,
94
+ fetchCallName,
95
+ // TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
96
+ reason: (progress.cancel as AbortSignal & { reason: any }).reason,
97
+ },
90
98
  );
91
99
  }
92
100
 
@@ -107,8 +115,9 @@ export async function runWithRetry<T>(
107
115
  numRetries++;
108
116
  lastError = err;
109
117
  // If the error is throttling error, then wait for the specified time before retrying.
110
- // If the waitTime is not specified, then we start with retrying immediately to max of 8s.
111
- retryAfterMs = getRetryDelayFromError(err) ?? Math.min(retryAfterMs * 2, 8000);
118
+ retryAfterMs =
119
+ getRetryDelayFromError(err) ??
120
+ Math.min(retryAfterMs * 2, calculateMaxWaitTime(err));
112
121
  if (progress.onRetry) {
113
122
  progress.onRetry(retryAfterMs, err);
114
123
  }
@@ -129,3 +138,19 @@ export async function runWithRetry<T>(
129
138
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
130
139
  return result!;
131
140
  }
141
+
142
+ const MaxReconnectDelayInMsWhenEndpointIsReachable = 30000;
143
+ const MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;
144
+
145
+ /**
146
+ * In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error
147
+ * not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared
148
+ * to when endpoint is reachable in which case it is 30s.
149
+ * @param error - error based on which we decide max wait time.
150
+ * @returns Max wait time.
151
+ */
152
+ export function calculateMaxWaitTime(error: unknown): number {
153
+ return isFluidError(error) && error.getTelemetryProperties().endpointReached === true
154
+ ? MaxReconnectDelayInMsWhenEndpointIsReachable
155
+ : MaxReconnectDelayInMsWhenEndpointIsNotReachable;
156
+ }
@@ -3,7 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/common-utils";
7
6
  import {
8
7
  ISummaryTree,
9
8
  SummaryType,
@@ -46,36 +45,6 @@ export function isCombinedAppAndProtocolSummary(
46
45
  return true;
47
46
  }
48
47
 
49
- /**
50
- * Combine the app summary and protocol summary in 1 tree.
51
- * @param appSummary - Summary of the app.
52
- * @param protocolSummary - Summary of the protocol.
53
- * @internal
54
- *
55
- * @deprecated 2.0.0-internal.3.4.0 - Not intended for public use. Will be moved to container-loader and no longer exported in an upcoming release.
56
- */
57
- export function combineAppAndProtocolSummary(
58
- appSummary: ISummaryTree,
59
- protocolSummary: ISummaryTree,
60
- ): CombinedAppAndProtocolSummary {
61
- assert(
62
- !isCombinedAppAndProtocolSummary(appSummary),
63
- 0x5a8 /* app summary is already a combined tree! */,
64
- );
65
- assert(
66
- !isCombinedAppAndProtocolSummary(protocolSummary),
67
- 0x5a9 /* protocol summary is already a combined tree! */,
68
- );
69
- const createNewSummary: CombinedAppAndProtocolSummary = {
70
- type: SummaryType.Tree,
71
- tree: {
72
- ".protocol": protocolSummary,
73
- ".app": appSummary,
74
- },
75
- };
76
- return createNewSummary;
77
- }
78
-
79
48
  /**
80
49
  * Extract the attributes from the protocol summary.
81
50
  * @param protocolSummary - protocol summary from which the values are to be extracted.
@@ -3,7 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { Uint8ArrayToString, unreachableCase } from "@fluidframework/common-utils";
6
+ import { Uint8ArrayToString } from "@fluid-internal/client-utils";
7
+ import { unreachableCase } from "@fluidframework/core-utils";
7
8
  import { ISummaryTree, ITree, ITreeEntry, SummaryType } from "@fluidframework/protocol-definitions";
8
9
  import { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from "./blob";
9
10
  import { isCombinedAppAndProtocolSummary } from "./summaryForCreateNew";