lakesync 0.1.8 → 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 (60) hide show
  1. package/dist/adapter-types-DwsQGQS4.d.ts +94 -0
  2. package/dist/adapter.d.ts +23 -49
  3. package/dist/adapter.js +9 -4
  4. package/dist/analyst.js +1 -1
  5. package/dist/{base-poller-Bj9kX9dv.d.ts → base-poller-Y7ORYgUv.d.ts} +2 -0
  6. package/dist/catalogue.js +2 -2
  7. package/dist/{chunk-LDFFCG2K.js → chunk-4SG66H5K.js} +44 -31
  8. package/dist/chunk-4SG66H5K.js.map +1 -0
  9. package/dist/{chunk-LPWXOYNS.js → chunk-C4KD6YKP.js} +59 -43
  10. package/dist/chunk-C4KD6YKP.js.map +1 -0
  11. package/dist/{chunk-JI4C4R5H.js → chunk-FIIHPQMQ.js} +196 -118
  12. package/dist/chunk-FIIHPQMQ.js.map +1 -0
  13. package/dist/{chunk-TMLG32QV.js → chunk-U2NV4DUX.js} +2 -2
  14. package/dist/{chunk-QNITY4F6.js → chunk-XVP5DJJ7.js} +16 -13
  15. package/dist/{chunk-QNITY4F6.js.map → chunk-XVP5DJJ7.js.map} +1 -1
  16. package/dist/{chunk-KVSWLIJR.js → chunk-YHYBLU6W.js} +2 -2
  17. package/dist/{chunk-PYRS74YP.js → chunk-ZNY4DSFU.js} +16 -13
  18. package/dist/{chunk-PYRS74YP.js.map → chunk-ZNY4DSFU.js.map} +1 -1
  19. package/dist/{chunk-SSICS5KI.js → chunk-ZU7RC7CT.js} +2 -2
  20. package/dist/client.d.ts +28 -10
  21. package/dist/client.js +150 -29
  22. package/dist/client.js.map +1 -1
  23. package/dist/compactor.d.ts +1 -1
  24. package/dist/compactor.js +3 -3
  25. package/dist/connector-jira.d.ts +13 -3
  26. package/dist/connector-jira.js +6 -2
  27. package/dist/connector-salesforce.d.ts +13 -3
  28. package/dist/connector-salesforce.js +6 -2
  29. package/dist/{coordinator-NXy6tA0h.d.ts → coordinator-eGmZMnJ_.d.ts} +99 -16
  30. package/dist/create-poller-Cc2MGfhh.d.ts +55 -0
  31. package/dist/factory-DFfR-030.d.ts +33 -0
  32. package/dist/gateway-server.d.ts +398 -95
  33. package/dist/gateway-server.js +743 -56
  34. package/dist/gateway-server.js.map +1 -1
  35. package/dist/gateway.d.ts +14 -8
  36. package/dist/gateway.js +6 -5
  37. package/dist/index.d.ts +45 -73
  38. package/dist/index.js +5 -3
  39. package/dist/parquet.js +2 -2
  40. package/dist/proto.js +2 -2
  41. package/dist/react.d.ts +3 -3
  42. package/dist/{registry-BcspAtZI.d.ts → registry-Dd8JuW8T.d.ts} +1 -1
  43. package/dist/{request-handler-pUvL7ozF.d.ts → request-handler-B1I5xDOx.d.ts} +71 -27
  44. package/dist/{src-ROW4XLO7.js → src-WU7IBVC4.js} +6 -4
  45. package/dist/{types-BrcD1oJg.d.ts → types-D2C9jTbL.d.ts} +33 -23
  46. package/package.json +1 -1
  47. package/dist/auth-CAVutXzx.d.ts +0 -30
  48. package/dist/chunk-JI4C4R5H.js.map +0 -1
  49. package/dist/chunk-LDFFCG2K.js.map +0 -1
  50. package/dist/chunk-LPWXOYNS.js.map +0 -1
  51. package/dist/db-types-CfLMUBfW.d.ts +0 -29
  52. package/dist/src-B6NLV3FP.js +0 -27
  53. package/dist/src-ROW4XLO7.js.map +0 -1
  54. package/dist/src-ZRHKG42A.js +0 -25
  55. package/dist/src-ZRHKG42A.js.map +0 -1
  56. package/dist/types-DSC_EiwR.d.ts +0 -45
  57. /package/dist/{chunk-TMLG32QV.js.map → chunk-U2NV4DUX.js.map} +0 -0
  58. /package/dist/{chunk-KVSWLIJR.js.map → chunk-YHYBLU6W.js.map} +0 -0
  59. /package/dist/{chunk-SSICS5KI.js.map → chunk-ZU7RC7CT.js.map} +0 -0
  60. /package/dist/{src-B6NLV3FP.js.map → src-WU7IBVC4.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -2,15 +2,16 @@ import { A as Action, a as ActionValidationError, S as SyncRulesConfig, B as Buc
2
2
  export { c as ActionDescriptor, d as ActionDiscovery, e as ActionErrorResult, f as ActionExecutionError, g as ActionHandler, h as ActionNotSupportedError, i as ActionPush, j as ActionResponse, k as ActionResult, l as AuthContext, m as SyncRuleFilter, n as SyncRuleOp, o as isActionError, p as isActionHandler } from './types-Bs-QyOe-.js';
3
3
  import { H as HLCTimestamp, R as Result, C as ConflictError, L as LakeSyncError, S as SchemaError } from './result-CojzlFE2.js';
4
4
  export { A as AdapterError, a as AdapterNotFoundError, B as BackpressureError, b as ClockDriftError, E as Err, F as FlushError, O as Ok, f as flatMapResult, c as fromPromise, m as mapResult, t as toError, u as unwrapOrThrow } from './result-CojzlFE2.js';
5
- export { A as AuthClaims, a as AuthError, v as verifyToken } from './auth-CAVutXzx.js';
6
- import { P as PushTarget, B as BaseSourcePoller } from './base-poller-Bj9kX9dv.js';
7
- export { C as ChunkedPusher, F as FlushableTarget, I as IngestTarget, a as PollerMemoryConfig, b as PressureManager, i as isIngestTarget } from './base-poller-Bj9kX9dv.js';
8
- import { S as SyncPush, R as RowDelta, T as TableSchema } from './types-BdGBv2ba.js';
5
+ export { D as DatabaseAdapter, a as DatabaseAdapterConfig, L as LakeAdapter, M as Materialisable, O as ObjectInfo, i as isDatabaseAdapter, b as isMaterialisable } from './adapter-types-DwsQGQS4.js';
6
+ export { A as AuthClaims, a as AuthError, P as PollerFactory, b as PollerRegistry, c as createPoller, d as createPollerRegistry, v as verifyToken } from './create-poller-Cc2MGfhh.js';
7
+ import { P as PushTarget } from './base-poller-Y7ORYgUv.js';
8
+ export { B as BaseSourcePoller, C as ChunkedPusher, F as FlushableTarget, I as IngestTarget, a as PollerMemoryConfig, b as PressureManager, i as isIngestTarget } from './base-poller-Y7ORYgUv.js';
9
+ import { R as RowDelta, T as TableSchema, S as SyncPush } from './types-BdGBv2ba.js';
9
10
  export { C as COLUMN_TYPES, a as ColumnDelta, b as ColumnReference, c as ColumnType, D as DeltaOp, d as RowKey, e as SyncPull, f as SyncResponse, r as rowKey } from './types-BdGBv2ba.js';
10
11
  import { C as ConflictResolver } from './resolver-CXxmC0jR.js';
11
- export { C as ConnectorCategory, a as ConnectorDescriptor, b as ConnectorRegistry, c as createConnectorRegistry, g as getConnectorDescriptor, l as listConnectorDescriptors, r as registerConnectorDescriptor, d as registerOutputSchemas } from './registry-BcspAtZI.js';
12
- import { C as ConnectorConfig } from './types-BrcD1oJg.js';
13
- export { B as BigQueryConnectorConfig, a as CONNECTOR_TYPES, b as ConnectorIngestConfig, c as ConnectorIngestTable, d as ConnectorType, J as JiraConnectorConfig, M as MySQLConnectorConfig, P as PostgresConnectorConfig, S as SalesforceConnectorConfig } from './types-BrcD1oJg.js';
12
+ export { C as ConnectorCategory, a as ConnectorDescriptor, b as ConnectorRegistry, c as createConnectorRegistry, g as getConnectorDescriptor, l as listConnectorDescriptors, r as registerConnectorDescriptor, d as registerOutputSchemas } from './registry-Dd8JuW8T.js';
13
+ import { C as ConnectorConfig } from './types-D2C9jTbL.js';
14
+ export { B as BigQueryConnectorConfig, a as BigQueryConnectorConfigFull, b as CONNECTOR_TYPES, c as ConnectorConfigBase, d as ConnectorIngestConfig, e as ConnectorIngestTable, f as ConnectorType, J as JiraConnectorConfig, g as JiraConnectorConfigFull, M as MySQLConnectorConfig, h as MySQLConnectorConfigFull, P as PostgresConnectorConfig, i as PostgresConnectorConfigFull, S as SalesforceConnectorConfig, j as SalesforceConnectorConfigFull } from './types-D2C9jTbL.js';
14
15
  export { H as HLC } from './hlc-DiD8QNG3.js';
15
16
  export { b as bigintReplacer, a as bigintReviver } from './json-dYtqiL0F.js';
16
17
 
@@ -36,6 +37,42 @@ declare function generateActionId(params: {
36
37
  */
37
38
  declare function validateAction(action: unknown): Result<Action, ActionValidationError>;
38
39
 
40
+ /**
41
+ * Apply a delta to an existing row, returning the merged result.
42
+ *
43
+ * - DELETE → returns null
44
+ * - INSERT → creates a new row from delta columns
45
+ * - UPDATE → merges delta columns onto existing row (immutable — returns a new object)
46
+ *
47
+ * @param row - The current row state, or null if no row exists
48
+ * @param delta - The delta to apply
49
+ * @returns The merged row, or null for DELETE operations
50
+ */
51
+ declare function applyDelta(row: Record<string, unknown> | null, delta: RowDelta): Record<string, unknown> | null;
52
+
53
+ /**
54
+ * Extract a column-level delta between two row states.
55
+ *
56
+ * - `before` null/undefined + `after` present -> INSERT (all columns)
57
+ * - `before` present + `after` null/undefined -> DELETE (empty columns)
58
+ * - Both present -> compare each column, emit only changed columns as UPDATE
59
+ * - No columns changed -> returns null (no-op)
60
+ *
61
+ * If `schema` is provided, only columns listed in the schema are considered.
62
+ *
63
+ * @param before - The previous row state, or null/undefined for a new row
64
+ * @param after - The current row state, or null/undefined for a deleted row
65
+ * @param opts - Table name, row ID, client ID, HLC timestamp, and optional schema
66
+ * @returns The extracted RowDelta, or null if nothing changed
67
+ */
68
+ declare function extractDelta(before: Record<string, unknown> | null | undefined, after: Record<string, unknown> | null | undefined, opts: {
69
+ table: string;
70
+ rowId: string;
71
+ clientId: string;
72
+ hlc: HLCTimestamp;
73
+ schema?: TableSchema;
74
+ }): Promise<RowDelta | null>;
75
+
39
76
  /**
40
77
  * A simple PushTarget implementation that forwards every push to a
41
78
  * user-supplied callback. Useful for testing, logging, or lightweight
@@ -102,71 +139,6 @@ declare class ConnectorValidationError extends LakeSyncError {
102
139
  */
103
140
  declare function validateConnectorConfig(input: unknown): Result<ConnectorConfig, ConnectorValidationError>;
104
141
 
105
- /** Factory function that creates a poller from a ConnectorConfig. */
106
- type PollerFactory = (config: ConnectorConfig, gateway: PushTarget) => BaseSourcePoller;
107
- /** Immutable registry of poller factories keyed by connector type. */
108
- interface PollerRegistry {
109
- /** Look up a factory by type. */
110
- get(type: string): PollerFactory | undefined;
111
- /** Create a new registry with an additional or replaced factory. */
112
- with(type: string, factory: PollerFactory): PollerRegistry;
113
- }
114
- /**
115
- * Create an immutable {@link PollerRegistry} from a Map of factories.
116
- */
117
- declare function createPollerRegistry(factories?: Map<string, PollerFactory>): PollerRegistry;
118
- /**
119
- * Register a poller factory for a connector type.
120
- * Connector packages call this at module load time so that
121
- * `createPoller()` can instantiate the correct poller.
122
- */
123
- declare function registerPollerFactory(type: string, factory: PollerFactory): void;
124
- /**
125
- * Create a poller from a {@link ConnectorConfig}.
126
- *
127
- * @param config - Connector configuration.
128
- * @param gateway - Push target for the poller.
129
- * @param registry - Optional explicit registry. Defaults to the global registry.
130
- * @throws If no factory has been registered for the config's `type`.
131
- */
132
- declare function createPoller(config: ConnectorConfig, gateway: PushTarget, registry?: PollerRegistry): BaseSourcePoller;
133
-
134
- /**
135
- * Apply a delta to an existing row, returning the merged result.
136
- *
137
- * - DELETE → returns null
138
- * - INSERT → creates a new row from delta columns
139
- * - UPDATE → merges delta columns onto existing row (immutable — returns a new object)
140
- *
141
- * @param row - The current row state, or null if no row exists
142
- * @param delta - The delta to apply
143
- * @returns The merged row, or null for DELETE operations
144
- */
145
- declare function applyDelta(row: Record<string, unknown> | null, delta: RowDelta): Record<string, unknown> | null;
146
-
147
- /**
148
- * Extract a column-level delta between two row states.
149
- *
150
- * - `before` null/undefined + `after` present -> INSERT (all columns)
151
- * - `before` present + `after` null/undefined -> DELETE (empty columns)
152
- * - Both present -> compare each column, emit only changed columns as UPDATE
153
- * - No columns changed -> returns null (no-op)
154
- *
155
- * If `schema` is provided, only columns listed in the schema are considered.
156
- *
157
- * @param before - The previous row state, or null/undefined for a new row
158
- * @param after - The current row state, or null/undefined for a deleted row
159
- * @param opts - Table name, row ID, client ID, HLC timestamp, and optional schema
160
- * @returns The extracted RowDelta, or null if nothing changed
161
- */
162
- declare function extractDelta(before: Record<string, unknown> | null | undefined, after: Record<string, unknown> | null | undefined, opts: {
163
- table: string;
164
- rowId: string;
165
- clientId: string;
166
- hlc: HLCTimestamp;
167
- schema?: TableSchema;
168
- }): Promise<RowDelta | null>;
169
-
170
142
  /**
171
143
  * Manages the start/stop lifecycle and timer scheduling for a poll function.
172
144
  * Has no knowledge of deltas, gateways, or sync protocol.
@@ -305,4 +277,4 @@ declare function assertValidIdentifier(name: string): Result<void, SchemaError>;
305
277
  */
306
278
  declare function quoteIdentifier(name: string): string;
307
279
 
308
- export { Action, ActionValidationError, BaseSourcePoller, BucketDefinition, CallbackPushTarget, ConflictError, ConflictResolver, ConnectorConfig, ConnectorValidationError, HLCTimestamp, LWWResolver, LakeSyncError, type PollerFactory, type PollerRegistry, PollingScheduler, PushTarget, ResolvedClaims, Result, RowDelta, SchemaError, SyncPush, SyncRuleError, SyncRulesConfig, SyncRulesContext, TableSchema, applyDelta, assertValidIdentifier, createPassAllRules, createPoller, createPollerRegistry, createUserScopedRules, deltaMatchesBucket, extractDelta, filterDeltas, generateActionId, isValidIdentifier, quoteIdentifier, registerPollerFactory, resolveClientBuckets, resolveFilterValue, resolveLWW, validateAction, validateConnectorConfig, validateSyncRules };
280
+ export { Action, ActionValidationError, BucketDefinition, CallbackPushTarget, ConflictError, ConflictResolver, ConnectorConfig, ConnectorValidationError, HLCTimestamp, LWWResolver, LakeSyncError, PollingScheduler, PushTarget, ResolvedClaims, Result, RowDelta, SchemaError, SyncPush, SyncRuleError, SyncRulesConfig, SyncRulesContext, TableSchema, applyDelta, assertValidIdentifier, createPassAllRules, createUserScopedRules, deltaMatchesBucket, extractDelta, filterDeltas, generateActionId, isValidIdentifier, quoteIdentifier, resolveClientBuckets, resolveFilterValue, resolveLWW, validateAction, validateConnectorConfig, validateSyncRules };
package/dist/index.js CHANGED
@@ -42,14 +42,15 @@ import {
42
42
  getConnectorDescriptor,
43
43
  isActionError,
44
44
  isActionHandler,
45
+ isDatabaseAdapter,
45
46
  isIngestTarget,
47
+ isMaterialisable,
46
48
  isValidIdentifier,
47
49
  listConnectorDescriptors,
48
50
  mapResult,
49
51
  quoteIdentifier,
50
52
  registerConnectorDescriptor,
51
53
  registerOutputSchemas,
52
- registerPollerFactory,
53
54
  resolveClientBuckets,
54
55
  resolveFilterValue,
55
56
  resolveLWW,
@@ -60,7 +61,7 @@ import {
60
61
  validateConnectorConfig,
61
62
  validateSyncRules,
62
63
  verifyToken
63
- } from "./chunk-LDFFCG2K.js";
64
+ } from "./chunk-4SG66H5K.js";
64
65
  import "./chunk-DGUM43GV.js";
65
66
  export {
66
67
  ActionExecutionError,
@@ -106,14 +107,15 @@ export {
106
107
  getConnectorDescriptor,
107
108
  isActionError,
108
109
  isActionHandler,
110
+ isDatabaseAdapter,
109
111
  isIngestTarget,
112
+ isMaterialisable,
110
113
  isValidIdentifier,
111
114
  listConnectorDescriptors,
112
115
  mapResult,
113
116
  quoteIdentifier,
114
117
  registerConnectorDescriptor,
115
118
  registerOutputSchemas,
116
- registerPollerFactory,
117
119
  resolveClientBuckets,
118
120
  resolveFilterValue,
119
121
  resolveLWW,
package/dist/parquet.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  deltasToArrowTable,
4
4
  readParquetToDeltas,
5
5
  writeDeltasToParquet
6
- } from "./chunk-SSICS5KI.js";
7
- import "./chunk-LDFFCG2K.js";
6
+ } from "./chunk-ZU7RC7CT.js";
7
+ import "./chunk-4SG66H5K.js";
8
8
  import "./chunk-DGUM43GV.js";
9
9
  export {
10
10
  buildArrowSchema,
package/dist/proto.js CHANGED
@@ -29,8 +29,8 @@ import {
29
29
  encodeSyncPull,
30
30
  encodeSyncPush,
31
31
  encodeSyncResponse
32
- } from "./chunk-KVSWLIJR.js";
33
- import "./chunk-LDFFCG2K.js";
32
+ } from "./chunk-YHYBLU6W.js";
33
+ import "./chunk-4SG66H5K.js";
34
34
  import "./chunk-DGUM43GV.js";
35
35
  export {
36
36
  ActionPushSchema,
package/dist/react.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as react from 'react';
2
- import { b as SyncCoordinator, k as SyncTracker, D as DbError } from './coordinator-NXy6tA0h.js';
2
+ import { b as SyncCoordinator, p as SyncTracker, D as DbError } from './coordinator-eGmZMnJ_.js';
3
3
  import { L as LakeSyncError, R as Result } from './result-CojzlFE2.js';
4
4
  import { c as ActionDescriptor, k as ActionResult, e as ActionErrorResult } from './types-Bs-QyOe-.js';
5
- import { a as ConnectorDescriptor } from './registry-BcspAtZI.js';
5
+ import { a as ConnectorDescriptor } from './registry-Dd8JuW8T.js';
6
6
  import './hlc-DiD8QNG3.js';
7
7
  import './types-BdGBv2ba.js';
8
- import './types-BrcD1oJg.js';
8
+ import './types-D2C9jTbL.js';
9
9
 
10
10
  /** Stable context value — coordinator and tracker references that never change. */
11
11
  interface LakeSyncStableContextValue {
@@ -1,5 +1,5 @@
1
1
  import { T as TableSchema } from './types-BdGBv2ba.js';
2
- import { d as ConnectorType } from './types-BrcD1oJg.js';
2
+ import { f as ConnectorType } from './types-D2C9jTbL.js';
3
3
 
4
4
  /** Connector category — determines the ingest model. */
5
5
  type ConnectorCategory = "database" | "api";
@@ -1,33 +1,81 @@
1
1
  import { H as HLCTimestamp, R as Result, S as SchemaError, b as ClockDriftError, B as BackpressureError, a as AdapterNotFoundError, A as AdapterError, F as FlushError } from './result-CojzlFE2.js';
2
- import { g as ActionHandler, i as ActionPush, l as AuthContext, j as ActionResponse, a as ActionValidationError, d as ActionDiscovery, S as SyncRulesConfig, b as SyncRulesContext, R as ResolvedClaims } from './types-Bs-QyOe-.js';
2
+ import { k as ActionResult, g as ActionHandler, i as ActionPush, l as AuthContext, j as ActionResponse, a as ActionValidationError, d as ActionDiscovery, S as SyncRulesConfig, b as SyncRulesContext, R as ResolvedClaims } from './types-Bs-QyOe-.js';
3
3
  import { R as RowDelta, d as RowKey, T as TableSchema, S as SyncPush, e as SyncPull, f as SyncResponse } from './types-BdGBv2ba.js';
4
- import { C as ConnectorConfig } from './types-BrcD1oJg.js';
5
- import { I as IngestTarget } from './base-poller-Bj9kX9dv.js';
6
- import { D as DatabaseAdapter } from './db-types-CfLMUBfW.js';
7
- import { L as LakeAdapter } from './types-DSC_EiwR.js';
4
+ import { C as ConnectorConfig } from './types-D2C9jTbL.js';
5
+ import { L as LakeAdapter, D as DatabaseAdapter } from './adapter-types-DwsQGQS4.js';
6
+ import { I as IngestTarget } from './base-poller-Y7ORYgUv.js';
8
7
  import { N as NessieCatalogueClient } from './nessie-client-DrNikVXy.js';
9
8
 
10
- /** Configuration for ActionDispatcher caches. */
11
- interface ActionCacheConfig {
12
- /** Maximum number of entries in the executed actions set and idempotency map. */
9
+ /** Cached action result — either a successful result or an error descriptor. */
10
+ type CachedActionResult = ActionResult | {
11
+ actionId: string;
12
+ code: string;
13
+ message: string;
14
+ retryable: boolean;
15
+ };
16
+ /**
17
+ * Interface for idempotency caching of action results.
18
+ *
19
+ * Implementations store action results keyed by actionId and optional
20
+ * idempotencyKey, enabling deduplication of repeated action dispatches.
21
+ */
22
+ interface IdempotencyCache {
23
+ /** Check whether an action ID has been executed. */
24
+ has(actionId: string): boolean;
25
+ /** Get a cached result by action ID or idempotency key. Returns `undefined` if not found or expired. */
26
+ get(key: string): CachedActionResult | undefined;
27
+ /** Cache an action result. Also stores by idempotencyKey if provided. */
28
+ set(actionId: string, result: CachedActionResult, idempotencyKey?: string): void;
29
+ }
30
+ /** Configuration for {@link MemoryIdempotencyCache}. */
31
+ interface IdempotencyCacheConfig {
32
+ /** Maximum number of entries in the cache. */
13
33
  maxSize?: number;
14
- /** Time-to-live for idempotency entries in milliseconds. */
34
+ /** Time-to-live for cache entries in milliseconds. */
15
35
  ttlMs?: number;
16
36
  }
37
+ /**
38
+ * In-memory idempotency cache with TTL expiration and bounded size.
39
+ *
40
+ * All state lives in a single Map keyed by actionId or `idem:{idempotencyKey}`.
41
+ * Stale entries are evicted on every `set()` call and the cache is
42
+ * trimmed to the configured max size (counting only non-idem entries).
43
+ */
44
+ declare class MemoryIdempotencyCache implements IdempotencyCache {
45
+ private readonly entries;
46
+ private readonly maxSize;
47
+ private readonly ttlMs;
48
+ constructor(config?: IdempotencyCacheConfig);
49
+ /** {@inheritDoc IdempotencyCache.has} */
50
+ has(actionId: string): boolean;
51
+ /** {@inheritDoc IdempotencyCache.get} */
52
+ get(key: string): CachedActionResult | undefined;
53
+ /** {@inheritDoc IdempotencyCache.set} */
54
+ set(actionId: string, result: CachedActionResult, idempotencyKey?: string): void;
55
+ /** Evict expired entries and trim to max size (counting only non-idem entries). */
56
+ private evictStaleEntries;
57
+ }
58
+
59
+ /** @deprecated Use {@link IdempotencyCacheConfig} instead. */
60
+ type ActionCacheConfig = IdempotencyCacheConfig;
17
61
  /**
18
62
  * Dispatches imperative actions to registered handlers.
19
63
  *
20
- * Manages idempotency via actionId deduplication and idempotencyKey mapping.
21
- * Caches are bounded by max size and TTL to prevent unbounded growth.
64
+ * Routing and handler management are separated from idempotency caching,
65
+ * which is delegated to an {@link IdempotencyCache} instance.
22
66
  * Completely decoupled from the HLC clock — takes a callback for timestamp generation.
23
67
  */
24
68
  declare class ActionDispatcher {
25
69
  private actionHandlers;
26
- private executedActions;
27
- private idempotencyMap;
28
- private readonly maxCacheSize;
29
- private readonly cacheTtlMs;
30
- constructor(handlers?: Record<string, ActionHandler>, cacheConfig?: ActionCacheConfig);
70
+ private readonly cache;
71
+ /**
72
+ * Create an ActionDispatcher.
73
+ *
74
+ * @param handlers - Optional map of connector name to action handler.
75
+ * @param cacheConfig - Optional cache configuration (used when no `cache` is provided).
76
+ * @param cache - Optional pre-built idempotency cache; defaults to a {@link MemoryIdempotencyCache}.
77
+ */
78
+ constructor(handlers?: Record<string, ActionHandler>, cacheConfig?: ActionCacheConfig, cache?: IdempotencyCache);
31
79
  /**
32
80
  * Dispatch an action push to registered handlers.
33
81
  *
@@ -69,12 +117,6 @@ declare class ActionDispatcher {
69
117
  * @returns An {@link ActionDiscovery} object listing connectors and their actions.
70
118
  */
71
119
  describe(): ActionDiscovery;
72
- /** Cache an action result for idempotency deduplication. */
73
- private cacheActionResult;
74
- /** Get a cached result if it exists and hasn't expired. */
75
- private getCachedResult;
76
- /** Evict expired entries and trim to max size. */
77
- private evictStaleEntries;
78
120
  }
79
121
 
80
122
  /**
@@ -174,12 +216,12 @@ declare class MemoryConfigStore implements ConfigStore {
174
216
  * Manages schema versioning and validation for the gateway.
175
217
  *
176
218
  * Validates incoming deltas against the current schema and supports
177
- * safe schema evolution (adding nullable columns only).
219
+ * safe schema evolution (adding nullable columns only). Schema, version,
220
+ * and allowed columns are held in a single {@link SchemaSnapshot} that
221
+ * is swapped atomically — no intermediate inconsistent state is possible.
178
222
  */
179
223
  declare class SchemaManager {
180
- private currentSchema;
181
- private version;
182
- private allowedColumns;
224
+ private state;
183
225
  constructor(schema: TableSchema, version?: number);
184
226
  /** Get the current schema and version. */
185
227
  getSchema(): {
@@ -376,6 +418,8 @@ declare class SyncGateway implements IngestTarget {
376
418
  * @returns Array of registered source adapter names.
377
419
  */
378
420
  listSources(): string[];
421
+ /** Rehydrate the buffer with persisted deltas (bypasses push validation). */
422
+ rehydrate(deltas: ReadonlyArray<RowDelta>): void;
379
423
  /** Get per-table buffer statistics. */
380
424
  get tableStats(): Array<{
381
425
  table: string;
@@ -465,4 +509,4 @@ declare function handleListConnectorTypes(): HandlerResult;
465
509
  */
466
510
  declare function handleMetrics(gateway: SyncGateway, extra?: Record<string, unknown>): HandlerResult;
467
511
 
468
- export { type ActionCacheConfig as A, type BufferConfig as B, type ConfigStore as C, DeltaBuffer as D, type FlushEnvelope as F, type GatewayConfig as G, type HandlePushResult as H, MemoryConfigStore as M, SchemaManager as S, ActionDispatcher as a, type GatewayState as b, type HandlerResult as c, SyncGateway as d, handleFlushRequest as e, handleListConnectorTypes as f, handleListConnectors as g, handleActionRequest as h, handleMetrics as i, handlePullRequest as j, handlePushRequest as k, handleRegisterConnector as l, handleSaveSchema as m, handleSaveSyncRules as n, handleUnregisterConnector as o };
512
+ export { type ActionCacheConfig as A, type BufferConfig as B, type CachedActionResult as C, DeltaBuffer as D, type FlushEnvelope as F, type GatewayConfig as G, type HandlePushResult as H, type IdempotencyCache as I, MemoryConfigStore as M, SchemaManager as S, ActionDispatcher as a, type ConfigStore as b, type GatewayState as c, type HandlerResult as d, type IdempotencyCacheConfig as e, MemoryIdempotencyCache as f, SyncGateway as g, handleActionRequest as h, handleFlushRequest as i, handleListConnectorTypes as j, handleListConnectors as k, handleMetrics as l, handlePullRequest as m, handlePushRequest as n, handleRegisterConnector as o, handleSaveSchema as p, handleSaveSyncRules as q, handleUnregisterConnector as r };
@@ -42,14 +42,15 @@ import {
42
42
  getConnectorDescriptor,
43
43
  isActionError,
44
44
  isActionHandler,
45
+ isDatabaseAdapter,
45
46
  isIngestTarget,
47
+ isMaterialisable,
46
48
  isValidIdentifier,
47
49
  listConnectorDescriptors,
48
50
  mapResult,
49
51
  quoteIdentifier,
50
52
  registerConnectorDescriptor,
51
53
  registerOutputSchemas,
52
- registerPollerFactory,
53
54
  resolveClientBuckets,
54
55
  resolveFilterValue,
55
56
  resolveLWW,
@@ -60,7 +61,7 @@ import {
60
61
  validateConnectorConfig,
61
62
  validateSyncRules,
62
63
  verifyToken
63
- } from "./chunk-LDFFCG2K.js";
64
+ } from "./chunk-4SG66H5K.js";
64
65
  import "./chunk-DGUM43GV.js";
65
66
  export {
66
67
  ActionExecutionError,
@@ -106,14 +107,15 @@ export {
106
107
  getConnectorDescriptor,
107
108
  isActionError,
108
109
  isActionHandler,
110
+ isDatabaseAdapter,
109
111
  isIngestTarget,
112
+ isMaterialisable,
110
113
  isValidIdentifier,
111
114
  listConnectorDescriptors,
112
115
  mapResult,
113
116
  quoteIdentifier,
114
117
  registerConnectorDescriptor,
115
118
  registerOutputSchemas,
116
- registerPollerFactory,
117
119
  resolveClientBuckets,
118
120
  resolveFilterValue,
119
121
  resolveLWW,
@@ -125,4 +127,4 @@ export {
125
127
  validateSyncRules,
126
128
  verifyToken
127
129
  };
128
- //# sourceMappingURL=src-ROW4XLO7.js.map
130
+ //# sourceMappingURL=src-WU7IBVC4.js.map
@@ -93,37 +93,47 @@ interface ConnectorIngestConfig {
93
93
  /** Approximate memory budget in bytes — triggers flush at 70%. */
94
94
  memoryBudgetBytes?: number;
95
95
  }
96
- /**
97
- * Configuration for a dynamically registered connector (data source).
98
- *
99
- * Discriminated union keyed on `type` — each variant carries exactly
100
- * its own connection config. No optional fields from other types.
101
- */
102
- type ConnectorConfig = {
103
- type: "postgres";
96
+ /** Base configuration shared by all connectors. */
97
+ interface ConnectorConfigBase {
98
+ /** Connector type identifier. */
99
+ type: string;
100
+ /** Unique connector name. */
104
101
  name: string;
105
- postgres: PostgresConnectorConfig;
102
+ /** Optional ingest polling configuration. */
106
103
  ingest?: ConnectorIngestConfig;
107
- } | {
104
+ }
105
+ /** Typed connector config for PostgreSQL. */
106
+ interface PostgresConnectorConfigFull extends ConnectorConfigBase {
107
+ type: "postgres";
108
+ postgres: PostgresConnectorConfig;
109
+ }
110
+ /** Typed connector config for MySQL. */
111
+ interface MySQLConnectorConfigFull extends ConnectorConfigBase {
108
112
  type: "mysql";
109
- name: string;
110
113
  mysql: MySQLConnectorConfig;
111
- ingest?: ConnectorIngestConfig;
112
- } | {
114
+ }
115
+ /** Typed connector config for BigQuery. */
116
+ interface BigQueryConnectorConfigFull extends ConnectorConfigBase {
113
117
  type: "bigquery";
114
- name: string;
115
118
  bigquery: BigQueryConnectorConfig;
116
- ingest?: ConnectorIngestConfig;
117
- } | {
119
+ }
120
+ /** Typed connector config for Jira Cloud. */
121
+ interface JiraConnectorConfigFull extends ConnectorConfigBase {
118
122
  type: "jira";
119
- name: string;
120
123
  jira: JiraConnectorConfig;
121
- ingest?: ConnectorIngestConfig;
122
- } | {
124
+ }
125
+ /** Typed connector config for Salesforce. */
126
+ interface SalesforceConnectorConfigFull extends ConnectorConfigBase {
123
127
  type: "salesforce";
124
- name: string;
125
128
  salesforce: SalesforceConnectorConfig;
126
- ingest?: ConnectorIngestConfig;
127
- };
129
+ }
130
+ /**
131
+ * Configuration for a dynamically registered connector (data source).
132
+ *
133
+ * Union of known connector configs plus an open base for extensibility.
134
+ * Existing switch statements still work for known types; unknown types
135
+ * can pass through via the open base.
136
+ */
137
+ type ConnectorConfig = PostgresConnectorConfigFull | MySQLConnectorConfigFull | BigQueryConnectorConfigFull | JiraConnectorConfigFull | SalesforceConnectorConfigFull | (ConnectorConfigBase & Record<string, unknown>);
128
138
 
129
- export { type BigQueryConnectorConfig as B, type ConnectorConfig as C, type JiraConnectorConfig as J, type MySQLConnectorConfig as M, type PostgresConnectorConfig as P, type SalesforceConnectorConfig as S, CONNECTOR_TYPES as a, type ConnectorIngestConfig as b, type ConnectorIngestTable as c, type ConnectorType as d };
139
+ export { type BigQueryConnectorConfig as B, type ConnectorConfig as C, type JiraConnectorConfig as J, type MySQLConnectorConfig as M, type PostgresConnectorConfig as P, type SalesforceConnectorConfig as S, type BigQueryConnectorConfigFull as a, CONNECTOR_TYPES as b, type ConnectorConfigBase as c, type ConnectorIngestConfig as d, type ConnectorIngestTable as e, type ConnectorType as f, type JiraConnectorConfigFull as g, type MySQLConnectorConfigFull as h, type PostgresConnectorConfigFull as i, type SalesforceConnectorConfigFull as j };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lakesync",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Local-first sync engine with pluggable backends — Postgres, MySQL, BigQuery, S3/R2 via Apache Iceberg",
6
6
  "license": "Apache-2.0",
@@ -1,30 +0,0 @@
1
- import { R as Result } from './result-CojzlFE2.js';
2
-
3
- /** Claims extracted from a verified JWT token */
4
- interface AuthClaims {
5
- /** Client identifier (from JWT `sub` claim) */
6
- clientId: string;
7
- /** Authorised gateway ID (from JWT `gw` claim) */
8
- gatewayId: string;
9
- /** Role for route-level access control (from JWT `role` claim, defaults to "client") */
10
- role: string;
11
- /** Non-standard JWT claims for sync rule evaluation */
12
- customClaims: Record<string, string | string[]>;
13
- }
14
- /** Authentication error returned when JWT verification fails */
15
- declare class AuthError extends Error {
16
- constructor(message: string);
17
- }
18
- /**
19
- * Verify a JWT token signed with HMAC-SHA256 and extract authentication claims.
20
- *
21
- * Uses the Web Crypto API exclusively (no external dependencies), making it
22
- * suitable for Cloudflare Workers and other edge runtimes.
23
- *
24
- * @param token - The raw JWT string (header.payload.signature)
25
- * @param secret - The HMAC-SHA256 secret key
26
- * @returns A Result containing AuthClaims on success, or AuthError on failure
27
- */
28
- declare function verifyToken(token: string, secret: string): Promise<Result<AuthClaims, AuthError>>;
29
-
30
- export { type AuthClaims as A, AuthError as a, verifyToken as v };