@powerhousedao/reactor 5.1.0-dev.1 → 5.1.0-dev.3
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/core/reactor-builder.d.ts +2 -1
- package/dist/src/core/reactor-builder.d.ts.map +1 -1
- package/dist/src/core/reactor-builder.js +47 -21
- package/dist/src/core/reactor-builder.js.map +1 -1
- package/dist/src/core/reactor.d.ts +0 -4
- package/dist/src/core/reactor.d.ts.map +1 -1
- package/dist/src/core/reactor.js +0 -11
- package/dist/src/core/reactor.js.map +1 -1
- package/dist/src/core/types.d.ts +49 -8
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/storage/kysely/sync-remote-storage.d.ts.map +1 -1
- package/dist/src/storage/kysely/sync-remote-storage.js +3 -4
- package/dist/src/storage/kysely/sync-remote-storage.js.map +1 -1
- package/dist/src/sync/channels/gql-channel-factory.d.ts +22 -0
- package/dist/src/sync/channels/gql-channel-factory.d.ts.map +1 -0
- package/dist/src/sync/channels/gql-channel-factory.js +70 -0
- package/dist/src/sync/channels/gql-channel-factory.js.map +1 -0
- package/dist/src/sync/channels/gql-channel.d.ts +91 -0
- package/dist/src/sync/channels/gql-channel.d.ts.map +1 -0
- package/dist/src/sync/channels/gql-channel.js +295 -0
- package/dist/src/sync/channels/gql-channel.js.map +1 -0
- package/dist/src/sync/channels/index.d.ts +2 -0
- package/dist/src/sync/channels/index.d.ts.map +1 -1
- package/dist/src/sync/channels/index.js +2 -0
- package/dist/src/sync/channels/index.js.map +1 -1
- package/dist/src/sync/index.d.ts +1 -1
- package/dist/src/sync/index.d.ts.map +1 -1
- package/dist/src/sync/index.js +1 -1
- package/dist/src/sync/index.js.map +1 -1
- package/dist/src/sync/interfaces.d.ts +18 -3
- package/dist/src/sync/interfaces.d.ts.map +1 -1
- package/dist/src/sync/sync-builder.d.ts +2 -1
- package/dist/src/sync/sync-builder.d.ts.map +1 -1
- package/dist/src/sync/sync-builder.js +11 -1
- package/dist/src/sync/sync-builder.js.map +1 -1
- package/dist/src/sync/sync-manager.d.ts +3 -2
- package/dist/src/sync/sync-manager.d.ts.map +1 -1
- package/dist/src/sync/sync-manager.js +16 -4
- package/dist/src/sync/sync-manager.js.map +1 -1
- package/dist/src/sync/types.d.ts +1 -2
- package/dist/src/sync/types.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-remote-storage.js","sourceRoot":"","sources":["../../../../src/storage/kysely/sync-remote-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAK7B,SAAS,iBAAiB,CAAC,GAAkB;IAC3C,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,YAAY,EAAE,GAAG,CAAC,aAAa;QAC/B,aAAa,EAAE;YACb,IAAI,EAAE,GAAG,CAAC,YAAY;YACtB,
|
|
1
|
+
{"version":3,"file":"sync-remote-storage.js","sourceRoot":"","sources":["../../../../src/storage/kysely/sync-remote-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAK7B,SAAS,iBAAiB,CAAC,GAAkB;IAC3C,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,UAAU;QAClB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,YAAY,EAAE,GAAG,CAAC,aAAa;QAC/B,aAAa,EAAE;YACb,IAAI,EAAE,GAAG,CAAC,YAAY;YACtB,UAAU,EAAE,CAAC,GAAG,CAAC,kBAAkB,IAAI,EAAE,CAA4B;SACtE;QACD,MAAM,EAAE;YACN,UAAU,EAAE,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAa;YACvD,KAAK,EAAE,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAa;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,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAChD,MAAM,UAAU,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAE7C,MAAM,GAAG;iBACN,UAAU,CAAC,cAAc,CAAC;iBAC1B,MAAM,CAAC,UAAU,CAAC;iBAClB,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CACjB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC;gBAC5B,GAAG,UAAU;gBACb,UAAU,EAAE,GAAG,CAAA,OAAO;aACvB,CAAC,CACH;iBACA,OAAO,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,MAAoB;QAC7C,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QAED,MAAM,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAChD,MAAM,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QAC1E,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ISyncCursorStorage } from "../../storage/interfaces.js";
|
|
2
|
+
import type { IChannel, IChannelFactory } from "../interfaces.js";
|
|
3
|
+
import type { ChannelConfig } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Factory for creating GqlChannel instances.
|
|
6
|
+
*
|
|
7
|
+
* Extracts GraphQL-specific configuration from ChannelConfig.parameters and
|
|
8
|
+
* instantiates GqlChannel instances for network-based synchronization.
|
|
9
|
+
*/
|
|
10
|
+
export declare class GqlChannelFactory implements IChannelFactory {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new GqlChannel instance with the given configuration.
|
|
13
|
+
* See GqlChannelConfig for the expected parameters.
|
|
14
|
+
*
|
|
15
|
+
* @param config - Channel configuration including type and parameters
|
|
16
|
+
* @param cursorStorage - Storage for persisting synchronization cursors
|
|
17
|
+
* @returns A new GqlChannel instance
|
|
18
|
+
* @throws Error if config.type is not "gql" or required parameters are missing
|
|
19
|
+
*/
|
|
20
|
+
instance(remoteId: string, remoteName: string, config: ChannelConfig, cursorStorage: ISyncCursorStorage): IChannel;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=gql-channel-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gql-channel-factory.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/gql-channel-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IACvD;;;;;;;;OAQG;IACH,QAAQ,CACN,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,kBAAkB,GAChC,QAAQ;CAgEZ"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { GqlChannel } from "./gql-channel.js";
|
|
2
|
+
/**
|
|
3
|
+
* Factory for creating GqlChannel instances.
|
|
4
|
+
*
|
|
5
|
+
* Extracts GraphQL-specific configuration from ChannelConfig.parameters and
|
|
6
|
+
* instantiates GqlChannel instances for network-based synchronization.
|
|
7
|
+
*/
|
|
8
|
+
export class GqlChannelFactory {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new GqlChannel instance with the given configuration.
|
|
11
|
+
* See GqlChannelConfig for the expected parameters.
|
|
12
|
+
*
|
|
13
|
+
* @param config - Channel configuration including type and parameters
|
|
14
|
+
* @param cursorStorage - Storage for persisting synchronization cursors
|
|
15
|
+
* @returns A new GqlChannel instance
|
|
16
|
+
* @throws Error if config.type is not "gql" or required parameters are missing
|
|
17
|
+
*/
|
|
18
|
+
instance(remoteId, remoteName, config, cursorStorage) {
|
|
19
|
+
if (config.type !== "gql") {
|
|
20
|
+
throw new Error(`GqlChannelFactory can only create channels of type "gql", got "${config.type}"`);
|
|
21
|
+
}
|
|
22
|
+
// Extract and validate required parameters
|
|
23
|
+
const url = config.parameters.url;
|
|
24
|
+
if (typeof url !== "string" || !url) {
|
|
25
|
+
throw new Error('GqlChannelFactory requires "url" parameter in config.parameters');
|
|
26
|
+
}
|
|
27
|
+
// Extract optional parameters with validation
|
|
28
|
+
const gqlConfig = {
|
|
29
|
+
url,
|
|
30
|
+
};
|
|
31
|
+
if (config.parameters.authToken !== undefined) {
|
|
32
|
+
if (typeof config.parameters.authToken !== "string") {
|
|
33
|
+
throw new Error('"authToken" parameter must be a string');
|
|
34
|
+
}
|
|
35
|
+
gqlConfig.authToken = config.parameters.authToken;
|
|
36
|
+
}
|
|
37
|
+
if (config.parameters.pollIntervalMs !== undefined) {
|
|
38
|
+
if (typeof config.parameters.pollIntervalMs !== "number") {
|
|
39
|
+
throw new Error('"pollIntervalMs" parameter must be a number');
|
|
40
|
+
}
|
|
41
|
+
gqlConfig.pollIntervalMs = config.parameters.pollIntervalMs;
|
|
42
|
+
}
|
|
43
|
+
if (config.parameters.retryBaseDelayMs !== undefined) {
|
|
44
|
+
if (typeof config.parameters.retryBaseDelayMs !== "number") {
|
|
45
|
+
throw new Error('"retryBaseDelayMs" parameter must be a number');
|
|
46
|
+
}
|
|
47
|
+
gqlConfig.retryBaseDelayMs = config.parameters.retryBaseDelayMs;
|
|
48
|
+
}
|
|
49
|
+
if (config.parameters.retryMaxDelayMs !== undefined) {
|
|
50
|
+
if (typeof config.parameters.retryMaxDelayMs !== "number") {
|
|
51
|
+
throw new Error('"retryMaxDelayMs" parameter must be a number');
|
|
52
|
+
}
|
|
53
|
+
gqlConfig.retryMaxDelayMs = config.parameters.retryMaxDelayMs;
|
|
54
|
+
}
|
|
55
|
+
if (config.parameters.maxFailures !== undefined) {
|
|
56
|
+
if (typeof config.parameters.maxFailures !== "number") {
|
|
57
|
+
throw new Error('"maxFailures" parameter must be a number');
|
|
58
|
+
}
|
|
59
|
+
gqlConfig.maxFailures = config.parameters.maxFailures;
|
|
60
|
+
}
|
|
61
|
+
if (config.parameters.fetchFn !== undefined) {
|
|
62
|
+
if (typeof config.parameters.fetchFn !== "function") {
|
|
63
|
+
throw new Error('"fetchFn" parameter must be a function');
|
|
64
|
+
}
|
|
65
|
+
gqlConfig.fetchFn = config.parameters.fetchFn;
|
|
66
|
+
}
|
|
67
|
+
return new GqlChannel(remoteId, remoteName, cursorStorage, gqlConfig);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=gql-channel-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gql-channel-factory.js","sourceRoot":"","sources":["../../../../src/sync/channels/gql-channel-factory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAyB,MAAM,kBAAkB,CAAC;AAErE;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;;;;;OAQG;IACH,QAAQ,CACN,QAAgB,EAChB,UAAkB,EAClB,MAAqB,EACrB,aAAiC;QAEjC,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YAC1B,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C,eAAe,KAAK,SAAS,EAAE,CAAC;YACpD,IAAI,OAAO,MAAM,CAAC,UAAU,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;gBAC1D,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAClE,CAAC;YACD,SAAS,CAAC,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC;QAChE,CAAC;QAED,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAChD,IAAI,OAAO,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;gBACtD,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;YAC9D,CAAC;YACD,SAAS,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC;QACxD,CAAC;QAED,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC5C,IAAI,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBACpD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAC5D,CAAC;YACD,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,OAAuB,CAAC;QAChE,CAAC;QAED,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;IACxE,CAAC;CACF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { ISyncCursorStorage } from "../../storage/interfaces.js";
|
|
2
|
+
import type { IChannel } from "../interfaces.js";
|
|
3
|
+
import { Mailbox } from "../mailbox.js";
|
|
4
|
+
import type { SyncOperation } from "../sync-operation.js";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration parameters for GqlChannel
|
|
7
|
+
*/
|
|
8
|
+
export type GqlChannelConfig = {
|
|
9
|
+
/** The GraphQL endpoint URL */
|
|
10
|
+
url: string;
|
|
11
|
+
/** Authentication token for the remote */
|
|
12
|
+
authToken?: string;
|
|
13
|
+
/** Polling interval in milliseconds (default: 5000) */
|
|
14
|
+
pollIntervalMs?: number;
|
|
15
|
+
/** Base delay for exponential backoff retries in milliseconds (default: 1000) */
|
|
16
|
+
retryBaseDelayMs?: number;
|
|
17
|
+
/** Maximum delay for exponential backoff retries in milliseconds (default: 300000) */
|
|
18
|
+
retryMaxDelayMs?: number;
|
|
19
|
+
/** Maximum number of consecutive failures before marking as error (default: 5) */
|
|
20
|
+
maxFailures?: number;
|
|
21
|
+
/** Custom fetch function for testing (default: global fetch) */
|
|
22
|
+
fetchFn?: typeof fetch;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* GraphQL-based synchronization channel for network communication between reactors.
|
|
26
|
+
*/
|
|
27
|
+
export declare class GqlChannel implements IChannel {
|
|
28
|
+
readonly inbox: Mailbox<SyncOperation>;
|
|
29
|
+
readonly outbox: Mailbox<SyncOperation>;
|
|
30
|
+
readonly deadLetter: Mailbox<SyncOperation>;
|
|
31
|
+
private readonly channelId;
|
|
32
|
+
private readonly remoteName;
|
|
33
|
+
private readonly cursorStorage;
|
|
34
|
+
private readonly config;
|
|
35
|
+
private isShutdown;
|
|
36
|
+
private pollTimer?;
|
|
37
|
+
private failureCount;
|
|
38
|
+
private lastSuccessUtcMs?;
|
|
39
|
+
private lastFailureUtcMs?;
|
|
40
|
+
constructor(channelId: string, remoteName: string, cursorStorage: ISyncCursorStorage, config: GqlChannelConfig);
|
|
41
|
+
/**
|
|
42
|
+
* Shuts down the channel and prevents further operations.
|
|
43
|
+
*/
|
|
44
|
+
shutdown(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Starts the polling loop to fetch operations from the remote.
|
|
47
|
+
*/
|
|
48
|
+
private startPolling;
|
|
49
|
+
/**
|
|
50
|
+
* Polls the remote for new sync envelopes.
|
|
51
|
+
*/
|
|
52
|
+
private poll;
|
|
53
|
+
/**
|
|
54
|
+
* Handles polling errors with exponential backoff.
|
|
55
|
+
*/
|
|
56
|
+
private handlePollError;
|
|
57
|
+
/**
|
|
58
|
+
* Queries the remote GraphQL endpoint for sync envelopes.
|
|
59
|
+
*/
|
|
60
|
+
private pollSyncEnvelopes;
|
|
61
|
+
/**
|
|
62
|
+
* Handles sync operations added to the outbox by sending them to the remote.
|
|
63
|
+
*/
|
|
64
|
+
private handleOutboxAdded;
|
|
65
|
+
/**
|
|
66
|
+
* Pushes a sync operation to the remote via GraphQL mutation.
|
|
67
|
+
*/
|
|
68
|
+
private pushSyncOperation;
|
|
69
|
+
/**
|
|
70
|
+
* Serializes a SyncEnvelope for GraphQL transport.
|
|
71
|
+
*/
|
|
72
|
+
private serializeEnvelope;
|
|
73
|
+
/**
|
|
74
|
+
* Executes a GraphQL query or mutation against the remote endpoint.
|
|
75
|
+
*/
|
|
76
|
+
private executeGraphQL;
|
|
77
|
+
/**
|
|
78
|
+
* Updates the synchronization cursor for this channel's remote.
|
|
79
|
+
*/
|
|
80
|
+
updateCursor(cursorOrdinal: number): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Gets the current health status of the channel.
|
|
83
|
+
*/
|
|
84
|
+
getHealth(): {
|
|
85
|
+
state: "idle" | "running" | "error";
|
|
86
|
+
lastSuccessUtcMs?: number;
|
|
87
|
+
lastFailureUtcMs?: number;
|
|
88
|
+
failureCount: number;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=gql-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gql-channel.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/gql-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,aA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IAAI;IAuClB;;OAEG;IACH,OAAO,CAAC,eAAe;IAmBvB;;OAEG;YACW,iBAAiB;IAkD/B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAezB;;OAEG;YACW,iBAAiB;IA6B/B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAqBzB;;OAEG;YACW,cAAc;IA4D5B;;OAEG;IACG,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxD;;OAEG;IACH,SAAS,IAAI;QACX,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;QACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;KACtB;CAaF"}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { ChannelError } from "../errors.js";
|
|
2
|
+
import { Mailbox } from "../mailbox.js";
|
|
3
|
+
import { ChannelErrorSource } from "../types.js";
|
|
4
|
+
import { envelopeToSyncOperation } from "./utils.js";
|
|
5
|
+
/**
|
|
6
|
+
* GraphQL-based synchronization channel for network communication between reactors.
|
|
7
|
+
*/
|
|
8
|
+
export class GqlChannel {
|
|
9
|
+
inbox;
|
|
10
|
+
outbox;
|
|
11
|
+
deadLetter;
|
|
12
|
+
channelId;
|
|
13
|
+
remoteName;
|
|
14
|
+
cursorStorage;
|
|
15
|
+
config;
|
|
16
|
+
isShutdown;
|
|
17
|
+
pollTimer;
|
|
18
|
+
failureCount;
|
|
19
|
+
lastSuccessUtcMs;
|
|
20
|
+
lastFailureUtcMs;
|
|
21
|
+
constructor(channelId, remoteName, cursorStorage, config) {
|
|
22
|
+
this.channelId = channelId;
|
|
23
|
+
this.remoteName = remoteName;
|
|
24
|
+
this.cursorStorage = cursorStorage;
|
|
25
|
+
this.config = {
|
|
26
|
+
url: config.url,
|
|
27
|
+
authToken: config.authToken,
|
|
28
|
+
pollIntervalMs: config.pollIntervalMs ?? 5000,
|
|
29
|
+
retryBaseDelayMs: config.retryBaseDelayMs ?? 1000,
|
|
30
|
+
retryMaxDelayMs: config.retryMaxDelayMs ?? 300000,
|
|
31
|
+
maxFailures: config.maxFailures ?? 5,
|
|
32
|
+
fetchFn: config.fetchFn,
|
|
33
|
+
};
|
|
34
|
+
this.isShutdown = false;
|
|
35
|
+
this.failureCount = 0;
|
|
36
|
+
this.inbox = new Mailbox();
|
|
37
|
+
this.outbox = new Mailbox();
|
|
38
|
+
this.deadLetter = new Mailbox();
|
|
39
|
+
this.outbox.onAdded((syncOp) => {
|
|
40
|
+
this.handleOutboxAdded(syncOp);
|
|
41
|
+
});
|
|
42
|
+
// Start polling
|
|
43
|
+
this.startPolling();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Shuts down the channel and prevents further operations.
|
|
47
|
+
*/
|
|
48
|
+
shutdown() {
|
|
49
|
+
this.isShutdown = true;
|
|
50
|
+
if (this.pollTimer) {
|
|
51
|
+
clearTimeout(this.pollTimer);
|
|
52
|
+
this.pollTimer = undefined;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Starts the polling loop to fetch operations from the remote.
|
|
57
|
+
*/
|
|
58
|
+
startPolling() {
|
|
59
|
+
if (this.isShutdown) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.pollTimer = setTimeout(() => {
|
|
63
|
+
void this.poll().then(() => {
|
|
64
|
+
this.startPolling(); // Schedule next poll
|
|
65
|
+
});
|
|
66
|
+
}, this.config.pollIntervalMs);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Polls the remote for new sync envelopes.
|
|
70
|
+
*/
|
|
71
|
+
async poll() {
|
|
72
|
+
if (this.isShutdown) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (this.failureCount >= this.config.maxFailures) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let cursor;
|
|
79
|
+
try {
|
|
80
|
+
cursor = await this.cursorStorage.get(this.remoteName);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
this.handlePollError(error);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const cursorOrdinal = cursor.cursorOrdinal;
|
|
87
|
+
let envelopes;
|
|
88
|
+
try {
|
|
89
|
+
envelopes = await this.pollSyncEnvelopes(cursorOrdinal);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
this.handlePollError(error);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
for (const envelope of envelopes) {
|
|
96
|
+
if (envelope.type === "operations" && envelope.operations) {
|
|
97
|
+
const syncOp = envelopeToSyncOperation(envelope, this.remoteName);
|
|
98
|
+
syncOp.transported();
|
|
99
|
+
this.inbox.add(syncOp);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
this.lastSuccessUtcMs = Date.now();
|
|
103
|
+
this.failureCount = 0;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Handles polling errors with exponential backoff.
|
|
107
|
+
*/
|
|
108
|
+
handlePollError(error) {
|
|
109
|
+
this.failureCount++;
|
|
110
|
+
this.lastFailureUtcMs = Date.now();
|
|
111
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
112
|
+
const channelError = new ChannelError(ChannelErrorSource.Inbox, err);
|
|
113
|
+
console.error(`GqlChannel poll error (${this.failureCount}/${this.config.maxFailures}):`, channelError);
|
|
114
|
+
if (this.failureCount >= this.config.maxFailures) {
|
|
115
|
+
console.error(`GqlChannel ${this.channelId} exceeded failure threshold, stopping polls`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Queries the remote GraphQL endpoint for sync envelopes.
|
|
120
|
+
*/
|
|
121
|
+
async pollSyncEnvelopes(cursorOrdinal) {
|
|
122
|
+
const query = `
|
|
123
|
+
query PollSyncEnvelopes($channelId: String!, $cursorOrdinal: Int!) {
|
|
124
|
+
pollSyncEnvelopes(channelId: $channelId, cursorOrdinal: $cursorOrdinal) {
|
|
125
|
+
type
|
|
126
|
+
channelMeta {
|
|
127
|
+
id
|
|
128
|
+
}
|
|
129
|
+
operations {
|
|
130
|
+
operation {
|
|
131
|
+
index
|
|
132
|
+
timestampUtcMs
|
|
133
|
+
hash
|
|
134
|
+
skip
|
|
135
|
+
error
|
|
136
|
+
resultingState
|
|
137
|
+
id
|
|
138
|
+
action
|
|
139
|
+
}
|
|
140
|
+
context {
|
|
141
|
+
documentId
|
|
142
|
+
documentType
|
|
143
|
+
scope
|
|
144
|
+
branch
|
|
145
|
+
resultingState
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
cursor {
|
|
149
|
+
remoteName
|
|
150
|
+
cursorOrdinal
|
|
151
|
+
lastSyncedAtUtcMs
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
156
|
+
const variables = {
|
|
157
|
+
channelId: this.channelId,
|
|
158
|
+
cursorOrdinal,
|
|
159
|
+
};
|
|
160
|
+
const response = await this.executeGraphQL(query, variables);
|
|
161
|
+
return response.pollSyncEnvelopes;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Handles sync operations added to the outbox by sending them to the remote.
|
|
165
|
+
*/
|
|
166
|
+
handleOutboxAdded(syncOp) {
|
|
167
|
+
if (this.isShutdown) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
// Execute async but don't await (fire and forget with error handling)
|
|
171
|
+
this.pushSyncOperation(syncOp).catch((error) => {
|
|
172
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
173
|
+
const channelError = new ChannelError(ChannelErrorSource.Outbox, err);
|
|
174
|
+
syncOp.failed(channelError);
|
|
175
|
+
this.deadLetter.add(syncOp);
|
|
176
|
+
this.outbox.remove(syncOp);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Pushes a sync operation to the remote via GraphQL mutation.
|
|
181
|
+
*/
|
|
182
|
+
async pushSyncOperation(syncOp) {
|
|
183
|
+
syncOp.started();
|
|
184
|
+
const envelope = {
|
|
185
|
+
type: "operations",
|
|
186
|
+
channelMeta: { id: this.channelId },
|
|
187
|
+
operations: syncOp.operations,
|
|
188
|
+
};
|
|
189
|
+
const mutation = `
|
|
190
|
+
mutation PushSyncEnvelope($envelope: SyncEnvelopeInput!) {
|
|
191
|
+
pushSyncEnvelope(envelope: $envelope)
|
|
192
|
+
}
|
|
193
|
+
`;
|
|
194
|
+
const variables = {
|
|
195
|
+
envelope: this.serializeEnvelope(envelope),
|
|
196
|
+
};
|
|
197
|
+
await this.executeGraphQL(mutation, variables);
|
|
198
|
+
// Successfully sent - the outbox will be cleared when we receive ACK
|
|
199
|
+
// For now, we optimistically remove from outbox
|
|
200
|
+
this.outbox.remove(syncOp);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Serializes a SyncEnvelope for GraphQL transport.
|
|
204
|
+
*/
|
|
205
|
+
serializeEnvelope(envelope) {
|
|
206
|
+
return {
|
|
207
|
+
type: envelope.type.toUpperCase(),
|
|
208
|
+
channelMeta: envelope.channelMeta,
|
|
209
|
+
operations: envelope.operations?.map((opWithContext) => ({
|
|
210
|
+
operation: {
|
|
211
|
+
index: opWithContext.operation.index,
|
|
212
|
+
timestampUtcMs: opWithContext.operation.timestampUtcMs,
|
|
213
|
+
hash: opWithContext.operation.hash,
|
|
214
|
+
skip: opWithContext.operation.skip,
|
|
215
|
+
error: opWithContext.operation.error,
|
|
216
|
+
resultingState: opWithContext.operation.resultingState,
|
|
217
|
+
id: opWithContext.operation.id,
|
|
218
|
+
action: opWithContext.operation.action,
|
|
219
|
+
},
|
|
220
|
+
context: opWithContext.context,
|
|
221
|
+
})),
|
|
222
|
+
cursor: envelope.cursor,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Executes a GraphQL query or mutation against the remote endpoint.
|
|
227
|
+
*/
|
|
228
|
+
async executeGraphQL(query, variables) {
|
|
229
|
+
const headers = {
|
|
230
|
+
"Content-Type": "application/json",
|
|
231
|
+
};
|
|
232
|
+
if (this.config.authToken) {
|
|
233
|
+
headers["Authorization"] = `Bearer ${this.config.authToken}`;
|
|
234
|
+
}
|
|
235
|
+
const fetchFn = this.config.fetchFn ?? fetch;
|
|
236
|
+
let response;
|
|
237
|
+
try {
|
|
238
|
+
response = await fetchFn(this.config.url, {
|
|
239
|
+
method: "POST",
|
|
240
|
+
headers,
|
|
241
|
+
body: JSON.stringify({
|
|
242
|
+
query,
|
|
243
|
+
variables,
|
|
244
|
+
}),
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
throw new Error(`GraphQL request failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
249
|
+
}
|
|
250
|
+
if (!response.ok) {
|
|
251
|
+
throw new Error(`GraphQL request failed: ${response.status} ${response.statusText}`);
|
|
252
|
+
}
|
|
253
|
+
let result;
|
|
254
|
+
try {
|
|
255
|
+
result = (await response.json());
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
throw new Error(`Failed to parse GraphQL response: ${error instanceof Error ? error.message : String(error)}`);
|
|
259
|
+
}
|
|
260
|
+
if (result.errors) {
|
|
261
|
+
throw new Error(`GraphQL errors: ${JSON.stringify(result.errors, null, 2)}`);
|
|
262
|
+
}
|
|
263
|
+
if (!result.data) {
|
|
264
|
+
throw new Error("GraphQL response missing data field");
|
|
265
|
+
}
|
|
266
|
+
return result.data;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Updates the synchronization cursor for this channel's remote.
|
|
270
|
+
*/
|
|
271
|
+
async updateCursor(cursorOrdinal) {
|
|
272
|
+
const cursor = {
|
|
273
|
+
remoteName: this.remoteName,
|
|
274
|
+
cursorOrdinal,
|
|
275
|
+
lastSyncedAtUtcMs: Date.now(),
|
|
276
|
+
};
|
|
277
|
+
await this.cursorStorage.upsert(cursor);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Gets the current health status of the channel.
|
|
281
|
+
*/
|
|
282
|
+
getHealth() {
|
|
283
|
+
return {
|
|
284
|
+
state: this.failureCount >= this.config.maxFailures
|
|
285
|
+
? "error"
|
|
286
|
+
: this.failureCount > 0
|
|
287
|
+
? "running"
|
|
288
|
+
: "idle",
|
|
289
|
+
lastSuccessUtcMs: this.lastSuccessUtcMs,
|
|
290
|
+
lastFailureUtcMs: this.lastFailureUtcMs,
|
|
291
|
+
failureCount: this.failureCount,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=gql-channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gql-channel.js","sourceRoot":"","sources":["../../../../src/sync/channels/gql-channel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAsBrD;;GAEG;AACH,MAAM,OAAO,UAAU;IACZ,KAAK,CAAyB;IAC9B,MAAM,CAAyB;IAC/B,UAAU,CAAyB;IAE3B,SAAS,CAAS;IAClB,UAAU,CAAS;IACnB,aAAa,CAAqB;IAClC,MAAM,CAAmB;IAClC,UAAU,CAAU;IACpB,SAAS,CAAkB;IAC3B,YAAY,CAAS;IACrB,gBAAgB,CAAU;IAC1B,gBAAgB,CAAU;IAElC,YACE,SAAiB,EACjB,UAAkB,EAClB,aAAiC,EACjC,MAAwB;QAExB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,MA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QAMP,OAAO;YACL,KAAK,EACH,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,WAAY;gBAC3C,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC;oBACrB,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,MAAM;YACd,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { InternalChannel } from "./internal-channel.js";
|
|
2
|
+
export { GqlChannel, type GqlChannelConfig } from "./gql-channel.js";
|
|
3
|
+
export { GqlChannelFactory } from "./gql-channel-factory.js";
|
|
2
4
|
export { envelopeToSyncOperation } from "./utils.js";
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/sync/channels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/sync/channels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAyB,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/src/sync/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ 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
7
|
export { ChannelError, InternalChannelError } from "./errors.js";
|
|
8
|
-
export { InternalChannel } from "./channels/index.js";
|
|
8
|
+
export { InternalChannel, GqlChannelFactory } 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,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
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,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,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
|
@@ -2,7 +2,7 @@ export { ChannelErrorSource, SyncOperationStatus } from "./types.js";
|
|
|
2
2
|
export { SyncOperation, SyncOperationAggregateError, } from "./sync-operation.js";
|
|
3
3
|
export { Mailbox } from "./mailbox.js";
|
|
4
4
|
export { ChannelError, InternalChannelError } from "./errors.js";
|
|
5
|
-
export { InternalChannel } from "./channels/index.js";
|
|
5
|
+
export { InternalChannel, GqlChannelFactory } 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,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
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,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,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"}
|
|
@@ -48,11 +48,13 @@ export interface IChannelFactory {
|
|
|
48
48
|
/**
|
|
49
49
|
* Creates a new channel instance with the given configuration.
|
|
50
50
|
*
|
|
51
|
+
* @param remoteId - Unique identifier for the remote
|
|
52
|
+
* @param remoteName - Name of the remote
|
|
51
53
|
* @param config - Channel configuration including type and parameters
|
|
52
54
|
* @param cursorStorage - Storage for persisting synchronization cursors
|
|
53
55
|
* @returns A new channel instance
|
|
54
56
|
*/
|
|
55
|
-
instance(config: ChannelConfig, cursorStorage: ISyncCursorStorage): IChannel;
|
|
57
|
+
instance(remoteId: string, remoteName: string, config: ChannelConfig, cursorStorage: ISyncCursorStorage): IChannel;
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* Represents a configured remote with an active channel.
|
|
@@ -61,6 +63,10 @@ export interface IChannelFactory {
|
|
|
61
63
|
* The remote name is used as a unique identifier across the system.
|
|
62
64
|
*/
|
|
63
65
|
export type Remote = {
|
|
66
|
+
/**
|
|
67
|
+
* Unique identifier for this remote.
|
|
68
|
+
*/
|
|
69
|
+
id: string;
|
|
64
70
|
/**
|
|
65
71
|
* Unique name for this remote.
|
|
66
72
|
*/
|
|
@@ -113,7 +119,15 @@ export interface ISyncManager {
|
|
|
113
119
|
* @returns The remote
|
|
114
120
|
* @throws Error if the remote does not exist
|
|
115
121
|
*/
|
|
116
|
-
|
|
122
|
+
getByName(name: string): Remote;
|
|
123
|
+
/**
|
|
124
|
+
* Gets a remote by ID.
|
|
125
|
+
*
|
|
126
|
+
* @param id - The ID of the remote
|
|
127
|
+
* @returns The remote
|
|
128
|
+
* @throws Error if the remote does not exist
|
|
129
|
+
*/
|
|
130
|
+
getById(id: string): Remote;
|
|
117
131
|
/**
|
|
118
132
|
* Adds a new remote and starts its channel.
|
|
119
133
|
*
|
|
@@ -125,10 +139,11 @@ export interface ISyncManager {
|
|
|
125
139
|
* @param channelConfig - Configuration for the channel type and parameters
|
|
126
140
|
* @param filter - Optional filter for operations (defaults to no filtering)
|
|
127
141
|
* @param options - Optional remote configuration options
|
|
142
|
+
* @param id - Optional ID for the remote (generated if not provided)
|
|
128
143
|
* @returns Promise that resolves with the created remote
|
|
129
144
|
* @throws Error if a remote with this name already exists
|
|
130
145
|
*/
|
|
131
|
-
add(name: string, collectionId: string, channelConfig: ChannelConfig, filter?: RemoteFilter, options?: RemoteOptions): Promise<Remote>;
|
|
146
|
+
add(name: string, collectionId: string, channelConfig: ChannelConfig, filter?: RemoteFilter, options?: RemoteOptions, id?: string): Promise<Remote>;
|
|
132
147
|
/**
|
|
133
148
|
* Removes a remote and stops its channel.
|
|
134
149
|
*
|