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