@fluidframework/map 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277

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 (119) hide show
  1. package/.eslintrc.js +12 -11
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +162 -0
  4. package/README.md +24 -8
  5. package/api-extractor-esm.json +4 -0
  6. package/api-extractor-lint.json +4 -0
  7. package/api-extractor.json +2 -2
  8. package/api-report/map.api.md +297 -0
  9. package/dist/{directory.js → directory.cjs} +749 -228
  10. package/dist/directory.cjs.map +1 -0
  11. package/dist/directory.d.ts +567 -34
  12. package/dist/directory.d.ts.map +1 -1
  13. package/dist/index.cjs +27 -0
  14. package/dist/index.cjs.map +1 -0
  15. package/dist/index.d.ts +5 -5
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/{interfaces.js → interfaces.cjs} +1 -1
  18. package/dist/interfaces.cjs.map +1 -0
  19. package/dist/interfaces.d.ts +167 -184
  20. package/dist/interfaces.d.ts.map +1 -1
  21. package/dist/internalInterfaces.cjs +7 -0
  22. package/dist/internalInterfaces.cjs.map +1 -0
  23. package/dist/internalInterfaces.d.ts +101 -0
  24. package/dist/internalInterfaces.d.ts.map +1 -0
  25. package/dist/{localValues.js → localValues.cjs} +15 -3
  26. package/dist/localValues.cjs.map +1 -0
  27. package/dist/localValues.d.ts +17 -6
  28. package/dist/localValues.d.ts.map +1 -1
  29. package/dist/map-alpha.d.ts +982 -0
  30. package/dist/map-beta.d.ts +275 -0
  31. package/dist/map-public.d.ts +275 -0
  32. package/dist/map-untrimmed.d.ts +996 -0
  33. package/dist/{map.js → map.cjs} +39 -34
  34. package/dist/map.cjs.map +1 -0
  35. package/dist/map.d.ts +10 -17
  36. package/dist/map.d.ts.map +1 -1
  37. package/dist/{mapKernel.js → mapKernel.cjs} +122 -79
  38. package/dist/mapKernel.cjs.map +1 -0
  39. package/dist/mapKernel.d.ts +17 -48
  40. package/dist/mapKernel.d.ts.map +1 -1
  41. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  42. package/dist/packageVersion.cjs.map +1 -0
  43. package/dist/packageVersion.d.ts +1 -1
  44. package/dist/packageVersion.d.ts.map +1 -1
  45. package/dist/tsdoc-metadata.json +11 -0
  46. package/lib/directory.d.mts +902 -0
  47. package/lib/directory.d.mts.map +1 -0
  48. package/lib/{directory.js → directory.mjs} +736 -199
  49. package/lib/directory.mjs.map +1 -0
  50. package/lib/index.d.mts +9 -0
  51. package/lib/index.d.mts.map +1 -0
  52. package/lib/index.mjs +8 -0
  53. package/lib/index.mjs.map +1 -0
  54. package/lib/{interfaces.d.ts → interfaces.d.mts} +168 -185
  55. package/lib/interfaces.d.mts.map +1 -0
  56. package/lib/{interfaces.js → interfaces.mjs} +1 -1
  57. package/lib/interfaces.mjs.map +1 -0
  58. package/lib/internalInterfaces.d.mts +101 -0
  59. package/lib/internalInterfaces.d.mts.map +1 -0
  60. package/lib/internalInterfaces.mjs +6 -0
  61. package/lib/internalInterfaces.mjs.map +1 -0
  62. package/lib/{localValues.d.ts → localValues.d.mts} +19 -8
  63. package/lib/localValues.d.mts.map +1 -0
  64. package/lib/{localValues.js → localValues.mjs} +15 -3
  65. package/lib/localValues.mjs.map +1 -0
  66. package/lib/map-alpha.d.mts +970 -0
  67. package/lib/map-beta.d.mts +263 -0
  68. package/lib/map-public.d.mts +263 -0
  69. package/lib/map-untrimmed.d.mts +984 -0
  70. package/lib/{map.d.ts → map.d.mts} +12 -19
  71. package/lib/map.d.mts.map +1 -0
  72. package/lib/{map.js → map.mjs} +40 -35
  73. package/lib/map.mjs.map +1 -0
  74. package/lib/{mapKernel.d.ts → mapKernel.d.mts} +19 -50
  75. package/lib/mapKernel.d.mts.map +1 -0
  76. package/lib/{mapKernel.js → mapKernel.mjs} +116 -73
  77. package/lib/mapKernel.mjs.map +1 -0
  78. package/lib/{packageVersion.d.ts → packageVersion.d.mts} +2 -2
  79. package/lib/packageVersion.d.mts.map +1 -0
  80. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  81. package/lib/packageVersion.mjs.map +1 -0
  82. package/package.json +143 -65
  83. package/prettier.config.cjs +8 -0
  84. package/src/directory.ts +2544 -1727
  85. package/src/index.ts +31 -5
  86. package/src/interfaces.ts +346 -345
  87. package/src/internalInterfaces.ts +119 -0
  88. package/src/localValues.ts +103 -96
  89. package/src/map.ts +362 -351
  90. package/src/mapKernel.ts +755 -722
  91. package/src/packageVersion.ts +1 -1
  92. package/tsc-multi.test.json +4 -0
  93. package/tsconfig.json +10 -15
  94. package/dist/directory.js.map +0 -1
  95. package/dist/index.js +0 -34
  96. package/dist/index.js.map +0 -1
  97. package/dist/interfaces.js.map +0 -1
  98. package/dist/localValues.js.map +0 -1
  99. package/dist/map.js.map +0 -1
  100. package/dist/mapKernel.js.map +0 -1
  101. package/dist/packageVersion.js.map +0 -1
  102. package/lib/directory.d.ts +0 -369
  103. package/lib/directory.d.ts.map +0 -1
  104. package/lib/directory.js.map +0 -1
  105. package/lib/index.d.ts +0 -20
  106. package/lib/index.d.ts.map +0 -1
  107. package/lib/index.js +0 -20
  108. package/lib/index.js.map +0 -1
  109. package/lib/interfaces.d.ts.map +0 -1
  110. package/lib/interfaces.js.map +0 -1
  111. package/lib/localValues.d.ts.map +0 -1
  112. package/lib/localValues.js.map +0 -1
  113. package/lib/map.d.ts.map +0 -1
  114. package/lib/map.js.map +0 -1
  115. package/lib/mapKernel.d.ts.map +0 -1
  116. package/lib/mapKernel.js.map +0 -1
  117. package/lib/packageVersion.d.ts.map +0 -1
  118. package/lib/packageVersion.js.map +0 -1
  119. package/tsconfig.esnext.json +0 -7
