document-drive 4.0.1 → 4.1.0-dev.2
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/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/prisma/schema.prisma +1 -2
- package/dist/src/drive-document-model/gen/document-model.js +3 -3
- package/dist/src/drive-document-model/gen/document-model.js.map +1 -1
- package/dist/src/drive-document-model/gen/drive/actions.d.ts +9 -9
- package/dist/src/drive-document-model/gen/drive/actions.d.ts.map +1 -1
- package/dist/src/drive-document-model/gen/node/actions.d.ts +8 -8
- package/dist/src/drive-document-model/gen/node/actions.d.ts.map +1 -1
- package/dist/src/drive-document-model/gen/node/creators.d.ts +6 -2
- package/dist/src/drive-document-model/gen/node/creators.d.ts.map +1 -1
- package/dist/src/drive-document-model/gen/node/creators.js +8 -1
- package/dist/src/drive-document-model/gen/node/creators.js.map +1 -1
- package/dist/src/drive-document-model/gen/reducer.d.ts.map +1 -1
- package/dist/src/drive-document-model/gen/reducer.js.map +1 -1
- package/dist/src/drive-document-model/gen/schema/types.d.ts +1 -14
- package/dist/src/drive-document-model/gen/schema/types.d.ts.map +1 -1
- package/dist/src/drive-document-model/gen/schema/zod.d.ts +1 -5
- package/dist/src/drive-document-model/gen/schema/zod.d.ts.map +1 -1
- package/dist/src/drive-document-model/gen/schema/zod.js +0 -12
- package/dist/src/drive-document-model/gen/schema/zod.js.map +1 -1
- package/dist/src/drive-document-model/gen/types.d.ts +13 -4
- package/dist/src/drive-document-model/gen/types.d.ts.map +1 -1
- package/dist/src/drive-document-model/gen/types.js.map +1 -1
- package/dist/src/drive-document-model/module.d.ts +2 -1
- package/dist/src/drive-document-model/module.d.ts.map +1 -1
- package/dist/src/drive-document-model/src/reducers/node.d.ts.map +1 -1
- package/dist/src/drive-document-model/src/reducers/node.js +1 -25
- package/dist/src/drive-document-model/src/reducers/node.js.map +1 -1
- package/dist/src/drive-document-model/src/tests/actions.test.js +1 -23
- package/dist/src/drive-document-model/src/tests/actions.test.js.map +1 -1
- package/dist/src/drive-document-model/src/tests/base.test.js +0 -32
- package/dist/src/drive-document-model/src/tests/base.test.js.map +1 -1
- package/dist/src/drive-document-model/src/tests/utils.test.js +7 -37
- package/dist/src/drive-document-model/src/tests/utils.test.js.map +1 -1
- package/dist/src/drive-document-model/src/utils.d.ts +2 -8
- package/dist/src/drive-document-model/src/utils.d.ts.map +1 -1
- package/dist/src/drive-document-model/src/utils.js +6 -55
- package/dist/src/drive-document-model/src/utils.js.map +1 -1
- package/dist/src/processors/types.d.ts +2 -1
- package/dist/src/processors/types.d.ts.map +1 -1
- package/dist/src/queue/base.d.ts +6 -27
- package/dist/src/queue/base.d.ts.map +1 -1
- package/dist/src/queue/base.js +15 -203
- package/dist/src/queue/base.js.map +1 -1
- package/dist/src/queue/event.d.ts +41 -0
- package/dist/src/queue/event.d.ts.map +1 -0
- package/dist/src/queue/event.js +222 -0
- package/dist/src/queue/event.js.map +1 -0
- package/dist/src/queue/redis.d.ts +1 -27
- package/dist/src/queue/redis.d.ts.map +1 -1
- package/dist/src/queue/redis.js +122 -110
- package/dist/src/queue/redis.js.map +1 -1
- package/dist/src/queue/types.d.ts +18 -12
- package/dist/src/queue/types.d.ts.map +1 -1
- package/dist/src/queue/types.js +3 -0
- package/dist/src/queue/types.js.map +1 -1
- package/dist/src/server/base-server.d.ts +87 -11
- package/dist/src/server/base-server.d.ts.map +1 -1
- package/dist/src/server/base-server.js +549 -250
- package/dist/src/server/base-server.js.map +1 -1
- package/dist/src/server/builder.js +2 -2
- package/dist/src/server/builder.js.map +1 -1
- package/dist/src/server/error.d.ts +3 -3
- package/dist/src/server/error.d.ts.map +1 -1
- package/dist/src/server/error.js +2 -2
- package/dist/src/server/error.js.map +1 -1
- package/dist/src/server/listener/listener-manager.d.ts +5 -6
- package/dist/src/server/listener/listener-manager.d.ts.map +1 -1
- package/dist/src/server/listener/listener-manager.js +62 -79
- package/dist/src/server/listener/listener-manager.js.map +1 -1
- package/dist/src/server/listener/transmitter/internal.d.ts +3 -3
- package/dist/src/server/listener/transmitter/internal.d.ts.map +1 -1
- package/dist/src/server/listener/transmitter/internal.js +18 -13
- package/dist/src/server/listener/transmitter/internal.js.map +1 -1
- package/dist/src/server/listener/transmitter/pull-responder.d.ts.map +1 -1
- package/dist/src/server/listener/transmitter/pull-responder.js +14 -8
- package/dist/src/server/listener/transmitter/pull-responder.js.map +1 -1
- package/dist/src/server/listener/transmitter/switchboard-push.d.ts.map +1 -1
- package/dist/src/server/listener/transmitter/switchboard-push.js +13 -8
- package/dist/src/server/listener/transmitter/switchboard-push.js.map +1 -1
- package/dist/src/server/sync-manager.d.ts +8 -10
- package/dist/src/server/sync-manager.d.ts.map +1 -1
- package/dist/src/server/sync-manager.js +62 -147
- package/dist/src/server/sync-manager.js.map +1 -1
- package/dist/src/server/sync-unit-map.d.ts +137 -0
- package/dist/src/server/sync-unit-map.d.ts.map +1 -0
- package/dist/src/server/sync-unit-map.js +234 -0
- package/dist/src/server/sync-unit-map.js.map +1 -0
- package/dist/src/server/types.d.ts +116 -33
- package/dist/src/server/types.d.ts.map +1 -1
- package/dist/src/server/types.js.map +1 -1
- package/dist/src/server/utils.d.ts +10 -1
- package/dist/src/server/utils.d.ts.map +1 -1
- package/dist/src/server/utils.js +44 -1
- package/dist/src/server/utils.js.map +1 -1
- package/dist/src/storage/browser.d.ts +7 -2
- package/dist/src/storage/browser.d.ts.map +1 -1
- package/dist/src/storage/browser.js +80 -22
- package/dist/src/storage/browser.js.map +1 -1
- package/dist/src/storage/filesystem.d.ts +7 -2
- package/dist/src/storage/filesystem.d.ts.map +1 -1
- package/dist/src/storage/filesystem.js +79 -22
- package/dist/src/storage/filesystem.js.map +1 -1
- package/dist/src/storage/memory.d.ts +7 -2
- package/dist/src/storage/memory.d.ts.map +1 -1
- package/dist/src/storage/memory.js +76 -22
- package/dist/src/storage/memory.js.map +1 -1
- package/dist/src/storage/prisma/client/edge.js +5 -4
- package/dist/src/storage/prisma/client/index-browser.js +2 -1
- package/dist/src/storage/prisma/client/index.d.ts +58 -249
- package/dist/src/storage/prisma/client/index.js +5 -4
- package/dist/src/storage/prisma/client/package.json +1 -1
- package/dist/src/storage/prisma/client/schema.prisma +2 -3
- package/dist/src/storage/prisma/client/wasm.js +2 -1
- package/dist/src/storage/prisma/prisma.d.ts +9 -4
- package/dist/src/storage/prisma/prisma.d.ts.map +1 -1
- package/dist/src/storage/prisma/prisma.js +119 -51
- package/dist/src/storage/prisma/prisma.js.map +1 -1
- package/dist/src/storage/types.d.ts +43 -4
- package/dist/src/storage/types.d.ts.map +1 -1
- package/dist/src/storage/utils.d.ts +3 -0
- package/dist/src/storage/utils.d.ts.map +1 -1
- package/dist/src/storage/utils.js +14 -0
- package/dist/src/storage/utils.js.map +1 -1
- package/dist/src/utils/gql-transformations.d.ts +14 -5
- package/dist/src/utils/gql-transformations.d.ts.map +1 -1
- package/dist/src/utils/gql-transformations.js +1 -0
- package/dist/src/utils/gql-transformations.js.map +1 -1
- package/dist/src/utils/migrations.d.ts.map +1 -1
- package/dist/src/utils/migrations.js.map +1 -1
- package/dist/src/utils/misc.d.ts +2 -0
- package/dist/src/utils/misc.d.ts.map +1 -1
- package/dist/src/utils/misc.js +4 -0
- package/dist/src/utils/misc.js.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +4 -4
- package/dist/test/cache.test.d.ts +0 -2
- package/dist/test/cache.test.d.ts.map +0 -1
- package/dist/test/cache.test.js +0 -281
- package/dist/test/cache.test.js.map +0 -1
- package/dist/test/default-remote-drives.test.d.ts +0 -2
- package/dist/test/default-remote-drives.test.d.ts.map +0 -1
- package/dist/test/default-remote-drives.test.js +0 -446
- package/dist/test/default-remote-drives.test.js.map +0 -1
- package/dist/test/document-helpers/addUndo.test.d.ts +0 -2
- package/dist/test/document-helpers/addUndo.test.d.ts.map +0 -1
- package/dist/test/document-helpers/addUndo.test.js +0 -120
- package/dist/test/document-helpers/addUndo.test.js.map +0 -1
- package/dist/test/document-helpers/attachBranch.test.d.ts +0 -2
- package/dist/test/document-helpers/attachBranch.test.d.ts.map +0 -1
- package/dist/test/document-helpers/attachBranch.test.js +0 -333
- package/dist/test/document-helpers/attachBranch.test.js.map +0 -1
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts +0 -2
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts.map +0 -1
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.js +0 -252
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.js.map +0 -1
- package/dist/test/document-helpers/garbageCollect.test.d.ts +0 -2
- package/dist/test/document-helpers/garbageCollect.test.d.ts.map +0 -1
- package/dist/test/document-helpers/garbageCollect.test.js +0 -136
- package/dist/test/document-helpers/garbageCollect.test.js.map +0 -1
- package/dist/test/document-helpers/groupOperationsByScope.test.d.ts +0 -2
- package/dist/test/document-helpers/groupOperationsByScope.test.d.ts.map +0 -1
- package/dist/test/document-helpers/groupOperationsByScope.test.js +0 -98
- package/dist/test/document-helpers/groupOperationsByScope.test.js.map +0 -1
- package/dist/test/document-helpers/merge.test.d.ts +0 -2
- package/dist/test/document-helpers/merge.test.d.ts.map +0 -1
- package/dist/test/document-helpers/merge.test.js +0 -757
- package/dist/test/document-helpers/merge.test.js.map +0 -1
- package/dist/test/document-helpers/nextSkipNumber.test.d.ts +0 -2
- package/dist/test/document-helpers/nextSkipNumber.test.d.ts.map +0 -1
- package/dist/test/document-helpers/nextSkipNumber.test.js +0 -123
- package/dist/test/document-helpers/nextSkipNumber.test.js.map +0 -1
- package/dist/test/document-helpers/prepareOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/prepareOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/prepareOperations.test.js +0 -304
- package/dist/test/document-helpers/prepareOperations.test.js.map +0 -1
- package/dist/test/document-helpers/removeExistingOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/removeExistingOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/removeExistingOperations.test.js +0 -150
- package/dist/test/document-helpers/removeExistingOperations.test.js.map +0 -1
- package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts +0 -2
- package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts.map +0 -1
- package/dist/test/document-helpers/reshuffleByTimestamp.test.js +0 -148
- package/dist/test/document-helpers/reshuffleByTimestamp.test.js.map +0 -1
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts +0 -2
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts.map +0 -1
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.js +0 -200
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.js.map +0 -1
- package/dist/test/document-helpers/sortOperations.test.d.ts +0 -2
- package/dist/test/document-helpers/sortOperations.test.d.ts.map +0 -1
- package/dist/test/document-helpers/sortOperations.test.js +0 -101
- package/dist/test/document-helpers/sortOperations.test.js.map +0 -1
- package/dist/test/document-helpers/split.test.d.ts +0 -2
- package/dist/test/document-helpers/split.test.d.ts.map +0 -1
- package/dist/test/document-helpers/split.test.js +0 -121
- package/dist/test/document-helpers/split.test.js.map +0 -1
- package/dist/test/document-helpers/utils.d.ts +0 -8
- package/dist/test/document-helpers/utils.d.ts.map +0 -1
- package/dist/test/document-helpers/utils.js +0 -22
- package/dist/test/document-helpers/utils.js.map +0 -1
- package/dist/test/drive-operations.test.d.ts +0 -2
- package/dist/test/drive-operations.test.d.ts.map +0 -1
- package/dist/test/drive-operations.test.js +0 -145
- package/dist/test/drive-operations.test.js.map +0 -1
- package/dist/test/graphql.test.d.ts +0 -2
- package/dist/test/graphql.test.d.ts.map +0 -1
- package/dist/test/graphql.test.js +0 -10
- package/dist/test/graphql.test.js.map +0 -1
- package/dist/test/internal-listener.test.d.ts +0 -2
- package/dist/test/internal-listener.test.d.ts.map +0 -1
- package/dist/test/internal-listener.test.js +0 -277
- package/dist/test/internal-listener.test.js.map +0 -1
- package/dist/test/queue.test.d.ts +0 -2
- package/dist/test/queue.test.d.ts.map +0 -1
- package/dist/test/queue.test.js +0 -338
- package/dist/test/queue.test.js.map +0 -1
- package/dist/test/read-mode.test.d.ts +0 -2
- package/dist/test/read-mode.test.d.ts.map +0 -1
- package/dist/test/read-mode.test.js +0 -578
- package/dist/test/read-mode.test.js.map +0 -1
- package/dist/test/server/driveOperationsConflictResolution.test.d.ts +0 -2
- package/dist/test/server/driveOperationsConflictResolution.test.d.ts.map +0 -1
- package/dist/test/server/driveOperationsConflictResolution.test.js +0 -460
- package/dist/test/server/driveOperationsConflictResolution.test.js.map +0 -1
- package/dist/test/server/mergeOperations.test.d.ts +0 -2
- package/dist/test/server/mergeOperations.test.d.ts.map +0 -1
- package/dist/test/server/mergeOperations.test.js +0 -107
- package/dist/test/server/mergeOperations.test.js.map +0 -1
- package/dist/test/server/processOperations.test.d.ts +0 -2
- package/dist/test/server/processOperations.test.d.ts.map +0 -1
- package/dist/test/server/processOperations.test.js +0 -380
- package/dist/test/server/processOperations.test.js.map +0 -1
- package/dist/test/server.test.d.ts +0 -2
- package/dist/test/server.test.d.ts.map +0 -1
- package/dist/test/server.test.js +0 -899
- package/dist/test/server.test.js.map +0 -1
- package/dist/test/signature-migration.test.d.ts +0 -2
- package/dist/test/signature-migration.test.d.ts.map +0 -1
- package/dist/test/signature-migration.test.js +0 -239
- package/dist/test/signature-migration.test.js.map +0 -1
- package/dist/test/storage.test.d.ts +0 -2
- package/dist/test/storage.test.d.ts.map +0 -1
- package/dist/test/storage.test.js +0 -523
- package/dist/test/storage.test.js.map +0 -1
- package/dist/test/utils.d.ts +0 -48
- package/dist/test/utils.d.ts.map +0 -1
- package/dist/test/utils.js +0 -133
- package/dist/test/utils.js.map +0 -1
- package/dist/test/utils.test.d.ts +0 -2
- package/dist/test/utils.test.d.ts.map +0 -1
- package/dist/test/utils.test.js +0 -89
- package/dist/test/utils.test.js.map +0 -1
- package/dist/test/vitest-setup.d.ts +0 -2
- package/dist/test/vitest-setup.d.ts.map +0 -1
- package/dist/test/vitest-setup.js +0 -5
- package/dist/test/vitest-setup.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -27
- package/dist/vitest.config.js.map +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { type SynchronizationUnitId } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for a specialized Map implementation that manages synchronization units.
|
|
4
|
+
* Each unit is identified by a SynchronizationUnitId which consists of documentId, scope, and branch.
|
|
5
|
+
*/
|
|
6
|
+
export interface ISyncUnitMap<Value> {
|
|
7
|
+
set(id: SynchronizationUnitId, state: Value): this;
|
|
8
|
+
get(id: SynchronizationUnitId): Value | undefined;
|
|
9
|
+
has(id: SynchronizationUnitId): boolean;
|
|
10
|
+
delete(id: SynchronizationUnitId): boolean;
|
|
11
|
+
clear(): void;
|
|
12
|
+
get size(): number;
|
|
13
|
+
keys(): IterableIterator<SynchronizationUnitId>;
|
|
14
|
+
values(): IterableIterator<Value>;
|
|
15
|
+
entries(): IterableIterator<[SynchronizationUnitId, Value]>;
|
|
16
|
+
[Symbol.iterator](): IterableIterator<[SynchronizationUnitId, Value]>;
|
|
17
|
+
forEach(callbackfn: (value: Value, key: SynchronizationUnitId, map: ISyncUnitMap<Value>) => void, thisArg?: any): void;
|
|
18
|
+
deleteByDocumentId(documentId: string): void;
|
|
19
|
+
deleteByDocumentIdAndScope(documentId: string, scope: string): void;
|
|
20
|
+
getAllByDocumentId(documentId: string): [SynchronizationUnitId, Value][];
|
|
21
|
+
getAllByDocumentIdAndScope(documentId: string, scope: string): [SynchronizationUnitId, Value][];
|
|
22
|
+
}
|
|
23
|
+
/** Separator character used to join synchronization unit key parts */
|
|
24
|
+
type SyncUnitKeySeparator = "|";
|
|
25
|
+
/**
|
|
26
|
+
* Internal key format used to store synchronization units.
|
|
27
|
+
* Composed of documentId, scope, and branch joined by the separator.
|
|
28
|
+
*/
|
|
29
|
+
type SyncUnitKey = `${SynchronizationUnitId["documentId"]}${SyncUnitKeySeparator}${SynchronizationUnitId["scope"]}${SyncUnitKeySeparator}${SynchronizationUnitId["branch"]}`;
|
|
30
|
+
/**
|
|
31
|
+
* A specialized Map implementation for managing synchronization units that uses a "documentId - scope - branch" tuple as key.
|
|
32
|
+
* It provides methods to store, retrieve, and delete synchronization units of a certain documentId, optionally a scope and a branch.
|
|
33
|
+
* The implementation uses an internal Map with string keys created by combining documentId, scope, and branch with a separator character.
|
|
34
|
+
*/
|
|
35
|
+
export declare class SyncUnitMap<Value> implements ISyncUnitMap<Value> {
|
|
36
|
+
/** Internal storage using concatenated string keys */
|
|
37
|
+
private internalMap;
|
|
38
|
+
/** Character used to separate key components */
|
|
39
|
+
static keySeparator: SyncUnitKeySeparator;
|
|
40
|
+
/**
|
|
41
|
+
* Escapes the separator character in a string by prefixing it with a backslash
|
|
42
|
+
* @param str String to escape
|
|
43
|
+
*/
|
|
44
|
+
private static escape;
|
|
45
|
+
/**
|
|
46
|
+
* Unescapes the separator character in a string by removing the prefix backslash
|
|
47
|
+
* @param str String to unescape
|
|
48
|
+
*/
|
|
49
|
+
private static unescape;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a composite key from a SynchronizationUnitId
|
|
52
|
+
* Escapes any separator characters in the components
|
|
53
|
+
* @param id The synchronization unit identifier
|
|
54
|
+
* @returns A string key combining documentId, scope, and branch
|
|
55
|
+
*/
|
|
56
|
+
static buildKey(id: SynchronizationUnitId): SyncUnitKey;
|
|
57
|
+
/**
|
|
58
|
+
* Parses a composite key back into a SynchronizationUnitId
|
|
59
|
+
* Unescapes any separator characters in the components
|
|
60
|
+
* @param key The composite key string
|
|
61
|
+
* @returns The parsed synchronization unit identifier
|
|
62
|
+
*/
|
|
63
|
+
static parseKey(key: SyncUnitKey): SynchronizationUnitId;
|
|
64
|
+
/**
|
|
65
|
+
* Stores a value with the given synchronization unit identifier
|
|
66
|
+
* @throws Error if any part of the id contains the separator character
|
|
67
|
+
*/
|
|
68
|
+
set(id: SynchronizationUnitId, state: Value): this;
|
|
69
|
+
/** Retrieves a value by its synchronization unit identifier */
|
|
70
|
+
get(id: SynchronizationUnitId): Value | undefined;
|
|
71
|
+
/** Checks if a value exists for the given synchronization unit identifier */
|
|
72
|
+
has(id: SynchronizationUnitId): boolean;
|
|
73
|
+
/** Removes a value by its synchronization unit identifier */
|
|
74
|
+
delete(id: SynchronizationUnitId): boolean;
|
|
75
|
+
/** Removes all entries from the map */
|
|
76
|
+
clear(): void;
|
|
77
|
+
/** Returns the number of entries in the map */
|
|
78
|
+
get size(): number;
|
|
79
|
+
/**
|
|
80
|
+
* Returns an iterator of synchronization unit identifiers
|
|
81
|
+
* @param filter Optional filter by documentId and scope
|
|
82
|
+
*/
|
|
83
|
+
keys(filter?: {
|
|
84
|
+
documentId: string;
|
|
85
|
+
scope?: string;
|
|
86
|
+
} | undefined): IterableIterator<SynchronizationUnitId>;
|
|
87
|
+
/**
|
|
88
|
+
* Returns an iterator of stored values
|
|
89
|
+
* @param filter Optional filter by documentId and scope
|
|
90
|
+
*/
|
|
91
|
+
values(filter?: {
|
|
92
|
+
documentId: string;
|
|
93
|
+
scope?: string;
|
|
94
|
+
} | undefined): IterableIterator<Value>;
|
|
95
|
+
/**
|
|
96
|
+
* Returns an iterator of [id, value] pairs
|
|
97
|
+
* @param filter Optional filter by documentId and scope
|
|
98
|
+
*/
|
|
99
|
+
entries(filter?: {
|
|
100
|
+
documentId: string;
|
|
101
|
+
scope?: string;
|
|
102
|
+
} | undefined): IterableIterator<[SynchronizationUnitId, Value]>;
|
|
103
|
+
/** Makes the map iterable */
|
|
104
|
+
[Symbol.iterator](): IterableIterator<[SynchronizationUnitId, Value]>;
|
|
105
|
+
/**
|
|
106
|
+
* Executes a callback for each entry in the map
|
|
107
|
+
* @param callbackfn Function to execute for each entry
|
|
108
|
+
* @param thisArg Value to use as 'this' in the callback
|
|
109
|
+
*/
|
|
110
|
+
forEach(callbackfn: (value: Value, key: SynchronizationUnitId, map: ISyncUnitMap<Value>) => void, thisArg?: any): void;
|
|
111
|
+
/**
|
|
112
|
+
* Removes all entries associated with a specific document
|
|
113
|
+
* @param documentId The document identifier
|
|
114
|
+
*/
|
|
115
|
+
deleteByDocumentId(documentId: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* Removes all entries for a specific document and scope combination
|
|
118
|
+
* @param documentId The document identifier
|
|
119
|
+
* @param scope The scope identifier
|
|
120
|
+
*/
|
|
121
|
+
deleteByDocumentIdAndScope(documentId: string, scope: string): void;
|
|
122
|
+
/**
|
|
123
|
+
* Retrieves all entries associated with a specific document
|
|
124
|
+
* @param documentId The document identifier
|
|
125
|
+
* @returns Array of [id, value] pairs
|
|
126
|
+
*/
|
|
127
|
+
getAllByDocumentId(documentId: string): [SynchronizationUnitId, Value][];
|
|
128
|
+
/**
|
|
129
|
+
* Retrieves all entries for a specific document and scope combination
|
|
130
|
+
* @param documentId The document identifier
|
|
131
|
+
* @param scope The scope identifier
|
|
132
|
+
* @returns Array of [id, value] pairs
|
|
133
|
+
*/
|
|
134
|
+
getAllByDocumentIdAndScope(documentId: string, scope: string): [SynchronizationUnitId, Value][];
|
|
135
|
+
}
|
|
136
|
+
export {};
|
|
137
|
+
//# sourceMappingURL=sync-unit-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-unit-map.d.ts","sourceRoot":"","sources":["../../../src/server/sync-unit-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,YAAY,CAAC,KAAK;IACjC,GAAG,CAAC,EAAE,EAAE,qBAAqB,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACnD,GAAG,CAAC,EAAE,EAAE,qBA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O,CACL,MAAM,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,GAC1D,gBAAgB,CAAC,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;IA0BnD,6BAA6B;IAC7B,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIjB;;;;OAIG;IACH,OAAO,CACL,UAAU,EAAE,CACV,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,qBAAqB,EAC1B,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,KACrB,IAAI,EACT,OAAO,CAAC,EAAE,GAAG,GACZ,IAAI;IAQP;;;OAGG;IACH,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQ5C;;;;OAIG;IACH,0BAA0B,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IASnE;;;;OAIG;IACH,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,qBAAqB,EAAE,KAAK,CAAC,EAAE;IAUxE;;;;;OAKG;IACH,0BAA0B,CACxB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,CAAC,qBAAqB,EAAE,KAAK,CAAC,EAAE;CAUpC"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A specialized Map implementation for managing synchronization units that uses a "documentId - scope - branch" tuple as key.
|
|
3
|
+
* It provides methods to store, retrieve, and delete synchronization units of a certain documentId, optionally a scope and a branch.
|
|
4
|
+
* The implementation uses an internal Map with string keys created by combining documentId, scope, and branch with a separator character.
|
|
5
|
+
*/
|
|
6
|
+
export class SyncUnitMap {
|
|
7
|
+
/** Internal storage using concatenated string keys */
|
|
8
|
+
internalMap = new Map();
|
|
9
|
+
/** Character used to separate key components */
|
|
10
|
+
static keySeparator = "|";
|
|
11
|
+
/**
|
|
12
|
+
* Escapes the separator character in a string by prefixing it with a backslash
|
|
13
|
+
* @param str String to escape
|
|
14
|
+
*/
|
|
15
|
+
static escape(str) {
|
|
16
|
+
return str.replace(/\|/g, "\\|");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Unescapes the separator character in a string by removing the prefix backslash
|
|
20
|
+
* @param str String to unescape
|
|
21
|
+
*/
|
|
22
|
+
static unescape(str) {
|
|
23
|
+
return str.replace(/\\\|/g, "|");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a composite key from a SynchronizationUnitId
|
|
27
|
+
* Escapes any separator characters in the components
|
|
28
|
+
* @param id The synchronization unit identifier
|
|
29
|
+
* @returns A string key combining documentId, scope, and branch
|
|
30
|
+
*/
|
|
31
|
+
static buildKey(id) {
|
|
32
|
+
return `${SyncUnitMap.escape(id.documentId)}${SyncUnitMap.keySeparator}${SyncUnitMap.escape(id.scope)}${SyncUnitMap.keySeparator}${SyncUnitMap.escape(id.branch)}`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parses a composite key back into a SynchronizationUnitId
|
|
36
|
+
* Unescapes any separator characters in the components
|
|
37
|
+
* @param key The composite key string
|
|
38
|
+
* @returns The parsed synchronization unit identifier
|
|
39
|
+
*/
|
|
40
|
+
static parseKey(key) {
|
|
41
|
+
const parts = key
|
|
42
|
+
.split(/(?<!\\)\|/)
|
|
43
|
+
.map((part) => SyncUnitMap.unescape(part));
|
|
44
|
+
const [documentId, scope, branch] = parts;
|
|
45
|
+
return { documentId, scope, branch };
|
|
46
|
+
}
|
|
47
|
+
// Map API implementation
|
|
48
|
+
/**
|
|
49
|
+
* Stores a value with the given synchronization unit identifier
|
|
50
|
+
* @throws Error if any part of the id contains the separator character
|
|
51
|
+
*/
|
|
52
|
+
set(id, state) {
|
|
53
|
+
this.internalMap.set(SyncUnitMap.buildKey(id), state);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
/** Retrieves a value by its synchronization unit identifier */
|
|
57
|
+
get(id) {
|
|
58
|
+
return this.internalMap.get(SyncUnitMap.buildKey(id));
|
|
59
|
+
}
|
|
60
|
+
/** Checks if a value exists for the given synchronization unit identifier */
|
|
61
|
+
has(id) {
|
|
62
|
+
return this.internalMap.has(SyncUnitMap.buildKey(id));
|
|
63
|
+
}
|
|
64
|
+
/** Removes a value by its synchronization unit identifier */
|
|
65
|
+
delete(id) {
|
|
66
|
+
return this.internalMap.delete(SyncUnitMap.buildKey(id));
|
|
67
|
+
}
|
|
68
|
+
/** Removes all entries from the map */
|
|
69
|
+
clear() {
|
|
70
|
+
this.internalMap.clear();
|
|
71
|
+
}
|
|
72
|
+
/** Returns the number of entries in the map */
|
|
73
|
+
get size() {
|
|
74
|
+
return this.internalMap.size;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns an iterator of synchronization unit identifiers
|
|
78
|
+
* @param filter Optional filter by documentId and scope
|
|
79
|
+
*/
|
|
80
|
+
keys(filter) {
|
|
81
|
+
const iter = this.internalMap.keys();
|
|
82
|
+
return {
|
|
83
|
+
[Symbol.iterator]() {
|
|
84
|
+
return this;
|
|
85
|
+
},
|
|
86
|
+
next() {
|
|
87
|
+
while (true) {
|
|
88
|
+
const result = iter.next();
|
|
89
|
+
if (result.done)
|
|
90
|
+
return { done: true, value: undefined };
|
|
91
|
+
const key = result.value;
|
|
92
|
+
const id = SyncUnitMap.parseKey(key);
|
|
93
|
+
if (filter) {
|
|
94
|
+
if (id.documentId !== filter.documentId)
|
|
95
|
+
continue;
|
|
96
|
+
if (filter.scope !== undefined && id.scope !== filter.scope)
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
return { done: false, value: id };
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Returns an iterator of stored values
|
|
106
|
+
* @param filter Optional filter by documentId and scope
|
|
107
|
+
*/
|
|
108
|
+
values(filter) {
|
|
109
|
+
const iter = this.internalMap.entries();
|
|
110
|
+
return {
|
|
111
|
+
[Symbol.iterator]() {
|
|
112
|
+
return this;
|
|
113
|
+
},
|
|
114
|
+
next() {
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
116
|
+
while (true) {
|
|
117
|
+
const result = iter.next();
|
|
118
|
+
if (result.done)
|
|
119
|
+
return { done: true, value: undefined };
|
|
120
|
+
const [key, value] = result.value;
|
|
121
|
+
const id = SyncUnitMap.parseKey(key);
|
|
122
|
+
if (filter) {
|
|
123
|
+
if (id.documentId !== filter.documentId)
|
|
124
|
+
continue;
|
|
125
|
+
if (filter.scope !== undefined && id.scope !== filter.scope)
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
return { done: false, value };
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns an iterator of [id, value] pairs
|
|
135
|
+
* @param filter Optional filter by documentId and scope
|
|
136
|
+
*/
|
|
137
|
+
entries(filter) {
|
|
138
|
+
const iter = this.internalMap.entries();
|
|
139
|
+
return {
|
|
140
|
+
[Symbol.iterator]() {
|
|
141
|
+
return this;
|
|
142
|
+
},
|
|
143
|
+
next() {
|
|
144
|
+
while (true) {
|
|
145
|
+
const result = iter.next();
|
|
146
|
+
if (result.done)
|
|
147
|
+
return { done: true, value: undefined };
|
|
148
|
+
const [key, value] = result.value;
|
|
149
|
+
const id = SyncUnitMap.parseKey(key);
|
|
150
|
+
if (filter) {
|
|
151
|
+
if (id.documentId !== filter.documentId)
|
|
152
|
+
continue;
|
|
153
|
+
if (filter.scope !== undefined && id.scope !== filter.scope)
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
done: false,
|
|
158
|
+
value: [id, value],
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/** Makes the map iterable */
|
|
165
|
+
[Symbol.iterator]() {
|
|
166
|
+
return this.entries();
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Executes a callback for each entry in the map
|
|
170
|
+
* @param callbackfn Function to execute for each entry
|
|
171
|
+
* @param thisArg Value to use as 'this' in the callback
|
|
172
|
+
*/
|
|
173
|
+
forEach(callbackfn, thisArg) {
|
|
174
|
+
for (const [k, v] of this.entries()) {
|
|
175
|
+
callbackfn.call(thisArg, v, k, this);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Custom API methods
|
|
179
|
+
/**
|
|
180
|
+
* Removes all entries associated with a specific document
|
|
181
|
+
* @param documentId The document identifier
|
|
182
|
+
*/
|
|
183
|
+
deleteByDocumentId(documentId) {
|
|
184
|
+
for (const key of this.internalMap.keys()) {
|
|
185
|
+
if (key.startsWith(documentId + SyncUnitMap.keySeparator)) {
|
|
186
|
+
this.internalMap.delete(key);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Removes all entries for a specific document and scope combination
|
|
192
|
+
* @param documentId The document identifier
|
|
193
|
+
* @param scope The scope identifier
|
|
194
|
+
*/
|
|
195
|
+
deleteByDocumentIdAndScope(documentId, scope) {
|
|
196
|
+
const prefix = `${documentId}${SyncUnitMap.keySeparator}${scope}${SyncUnitMap.keySeparator}`;
|
|
197
|
+
for (const key of this.internalMap.keys()) {
|
|
198
|
+
if (key.startsWith(prefix)) {
|
|
199
|
+
this.internalMap.delete(key);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Retrieves all entries associated with a specific document
|
|
205
|
+
* @param documentId The document identifier
|
|
206
|
+
* @returns Array of [id, value] pairs
|
|
207
|
+
*/
|
|
208
|
+
getAllByDocumentId(documentId) {
|
|
209
|
+
const results = [];
|
|
210
|
+
for (const [key, value] of this.internalMap.entries()) {
|
|
211
|
+
if (key.startsWith(documentId + SyncUnitMap.keySeparator)) {
|
|
212
|
+
results.push([SyncUnitMap.parseKey(key), value]);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return results;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Retrieves all entries for a specific document and scope combination
|
|
219
|
+
* @param documentId The document identifier
|
|
220
|
+
* @param scope The scope identifier
|
|
221
|
+
* @returns Array of [id, value] pairs
|
|
222
|
+
*/
|
|
223
|
+
getAllByDocumentIdAndScope(documentId, scope) {
|
|
224
|
+
const prefix = `${documentId}${SyncUnitMap.keySeparator}${scope}${SyncUnitMap.keySeparator}`;
|
|
225
|
+
const results = [];
|
|
226
|
+
for (const [key, value] of this.internalMap.entries()) {
|
|
227
|
+
if (key.startsWith(prefix)) {
|
|
228
|
+
results.push([SyncUnitMap.parseKey(key), value]);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return results;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=sync-unit-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-unit-map.js","sourceRoot":"","sources":["../../../src/server/sync-unit-map.ts"],"names":[],"mappings":"AA4CA;;;;GAIG;AACH,MAAM,OAAO,WAAW;IACtB,sDAAsD;IAC9C,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEpD,gDAAgD;IAChD,MAAM,CAAC,YAAY,GAAyB,GAAG,CAAC;IAEhD;;;OAGG;IACK,MAAM,CAAC,MAAM,CAAC,GAAW;QAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,QAAQ,CAAC,GAAW;QACjC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,EAAyB;QACvC,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,U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AM,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,kBAAkB,CAAC,UAAkB;QACnC,MAAM,OAAO,GAAqC,EAAE,CAAC;QACrD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC;YACtD,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,0BAA0B,CACxB,UAAkB,EAClB,KAAa;QAEb,MAAM,MAAM,GAAG,GAAG,UAAU,GAAG,WAAW,CAAC,YAAY,GAAG,KAAK,GAAG,WAAW,CAAC,YAAY,EAAE,CAAC;QAC7F,MAAM,OAAO,GAAqC,EAAE,CAAC;QACrD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC;YACtD,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { type DocumentDriveAction, type DocumentDriveDocument, type DocumentDriveLocalState, type ListenerCallInfo, type ListenerFilter, type Trigger } from "#drive-document-model/gen/types";
|
|
1
|
+
import { type DocumentDriveAction, type DocumentDriveDocument, type DocumentDriveLocalState, type LegacyAddFileAction, type ListenerCallInfo, type ListenerFilter, type Trigger } from "#drive-document-model/gen/types";
|
|
2
2
|
import { type IReadModeDriveServer } from "#read-mode/types";
|
|
3
3
|
import { type IDefaultDrivesManager } from "#utils/default-drives-manager";
|
|
4
4
|
import { type DriveInfo } from "#utils/graphql";
|
|
5
5
|
import { type RunAsap } from "#utils/run-asap";
|
|
6
|
-
import { type Action, type ActionContext, type
|
|
6
|
+
import { type Action, type ActionContext, type DocumentModelModule, type Operation, type OperationFromDocument, type PHDocument, type PHDocumentHeader, type PHDocumentMeta, type ReducerOptions } from "document-model";
|
|
7
7
|
import { type Unsubscribe } from "nanoevents";
|
|
8
|
+
import { type SignalResult } from "../../../document-model/src/document/signal.js";
|
|
8
9
|
import { type BaseDocumentDriveServer } from "./base-server.js";
|
|
9
10
|
import { type OperationError, type SynchronizationUnitNotFoundError } from "./error.js";
|
|
10
11
|
import { type ITransmitter, type StrandUpdateSource } from "./listener/transmitter/types.js";
|
|
12
|
+
import { type ISyncUnitMap } from "./sync-unit-map.js";
|
|
11
13
|
export type Constructor<T = object> = new (...args: any[]) => T;
|
|
12
14
|
export type Mixin<T extends Constructor, I> = T & Constructor<InstanceType<T> & I>;
|
|
13
15
|
export type DocumentDriveServerMixin<I> = Mixin<typeof BaseDocumentDriveServer, I>;
|
|
@@ -28,11 +30,26 @@ export type RemoteDriveOptions = DocumentDriveLocalState & {
|
|
|
28
30
|
expectedDriveInfo?: DriveInfo;
|
|
29
31
|
accessLevel?: RemoteDriveAccessLevel;
|
|
30
32
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated In the future we will disallow this. Use the header field instead.
|
|
35
|
+
*/
|
|
36
|
+
export type LegacyCreateDocumentInput = {
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated In the future we will disallow this. Use the header field instead.
|
|
39
|
+
*/
|
|
40
|
+
id: string;
|
|
41
|
+
documentType: string;
|
|
42
|
+
};
|
|
43
|
+
export type CreateDocumentInputWithDocument<TDocument extends PHDocument> = {
|
|
44
|
+
document: TDocument;
|
|
45
|
+
};
|
|
46
|
+
export type CreateDocumentInputWithHeader = {
|
|
47
|
+
header: PHDocumentHeader;
|
|
48
|
+
};
|
|
49
|
+
export type CreateDocumentInputWithDocumentId = {
|
|
50
|
+
documentType: string;
|
|
35
51
|
};
|
|
52
|
+
export type CreateDocumentInput<TDocument extends PHDocument> = LegacyCreateDocumentInput | CreateDocumentInputWithDocument<TDocument> | CreateDocumentInputWithHeader | CreateDocumentInputWithDocumentId;
|
|
36
53
|
export type IOperationResult<TDocument extends PHDocument = PHDocument> = {
|
|
37
54
|
status: UpdateStatus;
|
|
38
55
|
error?: OperationError;
|
|
@@ -41,12 +58,13 @@ export type IOperationResult<TDocument extends PHDocument = PHDocument> = {
|
|
|
41
58
|
signals: SignalResult[];
|
|
42
59
|
};
|
|
43
60
|
export type DriveOperationResult = IOperationResult<DocumentDriveDocument>;
|
|
44
|
-
export type
|
|
45
|
-
syncId: string;
|
|
61
|
+
export type SynchronizationUnitId = {
|
|
46
62
|
documentId: string;
|
|
47
|
-
documentType: string;
|
|
48
63
|
scope: string;
|
|
49
64
|
branch: string;
|
|
65
|
+
};
|
|
66
|
+
export type SynchronizationUnit = SynchronizationUnitId & {
|
|
67
|
+
documentType: string;
|
|
50
68
|
lastUpdated: string;
|
|
51
69
|
revision: number;
|
|
52
70
|
};
|
|
@@ -80,6 +98,7 @@ export declare enum TransmitterType {
|
|
|
80
98
|
export type ListenerRevision = {
|
|
81
99
|
driveId: string;
|
|
82
100
|
documentId: string;
|
|
101
|
+
documentType: string;
|
|
83
102
|
scope: string;
|
|
84
103
|
branch: string;
|
|
85
104
|
status: UpdateStatus;
|
|
@@ -108,7 +127,8 @@ export type OperationUpdate = {
|
|
|
108
127
|
export type StrandUpdate = {
|
|
109
128
|
driveId: string;
|
|
110
129
|
documentId: string;
|
|
111
|
-
|
|
130
|
+
documentType: string;
|
|
131
|
+
scope: string;
|
|
112
132
|
branch: string;
|
|
113
133
|
operations: OperationUpdate[];
|
|
114
134
|
};
|
|
@@ -121,21 +141,21 @@ export type SyncUnitStatusObject = {
|
|
|
121
141
|
};
|
|
122
142
|
export type AddRemoteDriveStatus = "SUCCESS" | "ERROR" | "PENDING" | "ADDING" | "ALREADY_ADDED";
|
|
123
143
|
export interface DriveEvents {
|
|
124
|
-
syncStatus: (driveId: string, status: SyncStatus, error?: Error, syncUnitStatus?: SyncUnitStatusObject) => void;
|
|
144
|
+
syncStatus: (driveId: string, status: SyncStatus, error?: Error, syncUnitStatus?: SyncUnitStatusObject, scope?: string, branch?: string) => void;
|
|
125
145
|
defaultRemoteDrive: (status: AddRemoteDriveStatus, defaultDrives: Map<string, DefaultRemoteDriveInfo>, driveInput: DefaultRemoteDriveInput, driveId?: string, driveName?: string, error?: Error) => void;
|
|
126
146
|
strandUpdate: (update: StrandUpdate) => void;
|
|
127
147
|
clientStrandsError: (driveId: string, trigger: Trigger, status: number, errorMessage: string) => void;
|
|
128
148
|
documentModelModules: (documentModelModules: DocumentModelModule[]) => void;
|
|
129
149
|
driveAdded: (drive: DocumentDriveDocument) => void;
|
|
130
150
|
driveDeleted: (driveId: string) => void;
|
|
131
|
-
documentOperationsAdded: (
|
|
151
|
+
documentOperationsAdded: (documentId: string, operations: Operation[]) => void;
|
|
132
152
|
driveOperationsAdded: (driveId: string, operations: Operation[]) => void;
|
|
133
|
-
operationsAdded: (
|
|
153
|
+
operationsAdded: (documentId: string, operations: Operation[]) => void;
|
|
134
154
|
}
|
|
135
155
|
export type PartialRecord<K extends keyof any, T> = {
|
|
136
156
|
[P in K]?: T;
|
|
137
157
|
};
|
|
138
|
-
export type RevisionsFilter = PartialRecord<
|
|
158
|
+
export type RevisionsFilter = PartialRecord<string, number>;
|
|
139
159
|
export type GetDocumentOptions = ReducerOptions & {
|
|
140
160
|
revisions?: RevisionsFilter;
|
|
141
161
|
checkHashes?: boolean;
|
|
@@ -234,30 +254,92 @@ export interface IBaseDocumentDriveServer {
|
|
|
234
254
|
getDrive(driveId: string, options?: GetDocumentOptions): Promise<DocumentDriveDocument>;
|
|
235
255
|
getDriveBySlug(slug: string): Promise<DocumentDriveDocument>;
|
|
236
256
|
getDriveIdBySlug(slug: string): Promise<DocumentDriveDocument["header"]["id"]>;
|
|
237
|
-
|
|
257
|
+
addDocument<TDocument extends PHDocument>(input: TDocument, meta?: PHDocumentMeta): Promise<TDocument>;
|
|
258
|
+
deleteDocument(documentId: string): Promise<void>;
|
|
259
|
+
getDocuments(parentId: string): Promise<string[]>;
|
|
260
|
+
/**
|
|
261
|
+
* @deprecated Use getDocument(documentId, options) instead. This method will be removed in the future.
|
|
262
|
+
*/
|
|
238
263
|
getDocument<TDocument extends PHDocument>(driveId: string, documentId: string, options?: GetDocumentOptions): Promise<TDocument>;
|
|
264
|
+
getDocument<TDocument extends PHDocument>(documentId: string, options?: GetDocumentOptions): Promise<TDocument>;
|
|
265
|
+
queueDocument<TDocument extends PHDocument>(input: CreateDocumentInput<TDocument>, options?: AddOperationOptions): Promise<IOperationResult>;
|
|
266
|
+
/**
|
|
267
|
+
* @deprecated Use addOperation(documentId, operation, options) instead. This method will be removed in the future.
|
|
268
|
+
*/
|
|
239
269
|
addOperation(driveId: string, documentId: string, operation: Operation, options?: AddOperationOptions): Promise<IOperationResult>;
|
|
270
|
+
addOperation(documentId: string, operation: Operation, options?: AddOperationOptions): Promise<IOperationResult>;
|
|
271
|
+
/**
|
|
272
|
+
* @deprecated Use addOperations(documentId, operations, options) instead. This method will be removed in the future.
|
|
273
|
+
*/
|
|
240
274
|
addOperations(driveId: string, documentId: string, operations: Operation[], options?: AddOperationOptions): Promise<IOperationResult>;
|
|
275
|
+
addOperations(documentId: string, operations: Operation[], options?: AddOperationOptions): Promise<IOperationResult>;
|
|
276
|
+
/**
|
|
277
|
+
* @deprecated Use queueOperation(documentId, operation, options) instead. This method will be removed in the future.
|
|
278
|
+
*/
|
|
241
279
|
queueOperation(driveId: string, documentId: string, operation: Operation, options?: AddOperationOptions): Promise<IOperationResult>;
|
|
280
|
+
queueOperation(documentId: string, operation: Operation, options?: AddOperationOptions): Promise<IOperationResult>;
|
|
281
|
+
/**
|
|
282
|
+
* @deprecated Use queueOperations(documentId, operations, options) instead. This method will be removed in the future.
|
|
283
|
+
*/
|
|
242
284
|
queueOperations(driveId: string, documentId: string, operations: Operation[], options?: AddOperationOptions): Promise<IOperationResult>;
|
|
285
|
+
queueOperations(documentId: string, operations: Operation[], options?: AddOperationOptions): Promise<IOperationResult>;
|
|
286
|
+
/**
|
|
287
|
+
* @deprecated Use queueAction(documentId, action, options) instead. This method will be removed in the future.
|
|
288
|
+
*/
|
|
243
289
|
queueAction(driveId: string, documentId: string, action: Action, options?: AddOperationOptions): Promise<IOperationResult>;
|
|
290
|
+
queueAction(documentId: string, action: Action, options?: AddOperationOptions): Promise<IOperationResult>;
|
|
291
|
+
/**
|
|
292
|
+
* @deprecated Use queueActions(documentId, actions, options) instead. This method will be removed in the future.
|
|
293
|
+
*/
|
|
244
294
|
queueActions(driveId: string, documentId: string, actions: Action[], options?: AddOperationOptions): Promise<IOperationResult>;
|
|
295
|
+
queueActions(documentId: string, actions: Action[], options?: AddOperationOptions): Promise<IOperationResult>;
|
|
296
|
+
/**
|
|
297
|
+
* @deprecated Use the {@link addOperation} method instead.
|
|
298
|
+
*/
|
|
245
299
|
addDriveOperation(driveId: string, operation: Operation<DocumentDriveAction>, options?: AddOperationOptions): Promise<DriveOperationResult>;
|
|
300
|
+
/**
|
|
301
|
+
* @deprecated Use the {@link addOperations} method instead.
|
|
302
|
+
*/
|
|
246
303
|
addDriveOperations(driveId: string, operations: Operation<DocumentDriveAction>[], options?: AddOperationOptions): Promise<DriveOperationResult>;
|
|
304
|
+
/**
|
|
305
|
+
* @deprecated Use the {@link queueOperation} method instead.
|
|
306
|
+
*/
|
|
247
307
|
queueDriveOperation(driveId: string, operation: Operation<DocumentDriveAction>, options?: AddOperationOptions): Promise<DriveOperationResult>;
|
|
308
|
+
/**
|
|
309
|
+
* @deprecated Use the {@link queueOperations} method instead.
|
|
310
|
+
*/
|
|
248
311
|
queueDriveOperations(driveId: string, operations: Operation<DocumentDriveAction>[], options?: AddOperationOptions): Promise<DriveOperationResult>;
|
|
312
|
+
/**
|
|
313
|
+
* @deprecated Use the {@link queueAction} method instead.
|
|
314
|
+
*/
|
|
249
315
|
queueDriveAction(driveId: string, action: DocumentDriveAction, options?: AddOperationOptions): Promise<IOperationResult>;
|
|
316
|
+
/**
|
|
317
|
+
* @deprecated Use the {@link queueActions} method instead.
|
|
318
|
+
*/
|
|
250
319
|
queueDriveActions(driveId: string, actions: DocumentDriveAction[], options?: AddOperationOptions): Promise<IOperationResult>;
|
|
320
|
+
/**
|
|
321
|
+
* @deprecated Use addAction(documentId, action, options) method instead. This method will be removed in the future.
|
|
322
|
+
*/
|
|
251
323
|
addAction(driveId: string, documentId: string, action: Action, options?: AddOperationOptions): Promise<IOperationResult>;
|
|
324
|
+
addAction(documentId: string, action: Action, options?: AddOperationOptions): Promise<IOperationResult>;
|
|
325
|
+
/**
|
|
326
|
+
* @deprecated Use addActions(documentId, actions, options) instead. This method will be removed in the future.
|
|
327
|
+
*/
|
|
252
328
|
addActions(driveId: string, documentId: string, actions: Action[], options?: AddOperationOptions): Promise<IOperationResult>;
|
|
329
|
+
addActions(documentId: string, actions: Action[], options?: AddOperationOptions): Promise<IOperationResult>;
|
|
330
|
+
/**
|
|
331
|
+
* @deprecated Use the {@link addAction} method with a {@link AddFileAction} and call {@link addDocument} if the document needs to be created.
|
|
332
|
+
*/
|
|
333
|
+
addDriveAction(driveId: string, action: LegacyAddFileAction, options?: AddOperationOptions): Promise<DriveOperationResult>;
|
|
334
|
+
/**
|
|
335
|
+
* @deprecated Use the {@link addAction} method instead.
|
|
336
|
+
*/
|
|
253
337
|
addDriveAction(driveId: string, action: DocumentDriveAction, options?: AddOperationOptions): Promise<DriveOperationResult>;
|
|
338
|
+
/**
|
|
339
|
+
* @deprecated Use the {@link addActions} method instead.
|
|
340
|
+
*/
|
|
254
341
|
addDriveActions(driveId: string, actions: DocumentDriveAction[], options?: AddOperationOptions): Promise<DriveOperationResult>;
|
|
255
|
-
getSyncStatus(
|
|
256
|
-
/** Synchronization methods */
|
|
257
|
-
getSynchronizationUnits(driveId: string, documentId?: string[], scope?: string[], branch?: string[], documentType?: string[]): Promise<SynchronizationUnit[]>;
|
|
258
|
-
getSynchronizationUnit(driveId: string, syncId: string, loadedDrive?: DocumentDriveDocument): Promise<SynchronizationUnit | undefined>;
|
|
259
|
-
getSynchronizationUnitsIds(driveId: string, documentId?: string[], scope?: string[], branch?: string[], documentType?: string[]): Promise<SynchronizationUnitQuery[]>;
|
|
260
|
-
getOperationData(driveId: string, syncId: string, filter: GetStrandsOptions): Promise<OperationUpdate[]>;
|
|
342
|
+
getSyncStatus(documentId: string, scope?: string, branch?: string): SyncStatus | SynchronizationUnitNotFoundError;
|
|
261
343
|
/** Internal methods **/
|
|
262
344
|
getDocumentModelModules(): DocumentModelModule[];
|
|
263
345
|
on<K extends keyof DriveEvents>(event: K, cb: DriveEvents[K]): Unsubscribe;
|
|
@@ -275,21 +357,21 @@ export interface IListenerManager {
|
|
|
275
357
|
removeListener(driveId: string, listenerId: string): Promise<boolean>;
|
|
276
358
|
getListenerState(driveId: string, listenerId: string): ListenerState;
|
|
277
359
|
getStrands(driveId: string, listenerId: string, options?: GetStrandsOptions): Promise<StrandUpdate[]>;
|
|
278
|
-
updateSynchronizationRevisions(
|
|
279
|
-
updateListenerRevision(listenerId: string, driveId: string,
|
|
280
|
-
|
|
281
|
-
removeSyncUnits(driveId: string, syncUnits: Pick<SynchronizationUnit, "syncId">[]): Promise<void>;
|
|
360
|
+
updateSynchronizationRevisions(syncUnits: SynchronizationUnit[], source: StrandUpdateSource, willUpdate?: (listeners: Listener[]) => void, onError?: (error: Error, driveId: string, listener: ListenerState) => void, forceSync?: boolean): Promise<ListenerUpdate[]>;
|
|
361
|
+
updateListenerRevision(listenerId: string, driveId: string, syncUnitId: SynchronizationUnitId, listenerRev: number): Promise<void>;
|
|
362
|
+
removeSyncUnits(parentId: string, syncUnits: SynchronizationUnitId[]): Promise<void>;
|
|
282
363
|
setGenerateJwtHandler(handler: (driveUrl: string) => Promise<string>): void;
|
|
283
364
|
removeJwtHandler(): void;
|
|
284
365
|
generateJwtHandler?: (driveUrl: string) => Promise<string>;
|
|
285
366
|
}
|
|
286
367
|
export type ListenerStatus = "CREATED" | "PENDING" | "SUCCESS" | "MISSING" | "CONFLICT" | "ERROR";
|
|
368
|
+
export type SynchronizationUnitMap = ISyncUnitMap<SyncronizationUnitState>;
|
|
287
369
|
export interface ListenerState {
|
|
288
370
|
driveId: string;
|
|
289
371
|
block: boolean;
|
|
290
372
|
pendingTimeout: string;
|
|
291
373
|
listener: Listener;
|
|
292
|
-
syncUnits:
|
|
374
|
+
syncUnits: SynchronizationUnitMap;
|
|
293
375
|
listenerStatus: ListenerStatus;
|
|
294
376
|
}
|
|
295
377
|
export interface SyncronizationUnitState {
|
|
@@ -305,13 +387,14 @@ export interface IEventEmitter {
|
|
|
305
387
|
}
|
|
306
388
|
export interface ISynchronizationManager {
|
|
307
389
|
setDocumentModelModules(arg0: DocumentModelModule[]): void;
|
|
308
|
-
getSynchronizationUnits(
|
|
309
|
-
getSynchronizationUnitsIds(
|
|
310
|
-
getSynchronizationUnit(
|
|
311
|
-
getOperationData(
|
|
312
|
-
|
|
313
|
-
getSyncStatus(
|
|
314
|
-
updateSyncStatus(
|
|
390
|
+
getSynchronizationUnits(parentId?: string, documentId?: string[], scope?: string[], branch?: string[], documentType?: string[]): Promise<SynchronizationUnit[]>;
|
|
391
|
+
getSynchronizationUnitsIds(parentId?: string, documentId?: string[], scope?: string[], branch?: string[], documentType?: string[]): Promise<SynchronizationUnitQuery[]>;
|
|
392
|
+
getSynchronizationUnit(syncId: SynchronizationUnitId): Promise<SynchronizationUnit | undefined>;
|
|
393
|
+
getOperationData(syncId: SynchronizationUnitId, filter: GetStrandsOptions): Promise<OperationUpdate[]>;
|
|
394
|
+
getSyncStatus(documentId: string, scope?: string, branch?: string): SyncStatus | SynchronizationUnitNotFoundError;
|
|
395
|
+
getSyncStatus(syncId: SynchronizationUnitId): SyncStatus | SynchronizationUnitNotFoundError;
|
|
396
|
+
updateSyncStatus(documentId: string, status: Partial<SyncUnitStatusObject> | null, error?: Error, scope?: string, branch?: string): void;
|
|
397
|
+
updateSyncStatus(syncId: SynchronizationUnitId, status: Partial<SyncUnitStatusObject> | null, error?: Error): void;
|
|
315
398
|
initializeDriveSyncStatus(driveId: string, drive: DocumentDriveDocument): Promise<void>;
|
|
316
399
|
getCombinedSyncUnitStatus(syncUnitStatus: SyncUnitStatusObject): SyncStatus;
|
|
317
400
|
}
|