@fluidframework/odsp-driver 0.59.4002 → 1.0.2

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 (92) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/compactSnapshotParser.d.ts.map +1 -1
  3. package/dist/compactSnapshotParser.js +4 -1
  4. package/dist/compactSnapshotParser.js.map +1 -1
  5. package/dist/compactSnapshotWriter.d.ts.map +1 -1
  6. package/dist/compactSnapshotWriter.js +6 -3
  7. package/dist/compactSnapshotWriter.js.map +1 -1
  8. package/dist/epochTracker.d.ts +3 -2
  9. package/dist/epochTracker.d.ts.map +1 -1
  10. package/dist/epochTracker.js +10 -4
  11. package/dist/epochTracker.js.map +1 -1
  12. package/dist/fetchSnapshot.js +2 -2
  13. package/dist/fetchSnapshot.js.map +1 -1
  14. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  15. package/dist/odspDocumentDeltaConnection.js +2 -1
  16. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  17. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  18. package/dist/odspDocumentServiceFactoryCore.js +2 -2
  19. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  20. package/dist/odspDocumentStorageManager.d.ts +0 -1
  21. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  22. package/dist/odspDocumentStorageManager.js +0 -4
  23. package/dist/odspDocumentStorageManager.js.map +1 -1
  24. package/dist/odspSnapshotParser.d.ts +1 -1
  25. package/dist/odspSnapshotParser.js +3 -3
  26. package/dist/odspSnapshotParser.js.map +1 -1
  27. package/dist/odspSummaryUploadManager.d.ts.map +1 -1
  28. package/dist/odspSummaryUploadManager.js +1 -4
  29. package/dist/odspSummaryUploadManager.js.map +1 -1
  30. package/dist/packageVersion.d.ts +1 -1
  31. package/dist/packageVersion.d.ts.map +1 -1
  32. package/dist/packageVersion.js +1 -1
  33. package/dist/packageVersion.js.map +1 -1
  34. package/dist/retryErrorsStorageAdapter.d.ts +1 -2
  35. package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
  36. package/dist/retryErrorsStorageAdapter.js +0 -3
  37. package/dist/retryErrorsStorageAdapter.js.map +1 -1
  38. package/dist/retryUtils.d.ts.map +1 -1
  39. package/dist/retryUtils.js +2 -3
  40. package/dist/retryUtils.js.map +1 -1
  41. package/lib/compactSnapshotParser.d.ts.map +1 -1
  42. package/lib/compactSnapshotParser.js +4 -1
  43. package/lib/compactSnapshotParser.js.map +1 -1
  44. package/lib/compactSnapshotWriter.d.ts.map +1 -1
  45. package/lib/compactSnapshotWriter.js +6 -3
  46. package/lib/compactSnapshotWriter.js.map +1 -1
  47. package/lib/epochTracker.d.ts +3 -2
  48. package/lib/epochTracker.d.ts.map +1 -1
  49. package/lib/epochTracker.js +10 -4
  50. package/lib/epochTracker.js.map +1 -1
  51. package/lib/fetchSnapshot.js +3 -3
  52. package/lib/fetchSnapshot.js.map +1 -1
  53. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  54. package/lib/odspDocumentDeltaConnection.js +2 -1
  55. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  56. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  57. package/lib/odspDocumentServiceFactoryCore.js +2 -2
  58. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  59. package/lib/odspDocumentStorageManager.d.ts +0 -1
  60. package/lib/odspDocumentStorageManager.d.ts.map +1 -1
  61. package/lib/odspDocumentStorageManager.js +0 -4
  62. package/lib/odspDocumentStorageManager.js.map +1 -1
  63. package/lib/odspSnapshotParser.d.ts +1 -1
  64. package/lib/odspSnapshotParser.js +1 -1
  65. package/lib/odspSnapshotParser.js.map +1 -1
  66. package/lib/odspSummaryUploadManager.d.ts.map +1 -1
  67. package/lib/odspSummaryUploadManager.js +1 -4
  68. package/lib/odspSummaryUploadManager.js.map +1 -1
  69. package/lib/packageVersion.d.ts +1 -1
  70. package/lib/packageVersion.d.ts.map +1 -1
  71. package/lib/packageVersion.js +1 -1
  72. package/lib/packageVersion.js.map +1 -1
  73. package/lib/retryErrorsStorageAdapter.d.ts +1 -2
  74. package/lib/retryErrorsStorageAdapter.d.ts.map +1 -1
  75. package/lib/retryErrorsStorageAdapter.js +0 -3
  76. package/lib/retryErrorsStorageAdapter.js.map +1 -1
  77. package/lib/retryUtils.d.ts.map +1 -1
  78. package/lib/retryUtils.js +3 -4
  79. package/lib/retryUtils.js.map +1 -1
  80. package/package.json +12 -25
  81. package/src/compactSnapshotParser.ts +3 -1
  82. package/src/compactSnapshotWriter.ts +6 -3
  83. package/src/epochTracker.ts +10 -3
  84. package/src/fetchSnapshot.ts +3 -3
  85. package/src/odspDocumentDeltaConnection.ts +2 -1
  86. package/src/odspDocumentServiceFactoryCore.ts +4 -2
  87. package/src/odspDocumentStorageManager.ts +0 -6
  88. package/src/odspSnapshotParser.ts +1 -1
  89. package/src/odspSummaryUploadManager.ts +1 -4
  90. package/src/packageVersion.ts +1 -1
  91. package/src/retryErrorsStorageAdapter.ts +0 -8
  92. package/src/retryUtils.ts +3 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/odsp-driver",
