lakesync 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/adapter-types-DwsQGQS4.d.ts +94 -0
  2. package/dist/adapter.d.ts +202 -63
  3. package/dist/adapter.js +20 -5
  4. package/dist/analyst.js +2 -2
  5. package/dist/{base-poller-BpUyuG2R.d.ts → base-poller-Y7ORYgUv.d.ts} +78 -19
  6. package/dist/catalogue.d.ts +1 -1
  7. package/dist/catalogue.js +3 -3
  8. package/dist/{chunk-P3FT7QCW.js → chunk-4SG66H5K.js} +395 -252
  9. package/dist/chunk-4SG66H5K.js.map +1 -0
  10. package/dist/{chunk-GUJWMK5P.js → chunk-C4KD6YKP.js} +419 -380
  11. package/dist/chunk-C4KD6YKP.js.map +1 -0
  12. package/dist/chunk-DGUM43GV.js +11 -0
  13. package/dist/{chunk-IRJ4QRWV.js → chunk-FIIHPQMQ.js} +396 -209
  14. package/dist/chunk-FIIHPQMQ.js.map +1 -0
  15. package/dist/{chunk-UAUQGP3B.js → chunk-U2NV4DUX.js} +2 -2
  16. package/dist/{chunk-NCZYFZ3B.js → chunk-XVP5DJJ7.js} +44 -18
  17. package/dist/{chunk-NCZYFZ3B.js.map → chunk-XVP5DJJ7.js.map} +1 -1
  18. package/dist/{chunk-FHVTUKXL.js → chunk-YHYBLU6W.js} +2 -2
  19. package/dist/{chunk-QMS7TGFL.js → chunk-ZNY4DSFU.js} +29 -15
  20. package/dist/{chunk-QMS7TGFL.js.map → chunk-ZNY4DSFU.js.map} +1 -1
  21. package/dist/{chunk-SF7Y6ZUA.js → chunk-ZU7RC7CT.js} +2 -2
  22. package/dist/client.d.ts +186 -17
  23. package/dist/client.js +456 -188
  24. package/dist/client.js.map +1 -1
  25. package/dist/compactor.d.ts +2 -2
  26. package/dist/compactor.js +4 -4
  27. package/dist/connector-jira.d.ts +13 -3
  28. package/dist/connector-jira.js +7 -3
  29. package/dist/connector-salesforce.d.ts +13 -3
  30. package/dist/connector-salesforce.js +7 -3
  31. package/dist/{coordinator-D32a5rNk.d.ts → coordinator-eGmZMnJ_.d.ts} +120 -30
  32. package/dist/create-poller-Cc2MGfhh.d.ts +55 -0
  33. package/dist/factory-DFfR-030.d.ts +33 -0
  34. package/dist/gateway-server.d.ts +516 -119
  35. package/dist/gateway-server.js +1201 -4035
  36. package/dist/gateway-server.js.map +1 -1
  37. package/dist/gateway.d.ts +69 -106
  38. package/dist/gateway.js +13 -6
  39. package/dist/index.d.ts +65 -58
  40. package/dist/index.js +18 -4
  41. package/dist/parquet.d.ts +1 -1
  42. package/dist/parquet.js +3 -3
  43. package/dist/proto.d.ts +1 -1
  44. package/dist/proto.js +3 -3
  45. package/dist/react.d.ts +47 -10
  46. package/dist/react.js +88 -40
  47. package/dist/react.js.map +1 -1
  48. package/dist/{registry-CPTgO9jv.d.ts → registry-Dd8JuW8T.d.ts} +19 -4
  49. package/dist/{gateway-Bpvatd9n.d.ts → request-handler-B1I5xDOx.d.ts} +193 -20
  50. package/dist/{resolver-CbuXm3nB.d.ts → resolver-CXxmC0jR.d.ts} +1 -1
  51. package/dist/{src-RHKJFQKR.js → src-WU7IBVC4.js} +19 -5
  52. package/dist/{types-CLlD4XOy.d.ts → types-BdGBv2ba.d.ts} +17 -2
  53. package/dist/{types-D-E0VrfS.d.ts → types-D2C9jTbL.d.ts} +39 -22
  54. package/package.json +1 -1
  55. package/dist/auth-CAVutXzx.d.ts +0 -30
  56. package/dist/chunk-7D4SUZUM.js +0 -38
  57. package/dist/chunk-GUJWMK5P.js.map +0 -1
  58. package/dist/chunk-IRJ4QRWV.js.map +0 -1
  59. package/dist/chunk-P3FT7QCW.js.map +0 -1
  60. package/dist/db-types-BlN-4KbQ.d.ts +0 -29
  61. package/dist/src-CLCALYDT.js +0 -25
  62. package/dist/src-FPJQYQNA.js +0 -27
  63. package/dist/src-FPJQYQNA.js.map +0 -1
  64. package/dist/src-RHKJFQKR.js.map +0 -1
  65. package/dist/types-DSC_EiwR.d.ts +0 -45
  66. /package/dist/{chunk-7D4SUZUM.js.map → chunk-DGUM43GV.js.map} +0 -0
  67. /package/dist/{chunk-UAUQGP3B.js.map → chunk-U2NV4DUX.js.map} +0 -0
  68. /package/dist/{chunk-FHVTUKXL.js.map → chunk-YHYBLU6W.js.map} +0 -0
  69. /package/dist/{chunk-SF7Y6ZUA.js.map → chunk-ZU7RC7CT.js.map} +0 -0
  70. /package/dist/{src-CLCALYDT.js.map → src-WU7IBVC4.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { H as HLCTimestamp, R as Result, L as LakeSyncError, F as FlushError } from './result-CojzlFE2.js';
2
- import { T as TableSchema } from './types-CLlD4XOy.js';
3
- import { L as LakeAdapter } from './types-DSC_EiwR.js';
2
+ import { L as LakeAdapter } from './adapter-types-DwsQGQS4.js';
3
+ import { T as TableSchema } from './types-BdGBv2ba.js';
4
4
 
5
5
  /** Configuration for checkpoint generation */
6
6
  interface CheckpointConfig {
package/dist/compactor.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  encodeSyncResponse
3
- } from "./chunk-FHVTUKXL.js";
3
+ } from "./chunk-YHYBLU6W.js";
4
4
  import {
5
5
  readParquetToDeltas,
6
6
  writeDeltasToParquet
7
- } from "./chunk-SF7Y6ZUA.js";
7
+ } from "./chunk-ZU7RC7CT.js";
8
8
  import {
9
9
  Err,
10
10
  FlushError,
@@ -12,8 +12,8 @@ import {
12
12
  LakeSyncError,
13
13
  Ok,
14
14
  rowKey
15
- } from "./chunk-P3FT7QCW.js";
16
- import "./chunk-7D4SUZUM.js";
15
+ } from "./chunk-4SG66H5K.js";
16
+ import "./chunk-DGUM43GV.js";
17
17
 
