@fluidframework/map 2.0.0-internal.7.2.2 → 2.0.0-internal.7.4.0

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