lakesync 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter.d.ts +87 -9
- package/dist/adapter.js +8 -2
- package/dist/analyst.js +1 -1
- package/dist/{base-poller-Dfaj05py.d.ts → base-poller-CBvhdvcj.d.ts} +1 -1
- package/dist/catalogue.d.ts +1 -1
- package/dist/catalogue.js +2 -2
- package/dist/{chunk-265CMYJH.js → chunk-46CKACNC.js} +2 -2
- package/dist/{chunk-C7ECMNQ4.js → chunk-7UBS6MFH.js} +295 -1
- package/dist/chunk-7UBS6MFH.js.map +1 -0
- package/dist/{chunk-TIPMVLIG.js → chunk-B3QEUG6E.js} +2 -2
- package/dist/{chunk-E7ZDOJCP.js → chunk-L4ZL5JA7.js} +2 -2
- package/dist/{chunk-HAR3YPCY.js → chunk-PWGQ3PXE.js} +32 -9
- package/dist/chunk-PWGQ3PXE.js.map +1 -0
- package/dist/{chunk-SXQB6JT6.js → chunk-SZSGSTVZ.js} +4 -2
- package/dist/{chunk-SXQB6JT6.js.map → chunk-SZSGSTVZ.js.map} +1 -1
- package/dist/{chunk-L6LTCXJ4.js → chunk-TVLTXHW6.js} +4 -2
- package/dist/{chunk-L6LTCXJ4.js.map → chunk-TVLTXHW6.js.map} +1 -1
- package/dist/{chunk-NCMXLWEW.js → chunk-Z7FGLEQU.js} +337 -20
- package/dist/chunk-Z7FGLEQU.js.map +1 -0
- package/dist/client.d.ts +12 -4
- package/dist/client.js +48 -3
- package/dist/client.js.map +1 -1
- package/dist/compactor.d.ts +1 -1
- package/dist/compactor.js +3 -3
- package/dist/connector-jira.d.ts +2 -2
- package/dist/connector-jira.js +2 -2
- package/dist/connector-salesforce.d.ts +2 -2
- package/dist/connector-salesforce.js +2 -2
- package/dist/{coordinator-CSbsqp5C.d.ts → coordinator-DN8D8C7W.d.ts} +11 -1
- package/dist/{db-types-CPAPw8Ws.d.ts → db-types-B6_JKQWK.d.ts} +1 -1
- package/dist/{gateway-Cej8JUh9.d.ts → gateway-CvO7Xy3T.d.ts} +5 -3
- package/dist/gateway-server.d.ts +4 -4
- package/dist/gateway-server.js +14 -8
- package/dist/gateway-server.js.map +1 -1
- package/dist/gateway.d.ts +12 -7
- package/dist/gateway.js +7 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +9 -1
- package/dist/parquet.d.ts +1 -1
- package/dist/parquet.js +2 -2
- package/dist/proto.d.ts +1 -1
- package/dist/proto.js +2 -2
- package/dist/react.d.ts +32 -3
- package/dist/react.js +54 -19
- package/dist/react.js.map +1 -1
- package/dist/registry-BN_9spxE.d.ts +53 -0
- package/dist/{resolver-B10tk8Er.d.ts → resolver-BZURzdlL.d.ts} +1 -1
- package/dist/{src-PPKRY5GD.js → src-RR7I76OL.js} +3 -3
- package/dist/{src-TLTET7JZ.js → src-SLVE5567.js} +10 -2
- package/dist/{src-VVCNNYND.js → src-V2CTPR7V.js} +3 -3
- package/dist/{types-BUzzVRD6.d.ts → types-GGBfZBKQ.d.ts} +3 -0
- package/package.json +1 -1
- package/dist/chunk-C7ECMNQ4.js.map +0 -1
- package/dist/chunk-HAR3YPCY.js.map +0 -1
- package/dist/chunk-NCMXLWEW.js.map +0 -1
- /package/dist/{chunk-265CMYJH.js.map → chunk-46CKACNC.js.map} +0 -0
- /package/dist/{chunk-TIPMVLIG.js.map → chunk-B3QEUG6E.js.map} +0 -0
- /package/dist/{chunk-E7ZDOJCP.js.map → chunk-L4ZL5JA7.js.map} +0 -0
- /package/dist/{src-PPKRY5GD.js.map → src-RR7I76OL.js.map} +0 -0
- /package/dist/{src-TLTET7JZ.js.map → src-SLVE5567.js.map} +0 -0
- /package/dist/{src-VVCNNYND.js.map → src-V2CTPR7V.js.map} +0 -0
package/dist/gateway.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { S as SyncRulesConfig, R as ResolvedClaims, b as SyncRulesContext, i as ActionPush } from './types-Bs-QyOe-.js';
|
|
2
2
|
export { d as ActionDiscovery, g as ActionHandler, j as ActionResponse, l as AuthContext } from './types-Bs-QyOe-.js';
|
|
3
|
-
export { I as IngestTarget, i as isIngestTarget } from './base-poller-
|
|
4
|
-
import { T as TableSchema, R as RowDelta, b as SyncPull, S as SyncPush } from './types-
|
|
5
|
-
export { c as SyncResponse } from './types-
|
|
3
|
+
export { I as IngestTarget, i as isIngestTarget } from './base-poller-CBvhdvcj.js';
|
|
4
|
+
import { T as TableSchema, R as RowDelta, b as SyncPull, S as SyncPush } from './types-GGBfZBKQ.js';
|
|
5
|
+
export { c as SyncResponse } from './types-GGBfZBKQ.js';
|
|
6
6
|
export { b as bigintReplacer, a as bigintReviver } from './json-dYtqiL0F.js';
|
|
7
|
-
import { S as SyncGateway } from './gateway-
|
|
8
|
-
export { A as ActionDispatcher, B as BufferConfig, D as DeltaBuffer, F as FlushEnvelope, G as GatewayConfig, a as GatewayState, H as HandlePushResult, b as SchemaManager } from './gateway-
|
|
7
|
+
import { S as SyncGateway } from './gateway-CvO7Xy3T.js';
|
|
8
|
+
export { A as ActionDispatcher, B as BufferConfig, D as DeltaBuffer, F as FlushEnvelope, G as GatewayConfig, a as GatewayState, H as HandlePushResult, b as SchemaManager } from './gateway-CvO7Xy3T.js';
|
|
9
9
|
import { C as ConnectorConfig } from './types-D-E0VrfS.js';
|
|
10
10
|
import { R as Result, F as FlushError, H as HLCTimestamp } from './result-CojzlFE2.js';
|
|
11
|
-
import { D as DatabaseAdapter } from './db-types-
|
|
11
|
+
import { D as DatabaseAdapter } from './db-types-B6_JKQWK.js';
|
|
12
12
|
import { L as LakeAdapter } from './types-DSC_EiwR.js';
|
|
13
13
|
import { N as NessieCatalogueClient } from './nessie-client-DrNikVXy.js';
|
|
14
14
|
import './hlc-DiD8QNG3.js';
|
|
@@ -70,6 +70,7 @@ interface FlushDeps {
|
|
|
70
70
|
adapter: LakeAdapter | DatabaseAdapter;
|
|
71
71
|
config: FlushConfig;
|
|
72
72
|
restoreEntries: (entries: RowDelta[]) => void;
|
|
73
|
+
schemas?: ReadonlyArray<TableSchema>;
|
|
73
74
|
}
|
|
74
75
|
/** Find the min and max HLC in a non-empty array of deltas. */
|
|
75
76
|
declare function hlcRange(entries: RowDelta[]): {
|
|
@@ -151,6 +152,10 @@ declare function handleUnregisterConnector(name: string, store: ConfigStore): Pr
|
|
|
151
152
|
* Handle listing connectors.
|
|
152
153
|
*/
|
|
153
154
|
declare function handleListConnectors(store: ConfigStore): Promise<HandlerResult>;
|
|
155
|
+
/**
|
|
156
|
+
* Handle listing available connector types (static metadata).
|
|
157
|
+
*/
|
|
158
|
+
declare function handleListConnectorTypes(): HandlerResult;
|
|
154
159
|
/**
|
|
155
160
|
* Handle metrics request.
|
|
156
161
|
*/
|
|
@@ -193,4 +198,4 @@ declare function pushErrorToStatus(code: string): number;
|
|
|
193
198
|
*/
|
|
194
199
|
declare function buildSyncRulesContext(rules: SyncRulesConfig | undefined, claims: ResolvedClaims): SyncRulesContext | undefined;
|
|
195
200
|
|
|
196
|
-
export { ActionPush, type ConfigStore, DEFAULT_MAX_BUFFER_AGE_MS, DEFAULT_MAX_BUFFER_BYTES, DEFAULT_PULL_LIMIT, type FlushConfig, type FlushDeps, type HandlerResult, MAX_DELTAS_PER_PUSH, MAX_PULL_LIMIT, MAX_PUSH_PAYLOAD_BYTES, MemoryConfigStore, type RequestError, SyncGateway, SyncPull, SyncPush, VALID_COLUMN_TYPES, buildSyncRulesContext, commitToCatalogue, flushEntries, handleActionRequest, handleFlushRequest, handleListConnectors, handleMetrics, handlePullRequest, handlePushRequest, handleRegisterConnector, handleSaveSchema, handleSaveSyncRules, handleUnregisterConnector, hlcRange, parsePullParams, pushErrorToStatus, validateActionBody, validatePushBody, validateSchemaBody };
|
|
201
|
+
export { ActionPush, type ConfigStore, DEFAULT_MAX_BUFFER_AGE_MS, DEFAULT_MAX_BUFFER_BYTES, DEFAULT_PULL_LIMIT, type FlushConfig, type FlushDeps, type HandlerResult, MAX_DELTAS_PER_PUSH, MAX_PULL_LIMIT, MAX_PUSH_PAYLOAD_BYTES, MemoryConfigStore, type RequestError, SyncGateway, SyncPull, SyncPush, VALID_COLUMN_TYPES, buildSyncRulesContext, commitToCatalogue, flushEntries, handleActionRequest, handleFlushRequest, handleListConnectorTypes, handleListConnectors, handleMetrics, handlePullRequest, handlePushRequest, handleRegisterConnector, handleSaveSchema, handleSaveSyncRules, handleUnregisterConnector, hlcRange, parsePullParams, pushErrorToStatus, validateActionBody, validatePushBody, validateSchemaBody };
|
package/dist/gateway.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
flushEntries,
|
|
17
17
|
handleActionRequest,
|
|
18
18
|
handleFlushRequest,
|
|
19
|
+
handleListConnectorTypes,
|
|
19
20
|
handleListConnectors,
|
|
20
21
|
handleMetrics,
|
|
21
22
|
handlePullRequest,
|
|
@@ -30,15 +31,15 @@ import {
|
|
|
30
31
|
validateActionBody,
|
|
31
32
|
validatePushBody,
|
|
32
33
|
validateSchemaBody
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import "./chunk-
|
|
35
|
-
import "./chunk-
|
|
36
|
-
import "./chunk-
|
|
34
|
+
} from "./chunk-PWGQ3PXE.js";
|
|
35
|
+
import "./chunk-Z7FGLEQU.js";
|
|
36
|
+
import "./chunk-B3QEUG6E.js";
|
|
37
|
+
import "./chunk-46CKACNC.js";
|
|
37
38
|
import {
|
|
38
39
|
bigintReplacer,
|
|
39
40
|
bigintReviver,
|
|
40
41
|
isIngestTarget
|
|
41
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-7UBS6MFH.js";
|
|
42
43
|
import "./chunk-7D4SUZUM.js";
|
|
43
44
|
export {
|
|
44
45
|
ActionDispatcher,
|
|
@@ -60,6 +61,7 @@ export {
|
|
|
60
61
|
flushEntries,
|
|
61
62
|
handleActionRequest,
|
|
62
63
|
handleFlushRequest,
|
|
64
|
+
handleListConnectorTypes,
|
|
63
65
|
handleListConnectors,
|
|
64
66
|
handleMetrics,
|
|
65
67
|
handlePullRequest,
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,12 @@ export { c as ActionDescriptor, d as ActionDiscovery, e as ActionErrorResult, f
|
|
|
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
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-
|
|
7
|
-
export { I as IngestTarget, a as PollerMemoryConfig, i as isIngestTarget } from './base-poller-
|
|
8
|
-
import { S as SyncPush, R as RowDelta, T as TableSchema } from './types-
|
|
9
|
-
export { C as ColumnDelta, D as DeltaOp, a as RowKey, b as SyncPull, c as SyncResponse, r as rowKey } from './types-
|
|
10
|
-
import { C as ConflictResolver } from './resolver-
|
|
6
|
+
import { P as PushTarget, B as BaseSourcePoller } from './base-poller-CBvhdvcj.js';
|
|
7
|
+
export { I as IngestTarget, a as PollerMemoryConfig, i as isIngestTarget } from './base-poller-CBvhdvcj.js';
|
|
8
|
+
import { S as SyncPush, R as RowDelta, T as TableSchema } from './types-GGBfZBKQ.js';
|
|
9
|
+
export { C as ColumnDelta, D as DeltaOp, a as RowKey, b as SyncPull, c as SyncResponse, r as rowKey } from './types-GGBfZBKQ.js';
|
|
10
|
+
import { C as ConflictResolver } from './resolver-BZURzdlL.js';
|
|
11
|
+
export { C as ConnectorCategory, a as ConnectorDescriptor, g as getConnectorDescriptor, l as listConnectorDescriptors, r as registerConnectorDescriptor, b as registerOutputSchemas } from './registry-BN_9spxE.js';
|
|
11
12
|
import { C as ConnectorConfig } from './types-D-E0VrfS.js';
|
|
12
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-D-E0VrfS.js';
|
|
13
14
|
export { H as HLC } from './hlc-DiD8QNG3.js';
|
package/dist/index.js
CHANGED
|
@@ -33,12 +33,16 @@ import {
|
|
|
33
33
|
flatMapResult,
|
|
34
34
|
fromPromise,
|
|
35
35
|
generateActionId,
|
|
36
|
+
getConnectorDescriptor,
|
|
36
37
|
isActionError,
|
|
37
38
|
isActionHandler,
|
|
38
39
|
isIngestTarget,
|
|
39
40
|
isValidIdentifier,
|
|
41
|
+
listConnectorDescriptors,
|
|
40
42
|
mapResult,
|
|
41
43
|
quoteIdentifier,
|
|
44
|
+
registerConnectorDescriptor,
|
|
45
|
+
registerOutputSchemas,
|
|
42
46
|
registerPollerFactory,
|
|
43
47
|
resolveClientBuckets,
|
|
44
48
|
resolveFilterValue,
|
|
@@ -50,7 +54,7 @@ import {
|
|
|
50
54
|
validateConnectorConfig,
|
|
51
55
|
validateSyncRules,
|
|
52
56
|
verifyToken
|
|
53
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-7UBS6MFH.js";
|
|
54
58
|
import "./chunk-7D4SUZUM.js";
|
|
55
59
|
export {
|
|
56
60
|
ActionExecutionError,
|
|
@@ -87,12 +91,16 @@ export {
|
|
|
87
91
|
flatMapResult,
|
|
88
92
|
fromPromise,
|
|
89
93
|
generateActionId,
|
|
94
|
+
getConnectorDescriptor,
|
|
90
95
|
isActionError,
|
|
91
96
|
isActionHandler,
|
|
92
97
|
isIngestTarget,
|
|
93
98
|
isValidIdentifier,
|
|
99
|
+
listConnectorDescriptors,
|
|
94
100
|
mapResult,
|
|
95
101
|
quoteIdentifier,
|
|
102
|
+
registerConnectorDescriptor,
|
|
103
|
+
registerOutputSchemas,
|
|
96
104
|
registerPollerFactory,
|
|
97
105
|
resolveClientBuckets,
|
|
98
106
|
resolveFilterValue,
|
package/dist/parquet.d.ts
CHANGED
package/dist/parquet.js
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
deltasToArrowTable,
|
|
4
4
|
readParquetToDeltas,
|
|
5
5
|
writeDeltasToParquet
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-46CKACNC.js";
|
|
7
|
+
import "./chunk-7UBS6MFH.js";
|
|
8
8
|
import "./chunk-7D4SUZUM.js";
|
|
9
9
|
export {
|
|
10
10
|
buildArrowSchema,
|
package/dist/proto.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { H as HLCTimestamp, R as Result } from './result-CojzlFE2.js';
|
|
2
2
|
import { i as ActionPush$1, j as ActionResponse$1 } from './types-Bs-QyOe-.js';
|
|
3
|
-
import { R as RowDelta$1 } from './types-
|
|
3
|
+
import { R as RowDelta$1 } from './types-GGBfZBKQ.js';
|
|
4
4
|
import { GenMessage, GenEnum } from '@bufbuild/protobuf/codegenv2';
|
|
5
5
|
import { Message } from '@bufbuild/protobuf';
|
|
6
6
|
|
package/dist/proto.js
CHANGED
|
@@ -29,8 +29,8 @@ import {
|
|
|
29
29
|
encodeSyncPull,
|
|
30
30
|
encodeSyncPush,
|
|
31
31
|
encodeSyncResponse
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-
|
|
32
|
+
} from "./chunk-L4ZL5JA7.js";
|
|
33
|
+
import "./chunk-7UBS6MFH.js";
|
|
34
34
|
import "./chunk-7D4SUZUM.js";
|
|
35
35
|
export {
|
|
36
36
|
ActionPushSchema,
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { b as SyncCoordinator, j as SyncTracker, D as DbError } from './coordinator-
|
|
2
|
+
import { b as SyncCoordinator, j as SyncTracker, D as DbError } from './coordinator-DN8D8C7W.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-BN_9spxE.js';
|
|
5
6
|
import './hlc-DiD8QNG3.js';
|
|
6
|
-
import './types-
|
|
7
|
+
import './types-GGBfZBKQ.js';
|
|
8
|
+
import './types-D-E0VrfS.js';
|
|
7
9
|
|
|
8
10
|
/** Internal context value shared across all hooks. */
|
|
9
11
|
interface LakeSyncContextValue {
|
|
@@ -95,6 +97,33 @@ interface UseActionDiscoveryResult {
|
|
|
95
97
|
*/
|
|
96
98
|
declare function useActionDiscovery(): UseActionDiscoveryResult;
|
|
97
99
|
|
|
100
|
+
/** Return type of `useConnectorTypes`. */
|
|
101
|
+
interface UseConnectorTypesResult {
|
|
102
|
+
/** Array of available connector type descriptors. */
|
|
103
|
+
types: ConnectorDescriptor[];
|
|
104
|
+
/** Whether discovery is loading. */
|
|
105
|
+
isLoading: boolean;
|
|
106
|
+
/** Error from the last fetch, or null. */
|
|
107
|
+
error: LakeSyncError | null;
|
|
108
|
+
/** Manually re-fetch connector types. */
|
|
109
|
+
refetch: () => void;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Discover available connector types and their configuration schemas.
|
|
113
|
+
*
|
|
114
|
+
* Calls `coordinator.listConnectorTypes()` on mount and returns the
|
|
115
|
+
* result reactively. Use this to build dynamic "Add Connector" forms.
|
|
116
|
+
*
|
|
117
|
+
* ```ts
|
|
118
|
+
* const { types, isLoading } = useConnectorTypes();
|
|
119
|
+
*
|
|
120
|
+
* for (const t of types) {
|
|
121
|
+
* console.log(t.displayName, t.configSchema);
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
declare function useConnectorTypes(): UseConnectorTypesResult;
|
|
126
|
+
|
|
98
127
|
/** Return type of `useMutation`. */
|
|
99
128
|
interface UseMutationResult {
|
|
100
129
|
insert: (table: string, rowId: string, data: Record<string, unknown>) => Promise<Result<void, LakeSyncError>>;
|
|
@@ -144,4 +173,4 @@ interface UseSyncStatusResult {
|
|
|
144
173
|
*/
|
|
145
174
|
declare function useSyncStatus(): UseSyncStatusResult;
|
|
146
175
|
|
|
147
|
-
export { type ActionParams, type LakeSyncContextValue, LakeSyncProvider, type LakeSyncProviderProps, type UseActionDiscoveryResult, type UseActionResult, type UseMutationResult, type UseQueryResult, type UseSyncStatusResult, useAction, useActionDiscovery, useLakeSync, useMutation, useQuery, useSyncStatus };
|
|
176
|
+
export { type ActionParams, type LakeSyncContextValue, LakeSyncProvider, type LakeSyncProviderProps, type UseActionDiscoveryResult, type UseActionResult, type UseConnectorTypesResult, type UseMutationResult, type UseQueryResult, type UseSyncStatusResult, useAction, useActionDiscovery, useConnectorTypes, useLakeSync, useMutation, useQuery, useSyncStatus };
|
package/dist/react.js
CHANGED
|
@@ -102,11 +102,45 @@ function useActionDiscovery() {
|
|
|
102
102
|
return { connectors, isLoading, error, refetch };
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
// ../react/src/use-connector-types.ts
|
|
106
|
+
import { useCallback as useCallback3, useEffect as useEffect3, useState as useState3 } from "react";
|
|
107
|
+
function useConnectorTypes() {
|
|
108
|
+
const { coordinator } = useLakeSync();
|
|
109
|
+
const [types, setTypes] = useState3([]);
|
|
110
|
+
const [isLoading, setIsLoading] = useState3(true);
|
|
111
|
+
const [error, setError] = useState3(null);
|
|
112
|
+
const [trigger, setTrigger] = useState3(0);
|
|
113
|
+
const refetch = useCallback3(() => {
|
|
114
|
+
setTrigger((v) => v + 1);
|
|
115
|
+
}, []);
|
|
116
|
+
useEffect3(() => {
|
|
117
|
+
void trigger;
|
|
118
|
+
let cancelled = false;
|
|
119
|
+
const run = async () => {
|
|
120
|
+
setIsLoading(true);
|
|
121
|
+
const result = await coordinator.listConnectorTypes();
|
|
122
|
+
if (cancelled) return;
|
|
123
|
+
if (result.ok) {
|
|
124
|
+
setTypes(result.value);
|
|
125
|
+
setError(null);
|
|
126
|
+
} else {
|
|
127
|
+
setError(result.error);
|
|
128
|
+
}
|
|
129
|
+
setIsLoading(false);
|
|
130
|
+
};
|
|
131
|
+
run();
|
|
132
|
+
return () => {
|
|
133
|
+
cancelled = true;
|
|
134
|
+
};
|
|
135
|
+
}, [coordinator, trigger]);
|
|
136
|
+
return { types, isLoading, error, refetch };
|
|
137
|
+
}
|
|
138
|
+
|
|
105
139
|
// ../react/src/use-mutation.ts
|
|
106
|
-
import { useCallback as
|
|
140
|
+
import { useCallback as useCallback4 } from "react";
|
|
107
141
|
function useMutation() {
|
|
108
142
|
const { tracker, invalidate } = useLakeSync();
|
|
109
|
-
const insert =
|
|
143
|
+
const insert = useCallback4(
|
|
110
144
|
async (table, rowId, data) => {
|
|
111
145
|
const result = await tracker.insert(table, rowId, data);
|
|
112
146
|
if (result.ok) invalidate();
|
|
@@ -114,7 +148,7 @@ function useMutation() {
|
|
|
114
148
|
},
|
|
115
149
|
[tracker, invalidate]
|
|
116
150
|
);
|
|
117
|
-
const update =
|
|
151
|
+
const update = useCallback4(
|
|
118
152
|
async (table, rowId, data) => {
|
|
119
153
|
const result = await tracker.update(table, rowId, data);
|
|
120
154
|
if (result.ok) invalidate();
|
|
@@ -122,7 +156,7 @@ function useMutation() {
|
|
|
122
156
|
},
|
|
123
157
|
[tracker, invalidate]
|
|
124
158
|
);
|
|
125
|
-
const remove =
|
|
159
|
+
const remove = useCallback4(
|
|
126
160
|
async (table, rowId) => {
|
|
127
161
|
const result = await tracker.delete(table, rowId);
|
|
128
162
|
if (result.ok) invalidate();
|
|
@@ -134,21 +168,21 @@ function useMutation() {
|
|
|
134
168
|
}
|
|
135
169
|
|
|
136
170
|
// ../react/src/use-query.ts
|
|
137
|
-
import { useCallback as
|
|
171
|
+
import { useCallback as useCallback5, useEffect as useEffect4, useRef, useState as useState4 } from "react";
|
|
138
172
|
function useQuery(sql, params) {
|
|
139
173
|
const { tracker, dataVersion } = useLakeSync();
|
|
140
|
-
const [data, setData] =
|
|
141
|
-
const [error, setError] =
|
|
142
|
-
const [isLoading, setIsLoading] =
|
|
143
|
-
const [manualTrigger, setManualTrigger] =
|
|
174
|
+
const [data, setData] = useState4([]);
|
|
175
|
+
const [error, setError] = useState4(null);
|
|
176
|
+
const [isLoading, setIsLoading] = useState4(true);
|
|
177
|
+
const [manualTrigger, setManualTrigger] = useState4(0);
|
|
144
178
|
const paramsKey = JSON.stringify(params ?? []);
|
|
145
179
|
const paramsRef = useRef(params);
|
|
146
180
|
paramsRef.current = params;
|
|
147
|
-
const refetch =
|
|
181
|
+
const refetch = useCallback5(() => {
|
|
148
182
|
setManualTrigger((v) => v + 1);
|
|
149
183
|
}, []);
|
|
150
184
|
const version = `${dataVersion}:${manualTrigger}:${paramsKey}`;
|
|
151
|
-
|
|
185
|
+
useEffect4(() => {
|
|
152
186
|
void version;
|
|
153
187
|
let cancelled = false;
|
|
154
188
|
const run = async () => {
|
|
@@ -171,18 +205,18 @@ function useQuery(sql, params) {
|
|
|
171
205
|
}
|
|
172
206
|
|
|
173
207
|
// ../react/src/use-sync-status.ts
|
|
174
|
-
import { useCallback as
|
|
208
|
+
import { useCallback as useCallback6, useEffect as useEffect5, useState as useState5 } from "react";
|
|
175
209
|
function useSyncStatus() {
|
|
176
210
|
const { coordinator, dataVersion } = useLakeSync();
|
|
177
|
-
const [isSyncing, setIsSyncing] =
|
|
178
|
-
const [lastSyncTime, setLastSyncTime] =
|
|
179
|
-
const [queueDepth, setQueueDepth] =
|
|
180
|
-
const [error, setError] =
|
|
181
|
-
const refreshQueueDepth =
|
|
211
|
+
const [isSyncing, setIsSyncing] = useState5(false);
|
|
212
|
+
const [lastSyncTime, setLastSyncTime] = useState5(null);
|
|
213
|
+
const [queueDepth, setQueueDepth] = useState5(0);
|
|
214
|
+
const [error, setError] = useState5(null);
|
|
215
|
+
const refreshQueueDepth = useCallback6(async () => {
|
|
182
216
|
const depth = await coordinator.queueDepth();
|
|
183
217
|
setQueueDepth(depth);
|
|
184
218
|
}, [coordinator]);
|
|
185
|
-
|
|
219
|
+
useEffect5(() => {
|
|
186
220
|
const handleSyncComplete = () => {
|
|
187
221
|
setIsSyncing(false);
|
|
188
222
|
setLastSyncTime(coordinator.lastSyncTime);
|
|
@@ -206,7 +240,7 @@ function useSyncStatus() {
|
|
|
206
240
|
coordinator.off("onChange", handleChange);
|
|
207
241
|
};
|
|
208
242
|
}, [coordinator, refreshQueueDepth]);
|
|
209
|
-
|
|
243
|
+
useEffect5(() => {
|
|
210
244
|
void dataVersion;
|
|
211
245
|
refreshQueueDepth();
|
|
212
246
|
}, [dataVersion, refreshQueueDepth]);
|
|
@@ -216,6 +250,7 @@ export {
|
|
|
216
250
|
LakeSyncProvider,
|
|
217
251
|
useAction,
|
|
218
252
|
useActionDiscovery,
|
|
253
|
+
useConnectorTypes,
|
|
219
254
|
useLakeSync,
|
|
220
255
|
useMutation,
|
|
221
256
|
useQuery,
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../react/src/context.ts","../../react/src/use-action.ts","../../react/src/use-mutation.ts","../../react/src/use-query.ts","../../react/src/use-sync-status.ts"],"sourcesContent":["import type { SyncCoordinator, SyncTracker } from \"@lakesync/client\";\nimport {\n\tcreateContext,\n\tcreateElement,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseState,\n} from \"react\";\n\n/** Internal context value shared across all hooks. */\nexport interface LakeSyncContextValue {\n\tcoordinator: SyncCoordinator;\n\ttracker: SyncTracker;\n\t/** Monotonically increasing counter — bumped on every data change. */\n\tdataVersion: number;\n\t/** Increment dataVersion to trigger query re-runs. */\n\tinvalidate: () => void;\n}\n\nconst LakeSyncContext = createContext<LakeSyncContextValue | null>(null);\n\n/** Props for the LakeSyncProvider component. */\nexport interface LakeSyncProviderProps {\n\t/** An already-constructed SyncCoordinator instance. */\n\tcoordinator: SyncCoordinator;\n\tchildren: React.ReactNode;\n}\n\n/**\n * Provides LakeSync context to the component tree.\n *\n * Subscribes to `onChange` events from the coordinator and maintains a\n * `dataVersion` counter that increments on every remote delta application,\n * triggering reactive query re-runs in `useQuery`.\n */\nexport function LakeSyncProvider(props: LakeSyncProviderProps) {\n\tconst { coordinator, children } = props;\n\tconst [dataVersion, setDataVersion] = useState(0);\n\n\tconst invalidate = useCallback(() => {\n\t\tsetDataVersion((v) => v + 1);\n\t}, []);\n\n\tuseEffect(() => {\n\t\tconst handleChange = () => {\n\t\t\tsetDataVersion((v) => v + 1);\n\t\t};\n\t\tcoordinator.on(\"onChange\", handleChange);\n\t\treturn () => {\n\t\t\tcoordinator.off(\"onChange\", handleChange);\n\t\t};\n\t}, [coordinator]);\n\n\tconst value = useMemo<LakeSyncContextValue>(\n\t\t() => ({\n\t\t\tcoordinator,\n\t\t\ttracker: coordinator.tracker,\n\t\t\tdataVersion,\n\t\t\tinvalidate,\n\t\t}),\n\t\t[coordinator, dataVersion, invalidate],\n\t);\n\n\treturn createElement(LakeSyncContext.Provider, { value }, children);\n}\n\n/**\n * Access the raw LakeSync SDK instances from context.\n *\n * @throws if called outside a `<LakeSyncProvider>`.\n */\nexport function useLakeSync(): LakeSyncContextValue {\n\tconst ctx = useContext(LakeSyncContext);\n\tif (!ctx) {\n\t\tthrow new Error(\"useLakeSync must be used within a <LakeSyncProvider>\");\n\t}\n\treturn ctx;\n}\n","import type {\n\tActionDescriptor,\n\tActionErrorResult,\n\tActionResult,\n\tLakeSyncError,\n} from \"@lakesync/core\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { useLakeSync } from \"./context\";\n\n/** Parameters for a single action execution. */\nexport interface ActionParams {\n\tconnector: string;\n\tactionType: string;\n\tparams: Record<string, unknown>;\n\tidempotencyKey?: string;\n}\n\n/** Return type of `useAction`. */\nexport interface UseActionResult {\n\t/** Execute an action against a connector via the gateway. */\n\texecute: (params: ActionParams) => Promise<void>;\n\t/** Last action result (success or error). Null before first execution. */\n\tlastResult: ActionResult | ActionErrorResult | null;\n\t/** Whether an action is currently in flight. */\n\tisPending: boolean;\n}\n\n/**\n * Execute imperative actions against external systems via the gateway.\n *\n * Wraps `SyncCoordinator.executeAction()` and subscribes to\n * `onActionComplete` events to track the latest result.\n *\n * ```ts\n * const { execute, lastResult, isPending } = useAction();\n *\n * await execute({\n * connector: \"slack\",\n * actionType: \"send_message\",\n * params: { channel: \"#general\", text: \"Hello\" },\n * });\n * ```\n */\nexport function useAction(): UseActionResult {\n\tconst { coordinator } = useLakeSync();\n\tconst [lastResult, setLastResult] = useState<ActionResult | ActionErrorResult | null>(null);\n\tconst [isPending, setIsPending] = useState(false);\n\n\tuseEffect(() => {\n\t\tconst handleComplete = (_actionId: string, result: ActionResult | ActionErrorResult) => {\n\t\t\tsetLastResult(result);\n\t\t\tsetIsPending(false);\n\t\t};\n\n\t\tcoordinator.on(\"onActionComplete\", handleComplete);\n\t\treturn () => {\n\t\t\tcoordinator.off(\"onActionComplete\", handleComplete);\n\t\t};\n\t}, [coordinator]);\n\n\tconst execute = useCallback(\n\t\tasync (params: ActionParams): Promise<void> => {\n\t\t\tsetIsPending(true);\n\t\t\tawait coordinator.executeAction(params);\n\t\t},\n\t\t[coordinator],\n\t);\n\n\treturn { execute, lastResult, isPending };\n}\n\n/** Return type of `useActionDiscovery`. */\nexport interface UseActionDiscoveryResult {\n\t/** Map of connector name to supported action descriptors. */\n\tconnectors: Record<string, ActionDescriptor[]>;\n\t/** Whether discovery is loading. */\n\tisLoading: boolean;\n\t/** Error from the last fetch, or null. */\n\terror: LakeSyncError | null;\n\t/** Manually re-fetch available actions. */\n\trefetch: () => void;\n}\n\n/**\n * Discover available connectors and their supported action types.\n *\n * Calls `transport.describeActions()` on mount and returns the result\n * reactively. Use this to build dynamic UI based on available actions.\n *\n * ```ts\n * const { connectors, isLoading } = useActionDiscovery();\n *\n * for (const [name, actions] of Object.entries(connectors)) {\n * console.log(name, actions.map(a => a.actionType));\n * }\n * ```\n */\nexport function useActionDiscovery(): UseActionDiscoveryResult {\n\tconst { coordinator } = useLakeSync();\n\tconst [connectors, setConnectors] = useState<Record<string, ActionDescriptor[]>>({});\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<LakeSyncError | null>(null);\n\tconst [trigger, setTrigger] = useState(0);\n\n\tconst refetch = useCallback(() => {\n\t\tsetTrigger((v) => v + 1);\n\t}, []);\n\n\tuseEffect(() => {\n\t\tvoid trigger;\n\t\tlet cancelled = false;\n\n\t\tconst run = async () => {\n\t\t\tsetIsLoading(true);\n\t\t\tconst result = await coordinator.describeActions();\n\t\t\tif (cancelled) return;\n\n\t\t\tif (result.ok) {\n\t\t\t\tsetConnectors(result.value.connectors);\n\t\t\t\tsetError(null);\n\t\t\t} else {\n\t\t\t\tsetError(result.error);\n\t\t\t}\n\t\t\tsetIsLoading(false);\n\t\t};\n\n\t\trun();\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [coordinator, trigger]);\n\n\treturn { connectors, isLoading, error, refetch };\n}\n","import type { LakeSyncError, Result } from \"@lakesync/core\";\nimport { useCallback } from \"react\";\nimport { useLakeSync } from \"./context\";\n\n/** Return type of `useMutation`. */\nexport interface UseMutationResult {\n\tinsert: (\n\t\ttable: string,\n\t\trowId: string,\n\t\tdata: Record<string, unknown>,\n\t) => Promise<Result<void, LakeSyncError>>;\n\tupdate: (\n\t\ttable: string,\n\t\trowId: string,\n\t\tdata: Record<string, unknown>,\n\t) => Promise<Result<void, LakeSyncError>>;\n\tremove: (table: string, rowId: string) => Promise<Result<void, LakeSyncError>>;\n}\n\n/**\n * Wraps SyncTracker mutations with automatic query invalidation.\n *\n * After each successful mutation, `dataVersion` is incremented so all\n * active `useQuery` hooks re-run.\n */\nexport function useMutation(): UseMutationResult {\n\tconst { tracker, invalidate } = useLakeSync();\n\n\tconst insert = useCallback(\n\t\tasync (\n\t\t\ttable: string,\n\t\t\trowId: string,\n\t\t\tdata: Record<string, unknown>,\n\t\t): Promise<Result<void, LakeSyncError>> => {\n\t\t\tconst result = await tracker.insert(table, rowId, data);\n\t\t\tif (result.ok) invalidate();\n\t\t\treturn result;\n\t\t},\n\t\t[tracker, invalidate],\n\t);\n\n\tconst update = useCallback(\n\t\tasync (\n\t\t\ttable: string,\n\t\t\trowId: string,\n\t\t\tdata: Record<string, unknown>,\n\t\t): Promise<Result<void, LakeSyncError>> => {\n\t\t\tconst result = await tracker.update(table, rowId, data);\n\t\t\tif (result.ok) invalidate();\n\t\t\treturn result;\n\t\t},\n\t\t[tracker, invalidate],\n\t);\n\n\tconst remove = useCallback(\n\t\tasync (table: string, rowId: string): Promise<Result<void, LakeSyncError>> => {\n\t\t\tconst result = await tracker.delete(table, rowId);\n\t\t\tif (result.ok) invalidate();\n\t\t\treturn result;\n\t\t},\n\t\t[tracker, invalidate],\n\t);\n\n\treturn { insert, update, remove };\n}\n","import type { DbError } from \"@lakesync/client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useLakeSync } from \"./context\";\n\n/** Return type of `useQuery`. */\nexport interface UseQueryResult<T> {\n\tdata: T[];\n\terror: DbError | null;\n\tisLoading: boolean;\n\trefetch: () => void;\n}\n\n/**\n * Reactive SQL query hook.\n *\n * Re-runs automatically when:\n * - Remote deltas are applied (via `onChange`)\n * - A local mutation completes (via `invalidate()`)\n * - The `sql` or `params` arguments change\n *\n * @param sql - SQL query string\n * @param params - Optional bind parameters\n */\nexport function useQuery<T>(sql: string, params?: unknown[]): UseQueryResult<T> {\n\tconst { tracker, dataVersion } = useLakeSync();\n\tconst [data, setData] = useState<T[]>([]);\n\tconst [error, setError] = useState<DbError | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [manualTrigger, setManualTrigger] = useState(0);\n\n\t// Stable serialisation of params for dependency comparison\n\tconst paramsKey = JSON.stringify(params ?? []);\n\tconst paramsRef = useRef(params);\n\tparamsRef.current = params;\n\n\tconst refetch = useCallback(() => {\n\t\tsetManualTrigger((v) => v + 1);\n\t}, []);\n\n\t// Combine all trigger values into a single version for the effect.\n\t// This satisfies exhaustive-deps: the effect reads `version` directly.\n\tconst version = `${dataVersion}:${manualTrigger}:${paramsKey}`;\n\n\tuseEffect(() => {\n\t\t// Read version to establish dependency\n\t\tvoid version;\n\t\tlet cancelled = false;\n\n\t\tconst run = async () => {\n\t\t\tconst result = await tracker.query<T>(sql, paramsRef.current);\n\t\t\tif (cancelled) return;\n\n\t\t\tif (result.ok) {\n\t\t\t\tsetData(result.value);\n\t\t\t\tsetError(null);\n\t\t\t} else {\n\t\t\t\tsetError(result.error);\n\t\t\t}\n\t\t\tsetIsLoading(false);\n\t\t};\n\n\t\trun();\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [tracker, sql, version]);\n\n\treturn { data, error, isLoading, refetch };\n}\n","import { useCallback, useEffect, useState } from \"react\";\nimport { useLakeSync } from \"./context\";\n\n/** Return type of `useSyncStatus`. */\nexport interface UseSyncStatusResult {\n\tisSyncing: boolean;\n\tlastSyncTime: Date | null;\n\tqueueDepth: number;\n\terror: Error | null;\n}\n\n/**\n * Observe the sync lifecycle.\n *\n * Tracks whether a sync is in progress, last successful sync time,\n * outbox queue depth, and the most recent sync error (cleared on success).\n */\nexport function useSyncStatus(): UseSyncStatusResult {\n\tconst { coordinator, dataVersion } = useLakeSync();\n\tconst [isSyncing, setIsSyncing] = useState(false);\n\tconst [lastSyncTime, setLastSyncTime] = useState<Date | null>(null);\n\tconst [queueDepth, setQueueDepth] = useState(0);\n\tconst [error, setError] = useState<Error | null>(null);\n\n\tconst refreshQueueDepth = useCallback(async () => {\n\t\tconst depth = await coordinator.queueDepth();\n\t\tsetQueueDepth(depth);\n\t}, [coordinator]);\n\n\tuseEffect(() => {\n\t\tconst handleSyncComplete = () => {\n\t\t\tsetIsSyncing(false);\n\t\t\tsetLastSyncTime(coordinator.lastSyncTime);\n\t\t\tsetError(null);\n\t\t\trefreshQueueDepth();\n\t\t};\n\n\t\tconst handleError = (err: Error) => {\n\t\t\tsetIsSyncing(false);\n\t\t\tsetError(err);\n\t\t};\n\n\t\tconst handleChange = () => {\n\t\t\trefreshQueueDepth();\n\t\t};\n\n\t\tcoordinator.on(\"onSyncComplete\", handleSyncComplete);\n\t\tcoordinator.on(\"onError\", handleError);\n\t\tcoordinator.on(\"onChange\", handleChange);\n\n\t\t// Initial queue depth\n\t\trefreshQueueDepth();\n\n\t\treturn () => {\n\t\t\tcoordinator.off(\"onSyncComplete\", handleSyncComplete);\n\t\t\tcoordinator.off(\"onError\", handleError);\n\t\t\tcoordinator.off(\"onChange\", handleChange);\n\t\t};\n\t}, [coordinator, refreshQueueDepth]);\n\n\t// Also refresh queue depth when dataVersion changes (local mutations)\n\tuseEffect(() => {\n\t\tvoid dataVersion;\n\t\trefreshQueueDepth();\n\t}, [dataVersion, refreshQueueDepth]);\n\n\treturn { isSyncing, lastSyncTime, queueDepth, error };\n}\n"],"mappings":";;;AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAYP,IAAM,kBAAkB,cAA2C,IAAI;AAgBhE,SAAS,iBAAiB,OAA8B;AAC9D,QAAM,EAAE,aAAa,SAAS,IAAI;AAClC,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,CAAC;AAEhD,QAAM,aAAa,YAAY,MAAM;AACpC,mBAAe,CAAC,MAAM,IAAI,CAAC;AAAA,EAC5B,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACf,UAAM,eAAe,MAAM;AAC1B,qBAAe,CAAC,MAAM,IAAI,CAAC;AAAA,IAC5B;AACA,gBAAY,GAAG,YAAY,YAAY;AACvC,WAAO,MAAM;AACZ,kBAAY,IAAI,YAAY,YAAY;AAAA,IACzC;AAAA,EACD,GAAG,CAAC,WAAW,CAAC;AAEhB,QAAM,QAAQ;AAAA,IACb,OAAO;AAAA,MACN;AAAA,MACA,SAAS,YAAY;AAAA,MACrB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AY,IAAIC,UAAS,KAAK;AAChD,QAAM,CAAC,cAAc,eAAe,IAAIA,UAAsB,IAAI;AAClE,QAAM,CAAC,YAAY,aAAa,IAAIA,UAAS,CAAC;AAC9C,QAAM,CAAC,OAAO,QAAQ,IAAIA,UAAuB,IAAI;AAErD,QAAM,oBAAoBC,aAAY,YAAY;AACjD,UAAM,QAAQ,MAAM,YAAY,WAAW;AAC3C,kBAAc,KAAK;AAAA,EACpB,GAAG,CAAC,WAAW,CAAC;AAEhB,EAAAC,WAAU,MAAM;AACf,UAAM,qBAAqB,MAAM;AAChC,mBAAa,KAAK;AAClB,sBAAgB,YAAY,YAAY;AACxC,eAAS,IAAI;AACb,wBAAkB;AAAA,IACnB;AAEA,UAAM,cAAc,CAAC,QAAe;AACnC,mBAAa,KAAK;AAClB,eAAS,GAAG;AAAA,IACb;AAEA,UAAM,eAAe,MAAM;AAC1B,wBAAkB;AAAA,IACnB;AAEA,gBAAY,GAAG,kBAAkB,kBAAkB;AACnD,gBAAY,GAAG,WAAW,WAAW;AACrC,gBAAY,GAAG,YAAY,YAAY;AAGvC,sBAAkB;AAElB,WAAO,MAAM;AACZ,kBAAY,IAAI,kBAAkB,kBAAkB;AACpD,kBAAY,IAAI,WAAW,WAAW;AACtC,kBAAY,IAAI,YAAY,YAAY;AAAA,IACzC;AAAA,EACD,GAAG,CAAC,aAAa,iBAAiB,CAAC;AAGnC,EAAAA,WAAU,MAAM;AACf,SAAK;AACL,sBAAkB;AAAA,EACnB,GAAG,CAAC,aAAa,iBAAiB,CAAC;AAEnC,SAAO,EAAE,WAAW,cAAc,YAAY,MAAM;AACrD;","names":["useCallback","useEffect","useState","useState","useEffect","useCallback","useCallback","useCallback","useCallback","useEffect","useState","useState","useCallback","useEffect","useCallback","useEffect","useState","useState","useCallback","useEffect"]}
|
|
1
|
+
{"version":3,"sources":["../../react/src/context.ts","../../react/src/use-action.ts","../../react/src/use-connector-types.ts","../../react/src/use-mutation.ts","../../react/src/use-query.ts","../../react/src/use-sync-status.ts"],"sourcesContent":["import type { SyncCoordinator, SyncTracker } from \"@lakesync/client\";\nimport {\n\tcreateContext,\n\tcreateElement,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseState,\n} from \"react\";\n\n/** Internal context value shared across all hooks. */\nexport interface LakeSyncContextValue {\n\tcoordinator: SyncCoordinator;\n\ttracker: SyncTracker;\n\t/** Monotonically increasing counter — bumped on every data change. */\n\tdataVersion: number;\n\t/** Increment dataVersion to trigger query re-runs. */\n\tinvalidate: () => void;\n}\n\nconst LakeSyncContext = createContext<LakeSyncContextValue | null>(null);\n\n/** Props for the LakeSyncProvider component. */\nexport interface LakeSyncProviderProps {\n\t/** An already-constructed SyncCoordinator instance. */\n\tcoordinator: SyncCoordinator;\n\tchildren: React.ReactNode;\n}\n\n/**\n * Provides LakeSync context to the component tree.\n *\n * Subscribes to `onChange` events from the coordinator and maintains a\n * `dataVersion` counter that increments on every remote delta application,\n * triggering reactive query re-runs in `useQuery`.\n */\nexport function LakeSyncProvider(props: LakeSyncProviderProps) {\n\tconst { coordinator, children } = props;\n\tconst [dataVersion, setDataVersion] = useState(0);\n\n\tconst invalidate = useCallback(() => {\n\t\tsetDataVersion((v) => v + 1);\n\t}, []);\n\n\tuseEffect(() => {\n\t\tconst handleChange = () => {\n\t\t\tsetDataVersion((v) => v + 1);\n\t\t};\n\t\tcoordinator.on(\"onChange\", handleChange);\n\t\treturn () => {\n\t\t\tcoordinator.off(\"onChange\", handleChange);\n\t\t};\n\t}, [coordinator]);\n\n\tconst value = useMemo<LakeSyncContextValue>(\n\t\t() => ({\n\t\t\tcoordinator,\n\t\t\ttracker: coordinator.tracker,\n\t\t\tdataVersion,\n\t\t\tinvalidate,\n\t\t}),\n\t\t[coordinator, dataVersion, invalidate],\n\t);\n\n\treturn createElement(LakeSyncContext.Provider, { value }, children);\n}\n\n/**\n * Access the raw LakeSync SDK instances from context.\n *\n * @throws if called outside a `<LakeSyncProvider>`.\n */\nexport function useLakeSync(): LakeSyncContextValue {\n\tconst ctx = useContext(LakeSyncContext);\n\tif (!ctx) {\n\t\tthrow new Error(\"useLakeSync must be used within a <LakeSyncProvider>\");\n\t}\n\treturn ctx;\n}\n","import type {\n\tActionDescriptor,\n\tActionErrorResult,\n\tActionResult,\n\tLakeSyncError,\n} from \"@lakesync/core\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { useLakeSync } from \"./context\";\n\n/** Parameters for a single action execution. */\nexport interface ActionParams {\n\tconnector: string;\n\tactionType: string;\n\tparams: Record<string, unknown>;\n\tidempotencyKey?: string;\n}\n\n/** Return type of `useAction`. */\nexport interface UseActionResult {\n\t/** Execute an action against a connector via the gateway. */\n\texecute: (params: ActionParams) => Promise<void>;\n\t/** Last action result (success or error). Null before first execution. */\n\tlastResult: ActionResult | ActionErrorResult | null;\n\t/** Whether an action is currently in flight. */\n\tisPending: boolean;\n}\n\n/**\n * Execute imperative actions against external systems via the gateway.\n *\n * Wraps `SyncCoordinator.executeAction()` and subscribes to\n * `onActionComplete` events to track the latest result.\n *\n * ```ts\n * const { execute, lastResult, isPending } = useAction();\n *\n * await execute({\n * connector: \"slack\",\n * actionType: \"send_message\",\n * params: { channel: \"#general\", text: \"Hello\" },\n * });\n * ```\n */\nexport function useAction(): UseActionResult {\n\tconst { coordinator } = useLakeSync();\n\tconst [lastResult, setLastResult] = useState<ActionResult | ActionErrorResult | null>(null);\n\tconst [isPending, setIsPending] = useState(false);\n\n\tuseEffect(() => {\n\t\tconst handleComplete = (_actionId: string, result: ActionResult | ActionErrorResult) => {\n\t\t\tsetLastResult(result);\n\t\t\tsetIsPending(false);\n\t\t};\n\n\t\tcoordinator.on(\"onActionComplete\", handleComplete);\n\t\treturn () => {\n\t\t\tcoordinator.off(\"onActionComplete\", handleComplete);\n\t\t};\n\t}, [coordinator]);\n\n\tconst execute = useCallback(\n\t\tasync (params: ActionParams): Promise<void> => {\n\t\t\tsetIsPending(true);\n\t\t\tawait coordinator.executeAction(params);\n\t\t},\n\t\t[coordinator],\n\t);\n\n\treturn { execute, lastResult, isPending };\n}\n\n/** Return type of `useActionDiscovery`. */\nexport interface UseActionDiscoveryResult {\n\t/** Map of connector name to supported action descriptors. */\n\tconnectors: Record<string, ActionDescriptor[]>;\n\t/** Whether discovery is loading. */\n\tisLoading: boolean;\n\t/** Error from the last fetch, or null. */\n\terror: LakeSyncError | null;\n\t/** Manually re-fetch available actions. */\n\trefetch: () => void;\n}\n\n/**\n * Discover available connectors and their supported action types.\n *\n * Calls `transport.describeActions()` on mount and returns the result\n * reactively. Use this to build dynamic UI based on available actions.\n *\n * ```ts\n * const { connectors, isLoading } = useActionDiscovery();\n *\n * for (const [name, actions] of Object.entries(connectors)) {\n * console.log(name, actions.map(a => a.actionType));\n * }\n * ```\n */\nexport function useActionDiscovery(): UseActionDiscoveryResult {\n\tconst { coordinator } = useLakeSync();\n\tconst [connectors, setConnectors] = useState<Record<string, ActionDescriptor[]>>({});\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<LakeSyncError | null>(null);\n\tconst [trigger, setTrigger] = useState(0);\n\n\tconst refetch = useCallback(() => {\n\t\tsetTrigger((v) => v + 1);\n\t}, []);\n\n\tuseEffect(() => {\n\t\tvoid trigger;\n\t\tlet cancelled = false;\n\n\t\tconst run = async () => {\n\t\t\tsetIsLoading(true);\n\t\t\tconst result = await coordinator.describeActions();\n\t\t\tif (cancelled) return;\n\n\t\t\tif (result.ok) {\n\t\t\t\tsetConnectors(result.value.connectors);\n\t\t\t\tsetError(null);\n\t\t\t} else {\n\t\t\t\tsetError(result.error);\n\t\t\t}\n\t\t\tsetIsLoading(false);\n\t\t};\n\n\t\trun();\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [coordinator, trigger]);\n\n\treturn { connectors, isLoading, error, refetch };\n}\n","import type { ConnectorDescriptor, LakeSyncError } from \"@lakesync/core\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { useLakeSync } from \"./context\";\n\n/** Return type of `useConnectorTypes`. */\nexport interface UseConnectorTypesResult {\n\t/** Array of available connector type descriptors. */\n\ttypes: ConnectorDescriptor[];\n\t/** Whether discovery is loading. */\n\tisLoading: boolean;\n\t/** Error from the last fetch, or null. */\n\terror: LakeSyncError | null;\n\t/** Manually re-fetch connector types. */\n\trefetch: () => void;\n}\n\n/**\n * Discover available connector types and their configuration schemas.\n *\n * Calls `coordinator.listConnectorTypes()` on mount and returns the\n * result reactively. Use this to build dynamic \"Add Connector\" forms.\n *\n * ```ts\n * const { types, isLoading } = useConnectorTypes();\n *\n * for (const t of types) {\n * console.log(t.displayName, t.configSchema);\n * }\n * ```\n */\nexport function useConnectorTypes(): UseConnectorTypesResult {\n\tconst { coordinator } = useLakeSync();\n\tconst [types, setTypes] = useState<ConnectorDescriptor[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<LakeSyncError | null>(null);\n\tconst [trigger, setTrigger] = useState(0);\n\n\tconst refetch = useCallback(() => {\n\t\tsetTrigger((v) => v + 1);\n\t}, []);\n\n\tuseEffect(() => {\n\t\tvoid trigger;\n\t\tlet cancelled = false;\n\n\t\tconst run = async () => {\n\t\t\tsetIsLoading(true);\n\t\t\tconst result = await coordinator.listConnectorTypes();\n\t\t\tif (cancelled) return;\n\n\t\t\tif (result.ok) {\n\t\t\t\tsetTypes(result.value);\n\t\t\t\tsetError(null);\n\t\t\t} else {\n\t\t\t\tsetError(result.error);\n\t\t\t}\n\t\t\tsetIsLoading(false);\n\t\t};\n\n\t\trun();\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [coordinator, trigger]);\n\n\treturn { types, isLoading, error, refetch };\n}\n","import type { LakeSyncError, Result } from \"@lakesync/core\";\nimport { useCallback } from \"react\";\nimport { useLakeSync } from \"./context\";\n\n/** Return type of `useMutation`. */\nexport interface UseMutationResult {\n\tinsert: (\n\t\ttable: string,\n\t\trowId: string,\n\t\tdata: Record<string, unknown>,\n\t) => Promise<Result<void, LakeSyncError>>;\n\tupdate: (\n\t\ttable: string,\n\t\trowId: string,\n\t\tdata: Record<string, unknown>,\n\t) => Promise<Result<void, LakeSyncError>>;\n\tremove: (table: string, rowId: string) => Promise<Result<void, LakeSyncError>>;\n}\n\n/**\n * Wraps SyncTracker mutations with automatic query invalidation.\n *\n * After each successful mutation, `dataVersion` is incremented so all\n * active `useQuery` hooks re-run.\n */\nexport function useMutation(): UseMutationResult {\n\tconst { tracker, invalidate } = useLakeSync();\n\n\tconst insert = useCallback(\n\t\tasync (\n\t\t\ttable: string,\n\t\t\trowId: string,\n\t\t\tdata: Record<string, unknown>,\n\t\t): Promise<Result<void, LakeSyncError>> => {\n\t\t\tconst result = await tracker.insert(table, rowId, data);\n\t\t\tif (result.ok) invalidate();\n\t\t\treturn result;\n\t\t},\n\t\t[tracker, invalidate],\n\t);\n\n\tconst update = useCallback(\n\t\tasync (\n\t\t\ttable: string,\n\t\t\trowId: string,\n\t\t\tdata: Record<string, unknown>,\n\t\t): Promise<Result<void, LakeSyncError>> => {\n\t\t\tconst result = await tracker.update(table, rowId, data);\n\t\t\tif (result.ok) invalidate();\n\t\t\treturn result;\n\t\t},\n\t\t[tracker, invalidate],\n\t);\n\n\tconst remove = useCallback(\n\t\tasync (table: string, rowId: string): Promise<Result<void, LakeSyncError>> => {\n\t\t\tconst result = await tracker.delete(table, rowId);\n\t\t\tif (result.ok) invalidate();\n\t\t\treturn result;\n\t\t},\n\t\t[tracker, invalidate],\n\t);\n\n\treturn { insert, update, remove };\n}\n","import type { DbError } from \"@lakesync/client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useLakeSync } from \"./context\";\n\n/** Return type of `useQuery`. */\nexport interface UseQueryResult<T> {\n\tdata: T[];\n\terror: DbError | null;\n\tisLoading: boolean;\n\trefetch: () => void;\n}\n\n/**\n * Reactive SQL query hook.\n *\n * Re-runs automatically when:\n * - Remote deltas are applied (via `onChange`)\n * - A local mutation completes (via `invalidate()`)\n * - The `sql` or `params` arguments change\n *\n * @param sql - SQL query string\n * @param params - Optional bind parameters\n */\nexport function useQuery<T>(sql: string, params?: unknown[]): UseQueryResult<T> {\n\tconst { tracker, dataVersion } = useLakeSync();\n\tconst [data, setData] = useState<T[]>([]);\n\tconst [error, setError] = useState<DbError | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [manualTrigger, setManualTrigger] = useState(0);\n\n\t// Stable serialisation of params for dependency comparison\n\tconst paramsKey = JSON.stringify(params ?? []);\n\tconst paramsRef = useRef(params);\n\tparamsRef.current = params;\n\n\tconst refetch = useCallback(() => {\n\t\tsetManualTrigger((v) => v + 1);\n\t}, []);\n\n\t// Combine all trigger values into a single version for the effect.\n\t// This satisfies exhaustive-deps: the effect reads `version` directly.\n\tconst version = `${dataVersion}:${manualTrigger}:${paramsKey}`;\n\n\tuseEffect(() => {\n\t\t// Read version to establish dependency\n\t\tvoid version;\n\t\tlet cancelled = false;\n\n\t\tconst run = async () => {\n\t\t\tconst result = await tracker.query<T>(sql, paramsRef.current);\n\t\t\tif (cancelled) return;\n\n\t\t\tif (result.ok) {\n\t\t\t\tsetData(result.value);\n\t\t\t\tsetError(null);\n\t\t\t} else {\n\t\t\t\tsetError(result.error);\n\t\t\t}\n\t\t\tsetIsLoading(false);\n\t\t};\n\n\t\trun();\n\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [tracker, sql, version]);\n\n\treturn { data, error, isLoading, refetch };\n}\n","import { useCallback, useEffect, useState } from \"react\";\nimport { useLakeSync } from \"./context\";\n\n/** Return type of `useSyncStatus`. */\nexport interface UseSyncStatusResult {\n\tisSyncing: boolean;\n\tlastSyncTime: Date | null;\n\tqueueDepth: number;\n\terror: Error | null;\n}\n\n/**\n * Observe the sync lifecycle.\n *\n * Tracks whether a sync is in progress, last successful sync time,\n * outbox queue depth, and the most recent sync error (cleared on success).\n */\nexport function useSyncStatus(): UseSyncStatusResult {\n\tconst { coordinator, dataVersion } = useLakeSync();\n\tconst [isSyncing, setIsSyncing] = useState(false);\n\tconst [lastSyncTime, setLastSyncTime] = useState<Date | null>(null);\n\tconst [queueDepth, setQueueDepth] = useState(0);\n\tconst [error, setError] = useState<Error | null>(null);\n\n\tconst refreshQueueDepth = useCallback(async () => {\n\t\tconst depth = await coordinator.queueDepth();\n\t\tsetQueueDepth(depth);\n\t}, [coordinator]);\n\n\tuseEffect(() => {\n\t\tconst handleSyncComplete = () => {\n\t\t\tsetIsSyncing(false);\n\t\t\tsetLastSyncTime(coordinator.lastSyncTime);\n\t\t\tsetError(null);\n\t\t\trefreshQueueDepth();\n\t\t};\n\n\t\tconst handleError = (err: Error) => {\n\t\t\tsetIsSyncing(false);\n\t\t\tsetError(err);\n\t\t};\n\n\t\tconst handleChange = () => {\n\t\t\trefreshQueueDepth();\n\t\t};\n\n\t\tcoordinator.on(\"onSyncComplete\", handleSyncComplete);\n\t\tcoordinator.on(\"onError\", handleError);\n\t\tcoordinator.on(\"onChange\", handleChange);\n\n\t\t// Initial queue depth\n\t\trefreshQueueDepth();\n\n\t\treturn () => {\n\t\t\tcoordinator.off(\"onSyncComplete\", handleSyncComplete);\n\t\t\tcoordinator.off(\"onError\", handleError);\n\t\t\tcoordinator.off(\"onChange\", handleChange);\n\t\t};\n\t}, [coordinator, refreshQueueDepth]);\n\n\t// Also refresh queue depth when dataVersion changes (local mutations)\n\tuseEffect(() => {\n\t\tvoid dataVersion;\n\t\trefreshQueueDepth();\n\t}, [dataVersion, refreshQueueDepth]);\n\n\treturn { isSyncing, lastSyncTime, queueDepth, error };\n}\n"],"mappings":";;;AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAYP,IAAM,kBAAkB,cAA2C,IAAI;AAgBhE,SAAS,iBAAiB,OAA8B;AAC9D,QAAM,EAAE,aAAa,SAAS,IAAI;AAClC,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,CAA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AAa,YAAY,IAAI,YAAY;AACjD,QAAM,CAAC,WAAW,YAAY,IAAIC,UAAS,KAAK;AAChD,QAAM,CAAC,cAAc,eAAe,IAAIA,UAAsB,IAAI;AAClE,QAAM,CAAC,YAAY,aAAa,IAAIA,UAAS,CAAC;AAC9C,QAAM,CAAC,OAAO,QAAQ,IAAIA,UAAuB,IAAI;AAErD,QAAM,oBAAoBC,aAAY,YAAY;AACjD,UAAM,QAAQ,MAAM,YAAY,WAAW;AAC3C,kBAAc,KAAK;AAAA,EACpB,GAAG,CAAC,WAAW,CAAC;AAEhB,EAAAC,WAAU,MAAM;AACf,UAAM,qBAAqB,MAAM;AAChC,mBAAa,KAAK;AAClB,sBAAgB,YAAY,YAAY;AACxC,eAAS,IAAI;AACb,wBAAkB;AAAA,IACnB;AAEA,UAAM,cAAc,CAAC,QAAe;AACnC,mBAAa,KAAK;AAClB,eAAS,GAAG;AAAA,IACb;AAEA,UAAM,eAAe,MAAM;AAC1B,wBAAkB;AAAA,IACnB;AAEA,gBAAY,GAAG,kBAAkB,kBAAkB;AACnD,gBAAY,GAAG,WAAW,WAAW;AACrC,gBAAY,GAAG,YAAY,YAAY;AAGvC,sBAAkB;AAElB,WAAO,MAAM;AACZ,kBAAY,IAAI,kBAAkB,kBAAkB;AACpD,kBAAY,IAAI,WAAW,WAAW;AACtC,kBAAY,IAAI,YAAY,YAAY;AAAA,IACzC;AAAA,EACD,GAAG,CAAC,aAAa,iBAAiB,CAAC;AAGnC,EAAAA,WAAU,MAAM;AACf,SAAK;AACL,sBAAkB;AAAA,EACnB,GAAG,CAAC,aAAa,iBAAiB,CAAC;AAEnC,SAAO,EAAE,WAAW,cAAc,YAAY,MAAM;AACrD;","names":["useCallback","useEffect","useState","useState","useEffect","useCallback","useCallback","useEffect","useState","useState","useCallback","useEffect","useCallback","useCallback","useCallback","useEffect","useState","useState","useCallback","useEffect","useCallback","useEffect","useState","useState","useCallback","useEffect"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { T as TableSchema } from './types-GGBfZBKQ.js';
|
|
2
|
+
import { d as ConnectorType } from './types-D-E0VrfS.js';
|
|
3
|
+
|
|
4
|
+
/** Connector category — determines the ingest model. */
|
|
5
|
+
type ConnectorCategory = "database" | "api";
|
|
6
|
+
/**
|
|
7
|
+
* Machine-readable descriptor for a connector type.
|
|
8
|
+
*
|
|
9
|
+
* Exposes enough metadata for a UI to render an "Add Connector" form
|
|
10
|
+
* without hardcoding per-type config shapes.
|
|
11
|
+
*/
|
|
12
|
+
interface ConnectorDescriptor {
|
|
13
|
+
/** Connector type identifier (e.g. "postgres", "jira"). */
|
|
14
|
+
type: ConnectorType;
|
|
15
|
+
/** Human-readable display name (e.g. "PostgreSQL"). */
|
|
16
|
+
displayName: string;
|
|
17
|
+
/** Short description of the connector. */
|
|
18
|
+
description: string;
|
|
19
|
+
/** Ingest model category. */
|
|
20
|
+
category: ConnectorCategory;
|
|
21
|
+
/** JSON Schema (draft-07) describing the connector-specific config object. */
|
|
22
|
+
configSchema: Record<string, unknown>;
|
|
23
|
+
/** JSON Schema (draft-07) describing the ingest configuration. */
|
|
24
|
+
ingestSchema: Record<string, unknown>;
|
|
25
|
+
/** Output table schemas for API connectors. Null for database connectors. */
|
|
26
|
+
outputTables: ReadonlyArray<TableSchema> | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Register (or replace) a connector descriptor.
|
|
30
|
+
*
|
|
31
|
+
* Called at module load time by built-in registration and by connector
|
|
32
|
+
* packages that need to attach output schemas.
|
|
33
|
+
*/
|
|
34
|
+
declare function registerConnectorDescriptor(descriptor: ConnectorDescriptor): void;
|
|
35
|
+
/**
|
|
36
|
+
* Attach output table schemas to an already-registered connector type.
|
|
37
|
+
*
|
|
38
|
+
* No-op if the type has not been registered yet — this allows connector
|
|
39
|
+
* packages to be imported in any order relative to the core registration.
|
|
40
|
+
*/
|
|
41
|
+
declare function registerOutputSchemas(type: string, schemas: ReadonlyArray<TableSchema>): void;
|
|
42
|
+
/**
|
|
43
|
+
* Look up a single connector descriptor by type.
|
|
44
|
+
*
|
|
45
|
+
* Returns `undefined` when the type is not registered.
|
|
46
|
+
*/
|
|
47
|
+
declare function getConnectorDescriptor(type: string): ConnectorDescriptor | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* List all registered connector descriptors, sorted alphabetically by type.
|
|
50
|
+
*/
|
|
51
|
+
declare function listConnectorDescriptors(): ConnectorDescriptor[];
|
|
52
|
+
|
|
53
|
+
export { type ConnectorCategory as C, type ConnectorDescriptor as a, registerOutputSchemas as b, getConnectorDescriptor as g, listConnectorDescriptors as l, registerConnectorDescriptor as r };
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
mapLead,
|
|
10
10
|
mapOpportunity,
|
|
11
11
|
testConnection
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-TVLTXHW6.js";
|
|
13
|
+
import "./chunk-7UBS6MFH.js";
|
|
14
14
|
import "./chunk-7D4SUZUM.js";
|
|
15
15
|
export {
|
|
16
16
|
SALESFORCE_TABLE_SCHEMAS,
|
|
@@ -24,4 +24,4 @@ export {
|
|
|
24
24
|
mapOpportunity,
|
|
25
25
|
testConnection
|
|
26
26
|
};
|
|
27
|
-
//# sourceMappingURL=src-
|
|
27
|
+
//# sourceMappingURL=src-RR7I76OL.js.map
|
|
@@ -33,12 +33,16 @@ import {
|
|
|
33
33
|
flatMapResult,
|
|
34
34
|
fromPromise,
|
|
35
35
|
generateActionId,
|
|
36
|
+
getConnectorDescriptor,
|
|
36
37
|
isActionError,
|
|
37
38
|
isActionHandler,
|
|
38
39
|
isIngestTarget,
|
|
39
40
|
isValidIdentifier,
|
|
41
|
+
listConnectorDescriptors,
|
|
40
42
|
mapResult,
|
|
41
43
|
quoteIdentifier,
|
|
44
|
+
registerConnectorDescriptor,
|
|
45
|
+
registerOutputSchemas,
|
|
42
46
|
registerPollerFactory,
|
|
43
47
|
resolveClientBuckets,
|
|
44
48
|
resolveFilterValue,
|
|
@@ -50,7 +54,7 @@ import {
|
|
|
50
54
|
validateConnectorConfig,
|
|
51
55
|
validateSyncRules,
|
|
52
56
|
verifyToken
|
|
53
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-7UBS6MFH.js";
|
|
54
58
|
import "./chunk-7D4SUZUM.js";
|
|
55
59
|
export {
|
|
56
60
|
ActionExecutionError,
|
|
@@ -87,12 +91,16 @@ export {
|
|
|
87
91
|
flatMapResult,
|
|
88
92
|
fromPromise,
|
|
89
93
|
generateActionId,
|
|
94
|
+
getConnectorDescriptor,
|
|
90
95
|
isActionError,
|
|
91
96
|
isActionHandler,
|
|
92
97
|
isIngestTarget,
|
|
93
98
|
isValidIdentifier,
|
|
99
|
+
listConnectorDescriptors,
|
|
94
100
|
mapResult,
|
|
95
101
|
quoteIdentifier,
|
|
102
|
+
registerConnectorDescriptor,
|
|
103
|
+
registerOutputSchemas,
|
|
96
104
|
registerPollerFactory,
|
|
97
105
|
resolveClientBuckets,
|
|
98
106
|
resolveFilterValue,
|
|
@@ -105,4 +113,4 @@ export {
|
|
|
105
113
|
validateSyncRules,
|
|
106
114
|
verifyToken
|
|
107
115
|
};
|
|
108
|
-
//# sourceMappingURL=src-
|
|
116
|
+
//# sourceMappingURL=src-SLVE5567.js.map
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
mapIssue,
|
|
9
9
|
mapProject,
|
|
10
10
|
testConnection
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-SZSGSTVZ.js";
|
|
12
|
+
import "./chunk-7UBS6MFH.js";
|
|
13
13
|
import "./chunk-7D4SUZUM.js";
|
|
14
14
|
export {
|
|
15
15
|
JIRA_TABLE_SCHEMAS,
|
|
@@ -22,4 +22,4 @@ export {
|
|
|
22
22
|
mapProject,
|
|
23
23
|
testConnection
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=src-
|
|
25
|
+
//# sourceMappingURL=src-V2CTPR7V.js.map
|
|
@@ -28,7 +28,10 @@ interface RowDelta {
|
|
|
28
28
|
}
|
|
29
29
|
/** Minimal schema for Phase 1. Column allow-list + type hints. */
|
|
30
30
|
interface TableSchema {
|
|
31
|
+
/** Destination table name (what gets created in the database). */
|
|
31
32
|
table: string;
|
|
33
|
+
/** Delta table name to match against. Defaults to `table` when omitted. Use to rename destination tables. */
|
|
34
|
+
sourceTable?: string;
|
|
32
35
|
columns: Array<{
|
|
33
36
|
name: string;
|
|
34
37
|
type: "string" | "number" | "boolean" | "json" | "null";
|