@fluid-experimental/tree 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 (36) hide show
  1. package/dist/SharedTree.d.ts +89 -30
  2. package/dist/SharedTree.d.ts.map +1 -1
  3. package/dist/SharedTree.js +94 -59
  4. package/dist/SharedTree.js.map +1 -1
  5. package/dist/SharedTreeEncoder.d.ts +1 -1
  6. package/dist/SharedTreeEncoder.d.ts.map +1 -1
  7. package/dist/SharedTreeEncoder.js.map +1 -1
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js.map +1 -1
  11. package/lib/SharedTree.d.ts +89 -30
  12. package/lib/SharedTree.d.ts.map +1 -1
  13. package/lib/SharedTree.js +95 -60
  14. package/lib/SharedTree.js.map +1 -1
  15. package/lib/SharedTreeEncoder.d.ts +1 -1
  16. package/lib/SharedTreeEncoder.d.ts.map +1 -1
  17. package/lib/SharedTreeEncoder.js.map +1 -1
  18. package/lib/index.d.ts +1 -1
  19. package/lib/index.d.ts.map +1 -1
  20. package/lib/index.js.map +1 -1
  21. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
  22. package/lib/test/fuzz/SharedTreeFuzzTests.js +3 -1
  23. package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
  24. package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
  25. package/lib/test/utilities/SharedTreeTests.js +27 -50
  26. package/lib/test/utilities/SharedTreeTests.js.map +1 -1
  27. package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
  28. package/lib/test/utilities/SharedTreeVersioningTests.js +19 -19
  29. package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
  30. package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
  31. package/lib/test/utilities/TestUtilities.js +11 -11
  32. package/lib/test/utilities/TestUtilities.js.map +1 -1
  33. package/package.json +18 -31
  34. package/src/SharedTree.ts +196 -47
  35. package/src/SharedTreeEncoder.ts +1 -1
  36. package/src/index.ts +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-experimental/tree",
3
- "version": "0.59.4002",
3
+ "version": "1.0.2",
4
4
  "description": "Distributed tree",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -38,13 +38,13 @@
38
38
  "dependencies": {
39
39
  "@fluidframework/common-definitions": "^0.20.1",
40
40
  "@fluidframework/common-utils": "^0.32.1",
41
- "@fluidframework/container-definitions": "^0.48.2000",
42
- "@fluidframework/core-interfaces": "^0.43.1000",
43
- "@fluidframework/datastore-definitions": "^0.59.4002",
41
+ "@fluidframework/container-definitions": "^1.0.2",
42
+ "@fluidframework/core-interfaces": "^1.0.2",
43
+ "@fluidframework/datastore-definitions": "^1.0.2",
44
44
  "@fluidframework/protocol-definitions": "^0.1028.2000",
45
- "@fluidframework/runtime-definitions": "^0.59.4002",
46
- "@fluidframework/shared-object-base": "^0.59.4002",
47
- "@fluidframework/telemetry-utils": "^0.59.4002",
45
+ "@fluidframework/runtime-definitions": "^1.0.2",
46
+ "@fluidframework/shared-object-base": "^1.0.2",
47
+ "@fluidframework/telemetry-utils": "^1.0.2",
48
48
  "buffer": "^6.0.3",
49
49
  "denque": "^1.5.1",
50
50
  "lru-cache": "^6.0.0",
@@ -52,43 +52,30 @@
52
52
  "uuid": "^8.3.1"
53
53
  },