18
18
  // ../compactor/src/checkpoint-generator.ts
19
19
  var DEFAULT_CHECKPOINT_CONFIG = {
@@ -1,6 +1,7 @@
1
+ import { B as BaseSourcePoller, P as PushTarget } from './base-poller-Y7ORYgUv.js';
2
+ import { C as ConnectorConfig } from './types-D2C9jTbL.js';
3
+ import { T as TableSchema } from './types-BdGBv2ba.js';
1
4
  import { L as LakeSyncError, R as Result } from './result-CojzlFE2.js';
2
- import { B as BaseSourcePoller, P as PushTarget } from './base-poller-BpUyuG2R.js';
3
- import { T as TableSchema } from './types-CLlD4XOy.js';
4
5
  import './hlc-DiD8QNG3.js';
5
6
 
6
7
  /** HTTP error from the Jira REST API. */
@@ -228,4 +229,13 @@ declare const JIRA_TABLE_SCHEMAS: ReadonlyArray<TableSchema>;
228
229
  */
229
230
  declare function testConnection(config: JiraConnectorConfig): Promise<Result<void, JiraApiError | JiraRateLimitError>>;
230
231
 
231
- export { JIRA_TABLE_SCHEMAS, JiraApiError, JiraClient, type JiraComment, type JiraCommentPage, type JiraConnectorConfig, type JiraIngestConfig, type JiraIssue, type JiraProject, type JiraProjectPage, JiraRateLimitError, type JiraSearchResponse, JiraSourcePoller, mapComment, mapIssue, mapProject, testConnection };
232
+ /**
233
+ * Poller factory for Jira connectors.
234
+ *
235
+ * Register with a {@link import("@lakesync/core").PollerRegistry} via `.with("jira", jiraPollerFactory)`.
236
+ */
237
+ declare function jiraPollerFactory(config: ConnectorConfig, gateway: PushTarget): BaseSourcePoller;
238
+ /** @deprecated Use {@link jiraPollerFactory} instead. */
239
+ declare const createJiraPoller: typeof jiraPollerFactory;
240
+
241
+ export { JIRA_TABLE_SCHEMAS, JiraApiError, JiraClient, type JiraComment, type JiraCommentPage, type JiraConnectorConfig, type JiraIngestConfig, type JiraIssue, type JiraProject, type JiraProjectPage, JiraRateLimitError, type JiraSearchResponse, JiraSourcePoller, createJiraPoller, jiraPollerFactory, mapComment, mapIssue, mapProject, testConnection };
@@ -4,19 +4,23 @@ import {
4
4
  JiraClient,
5
5
  JiraRateLimitError,
6
6
  JiraSourcePoller,
7
+ createJiraPoller,
8
+ jiraPollerFactory,
7
9
  mapComment,
8
10
  mapIssue,
9
11
  mapProject,
10
12
  testConnection
11
- } from "./chunk-QMS7TGFL.js";
12
- import "./chunk-P3FT7QCW.js";
13
- import "./chunk-7D4SUZUM.js";
13
+ } from "./chunk-ZNY4DSFU.js";
14
+ import "./chunk-4SG66H5K.js";
15
+ import "./chunk-DGUM43GV.js";
14
16
  export {
15
17
  JIRA_TABLE_SCHEMAS,
16
18
  JiraApiError,
17
19
  JiraClient,
18
20
  JiraRateLimitError,
19
21
  JiraSourcePoller,
22
+ createJiraPoller,
23
+ jiraPollerFactory,
20
24
  mapComment,
21
25
  mapIssue,
22
26
  mapProject,
@@ -1,6 +1,7 @@
1
+ import { B as BaseSourcePoller, P as PushTarget } from './base-poller-Y7ORYgUv.js';
2
+ import { C as ConnectorConfig } from './types-D2C9jTbL.js';
3
+ import { T as TableSchema } from './types-BdGBv2ba.js';
1
4
  import { L as LakeSyncError, R as Result } from './result-CojzlFE2.js';
2
- import { B as BaseSourcePoller, P as PushTarget } from './base-poller-BpUyuG2R.js';
3
- import { T as TableSchema } from './types-CLlD4XOy.js';
4
5
  import './hlc-DiD8QNG3.js';
5
6
 
6
7
  /** HTTP error from the Salesforce REST API. */
@@ -251,4 +252,13 @@ declare const SALESFORCE_TABLE_SCHEMAS: ReadonlyArray<TableSchema>;
251
252
  */
252
253
  declare function testConnection(config: SalesforceConnectorConfig): Promise<Result<void, SalesforceAuthError>>;
253
254
 
254
- export { SALESFORCE_TABLE_SCHEMAS, SalesforceApiError, SalesforceAuthError, type SalesforceAuthResponse, SalesforceClient, type SalesforceConnectorConfig, type SalesforceIngestConfig, type SalesforceQueryResponse, SalesforceSourcePoller, type SfAccount, type SfContact, type SfLead, type SfOpportunity, mapAccount, mapContact, mapLead, mapOpportunity, testConnection };
255
+ /**
256
+ * Poller factory for Salesforce connectors.
257
+ *
258
+ * Register with a {@link import("@lakesync/core").PollerRegistry} via `.with("salesforce", salesforcePollerFactory)`.
259
+ */
260
+ declare function salesforcePollerFactory(config: ConnectorConfig, gateway: PushTarget): BaseSourcePoller;
261
+ /** @deprecated Use {@link salesforcePollerFactory} instead. */
262
+ declare const createSalesforcePoller: typeof salesforcePollerFactory;
263
+
264
+ export { SALESFORCE_TABLE_SCHEMAS, SalesforceApiError, SalesforceAuthError, type SalesforceAuthResponse, SalesforceClient, type SalesforceConnectorConfig, type SalesforceIngestConfig, type SalesforceQueryResponse, SalesforceSourcePoller, type SfAccount, type SfContact, type SfLead, type SfOpportunity, createSalesforcePoller, mapAccount, mapContact, mapLead, mapOpportunity, salesforcePollerFactory, testConnection };
@@ -4,24 +4,28 @@ import {
4
4
  SalesforceAuthError,
5
5
  SalesforceClient,
6
6
  SalesforceSourcePoller,
7
+ createSalesforcePoller,
7
8
  mapAccount,
8
9
  mapContact,
9
10
  mapLead,
10
11
  mapOpportunity,
12
+ salesforcePollerFactory,
11
13
  testConnection
12
- } from "./chunk-NCZYFZ3B.js";
13
- import "./chunk-P3FT7QCW.js";
14
- import "./chunk-7D4SUZUM.js";
14
+ } from "./chunk-XVP5DJJ7.js";
15
+ import "./chunk-4SG66H5K.js";
16
+ import "./chunk-DGUM43GV.js";
15
17
  export {
16
18
  SALESFORCE_TABLE_SCHEMAS,
17
19
  SalesforceApiError,
18
20
  SalesforceAuthError,
19
21
  SalesforceClient,
20
22
  SalesforceSourcePoller,
23
+ createSalesforcePoller,
21
24
  mapAccount,
22
25
  mapContact,
23
26
  mapLead,
24
27
  mapOpportunity,
28
+ salesforcePollerFactory,
25
29
  testConnection
26
30
  };