3
- "version": "0.59.4002",
3
+ "version": "1.0.2",
4
4
  "description": "Socket storage implementation for SPO and ODC",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -62,16 +62,16 @@
62
62
  "dependencies": {
63
63
  "@fluidframework/common-definitions": "^0.20.1",
64
64
  "@fluidframework/common-utils": "^0.32.1",
65
- "@fluidframework/core-interfaces": "^0.43.1000",
66
- "@fluidframework/driver-base": "^0.59.4002",
67
- "@fluidframework/driver-definitions": "^0.46.2000",
68
- "@fluidframework/driver-utils": "^0.59.4002",
65
+ "@fluidframework/core-interfaces": "^1.0.2",
66
+ "@fluidframework/driver-base": "^1.0.2",
67
+ "@fluidframework/driver-definitions": "^1.0.2",
68
+ "@fluidframework/driver-utils": "^1.0.2",
69
69
  "@fluidframework/gitresources": "^0.1036.4000",
70
- "@fluidframework/odsp-doclib-utils": "^0.59.4002",
71
- "@fluidframework/odsp-driver-definitions": "^0.59.4002",
70
+ "@fluidframework/odsp-doclib-utils": "^1.0.2",
71
+ "@fluidframework/odsp-driver-definitions": "^1.0.2",
72
72
  "@fluidframework/protocol-base": "^0.1036.4000",
73
73
  "@fluidframework/protocol-definitions": "^0.1028.2000",
74
- "@fluidframework/telemetry-utils": "^0.59.4002",
74
+ "@fluidframework/telemetry-utils": "^1.0.2",
75
75
  "abort-controller": "^3.0.0",
76
76
  "node-fetch": "^2.6.1",
77
77
  "socket.io-client": "^4.4.1",
@@ -79,32 +79,19 @@
79
79
  },
80
80
  "devDependencies": {
81
81
  "@fluidframework/build-common": "^0.23.0",
82
- "@fluidframework/build-tools": "^0.2.70857",
82
+ "@fluidframework/build-tools": "^0.2.71273",
83
83
  "@fluidframework/eslint-config-fluid": "^0.28.2000",
84
- "@fluidframework/mocha-test-setup": "^0.59.4002",
85
- "@fluidframework/odsp-driver-previous": "npm:@fluidframework/odsp-driver@0.59.4001",
84
+ "@fluidframework/mocha-test-setup": "^1.0.2",
85
+ "@fluidframework/odsp-driver-previous": "npm:@fluidframework/odsp-driver@^0.59.0",
86
86
  "@microsoft/api-extractor": "^7.22.2",
87
87
  "@rushstack/eslint-config": "^2.5.1",
88
88
  "@types/mocha": "^9.1.1",
89
89
  "@types/node-fetch": "^2.5.10",
90
90
  "@types/sha.js": "^2.4.0",
91
- "@typescript-eslint/eslint-plugin": "~5.9.0",
92
- "@typescript-eslint/parser": "~5.9.0",
93
91
  "concurrently": "^6.2.0",
94
92
  "copyfiles": "^2.1.0",
95
93
  "cross-env": "^7.0.2",
96
94
  "eslint": "~8.6.0",
97
- "eslint-plugin-editorconfig": "~3.2.0",
98
- "eslint-plugin-eslint-comments": "~3.2.0",
99
- "eslint-plugin-import": "~2.25.4",
100
- "eslint-plugin-jest": "~26.1.3",
101
- "eslint-plugin-jsdoc": "~39.3.0",
102
- "eslint-plugin-mocha": "~10.0.3",
103
- "eslint-plugin-promise": "~6.0.0",
104
- "eslint-plugin-react": "~7.28.0",
105
- "eslint-plugin-tsdoc": "~0.2.14",
106
- "eslint-plugin-unicorn": "~40.0.0",
107
- "eslint-plugin-unused-imports": "~2.0.0",
108
95
  "mocha": "^10.0.0",
109
96
  "nyc": "^15.0.0",
110
97
  "rimraf": "^2.6.2",
@@ -113,7 +100,7 @@
113
100
  "typescript-formatter": "7.1.0"
114
101
  },