54
54
  "devDependencies": {
55
- "@fluid-internal/stochastic-test-utils": "^0.59.4002",
56
- "@fluid-tools/benchmark": "^0.41.67945",
55
+ "@fluid-internal/stochastic-test-utils": "^1.0.2",
56
+ "@fluid-tools/benchmark": "^0.40.0",
57
57
  "@fluidframework/build-common": "^0.23.0",
58
- "@fluidframework/container-loader": "^0.59.4002",
59
- "@fluidframework/container-runtime": "^0.59.4002",
58
+ "@fluidframework/container-loader": "^1.0.2",
59
+ "@fluidframework/container-runtime": "^1.0.2",
60
60
  "@fluidframework/eslint-config-fluid": "^0.28.2000",
61
- "@fluidframework/mocha-test-setup": "^0.59.4002",
62
- "@fluidframework/runtime-utils": "^0.59.4002",
63
- "@fluidframework/test-driver-definitions": "^0.59.4002",
64
- "@fluidframework/test-drivers": "^0.59.4002",
65
- "@fluidframework/test-runtime-utils": "^0.59.4002",
66
- "@fluidframework/test-utils": "^0.59.4002",
67
- "@fluidframework/undo-redo": "^0.59.4002",
61
+ "@fluidframework/mocha-test-setup": "^1.0.2",
62
+ "@fluidframework/runtime-utils": "^1.0.2",
63
+ "@fluidframework/test-driver-definitions": "^1.0.2",
64
+ "@fluidframework/test-drivers": "^1.0.2",
65
+ "@fluidframework/test-runtime-utils": "^1.0.2",
66
+ "@fluidframework/test-utils": "^1.0.2",
67
+ "@fluidframework/undo-redo": "^1.0.2",
68
68
  "@microsoft/api-extractor": "^7.22.2",
69
69
  "@rushstack/eslint-config": "^2.5.1",
70
70
  "@types/lru-cache": "^5.1.0",
71
71
  "@types/mocha": "^9.1.1",
72
72
  "@types/random-js": "^1.0.31",
73
- "@typescript-eslint/eslint-plugin": "~5.9.0",
74
- "@typescript-eslint/parser": "~5.9.0",
75
73
  "chai": "^4.2.0",
76
74
  "concurrently": "^6.2.0",
77
75
  "cross-env": "^7.0.2",
78
76
  "easy-table": "^1.1.1",
79
77
  "env-cmd": "^10.1.0",
80
78
  "eslint": "~8.6.0",
81
- "eslint-plugin-editorconfig": "~3.2.0",
82
- "eslint-plugin-eslint-comments": "~3.2.0",
83
- "eslint-plugin-import": "~2.25.4",
84
- "eslint-plugin-jest": "~26.1.3",
85
- "eslint-plugin-jsdoc": "~39.3.0",
86
- "eslint-plugin-mocha": "~10.0.3",
87
- "eslint-plugin-promise": "~6.0.0",
88
- "eslint-plugin-react": "~7.28.0",
89
- "eslint-plugin-tsdoc": "~0.2.14",
90
- "eslint-plugin-unicorn": "~40.0.0",
91
- "eslint-plugin-unused-imports": "~2.0.0",
92
79
  "mocha": "^10.0.0",
93
80
  "nyc": "^15.0.0",
94
81
  "prettier": "^2.3.1",
package/src/SharedTree.ts CHANGED
@@ -27,7 +27,15 @@ import { ChildLogger, ITelemetryLoggerPropertyBags, PerformanceEvent } from '@fl
27
27
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
28
28
  import { assert, assertNotUndefined, fail, copyPropertyIfDefined, noop } from './Common';
29
29
  import { EditHandle, EditLog, getNumberOfHandlesFromEditLogSummary, OrderedEditSet } from './EditLog';
30
- import { EditId, NodeId, StableNodeId, DetachedSequenceId, OpSpaceNodeId, isDetachedSequenceId } from './Identifiers';
30
+ import {
31
+ EditId,
32
+ NodeId,
33
+ StableNodeId,
34
+ DetachedSequenceId,
35
+ OpSpaceNodeId,
36
+ isDetachedSequenceId,
37
+ AttributionId,
38
+ } from './Identifiers';
31
39
  import { initialTree } from './InitialTree';
32
40
  import {
33
41
  CachingLogViewer,
@@ -88,6 +96,75 @@ import { TransactionInternal } from './TransactionInternal';
88
96
  import { IdCompressor, createSessionId } from './id-compressor';
89
97
  import { convertEditIds } from './IdConversion';
90
98
  import { MutableStringInterner } from './StringInterner';
99
+ import { nilUuid } from './UuidUtilities';
100
+
101
+ /**
102
+ * The write format and associated options used to construct a `SharedTree`
103
+ * @public
104
+ */
105
+ export type SharedTreeArgs<WF extends WriteFormat = WriteFormat> = [writeFormat: WF, options?: SharedTreeOptions<WF>];
106
+
107
+ /**
108
+ * The type of shared tree options for a given write format
109
+ * @public
110
+ */
111
+ export type SharedTreeOptions<
112
+ WF extends WriteFormat,
113
+ HistoryCompatibility extends 'Forwards' | 'None' = 'Forwards'
114
+ > = Omit<
115
+ WF extends WriteFormat.v0_0_2
116
+ ? SharedTreeOptions_0_0_2
117
+ : WF extends WriteFormat.v0_1_1
118
+ ? SharedTreeOptions_0_1_1
119
+ : never,
120
+ HistoryCompatibility extends 'Forwards' ? 'summarizeHistory' : never
121
+ >;
122
+
123
+ /**
124
+ * Configuration options for a SharedTree with write format 0.0.2
125
+ * @public
126
+ */
127
+ export interface SharedTreeOptions_0_0_2 {
128
+ /**
129
+ * Determines if the history is included in summaries.
130
+ *
131
+ * Warning: enabling history summarization incurs a permanent cost in the document. It is not possible to disable history summarization
132
+ * later once it has been enabled, and thus the history cannot be safely deleted.
133
+ *
134
+ * On 0.1.1 documents, due to current code limitations, this parameter is only impactful for newly created documents.
135
+ * `SharedTree`s which load existing documents will summarize history if and only if the loaded summary included history.
136
+ *
137
+ * The technical limitations here relate to clients with mixed versions collaborating.
138
+ * In the future we may allow modification of whether or not a particular document saves history, but only via a consensus mechanism.
139
+ * See the skipped test in SharedTreeFuzzTests.ts for more details on this issue.
140
+ * See docs/Breaking-Change-Migration for more details on the consensus scheme.
141
+ */
142
+ summarizeHistory?: boolean;
143
+ }
144
+
145
+ /**
146
+ * Configuration options for a SharedTree with write format 0.1.1
147
+ * @public
148
+ */
149
+ export interface SharedTreeOptions_0_1_1 {
150
+ /**
151
+ * Determines if the history is included in summaries and if edit chunks are uploaded when they are full.
152
+ *
153
+ * Warning: enabling history summarization incurs a permanent cost in the document. It is not possible to disable history summarization
154
+ * later once it has been enabled, and thus the history cannot be safely deleted.
155
+ *
156
+ * On 0.1.1 documents, due to current code limitations, this parameter is only impactful for newly created documents.
157
+ * `SharedTree`s which load existing documents will summarize history if and only if the loaded summary included history.
158
+ *
159
+ * The technical limitations here relate to clients with mixed versions collaborating.
160
+ * In the future we may allow modification of whether or not a particular document saves history, but only via a consensus mechanism.
161
+ * See the skipped test in SharedTreeFuzzTests.ts for more details on this issue.
162
+ * See docs/Breaking-Change-Migration for more details on the consensus scheme.
163
+ */
164
+ summarizeHistory?: false | { uploadEditChunks: boolean };
165
+ /** a UUID that identifies the user of this tree; all node IDs generated by this tree will be associated with this UUID */
166
+ attributionId?: AttributionId;
167
+ }
91
168
 
92
169
  /**
93
170
  * Factory for SharedTree.
@@ -109,20 +186,20 @@ export class SharedTreeFactory implements IChannelFactory {
109
186
  packageVersion: '0.1',
110
187
  };
111
188
 
189
+ private readonly args: SharedTreeArgs;
190
+
112
191
  /**
113
192
  * Get a factory for SharedTree to register with the data store.
114
193
  * @param writeFormat - Determines the format version the SharedTree will write ops and summaries in. See [the write format
115
194
  * documentation](../docs/Write-Format.md) for more information.
116
- * @param summarizeHistory - Determines if the history is included in summaries and if edit chunks are uploaded when they are full.
117
- * See the [breaking change migration documentation](docs/Breaking-Change-Migration) for more details on this scheme.
118
- * @param expensiveValidation - Enables expensive asserts on SharedTree.
195
+ * @param options - Configuration options for this tree
119
196
  * @returns A factory that creates `SharedTree`s and loads them from storage.
120
197
  */
121
- constructor(
122
- private readonly writeFormat: WriteFormat,
123
- private readonly summarizeHistory: false | { uploadEditChunks: boolean } = false,
124
- private expensiveValidation = false
125
- ) {}
198
+ constructor(...args: SharedTreeArgs<WriteFormat.v0_0_2>);
199
+ constructor(...args: SharedTreeArgs<WriteFormat.v0_1_1>);
200
+ constructor(...args: SharedTreeArgs) {
201
+ this.args = args;
202
+ }
126
203
 
127
204
  /**
128
205
  * {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory."type"}
@@ -157,22 +234,22 @@ export class SharedTreeFactory implements IChannelFactory {
157
234
  * @param runtime - data store runtime that owns the new SharedTree
158
235
  * @param id - optional name for the SharedTree
159
236
  */
160
- public create(runtime: IFluidDataStoreRuntime, id: string, expensiveValidation: boolean = false): SharedTree {
161
- this.expensiveValidation = expensiveValidation;
237
+ public create(runtime: IFluidDataStoreRuntime, id: string): SharedTree {
162
238
  const sharedTree = this.createSharedTree(runtime, id);
163
239
  sharedTree.initializeLocal();
164
240
  return sharedTree;
165
241
  }
166
242
 
167
243
  private createSharedTree(runtime: IFluidDataStoreRuntime, id: string): SharedTree {
168
- const sharedTree = new SharedTree(
169
- runtime,
170
- id,
171
- this.writeFormat,
172
- this.summarizeHistory,
173
- this.expensiveValidation
174
- );
175
- return sharedTree;
244
+ const [writeFormat] = this.args;
245
+ switch (writeFormat) {
246
+ case WriteFormat.v0_0_2:
247
+ return new SharedTree(runtime, id, ...(this.args as SharedTreeArgs<WriteFormat.v0_0_2>));
248
+ case WriteFormat.v0_1_1:
249
+ return new SharedTree(runtime, id, ...(this.args as SharedTreeArgs<WriteFormat.v0_1_1>));
250
+ default:
251
+ fail('Unknown write format');
252
+ }
176
253
  }
177
254
  }
178
255
 
@@ -281,35 +358,56 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
281
358
 
282
359
  /**
283
360
  * Get a factory for SharedTree to register with the data store.
284
- * @param summarizeHistory - Determines if the history is included in summaries and if edit chunks are uploaded when they are full.
285
- *
286
- * On 0.1.1 documents, due to current code limitations, this parameter is only impactful for newly created documents.
287
- * `SharedTree`s which load existing documents will summarize history if and only if the loaded summary included history.
288
- *
289
- * The technical limitations here relate to clients with mixed versions collaborating.
290
- * In the future we may allow modification of whether or not a particular document saves history, but only via a consensus mechanism.
291
- * See the skipped test in SharedTreeFuzzTests.ts for more details on this issue.
292
- * See docs/Breaking-Change-Migration for more details on the consensus scheme.
293
361
  * @param writeFormat - Determines the format version the SharedTree will write ops and summaries in.
294
362
  * This format may be updated to a newer (supported) version at runtime if a collaborating shared-tree
295
363
  * that was initialized with a newer write version connects to the session. Care must be taken when changing this value,
296
364
  * as a staged rollout must of occurred such that all collaborating clients must have the code to read at least the version
297
365
  * written.
298
366
  * See [the write format documentation](../docs/Write-Format.md) for more information.
367
+ * @param options - Configuration options for this tree
299
368
  * @returns A factory that creates `SharedTree`s and loads them from storage.
300
369
  */
301
- public static getFactory(
302
- writeFormat: WriteFormat,
303
- summarizeHistory: false | { uploadEditChunks: boolean } = false
304
- ): SharedTreeFactory {
370
+ public static getFactory(...args: SharedTreeArgs<WriteFormat.v0_0_2>): SharedTreeFactory;
371
+
372
+ public static getFactory(...args: SharedTreeArgs<WriteFormat.v0_1_1>): SharedTreeFactory;
373
+
374
+ public static getFactory(...args: SharedTreeArgs): SharedTreeFactory {
375
+ const [writeFormat] = args;
305
376
  // On 0.1.1 documents, due to current code limitations, all clients MUST agree on the value of `summarizeHistory`.
306
377
  // Note that this means staged rollout changing this value should not be attempted.
307
378
  // It is possible to update shared-tree to correctly handle such a staged rollout, but that hasn't been implemented.
308
379
  // See the skipped test in SharedTreeFuzzTests.ts for more details on this issue.
309
- return new SharedTreeFactory(writeFormat, summarizeHistory);
380
+ switch (writeFormat) {
381
+ case WriteFormat.v0_0_2:
382
+ return new SharedTreeFactory(...(args as SharedTreeArgs<WriteFormat.v0_0_2>));
383
+ case WriteFormat.v0_1_1:
384
+ return new SharedTreeFactory(...(args as SharedTreeArgs<WriteFormat.v0_1_1>));
385
+ default:
386
+ fail('Unknown write format');
387
+ }
310
388
  }
311
389
 
312
- private idCompressor: IdCompressor = new IdCompressor(createSessionId(), reservedIdCount);
390
+ /**
391
+ * The UUID used for attribution of nodes created by this SharedTree. All shared trees with a write format of 0.1.1 or
392
+ * greater have a unique attribution ID which may be configured in the constructor. All other shared trees (i.e. those
393
+ * with a write format of 0.0.2) use the nil UUID as their attribution ID.
394
+ * @public
395
+ */
396
+ public get attributionId(): AttributionId {
397
+ switch (this.writeFormat) {
398
+ case WriteFormat.v0_0_2:
399
+ return nilUuid;
400
+ default: {
401
+ const { attributionId } = this.idCompressor;
402
+ if (attributionId === ghostSessionId) {
403
+ return nilUuid;
404
+ }
405
+ return attributionId;
406
+ }
407
+ }
408
+ }
409
+
410
+ private idCompressor: IdCompressor;
313
411
  private readonly idNormalizer: NodeIdNormalizer<OpSpaceNodeId> & { tree: SharedTree } = {
314
412
  tree: this,
315
413
  get localSessionId() {
@@ -375,25 +473,46 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
375
473
  private summarizeHistory: boolean;
376
474
  private uploadEditChunks: boolean;
377
475
 
476
+ private getHistoryPolicy(options: SharedTreeOptions<WriteFormat, 'Forwards' | 'None'>): {
477
+ summarizeHistory: boolean;
478
+ uploadEditChunks: boolean;
479
+ } {
480
+ const noCompatOptions = options as SharedTreeOptions<WriteFormat, 'None'>;
481
+ if (typeof noCompatOptions.summarizeHistory === 'object') {
482
+ return {
483
+ summarizeHistory: true,
484
+ uploadEditChunks: noCompatOptions.summarizeHistory.uploadEditChunks,
485
+ };
486
+ } else {
487
+ return {
488
+ summarizeHistory: noCompatOptions.summarizeHistory ?? false,
489
+ uploadEditChunks: false,
490
+ };
491
+ }
492
+ }
493
+
378
494
  /**
379
- * Create a new SharedTreeFactory.
495
+ * Create a new SharedTree.
380
496
  * @param runtime - The runtime the SharedTree will be associated with
381
497
  * @param id - Unique ID for the SharedTree
382
498
  * @param writeFormat - Determines the format version the SharedTree will write ops and summaries in. See [the write format
383
499
  * documentation](../docs/Write-Format.md) for more information.
384
- * @param summarizeHistory - Determines if the history is included in summaries and if edit chunks are uploaded when they are full.
385
- * @param expensiveValidation - Enable expensive asserts.
500
+ * @param options - Configuration options for this tree
386
501
  */
502
+ public constructor(runtime: IFluidDataStoreRuntime, id: string, ...args: SharedTreeArgs<WriteFormat.v0_0_2>);
503
+
504
+ public constructor(runtime: IFluidDataStoreRuntime, id: string, ...args: SharedTreeArgs<WriteFormat.v0_1_1>);
505
+
387
506
  public constructor(
388
507
  runtime: IFluidDataStoreRuntime,
389
508
  id: string,
390
509
  private writeFormat: WriteFormat,
391
- summarizeHistory: false | { uploadEditChunks: boolean } = false,
392
- private readonly expensiveValidation = false
510
+ options: SharedTreeOptions<typeof writeFormat> = {}
393
511
  ) {
394
- super(id, runtime, SharedTreeFactory.Attributes);
395
- this.summarizeHistory = summarizeHistory === false ? false : true;
396
- this.uploadEditChunks = summarizeHistory === false ? false : summarizeHistory.uploadEditChunks;
512
+ super(id, runtime, SharedTreeFactory.Attributes, 'fluid_sharedTree_');
513
+ const historyPolicy = this.getHistoryPolicy(options);
514
+ this.summarizeHistory = historyPolicy.summarizeHistory;
515
+ this.uploadEditChunks = historyPolicy.uploadEditChunks;
397
516
 
398
517
  // This code is somewhat duplicated from OldestClientObserver because it currently depends on the container runtime
399
518
  // which SharedTree does not have access to.
@@ -412,13 +531,15 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
412
531
  sharedTreeTelemetryProperties
413
532
  );
414
533
 
534
+ const attributionId = (options as SharedTreeOptions<WriteFormat.v0_1_1>).attributionId;
535
+ this.idCompressor = new IdCompressor(createSessionId(), reservedIdCount, attributionId);
415
536
  const { editLog, cachingLogViewer } = this.initializeNewEditLogFromSummary(
416
537
  {
417
538
  editChunks: [],
418
539
  editIds: [],
419
540
  },
420
541
  undefined,
421
- this.idCompressor, // TODO: Attribution info
542
+ this.idCompressor,
422
543
  this.processEditResult,
423
544
  this.processSequencedEditResult,
424
545
  WriteFormat.v0_1_1
@@ -429,6 +550,11 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
429
550
  this.encoder_0_1_1 = new SharedTreeEncoder_0_1_1(this.summarizeHistory);
430
551
  }
431
552
 
553
+ /**
554
+ * The write format version currently used by this `SharedTree`. This is always initialized to the write format
555
+ * passed to the tree's constructor, but it may automatically upgrade over time (e.g. when connected to another
556
+ * SharedTree with a higher write format, or when loading a summary with a higher write format).
557
+ */
432
558
  public getWriteFormat(): WriteFormat {
433
559
  return this.writeFormat;
434
560
  }
@@ -555,6 +681,26 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
555
681
  return this.idCompressor.tryRecompress(id) as NodeId | undefined;
556
682
  }
557
683
 
684
+ /**
685
+ * Returns the attribution ID associated with the SharedTree that generated the given node ID. This is generally only useful for clients
686
+ * with a write format of 0.1.1 or greater since older clients cannot be given an attribution ID and will always use the default
687
+ * `attributionId` of the tree.
688
+ * @public
689
+ */
690
+ public attributeNodeId(id: NodeId): AttributionId {
691
+ switch (this.writeFormat) {
692
+ case WriteFormat.v0_0_2:
693
+ return nilUuid;
694
+ default: {
695
+ const attributionId = this.idCompressor.attributeId(id);
696
+ if (attributionId === ghostSessionId) {
697
+ return nilUuid;
698
+ }
699
+ return attributionId;
700
+ }
701
+ }
702
+ }
703
+
558
704
  /**
559
705
  * @returns the edit history of the tree.
560
706
  * @public
@@ -744,7 +890,10 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
744
890
  let convertedSummary: SummaryContents;
745
891
  switch (loadedSummaryVersion) {
746
892
  case WriteFormat.v0_0_2:
747
- convertedSummary = this.encoder_0_0_2.decodeSummary(summary as SharedTreeSummary_0_0_2);
893
+ convertedSummary = this.encoder_0_0_2.decodeSummary(
894
+ summary as SharedTreeSummary_0_0_2,
895
+ this.attributionId
896
+ );
748
897
  break;
749
898
  case WriteFormat.v0_1_1: {
750
899
  const typedSummary = summary as SharedTreeSummary;
@@ -756,7 +905,7 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
756
905
  this.encoder_0_1_1 = new SharedTreeEncoder_0_1_1(this.summarizeHistory);
757
906
  }
758
907
 
759
- convertedSummary = this.encoder_0_1_1.decodeSummary(summary as SharedTreeSummary); // TODO:#461: pass attribution info
908
+ convertedSummary = this.encoder_0_1_1.decodeSummary(summary as SharedTreeSummary, this.attributionId);
760
909
  break;
761
910
  }
762
911
  default:
@@ -1115,7 +1264,7 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
1115
1264
  this.interner = new MutableStringInterner([initialTree.definition]);
1116
1265
  const oldIdCompressor = this.idCompressor;
1117
1266
  // Create the IdCompressor that will be used after the upgrade
1118
- const newIdCompressor = new IdCompressor(createSessionId(), reservedIdCount); // TODO: attribution info
1267
+ const newIdCompressor = new IdCompressor(createSessionId(), reservedIdCount, this.attributionId);
1119
1268
  const newContext = getNodeIdContext(newIdCompressor);
1120
1269
  // Generate all local IDs in the new compressor that were in the old compressor and preserve their UUIDs.
1121
1270
  // This will allow the client to continue to use local IDs that were allocated pre-upgrade
@@ -1130,7 +1279,7 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
1130
1279
  }
1131
1280
  };
1132
1281
  // Construct a temporary "ghost" compressor which is used to generate final IDs that will be consistent across all upgrading clients
1133
- const ghostIdCompressor = new IdCompressor(ghostSessionId, reservedIdCount); // TODO: attribution info
1282
+ const ghostIdCompressor = new IdCompressor(ghostSessionId, reservedIdCount);
1134
1283
  const ghostContext = getNodeIdContext(ghostIdCompressor);
1135
1284
  if (this.summarizeHistory) {
1136
1285
  // All clients have the full history, and can therefore all "generate" the same final IDs for every ID in the history
@@ -159,7 +159,7 @@ export class SharedTreeEncoder_0_1_1 {
159
159
  idCompressor: serializedIdCompressor,
160
160
  version,
161
161
  }: SharedTreeSummary,
162
- attributionId?: AttributionId
162
+ attributionId: AttributionId
163
163
  ): SummaryContents {
164
164
  assert(version === WriteFormat.v0_1_1, `Invalid summary version to decode: ${version}, expected: 0.1.1`);
165
165
  assert(typeof editHistory === 'object', '0.1.1 summary encountered with non-object edit history.');
package/src/index.ts CHANGED
@@ -91,6 +91,10 @@ export {
91
91
  TraitLocationInternal,
92
92
  } from './persisted-types';
93
93
  export {
94
+ SharedTreeArgs,
95
+ SharedTreeOptions,
96
+ SharedTreeOptions_0_0_2,
97
+ SharedTreeOptions_0_1_1,
94
98
  SharedTreeFactory,
95
99
  SharedTree,
96
100
  EditCommittedHandler,