27
31
  //# sourceMappingURL=connector-salesforce.js.map
@@ -1,8 +1,8 @@
1
1
  import { L as LakeSyncError, R as Result, H as HLCTimestamp } from './result-CojzlFE2.js';
2
2
  import { A as Action, i as ActionPush, j as ActionResponse, d as ActionDiscovery, k as ActionResult, e as ActionErrorResult } from './types-Bs-QyOe-.js';
3
3
  import { H as HLC } from './hlc-DiD8QNG3.js';
4
- import { a as ConnectorDescriptor } from './registry-CPTgO9jv.js';
5
- import { R as RowDelta, S as SyncPush, b as SyncPull, c as SyncResponse } from './types-CLlD4XOy.js';
4
+ import { a as ConnectorDescriptor } from './registry-Dd8JuW8T.js';
5
+ import { R as RowDelta, S as SyncPush, e as SyncPull, f as SyncResponse } from './types-BdGBv2ba.js';
6
6
 
7
7
  /** Configuration for opening a local database */
8
8
  interface DbConfig {
@@ -154,6 +154,54 @@ interface ActionQueue {
154
154
  clear(): Promise<Result<void, LakeSyncError>>;
155
155
  }
156
156
 
157
+ /**
158
+ * Context provided to sync strategies with access to sync operations.
159
+ *
160
+ * Each method performs a single sync operation. The strategy decides
161
+ * ordering and which operations to perform.
162
+ */
163
+ interface SyncContext {
164
+ /** Whether this is the first sync (lastSyncedHlc === 0). */
165
+ readonly isFirstSync: boolean;
166
+ /** Current sync mode. */
167
+ readonly syncMode: "full" | "pushOnly" | "pullOnly";
168
+ /** Perform initial sync via checkpoint download. */
169
+ initialSync(): Promise<void>;
170
+ /** Pull remote deltas from the gateway. */
171
+ pull(): Promise<number>;
172
+ /** Push local deltas to the gateway. */
173
+ push(): Promise<void>;
174
+ /** Process pending actions from the action queue. */
175
+ processActions(): Promise<void>;
176
+ }
177
+ /**
178
+ * Strategy that determines the ordering of sync operations.
179
+ *
180
+ * Decouples "what to sync" from "in what order".
181
+ */
182
+ interface SyncStrategy {
183
+ /** Execute a sync cycle using the provided context. */
184
+ execute(ctx: SyncContext): Promise<void>;
185
+ }
186
+ /**
187
+ * Default strategy: pull before push.
188
+ *
189
+ * On first sync, performs initial sync (checkpoint download).
190
+ * Then pulls remote deltas, pushes local deltas, and processes actions.
191
+ */
192
+ declare class PullFirstStrategy implements SyncStrategy {
193
+ execute(ctx: SyncContext): Promise<void>;
194
+ }
195
+ /**
196
+ * Push-first strategy for offline-first apps.
197
+ *
198
+ * Pushes local deltas first, then pulls remote deltas.
199
+ * Useful when local changes should be sent before receiving updates.
200
+ */
201
+ declare class PushFirstStrategy implements SyncStrategy {
202
+ execute(ctx: SyncContext): Promise<void>;
203
+ }
204
+
157
205
  /**
158
206
  * Tracks local mutations (insert, update, delete) and produces
159
207
  * column-level deltas that are pushed to a SyncQueue.
@@ -224,7 +272,7 @@ interface CheckpointResponse {
224
272
  /** Snapshot HLC marking the point-in-time of this checkpoint */
225
273
  snapshotHlc: HLCTimestamp;
226
274
  }
