@fluidframework/map 2.0.0-dev.7.3.0.211848 → 2.0.0-dev.7.4.0.214930

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 (68) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-extractor.json +12 -1
  3. package/dist/{directory.js → directory.cjs} +222 -27
  4. package/dist/directory.cjs.map +1 -0
  5. package/dist/directory.d.ts +485 -2
  6. package/dist/directory.d.ts.map +1 -1
  7. package/dist/{index.js → index.cjs} +4 -4
  8. package/dist/index.cjs.map +1 -0
  9. package/dist/{interfaces.js → interfaces.cjs} +1 -1
  10. package/dist/interfaces.cjs.map +1 -0
  11. package/dist/{internalInterfaces.js → internalInterfaces.cjs} +1 -1
  12. package/dist/internalInterfaces.cjs.map +1 -0
  13. package/dist/{localValues.js → localValues.cjs} +1 -1
  14. package/dist/localValues.cjs.map +1 -0
  15. package/dist/map-alpha.d.ts +950 -0
  16. package/dist/map-beta.d.ts +950 -0
  17. package/dist/map-public.d.ts +950 -0
  18. package/dist/map-untrimmed.d.ts +1035 -0
  19. package/dist/{map.js → map.cjs} +3 -3
  20. package/dist/map.cjs.map +1 -0
  21. package/dist/{mapKernel.js → mapKernel.cjs} +2 -2
  22. package/dist/mapKernel.cjs.map +1 -0
  23. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  24. package/dist/packageVersion.cjs.map +1 -0
  25. package/dist/packageVersion.d.ts +1 -1
  26. package/lib/directory.d.ts +485 -2
  27. package/lib/directory.d.ts.map +1 -1
  28. package/lib/{directory.js → directory.mjs} +222 -27
  29. package/lib/directory.mjs.map +1 -0
  30. package/lib/index.mjs +8 -0
  31. package/lib/index.mjs.map +1 -0
  32. package/lib/{interfaces.js → interfaces.mjs} +1 -1
  33. package/{dist/interfaces.js.map → lib/interfaces.mjs.map} +1 -1
  34. package/lib/{internalInterfaces.js → internalInterfaces.mjs} +1 -1
  35. package/{dist/internalInterfaces.js.map → lib/internalInterfaces.mjs.map} +1 -1
  36. package/lib/{localValues.js → localValues.mjs} +1 -1
  37. package/lib/localValues.mjs.map +1 -0
  38. package/lib/map-alpha.d.ts +950 -0
  39. package/lib/map-beta.d.ts +950 -0
  40. package/lib/map-public.d.ts +950 -0
  41. package/lib/map-untrimmed.d.ts +1035 -0
  42. package/lib/{map.js → map.mjs} +3 -3
  43. package/lib/map.mjs.map +1 -0
  44. package/lib/{mapKernel.js → mapKernel.mjs} +2 -2
  45. package/lib/mapKernel.mjs.map +1 -0
  46. package/lib/packageVersion.d.ts +1 -1
  47. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  48. package/lib/packageVersion.mjs.map +1 -0
  49. package/package.json +45 -27
  50. package/src/directory.ts +261 -22
  51. package/src/packageVersion.ts +1 -1
  52. package/tsc-multi.test.json +4 -0
  53. package/dist/directory.js.map +0 -1
  54. package/dist/index.js.map +0 -1
  55. package/dist/localValues.js.map +0 -1
  56. package/dist/map.js.map +0 -1
  57. package/dist/mapKernel.js.map +0 -1
  58. package/dist/packageVersion.js.map +0 -1
  59. package/lib/directory.js.map +0 -1
  60. package/lib/index.js +0 -19
  61. package/lib/index.js.map +0 -1
  62. package/lib/interfaces.js.map +0 -1
  63. package/lib/internalInterfaces.js.map +0 -1
  64. package/lib/localValues.js.map +0 -1
  65. package/lib/map.js.map +0 -1
  66. package/lib/mapKernel.js.map +0 -1
  67. package/lib/packageVersion.js.map +0 -1
  68. package/tsconfig.esnext.json +0 -6
