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