@@ -2,14 +2,17 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
5
6
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
6
7
  import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelServices, IChannelFactory } from "@fluidframework/datastore-definitions";
7
8
  import { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
8
9
  import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
9
- import { IDirectory, ISerializableValue, ISharedDirectory, ISharedDirectoryEvents } from "./interfaces";
10
- import { LocalValueMaker } from "./localValues";
10
+ import { RedBlackTree } from "@fluidframework/merge-tree";
11
+ import { IDirectory, IDirectoryEvents, ISerializableValue, ISerializedValue, ISharedDirectory, ISharedDirectoryEvents } from "./interfaces";
12
+ import { ILocalValue, LocalValueMaker } from "./localValues";
11
13
  /**
12
14
  * Operation indicating a value should be set for a key.
15
+ * @alpha
13
16
  */
14
17
  export interface IDirectorySetOperation {
15
18
  /**
@@ -31,6 +34,7 @@ export interface IDirectorySetOperation {
31
34
  }
32
35
  /**
33
36
  * Operation indicating a key should be deleted from the directory.
37
+ * @alpha
34
38
  */
35
39
  export interface IDirectoryDeleteOperation {
36
40
  /**
@@ -47,11 +51,13 @@ export interface IDirectoryDeleteOperation {
47
51
  path: string;
48
52
  }
49
53
  /**
50
- * An operation on a specific key within a directory
54
+ * An operation on a specific key within a directory.
55
+ * @alpha
51
56
  */
52
- export declare type IDirectoryKeyOperation = IDirectorySetOperation | IDirectoryDeleteOperation;
57
+ export type IDirectoryKeyOperation = IDirectorySetOperation | IDirectoryDeleteOperation;
53
58
  /**
54
59
  * Operation indicating the directory should be cleared.
60
+ * @alpha
55
61
  */
56
62
  export interface IDirectoryClearOperation {
57
63
  /**
@@ -64,11 +70,13 @@ export interface IDirectoryClearOperation {
64
70
  path: string;
65
71
  }
66
72
  /**
67
- * An operation on one or more of the keys within a directory
73
+ * An operation on one or more of the keys within a directory.
74
+ * @alpha
68
75
  */
69
- export declare type IDirectoryStorageOperation = IDirectoryKeyOperation | IDirectoryClearOperation;
76
+ export type IDirectoryStorageOperation = IDirectoryKeyOperation | IDirectoryClearOperation;
70
77
  /**
71
78
  * Operation indicating a subdirectory should be created.
79
+ * @alpha
72
80
  */
73
81
  export interface IDirectoryCreateSubDirectoryOperation {
74
82
  /**
@@ -86,6 +94,7 @@ export interface IDirectoryCreateSubDirectoryOperation {
86
94
  }
87
95
  /**
88
96
  * Operation indicating a subdirectory should be deleted.
97
+ * @alpha
89
98
  */
90
99
  export interface IDirectoryDeleteSubDirectoryOperation {
91
100
  /**
@@ -102,35 +111,82 @@ export interface IDirectoryDeleteSubDirectoryOperation {
102
111
  subdirName: string;
103
112
  }
104
113
  /**
105
- * An operation on the subdirectories within a directory
114
+ * An operation on the subdirectories within a directory.
115
+ * @alpha
106
116
  */
107
- export declare type IDirectorySubDirectoryOperation = IDirectoryCreateSubDirectoryOperation | IDirectoryDeleteSubDirectoryOperation;
117
+ export type IDirectorySubDirectoryOperation = IDirectoryCreateSubDirectoryOperation | IDirectoryDeleteSubDirectoryOperation;
108
118
  /**
109
- * Any operation on a directory
119
+ * Any operation on a directory.
120
+ * @alpha
110
121
  */
111
- export declare type IDirectoryOperation = IDirectoryStorageOperation | IDirectorySubDirectoryOperation;
122
+ export type IDirectoryOperation = IDirectoryStorageOperation | IDirectorySubDirectoryOperation;
123
+ /**
124
+ * Create info for the subdirectory.
125
+ * @alpha
126
+ */
127
+ export interface ICreateInfo {
128
+ /**
129
+ * Sequence number at which this subdirectory was created.
130
+ */
131
+ csn: number;
132
+ /**
133
+ * clientids of the clients which created this sub directory.
134
+ */
135
+ ccIds: string[];
136
+ }
112
137
  /**
113
138
  * Defines the in-memory object structure to be used for the conversion to/from serialized.
114
- * @privateRemarks
115
- * Directly used in JSON.stringify, direct result from JSON.parse.
139
+ *
140
+ * @remarks Directly used in
141
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
142
+ * | JSON.stringify}, direct result from
143
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.
144
+ * @alpha
116
145
  */
117
146
  export interface IDirectoryDataObject {
147
+ /**
148
+ * Key/value date set by the user.
149
+ */
118
150
  storage?: {
119
151
  [key: string]: ISerializableValue;
120
152
  };
153
+ /**
154
+ * Recursive sub-directories {@link IDirectoryDataObject | objects}.
155
+ */
121
156
  subdirectories?: {
122
157
  [subdirName: string]: IDirectoryDataObject;
123
158
  };
159
+ /**
160
+ * Create info for the sub directory. Since directories with same name can get deleted/created by multiple clients
161
+ * asynchronously, this info helps us to determine whether the ops where for the current instance of sub directory
162
+ * or not and whether to process them or not based on that. Summaries which were not produced which this change
163
+ * will not have this info and in that case we can still run in eventual consistency issues but that is no worse
164
+ * than the state before this change.
165
+ */
166
+ ci?: ICreateInfo;
124
167
  }
168
+ /**
169
+ * {@link IDirectory} storage format.
170
+ *
171
+ * @internal
172
+ */
125
173
  export interface IDirectoryNewStorageFormat {
174
+ /**
175
+ * Blob IDs representing larger directory data that was serialized.
176
+ */
126
177
  blobs: string[];
178
+ /**
179
+ * Storage content representing directory data that was not serialized.
180
+ */
127
181
  content: IDirectoryDataObject;
128
182
  }
129
183
  /**
130
- * The factory that defines the directory.
184
+ * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedDirectory}.
185
+ *
131
186
  * @sealed
187
+ * @alpha
132
188
  */
133
- export declare class DirectoryFactory {
189
+ export declare class DirectoryFactory implements IChannelFactory {
134
190
  /**
135
191
  * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
136
192
  */
@@ -157,11 +213,38 @@ export declare class DirectoryFactory {
157
213
  create(runtime: IFluidDataStoreRuntime, id: string): ISharedDirectory;
158
214
  }
159
215
  /**
160
- * SharedDirectory provides a hierarchical organization of map-like data structures as SubDirectories.
161
- * The values stored within can be accessed like a map, and the hierarchy can be navigated using path syntax.
162
- * SubDirectories can be retrieved for use as working directories.
216
+ * The combination of sequence numebr and client sequence number of a subdirectory
217
+ */
218
+ interface SequenceData {
219
+ seq: number;
220
+ clientSeq?: number;
221
+ }
222
+ /**
223
+ * A utility class for tracking associations between keys and their creation indices.
224
+ * This is relevant to support map iteration in insertion order, see
225
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/%40%40iterator
226
+ *
227
+ * TODO: It can be combined with the creation tracker utilized in SharedMap
228
+ */
229
+ declare class DirectoryCreationTracker {
230
+ readonly indexToKey: RedBlackTree<SequenceData, string>;
231
+ readonly keyToIndex: Map<string, SequenceData>;
232
+ constructor();
233
+ set(key: string, seqData: SequenceData): void;
234
+ has(keyOrSeqData: string | SequenceData): boolean;
235
+ delete(keyOrSeqData: string | SequenceData): void;
236
+ /**
237
+ * Retrieves all subdirectories with creation order that satisfy an optional constraint function.
238
+ * @param constraint - An optional constraint function that filters keys.
239
+ * @returns An array of keys that satisfy the constraint (or all keys if no constraint is provided).
240
+ */
241
+ keys(constraint?: (key: string) => boolean): string[];
242
+ }
243
+ /**
244
+ * {@inheritDoc ISharedDirectory}
163
245
  *
164
246
  * @example
247
+ *
165
248
  * ```typescript
166
249
  * mySharedDirectory.createSubDirectory("a").createSubDirectory("b").createSubDirectory("c").set("foo", val1);
167
250
  * const mySubDir = mySharedDirectory.getWorkingDirectory("/a/b/c");
@@ -169,6 +252,7 @@ export declare class DirectoryFactory {
169
252
  * ```
170
253
  *
171
254
  * @sealed
255
+ * @alpha
172
256
  */
173
257
  export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents> implements ISharedDirectory {
174
258
  /**
@@ -193,9 +277,7 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
193
277
  * {@inheritDoc IDirectory.absolutePath}
194
278
  */
195
279
  get absolutePath(): string;
196
- /**
197
- * @internal
198
- */
280
+ /***/
199
281
  readonly localValueMaker: LocalValueMaker;
200
282
  /**
201
283
  * Root of the SharedDirectory, most operations on the SharedDirectory itself act on the root.
@@ -220,7 +302,7 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
220
302
  /**
221
303
  * {@inheritDoc IDirectory.set}
222
304
  */
223
- set<T = any>(key: string, value: T): this;
305
+ set<T = unknown>(key: string, value: T): this;
224
306
  dispose(error?: Error): void;
225
307
  get disposed(): boolean;
226
308
  /**
@@ -298,7 +380,6 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
298
380
  getWorkingDirectory(relativePath: string): IDirectory | undefined;
299
381
  /**
300
382
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
301
- * @internal
302
383
  */
303
384
  protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
304
385
  /**
@@ -306,40 +387,33 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
306
387
  * @param op - Op to submit
307
388
  * @param localOpMetadata - The local metadata associated with the op. We send a unique id that is used to track
308
389
  * this op while it has not been ack'd. This will be sent when we receive this op back from the server.
309
- * @internal
310
390
  */
311
391
  submitDirectoryMessage(op: IDirectoryOperation, localOpMetadata: unknown): void;
312
392
  /**
313
393
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
314
- * @internal
315
394
  */
316
395
  protected onDisconnect(): void;
317
396
  /**
318
397
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
319
- * @internal
320
398
  */
321
- protected reSubmitCore(content: any, localOpMetadata: unknown): void;
399
+ protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
322
400
  /**
323
401
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
324
- * @internal
325
402
  */
326
403
  protected loadCore(storage: IChannelStorageService): Promise<void>;
327
404
  /**
328
405
  * Populate the directory with the given directory data.
329
406
  * @param data - A JSON string containing serialized directory data
330
- * @internal
331
407
  */
332
408
  protected populate(data: IDirectoryDataObject): void;
333
409
  /**
334
410
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
335
- * @internal
336
411
  */
337
412
  protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
338
413
  /**
339
414
  * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
340
- * @internal
341
- */
342
- protected rollback(content: any, localOpMetadata: unknown): void;
415
+ */
416
+ protected rollback(content: unknown, localOpMetadata: unknown): void;
343
417
  /**
344
418
  * Converts the given relative path to absolute against the root.
345
419
  * @param relativePath - The path to convert
@@ -356,14 +430,473 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
356
430
  * @returns The local value that was produced
357
431
  */
358
432
  private makeLocal;
433
+ /**
434
+ * This checks if there is pending delete op for local delete for a any subdir in the relative path.
435
+ * @param relativePath - path of sub directory.
436
+ * @returns `true` if there is pending delete, `false` otherwise.
437
+ */
438
+ private isSubDirectoryDeletePending;
359
439
  /**
360
440
  * Set the message handlers for the directory.
361
441
  */
362
442
  private setMessageHandlers;
363
443
  /**
364
- * @internal
444
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
365
445
  */
366
- protected applyStashedOp(): void;
446
+ protected applyStashedOp(op: unknown): unknown;
367
447
  private serializeDirectory;
368
448
  }
449
+ interface IKeyEditLocalOpMetadata {
450
+ type: "edit";
451
+ pendingMessageId: number;
452
+ previousValue: ILocalValue | undefined;
453
+ }
454
+ interface IClearLocalOpMetadata {
455
+ type: "clear";
456
+ pendingMessageId: number;
457
+ previousStorage: Map<string, ILocalValue>;
458
+ }
459
+ interface ICreateSubDirLocalOpMetadata {
460
+ type: "createSubDir";
461
+ }
462
+ interface IDeleteSubDirLocalOpMetadata {
463
+ type: "deleteSubDir";
464
+ subDirectory: SubDirectory | undefined;
465
+ }
466
+ type SubDirLocalOpMetadata = ICreateSubDirLocalOpMetadata | IDeleteSubDirLocalOpMetadata;
467
+ export type DirectoryLocalOpMetadata = IClearLocalOpMetadata | IKeyEditLocalOpMetadata | SubDirLocalOpMetadata;
468
+ /**
469
+ * Node of the directory tree.
470
+ * @sealed
471
+ */
472
+ declare class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirectory {
473
+ private readonly seqData;
474
+ private readonly clientIds;
475
+ private readonly directory;
476
+ private readonly runtime;
477
+ private readonly serializer;
478
+ readonly absolutePath: string;
479
+ /**
480
+ * Tells if the sub directory is deleted or not.
481
+ */
482
+ private _deleted;
483
+ /**
484
+ * String representation for the class.
485
+ */
486
+ [Symbol.toStringTag]: string;
487
+ /**
488
+ * The in-memory data the directory is storing.
489
+ */
490
+ private readonly _storage;
491
+ /**
492
+ * The subdirectories the directory is holding.
493
+ */
494
+ private readonly _subdirectories;
495
+ /**
496
+ * Keys that have been modified locally but not yet ack'd from the server. This is for operations on keys like
497
+ * set/delete operations on keys. The value of this map is list of pendingMessageIds at which that key
498
+ * was modified. We don't store the type of ops, and behaviour of key ops are different from behaviour of sub
499
+ * directory ops, so we have separate map from subDirectories tracker.
500
+ */
501
+ private readonly pendingKeys;
502
+ /**
503
+ * Subdirectories that have been deleted locally but not yet ack'd from the server. This maintains the record
504
+ * of delete op that are pending or yet to be acked from server. This is maintained just to track the locally
505
+ * deleted sub directory.
506
+ */
507
+ private readonly pendingDeleteSubDirectoriesTracker;
508
+ /**
509
+ * Subdirectories that have been created locally but not yet ack'd from the server. This maintains the record
510
+ * of create op that are pending or yet to be acked from server. This is maintained just to track the locally
511
+ * created sub directory.
512
+ */
513
+ private readonly pendingCreateSubDirectoriesTracker;
514
+ /**
515
+ * This is used to assign a unique id to every outgoing operation and helps in tracking unack'd ops.
516
+ */
517
+ private pendingMessageId;
518
+ /**
519
+ * The pending ids of any clears that have been performed locally but not yet ack'd from the server
520
+ */
521
+ private readonly pendingClearMessageIds;
522
+ /**
523
+ * Assigns a unique ID to each subdirectory created locally but pending for acknowledgement, facilitating the tracking
524
+ * of the creation order.
525
+ */
526
+ localCreationSeq: number;
527
+ /**
528
+ * Maintains a bidirectional association between ack'd subdirectories and their seqData.
529
+ * This helps to ensure iteration order which is consistent with the JS map spec.
530
+ */
531
+ readonly ackedCreationSeqTracker: DirectoryCreationTracker;
532
+ /**
533
+ * Similar to {@link ackedCreationSeqTracker}, but for local (unacked) entries.
534
+ */
535
+ readonly localCreationSeqTracker: DirectoryCreationTracker;
536
+ /**
537
+ * Constructor.
538
+ * @param sequenceNumber - Message seq number at which this was created.
539
+ * @param clientIds - Ids of client which created this directory.
540
+ * @param directory - Reference back to the SharedDirectory to perform operations
541
+ * @param runtime - The data store runtime this directory is associated with
542
+ * @param serializer - The serializer to serialize / parse handles
543
+ * @param absolutePath - The absolute path of this IDirectory
544
+ */
545
+ constructor(seqData: SequenceData, clientIds: Set<string>, directory: SharedDirectory, runtime: IFluidDataStoreRuntime, serializer: IFluidSerializer, absolutePath: string);
546
+ dispose(error?: Error): void;
547
+ /**
548
+ * Unmark the deleted property only when rolling back delete.
549
+ */
550
+ private undispose;
551
+ get disposed(): boolean;
552
+ private throwIfDisposed;
553
+ /**
554
+ * Checks whether the given key exists in this IDirectory.
555
+ * @param key - The key to check
556
+ * @returns True if the key exists, false otherwise
557
+ */
558
+ has(key: string): boolean;
559
+ /**
560
+ * {@inheritDoc IDirectory.get}
561
+ */
562
+ get<T = unknown>(key: string): T | undefined;
563
+ /**
564
+ * {@inheritDoc IDirectory.set}
565
+ */
566
+ set<T = unknown>(key: string, value: T): this;
567
+ /**
568
+ * {@inheritDoc IDirectory.countSubDirectory}
569
+ */
570
+ countSubDirectory(): number;
571
+ /**
572
+ * {@inheritDoc IDirectory.createSubDirectory}
573
+ */
574
+ createSubDirectory(subdirName: string): IDirectory;
575
+ /**
576
+ * @returns The Sequence Data which should be used for local changes.
577
+ * @remarks While detached, 0 is used rather than -1 to represent a change which should be universally known (as opposed to known
578
+ * only by the local client). This ensures that if the directory is later attached, none of its data needs to be updated (the values
579
+ * last set while detached will now be known to any new client, until they are changed).
580
+ *
581
+ * The client sequence number is incremented by 1 for maintaining the internal order of locally created subdirectories
582
+ * TODO: Convert these conventions to named constants. The semantics used here match those for merge-tree.
583
+ */
584
+ private getLocalSeq;
585
+ /**
586
+ * {@inheritDoc IDirectory.getSubDirectory}
587
+ */
588
+ getSubDirectory(subdirName: string): IDirectory | undefined;
589
+ /**
590
+ * {@inheritDoc IDirectory.hasSubDirectory}
591
+ */
592
+ hasSubDirectory(subdirName: string): boolean;
593
+ /**
594
+ * {@inheritDoc IDirectory.deleteSubDirectory}
595
+ */
596
+ deleteSubDirectory(subdirName: string): boolean;
597
+ /**
598
+ * {@inheritDoc IDirectory.subdirectories}
599
+ */
600
+ subdirectories(): IterableIterator<[string, IDirectory]>;
601
+ /**
602
+ * {@inheritDoc IDirectory.getWorkingDirectory}
603
+ */
604
+ getWorkingDirectory(relativePath: string): IDirectory | undefined;
605
+ /**
606
+ * This checks if there is pending delete op for local delete for a given child subdirectory.
607
+ * @param subDirName - directory name.
608
+ * @returns true if there is pending delete.
609
+ */
610
+ isSubDirectoryDeletePending(subDirName: string): boolean;
611
+ /**
612
+ * Deletes the given key from within this IDirectory.
613
+ * @param key - The key to delete
614
+ * @returns True if the key existed and was deleted, false if it did not exist
615
+ */
616
+ delete(key: string): boolean;
617
+ /**
618
+ * Deletes all keys from within this IDirectory.
619
+ */
620
+ clear(): void;
621
+ /**
622
+ * Issue a callback on each entry under this IDirectory.
623
+ * @param callback - Callback to issue
624
+ */
625
+ forEach(callback: (value: unknown, key: string, map: Map<string, unknown>) => void): void;
626
+ /**
627
+ * The number of entries under this IDirectory.
628
+ */
629
+ get size(): number;
630
+ /**
631
+ * Get an iterator over the entries under this IDirectory.
632
+ * @returns The iterator
633
+ */
634
+ entries(): IterableIterator<[string, unknown]>;
635
+ /**
636
+ * Get an iterator over the keys under this IDirectory.
637
+ * @returns The iterator
638
+ */
639
+ keys(): IterableIterator<string>;
640
+ /**
641
+ * Get an iterator over the values under this IDirectory.
642
+ * @returns The iterator
643
+ */
644
+ values(): IterableIterator<unknown>;
645
+ /**
646
+ * Get an iterator over the entries under this IDirectory.
647
+ * @returns The iterator
648
+ */
649
+ [Symbol.iterator](): IterableIterator<[string, unknown]>;
650
+ /**
651
+ * Process a clear operation.
652
+ * @param msg - The message from the server to apply.
653
+ * @param op - The op to process
654
+ * @param local - Whether the message originated from the local client
655
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
656
+ * For messages from a remote client, this will be undefined.
657
+ * @internal
658
+ */
659
+ processClearMessage(msg: ISequencedDocumentMessage, op: IDirectoryClearOperation, local: boolean, localOpMetadata: unknown): void;
660
+ /**
661
+ * Apply clear operation locally and generate metadata
662
+ * @param op - Op to apply
663
+ * @returns metadata generated for stahed op
664
+ */
665
+ applyStashedClearMessage(op: IDirectoryClearOperation): IClearLocalOpMetadata;
666
+ /**
667
+ * Process a delete operation.
668
+ * @param msg - The message from the server to apply.
669
+ * @param op - The op to process
670
+ * @param local - Whether the message originated from the local client
671
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
672
+ * For messages from a remote client, this will be undefined.
673
+ * @internal
674
+ */
675
+ processDeleteMessage(msg: ISequencedDocumentMessage, op: IDirectoryDeleteOperation, local: boolean, localOpMetadata: unknown): void;
676
+ /**
677
+ * Apply delete operation locally and generate metadata
678
+ * @param op - Op to apply
679
+ * @returns metadata generated for stahed op
680
+ */
681
+ applyStashedDeleteMessage(op: IDirectoryDeleteOperation): IKeyEditLocalOpMetadata;
682
+ /**
683
+ * Process a set operation.
684
+ * @param msg - The message from the server to apply.
685
+ * @param op - The op to process
686
+ * @param local - Whether the message originated from the local client
687
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
688
+ * For messages from a remote client, this will be undefined.
689
+ * @internal
690
+ */
691
+ processSetMessage(msg: ISequencedDocumentMessage, op: IDirectorySetOperation, context: ILocalValue | undefined, local: boolean, localOpMetadata: unknown): void;
692
+ /**
693
+ * Apply set operation locally and generate metadata
694
+ * @param op - Op to apply
695
+ * @returns metadata generated for stahed op
696
+ */
697
+ applyStashedSetMessage(op: IDirectorySetOperation, context: ILocalValue): IKeyEditLocalOpMetadata;
698
+ /**
699
+ * Process a create subdirectory operation.
700
+ * @param msg - The message from the server to apply.
701
+ * @param op - The op to process
702
+ * @param local - Whether the message originated from the local client
703
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
704
+ * For messages from a remote client, this will be undefined.
705
+ * @internal
706
+ */
707
+ processCreateSubDirectoryMessage(msg: ISequencedDocumentMessage, op: IDirectoryCreateSubDirectoryOperation, local: boolean, localOpMetadata: unknown): void;
708
+ /**
709
+ * Apply createSubDirectory operation locally and generate metadata
710
+ * @param op - Op to apply
711
+ * @returns metadata generated for stahed op
712
+ */
713
+ applyStashedCreateSubDirMessage(op: IDirectoryCreateSubDirectoryOperation): ICreateSubDirLocalOpMetadata;
714
+ /**
715
+ * Process a delete subdirectory operation.
716
+ * @param msg - The message from the server to apply.
717
+ * @param op - The op to process
718
+ * @param local - Whether the message originated from the local client
719
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
720
+ * For messages from a remote client, this will be undefined.
721
+ * @internal
722
+ */
723
+ processDeleteSubDirectoryMessage(msg: ISequencedDocumentMessage, op: IDirectoryDeleteSubDirectoryOperation, local: boolean, localOpMetadata: unknown): void;
724
+ /**
725
+ * Apply deleteSubDirectory operation locally and generate metadata
726
+ * @param op - Op to apply
727
+ * @returns metadata generated for stahed op
728
+ */
729
+ applyStashedDeleteSubDirMessage(op: IDirectoryDeleteSubDirectoryOperation): IDeleteSubDirLocalOpMetadata;
730
+ /**
731
+ * Submit a clear operation.
732
+ * @param op - The operation
733
+ */
734
+ private submitClearMessage;
735
+ /**
736
+ * Resubmit a clear operation.
737
+ * @param op - The operation
738
+ * @internal
739
+ */
740
+ resubmitClearMessage(op: IDirectoryClearOperation, localOpMetadata: unknown): void;
741
+ /**
742
+ * Get a new pending message id for the op and cache it to track the pending op
743
+ */
744
+ private getKeyMessageId;
745
+ /**
746
+ * Submit a key operation.
747
+ * @param op - The operation
748
+ * @param previousValue - The value of the key before this op
749
+ */
750
+ private submitKeyMessage;
751
+ /**
752
+ * Submit a key message to remote clients based on a previous submit.
753
+ * @param op - The map key message
754
+ * @param localOpMetadata - Metadata from the previous submit
755
+ * @internal
756
+ */
757
+ resubmitKeyMessage(op: IDirectoryKeyOperation, localOpMetadata: unknown): void;
758
+ private incrementPendingSubDirCount;
759
+ private decrementPendingSubDirCount;
760
+ /**
761
+ * Update the count for pending create/delete of the sub directory so that it can be validated on receiving op
762
+ * or while resubmitting the op.
763
+ */
764
+ private updatePendingSubDirMessageCount;
765
+ /**
766
+ * Submit a create subdirectory operation.
767
+ * @param op - The operation
768
+ */
769
+ private submitCreateSubDirectoryMessage;
770
+ /**
771
+ * Submit a delete subdirectory operation.
772
+ * @param op - The operation
773
+ * @param subDir - Any subdirectory deleted by the op
774
+ */
775
+ private submitDeleteSubDirectoryMessage;
776
+ /**
777
+ * Submit a subdirectory operation again
778
+ * @param op - The operation
779
+ * @param localOpMetadata - metadata submitted with the op originally
780
+ * @internal
781
+ */
782
+ resubmitSubDirectoryMessage(op: IDirectorySubDirectoryOperation, localOpMetadata: unknown): void;
783
+ /**
784
+ * Get the storage of this subdirectory in a serializable format, to be used in snapshotting.
785
+ * @param serializer - The serializer to use to serialize handles in its values.
786
+ * @returns The JSONable string representing the storage of this subdirectory
787
+ * @internal
788
+ */
789
+ getSerializedStorage(serializer: IFluidSerializer): Generator<[string, ISerializedValue], void>;
790
+ getSerializableCreateInfo(): ICreateInfo;
791
+ /**
792
+ * Populate a key value in this subdirectory's storage, to be used when loading from snapshot.
793
+ * @param key - The key to populate
794
+ * @param localValue - The local value to populate into it
795
+ * @internal
796
+ */
797
+ populateStorage(key: string, localValue: ILocalValue): void;
798
+ /**
799
+ * Populate a subdirectory into this subdirectory, to be used when loading from snapshot.
800
+ * @param subdirName - The name of the subdirectory to add
801
+ * @param newSubDir - The new subdirectory to add
802
+ * @internal
803
+ */
804
+ populateSubDirectory(subdirName: string, newSubDir: SubDirectory): void;
805
+ /**
806
+ * Retrieve the local value at the given key. This is used to get value type information stashed on the local
807
+ * value so op handlers can be retrieved
808
+ * @param key - The key to retrieve from
809
+ * @returns The local value
810
+ * @internal
811
+ */
812
+ getLocalValue<T extends ILocalValue = ILocalValue>(key: string): T;
813
+ /**
814
+ * Remove the pendingMessageId from the map tracking it on rollback
815
+ * @param map - map tracking the pending messages
816
+ * @param key - key of the edit in the op
817
+ */
818
+ private rollbackPendingMessageId;
819
+ /**
820
+ * Rollback a local op
821
+ * @param op - The operation to rollback
822
+ * @param localOpMetadata - The local metadata associated with the op.
823
+ */
824
+ rollback(op: any, localOpMetadata: unknown): void;
825
+ /**
826
+ * Converts the given relative path into an absolute path.
827
+ * @param path - Relative path to convert
828
+ * @returns The equivalent absolute path
829
+ */
830
+ private makeAbsolute;
831
+ /**
832
+ * If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should
833
+ * not process the incoming operation.
834
+ * @param op - Operation to check
835
+ * @param local - Whether the operation originated from the local client
836
+ * @param localOpMetadata - For local client ops, this is the metadata that was submitted with the op.
837
+ * For ops from a remote client, this will be undefined.
838
+ * @returns True if the operation should be processed, false otherwise
839
+ */
840
+ private needProcessStorageOperation;
841
+ /**
842
+ * This return true if the message is for the current instance of this sub directory. As the sub directory
843
+ * can be deleted and created again, then this finds if the message is for current instance of directory or not.
844
+ * @param msg - message for the directory
845
+ */
846
+ private isMessageForCurrentInstanceOfSubDirectory;
847
+ /**
848
+ * If our local operations that have not yet been ack'd will eventually overwrite an incoming operation, we should
849
+ * not process the incoming operation.
850
+ * @param op - Operation to check
851
+ * @param local - Whether the message originated from the local client
852
+ * @param message - The message
853
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
854
+ * For messages from a remote client, this will be undefined.
855
+ * @returns True if the operation should be processed, false otherwise
856
+ */
857
+ private needProcessSubDirectoryOperation;
858
+ /**
859
+ * Clear all keys in memory in response to a remote clear, but retain keys we have modified but not yet been ack'd.
860
+ */
861
+ private clearExceptPendingKeys;
862
+ /**
863
+ * Clear implementation used for both locally sourced clears as well as incoming remote clears.
864
+ * @param local - Whether the message originated from the local client
865
+ */
866
+ private clearCore;
867
+ /**
868
+ * Delete implementation used for both locally sourced deletes as well as incoming remote deletes.
869
+ * @param key - The key being deleted
870
+ * @param local - Whether the message originated from the local client
871
+ * @returns Previous local value of the key if it existed, undefined if it did not exist
872
+ */
873
+ private deleteCore;
874
+ /**
875
+ * Set implementation used for both locally sourced sets as well as incoming remote sets.
876
+ * @param key - The key being set
877
+ * @param value - The value being set
878
+ * @param local - Whether the message originated from the local client
879
+ * @returns Previous local value of the key, if any
880
+ */
881
+ private setCore;
882
+ /**
883
+ * Create subdirectory implementation used for both locally sourced creation as well as incoming remote creation.
884
+ * @param subdirName - The name of the subdirectory being created
885
+ * @param local - Whether the message originated from the local client
886
+ * @param seqData - Sequence number and client sequence number at which this directory is created
887
+ * @param clientId - Id of client which created this directory.
888
+ * @returns True if is newly created, false if it already existed.
889
+ */
890
+ private createSubDirectoryCore;
891
+ private registerEventsOnSubDirectory;
892
+ /**
893
+ * Delete subdirectory implementation used for both locally sourced creation as well as incoming remote creation.
894
+ * @param subdirName - The name of the subdirectory being deleted
895
+ * @param local - Whether the message originated from the local client
896
+ */
897
+ private deleteSubDirectoryCore;
898
+ private disposeSubDirectoryTree;
899
+ private undeleteSubDirectoryTree;
900
+ }
901
+ export {};
369
902
  //# sourceMappingURL=directory.d.ts.map