@@ -0,0 +1,1035 @@
1
+ /**
2
+ * The `map` library provides interfaces and implementing classes for map-like distributed data structures.
3
+ *
4
+ * @remarks The following distributed data structures are defined in this library:
5
+ *
6
+ * - {@link SharedMap}
7
+ *
8
+ * - {@link SharedDirectory}
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+
13
+ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
14
+ import { IChannelFactory } from '@fluidframework/datastore-definitions';
15
+ import { IChannelServices } from '@fluidframework/datastore-definitions';
16
+ import { IChannelStorageService } from '@fluidframework/datastore-definitions';
17
+ import { IDisposable } from '@fluidframework/core-interfaces';
18
+ import { IEvent } from '@fluidframework/core-interfaces';
19
+ import { IEventProvider } from '@fluidframework/core-interfaces';
20
+ import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
21
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
22
+ import { IFluidHandle } from '@fluidframework/core-interfaces';
23
+ import { IFluidSerializer } from '@fluidframework/shared-object-base';
24
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
25
+ import { ISharedObject } from '@fluidframework/shared-object-base';
26
+ import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
27
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
28
+ import { ITelemetryContext } from '@fluidframework/runtime-definitions';
29
+ import { SharedObject } from '@fluidframework/shared-object-base';
30
+
31
+ /**
32
+ * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedDirectory}.
33
+ *
34
+ * @sealed
35
+ * @public
36
+ */
37
+ export declare class DirectoryFactory implements IChannelFactory {
38
+ /**
39
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
40
+ */
41
+ static readonly Type = "https://graph.microsoft.com/types/directory";
42
+ /**
43
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
44
+ */
45
+ static readonly Attributes: IChannelAttributes;
46
+ /**
47
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
48
+ */
49
+ get type(): string;
50
+ /**
51
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
52
+ */
53
+ get attributes(): IChannelAttributes;
54
+ /**
55
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
56
+ */
57
+ load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<ISharedDirectory>;
58
+ /**
59
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
60
+ */
61
+ create(runtime: IFluidDataStoreRuntime, id: string): ISharedDirectory;
62
+ }
63
+
64
+ /**
65
+ * Create info for the subdirectory.
66
+ *
67
+ * @public
68
+ */
69
+ export declare interface ICreateInfo {
70
+ /**
71
+ * Sequence number at which this subdirectory was created.
72
+ */
73
+ csn: number;
74
+ /**
75
+ * clientids of the clients which created this sub directory.
76
+ */
77
+ ccIds: string[];
78
+ }
79
+
80
+ /**
81
+ * Interface describing actions on a directory.
82
+ *
83
+ * @remarks When used as a Map, operates on its keys.
84
+ *
85
+ * @public
86
+ */
87
+ export declare interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryEvents>, Partial<IDisposable> {
88
+ /**
89
+ * The absolute path of the directory.
90
+ */
91
+ readonly absolutePath: string;
92
+ /**
93
+ * Retrieves the value stored at the given key from the directory.
94
+ * @param key - Key to retrieve from
95
+ * @returns The stored value, or undefined if the key is not set
96
+ */
97
+ get<T = any>(key: string): T | undefined;
98
+ /**
99
+ * Sets the value stored at key to the provided value.
100
+ * @param key - Key to set at
101
+ * @param value - Value to set
102
+ * @returns The IDirectory itself
103
+ */
104
+ set<T = unknown>(key: string, value: T): this;
105
+ /**
106
+ * Get the number of sub directory within the directory.
107
+ * @returns The number of sub directory within a directory.
108
+ */
109
+ countSubDirectory?(): number;
110
+ /**
111
+ * Creates an IDirectory child of this IDirectory, or retrieves the existing IDirectory child if one with the
112
+ * same name already exists.
113
+ * @param subdirName - Name of the new child directory to create
114
+ * @returns The IDirectory child that was created or retrieved
115
+ */
116
+ createSubDirectory(subdirName: string): IDirectory;
117
+ /**
118
+ * Gets an IDirectory child of this IDirectory, if it exists.
119
+ * @param subdirName - Name of the child directory to get
120
+ * @returns The requested IDirectory
121
+ */
122
+ getSubDirectory(subdirName: string): IDirectory | undefined;
123
+ /**
124
+ * Checks whether this directory has a child directory with the given name.
125
+ * @param subdirName - Name of the child directory to check
126
+ * @returns True if it exists, false otherwise
127
+ */
128
+ hasSubDirectory(subdirName: string): boolean;
129
+ /**
130
+ * Deletes an IDirectory child of this IDirectory, if it exists, along with all descendent keys and directories.
131
+ * @param subdirName - Name of the child directory to delete
132
+ * @returns True if the IDirectory existed and was deleted, false if it did not exist
133
+ */
134
+ deleteSubDirectory(subdirName: string): boolean;
135
+ /**
136
+ * Gets an iterator over the IDirectory children of this IDirectory.
137
+ * @returns The IDirectory iterator
138
+ */
139
+ subdirectories(): IterableIterator<[string, IDirectory]>;
140
+ /**
141
+ * Get an IDirectory within the directory, in order to use relative paths from that location.
142
+ * @param relativePath - Path of the IDirectory to get, relative to this IDirectory
143
+ * @returns The requested IDirectory
144
+ */
145
+ getWorkingDirectory(relativePath: string): IDirectory | undefined;
146
+ }
147
+
148
+ /**
149
+ * Operation indicating the directory should be cleared.
150
+ *
151
+ * @public
152
+ */
153
+ export declare interface IDirectoryClearOperation {
154
+ /**
155
+ * String identifier of the operation type.
156
+ */
157
+ type: "clear";
158
+ /**
159
+ * Absolute path of the directory being cleared.
160
+ */
161
+ path: string;
162
+ }
163
+
164
+ /**
165
+ * Operation indicating a subdirectory should be created.
166
+ *
167
+ * @public
168
+ */
169
+ export declare interface IDirectoryCreateSubDirectoryOperation {
170
+ /**
171
+ * String identifier of the operation type.
172
+ */
173
+ type: "createSubDirectory";
174
+ /**
175
+ * Absolute path of the directory that will contain the new subdirectory.
176
+ */
177
+ path: string;
178
+ /**
179
+ * Name of the new subdirectory.
180
+ */
181
+ subdirName: string;
182
+ }
183
+
184
+ /**
185
+ * Defines the in-memory object structure to be used for the conversion to/from serialized.
186
+ *
187
+ * @remarks Directly used in
188
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
189
+ * | JSON.stringify}, direct result from
190
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.
191
+ *
192
+ * @public
193
+ */
194
+ export declare interface IDirectoryDataObject {
195
+ /**
196
+ * Key/value date set by the user.
197
+ */
198
+ storage?: {
199
+ [key: string]: ISerializableValue;
200
+ };
201
+ /**
202
+ * Recursive sub-directories {@link IDirectoryDataObject | objects}.
203
+ */
204
+ subdirectories?: {
205
+ [subdirName: string]: IDirectoryDataObject;
206
+ };
207
+ /**
208
+ * Create info for the sub directory. Since directories with same name can get deleted/created by multiple clients
209
+ * asynchronously, this info helps us to determine whether the ops where for the current instance of sub directory
210
+ * or not and whether to process them or not based on that. Summaries which were not produced which this change
211
+ * will not have this info and in that case we can still run in eventual consistency issues but that is no worse
212
+ * than the state before this change.
213
+ */
214
+ ci?: ICreateInfo;
215
+ }
216
+
217
+ /**
218
+ * Operation indicating a key should be deleted from the directory.
219
+ *
220
+ * @public
221
+ */
222
+ export declare interface IDirectoryDeleteOperation {
223
+ /**
224
+ * String identifier of the operation type.
225
+ */
226
+ type: "delete";
227
+ /**
228
+ * Directory key being modified.
229
+ */
230
+ key: string;
231
+ /**
232
+ * Absolute path of the directory where the modified key is located.
233
+ */
234
+ path: string;
235
+ }
236
+
237
+ /**
238
+ * Operation indicating a subdirectory should be deleted.
239
+ *
240
+ * @public
241
+ */
242
+ export declare interface IDirectoryDeleteSubDirectoryOperation {
243
+ /**
244
+ * String identifier of the operation type.
245
+ */
246
+ type: "deleteSubDirectory";
247
+ /**
248
+ * Absolute path of the directory that contains the directory to be deleted.
249
+ */
250
+ path: string;
251
+ /**
252
+ * Name of the subdirectory to be deleted.
253
+ */
254
+ subdirName: string;
255
+ }
256
+
257
+ /**
258
+ * Events emitted in response to changes to the directory data.
259
+ *
260
+ * @public
261
+ */
262
+ export declare interface IDirectoryEvents extends IEvent {
263
+ /**
264
+ * Emitted when a key is set or deleted. As opposed to the
265
+ * {@link SharedDirectory}'s valueChanged event, this is emitted only on the {@link IDirectory} that directly
266
+ * contains the key.
267
+ *
268
+ * @remarks Listener parameters:
269
+ *
270
+ * - `changed` - Information on the key that changed and its value prior to the change.
271
+ *
272
+ * - `local` - Whether the change originated from this client.
273
+ *
274
+ * - `target` - The {@link IDirectory} itself.
275
+ */
276
+ (event: "containedValueChanged", listener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void): any;
277
+ /**
278
+ * Emitted when a subdirectory is created. Also emitted when a delete
279
+ * of a subdirectory is rolled back.
280
+ *
281
+ * @remarks Listener parameters:
282
+ *
283
+ * - `path` - The relative path to the subdirectory that is created.
284
+ * It is relative from the object which raises the event.
285
+ *
286
+ * - `local` - Whether the creation originated from the this client.
287
+ *
288
+ * - `target` - The {@link ISharedDirectory} itself.
289
+ */
290
+ (event: "subDirectoryCreated", listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void): any;
291
+ /**
292
+ * Emitted when a subdirectory is deleted.
293
+ *
294
+ * @remarks Listener parameters:
295
+ *
296
+ * - `path` - The relative path to the subdirectory that is deleted.
297
+ * It is relative from the object which raises the event.
298
+ *
299
+ * - `local` - Whether the delete originated from the this client.
300
+ *
301
+ * - `target` - The {@link ISharedDirectory} itself.
302
+ */
303
+ (event: "subDirectoryDeleted", listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void): any;
304
+ /**
305
+ * Emitted when this sub directory is deleted.
306
+ *
307
+ * @remarks Listener parameters:
308
+ *
309
+ * - `target` - The {@link IDirectory} itself.
310
+ */
311
+ (event: "disposed", listener: (target: IEventThisPlaceHolder) => void): any;
312
+ /**
313
+ * Emitted when this previously deleted sub directory is restored.
314
+ * This event only needs to be handled in the case of rollback. If your application does
315
+ * not use the local rollback feature, you can ignore this event.
316
+ *
317
+ * @remarks Listener parameters:
318
+ *
319
+ * - `target` - The {@link IDirectory} itself.
320
+ */
321
+ (event: "undisposed", listener: (target: IEventThisPlaceHolder) => void): any;
322
+ }
323
+
324
+ /**
325
+ * An operation on a specific key within a directory.
326
+ *
327
+ * @public
328
+ */
329
+ export declare type IDirectoryKeyOperation = IDirectorySetOperation | IDirectoryDeleteOperation;
330
+
331
+ /**
332
+ * {@link IDirectory} storage format.
333
+ *
334
+ * @internal
335
+ */
336
+ export declare interface IDirectoryNewStorageFormat {
337
+ /**
338
+ * Blob IDs representing larger directory data that was serialized.
339
+ */
340
+ blobs: string[];
341
+ /**
342
+ * Storage content representing directory data that was not serialized.
343
+ */
344
+ content: IDirectoryDataObject;
345
+ }
346
+
347
+ /**
348
+ * Any operation on a directory.
349
+ *
350
+ * @public
351
+ */
352
+ export declare type IDirectoryOperation = IDirectoryStorageOperation | IDirectorySubDirectoryOperation;
353
+
354
+ /**
355
+ * Operation indicating a value should be set for a key.
356
+ *
357
+ * @public
358
+ */
359
+ export declare interface IDirectorySetOperation {
360
+ /**
361
+ * String identifier of the operation type.
362
+ */
363
+ type: "set";
364
+ /**
365
+ * Directory key being modified.
366
+ */
367
+ key: string;
368
+ /**
369
+ * Absolute path of the directory where the modified key is located.
370
+ */
371
+ path: string;
372
+ /**
373
+ * Value to be set on the key.
374
+ */
375
+ value: ISerializableValue;
376
+ }
377
+
378
+ /**
379
+ * An operation on one or more of the keys within a directory.
380
+ *
381
+ * @public
382
+ */
383
+ export declare type IDirectoryStorageOperation = IDirectoryKeyOperation | IDirectoryClearOperation;
384
+
385
+ /**
386
+ * An operation on the subdirectories within a directory.
387
+ *
388
+ * @public
389
+ */
390
+ export declare type IDirectorySubDirectoryOperation = IDirectoryCreateSubDirectoryOperation | IDirectoryDeleteSubDirectoryOperation;
391
+
392
+ /**
393
+ * Type of "valueChanged" event parameter for {@link ISharedDirectory}.
394
+ *
395
+ * @public
396
+ */
397
+ export declare interface IDirectoryValueChanged extends IValueChanged {
398
+ /**
399
+ * The absolute path to the IDirectory storing the key which changed.
400
+ */
401
+ path: string;
402
+ }
403
+
404
+ /**
405
+ * A local value to be stored in a container type Distributed Data Store (DDS).
406
+ *
407
+ * @public
408
+ */
409
+ export declare interface ILocalValue {
410
+ /**
411
+ * Type indicator of the value stored within.
412
+ */
413
+ readonly type: string;
414
+ /**
415
+ * The in-memory value stored within.
416
+ */
417
+ readonly value: any;
418
+ /**
419
+ * Retrieve the serialized form of the value stored within.
420
+ * @param serializer - Data store runtime's serializer
421
+ * @param bind - Container type's handle
422
+ * @returns The serialized form of the contained value
423
+ */
424
+ makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue;
425
+ }
426
+
427
+ /**
428
+ * The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use
429
+ * {@link ISerializableValue."type"} to understand whether they're storing a Plain JavaScript object,
430
+ * a {@link @fluidframework/shared-object-base#SharedObject}, or a value type.
431
+ *
432
+ * @remarks
433
+ *
434
+ * Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with
435
+ * the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to
436
+ * JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)
437
+ * and ops (set).
438
+ *
439
+ * If type is Plain, it must be a plain JS object that can survive a JSON.stringify/parse. E.g. a URL object will
440
+ * just get stringified to a URL string and not rehydrate as a URL object on the other side. It may contain members
441
+ * that are ISerializedHandle (the serialized form of a handle).
442
+ *
443
+ * If type is a value type then it must be amongst the types registered via registerValueType or we won't know how
444
+ * to serialize/deserialize it (we rely on its factory via .load() and .store()). Its value will be type-dependent.
445
+ * If type is Shared, then the in-memory value will just be a reference to the SharedObject. Its value will be a
446
+ * channel ID.
447
+ *
448
+ * @deprecated This type is legacy and deprecated.
449
+ *
450
+ * @public
451
+ */
452
+ export declare interface ISerializableValue {
453
+ /**
454
+ * A type annotation to help indicate how the value serializes.
455
+ */
456
+ type: string;
457
+ /**
458
+ * The JSONable representation of the value.
459
+ */
460
+ value: any;
461
+ }
462
+
463
+ /**
464
+ * Serialized {@link ISerializableValue} counterpart.
465
+ *
466
+ * @public
467
+ */
468
+ export declare interface ISerializedValue {
469
+ /**
470
+ * A type annotation to help indicate how the value serializes.
471
+ */
472
+ type: string;
473
+ /**
474
+ * String representation of the value.
475
+ *
476
+ * @remarks Will be undefined if the original value was undefined.
477
+ */
478
+ value: string | undefined;
479
+ }
480
+
481
+ /**
482
+ * Provides a hierarchical organization of map-like data structures as SubDirectories.
483
+ * The values stored within can be accessed like a map, and the hierarchy can be navigated using path syntax.
484
+ * SubDirectories can be retrieved for use as working directories.
485
+ *
486
+ * @public
487
+ */
488
+ export declare interface ISharedDirectory extends ISharedObject<ISharedDirectoryEvents & IDirectoryEvents>, Omit<IDirectory, "on" | "once" | "off"> {
489
+ [Symbol.iterator](): IterableIterator<[string, any]>;
490
+ readonly [Symbol.toStringTag]: string;
491
+ }
492
+
493
+ /**
494
+ * Events emitted in response to changes to the directory data.
495
+ *
496
+ * @remarks
497
+ * These events only emit on the {@link ISharedDirectory} itself, and not on subdirectories.
498
+ *
499
+ * @public
500
+ */
501
+ export declare interface ISharedDirectoryEvents extends ISharedObjectEvents {
502
+ /**
503
+ * Emitted when a key is set or deleted. This is emitted for any key in the {@link ISharedDirectory} or any
504
+ * subdirectory.
505
+ *
506
+ * @remarks Listener parameters:
507
+ *
508
+ * - `changed` - Information on the key that changed, its value prior to the change, and the path to the
509
+ * key that changed.
510
+ *
511
+ * - `local` - Whether the change originated from this client.
512
+ *
513
+ * - `target` - The {@link ISharedDirectory} itself.
514
+ */
515
+ (event: "valueChanged", listener: (changed: IDirectoryValueChanged, local: boolean, target: IEventThisPlaceHolder) => void): any;
516
+ /**
517
+ * Emitted when the {@link ISharedDirectory} is cleared.
518
+ *
519
+ * @remarks Listener parameters:
520
+ *
521
+ * - `local` - Whether the clear originated from this client.
522
+ *
523
+ * - `target` - The {@link ISharedDirectory} itself.
524
+ */
525
+ (event: "clear", listener: (local: boolean, target: IEventThisPlaceHolder) => void): any;
526
+ /**
527
+ * Emitted when a subdirectory is created.
528
+ *
529
+ * @remarks Listener parameters:
530
+ *
531
+ * - `path` - The relative path to the subdirectory that is created.
532
+ * It is relative from the object which raises the event.
533
+ *
534
+ * - `local` - Whether the create originated from the this client.
535
+ *
536
+ * - `target` - The {@link ISharedDirectory} itself.
537
+ */
538
+ (event: "subDirectoryCreated", listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void): any;
539
+ /**
540
+ * Emitted when a subdirectory is deleted.
541
+ *
542
+ * @remarks Listener parameters:
543
+ *
544
+ * - `path` - The relative path to the subdirectory that is deleted.
545
+ * It is relative from the object which raises the event.
546
+ *
547
+ * - `local` - Whether the delete originated from the this client.
548
+ *
549
+ * - `target` - The {@link ISharedDirectory} itself.
550
+ */
551
+ (event: "subDirectoryDeleted", listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void): any;
552
+ }
553
+
554
+ /**
555
+ * The SharedMap distributed data structure can be used to store key-value pairs. It provides the same API for setting
556
+ * and retrieving values that JavaScript developers are accustomed to with the
557
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} built-in object.
558
+ * However, the keys of a SharedMap must be strings, and the values must either be a JSON-serializable object or a
559
+ * {@link @fluidframework/datastore#FluidObjectHandle}.
560
+ *
561
+ * For more information, including example usages, see {@link https://fluidframework.com/docs/data-structures/map/}.
562
+ *
563
+ * @public
564
+ */
565
+ export declare interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string, any> {
566
+ /**
567
+ * Retrieves the given key from the map if it exists.
568
+ * @param key - Key to retrieve from
569
+ * @returns The stored value, or undefined if the key is not set
570
+ */
571
+ get<T = any>(key: string): T | undefined;
572
+ /**
573
+ * Sets the value stored at key to the provided value.
574
+ * @param key - Key to set
575
+ * @param value - Value to set
576
+ * @returns The {@link ISharedMap} itself
577
+ */
578
+ set<T = unknown>(key: string, value: T): this;
579
+ }
580
+
581
+ /**
582
+ * Events emitted in response to changes to the {@link ISharedMap | map} data.
583
+ *
584
+ * @public
585
+ */
586
+ export declare interface ISharedMapEvents extends ISharedObjectEvents {
587
+ /**
588
+ * Emitted when a key is set or deleted.
589
+ *
590
+ * @remarks Listener parameters:
591
+ *
592
+ * - `changed` - Information on the key that changed and its value prior to the change.
593
+ *
594
+ * - `local` - Whether the change originated from this client.
595
+ *
596
+ * - `target` - The {@link ISharedMap} itself.
597
+ */
598
+ (event: "valueChanged", listener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void): any;
599
+ /**
600
+ * Emitted when the map is cleared.
601
+ *
602
+ * @remarks Listener parameters:
603
+ *
604
+ * - `local` - Whether the clear originated from this client.
605
+ *
606
+ * - `target` - The {@link ISharedMap} itself.
607
+ */
608
+ (event: "clear", listener: (local: boolean, target: IEventThisPlaceHolder) => void): any;
609
+ }
610
+
611
+ /**
612
+ * Type of "valueChanged" event parameter.
613
+ *
614
+ * @public
615
+ */
616
+ export declare interface IValueChanged {
617
+ /**
618
+ * The key storing the value that changed.
619
+ */
620
+ key: string;
621
+ /**
622
+ * The value that was stored at the key prior to the change.
623
+ */
624
+ previousValue: any;
625
+ }
626
+
627
+ /**
628
+ * Enables a container type {@link https://fluidframework.com/docs/build/dds/ | DDS} to produce and store local
629
+ * values with minimal awareness of how those objects are stored, serialized, and deserialized.
630
+ *
631
+ * @public
632
+ */
633
+ export declare class LocalValueMaker {
634
+ private readonly serializer;
635
+ /**
636
+ * Create a new LocalValueMaker.
637
+ * @param serializer - The serializer to serialize / parse handles.
638
+ */
639
+ constructor(serializer: IFluidSerializer);
640
+ /**
641
+ * Create a new local value from an incoming serialized value.
642
+ * @param serializable - The serializable value to make local
643
+ */
644
+ fromSerializable(serializable: ISerializableValue): ILocalValue;
645
+ /**
646
+ * Create a new local value containing a given plain object.
647
+ * @param value - The value to store
648
+ * @returns An ILocalValue containing the value
649
+ */
650
+ fromInMemory(value: unknown): ILocalValue;
651
+ }
652
+
653
+ /**
654
+ * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMap}.
655
+ *
656
+ * @sealed
657
+ * @public
658
+ */
659
+ export declare class MapFactory implements IChannelFactory {
660
+ /**
661
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
662
+ */
663
+ static readonly Type = "https://graph.microsoft.com/types/map";
664
+ /**
665
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
666
+ */
667
+ static readonly Attributes: IChannelAttributes;
668
+ /**
669
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
670
+ */
671
+ get type(): string;
672
+ /**
673
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
674
+ */
675
+ get attributes(): IChannelAttributes;
676
+ /**
677
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
678
+ */
679
+ load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<ISharedMap>;
680
+ /**
681
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
682
+ */
683
+ create(runtime: IFluidDataStoreRuntime, id: string): ISharedMap;
684
+ }
685
+
686
+ /**
687
+ * {@inheritDoc ISharedDirectory}
688
+ *
689
+ * @example
690
+ *
691
+ * ```typescript
692
+ * mySharedDirectory.createSubDirectory("a").createSubDirectory("b").createSubDirectory("c").set("foo", val1);
693
+ * const mySubDir = mySharedDirectory.getWorkingDirectory("/a/b/c");
694
+ * mySubDir.get("foo"); // returns val1
695
+ * ```
696
+ *
697
+ * @sealed
698
+ * @public
699
+ */
700
+ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents> implements ISharedDirectory {
701
+ /**
702
+ * Create a new shared directory
703
+ *
704
+ * @param runtime - Data store runtime the new shared directory belongs to
705
+ * @param id - Optional name of the shared directory
706
+ * @returns Newly create shared directory (but not attached yet)
707
+ */
708
+ static create(runtime: IFluidDataStoreRuntime, id?: string): SharedDirectory;
709
+ /**
710
+ * Get a factory for SharedDirectory to register with the data store.
711
+ *
712
+ * @returns A factory that creates and load SharedDirectory
713
+ */
714
+ static getFactory(): IChannelFactory;
715
+ /**
716
+ * String representation for the class.
717
+ */
718
+ [Symbol.toStringTag]: string;
719
+ /**
720
+ * {@inheritDoc IDirectory.absolutePath}
721
+ */
722
+ get absolutePath(): string;
723
+ /**
724
+ * @internal
725
+ */
726
+ readonly localValueMaker: LocalValueMaker;
727
+ /**
728
+ * Root of the SharedDirectory, most operations on the SharedDirectory itself act on the root.
729
+ */
730
+ private readonly root;
731
+ /**
732
+ * Mapping of op types to message handlers.
733
+ */
734
+ private readonly messageHandlers;
735
+ /**
736
+ * Constructs a new shared directory. If the object is non-local an id and service interfaces will
737
+ * be provided.
738
+ * @param id - String identifier for the SharedDirectory
739
+ * @param runtime - Data store runtime
740
+ * @param type - Type identifier
741
+ */
742
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
743
+ /**
744
+ * {@inheritDoc IDirectory.get}
745
+ */
746
+ get<T = any>(key: string): T | undefined;
747
+ /**
748
+ * {@inheritDoc IDirectory.set}
749
+ */
750
+ set<T = unknown>(key: string, value: T): this;
751
+ dispose(error?: Error): void;
752
+ get disposed(): boolean;
753
+ /**
754
+ * Deletes the given key from within this IDirectory.
755
+ * @param key - The key to delete
756
+ * @returns True if the key existed and was deleted, false if it did not exist
757
+ */
758
+ delete(key: string): boolean;
759
+ /**
760
+ * Deletes all keys from within this IDirectory.
761
+ */
762
+ clear(): void;
763
+ /**
764
+ * Checks whether the given key exists in this IDirectory.
765
+ * @param key - The key to check
766
+ * @returns True if the key exists, false otherwise
767
+ */
768
+ has(key: string): boolean;
769
+ /**
770
+ * The number of entries under this IDirectory.
771
+ */
772
+ get size(): number;
773
+ /**
774
+ * Issue a callback on each entry under this IDirectory.
775
+ * @param callback - Callback to issue
776
+ */
777
+ forEach(callback: (value: any, key: string, map: Map<string, any>) => void): void;
778
+ /**
779
+ * Get an iterator over the entries under this IDirectory.
780
+ * @returns The iterator
781
+ */
782
+ [Symbol.iterator](): IterableIterator<[string, any]>;
783
+ /**
784
+ * Get an iterator over the entries under this IDirectory.
785
+ * @returns The iterator
786
+ */
787
+ entries(): IterableIterator<[string, any]>;
788
+ /**
789
+ * {@inheritDoc IDirectory.countSubDirectory}
790
+ */
791
+ countSubDirectory(): number;
792
+ /**
793
+ * Get an iterator over the keys under this IDirectory.
794
+ * @returns The iterator
795
+ */
796
+ keys(): IterableIterator<string>;
797
+ /**
798
+ * Get an iterator over the values under this IDirectory.
799
+ * @returns The iterator
800
+ */
801
+ values(): IterableIterator<any>;
802
+ /**
803
+ * {@inheritDoc IDirectory.createSubDirectory}
804
+ */
805
+ createSubDirectory(subdirName: string): IDirectory;
806
+ /**
807
+ * {@inheritDoc IDirectory.getSubDirectory}
808
+ */
809
+ getSubDirectory(subdirName: string): IDirectory | undefined;
810
+ /**
811
+ * {@inheritDoc IDirectory.hasSubDirectory}
812
+ */
813
+ hasSubDirectory(subdirName: string): boolean;
814
+ /**
815
+ * {@inheritDoc IDirectory.deleteSubDirectory}
816
+ */
817
+ deleteSubDirectory(subdirName: string): boolean;
818
+ /**
819
+ * {@inheritDoc IDirectory.subdirectories}
820
+ */
821
+ subdirectories(): IterableIterator<[string, IDirectory]>;
822
+ /**
823
+ * {@inheritDoc IDirectory.getWorkingDirectory}
824
+ */
825
+ getWorkingDirectory(relativePath: string): IDirectory | undefined;
826
+ /**
827
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
828
+ * @internal
829
+ */
830
+ protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
831
+ /**
832
+ * Submits an operation
833
+ * @param op - Op to submit
834
+ * @param localOpMetadata - The local metadata associated with the op. We send a unique id that is used to track
835
+ * this op while it has not been ack'd. This will be sent when we receive this op back from the server.
836
+ * @internal
837
+ */
838
+ submitDirectoryMessage(op: IDirectoryOperation, localOpMetadata: unknown): void;
839
+ /**
840
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
841
+ * @internal
842
+ */
843
+ protected onDisconnect(): void;
844
+ /**
845
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
846
+ * @internal
847
+ */
848
+ protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
849
+ /**
850
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
851
+ * @internal
852
+ */
853
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
854
+ /**
855
+ * Populate the directory with the given directory data.
856
+ * @param data - A JSON string containing serialized directory data
857
+ * @internal
858
+ */
859
+ protected populate(data: IDirectoryDataObject): void;
860
+ /**
861
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
862
+ * @internal
863
+ */
864
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
865
+ /**
866
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
867
+ * @internal
868
+ */
869
+ protected rollback(content: unknown, localOpMetadata: unknown): void;
870
+ /**
871
+ * Converts the given relative path to absolute against the root.
872
+ * @param relativePath - The path to convert
873
+ */
874
+ private makeAbsolute;
875
+ /**
876
+ * The remote ISerializableValue we're receiving (either as a result of a snapshot load or an incoming set op)
877
+ * will have the information we need to create a real object, but will not be the real object yet. For example,
878
+ * we might know it's a map and the ID but not have the actual map or its data yet. makeLocal's job
879
+ * is to convert that information into a real object for local usage.
880
+ * @param key - Key of element being converted
881
+ * @param absolutePath - Path of element being converted
882
+ * @param serializable - The remote information that we can convert into a real object
883
+ * @returns The local value that was produced
884
+ */
885
+ private makeLocal;
886
+ /**
887
+ * This checks if there is pending delete op for local delete for a any subdir in the relative path.
888
+ * @param relativePath - path of sub directory.
889
+ * @returns `true` if there is pending delete, `false` otherwise.
890
+ */
891
+ private isSubDirectoryDeletePending;
892
+ /**
893
+ * Set the message handlers for the directory.
894
+ */
895
+ private setMessageHandlers;
896
+ /**
897
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
898
+ * @internal
899
+ */
900
+ protected applyStashedOp(op: unknown): unknown;
901
+ private serializeDirectory;
902
+ }
903
+
904
+ /**
905
+ * {@inheritDoc ISharedMap}
906
+ *
907
+ * @public
908
+ */
909
+ export declare class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {
910
+ /**
911
+ * Create a new shared map.
912
+ * @param runtime - The data store runtime that the new shared map belongs to.
913
+ * @param id - Optional name of the shared map.
914
+ * @returns Newly created shared map.
915
+ *
916
+ * @example
917
+ * To create a `SharedMap`, call the static create method:
918
+ *
919
+ * ```typescript
920
+ * const myMap = SharedMap.create(this.runtime, id);
921
+ * ```
922
+ */
923
+ static create(runtime: IFluidDataStoreRuntime, id?: string): SharedMap;
924
+ /**
925
+ * Get a factory for SharedMap to register with the data store.
926
+ * @returns A factory that creates SharedMaps and loads them from storage.
927
+ */
928
+ static getFactory(): IChannelFactory;
929
+ /**
930
+ * String representation for the class.
931
+ */
932
+ readonly [Symbol.toStringTag]: string;
933
+ /**
934
+ * MapKernel which manages actual map operations.
935
+ */
936
+ private readonly kernel;
937
+ /**
938
+ * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.
939
+ *
940
+ * @param id - String identifier.
941
+ * @param runtime - Data store runtime.
942
+ * @param attributes - The attributes for the map.
943
+ */
944
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
945
+ /**
946
+ * Get an iterator over the keys in this map.
947
+ * @returns The iterator
948
+ */
949
+ keys(): IterableIterator<string>;
950
+ /**
951
+ * Get an iterator over the entries in this map.
952
+ * @returns The iterator
953
+ */
954
+ entries(): IterableIterator<[string, any]>;
955
+ /**
956
+ * Get an iterator over the values in this map.
957
+ * @returns The iterator
958
+ */
959
+ values(): IterableIterator<any>;
960
+ /**
961
+ * Get an iterator over the entries in this map.
962
+ * @returns The iterator
963
+ */
964
+ [Symbol.iterator](): IterableIterator<[string, any]>;
965
+ /**
966
+ * The number of key/value pairs stored in the map.
967
+ */
968
+ get size(): number;
969
+ /**
970
+ * Executes the given callback on each entry in the map.
971
+ * @param callbackFn - Callback function
972
+ */
973
+ forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void;
974
+ /**
975
+ * {@inheritDoc ISharedMap.get}
976
+ */
977
+ get<T = any>(key: string): T | undefined;
978
+ /**
979
+ * Check if a key exists in the map.
980
+ * @param key - The key to check
981
+ * @returns True if the key exists, false otherwise
982
+ */
983
+ has(key: string): boolean;
984
+ /**
985
+ * {@inheritDoc ISharedMap.set}
986
+ */
987
+ set(key: string, value: unknown): this;
988
+ /**
989
+ * Delete a key from the map.
990
+ * @param key - Key to delete
991
+ * @returns True if the key existed and was deleted, false if it did not exist
992
+ */
993
+ delete(key: string): boolean;
994
+ /**
995
+ * Clear all data from the map.
996
+ */
997
+ clear(): void;
998
+ /**
999
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
1000
+ * @internal
1001
+ */
1002
+ protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
1003
+ /**
1004
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
1005
+ * @internal
1006
+ */
1007
+ protected loadCore(storage: IChannelStorageService): Promise<void>;
1008
+ /**
1009
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
1010
+ * @internal
1011
+ */
1012
+ protected onDisconnect(): void;
1013
+ /**
1014
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.reSubmitCore}
1015
+ * @internal
1016
+ */
1017
+ protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
1018
+ /**
1019
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObjectCore.applyStashedOp}
1020
+ * @internal
1021
+ */
1022
+ protected applyStashedOp(content: unknown): unknown;
1023
+ /**
1024
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processCore}
1025
+ * @internal
1026
+ */
1027
+ protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
1028
+ /**
1029
+ * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
1030
+ * @internal
1031
+ */
1032
+ protected rollback(content: unknown, localOpMetadata: unknown): void;
1033
+ }
1034
+
1035
+ export { }