@fluidframework/map 2.0.0-dev.7.3.0.210328 → 2.0.0-dev.7.3.0.212138

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 (64) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-extractor.json +4 -1
  3. package/dist/{directory.js → directory.cjs} +3 -3
  4. package/dist/directory.cjs.map +1 -0
  5. package/dist/{index.js → index.cjs} +4 -4
  6. package/dist/index.cjs.map +1 -0
  7. package/dist/{interfaces.js → interfaces.cjs} +1 -1
  8. package/dist/interfaces.cjs.map +1 -0
  9. package/dist/{internalInterfaces.js → internalInterfaces.cjs} +1 -1
  10. package/dist/internalInterfaces.cjs.map +1 -0
  11. package/dist/{localValues.js → localValues.cjs} +1 -1
  12. package/dist/localValues.cjs.map +1 -0
  13. package/dist/map-alpha.d.ts +950 -0
  14. package/dist/map-beta.d.ts +950 -0
  15. package/dist/map-public.d.ts +950 -0
  16. package/dist/map-untrimmed.d.ts +1035 -0
  17. package/dist/{map.js → map.cjs} +3 -3
  18. package/dist/map.cjs.map +1 -0
  19. package/dist/{mapKernel.js → mapKernel.cjs} +2 -2
  20. package/dist/mapKernel.cjs.map +1 -0
  21. package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
  22. package/dist/packageVersion.cjs.map +1 -0
  23. package/dist/packageVersion.d.ts +1 -1
  24. package/dist/tsdoc-metadata.json +1 -1
  25. package/lib/{directory.js → directory.mjs} +3 -3
  26. package/lib/directory.mjs.map +1 -0
  27. package/lib/index.mjs +8 -0
  28. package/lib/index.mjs.map +1 -0
  29. package/lib/{interfaces.js → interfaces.mjs} +1 -1
  30. package/{dist/interfaces.js.map → lib/interfaces.mjs.map} +1 -1
  31. package/lib/{internalInterfaces.js → internalInterfaces.mjs} +1 -1
  32. package/{dist/internalInterfaces.js.map → lib/internalInterfaces.mjs.map} +1 -1
  33. package/lib/{localValues.js → localValues.mjs} +1 -1
  34. package/lib/localValues.mjs.map +1 -0
  35. package/lib/map-alpha.d.ts +950 -0
  36. package/lib/map-beta.d.ts +950 -0
  37. package/lib/map-public.d.ts +950 -0
  38. package/lib/map-untrimmed.d.ts +1035 -0
  39. package/lib/{map.js → map.mjs} +3 -3
  40. package/lib/map.mjs.map +1 -0
  41. package/lib/{mapKernel.js → mapKernel.mjs} +2 -2
  42. package/lib/mapKernel.mjs.map +1 -0
  43. package/lib/packageVersion.d.ts +1 -1
  44. package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
  45. package/lib/packageVersion.mjs.map +1 -0
  46. package/package.json +44 -27
  47. package/src/packageVersion.ts +1 -1
  48. package/tsc-multi.test.json +4 -0
  49. package/dist/directory.js.map +0 -1
  50. package/dist/index.js.map +0 -1
  51. package/dist/localValues.js.map +0 -1
  52. package/dist/map.js.map +0 -1
  53. package/dist/mapKernel.js.map +0 -1
  54. package/dist/packageVersion.js.map +0 -1
  55. package/lib/directory.js.map +0 -1
  56. package/lib/index.js +0 -19
  57. package/lib/index.js.map +0 -1
  58. package/lib/interfaces.js.map +0 -1
  59. package/lib/internalInterfaces.js.map +0 -1
  60. package/lib/localValues.js.map +0 -1
  61. package/lib/map.js.map +0 -1
  62. package/lib/mapKernel.js.map +0 -1
  63. package/lib/packageVersion.js.map +0 -1
  64. package/tsconfig.esnext.json +0 -6
