lakesync 0.1.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.
- package/README.md +74 -0
- package/dist/adapter.d.ts +369 -0
- package/dist/adapter.js +39 -0
- package/dist/adapter.js.map +1 -0
- package/dist/analyst.d.ts +268 -0
- package/dist/analyst.js +495 -0
- package/dist/analyst.js.map +1 -0
- package/dist/auth-CAVutXzx.d.ts +30 -0
- package/dist/base-poller-Qo_SmCZs.d.ts +82 -0
- package/dist/catalogue.d.ts +65 -0
- package/dist/catalogue.js +17 -0
- package/dist/catalogue.js.map +1 -0
- package/dist/chunk-4ARO6KTJ.js +257 -0
- package/dist/chunk-4ARO6KTJ.js.map +1 -0
- package/dist/chunk-5YOFCJQ7.js +1115 -0
- package/dist/chunk-5YOFCJQ7.js.map +1 -0
- package/dist/chunk-7D4SUZUM.js +38 -0
- package/dist/chunk-7D4SUZUM.js.map +1 -0
- package/dist/chunk-BNJOGBYK.js +335 -0
- package/dist/chunk-BNJOGBYK.js.map +1 -0
- package/dist/chunk-ICNT7I3K.js +1180 -0
- package/dist/chunk-ICNT7I3K.js.map +1 -0
- package/dist/chunk-P5DRFKIT.js +413 -0
- package/dist/chunk-P5DRFKIT.js.map +1 -0
- package/dist/chunk-X3RO5SYJ.js +880 -0
- package/dist/chunk-X3RO5SYJ.js.map +1 -0
- package/dist/client.d.ts +428 -0
- package/dist/client.js +2048 -0
- package/dist/client.js.map +1 -0
- package/dist/compactor.d.ts +342 -0
- package/dist/compactor.js +793 -0
- package/dist/compactor.js.map +1 -0
- package/dist/coordinator-CxckTzYW.d.ts +396 -0
- package/dist/db-types-BR6Kt4uf.d.ts +29 -0
- package/dist/gateway-D5SaaMvT.d.ts +337 -0
- package/dist/gateway-server.d.ts +306 -0
- package/dist/gateway-server.js +4663 -0
- package/dist/gateway-server.js.map +1 -0
- package/dist/gateway.d.ts +196 -0
- package/dist/gateway.js +79 -0
- package/dist/gateway.js.map +1 -0
- package/dist/hlc-DiD8QNG3.d.ts +70 -0
- package/dist/index.d.ts +245 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/json-dYtqiL0F.d.ts +18 -0
- package/dist/nessie-client-DrNikVXy.d.ts +160 -0
- package/dist/parquet.d.ts +78 -0
- package/dist/parquet.js +15 -0
- package/dist/parquet.js.map +1 -0
- package/dist/proto.d.ts +434 -0
- package/dist/proto.js +67 -0
- package/dist/proto.js.map +1 -0
- package/dist/react.d.ts +147 -0
- package/dist/react.js +224 -0
- package/dist/react.js.map +1 -0
- package/dist/resolver-C3Wphi6O.d.ts +10 -0
- package/dist/result-CojzlFE2.d.ts +64 -0
- package/dist/src-QU2YLPZY.js +383 -0
- package/dist/src-QU2YLPZY.js.map +1 -0
- package/dist/src-WYBF5LOI.js +102 -0
- package/dist/src-WYBF5LOI.js.map +1 -0
- package/dist/src-WZNPHANQ.js +426 -0
- package/dist/src-WZNPHANQ.js.map +1 -0
- package/dist/types-Bs-QyOe-.d.ts +143 -0
- package/dist/types-DAQL_vU_.d.ts +118 -0
- package/dist/types-DSC_EiwR.d.ts +45 -0
- package/dist/types-V_jVu2sA.d.ts +73 -0
- package/package.json +119 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** Supported connector types. */
|
|
2
|
+
declare const CONNECTOR_TYPES: readonly ["postgres", "mysql", "bigquery", "jira", "salesforce"];
|
|
3
|
+
/** Union of supported connector type strings. */
|
|
4
|
+
type ConnectorType = (typeof CONNECTOR_TYPES)[number];
|
|
5
|
+
/** Connection configuration for a PostgreSQL source. */
|
|
6
|
+
interface PostgresConnectorConfig {
|
|
7
|
+
/** PostgreSQL connection string (e.g. "postgres://user:pass@host/db"). */
|
|
8
|
+
connectionString: string;
|
|
9
|
+
}
|
|
10
|
+
/** Connection configuration for a MySQL source. */
|
|
11
|
+
interface MySQLConnectorConfig {
|
|
12
|
+
/** MySQL connection string (e.g. "mysql://user:pass@host/db"). */
|
|
13
|
+
connectionString: string;
|
|
14
|
+
}
|
|
15
|
+
/** Connection configuration for a BigQuery source. */
|
|
16
|
+
interface BigQueryConnectorConfig {
|
|
17
|
+
/** GCP project ID. */
|
|
18
|
+
projectId: string;
|
|
19
|
+
/** BigQuery dataset name. */
|
|
20
|
+
dataset: string;
|
|
21
|
+
/** Path to service account JSON key file. Falls back to ADC when omitted. */
|
|
22
|
+
keyFilename?: string;
|
|
23
|
+
/** Dataset location (default "US"). */
|
|
24
|
+
location?: string;
|
|
25
|
+
}
|
|
26
|
+
/** Ingest table configuration — defines a single table to poll. */
|
|
27
|
+
interface ConnectorIngestTable {
|
|
28
|
+
/** Target table name in LakeSync. */
|
|
29
|
+
table: string;
|
|
30
|
+
/** SQL query to poll (must return rowId + data columns). */
|
|
31
|
+
query: string;
|
|
32
|
+
/** Primary key column name (default "id"). */
|
|
33
|
+
rowIdColumn?: string;
|
|
34
|
+
/** Change detection strategy. */
|
|
35
|
+
strategy: {
|
|
36
|
+
type: "cursor";
|
|
37
|
+
cursorColumn: string;
|
|
38
|
+
lookbackMs?: number;
|
|
39
|
+
} | {
|
|
40
|
+
type: "diff";
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Connection configuration for a Salesforce CRM source. */
|
|
44
|
+
interface SalesforceConnectorConfig {
|
|
45
|
+
/** Salesforce instance URL (e.g. "https://mycompany.salesforce.com"). */
|
|
46
|
+
instanceUrl: string;
|
|
47
|
+
/** Connected App consumer key. */
|
|
48
|
+
clientId: string;
|
|
49
|
+
/** Connected App consumer secret. */
|
|
50
|
+
clientSecret: string;
|
|
51
|
+
/** Salesforce username. */
|
|
52
|
+
username: string;
|
|
53
|
+
/** Salesforce password + security token concatenated. */
|
|
54
|
+
password: string;
|
|
55
|
+
/** REST API version (default "v62.0"). */
|
|
56
|
+
apiVersion?: string;
|
|
57
|
+
/** Use test.salesforce.com for auth (default false). */
|
|
58
|
+
isSandbox?: boolean;
|
|
59
|
+
/** Optional WHERE clause fragment appended to all SOQL queries. */
|
|
60
|
+
soqlFilter?: string;
|
|
61
|
+
/** Whether to include Account objects (default true). */
|
|
62
|
+
includeAccounts?: boolean;
|
|
63
|
+
/** Whether to include Contact objects (default true). */
|
|
64
|
+
includeContacts?: boolean;
|
|
65
|
+
/** Whether to include Opportunity objects (default true). */
|
|
66
|
+
includeOpportunities?: boolean;
|
|
67
|
+
/** Whether to include Lead objects (default true). */
|
|
68
|
+
includeLeads?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** Connection configuration for a Jira Cloud source. */
|
|
71
|
+
interface JiraConnectorConfig {
|
|
72
|
+
/** Jira Cloud domain (e.g. "mycompany" for mycompany.atlassian.net). */
|
|
73
|
+
domain: string;
|
|
74
|
+
/** Email address for Basic auth. */
|
|
75
|
+
email: string;
|
|
76
|
+
/** API token paired with the email. */
|
|
77
|
+
apiToken: string;
|
|
78
|
+
/** Optional JQL filter to scope issue polling. */
|
|
79
|
+
jql?: string;
|
|
80
|
+
/** Whether to include comments (default true). */
|
|
81
|
+
includeComments?: boolean;
|
|
82
|
+
/** Whether to include projects (default true). */
|
|
83
|
+
includeProjects?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/** Optional ingest polling configuration attached to a connector. */
|
|
86
|
+
interface ConnectorIngestConfig {
|
|
87
|
+
/** Tables to poll for changes. */
|
|
88
|
+
tables: ConnectorIngestTable[];
|
|
89
|
+
/** Poll interval in milliseconds (default 10 000). */
|
|
90
|
+
intervalMs?: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Configuration for a dynamically registered connector (data source).
|
|
94
|
+
*
|
|
95
|
+
* Each connector maps to a named {@link DatabaseAdapter} in the gateway,
|
|
96
|
+
* optionally with an ingest poller that pushes detected changes into
|
|
97
|
+
* the sync buffer.
|
|
98
|
+
*/
|
|
99
|
+
interface ConnectorConfig {
|
|
100
|
+
/** Unique connector name (used as source adapter key). */
|
|
101
|
+
name: string;
|
|
102
|
+
/** Connector type — determines which adapter implementation to instantiate. */
|
|
103
|
+
type: ConnectorType;
|
|
104
|
+
/** PostgreSQL connection configuration (required when type is "postgres"). */
|
|
105
|
+
postgres?: PostgresConnectorConfig;
|
|
106
|
+
/** MySQL connection configuration (required when type is "mysql"). */
|
|
107
|
+
mysql?: MySQLConnectorConfig;
|
|
108
|
+
/** BigQuery connection configuration (required when type is "bigquery"). */
|
|
109
|
+
bigquery?: BigQueryConnectorConfig;
|
|
110
|
+
/** Jira Cloud connection configuration (required when type is "jira"). */
|
|
111
|
+
jira?: JiraConnectorConfig;
|
|
112
|
+
/** Salesforce CRM connection configuration (required when type is "salesforce"). */
|
|
113
|
+
salesforce?: SalesforceConnectorConfig;
|
|
114
|
+
/** Optional ingest polling configuration. */
|
|
115
|
+
ingest?: ConnectorIngestConfig;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
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 };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { R as Result, A as AdapterError } from './result-CojzlFE2.js';
|
|
2
|
+
|
|
3
|
+
/** Information about an object in the lake store */
|
|
4
|
+
interface ObjectInfo {
|
|
5
|
+
/** S3 object key */
|
|
6
|
+
key: string;
|
|
7
|
+
/** Object size in bytes */
|
|
8
|
+
size: number;
|
|
9
|
+
/** Last modification date */
|
|
10
|
+
lastModified: Date;
|
|
11
|
+
}
|
|
12
|
+
/** Configuration for connecting to the lake store */
|
|
13
|
+
interface AdapterConfig {
|
|
14
|
+
/** Endpoint URL (e.g. http://localhost:9000) */
|
|
15
|
+
endpoint: string;
|
|
16
|
+
/** Bucket name */
|
|
17
|
+
bucket: string;
|
|
18
|
+
/** AWS region (defaults to us-east-1) */
|
|
19
|
+
region?: string;
|
|
20
|
+
/** Access credentials */
|
|
21
|
+
credentials: {
|
|
22
|
+
accessKeyId: string;
|
|
23
|
+
secretAccessKey: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Abstract interface for lake storage operations */
|
|
27
|
+
interface LakeAdapter {
|
|
28
|
+
/** Store an object in the lake */
|
|
29
|
+
putObject(path: string, data: Uint8Array, contentType?: string): Promise<Result<void, AdapterError>>;
|
|
30
|
+
/** Retrieve an object from the lake */
|
|
31
|
+
getObject(path: string): Promise<Result<Uint8Array, AdapterError>>;
|
|
32
|
+
/** Get object metadata without retrieving the body */
|
|
33
|
+
headObject(path: string): Promise<Result<{
|
|
34
|
+
size: number;
|
|
35
|
+
lastModified: Date;
|
|
36
|
+
}, AdapterError>>;
|
|
37
|
+
/** List objects matching a given prefix */
|
|
38
|
+
listObjects(prefix: string): Promise<Result<ObjectInfo[], AdapterError>>;
|
|
39
|
+
/** Delete a single object from the lake */
|
|
40
|
+
deleteObject(path: string): Promise<Result<void, AdapterError>>;
|
|
41
|
+
/** Delete multiple objects from the lake in a single batch operation */
|
|
42
|
+
deleteObjects(paths: string[]): Promise<Result<void, AdapterError>>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type { AdapterConfig as A, LakeAdapter as L, ObjectInfo as O };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { H as HLCTimestamp } from './result-CojzlFE2.js';
|
|
2
|
+
|
|
3
|
+
/** Delta operation type */
|
|
4
|
+
type DeltaOp = "INSERT" | "UPDATE" | "DELETE";
|
|
5
|
+
/** A single column-level change */
|
|
6
|
+
interface ColumnDelta {
|
|
7
|
+
/** Column name */
|
|
8
|
+
column: string;
|
|
9
|
+
/** Serialisable JSON value — NEVER undefined, use null instead */
|
|
10
|
+
value: unknown;
|
|
11
|
+
}
|
|
12
|
+
/** A row-level delta containing column-level changes */
|
|
13
|
+
interface RowDelta {
|
|
14
|
+
/** Operation type */
|
|
15
|
+
op: DeltaOp;
|
|
16
|
+
/** Table name */
|
|
17
|
+
table: string;
|
|
18
|
+
/** Row identifier */
|
|
19
|
+
rowId: string;
|
|
20
|
+
/** Client identifier — used for LWW tiebreak and audit */
|
|
21
|
+
clientId: string;
|
|
22
|
+
/** Changed columns — empty for DELETE */
|
|
23
|
+
columns: ColumnDelta[];
|
|
24
|
+
/** HLC timestamp (branded bigint) */
|
|
25
|
+
hlc: HLCTimestamp;
|
|
26
|
+
/** Deterministic identifier: hash(clientId + hlc + table + rowId + columns) */
|
|
27
|
+
deltaId: string;
|
|
28
|
+
}
|
|
29
|
+
/** Minimal schema for Phase 1. Column allow-list + type hints. */
|
|
30
|
+
interface TableSchema {
|
|
31
|
+
table: string;
|
|
32
|
+
columns: Array<{
|
|
33
|
+
name: string;
|
|
34
|
+
type: "string" | "number" | "boolean" | "json" | "null";
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
/** Composite key utility — avoids string concatenation bugs */
|
|
38
|
+
type RowKey = string & {
|
|
39
|
+
readonly __brand: "RowKey";
|
|
40
|
+
};
|
|
41
|
+
/** Create a composite row key from table and row ID */
|
|
42
|
+
declare function rowKey(table: string, rowId: string): RowKey;
|
|
43
|
+
/** SyncPush input message — sent by clients to push local deltas to the gateway */
|
|
44
|
+
interface SyncPush {
|
|
45
|
+
/** Client that sent the push */
|
|
46
|
+
clientId: string;
|
|
47
|
+
/** Deltas to push */
|
|
48
|
+
deltas: RowDelta[];
|
|
49
|
+
/** Client's last-seen HLC */
|
|
50
|
+
lastSeenHlc: HLCTimestamp;
|
|
51
|
+
}
|
|
52
|
+
/** SyncPull input message — sent by clients to pull remote deltas from the gateway */
|
|
53
|
+
interface SyncPull {
|
|
54
|
+
/** Client that sent the pull */
|
|
55
|
+
clientId: string;
|
|
56
|
+
/** Return deltas with HLC strictly after this value */
|
|
57
|
+
sinceHlc: HLCTimestamp;
|
|
58
|
+
/** Maximum number of deltas to return */
|
|
59
|
+
maxDeltas: number;
|
|
60
|
+
/** Optional source adapter name — when set, pull from the named adapter instead of the buffer */
|
|
61
|
+
source?: string;
|
|
62
|
+
}
|
|
63
|
+
/** SyncResponse output — returned by the gateway after push or pull */
|
|
64
|
+
interface SyncResponse {
|
|
65
|
+
/** Deltas matching the pull criteria */
|
|
66
|
+
deltas: RowDelta[];
|
|
67
|
+
/** Current server HLC */
|
|
68
|
+
serverHlc: HLCTimestamp;
|
|
69
|
+
/** Whether there are more deltas to fetch */
|
|
70
|
+
hasMore: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { type ColumnDelta as C, type DeltaOp as D, type RowDelta as R, type SyncPull as S, type TableSchema as T, type RowKey as a, type SyncPush as b, type SyncResponse as c, rowKey as r };
|
package/package.json
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lakesync",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Local-first sync engine with pluggable backends — Postgres, MySQL, BigQuery, S3/R2 via Apache Iceberg",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./client": {
|
|
18
|
+
"types": "./dist/client.d.ts",
|
|
19
|
+
"import": "./dist/client.js"
|
|
20
|
+
},
|
|
21
|
+
"./gateway": {
|
|
22
|
+
"types": "./dist/gateway.d.ts",
|
|
23
|
+
"import": "./dist/gateway.js"
|
|
24
|
+
},
|
|
25
|
+
"./adapter": {
|
|
26
|
+
"types": "./dist/adapter.d.ts",
|
|
27
|
+
"import": "./dist/adapter.js"
|
|
28
|
+
},
|
|
29
|
+
"./proto": {
|
|
30
|
+
"types": "./dist/proto.d.ts",
|
|
31
|
+
"import": "./dist/proto.js"
|
|
32
|
+
},
|
|
33
|
+
"./parquet": {
|
|
34
|
+
"types": "./dist/parquet.d.ts",
|
|
35
|
+
"import": "./dist/parquet.js"
|
|
36
|
+
},
|
|
37
|
+
"./catalogue": {
|
|
38
|
+
"types": "./dist/catalogue.d.ts",
|
|
39
|
+
"import": "./dist/catalogue.js"
|
|
40
|
+
},
|
|
41
|
+
"./compactor": {
|
|
42
|
+
"types": "./dist/compactor.d.ts",
|
|
43
|
+
"import": "./dist/compactor.js"
|
|
44
|
+
},
|
|
45
|
+
"./analyst": {
|
|
46
|
+
"types": "./dist/analyst.d.ts",
|
|
47
|
+
"import": "./dist/analyst.js"
|
|
48
|
+
},
|
|
49
|
+
"./gateway-server": {
|
|
50
|
+
"types": "./dist/gateway-server.d.ts",
|
|
51
|
+
"import": "./dist/gateway-server.js"
|
|
52
|
+
},
|
|
53
|
+
"./react": {
|
|
54
|
+
"types": "./dist/react.d.ts",
|
|
55
|
+
"import": "./dist/react.js"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsup",
|
|
60
|
+
"typecheck": "tsc --noEmit",
|
|
61
|
+
"prepublishOnly": "tsup"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"fast-json-stable-stringify": "^2.1.0",
|
|
65
|
+
"fast-deep-equal": "^3.1.3"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"sql.js": "^1.11.0",
|
|
69
|
+
"idb": "^8.0.3",
|
|
70
|
+
"@aws-sdk/client-s3": "^3.0.0",
|
|
71
|
+
"@bufbuild/protobuf": "^2.0.0",
|
|
72
|
+
"parquet-wasm": "^0.7.0",
|
|
73
|
+
"apache-arrow": "^18.0.0",
|
|
74
|
+
"@duckdb/duckdb-wasm": "^1.33.0",
|
|
75
|
+
"pg": "^8.0.0",
|
|
76
|
+
"mysql2": "^3.0.0",
|
|
77
|
+
"@google-cloud/bigquery": "^8.0.0",
|
|
78
|
+
"better-sqlite3": "^11.0.0",
|
|
79
|
+
"react": ">=18.0.0"
|
|
80
|
+
},
|
|
81
|
+
"peerDependenciesMeta": {
|
|
82
|
+
"sql.js": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"idb": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"@aws-sdk/client-s3": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"@bufbuild/protobuf": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
94
|
+
"parquet-wasm": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
97
|
+
"apache-arrow": {
|
|
98
|
+
"optional": true
|
|
99
|
+
},
|
|
100
|
+
"@duckdb/duckdb-wasm": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"pg": {
|
|
104
|
+
"optional": true
|
|
105
|
+
},
|
|
106
|
+
"mysql2": {
|
|
107
|
+
"optional": true
|
|
108
|
+
},
|
|
109
|
+
"@google-cloud/bigquery": {
|
|
110
|
+
"optional": true
|
|
111
|
+
},
|
|
112
|
+
"better-sqlite3": {
|
|
113
|
+
"optional": true
|
|
114
|
+
},
|
|
115
|
+
"react": {
|
|
116
|
+
"optional": true
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|