115
102
  "typeValidation": {
116
- "version": "0.59.4002",
103
+ "version": "1.0.0",
117
104
  "broken": {}
118
105
  }
119
106
  }
@@ -81,9 +81,11 @@ function readTreeSection(node: NodeCore) {
81
81
  if (records.value !== undefined) {
82
82
  assertBlobCoreInstance(records.value, "Blob value should be BlobCore");
83
83
  snapshotTree.blobs[path] = records.value.toString();
84
- } else {
84
+ } else if (records.children !== undefined) {
85
85
  assertNodeCoreInstance(records.children, "Trees should be of type NodeCore");
86
86
  snapshotTree.trees[path] = readTreeSection(records.children);
87
+ } else {
88
+ snapshotTree.trees[path] = { blobs: {}, commits: {}, trees: {} };
87
89
  }
88
90
  if (records.unreferenced !== undefined) {
89
91
  assertBoolInstance(records.unreferenced, "Unreferenced flag should be bool");
@@ -60,9 +60,12 @@ function writeTreeSectionCore(treesNode: NodeCore, snapshotTree: ISnapshotTree)
60
60
  if (snapshotTree.unreferenced) {
61
61
  addBoolProperty(treeNode, "unreferenced", snapshotTree.unreferenced);
62
62
  }
63
- treeNode.addString("children", true);
64
- const childNode = treeNode.addNode("list");
65
- writeTreeSectionCore(childNode, value);
63
+ // Only write children prop if either blobs or trees are present.
64
+ if (Object.keys(value.blobs).length > 0 || Object.keys(value.trees).length > 0) {
65
+ treeNode.addString("children", true);
66
+ const childNode = treeNode.addNode("list");
67
+ writeTreeSectionCore(childNode, value);
68
+ }
66
69
  }
67
70
 
68
71
  if (snapshotTree.blobs) {
@@ -55,6 +55,7 @@ export class EpochTracker implements IPersistedFileCache {
55
55
  protected readonly cache: IPersistedCache,
56
56
  protected readonly fileEntry: IFileEntry,
57
57
  protected readonly logger: ITelemetryLogger,
58
+ protected readonly clientIsSummarizer?: boolean,
58
59
  ) {
59
60
  // Limits the max number of concurrent requests to 24.
60
61
  this.rateLimiter = new RateLimiter(24);
@@ -300,7 +301,12 @@ export class EpochTracker implements IPersistedFileCache {
300
301
  }
301
302
 
302
303
  private formatClientCorrelationId(fetchReason?: string) {
303
- const items: string[] = [`driverId=${this.driverId}`, `RequestNumber=${this.networkCallNumber++}`];
304
+ const items: string[] = [
305
+ `driverId=${this.driverId}`,
306
+ `RequestNumber=${this.networkCallNumber++}`,
307
+ `driverVersion=${driverVersion}`,
308
+ `isSummarizer=${this.clientIsSummarizer}`,
309
+ ];
304
310
  if (fetchReason !== undefined) {
305
311
  items.push(`fetchReason=${fetchReason}`);
306
312
  }
@@ -475,8 +481,9 @@ export function createOdspCacheAndTracker(
475
481
  persistedCacheArg: IPersistedCache,
476
482
  nonpersistentCache: INonPersistentCache,
477
483
  fileEntry: IFileEntry,
478
- logger: ITelemetryLogger): ICacheAndTracker {
479
- const epochTracker = new EpochTrackerWithRedemption(persistedCacheArg, fileEntry, logger);
484
+ logger: ITelemetryLogger,
485
+ clientIsSummarizer?: boolean): ICacheAndTracker {
486
+ const epochTracker = new EpochTrackerWithRedemption(persistedCacheArg, fileEntry, logger, clientIsSummarizer);
480
487
  return {
481
488
  cache: {
482
489
  ...nonpersistentCache,
@@ -28,7 +28,7 @@ import {
28
28
  IOdspResponse,
29
29
  ISnapshotContents,
30
30
  } from "./odspUtils";
31
- import { convertOdspSnapshotToSnapsohtTreeAndBlobs } from "./odspSnapshotParser";
31
+ import { convertOdspSnapshotToSnapshotTreeAndBlobs } from "./odspSnapshotParser";
32
32
  import { currentReadVersion, parseCompactSnapshotResponse } from "./compactSnapshotParser";
33
33
  import { ReadBuffer } from "./ReadBufferUtils";
34
34
  import { EpochTracker } from "./epochTracker";
@@ -83,7 +83,7 @@ export async function fetchSnapshot(
83
83
  },
84
84
  async () => snapshotDownloader(url, { headers }),
85
85
  ) as IOdspResponse<IOdspSnapshot>;
86
- return convertOdspSnapshotToSnapsohtTreeAndBlobs(response.content);
86
+ return convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);
87
87
  }
88
88
 
89
89
  export async function fetchSnapshotWithRedeem(
@@ -491,7 +491,7 @@ export async function downloadSnapshot(
491
491
  const text = await response.content.text();
492
492
  const content: IOdspSnapshot = JSON.parse(text);
493
493
  response.propsToLog.bodySize = text.length;
494
- const snapshotContents: ISnapshotContents = convertOdspSnapshotToSnapsohtTreeAndBlobs(content);
494
+ const snapshotContents: ISnapshotContents = convertOdspSnapshotToSnapshotTreeAndBlobs(content);
495
495
  finalSnapshotContents = { ...response, content: snapshotContents };
496
496
  } else {
497
497
  assert(contentType === "application/ms-fluid", 0x2c3 /* "Content type should be application/ms-fluid" */);
@@ -440,7 +440,7 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
440
440
  }
441
441
 
442
442
  protected serverDisconnectHandler = (error: IFluidErrorBase & OdspError) => {
443
- this.logger.sendTelemetryEvent({ eventName: "ServerDisconnect" }, error);
443
+ this.logger.sendTelemetryEvent({ eventName: "ServerDisconnect", clientId: this.clientId }, error);
444
444
  this.disposeCore(true, error);
445
445
  };
446
446
 
@@ -565,6 +565,7 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
565
565
  type,
566
566
  message,
567
567
  retryAfterSeconds: retryAfter,
568
+ clientId: this.clientId,
568
569
  });
569
570
  }
570
571
  this.emit("nack", clientIdOrDocumentId, nacks);
@@ -102,7 +102,8 @@ export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory {
102
102
  this.persistedCache,
103
103
  this.nonPersistentCache,
104
104
  fileEntry,
105
- odspLogger);
105
+ odspLogger,
106
+ clientIsSummarizer);
106
107
 
107
108
  return PerformanceEvent.timedExecAsync(
108
109
  odspLogger,
@@ -189,7 +190,8 @@ export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory {
189
190
  this.persistedCache,
190
191
  this.nonPersistentCache,
191
192
  { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId },
192
- odspLogger);
193
+ odspLogger,
194
+ clientIsSummarizer);
193
195
 
194
196
  const storageTokenFetcher = toInstrumentedOdspTokenFetcher(
195
197
  odspLogger,
@@ -642,12 +642,6 @@ export class OdspDocumentStorageService implements IDocumentStorageService {
642
642
  }
643
643
  }
644
644
 
645
- public async write(tree: api.ITree, parents: string[], message: string): Promise<api.IVersion> {
646
- this.checkSnapshotUrl();
647
-
648
- throw new Error("Not supported");
649
- }
650
-
651
645
  public async uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string> {
652
646
  this.checkSnapshotUrl();
653
647
 
@@ -51,7 +51,7 @@ function buildHierarchy(flatTree: IOdspSnapshotCommit): api.ISnapshotTree {
51
51
  * Converts existing IOdspSnapshot to snapshot tree, blob array and ops
52
52
  * @param odspSnapshot - snapshot
53
53
  */
54
- export function convertOdspSnapshotToSnapsohtTreeAndBlobs(
54
+ export function convertOdspSnapshotToSnapshotTreeAndBlobs(
55
55
  odspSnapshot: IOdspSnapshot,
56
56
  ): ISnapshotContents {
57
57
  const blobsWithBufferContent = new Map<string, ArrayBuffer>();
@@ -69,9 +69,7 @@ export class OdspSummaryUploadManager {
69
69
  referenceSequenceNumber: number,
70
70
  tree: api.ISummaryTree,
71
71
  ): Promise<IWriteSummaryResponse> {
72
- const enableContainerTypeSummaryUpload = this.mc.config.getBoolean("Fluid.Driver.Odsp.EnableContainerTypeSummaryUpload");
73
- const containsProtocolTree = enableContainerTypeSummaryUpload &&
74
- Object.keys(tree.tree).includes(".protocol");
72
+ const containsProtocolTree = Object.keys(tree.tree).includes(".protocol");
75
73
  const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(
76
74
  parentHandle,
77
75
  tree,
@@ -112,7 +110,6 @@ export class OdspSummaryUploadManager {
112
110
  size: postBody.length,
113
111
  referenceSequenceNumber,
114
112
  type: snapshot.type,
115
- enableContainerTypeSummaryUpload,
116
113
  },
117
114
  async () => {
118
115
  const response = await this.epochTracker.fetchAndParseAsJSON<IWriteSummaryResponse>(
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/odsp-driver";
9
- export const pkgVersion = "0.59.4002";
9
+ export const pkgVersion = "1.0.2";
@@ -14,7 +14,6 @@ import {
14
14
  ISnapshotTree,
15
15
  ISummaryHandle,
16
16
  ISummaryTree,
17
- ITree,
18
17
  IVersion,
19
18
  } from "@fluidframework/protocol-definitions";
20
19
  import { IDisposable, ITelemetryLogger } from "@fluidframework/common-definitions";
@@ -61,13 +60,6 @@ export class RetryErrorsStorageAdapter implements IDocumentStorageService, IDisp
61
60
  );
62
61
  }
63
62
 
64
- public async write(tree: ITree, parents: string[], message: string, ref: string): Promise<IVersion> {
65
- return this.runWithRetry(
66
- async () => this.internalStorageService.write(tree, parents, message, ref),
67
- "storage_write",
68
- );
69
- }
70
-
71
63
  public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {
72
64
  // Creation flow with attachment blobs - need to do retries!
73
65
  return this.runWithRetry(
package/src/retryUtils.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
- import { assert, delay, performance } from "@fluidframework/common-utils";
7
+ import { delay, performance } from "@fluidframework/common-utils";
8
8
  import { canRetryOnError } from "@fluidframework/driver-utils";
9
9
  import { OdspErrorType } from "@fluidframework/odsp-driver-definitions";
10
10
  import { Odsp409Error } from "./epochTracker";
@@ -43,8 +43,8 @@ export async function runWithRetry<T>(
43
43
 
44
44
  const coherencyError = error?.[Odsp409Error] === true;
45
45
  const serviceReadonlyError = error?.errorType === OdspErrorType.serviceReadOnly;
46
- // Retry for 409 coherency errors or serviceReadOnly errors.
47
- if (!(coherencyError || serviceReadonlyError)) {
46
+ // Retry for retriable 409 coherency errors or serviceReadOnly errors.
47
+ if (!(coherencyError || serviceReadonlyError || canRetry)) {
48
48
  throw error;
49
49
  }
50
50
 
@@ -66,7 +66,6 @@ export async function runWithRetry<T>(
66
66
  throw error;
67
67
  }
68
68
 
69
- assert(canRetry, 0x24d /* "can retry" */);
70
69
  await delay(Math.floor(retryAfter));
71
70
  retryAfter += retryAfter / 4 * (1 + Math.random());
72
71
  lastError = error;