227
- /** Abstract transport layer for communicating with a remote sync gateway */
275
+ /** Core sync transport push and pull deltas. */
228
276
  interface SyncTransport {
229
277
  /** Push local deltas to the gateway */
230
278
  push(msg: SyncPush): Promise<Result<{
@@ -233,30 +281,57 @@ interface SyncTransport {
233
281
  }, LakeSyncError>>;
234
282
  /** Pull remote deltas from the gateway */
235
283
  pull(msg: SyncPull): Promise<Result<SyncResponse, LakeSyncError>>;
284
+ }
285
+ /** Transport that supports checkpoint downloads for initial sync. */
286
+ interface CheckpointTransport {
236
287
  /** Download checkpoint for initial sync. Returns null if no checkpoint available. */
237
- checkpoint?(): Promise<Result<CheckpointResponse | null, LakeSyncError>>;
238
- /** Execute imperative actions against external systems via the gateway. */
239
- executeAction?(msg: ActionPush): Promise<Result<ActionResponse, LakeSyncError>>;
240
- /** Discover available connectors and their supported action types. */
241
- describeActions?(): Promise<Result<ActionDiscovery, LakeSyncError>>;
242
- /** List available connector types and their configuration schemas. */
243
- listConnectorTypes?(): Promise<Result<ConnectorDescriptor[], LakeSyncError>>;
288
+ checkpoint(): Promise<Result<CheckpointResponse | null, LakeSyncError>>;
289
+ }
290
+ /** Transport that supports real-time server-initiated broadcasts. */
291
+ interface RealtimeTransport {
244
292
  /** Whether this transport supports real-time server push. */
245
- readonly supportsRealtime?: boolean;
293
+ readonly supportsRealtime: boolean;
246
294
  /** Register callback for server-initiated broadcasts. */
247
- onBroadcast?(callback: (deltas: RowDelta[], serverHlc: HLCTimestamp) => void): void;
295
+ onBroadcast(callback: (deltas: RowDelta[], serverHlc: HLCTimestamp) => void): void;
248
296
  /** Connect persistent transport (e.g. open WebSocket). */
249
- connect?(): void;
297
+ connect(): void;
250
298
  /** Disconnect persistent transport (e.g. close WebSocket). */
251
- disconnect?(): void;
299
+ disconnect(): void;
252
300
  }
301
+ /** Transport that supports imperative action execution. */
302
+ interface ActionTransport {
303
+ /** Execute imperative actions against external systems via the gateway. */
304
+ executeAction(msg: ActionPush): Promise<Result<ActionResponse, LakeSyncError>>;
305
+ /** Discover available connectors and their supported action types. */
306
+ describeActions(): Promise<Result<ActionDiscovery, LakeSyncError>>;
307
+ /** List available connector types and their configuration schemas. */
308
+ listConnectorTypes(): Promise<Result<ConnectorDescriptor[], LakeSyncError>>;
309
+ }
310
+ /**
311
+ * Union type combining the core sync transport with optional capabilities.
312
+ *
313
+ * Transports must implement push/pull. Checkpoint, real-time, and action
314
+ * capabilities are opt-in via the respective interfaces.
315
+ */
316
+ type TransportWithCapabilities = SyncTransport & Partial<CheckpointTransport> & Partial<RealtimeTransport> & Partial<ActionTransport>;
253
317
 
254
318
  /** Controls which operations syncOnce() / startAutoSync() performs */
255
319
  type SyncMode = "full" | "pushOnly" | "pullOnly";
320
+ /** Readable snapshot of the coordinator's current sync state. */
321
+ interface SyncState {
322
+ /** Whether a sync cycle is currently in progress. */
323
+ syncing: boolean;
324
+ /** Last successful sync time, or null if never synced. */
325
+ lastSyncTime: Date | null;
326
+ /** HLC timestamp of the last successfully synced delta. */
327
+ lastSyncedHlc: HLCTimestamp;
328
+ }
256
329
  /** Events emitted by SyncCoordinator */
257
330
  interface SyncEvents {
258
331
  /** Fired after remote deltas are applied locally. Count is the number of deltas applied. */
259
332
  onChange: (count: number) => void;
333
+ /** Fired when a sync cycle (push + pull) begins. */
334
+ onSyncStart: () => void;
260
335
  /** Fired after a successful sync cycle (push + pull) completes. */
261
336
  onSyncComplete: () => void;
262
337
  /** Fired when a sync error occurs. */
@@ -284,12 +359,17 @@ interface SyncCoordinatorConfig {
284
359
  actionQueue?: ActionQueue;
285
360
  /** Maximum retries for actions before dead-lettering. Defaults to 5. */
286
361
  maxActionRetries?: number;
362
+ /** Sync strategy. Defaults to PullFirstStrategy. */
363
+ strategy?: SyncStrategy;
287
364
  }
288
365
  /**
289
366
  * Coordinates local mutations (via SyncTracker) with gateway push/pull.
290
367
  *
291
- * Uses a {@link SyncTransport} abstraction to communicate with the gateway,
368
+ * Uses a {@link TransportWithCapabilities} abstraction to communicate with the gateway,
292
369
  * allowing both in-process (LocalTransport) and remote (HttpTransport) usage.
370
+ *
371
+ * Delegates auto-sync scheduling to {@link AutoSyncScheduler} and action
372
+ * processing to {@link ActionProcessor}.
293
373
  */
294
374
  declare class SyncCoordinator {
295
375
  readonly tracker: SyncTracker;
@@ -301,22 +381,26 @@ declare class SyncCoordinator {
301
381
  private readonly _clientId;
302
382
  private readonly maxRetries;
303
383
  private readonly syncMode;
304
- private readonly autoSyncIntervalMs;
305
- private readonly realtimeHeartbeatMs;
306
384
  private lastSyncedHlc;
307
385
  private _lastSyncTime;
308
- private syncIntervalId;
309
- private visibilityHandler;
310
386
  private syncing;
311
- private readonly actionQueue;
312
- private readonly maxActionRetries;
387
+ private _online;
388
+ private onlineHandler;
389
+ private offlineHandler;
390
+ private readonly strategy;
391
+ private readonly autoSyncScheduler;
392
+ private readonly actionProcessor;
313
393
  private listeners;
314
- constructor(db: LocalDB, transport: SyncTransport, config?: SyncCoordinatorConfig);
394
+ constructor(db: LocalDB, transport: TransportWithCapabilities, config?: SyncCoordinatorConfig);
315
395
  /** Register an event listener */
316
396
  on<K extends keyof SyncEvents>(event: K, listener: SyncEvents[K]): void;
317
397
  /** Remove an event listener */
318
398
  off<K extends keyof SyncEvents>(event: K, listener: SyncEvents[K]): void;
319
399
  private emit;
400
+ /** Readable snapshot of the current sync state. */
401
+ get state(): SyncState;
402
+ /** Whether the client believes it is online. */
403
+ get isOnline(): boolean;
320
404
  /** Push pending deltas to the gateway via the transport */
321
405
  pushToGateway(): Promise<void>;
322
406
  /**
@@ -344,11 +428,11 @@ declare class SyncCoordinator {
344
428
  get lastSyncTime(): Date | null;
345
429
  /**
346
430
  * Start auto-sync: periodic interval + visibility change handler.
347
- * Synchronises (push + pull) on tab focus and every 10 seconds.
431
+ * Synchronises (push + pull) on tab focus and every N seconds.
432
+ * Registers online/offline listeners to skip sync when offline
433
+ * and trigger an immediate sync on reconnect.
348
434
  */
349
435
  startAutoSync(): void;
350
- /** Register a visibility change listener to sync on tab focus. */
351
- private setupVisibilitySync;
352
436
  /**
353
437
  * Perform initial sync via checkpoint download.
354
438
  *
@@ -359,6 +443,8 @@ declare class SyncCoordinator {
359
443
  * not support checkpoints, falls back to incremental pull.
360
444
  */
361
445
  private initialSync;
446
+ /** Build a {@link SyncContext} exposing sync operations for the current cycle. */
447
+ private createSyncContext;
362
448
  /** Perform a single sync cycle (push + pull + actions, depending on syncMode). */
363
449
  syncOnce(): Promise<void>;
364
450
  /**
@@ -379,10 +465,7 @@ declare class SyncCoordinator {
379
465
  /**
380
466
  * Process pending actions from the action queue.
381
467
  *
382
- * Peeks at pending entries, sends them to the gateway via
383
- * `transport.executeAction()`, and acks/nacks based on the result.
384
- * Dead-letters entries after `maxActionRetries` failures.
385
- * Triggers an immediate `syncOnce()` on success to pull fresh state.
468
+ * Delegates to the ActionProcessor if one is configured.
386
469
  */
387
470
  processActionQueue(): Promise<void>;
388
471
  /**
@@ -401,6 +484,13 @@ declare class SyncCoordinator {
401
484
  listConnectorTypes(): Promise<Result<ConnectorDescriptor[], LakeSyncError>>;
402
485
  /** Stop auto-sync and clean up listeners */
403
486
  stopAutoSync(): void;
487
+ /**
488
+ * Register window online/offline event listeners.
489
+ * Guards all browser API access with typeof checks for Node/SSR safety.
490
+ */
491
+ private setupOnlineListeners;
492
+ /** Remove online/offline listeners. */
493
+ private teardownOnlineListeners;
404
494
  }
405
495
 
406
- export { type ActionQueue as A, type CheckpointResponse as C, DbError as D, LocalDB as L, type QueueEntry as Q, type SyncQueue as S, type Transaction as T, type SyncCoordinatorConfig as a, SyncCoordinator as b, type SyncTransport as c, type ActionQueueEntry as d, type ActionQueueEntryStatus as e, type DbConfig as f, type QueueEntryStatus as g, type SyncEvents as h, type SyncMode as i, SyncTracker as j };
496
+ export { type ActionQueue as A, type CheckpointTransport as C, DbError as D, LocalDB as L, PullFirstStrategy as P, type QueueEntry as Q, type RealtimeTransport as R, type SyncQueue as S, type TransportWithCapabilities as T, type SyncCoordinatorConfig as a, SyncCoordinator as b, type ActionQueueEntry as c, type SyncTransport as d, type ActionTransport as e, type CheckpointResponse as f, type ActionQueueEntryStatus as g, type DbConfig as h, PushFirstStrategy as i, type QueueEntryStatus as j, type SyncContext as k, type SyncEvents as l, type SyncMode as m, type SyncState as n, type SyncStrategy as o, SyncTracker as p, type Transaction as q };
@@ -0,0 +1,55 @@
1
+ import { R as Result } from './result-CojzlFE2.js';
2
+ import { P as PushTarget, B as BaseSourcePoller } from './base-poller-Y7ORYgUv.js';
3
+ import { C as ConnectorConfig } from './types-D2C9jTbL.js';
4
+
5
+ /** Claims extracted from a verified JWT token */
6
+ interface AuthClaims {
7
+ /** Client identifier (from JWT `sub` claim) */
8
+ clientId: string;
9
+ /** Authorised gateway ID (from JWT `gw` claim) */
10
+ gatewayId: string;
11
+ /** Role for route-level access control (from JWT `role` claim, defaults to "client") */
12
+ role: string;
13
+ /** Non-standard JWT claims for sync rule evaluation */
14
+ customClaims: Record<string, string | string[]>;
15
+ }
16
+ /** Authentication error returned when JWT verification fails */
17
+ declare class AuthError extends Error {
18
+ constructor(message: string);
19
+ }
20
+ /**
21
+ * Verify a JWT token signed with HMAC-SHA256 and extract authentication claims.
22
+ *
23
+ * Uses the Web Crypto API exclusively (no external dependencies), making it
24
+ * suitable for Cloudflare Workers and other edge runtimes.
25
+ *
26
+ * @param token - The raw JWT string (header.payload.signature)
27
+ * @param secret - The HMAC-SHA256 secret key
28
+ * @returns A Result containing AuthClaims on success, or AuthError on failure
29
+ */
30
+ declare function verifyToken(token: string, secret: string): Promise<Result<AuthClaims, AuthError>>;
31
+
32
+ /** Factory function that creates a poller from a ConnectorConfig. */
33
+ type PollerFactory = (config: ConnectorConfig, gateway: PushTarget) => BaseSourcePoller;
34
+ /** Immutable registry of poller factories keyed by connector type. */
35
+ interface PollerRegistry {
36
+ /** Look up a factory by type. */
37
+ get(type: string): PollerFactory | undefined;
38
+ /** Create a new registry with an additional or replaced factory. */
39
+ with(type: string, factory: PollerFactory): PollerRegistry;
40
+ }
41
+ /**
42
+ * Create an immutable {@link PollerRegistry} from a Map of factories.
43
+ */
44
+ declare function createPollerRegistry(factories?: Map<string, PollerFactory>): PollerRegistry;
45
+ /**
46
+ * Create a poller from a {@link ConnectorConfig}.
47
+ *
48
+ * @param config - Connector configuration.
49
+ * @param gateway - Push target for the poller.
50
+ * @param registry - Registry of poller factories to look up the config's type.
51
+ * @throws If no factory has been registered for the config's `type`.
52
+ */
53
+ declare function createPoller(config: ConnectorConfig, gateway: PushTarget, registry: PollerRegistry): BaseSourcePoller;
54
+
55
+ export { type AuthClaims as A, type PollerFactory as P, AuthError as a, type PollerRegistry as b, createPoller as c, createPollerRegistry as d, verifyToken as v };
@@ -0,0 +1,33 @@
1
+ import { R as Result, A as AdapterError } from './result-CojzlFE2.js';
2
+ import { D as DatabaseAdapter } from './adapter-types-DwsQGQS4.js';
3
+ import { C as ConnectorConfig } from './types-D2C9jTbL.js';
4
+
5
+ /** Factory function that creates a DatabaseAdapter from a ConnectorConfig. */
6
+ type AdapterFactory = (config: ConnectorConfig) => DatabaseAdapter;
7
+ /** Immutable registry of adapter factories keyed by connector type. */
8
+ interface AdapterFactoryRegistry {
9
+ /** Look up a factory by type. */
10
+ get(type: string): AdapterFactory | undefined;
11
+ /** Create a new registry with an additional or replaced factory. */
12
+ with(type: string, factory: AdapterFactory): AdapterFactoryRegistry;
13
+ }
14
+ /**
15
+ * Create an immutable {@link AdapterFactoryRegistry} from a Map of factories.
16
+ */
17
+ declare function createAdapterFactoryRegistry(factories?: Map<string, AdapterFactory>): AdapterFactoryRegistry;
18
+ /** Default registry with built-in database adapters (Postgres, MySQL, BigQuery). */
19
+ declare function defaultAdapterFactoryRegistry(): AdapterFactoryRegistry;
20
+ /**
21
+ * Instantiate a {@link DatabaseAdapter} from a {@link ConnectorConfig}.
22
+ *
23
+ * Uses the provided registry (or the default built-in registry) to look up
24
+ * a factory for the config's type. Returns an {@link AdapterError} if the
25
+ * type is unsupported or the adapter constructor throws.
26
+ *
27
+ * @param config - Validated connector configuration.
28
+ * @param registry - Optional adapter factory registry. Defaults to built-in adapters.
29
+ * @returns The instantiated adapter or an error.
30
+ */
31
+ declare function createDatabaseAdapter(config: ConnectorConfig, registry?: AdapterFactoryRegistry): Result<DatabaseAdapter, AdapterError>;
32
+
33
+ export { type AdapterFactory as A, type AdapterFactoryRegistry as a, createDatabaseAdapter as b, createAdapterFactoryRegistry as c, defaultAdapterFactoryRegistry as d };