@powerhousedao/reactor 5.1.0-dev.4 → 5.1.0-dev.40
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/src/actions/index.d.ts +24 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +77 -0
- package/dist/src/actions/index.js.map +1 -0
- package/dist/src/cache/document-meta-cache-types.d.ts +114 -0
- package/dist/src/cache/document-meta-cache-types.d.ts.map +1 -0
- package/dist/src/cache/document-meta-cache-types.js +2 -0
- package/dist/src/cache/document-meta-cache-types.js.map +1 -0
- package/dist/src/cache/document-meta-cache.d.ts +30 -0
- package/dist/src/cache/document-meta-cache.d.ts.map +1 -0
- package/dist/src/cache/document-meta-cache.js +128 -0
- package/dist/src/cache/document-meta-cache.js.map +1 -0
- package/dist/src/cache/kysely-operation-index.d.ts +4 -2
- package/dist/src/cache/kysely-operation-index.d.ts.map +1 -1
- package/dist/src/cache/kysely-operation-index.js +67 -24
- package/dist/src/cache/kysely-operation-index.js.map +1 -1
- package/dist/src/cache/kysely-write-cache.d.ts.map +1 -1
- package/dist/src/cache/kysely-write-cache.js +3 -2
- package/dist/src/cache/kysely-write-cache.js.map +1 -1
- package/dist/src/cache/operation-index-types.d.ts +4 -3
- package/dist/src/cache/operation-index-types.d.ts.map +1 -1
- package/dist/src/cache/operation-index-types.js.map +1 -1
- package/dist/src/client/reactor-client.d.ts +16 -4
- package/dist/src/client/reactor-client.d.ts.map +1 -1
- package/dist/src/client/reactor-client.js +122 -5
- package/dist/src/client/reactor-client.js.map +1 -1
- package/dist/src/client/types.d.ts +22 -3
- package/dist/src/client/types.d.ts.map +1 -1
- package/dist/src/core/reactor-builder.d.ts +17 -11
- package/dist/src/core/reactor-builder.d.ts.map +1 -1
- package/dist/src/core/reactor-builder.js +88 -24
- package/dist/src/core/reactor-builder.js.map +1 -1
- package/dist/src/core/{builder.d.ts → reactor-client-builder.d.ts} +20 -4
- package/dist/src/core/reactor-client-builder.d.ts.map +1 -0
- package/dist/src/core/reactor-client-builder.js +123 -0
- package/dist/src/core/reactor-client-builder.js.map +1 -0
- package/dist/src/core/reactor.d.ts +11 -10
- package/dist/src/core/reactor.d.ts.map +1 -1
- package/dist/src/core/reactor.js +78 -91
- package/dist/src/core/reactor.js.map +1 -1
- package/dist/src/core/types.d.ts +40 -7
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/utils.d.ts +1 -2
- package/dist/src/core/utils.d.ts.map +1 -1
- package/dist/src/core/utils.js +2 -2
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/events/types.d.ts +1 -0
- package/dist/src/events/types.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor-manager.d.ts +3 -1
- package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor-manager.js +10 -7
- package/dist/src/executor/simple-job-executor-manager.js.map +1 -1
- package/dist/src/executor/simple-job-executor.d.ts +18 -3
- package/dist/src/executor/simple-job-executor.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor.js +327 -221
- package/dist/src/executor/simple-job-executor.js.map +1 -1
- package/dist/src/executor/types.d.ts +2 -8
- package/dist/src/executor/types.d.ts.map +1 -1
- package/dist/src/executor/types.js.map +1 -1
- package/dist/src/executor/util.d.ts +14 -5
- package/dist/src/executor/util.d.ts.map +1 -1
- package/dist/src/executor/util.js +36 -9
- package/dist/src/executor/util.js.map +1 -1
- package/dist/src/index.d.ts +16 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +15 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/logging/console.d.ts +23 -0
- package/dist/src/logging/console.d.ts.map +1 -0
- package/dist/src/logging/console.js +108 -0
- package/dist/src/logging/console.js.map +1 -0
- package/dist/src/logging/types.d.ts +12 -0
- package/dist/src/logging/types.d.ts.map +1 -0
- package/dist/src/logging/types.js +2 -0
- package/dist/src/logging/types.js.map +1 -0
- package/dist/src/processors/index.d.ts +3 -0
- package/dist/src/processors/index.d.ts.map +1 -0
- package/dist/src/processors/index.js +2 -0
- package/dist/src/processors/index.js.map +1 -0
- package/dist/src/processors/processor-manager.d.ts +38 -0
- package/dist/src/processors/processor-manager.d.ts.map +1 -0
- package/dist/src/processors/processor-manager.js +165 -0
- package/dist/src/processors/processor-manager.js.map +1 -0
- package/dist/src/processors/types.d.ts +63 -0
- package/dist/src/processors/types.d.ts.map +1 -0
- package/dist/src/processors/types.js +2 -0
- package/dist/src/processors/types.js.map +1 -0
- package/dist/src/processors/utils.d.ts +10 -0
- package/dist/src/processors/utils.d.ts.map +1 -0
- package/dist/src/processors/utils.js +58 -0
- package/dist/src/processors/utils.js.map +1 -0
- package/dist/src/queue/types.d.ts +2 -0
- package/dist/src/queue/types.d.ts.map +1 -1
- package/dist/src/queue/types.js.map +1 -1
- package/dist/src/read-models/base-read-model.d.ts +60 -0
- package/dist/src/read-models/base-read-model.d.ts.map +1 -0
- package/dist/src/read-models/base-read-model.js +143 -0
- package/dist/src/read-models/base-read-model.js.map +1 -0
- package/dist/src/read-models/coordinator.d.ts +3 -2
- package/dist/src/read-models/coordinator.d.ts.map +1 -1
- package/dist/src/read-models/coordinator.js +12 -13
- package/dist/src/read-models/coordinator.js.map +1 -1
- package/dist/src/read-models/document-view.d.ts +6 -7
- package/dist/src/read-models/document-view.d.ts.map +1 -1
- package/dist/src/read-models/document-view.js +18 -81
- package/dist/src/read-models/document-view.js.map +1 -1
- package/dist/src/read-models/types.d.ts +2 -1
- package/dist/src/read-models/types.d.ts.map +1 -1
- package/dist/src/registry/implementation.d.ts +42 -34
- package/dist/src/registry/implementation.d.ts.map +1 -1
- package/dist/src/registry/implementation.js +168 -48
- package/dist/src/registry/implementation.js.map +1 -1
- package/dist/src/registry/interfaces.d.ts +69 -8
- package/dist/src/registry/interfaces.d.ts.map +1 -1
- package/dist/src/shared/errors.d.ts +16 -0
- package/dist/src/shared/errors.d.ts.map +1 -1
- package/dist/src/shared/errors.js +28 -0
- package/dist/src/shared/errors.js.map +1 -1
- package/dist/src/shared/types.d.ts +4 -0
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/src/shared/types.js.map +1 -1
- package/dist/src/signer/passthrough-signer.d.ts +9 -3
- package/dist/src/signer/passthrough-signer.d.ts.map +1 -1
- package/dist/src/signer/passthrough-signer.js +13 -0
- package/dist/src/signer/passthrough-signer.js.map +1 -1
- package/dist/src/signer/types.d.ts +12 -10
- package/dist/src/signer/types.d.ts.map +1 -1
- package/dist/src/storage/consistency-aware-legacy-storage.d.ts +33 -0
- package/dist/src/storage/consistency-aware-legacy-storage.d.ts.map +1 -0
- package/dist/src/storage/consistency-aware-legacy-storage.js +65 -0
- package/dist/src/storage/consistency-aware-legacy-storage.js.map +1 -0
- package/dist/src/storage/interfaces.d.ts +94 -1
- package/dist/src/storage/interfaces.d.ts.map +1 -1
- package/dist/src/storage/interfaces.js +2 -2
- package/dist/src/storage/interfaces.js.map +1 -1
- package/dist/src/storage/kysely/store.d.ts +1 -0
- package/dist/src/storage/kysely/store.d.ts.map +1 -1
- package/dist/src/storage/kysely/store.js +40 -3
- package/dist/src/storage/kysely/store.js.map +1 -1
- package/dist/src/storage/kysely/sync-cursor-storage.js +2 -2
- package/dist/src/storage/kysely/sync-cursor-storage.js.map +1 -1
- package/dist/src/storage/kysely/sync-remote-storage.js +8 -8
- package/dist/src/storage/kysely/sync-remote-storage.js.map +1 -1
- package/dist/src/storage/kysely/types.d.ts +6 -6
- package/dist/src/storage/migrations/001_create_operation_table.d.ts.map +1 -1
- package/dist/src/storage/migrations/001_create_operation_table.js +2 -1
- package/dist/src/storage/migrations/001_create_operation_table.js.map +1 -1
- package/dist/src/storage/migrations/008_create_view_state_table.d.ts +1 -1
- package/dist/src/storage/migrations/008_create_view_state_table.d.ts.map +1 -1
- package/dist/src/storage/migrations/008_create_view_state_table.js +2 -1
- package/dist/src/storage/migrations/008_create_view_state_table.js.map +1 -1
- package/dist/src/storage/migrations/009_create_operation_index_tables.js +1 -1
- package/dist/src/storage/migrations/009_create_operation_index_tables.js.map +1 -1
- package/dist/src/storage/migrations/010_create_sync_tables.js +5 -5
- package/dist/src/storage/migrations/010_create_sync_tables.js.map +1 -1
- package/dist/src/storage/migrations/migrator.d.ts +3 -2
- package/dist/src/storage/migrations/migrator.d.ts.map +1 -1
- package/dist/src/storage/migrations/migrator.js +29 -6
- package/dist/src/storage/migrations/migrator.js.map +1 -1
- package/dist/src/storage/migrations/run-migrations.js +3 -3
- package/dist/src/storage/migrations/run-migrations.js.map +1 -1
- package/dist/src/storage/txn.d.ts.map +1 -1
- package/dist/src/storage/txn.js +2 -3
- package/dist/src/storage/txn.js.map +1 -1
- package/dist/src/subs/subscription-notification-read-model.d.ts +17 -0
- package/dist/src/subs/subscription-notification-read-model.d.ts.map +1 -0
- package/dist/src/subs/subscription-notification-read-model.js +62 -0
- package/dist/src/subs/subscription-notification-read-model.js.map +1 -0
- package/dist/src/sync/channels/composite-channel-factory.d.ts +30 -0
- package/dist/src/sync/channels/composite-channel-factory.d.ts.map +1 -0
- package/dist/src/sync/channels/composite-channel-factory.js +87 -0
- package/dist/src/sync/channels/composite-channel-factory.js.map +1 -0
- package/dist/src/sync/channels/gql-channel-factory.d.ts +5 -2
- package/dist/src/sync/channels/gql-channel-factory.d.ts.map +1 -1
- package/dist/src/sync/channels/gql-channel-factory.js +8 -2
- package/dist/src/sync/channels/gql-channel-factory.js.map +1 -1
- package/dist/src/sync/channels/gql-channel.d.ts +28 -1
- package/dist/src/sync/channels/gql-channel.d.ts.map +1 -1
- package/dist/src/sync/channels/gql-channel.js +150 -22
- package/dist/src/sync/channels/gql-channel.js.map +1 -1
- package/dist/src/sync/channels/index.d.ts +2 -1
- package/dist/src/sync/channels/index.d.ts.map +1 -1
- package/dist/src/sync/channels/index.js +2 -1
- package/dist/src/sync/channels/index.js.map +1 -1
- package/dist/src/sync/channels/polling-channel.d.ts +39 -0
- package/dist/src/sync/channels/polling-channel.d.ts.map +1 -0
- package/dist/src/sync/channels/polling-channel.js +72 -0
- package/dist/src/sync/channels/polling-channel.js.map +1 -0
- package/dist/src/sync/channels/utils.d.ts +17 -2
- package/dist/src/sync/channels/utils.d.ts.map +1 -1
- package/dist/src/sync/channels/utils.js +76 -6
- package/dist/src/sync/channels/utils.js.map +1 -1
- package/dist/src/sync/errors.d.ts +1 -1
- package/dist/src/sync/errors.d.ts.map +1 -1
- package/dist/src/sync/errors.js +2 -2
- package/dist/src/sync/errors.js.map +1 -1
- package/dist/src/sync/index.d.ts +2 -2
- package/dist/src/sync/index.d.ts.map +1 -1
- package/dist/src/sync/index.js +2 -2
- package/dist/src/sync/index.js.map +1 -1
- package/dist/src/sync/interfaces.d.ts +16 -1
- package/dist/src/sync/interfaces.d.ts.map +1 -1
- package/dist/src/sync/sync-builder.d.ts +3 -2
- package/dist/src/sync/sync-builder.d.ts.map +1 -1
- package/dist/src/sync/sync-builder.js +4 -4
- package/dist/src/sync/sync-builder.js.map +1 -1
- package/dist/src/sync/sync-manager.d.ts +4 -1
- package/dist/src/sync/sync-manager.d.ts.map +1 -1
- package/dist/src/sync/sync-manager.js +65 -8
- package/dist/src/sync/sync-manager.js.map +1 -1
- package/dist/src/sync/utils.d.ts +19 -0
- package/dist/src/sync/utils.d.ts.map +1 -1
- package/dist/src/sync/utils.js +44 -0
- package/dist/src/sync/utils.js.map +1 -1
- package/package.json +4 -4
- package/dist/src/core/builder.d.ts.map +0 -1
- package/dist/src/core/builder.js +0 -88
- package/dist/src/core/builder.js.map +0 -1
- package/dist/src/sync/channels/internal-channel.d.ts +0 -57
- package/dist/src/sync/channels/internal-channel.d.ts.map +0 -1
- package/dist/src/sync/channels/internal-channel.js +0 -106
- package/dist/src/sync/channels/internal-channel.js.map +0 -1
|
@@ -1,26 +1,96 @@
|
|
|
1
1
|
import { SyncOperation } from "../sync-operation.js";
|
|
2
|
+
import { batchOperationsByDocument } from "../utils.js";
|
|
2
3
|
let syncOpCounter = 0;
|
|
4
|
+
/**
|
|
5
|
+
* Deserializes a signature from a comma-separated string back to a tuple.
|
|
6
|
+
*
|
|
7
|
+
* GraphQL serializes Signature tuples as comma-separated strings for transport.
|
|
8
|
+
* This function converts them back to the expected [string, string, string, string, string] format.
|
|
9
|
+
*/
|
|
10
|
+
function deserializeSignature(sig) {
|
|
11
|
+
if (Array.isArray(sig)) {
|
|
12
|
+
return sig;
|
|
13
|
+
}
|
|
14
|
+
return sig.split(", ");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Deserializes signatures in an operation's signer context from strings back to tuples.
|
|
18
|
+
*
|
|
19
|
+
* When operations are transported via GraphQL, signatures are serialized as comma-separated
|
|
20
|
+
* strings. This function restores them to the Signature tuple format required for verification.
|
|
21
|
+
*/
|
|
22
|
+
function deserializeOperationSignatures(opWithContext) {
|
|
23
|
+
const signer = opWithContext.operation.action.context?.signer;
|
|
24
|
+
if (!signer?.signatures || signer.signatures.length === 0) {
|
|
25
|
+
return opWithContext;
|
|
26
|
+
}
|
|
27
|
+
const deserializedSignatures = signer.signatures.map(deserializeSignature);
|
|
28
|
+
const deserializedOperation = {
|
|
29
|
+
...opWithContext.operation,
|
|
30
|
+
action: {
|
|
31
|
+
...opWithContext.operation.action,
|
|
32
|
+
context: {
|
|
33
|
+
...opWithContext.operation.action.context,
|
|
34
|
+
signer: {
|
|
35
|
+
...signer,
|
|
36
|
+
signatures: deserializedSignatures,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
...opWithContext,
|
|
43
|
+
operation: deserializedOperation,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
3
46
|
/**
|
|
4
47
|
* Converts a SyncEnvelope containing operations into a SyncOperation.
|
|
5
48
|
*
|
|
6
49
|
* Extracts the necessary metadata from the envelope's operations to create
|
|
7
|
-
* a sync operation that can be processed by the receiving channel.
|
|
50
|
+
* a sync operation that can be processed by the receiving channel. Also
|
|
51
|
+
* deserializes any signatures from comma-separated strings back to tuples,
|
|
52
|
+
* as GraphQL transport serializes Signature tuples for compatibility.
|
|
8
53
|
*
|
|
9
54
|
* @param envelope - The sync envelope containing operations
|
|
10
55
|
* @param remoteName - The name of the remote this sync operation is associated with
|
|
11
|
-
* @returns A new SyncOperation containing the envelope's operations
|
|
56
|
+
* @returns A new SyncOperation containing the envelope's operations with deserialized signatures
|
|
12
57
|
* @throws Error if envelope has no operations or operations array is empty
|
|
13
58
|
*/
|
|
14
59
|
export function envelopeToSyncOperation(envelope, remoteName) {
|
|
15
60
|
if (!envelope.operations || envelope.operations.length === 0) {
|
|
16
61
|
throw new Error("Cannot create SyncOperation from envelope without operations");
|
|
17
62
|
}
|
|
18
|
-
const
|
|
19
|
-
const firstOp =
|
|
63
|
+
const deserializedOperations = envelope.operations.map(deserializeOperationSignatures);
|
|
64
|
+
const firstOp = deserializedOperations[0];
|
|
20
65
|
const documentId = firstOp.context.documentId;
|
|
21
66
|
const branch = firstOp.context.branch;
|
|
22
|
-
const scopes = [
|
|
67
|
+
const scopes = [
|
|
68
|
+
...new Set(deserializedOperations.map((op) => op.context.scope)),
|
|
69
|
+
];
|
|
23
70
|
const syncOpId = `syncop-${envelope.channelMeta.id}-${Date.now()}-${syncOpCounter++}`;
|
|
24
|
-
return new SyncOperation(syncOpId, remoteName, documentId, scopes, branch,
|
|
71
|
+
return new SyncOperation(syncOpId, remoteName, documentId, scopes, branch, deserializedOperations);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Converts a SyncEnvelope containing operations into multiple SyncOperations.
|
|
75
|
+
*
|
|
76
|
+
* This function batches operations by documentId, preserving cross-document ordering.
|
|
77
|
+
* For operations [a1, a2, a3, b1, b2, a4], it returns:
|
|
78
|
+
* - SyncOperation 1: [a1, a2, a3] for doc-a
|
|
79
|
+
* - SyncOperation 2: [b1, b2] for doc-b
|
|
80
|
+
* - SyncOperation 3: [a4] for doc-a
|
|
81
|
+
*
|
|
82
|
+
* This ensures operations are grouped for efficient processing while maintaining
|
|
83
|
+
* causality across documents.
|
|
84
|
+
*/
|
|
85
|
+
export function envelopesToSyncOperations(envelope, remoteName) {
|
|
86
|
+
if (!envelope.operations || envelope.operations.length === 0) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
const deserializedOps = envelope.operations.map(deserializeOperationSignatures);
|
|
90
|
+
const batches = batchOperationsByDocument(deserializedOps);
|
|
91
|
+
return batches.map((batch) => {
|
|
92
|
+
const syncOpId = `syncop-${envelope.channelMeta.id}-${Date.now()}-${syncOpCounter++}`;
|
|
93
|
+
return new SyncOperation(syncOpId, remoteName, batch.documentId, [batch.scope], batch.branch, batch.operations);
|
|
94
|
+
});
|
|
25
95
|
}
|
|
26
96
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/sync/channels/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/sync/channels/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExD,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,GAAuB;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAc,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,SAAS,8BAA8B,CACrC,aAAmC;IAEnC,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC;IAC9D,IAAI,CAAC,MAAM,EAAE,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAA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,GAAG,EAAE,IAAI,aAAa,EAAE,EAAE,CAAC;IAEtF,OAAO,IAAI,aAAa,CACtB,QAAQ,EACR,UAAU,EACV,UAAU,EACV,MAAM,EACN,MAAM,EACN,sBAAsB,CACvB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAsB,EACtB,UAAkB;IAElB,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7D,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,eAAe,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAC7C,8BAA8B,CAC/B,CAAC;IACF,MAAM,OAAO,GAAG,yBAAyB,CAAC,eAAe,CAAC,CAAC;IAE3D,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,MAAM,QAAQ,GAAG,UAAU,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,aAAa,EAAE,EAAE,CAAC;QACtF,OAAO,IAAI,aAAa,CACtB,QAAQ,EACR,UAAU,EACV,KAAK,CAAC,UAAU,EAChB,CAAC,KAAK,CAAC,KAAK,CAAC,EACb,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,UAAU,CACjB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/sync/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,qBAAa,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/sync/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;gBAED,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,KAAK;CAMrD"}
|
package/dist/src/sync/errors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class PollingChannelError extends Error {
|
|
2
2
|
constructor(message) {
|
|
3
3
|
super(message);
|
|
4
|
-
this.name = "
|
|
4
|
+
this.name = "PollingChannelError";
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
export class ChannelError extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/sync/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/sync/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,MAAM,CAAqB;IAC3B,KAAK,CAAQ;IAEb,YAAY,MAA0B,EAAE,KAAY;QAClD,KAAK,CAAC,gBAAgB,MAAM,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
|
package/dist/src/sync/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export type { ChannelConfig, ChannelHealth, SyncOperationErrorType, RemoteFilter
|
|
|
4
4
|
export { ChannelErrorSource, SyncOperationStatus } from "./types.js";
|
|
5
5
|
export { SyncOperation, SyncOperationAggregateError, } from "./sync-operation.js";
|
|
6
6
|
export { Mailbox, type MailboxItem } from "./mailbox.js";
|
|
7
|
-
export { ChannelError,
|
|
8
|
-
export {
|
|
7
|
+
export { ChannelError, PollingChannelError } from "./errors.js";
|
|
8
|
+
export { PollingChannel, GqlChannelFactory, CompositeChannelFactory, } from "./channels/index.js";
|
|
9
9
|
export { SyncManager } from "./sync-manager.js";
|
|
10
10
|
export { SyncBuilder } from "./sync-builder.js";
|
|
11
11
|
export { createIdleHealth, filterOperations } from "./utils.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sync/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,MAAM,GACP,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,YAAY,EACV,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,EACL,aAAa,EACb,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sync/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,MAAM,GACP,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,YAAY,EACV,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,EACL,aAAa,EACb,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/src/sync/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { ChannelErrorSource, SyncOperationStatus } from "./types.js";
|
|
2
2
|
export { SyncOperation, SyncOperationAggregateError, } from "./sync-operation.js";
|
|
3
3
|
export { Mailbox } from "./mailbox.js";
|
|
4
|
-
export { ChannelError,
|
|
5
|
-
export {
|
|
4
|
+
export { ChannelError, PollingChannelError } from "./errors.js";
|
|
5
|
+
export { PollingChannel, GqlChannelFactory, CompositeChannelFactory, } from "./channels/index.js";
|
|
6
6
|
export { SyncManager } from "./sync-manager.js";
|
|
7
7
|
export { SyncBuilder } from "./sync-builder.js";
|
|
8
8
|
export { createIdleHealth, filterOperations } from "./utils.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sync/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,EACL,aAAa,EACb,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAoB,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sync/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,EACL,aAAa,EACb,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAoB,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -33,10 +33,23 @@ export interface IChannel {
|
|
|
33
33
|
* These sync operations require manual intervention or should be logged for debugging.
|
|
34
34
|
*/
|
|
35
35
|
deadLetter: Mailbox<SyncOperation>;
|
|
36
|
+
/**
|
|
37
|
+
* Initializes the channel asynchronously.
|
|
38
|
+
* For remote channels, this typically involves registering the channel on the remote server.
|
|
39
|
+
* Must be called after construction before the channel is used.
|
|
40
|
+
*/
|
|
41
|
+
init(): Promise<void>;
|
|
36
42
|
/**
|
|
37
43
|
* Shuts down the channel and prevents further operations.
|
|
38
44
|
*/
|
|
39
45
|
shutdown(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Updates the synchronization cursor for this channel.
|
|
48
|
+
* For polling channels, this also removes acknowledged operations from the outbox.
|
|
49
|
+
*
|
|
50
|
+
* @param cursorOrdinal - The last processed ordinal
|
|
51
|
+
*/
|
|
52
|
+
updateCursor(cursorOrdinal: number): Promise<void>;
|
|
40
53
|
}
|
|
41
54
|
/**
|
|
42
55
|
* Factory for creating channel instances.
|
|
@@ -52,9 +65,11 @@ export interface IChannelFactory {
|
|
|
52
65
|
* @param remoteName - Name of the remote
|
|
53
66
|
* @param config - Channel configuration including type and parameters
|
|
54
67
|
* @param cursorStorage - Storage for persisting synchronization cursors
|
|
68
|
+
* @param collectionId - Collection ID to synchronize
|
|
69
|
+
* @param filter - Filter to apply to operations
|
|
55
70
|
* @returns A new channel instance
|
|
56
71
|
*/
|
|
57
|
-
instance(remoteId: string, remoteName: string, config: ChannelConfig, cursorStorage: ISyncCursorStorage): IChannel;
|
|
72
|
+
instance(remoteId: string, remoteName: string, config: ChannelConfig, cursorStorage: ISyncCursorStorage, collectionId: string, filter: RemoteFilter): IChannel;
|
|
58
73
|
}
|
|
59
74
|
/**
|
|
60
75
|
* Represents a configured remote with an active channel.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/sync/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7E;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAE9B;;;OAGG;IACH,MAAM,EAAE,OAAO,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AAM,MAAM,MAAM,GAAG;IACnB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,MAAM,EAAE,YAAY,CAAC;IAErB;;OAEG;IACH,OAAO,EAAE,aAAa,CAAC;IAEvB;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;OAOG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;;;;;;OAOG;IACH,QAAQ,IAAI,cAAc,CAAC;IAE3B;;;;;;OAMG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAEhC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAE5B;;;;;;;;;;;;;;OAcG;IACH,GAAG,CACD,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,aAAa,EAC5B,MAAM,CAAC,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE,aAAa,EACvB,EAAE,CAAC,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;;;;;;OASG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpC;;;;OAIG;IACH,IAAI,IAAI,MAAM,EAAE,CAAC;CAClB"}
|
|
@@ -2,6 +2,7 @@ import type { Kysely } from "kysely";
|
|
|
2
2
|
import type { IOperationIndex } from "../cache/operation-index-types.js";
|
|
3
3
|
import type { IReactor, SyncModule } from "../core/types.js";
|
|
4
4
|
import type { IEventBus } from "../events/interfaces.js";
|
|
5
|
+
import type { ILogger } from "../logging/types.js";
|
|
5
6
|
import type { ISyncCursorStorage, ISyncRemoteStorage } from "../storage/interfaces.js";
|
|
6
7
|
import type { Database } from "../storage/kysely/types.js";
|
|
7
8
|
import type { IChannelFactory, ISyncManager } from "./interfaces.js";
|
|
@@ -12,7 +13,7 @@ export declare class SyncBuilder {
|
|
|
12
13
|
withChannelFactory(factory: IChannelFactory): this;
|
|
13
14
|
withRemoteStorage(storage: ISyncRemoteStorage): this;
|
|
14
15
|
withCursorStorage(storage: ISyncCursorStorage): this;
|
|
15
|
-
build(reactor: IReactor, operationIndex: IOperationIndex, eventBus: IEventBus, db: Kysely<Database>): ISyncManager;
|
|
16
|
-
buildModule(reactor: IReactor, operationIndex: IOperationIndex, eventBus: IEventBus, db: Kysely<Database>): SyncModule;
|
|
16
|
+
build(reactor: IReactor, logger: ILogger, operationIndex: IOperationIndex, eventBus: IEventBus, db: Kysely<Database>): ISyncManager;
|
|
17
|
+
buildModule(reactor: IReactor, logger: ILogger, operationIndex: IOperationIndex, eventBus: IEventBus, db: Kysely<Database>): SyncModule;
|
|
17
18
|
}
|
|
18
19
|
//# sourceMappingURL=sync-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-builder.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-builder.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGrE,qBAAa,WAAW;IACtB,OAAO,CAAC,cAAc,CAAC,CAAkB;IACzC,OAAO,CAAC,aAAa,CAAC,CAAqB;IAC3C,OAAO,CAAC,aAAa,CAAC,CAAqB;IAE3C,kBAAkB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAKlD,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAKpD,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAKpD,KAAK,CACH,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,OAAO,EACf,cAAc,EAAE,eAAe,EAC/B,QAAQ,EAAE,SAAS,EACnB,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,GACnB,YAAY;IAWf,WAAW,CACT,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,OAAO,EACf,cAAc,EAAE,eAAe,EAC/B,QAAQ,EAAE,SAAS,EACnB,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,GACnB,UAAU;CAyBd"}
|
|
@@ -17,17 +17,17 @@ export class SyncBuilder {
|
|
|
17
17
|
this.cursorStorage = storage;
|
|
18
18
|
return this;
|
|
19
19
|
}
|
|
20
|
-
build(reactor, operationIndex, eventBus, db) {
|
|
21
|
-
const module = this.buildModule(reactor, operationIndex, eventBus, db);
|
|
20
|
+
build(reactor, logger, operationIndex, eventBus, db) {
|
|
21
|
+
const module = this.buildModule(reactor, logger, operationIndex, eventBus, db);
|
|
22
22
|
return module.syncManager;
|
|
23
23
|
}
|
|
24
|
-
buildModule(reactor, operationIndex, eventBus, db) {
|
|
24
|
+
buildModule(reactor, logger, operationIndex, eventBus, db) {
|
|
25
25
|
if (!this.channelFactory) {
|
|
26
26
|
throw new Error("Channel factory is required");
|
|
27
27
|
}
|
|
28
28
|
const remoteStorage = this.remoteStorage ?? new KyselySyncRemoteStorage(db);
|
|
29
29
|
const cursorStorage = this.cursorStorage ?? new KyselySyncCursorStorage(db);
|
|
30
|
-
const syncManager = new SyncManager(remoteStorage, cursorStorage, this.channelFactory, operationIndex, reactor, eventBus);
|
|
30
|
+
const syncManager = new SyncManager(logger, remoteStorage, cursorStorage, this.channelFactory, operationIndex, reactor, eventBus);
|
|
31
31
|
return {
|
|
32
32
|
remoteStorage,
|
|
33
33
|
cursorStorage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-builder.js","sourceRoot":"","sources":["../../../src/sync/sync-builder.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-builder.js","sourceRoot":"","sources":["../../../src/sync/sync-builder.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAGnF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,WAAW;IACd,cAAc,CAAmB;IACjC,aAAa,CAAsB;IACnC,aAAa,CAAsB;IAE3C,kBAAkB,CAAC,OAAwB;QACzC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iBAAiB,CAAC,OAA2B;QAC3C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iBAAiB,CAAC,OAA2B;QAC3C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CACH,OAAiB,EACjB,MAAe,EACf,cAA+B,EAC/B,QAAmB,EACnB,EAAoB;QAEpB,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAC7B,OAAO,EACP,MAAM,EACN,cAAc,EACd,QAAQ,EACR,EAAE,CACH,CAAC;QACF,OAAO,MAAM,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,WAAW,CACT,OAAiB,EACjB,MAAe,EACf,cAA+B,EAC/B,QAAmB,EACnB,EAAoB;QAEpB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,IAAI,uBAAuB,CAAC,EAAE,CAAC,CAAC;QAC5E,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,IAAI,uBAAuB,CAAC,EAAE,CAAC,CAAC;QAE5E,MAAM,WAAW,GAAG,IAAI,WAAW,CACjC,MAAM,EACN,aAAa,EACb,aAAa,EACb,IAAI,CAAC,cAAc,EACnB,cAAc,EACd,OAAO,EACP,QAAQ,CACT,CAAC;QAEF,OAAO;YACL,aAAa;YACb,aAAa;YACb,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,WAAW;SACZ,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { IOperationIndex } from "../cache/operation-index-types.js";
|
|
2
2
|
import type { IReactor } from "../core/types.js";
|
|
3
3
|
import type { IEventBus } from "../events/interfaces.js";
|
|
4
|
+
import type { ILogger } from "../logging/types.js";
|
|
4
5
|
import { type JobInfo, type ShutdownStatus } from "../shared/types.js";
|
|
5
6
|
import type { ISyncCursorStorage, ISyncRemoteStorage } from "../storage/interfaces.js";
|
|
6
7
|
import type { IChannelFactory, ISyncManager, Remote } from "./interfaces.js";
|
|
7
8
|
import type { ChannelConfig, RemoteFilter, RemoteOptions } from "./types.js";
|
|
8
9
|
export declare class SyncManager implements ISyncManager {
|
|
10
|
+
private readonly logger;
|
|
9
11
|
private readonly remoteStorage;
|
|
10
12
|
private readonly cursorStorage;
|
|
11
13
|
private readonly channelFactory;
|
|
@@ -17,12 +19,13 @@ export declare class SyncManager implements ISyncManager {
|
|
|
17
19
|
private isShutdown;
|
|
18
20
|
private eventUnsubscribe?;
|
|
19
21
|
loadJobs: Map<string, JobInfo>;
|
|
20
|
-
constructor(remoteStorage: ISyncRemoteStorage, cursorStorage: ISyncCursorStorage, channelFactory: IChannelFactory, operationIndex: IOperationIndex, reactor: IReactor, eventBus: IEventBus);
|
|
22
|
+
constructor(logger: ILogger, remoteStorage: ISyncRemoteStorage, cursorStorage: ISyncCursorStorage, channelFactory: IChannelFactory, operationIndex: IOperationIndex, reactor: IReactor, eventBus: IEventBus);
|
|
21
23
|
startup(): Promise<void>;
|
|
22
24
|
shutdown(): ShutdownStatus;
|
|
23
25
|
getByName(name: string): Remote;
|
|
24
26
|
getById(id: string): Remote;
|
|
25
27
|
add(name: string, collectionId: string, channelConfig: ChannelConfig, filter?: RemoteFilter, options?: RemoteOptions, id?: string): Promise<Remote>;
|
|
28
|
+
private backfillOutbox;
|
|
26
29
|
remove(name: string): Promise<void>;
|
|
27
30
|
list(): Remote[];
|
|
28
31
|
private wireChannelCallbacks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-manager.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,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,CAAC,OAAO,CAAa;IACrC,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,gBAAgB,CAAC,CAAa;IAE/B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAa;gBAGhD,MAAM,EAAE,OAAO,EACf,aAAa,EAAE,kBAAkB,EACjC,aAAa,EAAE,kBAAkB,EACjC,cAAc,EAAE,eAAe,EAC/B,cAAc,EAAE,eAAe,EAC/B,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,SAAS;IAgBf,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA6C9B,QAAQ,IAAI,cAAc;IA2B1B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAQ/B,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IASrB,GAAG,CACP,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,aAAa,EAC5B,MAAM,GAAE,YAAwD,EAChE,OAAO,GAAE,aAAkB,EAC3B,EAAE,CAAC,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC;YAkEJ,cAAc;IAsDtB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYzC,IAAI,IAAI,MAAM,EAAE;IAIhB,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,sBAAsB;IAiC9B,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,eAAe;YAUT,aAAa;CAsD5B"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { OperationEventTypes, } from "../events/types.js";
|
|
2
|
-
import { JobStatus, } from "../shared/types.js";
|
|
3
2
|
import { JobAwaiter } from "../shared/awaiter.js";
|
|
3
|
+
import { JobStatus, } from "../shared/types.js";
|
|
4
4
|
import { ChannelError } from "./errors.js";
|
|
5
5
|
import { SyncOperation } from "./sync-operation.js";
|
|
6
6
|
import { ChannelErrorSource, SyncOperationStatus } from "./types.js";
|
|
7
|
-
import { createIdleHealth, filterOperations } from "./utils.js";
|
|
7
|
+
import { batchOperationsByDocument, createIdleHealth, filterOperations, } from "./utils.js";
|
|
8
8
|
export class SyncManager {
|
|
9
|
+
logger;
|
|
9
10
|
remoteStorage;
|
|
10
11
|
cursorStorage;
|
|
11
12
|
channelFactory;
|
|
@@ -17,7 +18,8 @@ export class SyncManager {
|
|
|
17
18
|
isShutdown;
|
|
18
19
|
eventUnsubscribe;
|
|
19
20
|
loadJobs = new Map();
|
|
20
|
-
constructor(remoteStorage, cursorStorage, channelFactory, operationIndex, reactor, eventBus) {
|
|
21
|
+
constructor(logger, remoteStorage, cursorStorage, channelFactory, operationIndex, reactor, eventBus) {
|
|
22
|
+
this.logger = logger;
|
|
21
23
|
this.remoteStorage = remoteStorage;
|
|
22
24
|
this.cursorStorage = cursorStorage;
|
|
23
25
|
this.channelFactory = channelFactory;
|
|
@@ -34,7 +36,14 @@ export class SyncManager {
|
|
|
34
36
|
}
|
|
35
37
|
const remoteRecords = await this.remoteStorage.list();
|
|
36
38
|
for (const record of remoteRecords) {
|
|
37
|
-
const channel = this.channelFactory.instance(record.id, record.name, record.channelConfig, this.cursorStorage);
|
|
39
|
+
const channel = this.channelFactory.instance(record.id, record.name, record.channelConfig, this.cursorStorage, record.collectionId, record.filter);
|
|
40
|
+
try {
|
|
41
|
+
await channel.init();
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error(`Error initializing channel for remote ${record.name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
38
47
|
const remote = {
|
|
39
48
|
id: record.id,
|
|
40
49
|
name: record.name,
|
|
@@ -90,6 +99,7 @@ export class SyncManager {
|
|
|
90
99
|
if (this.remotes.has(name)) {
|
|
91
100
|
throw new Error(`Remote with name '${name}' already exists`);
|
|
92
101
|
}
|
|
102
|
+
this.logger.debug("Adding remote (@name, @collectionId, @channelConfig, @filter, @options, @id)", name, collectionId, channelConfig, filter, options, id);
|
|
93
103
|
const remoteId = id ?? crypto.randomUUID();
|
|
94
104
|
const status = {
|
|
95
105
|
push: createIdleHealth(),
|
|
@@ -105,7 +115,8 @@ export class SyncManager {
|
|
|
105
115
|
status,
|
|
106
116
|
};
|
|
107
117
|
await this.remoteStorage.upsert(remoteRecord);
|
|
108
|
-
const channel = this.channelFactory.instance(remoteId, name, channelConfig, this.cursorStorage);
|
|
118
|
+
const channel = this.channelFactory.instance(remoteId, name, channelConfig, this.cursorStorage, collectionId, filter);
|
|
119
|
+
await channel.init();
|
|
109
120
|
const remote = {
|
|
110
121
|
id: remoteId,
|
|
111
122
|
name,
|
|
@@ -116,8 +127,47 @@ export class SyncManager {
|
|
|
116
127
|
};
|
|
117
128
|
this.remotes.set(name, remote);
|
|
118
129
|
this.wireChannelCallbacks(remote);
|
|
130
|
+
await this.backfillOutbox(remote, collectionId, filter);
|
|
119
131
|
return remote;
|
|
120
132
|
}
|
|
133
|
+
async backfillOutbox(remote, collectionId, filter) {
|
|
134
|
+
let historicalOps;
|
|
135
|
+
try {
|
|
136
|
+
historicalOps = await this._operationIndex.find(collectionId);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (historicalOps.items.length === 0) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const opsWithContext = historicalOps.items.map((entry) => ({
|
|
145
|
+
operation: {
|
|
146
|
+
id: entry.id,
|
|
147
|
+
index: entry.index,
|
|
148
|
+
skip: entry.skip,
|
|
149
|
+
hash: entry.hash,
|
|
150
|
+
timestampUtcMs: entry.timestampUtcMs,
|
|
151
|
+
action: entry.action,
|
|
152
|
+
},
|
|
153
|
+
context: {
|
|
154
|
+
documentId: entry.documentId,
|
|
155
|
+
documentType: entry.documentType,
|
|
156
|
+
scope: entry.scope,
|
|
157
|
+
branch: entry.branch,
|
|
158
|
+
ordinal: entry.ordinal ?? 0,
|
|
159
|
+
},
|
|
160
|
+
}));
|
|
161
|
+
const filteredOps = filterOperations(opsWithContext, filter);
|
|
162
|
+
if (filteredOps.length === 0) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const batches = batchOperationsByDocument(filteredOps);
|
|
166
|
+
for (const batch of batches) {
|
|
167
|
+
const syncOp = new SyncOperation(crypto.randomUUID(), remote.name, batch.documentId, [batch.scope], batch.branch, batch.operations);
|
|
168
|
+
remote.channel.outbox.add(syncOp);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
121
171
|
async remove(name) {
|
|
122
172
|
const remote = this.remotes.get(name);
|
|
123
173
|
if (!remote) {
|
|
@@ -142,13 +192,20 @@ export class SyncManager {
|
|
|
142
192
|
if (this.isShutdown) {
|
|
143
193
|
return;
|
|
144
194
|
}
|
|
195
|
+
const sourceRemote = event.jobMeta?.sourceRemote;
|
|
145
196
|
for (const remote of this.remotes.values()) {
|
|
197
|
+
if (sourceRemote && remote.name === sourceRemote) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
146
200
|
const filteredOps = filterOperations(event.operations, remote.filter);
|
|
147
201
|
if (filteredOps.length === 0) {
|
|
148
202
|
continue;
|
|
149
203
|
}
|
|
150
|
-
const
|
|
151
|
-
|
|
204
|
+
const batches = batchOperationsByDocument(filteredOps);
|
|
205
|
+
for (const batch of batches) {
|
|
206
|
+
const syncOp = new SyncOperation(crypto.randomUUID(), remote.name, batch.documentId, [batch.scope], batch.branch, batch.operations);
|
|
207
|
+
remote.channel.outbox.add(syncOp);
|
|
208
|
+
}
|
|
152
209
|
}
|
|
153
210
|
}
|
|
154
211
|
handleInboxJob(remote, syncOp) {
|
|
@@ -171,7 +228,7 @@ export class SyncManager {
|
|
|
171
228
|
const operations = syncOp.operations.map((op) => op.operation);
|
|
172
229
|
let jobInfo;
|
|
173
230
|
try {
|
|
174
|
-
jobInfo = await this.reactor.load(syncOp.documentId, syncOp.branch, operations);
|
|
231
|
+
jobInfo = await this.reactor.load(syncOp.documentId, syncOp.branch, operations, undefined, { sourceRemote: remote.name });
|
|
175
232
|
}
|
|
176
233
|
catch (error) {
|
|
177
234
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-manager.js","sourceRoot":"","sources":["../../../src/sync/sync-manager.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-manager.js","sourceRoot":"","sources":["../../../src/sync/sync-manager.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,SAAS,GAGV,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQpD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,OAAO,WAAW;IACL,MAAM,CAAU;IAChB,aAAa,CAAqB;IAClC,aAAa,CAAqB;IAClC,cAAc,CAAkB;IAChC,eAAe,CAAkB;IACjC,OAAO,CAAW;IAClB,QAAQ,CAAY;IACpB,OAAO,CAAsB;IAC7B,OAAO,CAAa;IAC7B,UAAU,CAAU;IACpB,gBAAgB,CAAc;IAE/B,QAAQ,GAAyB,IAAI,GAAG,EAAE,CAAC;IAElD,YACE,MAAe,EACf,aAAiC,EACjC,aAAiC,EACjC,cAA+B,EAC/B,cAA+B,EAC/B,OAAiB,EACjB,QAAmB;QAEnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,a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tC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACvD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAE5C,IAAI,gBAAgB,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;YACjD,MAAM,KAAK,GAAG,IAAI,YAAY,CAC5B,kBAAkB,CAAC,KAAK,EACxB,IAAI,KAAK,CACP,+BAA+B,gBAAgB,CAAC,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,CACpF,CACF,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACrB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF"}
|
package/dist/src/sync/utils.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { OperationWithContext } from "../storage/interfaces.js";
|
|
2
2
|
import type { ChannelHealth, RemoteFilter } from "./types.js";
|
|
3
|
+
export type OperationBatch = {
|
|
4
|
+
documentId: string;
|
|
5
|
+
branch: string;
|
|
6
|
+
scope: string;
|
|
7
|
+
operations: OperationWithContext[];
|
|
8
|
+
};
|
|
3
9
|
/**
|
|
4
10
|
* Filters operations based on a remote's filter criteria.
|
|
5
11
|
*
|
|
@@ -14,4 +20,17 @@ export declare function filterOperations(operations: OperationWithContext[], fil
|
|
|
14
20
|
* @returns A new idle channel health object
|
|
15
21
|
*/
|
|
16
22
|
export declare function createIdleHealth(): ChannelHealth;
|
|
23
|
+
/**
|
|
24
|
+
* Batches consecutive operations by documentId and scope, preserving ordering.
|
|
25
|
+
*
|
|
26
|
+
* For operations [a1_doc, a1_global, a2_doc, b1_global], this returns:
|
|
27
|
+
* - Batch 1: [a1_doc] for doc-a, document scope
|
|
28
|
+
* - Batch 2: [a1_global] for doc-a, global scope
|
|
29
|
+
* - Batch 3: [a2_doc] for doc-a, document scope
|
|
30
|
+
* - Batch 4: [b1_global] for doc-b, global scope
|
|
31
|
+
*
|
|
32
|
+
* This ensures operations are grouped for efficient processing while maintaining
|
|
33
|
+
* causality across documents and scopes.
|
|
34
|
+
*/
|
|
35
|
+
export declare function batchOperationsByDocument(operations: OperationWithContext[]): OperationBatch[];
|
|
17
36
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/sync/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,oBAAoB,EAAE,EAClC,MAAM,EAAE,YAAY,GACnB,oBAAoB,EAAE,CAmBxB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/sync/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9D,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,oBAAoB,EAAE,CAAC;CACpC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,oBAAoB,EAAE,EAClC,MAAM,EAAE,YAAY,GACnB,oBAAoB,EAAE,CAmBxB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,oBAAoB,EAAE,GACjC,cAAc,EAAE,CAsClB"}
|
package/dist/src/sync/utils.js
CHANGED
|
@@ -31,4 +31,48 @@ export function createIdleHealth() {
|
|
|
31
31
|
failureCount: 0,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Batches consecutive operations by documentId and scope, preserving ordering.
|
|
36
|
+
*
|
|
37
|
+
* For operations [a1_doc, a1_global, a2_doc, b1_global], this returns:
|
|
38
|
+
* - Batch 1: [a1_doc] for doc-a, document scope
|
|
39
|
+
* - Batch 2: [a1_global] for doc-a, global scope
|
|
40
|
+
* - Batch 3: [a2_doc] for doc-a, document scope
|
|
41
|
+
* - Batch 4: [b1_global] for doc-b, global scope
|
|
42
|
+
*
|
|
43
|
+
* This ensures operations are grouped for efficient processing while maintaining
|
|
44
|
+
* causality across documents and scopes.
|
|
45
|
+
*/
|
|
46
|
+
export function batchOperationsByDocument(operations) {
|
|
47
|
+
const batches = [];
|
|
48
|
+
let currentDocId = null;
|
|
49
|
+
let currentScope = null;
|
|
50
|
+
let currentBatch = [];
|
|
51
|
+
const flushBatch = () => {
|
|
52
|
+
if (currentBatch.length === 0 ||
|
|
53
|
+
currentDocId === null ||
|
|
54
|
+
currentScope === null) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
batches.push({
|
|
58
|
+
documentId: currentDocId,
|
|
59
|
+
branch: currentBatch[0].context.branch,
|
|
60
|
+
scope: currentScope,
|
|
61
|
+
operations: currentBatch,
|
|
62
|
+
});
|
|
63
|
+
currentBatch = [];
|
|
64
|
+
};
|
|
65
|
+
for (const op of operations) {
|
|
66
|
+
const docId = op.context.documentId;
|
|
67
|
+
const scope = op.context.scope;
|
|
68
|
+
if (docId !== currentDocId || scope !== currentScope) {
|
|
69
|
+
flushBatch();
|
|
70
|
+
currentDocId = docId;
|
|
71
|
+
currentScope = scope;
|
|
72
|
+
}
|
|
73
|
+
currentBatch.push(op);
|
|
74
|
+
}
|
|
75
|
+
flushBatch();
|
|
76
|
+
return batches;
|
|
77
|
+
}
|
|
34
78
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/sync/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/sync/utils.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,UAAkC,EAClC,MAAoB;IAEpB,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE;QAC9B,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;YACzD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IACE,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;YAC5B,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,EAClD,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACxE,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAA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