velocious 1.0.672 → 1.0.673
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/README.md +1 -1
- package/build/database/drivers/base.js +52 -18
- package/build/database/drivers/mssql/index.js +48 -3
- package/build/src/database/drivers/base.d.ts +23 -0
- package/build/src/database/drivers/base.d.ts.map +1 -1
- package/build/src/database/drivers/base.js +51 -21
- package/build/src/database/drivers/mssql/index.d.ts +22 -0
- package/build/src/database/drivers/mssql/index.d.ts.map +1 -1
- package/build/src/database/drivers/mssql/index.js +45 -4
- package/build/src/sync/local-mutation-log.d.ts +12 -0
- package/build/src/sync/local-mutation-log.d.ts.map +1 -1
- package/build/src/sync/local-mutation-log.js +45 -1
- package/build/src/sync/sync-api-client.d.ts +6 -1
- package/build/src/sync/sync-api-client.d.ts.map +1 -1
- package/build/src/sync/sync-api-client.js +7 -2
- package/build/src/sync/sync-client.d.ts +60 -0
- package/build/src/sync/sync-client.d.ts.map +1 -1
- package/build/src/sync/sync-client.js +172 -3
- package/build/src/sync/sync-coordinator-types.d.ts +190 -0
- package/build/src/sync/sync-coordinator-types.d.ts.map +1 -0
- package/build/src/sync/sync-coordinator-types.js +65 -0
- package/build/src/sync/sync-coordinator.d.ts +246 -0
- package/build/src/sync/sync-coordinator.d.ts.map +1 -0
- package/build/src/sync/sync-coordinator.js +683 -0
- package/build/src/sync/sync-envelope-replay-service.d.ts +90 -2
- package/build/src/sync/sync-envelope-replay-service.d.ts.map +1 -1
- package/build/src/sync/sync-envelope-replay-service.js +101 -9
- package/build/src/sync/sync-realtime-bridge.d.ts.map +1 -1
- package/build/src/sync/sync-realtime-bridge.js +8 -1
- package/build/sync/local-mutation-log.js +53 -0
- package/build/sync/sync-api-client.js +7 -1
- package/build/sync/sync-client.js +190 -2
- package/build/sync/sync-coordinator-types.js +73 -0
- package/build/sync/sync-coordinator.js +738 -0
- package/build/sync/sync-envelope-replay-service.js +107 -8
- package/build/sync/sync-realtime-bridge.js +9 -0
- package/package.json +1 -1
- package/src/database/drivers/base.js +52 -18
- package/src/database/drivers/mssql/index.js +48 -3
- package/src/sync/local-mutation-log.js +53 -0
- package/src/sync/sync-api-client.js +7 -1
- package/src/sync/sync-client.js +190 -2
- package/src/sync/sync-coordinator-types.js +73 -0
- package/src/sync/sync-coordinator.js +738 -0
- package/src/sync/sync-envelope-replay-service.js +107 -8
- package/src/sync/sync-realtime-bridge.js +9 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
export type SyncCoordinatorState = "backoff" | "conflicted" | "failed" | "idle" | "offline" | "pending" | "stopped" | "syncing";
|
|
2
|
+
export type SyncConflictDiagnostic = {
|
|
3
|
+
/**
|
|
4
|
+
* - Version the local mutation was based on.
|
|
5
|
+
*/
|
|
6
|
+
baseVersion: string | number | null;
|
|
7
|
+
/**
|
|
8
|
+
* - Durable client idempotency identifier.
|
|
9
|
+
*/
|
|
10
|
+
clientMutationId: string;
|
|
11
|
+
/**
|
|
12
|
+
* - Optional client version returned by the conflict contract.
|
|
13
|
+
*/
|
|
14
|
+
localVersion: string | number | null;
|
|
15
|
+
/**
|
|
16
|
+
* - Durable local mutation-log record id.
|
|
17
|
+
*/
|
|
18
|
+
recordId: string;
|
|
19
|
+
/**
|
|
20
|
+
* - Stable resource identifier.
|
|
21
|
+
*/
|
|
22
|
+
resourceId: string;
|
|
23
|
+
/**
|
|
24
|
+
* - Stable resource/model type.
|
|
25
|
+
*/
|
|
26
|
+
resourceType: string;
|
|
27
|
+
/**
|
|
28
|
+
* - Authoritative server version.
|
|
29
|
+
*/
|
|
30
|
+
serverVersion: string | number | null;
|
|
31
|
+
/**
|
|
32
|
+
* - Authoritative version attribute name.
|
|
33
|
+
*/
|
|
34
|
+
versionAttribute: string | null;
|
|
35
|
+
};
|
|
36
|
+
export type SyncCoordinatorFailure = {
|
|
37
|
+
/**
|
|
38
|
+
* - Consecutive cycle attempt number.
|
|
39
|
+
*/
|
|
40
|
+
attempt: number;
|
|
41
|
+
/**
|
|
42
|
+
* - ISO timestamp of the failure.
|
|
43
|
+
*/
|
|
44
|
+
at: string;
|
|
45
|
+
/**
|
|
46
|
+
* - Stable safe error code.
|
|
47
|
+
*/
|
|
48
|
+
code: string;
|
|
49
|
+
/**
|
|
50
|
+
* - Optional safe display message.
|
|
51
|
+
*/
|
|
52
|
+
message?: string;
|
|
53
|
+
/**
|
|
54
|
+
* - Whether automatic retry is allowed.
|
|
55
|
+
*/
|
|
56
|
+
retryable: boolean;
|
|
57
|
+
};
|
|
58
|
+
export type SyncCoordinatorStatus = {
|
|
59
|
+
/**
|
|
60
|
+
* - Privacy-safe unresolved conflicts.
|
|
61
|
+
*/
|
|
62
|
+
conflicts: ReadonlyArray<SyncConflictDiagnostic>;
|
|
63
|
+
/**
|
|
64
|
+
* - Last unresolved cycle failure.
|
|
65
|
+
*/
|
|
66
|
+
failure: SyncCoordinatorFailure | null;
|
|
67
|
+
/**
|
|
68
|
+
* - Last successful online cycle timestamp.
|
|
69
|
+
*/
|
|
70
|
+
lastSuccessAt: string | null;
|
|
71
|
+
/**
|
|
72
|
+
* - Scheduled automatic retry timestamp.
|
|
73
|
+
*/
|
|
74
|
+
nextRetryAt: string | null;
|
|
75
|
+
/**
|
|
76
|
+
* - Durable pending mutation count.
|
|
77
|
+
*/
|
|
78
|
+
pendingCount: number;
|
|
79
|
+
/**
|
|
80
|
+
* - Durable permanently rejected mutation count.
|
|
81
|
+
*/
|
|
82
|
+
rejectedCount: number;
|
|
83
|
+
/**
|
|
84
|
+
* - Observable lifecycle state.
|
|
85
|
+
*/
|
|
86
|
+
state: SyncCoordinatorState;
|
|
87
|
+
};
|
|
88
|
+
export type SyncClientInspection = {
|
|
89
|
+
/**
|
|
90
|
+
* - Privacy-safe conflict diagnostics.
|
|
91
|
+
*/
|
|
92
|
+
conflicts: ReadonlyArray<SyncConflictDiagnostic>;
|
|
93
|
+
/**
|
|
94
|
+
* - Durable pending mutation count.
|
|
95
|
+
*/
|
|
96
|
+
pendingCount: number;
|
|
97
|
+
/**
|
|
98
|
+
* - Durable rejected mutation count.
|
|
99
|
+
*/
|
|
100
|
+
rejectedCount: number;
|
|
101
|
+
};
|
|
102
|
+
export type SyncCoordinatorConnectivity = {
|
|
103
|
+
/**
|
|
104
|
+
* - Subscribes to connectivity changes.
|
|
105
|
+
*/
|
|
106
|
+
subscribe: (listener: (online: boolean) => void) => (() => void);
|
|
107
|
+
};
|
|
108
|
+
export type SyncCoordinatorScheduler = {
|
|
109
|
+
/**
|
|
110
|
+
* - Clears a scheduled retry.
|
|
111
|
+
*/
|
|
112
|
+
clearTimeout: (timer: unknown) => void;
|
|
113
|
+
/**
|
|
114
|
+
* - Schedules a retry.
|
|
115
|
+
*/
|
|
116
|
+
setTimeout: (callback: () => void, delayMs: number) => unknown;
|
|
117
|
+
};
|
|
118
|
+
export type SyncCoordinatorStatusStore = {
|
|
119
|
+
/**
|
|
120
|
+
* - Loads the last safe snapshot.
|
|
121
|
+
*/
|
|
122
|
+
load: () => Promise<SyncCoordinatorStatus | null> | SyncCoordinatorStatus | null;
|
|
123
|
+
/**
|
|
124
|
+
* - Persists one safe snapshot.
|
|
125
|
+
*/
|
|
126
|
+
save: (status: SyncCoordinatorStatus) => Promise<void> | void;
|
|
127
|
+
};
|
|
128
|
+
/** @typedef {"backoff" | "conflicted" | "failed" | "idle" | "offline" | "pending" | "stopped" | "syncing"} SyncCoordinatorState */
|
|
129
|
+
/**
|
|
130
|
+
* Privacy-safe conflict metadata for status surfaces. Mutation attributes,
|
|
131
|
+
* authoritative record data, credentials, and rejection reasons are excluded.
|
|
132
|
+
* @typedef {object} SyncConflictDiagnostic
|
|
133
|
+
* @property {string | number | null} baseVersion - Version the local mutation was based on.
|
|
134
|
+
* @property {string} clientMutationId - Durable client idempotency identifier.
|
|
135
|
+
* @property {string | number | null} localVersion - Optional client version returned by the conflict contract.
|
|
136
|
+
* @property {string} recordId - Durable local mutation-log record id.
|
|
137
|
+
* @property {string} resourceId - Stable resource identifier.
|
|
138
|
+
* @property {string} resourceType - Stable resource/model type.
|
|
139
|
+
* @property {string | number | null} serverVersion - Authoritative server version.
|
|
140
|
+
* @property {string | null} versionAttribute - Authoritative version attribute name.
|
|
141
|
+
*/
|
|
142
|
+
/**
|
|
143
|
+
* Safe classified failure metadata. Applications own the classifier and must
|
|
144
|
+
* return only user-safe codes/messages; the original Error is never persisted.
|
|
145
|
+
* @typedef {object} SyncCoordinatorFailure
|
|
146
|
+
* @property {number} attempt - Consecutive cycle attempt number.
|
|
147
|
+
* @property {string} at - ISO timestamp of the failure.
|
|
148
|
+
* @property {string} code - Stable safe error code.
|
|
149
|
+
* @property {string} [message] - Optional safe display message.
|
|
150
|
+
* @property {boolean} retryable - Whether automatic retry is allowed.
|
|
151
|
+
*/
|
|
152
|
+
/**
|
|
153
|
+
* Immutable coordinator status snapshot.
|
|
154
|
+
* @typedef {object} SyncCoordinatorStatus
|
|
155
|
+
* @property {ReadonlyArray<SyncConflictDiagnostic>} conflicts - Privacy-safe unresolved conflicts.
|
|
156
|
+
* @property {SyncCoordinatorFailure | null} failure - Last unresolved cycle failure.
|
|
157
|
+
* @property {string | null} lastSuccessAt - Last successful online cycle timestamp.
|
|
158
|
+
* @property {string | null} nextRetryAt - Scheduled automatic retry timestamp.
|
|
159
|
+
* @property {number} pendingCount - Durable pending mutation count.
|
|
160
|
+
* @property {number} rejectedCount - Durable permanently rejected mutation count.
|
|
161
|
+
* @property {SyncCoordinatorState} state - Observable lifecycle state.
|
|
162
|
+
*/
|
|
163
|
+
/**
|
|
164
|
+
* Durable sync state reported by SyncClient.
|
|
165
|
+
* @typedef {object} SyncClientInspection
|
|
166
|
+
* @property {ReadonlyArray<SyncConflictDiagnostic>} conflicts - Privacy-safe conflict diagnostics.
|
|
167
|
+
* @property {number} pendingCount - Durable pending mutation count.
|
|
168
|
+
* @property {number} rejectedCount - Durable rejected mutation count.
|
|
169
|
+
*/
|
|
170
|
+
/**
|
|
171
|
+
* Application connectivity signal adapter. SyncClient remains the authority
|
|
172
|
+
* for the current online check; this adapter only notifies the coordinator.
|
|
173
|
+
* @typedef {object} SyncCoordinatorConnectivity
|
|
174
|
+
* @property {(listener: (online: boolean) => void) => (() => void)} subscribe - Subscribes to connectivity changes.
|
|
175
|
+
*/
|
|
176
|
+
/**
|
|
177
|
+
* Injected timer ownership for deterministic retry tests and teardown.
|
|
178
|
+
* @typedef {object} SyncCoordinatorScheduler
|
|
179
|
+
* @property {(timer: unknown) => void} clearTimeout - Clears a scheduled retry.
|
|
180
|
+
* @property {(callback: () => void, delayMs: number) => unknown} setTimeout - Schedules a retry.
|
|
181
|
+
*/
|
|
182
|
+
/**
|
|
183
|
+
* Optional durable status metadata store. Conflict payloads remain owned by
|
|
184
|
+
* LocalMutationLog; this store receives only privacy-safe snapshots.
|
|
185
|
+
* @typedef {object} SyncCoordinatorStatusStore
|
|
186
|
+
* @property {() => Promise<SyncCoordinatorStatus | null> | SyncCoordinatorStatus | null} load - Loads the last safe snapshot.
|
|
187
|
+
* @property {(status: SyncCoordinatorStatus) => Promise<void> | void} save - Persists one safe snapshot.
|
|
188
|
+
*/
|
|
189
|
+
export {};
|
|
190
|
+
//# sourceMappingURL=sync-coordinator-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-coordinator-types.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-coordinator-types.js"],"names":[],"mappings":"AAGI,YAAwG,oBAAoB,GAAlH,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAsB;AAK7H,YAAkB,sBAAsB,GACxC;;;;IAAmC,WAAW,EAAnC,MAAM,GAAG,MAAM,GAAG,IAAI,CACjC;;;;IAAmB,gBAAgB,EAAxB,MAAM,CACjB;;;;IAAmC,YAAY,EAApC,MAAM,GAAG,MAAM,GAAG,IAAI,CACjC;;;;IAAmB,QAAQ,EAAhB,MAAM,CACjB;;;;IA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,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAC/D;CAAA,CAAA;AAKE,YAAkB,0BAA0B,GAC5C;;;;IAAuF,IAAI,EAAhF,MAAM,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,GAAG,qBAAqB,GAAG,IAAI,CACrF;;;;IAAoE,IAAI,EAA7D,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CACpE;CAAA,CAAA;AAnED,mIAAmI;AAEnI;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAE,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/* eslint-disable jsdoc/no-undefined-types -- ReadonlyArray is a TypeScript utility type used by checkJs. */
|
|
3
|
+
/** @typedef {"backoff" | "conflicted" | "failed" | "idle" | "offline" | "pending" | "stopped" | "syncing"} SyncCoordinatorState */
|
|
4
|
+
/**
|
|
5
|
+
* Privacy-safe conflict metadata for status surfaces. Mutation attributes,
|
|
6
|
+
* authoritative record data, credentials, and rejection reasons are excluded.
|
|
7
|
+
* @typedef {object} SyncConflictDiagnostic
|
|
8
|
+
* @property {string | number | null} baseVersion - Version the local mutation was based on.
|
|
9
|
+
* @property {string} clientMutationId - Durable client idempotency identifier.
|
|
10
|
+
* @property {string | number | null} localVersion - Optional client version returned by the conflict contract.
|
|
11
|
+
* @property {string} recordId - Durable local mutation-log record id.
|
|
12
|
+
* @property {string} resourceId - Stable resource identifier.
|
|
13
|
+
* @property {string} resourceType - Stable resource/model type.
|
|
14
|
+
* @property {string | number | null} serverVersion - Authoritative server version.
|
|
15
|
+
* @property {string | null} versionAttribute - Authoritative version attribute name.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Safe classified failure metadata. Applications own the classifier and must
|
|
19
|
+
* return only user-safe codes/messages; the original Error is never persisted.
|
|
20
|
+
* @typedef {object} SyncCoordinatorFailure
|
|
21
|
+
* @property {number} attempt - Consecutive cycle attempt number.
|
|
22
|
+
* @property {string} at - ISO timestamp of the failure.
|
|
23
|
+
* @property {string} code - Stable safe error code.
|
|
24
|
+
* @property {string} [message] - Optional safe display message.
|
|
25
|
+
* @property {boolean} retryable - Whether automatic retry is allowed.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Immutable coordinator status snapshot.
|
|
29
|
+
* @typedef {object} SyncCoordinatorStatus
|
|
30
|
+
* @property {ReadonlyArray<SyncConflictDiagnostic>} conflicts - Privacy-safe unresolved conflicts.
|
|
31
|
+
* @property {SyncCoordinatorFailure | null} failure - Last unresolved cycle failure.
|
|
32
|
+
* @property {string | null} lastSuccessAt - Last successful online cycle timestamp.
|
|
33
|
+
* @property {string | null} nextRetryAt - Scheduled automatic retry timestamp.
|
|
34
|
+
* @property {number} pendingCount - Durable pending mutation count.
|
|
35
|
+
* @property {number} rejectedCount - Durable permanently rejected mutation count.
|
|
36
|
+
* @property {SyncCoordinatorState} state - Observable lifecycle state.
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Durable sync state reported by SyncClient.
|
|
40
|
+
* @typedef {object} SyncClientInspection
|
|
41
|
+
* @property {ReadonlyArray<SyncConflictDiagnostic>} conflicts - Privacy-safe conflict diagnostics.
|
|
42
|
+
* @property {number} pendingCount - Durable pending mutation count.
|
|
43
|
+
* @property {number} rejectedCount - Durable rejected mutation count.
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Application connectivity signal adapter. SyncClient remains the authority
|
|
47
|
+
* for the current online check; this adapter only notifies the coordinator.
|
|
48
|
+
* @typedef {object} SyncCoordinatorConnectivity
|
|
49
|
+
* @property {(listener: (online: boolean) => void) => (() => void)} subscribe - Subscribes to connectivity changes.
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Injected timer ownership for deterministic retry tests and teardown.
|
|
53
|
+
* @typedef {object} SyncCoordinatorScheduler
|
|
54
|
+
* @property {(timer: unknown) => void} clearTimeout - Clears a scheduled retry.
|
|
55
|
+
* @property {(callback: () => void, delayMs: number) => unknown} setTimeout - Schedules a retry.
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Optional durable status metadata store. Conflict payloads remain owned by
|
|
59
|
+
* LocalMutationLog; this store receives only privacy-safe snapshots.
|
|
60
|
+
* @typedef {object} SyncCoordinatorStatusStore
|
|
61
|
+
* @property {() => Promise<SyncCoordinatorStatus | null> | SyncCoordinatorStatus | null} load - Loads the last safe snapshot.
|
|
62
|
+
* @property {(status: SyncCoordinatorStatus) => Promise<void> | void} save - Persists one safe snapshot.
|
|
63
|
+
*/
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luYy1jb29yZGluYXRvci10eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zeW5jL3N5bmMtY29vcmRpbmF0b3ItdHlwZXMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsWUFBWTtBQUNaLDRHQUE0RztBQUU1RyxtSUFBbUk7QUFFbkk7Ozs7Ozs7Ozs7OztHQVlHO0FBRUg7Ozs7Ozs7OztHQVNHO0FBRUg7Ozs7Ozs7Ozs7R0FVRztBQUVIOzs7Ozs7R0FNRztBQUVIOzs7OztHQUtHO0FBRUg7Ozs7O0dBS0c7QUFFSDs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQUUsQ0FBQSIsInNvdXJjZXNDb250ZW50IjpbIi8vIEB0cy1jaGVja1xuLyogZXNsaW50LWRpc2FibGUganNkb2Mvbm8tdW5kZWZpbmVkLXR5cGVzIC0tIFJlYWRvbmx5QXJyYXkgaXMgYSBUeXBlU2NyaXB0I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lNczogbnVtYmVyKSA9PiB1bmtub3dufSBzZXRUaW1lb3V0IC0gU2NoZWR1bGVzIGEgcmV0cnkuXG4gKi9cblxuLyoqXG4gKiBPcHRpb25hbCBkdXJhYmxlIHN0YXR1cyBtZXRhZGF0YSBzdG9yZS4gQ29uZmxpY3QgcGF5bG9hZHMgcmVtYWluIG93bmVkIGJ5XG4gKiBMb2NhbE11dGF0aW9uTG9nOyB0aGlzIHN0b3JlIHJlY2VpdmVzIG9ubHkgcHJpdmFjeS1zYWZlIHNuYXBzaG90cy5cbiAqIEB0eXBlZGVmIHtvYmplY3R9IFN5bmNDb29yZGluYXRvclN0YXR1c1N0b3JlXG4gKiBAcHJvcGVydHkgeygpID0+IFByb21pc2U8U3luY0Nvb3JkaW5hdG9yU3RhdHVzIHwgbnVsbD4gfCBTeW5jQ29vcmRpbmF0b3JTdGF0dXMgfCBudWxsfSBsb2FkIC0gTG9hZHMgdGhlIGxhc3Qgc2FmZSBzbmFwc2hvdC5cbiAqIEBwcm9wZXJ0eSB7KHN0YXR1czogU3luY0Nvb3JkaW5hdG9yU3RhdHVzKSA9PiBQcm9taXNlPHZvaWQ+IHwgdm9pZH0gc2F2ZSAtIFBlcnNpc3RzIG9uZSBzYWZlIHNuYXBzaG90LlxuICovXG5cbmV4cG9ydCB7fVxuIl19
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/** Expected cooperative cancellation raised by a SyncCoordinator lifecycle transition. */
|
|
2
|
+
export declare class SyncCoordinatorLifecycleAbortError extends Error {
|
|
3
|
+
/**
|
|
4
|
+
* Creates a lifecycle cancellation error.
|
|
5
|
+
* @param {string} message - Cancellation reason.
|
|
6
|
+
*/
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Reusable observable lifecycle around SyncClient. It serializes replay,
|
|
11
|
+
* realtime subscription, and stable-cursor pull into one cycle; coalesces any
|
|
12
|
+
* triggers received during that cycle into one rerun; owns bounded retry; and
|
|
13
|
+
* generation-fences status updates after stop/restart.
|
|
14
|
+
*/
|
|
15
|
+
export default class SyncCoordinator {
|
|
16
|
+
syncClient: import("./sync-client.js").default;
|
|
17
|
+
classifyError: (error: Error) => {
|
|
18
|
+
code: string;
|
|
19
|
+
message?: string;
|
|
20
|
+
retryable: boolean;
|
|
21
|
+
};
|
|
22
|
+
connectivity: import("./sync-coordinator-types.js").SyncCoordinatorConnectivity | null;
|
|
23
|
+
now: () => Date;
|
|
24
|
+
prepare: (args: {
|
|
25
|
+
signal: AbortSignal;
|
|
26
|
+
syncClient: import("./sync-client.js").default;
|
|
27
|
+
}) => Promise<(() => Promise<void> | void) | void> | (() => Promise<void> | void) | void;
|
|
28
|
+
realtime: boolean;
|
|
29
|
+
retryPolicy: {
|
|
30
|
+
initialDelayMs: number;
|
|
31
|
+
maxAttempts: number;
|
|
32
|
+
maxDelayMs: number;
|
|
33
|
+
};
|
|
34
|
+
scheduler: import("./sync-coordinator-types.js").SyncCoordinatorScheduler;
|
|
35
|
+
statusStore: import("./sync-coordinator-types.js").SyncCoordinatorStatusStore | null;
|
|
36
|
+
_active: boolean;
|
|
37
|
+
_attempt: number;
|
|
38
|
+
_generation: number;
|
|
39
|
+
_lifecycleAbortController: AbortController;
|
|
40
|
+
/** @type {Set<(status: import("./sync-coordinator-types.js").SyncCoordinatorStatus) => void>} */
|
|
41
|
+
_listeners: Set<(status: import("./sync-coordinator-types.js").SyncCoordinatorStatus) => void>;
|
|
42
|
+
/** @type {Array<() => Promise<void> | void>} */
|
|
43
|
+
_lifecycleCleanups: Array<() => Promise<void> | void>;
|
|
44
|
+
/** @type {Promise<void> | null} */
|
|
45
|
+
_runPromise: Promise<void> | null;
|
|
46
|
+
_rerunRequested: boolean;
|
|
47
|
+
/** @type {unknown} */
|
|
48
|
+
_retryTimer: unknown;
|
|
49
|
+
/** @type {Promise<void> | null} */
|
|
50
|
+
_startPromise: Promise<void> | null;
|
|
51
|
+
/** @type {Promise<void> | null} */
|
|
52
|
+
_stopPromise: Promise<void> | null;
|
|
53
|
+
/** @type {import("./sync-coordinator-types.js").SyncCoordinatorStatus} */
|
|
54
|
+
_status: import("./sync-coordinator-types.js").SyncCoordinatorStatus;
|
|
55
|
+
/**
|
|
56
|
+
* Creates one reusable sync lifecycle owner.
|
|
57
|
+
* @param {object} args - Coordinator dependencies.
|
|
58
|
+
* @param {(error: Error) => {code: string, message?: string, retryable: boolean}} [args.classifyError] - Maps errors to safe retry/display metadata. Defaults to permanent `sync_failed` without persisting the error message.
|
|
59
|
+
* @param {import("./sync-coordinator-types.js").SyncCoordinatorConnectivity} [args.connectivity] - Optional connectivity event source.
|
|
60
|
+
* @param {() => Date} [args.now] - Injected clock.
|
|
61
|
+
* @param {(args: {signal: AbortSignal, syncClient: import("./sync-client.js").default}) => Promise<(() => Promise<void> | void) | void> | (() => Promise<void> | void) | void} [args.prepare] - Activates scopes/acquires app-owned resources before the first cycle and returns their teardown.
|
|
62
|
+
* @param {boolean} [args.realtime] - Whether cycles subscribe realtime before pulling. Defaults to true.
|
|
63
|
+
* @param {{initialDelayMs?: number, maxAttempts?: number, maxDelayMs?: number}} [args.retry] - Bounded automatic retry policy.
|
|
64
|
+
* @param {import("./sync-coordinator-types.js").SyncCoordinatorScheduler} [args.scheduler] - Injected timer owner.
|
|
65
|
+
* @param {import("./sync-coordinator-types.js").SyncCoordinatorStatusStore} [args.statusStore] - Optional privacy-safe durable status store.
|
|
66
|
+
* @param {import("./sync-client.js").default} args.syncClient - SyncClient owning queue, scopes, cursors, apply, and realtime.
|
|
67
|
+
*/
|
|
68
|
+
constructor({ classifyError, connectivity, now, prepare, realtime, retry, scheduler, statusStore, syncClient, ...restArgs }: {
|
|
69
|
+
classifyError?: (error: Error) => {
|
|
70
|
+
code: string;
|
|
71
|
+
message?: string;
|
|
72
|
+
retryable: boolean;
|
|
73
|
+
};
|
|
74
|
+
connectivity?: import("./sync-coordinator-types.js").SyncCoordinatorConnectivity;
|
|
75
|
+
now?: () => Date;
|
|
76
|
+
prepare?: (args: {
|
|
77
|
+
signal: AbortSignal;
|
|
78
|
+
syncClient: import("./sync-client.js").default;
|
|
79
|
+
}) => Promise<(() => Promise<void> | void) | void> | (() => Promise<void> | void) | void;
|
|
80
|
+
realtime?: boolean;
|
|
81
|
+
retry?: {
|
|
82
|
+
initialDelayMs?: number;
|
|
83
|
+
maxAttempts?: number;
|
|
84
|
+
maxDelayMs?: number;
|
|
85
|
+
};
|
|
86
|
+
scheduler?: import("./sync-coordinator-types.js").SyncCoordinatorScheduler;
|
|
87
|
+
statusStore?: import("./sync-coordinator-types.js").SyncCoordinatorStatusStore;
|
|
88
|
+
syncClient: import("./sync-client.js").default;
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* Installs local ownership and schedules the initial network cycle without
|
|
92
|
+
* awaiting it, so cached reads never depend on network completion.
|
|
93
|
+
* @returns {Promise<void>} - Resolves after local ownership is installed.
|
|
94
|
+
*/
|
|
95
|
+
start(): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Starts one lifecycle generation with rollback on failure.
|
|
98
|
+
* @param {number} generation - Owning generation.
|
|
99
|
+
* @returns {Promise<void>} - Resolves after activation completes.
|
|
100
|
+
*/
|
|
101
|
+
_start(generation: number): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Acquires coordinator, connectivity, client, and application resources.
|
|
104
|
+
* @param {number} generation - Owning generation.
|
|
105
|
+
* @returns {Promise<void>} - Resolves after every owner is active.
|
|
106
|
+
*/
|
|
107
|
+
_activate(generation: number): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Releases every partially acquired owner after a failed start, publishes a
|
|
110
|
+
* safe terminal failure, and rethrows the original error (or an aggregate if
|
|
111
|
+
* teardown also failed).
|
|
112
|
+
* @param {Error} error - Start failure.
|
|
113
|
+
* @param {number} generation - Failed generation.
|
|
114
|
+
* @returns {Promise<never>} - Always rejects with the start or aggregate error.
|
|
115
|
+
*/
|
|
116
|
+
_rollbackFailedStart(error: Error, generation: number): Promise<never>;
|
|
117
|
+
/**
|
|
118
|
+
* Stops current work, clears timers/listeners, drains SyncClient, and releases
|
|
119
|
+
* app-owned resources exactly once.
|
|
120
|
+
* @returns {Promise<void>} - Resolves after the lifecycle is fully stopped.
|
|
121
|
+
*/
|
|
122
|
+
stop(): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Drains captured lifecycle resources after a stop transition.
|
|
125
|
+
* @param {{cleanups: Array<() => Promise<void> | void>, runPromise: Promise<void> | null, startPromise: Promise<void> | null}} args - Captured generation resources.
|
|
126
|
+
* @returns {Promise<void>} - Resolves after teardown completes.
|
|
127
|
+
*/
|
|
128
|
+
_stop({ cleanups, runPromise, startPromise }: {
|
|
129
|
+
cleanups: Array<() => Promise<void> | void>;
|
|
130
|
+
runPromise: Promise<void> | null;
|
|
131
|
+
startPromise: Promise<void> | null;
|
|
132
|
+
}): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Requests a cycle. Overlapping requests share the active flight and produce
|
|
135
|
+
* at most one queued rerun.
|
|
136
|
+
* @param {string} [reason] - Diagnostic trigger label (never persisted).
|
|
137
|
+
* @returns {Promise<void>} - Resolves after the current or queued cycle drains.
|
|
138
|
+
*/
|
|
139
|
+
trigger(reason?: string): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Starts requested work only after lifecycle preparation has completed.
|
|
142
|
+
* @returns {Promise<void>} - Current or newly started coordinator flight.
|
|
143
|
+
*/
|
|
144
|
+
_startRequestedRun(): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Clears backoff and requests one single-flight user retry.
|
|
147
|
+
* @returns {Promise<void>} - Resolves after the retry cycle drains.
|
|
148
|
+
*/
|
|
149
|
+
retry(): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Resolves one durable conflict through SyncClient, then refreshes status and
|
|
152
|
+
* replays retry-local intent through the same cycle.
|
|
153
|
+
* @param {{recordId: string, resolution: "keep-server" | "retry-local", resourceType: string}} args - Explicit resolution.
|
|
154
|
+
* @returns {Promise<void>} - Resolves after resolution state is refreshed.
|
|
155
|
+
*/
|
|
156
|
+
resolveConflict(args: {
|
|
157
|
+
recordId: string;
|
|
158
|
+
resolution: "keep-server" | "retry-local";
|
|
159
|
+
resourceType: string;
|
|
160
|
+
}): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Drains requested work serially for one lifecycle generation.
|
|
163
|
+
* @param {number} generation - Owning generation.
|
|
164
|
+
* @returns {Promise<void>} - Resolves when no immediate rerun remains.
|
|
165
|
+
*/
|
|
166
|
+
_drain(generation: number): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Runs one replay, realtime-subscribe, and pull cycle.
|
|
169
|
+
* @param {number} generation - Owning generation.
|
|
170
|
+
* @returns {Promise<void>} - Resolves after this cycle settles.
|
|
171
|
+
*/
|
|
172
|
+
_runCycle(generation: number): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Publishes a classified failure and owns its bounded retry timer.
|
|
175
|
+
* @param {Error} error - Cycle failure.
|
|
176
|
+
* @param {number} generation - Owning generation.
|
|
177
|
+
* @returns {Promise<void>} - Resolves after status persistence and scheduling.
|
|
178
|
+
*/
|
|
179
|
+
_handleFailure(error: Error, generation: number): Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* Persists the current safe status for an active generation.
|
|
182
|
+
* @param {number} generation - Owning generation.
|
|
183
|
+
* @returns {Promise<void>} - Resolves after persistence.
|
|
184
|
+
*/
|
|
185
|
+
_persistStatus(generation: number): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Coalesces one connectivity change into the coordinator cycle.
|
|
188
|
+
* @param {{generation: number, online: boolean}} args - Connectivity event.
|
|
189
|
+
* @returns {void}
|
|
190
|
+
*/
|
|
191
|
+
_connectivityChanged({ generation, online }: {
|
|
192
|
+
generation: number;
|
|
193
|
+
online: boolean;
|
|
194
|
+
}): void;
|
|
195
|
+
/**
|
|
196
|
+
* Clears the currently owned retry timer, if present.
|
|
197
|
+
* @returns {void}
|
|
198
|
+
*/
|
|
199
|
+
_clearRetryTimer(): void;
|
|
200
|
+
/**
|
|
201
|
+
* Checks whether a lifecycle generation still owns state updates.
|
|
202
|
+
* @param {number} generation - Expected generation.
|
|
203
|
+
* @returns {boolean} - Whether the generation is current and active.
|
|
204
|
+
*/
|
|
205
|
+
_ownsGeneration(generation: number): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Fails when work no longer belongs to the active generation.
|
|
208
|
+
* @param {number} generation - Expected generation.
|
|
209
|
+
* @returns {void}
|
|
210
|
+
*/
|
|
211
|
+
_assertActive(generation: number): void;
|
|
212
|
+
/**
|
|
213
|
+
* Identifies coordinator-owned cooperative cancellation.
|
|
214
|
+
* @param {unknown} error - Candidate error.
|
|
215
|
+
* @returns {boolean} - Whether this coordinator created the abort error.
|
|
216
|
+
*/
|
|
217
|
+
isLifecycleAbort(error: unknown): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Reads and validates the injected clock.
|
|
220
|
+
* @returns {string} - Valid ISO clock value.
|
|
221
|
+
*/
|
|
222
|
+
_nowIso(): string;
|
|
223
|
+
/**
|
|
224
|
+
* Freezes and publishes a new observable snapshot.
|
|
225
|
+
* @param {import("./sync-coordinator-types.js").SyncCoordinatorStatus} status - New status.
|
|
226
|
+
* @returns {void}
|
|
227
|
+
*/
|
|
228
|
+
_publish(status: import("./sync-coordinator-types.js").SyncCoordinatorStatus): void;
|
|
229
|
+
/**
|
|
230
|
+
* Returns the current observable snapshot.
|
|
231
|
+
* @returns {import("./sync-coordinator-types.js").SyncCoordinatorStatus} - Current immutable snapshot.
|
|
232
|
+
*/
|
|
233
|
+
status(): import("./sync-coordinator-types.js").SyncCoordinatorStatus;
|
|
234
|
+
/**
|
|
235
|
+
* Observes status and receives the current snapshot immediately.
|
|
236
|
+
* @param {(status: import("./sync-coordinator-types.js").SyncCoordinatorStatus) => void} listener - Observer.
|
|
237
|
+
* @returns {() => void} - Idempotent unsubscribe.
|
|
238
|
+
*/
|
|
239
|
+
subscribe(listener: (status: import("./sync-coordinator-types.js").SyncCoordinatorStatus) => void): () => void;
|
|
240
|
+
/**
|
|
241
|
+
* Awaits only the active or queued cycle, not a future backoff timer.
|
|
242
|
+
* @returns {Promise<void>} - Resolves when current work drains.
|
|
243
|
+
*/
|
|
244
|
+
waitForCurrentRun(): Promise<void>;
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=sync-coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-coordinator.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-coordinator.js"],"names":[],"mappings":"AAOA,0FAA0F;AAC1F,qBAAa,kCAAmC,SAAQ,KAAK;IAC3D;;;OAGG;IACH,YAAY,OAAO,EAFR,MAEQ,EAGlB;CACF;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IA6B3B,UAAU;IACV,aAAa,UA1BD,KAAK,KAAK;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAC;IA2B1E,YAAY;IACZ,GAAG,QA1BO,IAAI;IA2Bd,OAAO,SA1BI;QAAC,MAAM,EAAE,WAAW,CAAC;QAAC,UAAU,EAAE,OAAO,kBAAkB,EAAE,OAAO,CAAA;KAAC,KAAK,OAAO,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI;IA2BvK,QAAQ;IACR,WAAW;wBAgiBU,MAAM;qBAAe,MAAM;oBAAc,MAAM;;IA/hBpE,SAAS;IACT,WAAW;IAEX,OAAO;IACP,QAAQ;IACR,WAAW;IACX,yBAAyB;IAC9B,iGAAiG;IAC5F,UAAU,EADJ,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,6BAA6B,EA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