@@ -0,0 +1,950 @@
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
+ /* Excluded from this release type: IDirectoryNewStorageFormat */
332
+
333
+ /**
334
+ * Any operation on a directory.
335
+ *
336
+ * @public
337
+ */
338
+ export declare type IDirectoryOperation = IDirectoryStorageOperation | IDirectorySubDirectoryOperation;
339
+
340
+ /**
341
+ * Operation indicating a value should be set for a key.
342
+ *
343
+ * @public
344
+ */
345
+ export declare interface IDirectorySetOperation {
346
+ /**
347
+ * String identifier of the operation type.
348
+ */
349
+ type: "set";
350
+ /**
351
+ * Directory key being modified.
352
+ */
353
+ key: string;
354
+ /**
355
+ * Absolute path of the directory where the modified key is located.
356
+ */
357
+ path: string;
358
+ /**
359
+ * Value to be set on the key.
360
+ */
361
+ value: ISerializableValue;
362
+ }
363
+
364
+ /**
365
+ * An operation on one or more of the keys within a directory.
366
+ *
367
+ * @public
368
+ */
369
+ export declare type IDirectoryStorageOperation = IDirectoryKeyOperation | IDirectoryClearOperation;
370
+
371
+ /**
372
+ * An operation on the subdirectories within a directory.
373
+ *
374
+ * @public
375
+ */
376
+ export declare type IDirectorySubDirectoryOperation = IDirectoryCreateSubDirectoryOperation | IDirectoryDeleteSubDirectoryOperation;
377
+
378
+ /**
379
+ * Type of "valueChanged" event parameter for {@link ISharedDirectory}.
380
+ *
381
+ * @public
382
+ */
383
+ export declare interface IDirectoryValueChanged extends IValueChanged {
384
+ /**
385
+ * The absolute path to the IDirectory storing the key which changed.
386
+ */
387
+ path: string;
388
+ }
389
+
390
+ /**
391
+ * A local value to be stored in a container type Distributed Data Store (DDS).
392
+ *
393
+ * @public
394
+ */
395
+ export declare interface ILocalValue {
396
+ /**
397
+ * Type indicator of the value stored within.
398
+ */
399
+ readonly type: string;
400
+ /**
401
+ * The in-memory value stored within.
402
+ */
403
+ readonly value: any;
404
+ /**
405
+ * Retrieve the serialized form of the value stored within.
406
+ * @param serializer - Data store runtime's serializer
407
+ * @param bind - Container type's handle
408
+ * @returns The serialized form of the contained value
409
+ */
410
+ makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue;
411
+ }
412
+
413
+ /**
414
+ * The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use
415
+ * {@link ISerializableValue."type"} to understand whether they're storing a Plain JavaScript object,
416
+ * a {@link @fluidframework/shared-object-base#SharedObject}, or a value type.
417
+ *
418
+ * @remarks
419
+ *
420
+ * Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with
421
+ * the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to
422
+ * JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)
423
+ * and ops (set).
424
+ *
425
+ * If type is Plain, it must be a plain JS object that can survive a JSON.stringify/parse. E.g. a URL object will
426
+ * just get stringified to a URL string and not rehydrate as a URL object on the other side. It may contain members
427
+ * that are ISerializedHandle (the serialized form of a handle).
428
+ *
429
+ * If type is a value type then it must be amongst the types registered via registerValueType or we won't know how
430
+ * to serialize/deserialize it (we rely on its factory via .load() and .store()). Its value will be type-dependent.
431
+ * If type is Shared, then the in-memory value will just be a reference to the SharedObject. Its value will be a
432
+ * channel ID.
433
+ *
434
+ * @deprecated This type is legacy and deprecated.
435
+ *
436
+ * @public
437
+ */
438
+ export declare interface ISerializableValue {
439
+ /**
440
+ * A type annotation to help indicate how the value serializes.
441
+ */
442
+ type: string;
443
+ /**
444
+ * The JSONable representation of the value.
445
+ */
446
+ value: any;
447
+ }
448
+
449
+ /**
450
+ * Serialized {@link ISerializableValue} counterpart.
451
+ *
452
+ * @public
453
+ */
454
+ export declare interface ISerializedValue {
455
+ /**
456
+ * A type annotation to help indicate how the value serializes.
457
+ */
458
+ type: string;
459
+ /**
460
+ * String representation of the value.
461
+ *
462
+ * @remarks Will be undefined if the original value was undefined.
463
+ */
464
+ value: string | undefined;
465
+ }
466
+
467
+ /**
468
+ * Provides a hierarchical organization of map-like data structures as SubDirectories.
469
+ * The values stored within can be accessed like a map, and the hierarchy can be navigated using path syntax.
470
+ * SubDirectories can be retrieved for use as working directories.
471
+ *
472
+ * @public
473
+ */
474
+ export declare interface ISharedDirectory extends ISharedObject<ISharedDirectoryEvents & IDirectoryEvents>, Omit<IDirectory, "on" | "once" | "off"> {
475
+ [Symbol.iterator](): IterableIterator<[string, any]>;
476
+ readonly [Symbol.toStringTag]: string;
477
+ }
478
+
479
+ /**
480
+ * Events emitted in response to changes to the directory data.
481
+ *
482
+ * @remarks
483
+ * These events only emit on the {@link ISharedDirectory} itself, and not on subdirectories.
484
+ *
485
+ * @public
486
+ */
487
+ export declare interface ISharedDirectoryEvents extends ISharedObjectEvents {
488
+ /**
489
+ * Emitted when a key is set or deleted. This is emitted for any key in the {@link ISharedDirectory} or any
490
+ * subdirectory.
491
+ *
492
+ * @remarks Listener parameters:
493
+ *
494
+ * - `changed` - Information on the key that changed, its value prior to the change, and the path to the
495
+ * key that changed.
496
+ *
497
+ * - `local` - Whether the change originated from this client.
498
+ *
499
+ * - `target` - The {@link ISharedDirectory} itself.
500
+ */
501
+ (event: "valueChanged", listener: (changed: IDirectoryValueChanged, local: boolean, target: IEventThisPlaceHolder) => void): any;
502
+ /**
503
+ * Emitted when the {@link ISharedDirectory} is cleared.
504
+ *
505
+ * @remarks Listener parameters:
506
+ *
507
+ * - `local` - Whether the clear originated from this client.
508
+ *
509
+ * - `target` - The {@link ISharedDirectory} itself.
510
+ */
511
+ (event: "clear", listener: (local: boolean, target: IEventThisPlaceHolder) => void): any;
512
+ /**
513
+ * Emitted when a subdirectory is created.
514
+ *
515
+ * @remarks Listener parameters:
516
+ *
517
+ * - `path` - The relative path to the subdirectory that is created.
518
+ * It is relative from the object which raises the event.
519
+ *
520
+ * - `local` - Whether the create originated from the this client.
521
+ *
522
+ * - `target` - The {@link ISharedDirectory} itself.
523
+ */
524
+ (event: "subDirectoryCreated", listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void): any;
525
+ /**
526
+ * Emitted when a subdirectory is deleted.
527
+ *
528
+ * @remarks Listener parameters:
529
+ *
530
+ * - `path` - The relative path to the subdirectory that is deleted.
531
+ * It is relative from the object which raises the event.
532
+ *
533
+ * - `local` - Whether the delete originated from the this client.
534
+ *
535
+ * - `target` - The {@link ISharedDirectory} itself.
536
+ */
537
+ (event: "subDirectoryDeleted", listener: (path: string, local: boolean, target: IEventThisPlaceHolder) => void): any;
538
+ }
539
+
540
+ /**
541
+ * The SharedMap distributed data structure can be used to store key-value pairs. It provides the same API for setting
542
+ * and retrieving values that JavaScript developers are accustomed to with the
543
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} built-in object.
544
+ * However, the keys of a SharedMap must be strings, and the values must either be a JSON-serializable object or a
545
+ * {@link @fluidframework/datastore#FluidObjectHandle}.
546
+ *
547
+ * For more information, including example usages, see {@link https://fluidframework.com/docs/data-structures/map/}.
548
+ *
549
+ * @public
550
+ */
551
+ export declare interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string, any> {
552
+ /**
553
+ * Retrieves the given key from the map if it exists.
554
+ * @param key - Key to retrieve from
555
+ * @returns The stored value, or undefined if the key is not set
556
+ */
557
+ get<T = any>(key: string): T | undefined;
558
+ /**
559
+ * Sets the value stored at key to the provided value.
560
+ * @param key - Key to set
561
+ * @param value - Value to set
562
+ * @returns The {@link ISharedMap} itself
563
+ */
564
+ set<T = unknown>(key: string, value: T): this;
565
+ }
566
+
567
+ /**
568
+ * Events emitted in response to changes to the {@link ISharedMap | map} data.
569
+ *
570
+ * @public
571
+ */
572
+ export declare interface ISharedMapEvents extends ISharedObjectEvents {
573
+ /**
574
+ * Emitted when a key is set or deleted.
575
+ *
576
+ * @remarks Listener parameters:
577
+ *
578
+ * - `changed` - Information on the key that changed and its value prior to the change.
579
+ *
580
+ * - `local` - Whether the change originated from this client.
581
+ *
582
+ * - `target` - The {@link ISharedMap} itself.
583
+ */
584
+ (event: "valueChanged", listener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void): any;
585
+ /**
586
+ * Emitted when the map is cleared.
587
+ *
588
+ * @remarks Listener parameters:
589
+ *
590
+ * - `local` - Whether the clear originated from this client.
591
+ *
592
+ * - `target` - The {@link ISharedMap} itself.
593
+ */
594
+ (event: "clear", listener: (local: boolean, target: IEventThisPlaceHolder) => void): any;
595
+ }
596
+
597
+ /**
598
+ * Type of "valueChanged" event parameter.
599
+ *
600
+ * @public
601
+ */
602
+ export declare interface IValueChanged {
603
+ /**
604
+ * The key storing the value that changed.
605
+ */
606
+ key: string;
607
+ /**
608
+ * The value that was stored at the key prior to the change.
609
+ */
610
+ previousValue: any;
611
+ }
612
+
613
+ /**
614
+ * Enables a container type {@link https://fluidframework.com/docs/build/dds/ | DDS} to produce and store local
615
+ * values with minimal awareness of how those objects are stored, serialized, and deserialized.
616
+ *
617
+ * @public
618
+ */
619
+ export declare class LocalValueMaker {
620
+ private readonly serializer;
621
+ /**
622
+ * Create a new LocalValueMaker.
623
+ * @param serializer - The serializer to serialize / parse handles.
624
+ */
625
+ constructor(serializer: IFluidSerializer);
626
+ /**
627
+ * Create a new local value from an incoming serialized value.
628
+ * @param serializable - The serializable value to make local
629
+ */
630
+ fromSerializable(serializable: ISerializableValue): ILocalValue;
631
+ /**
632
+ * Create a new local value containing a given plain object.
633
+ * @param value - The value to store
634
+ * @returns An ILocalValue containing the value
635
+ */
636
+ fromInMemory(value: unknown): ILocalValue;
637
+ }
638
+
639
+ /**
640
+ * {@link @fluidframework/datastore-definitions#IChannelFactory} for {@link SharedMap}.
641
+ *
642
+ * @sealed
643
+ * @public
644
+ */
645
+ export declare class MapFactory implements IChannelFactory {
646
+ /**
647
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
648
+ */
649
+ static readonly Type = "https://graph.microsoft.com/types/map";
650
+ /**
651
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
652
+ */
653
+ static readonly Attributes: IChannelAttributes;
654
+ /**
655
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
656
+ */
657
+ get type(): string;
658
+ /**
659
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
660
+ */
661
+ get attributes(): IChannelAttributes;
662
+ /**
663
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
664
+ */
665
+ load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<ISharedMap>;
666
+ /**
667
+ * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
668
+ */
669
+ create(runtime: IFluidDataStoreRuntime, id: string): ISharedMap;
670
+ }
671
+
672
+ /**
673
+ * {@inheritDoc ISharedDirectory}
674
+ *
675
+ * @example
676
+ *
677
+ * ```typescript
678
+ * mySharedDirectory.createSubDirectory("a").createSubDirectory("b").createSubDirectory("c").set("foo", val1);
679
+ * const mySubDir = mySharedDirectory.getWorkingDirectory("/a/b/c");
680
+ * mySubDir.get("foo"); // returns val1
681
+ * ```
682
+ *
683
+ * @sealed
684
+ * @public
685
+ */
686
+ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents> implements ISharedDirectory {
687
+ /**
688
+ * Create a new shared directory
689
+ *
690
+ * @param runtime - Data store runtime the new shared directory belongs to
691
+ * @param id - Optional name of the shared directory
692
+ * @returns Newly create shared directory (but not attached yet)
693
+ */
694
+ static create(runtime: IFluidDataStoreRuntime, id?: string): SharedDirectory;
695
+ /**
696
+ * Get a factory for SharedDirectory to register with the data store.
697
+ *
698
+ * @returns A factory that creates and load SharedDirectory
699
+ */
700
+ static getFactory(): IChannelFactory;
701
+ /**
702
+ * String representation for the class.
703
+ */
704
+ [Symbol.toStringTag]: string;
705
+ /**
706
+ * {@inheritDoc IDirectory.absolutePath}
707
+ */
708
+ get absolutePath(): string;
709
+ /* Excluded from this release type: localValueMaker */
710
+ /**
711
+ * Root of the SharedDirectory, most operations on the SharedDirectory itself act on the root.
712
+ */
713
+ private readonly root;
714
+ /**
715
+ * Mapping of op types to message handlers.
716
+ */
717
+ private readonly messageHandlers;
718
+ /**
719
+ * Constructs a new shared directory. If the object is non-local an id and service interfaces will
720
+ * be provided.
721
+ * @param id - String identifier for the SharedDirectory
722
+ * @param runtime - Data store runtime
723
+ * @param type - Type identifier
724
+ */
725
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
726
+ /**
727
+ * {@inheritDoc IDirectory.get}
728
+ */
729
+ get<T = any>(key: string): T | undefined;
730
+ /**
731
+ * {@inheritDoc IDirectory.set}
732
+ */
733
+ set<T = unknown>(key: string, value: T): this;
734
+ dispose(error?: Error): void;
735
+ get disposed(): boolean;
736
+ /**
737
+ * Deletes the given key from within this IDirectory.
738
+ * @param key - The key to delete
739
+ * @returns True if the key existed and was deleted, false if it did not exist
740
+ */
741
+ delete(key: string): boolean;
742
+ /**
743
+ * Deletes all keys from within this IDirectory.
744
+ */
745
+ clear(): void;
746
+ /**
747
+ * Checks whether the given key exists in this IDirectory.
748
+ * @param key - The key to check
749
+ * @returns True if the key exists, false otherwise
750
+ */
751
+ has(key: string): boolean;
752
+ /**
753
+ * The number of entries under this IDirectory.
754
+ */
755
+ get size(): number;
756
+ /**
757
+ * Issue a callback on each entry under this IDirectory.
758
+ * @param callback - Callback to issue
759
+ */
760
+ forEach(callback: (value: any, key: string, map: Map<string, any>) => void): void;
761
+ /**
762
+ * Get an iterator over the entries under this IDirectory.
763
+ * @returns The iterator
764
+ */
765
+ [Symbol.iterator](): IterableIterator<[string, any]>;
766
+ /**
767
+ * Get an iterator over the entries under this IDirectory.
768
+ * @returns The iterator
769
+ */
770
+ entries(): IterableIterator<[string, any]>;
771
+ /**
772
+ * {@inheritDoc IDirectory.countSubDirectory}
773
+ */
774
+ countSubDirectory(): number;
775
+ /**
776
+ * Get an iterator over the keys under this IDirectory.
777
+ * @returns The iterator
778
+ */
779
+ keys(): IterableIterator<string>;
780
+ /**
781
+ * Get an iterator over the values under this IDirectory.
782
+ * @returns The iterator
783
+ */
784
+ values(): IterableIterator<any>;
785
+ /**
786
+ * {@inheritDoc IDirectory.createSubDirectory}
787
+ */
788
+ createSubDirectory(subdirName: string): IDirectory;
789
+ /**
790
+ * {@inheritDoc IDirectory.getSubDirectory}
791
+ */
792
+ getSubDirectory(subdirName: string): IDirectory | undefined;
793
+ /**
794
+ * {@inheritDoc IDirectory.hasSubDirectory}
795
+ */
796
+ hasSubDirectory(subdirName: string): boolean;
797
+ /**
798
+ * {@inheritDoc IDirectory.deleteSubDirectory}
799
+ */
800
+ deleteSubDirectory(subdirName: string): boolean;
801
+ /**
802
+ * {@inheritDoc IDirectory.subdirectories}
803
+ */
804
+ subdirectories(): IterableIterator<[string, IDirectory]>;
805
+ /**
806
+ * {@inheritDoc IDirectory.getWorkingDirectory}
807
+ */
808
+ getWorkingDirectory(relativePath: string): IDirectory | undefined;
809
+ /* Excluded from this release type: summarizeCore */
810
+ /* Excluded from this release type: submitDirectoryMessage */
811
+ /* Excluded from this release type: onDisconnect */
812
+ /* Excluded from this release type: reSubmitCore */
813
+ /* Excluded from this release type: loadCore */
814
+ /* Excluded from this release type: populate */
815
+ /* Excluded from this release type: processCore */
816
+ /* Excluded from this release type: rollback */
817
+ /**
818
+ * Converts the given relative path to absolute against the root.
819
+ * @param relativePath - The path to convert
820
+ */
821
+ private makeAbsolute;
822
+ /**
823
+ * The remote ISerializableValue we're receiving (either as a result of a snapshot load or an incoming set op)
824
+ * will have the information we need to create a real object, but will not be the real object yet. For example,
825
+ * we might know it's a map and the ID but not have the actual map or its data yet. makeLocal's job
826
+ * is to convert that information into a real object for local usage.
827
+ * @param key - Key of element being converted
828
+ * @param absolutePath - Path of element being converted
829
+ * @param serializable - The remote information that we can convert into a real object
830
+ * @returns The local value that was produced
831
+ */
832
+ private makeLocal;
833
+ /**
834
+ * This checks if there is pending delete op for local delete for a any subdir in the relative path.
835
+ * @param relativePath - path of sub directory.
836
+ * @returns `true` if there is pending delete, `false` otherwise.
837
+ */
838
+ private isSubDirectoryDeletePending;
839
+ /**
840
+ * Set the message handlers for the directory.
841
+ */
842
+ private setMessageHandlers;
843
+ /* Excluded from this release type: applyStashedOp */
844
+ private serializeDirectory;
845
+ }
846
+
847
+ /**
848
+ * {@inheritDoc ISharedMap}
849
+ *
850
+ * @public
851
+ */
852
+ export declare class SharedMap extends SharedObject<ISharedMapEvents> implements ISharedMap {
853
+ /**
854
+ * Create a new shared map.
855
+ * @param runtime - The data store runtime that the new shared map belongs to.
856
+ * @param id - Optional name of the shared map.
857
+ * @returns Newly created shared map.
858
+ *
859
+ * @example
860
+ * To create a `SharedMap`, call the static create method:
861
+ *
862
+ * ```typescript
863
+ * const myMap = SharedMap.create(this.runtime, id);
864
+ * ```
865
+ */
866
+ static create(runtime: IFluidDataStoreRuntime, id?: string): SharedMap;
867
+ /**
868
+ * Get a factory for SharedMap to register with the data store.
869
+ * @returns A factory that creates SharedMaps and loads them from storage.
870
+ */
871
+ static getFactory(): IChannelFactory;
872
+ /**
873
+ * String representation for the class.
874
+ */
875
+ readonly [Symbol.toStringTag]: string;
876
+ /**
877
+ * MapKernel which manages actual map operations.
878
+ */
879
+ private readonly kernel;
880
+ /**
881
+ * Do not call the constructor. Instead, you should use the {@link SharedMap.create | create method}.
882
+ *
883
+ * @param id - String identifier.
884
+ * @param runtime - Data store runtime.
885
+ * @param attributes - The attributes for the map.
886
+ */
887
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
888
+ /**
889
+ * Get an iterator over the keys in this map.
890
+ * @returns The iterator
891
+ */
892
+ keys(): IterableIterator<string>;
893
+ /**
894
+ * Get an iterator over the entries in this map.
895
+ * @returns The iterator
896
+ */
897
+ entries(): IterableIterator<[string, any]>;
898
+ /**
899
+ * Get an iterator over the values in this map.
900
+ * @returns The iterator
901
+ */
902
+ values(): IterableIterator<any>;
903
+ /**
904
+ * Get an iterator over the entries in this map.
905
+ * @returns The iterator
906
+ */
907
+ [Symbol.iterator](): IterableIterator<[string, any]>;
908
+ /**
909
+ * The number of key/value pairs stored in the map.
910
+ */
911
+ get size(): number;
912
+ /**
913
+ * Executes the given callback on each entry in the map.
914
+ * @param callbackFn - Callback function
915
+ */
916
+ forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void;
917
+ /**
918
+ * {@inheritDoc ISharedMap.get}
919
+ */
920
+ get<T = any>(key: string): T | undefined;
921
+ /**
922
+ * Check if a key exists in the map.
923
+ * @param key - The key to check
924
+ * @returns True if the key exists, false otherwise
925
+ */
926
+ has(key: string): boolean;
927
+ /**
928
+ * {@inheritDoc ISharedMap.set}
929
+ */
930
+ set(key: string, value: unknown): this;
931
+ /**
932
+ * Delete a key from the map.
933
+ * @param key - Key to delete
934
+ * @returns True if the key existed and was deleted, false if it did not exist
935
+ */
936
+ delete(key: string): boolean;
937
+ /**
938
+ * Clear all data from the map.
939
+ */
940
+ clear(): void;
941
+ /* Excluded from this release type: summarizeCore */
942
+ /* Excluded from this release type: loadCore */
943
+ /* Excluded from this release type: onDisconnect */
944
+ /* Excluded from this release type: reSubmitCore */
945
+ /* Excluded from this release type: applyStashedOp */
946
+ /* Excluded from this release type: processCore */
947
+ /* Excluded from this release type: rollback */
948
+ }
949
+
950
+ export { }