@sixb/sync-worker 0.0.1
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/LICENSE +21 -0
- package/README.md +67 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +454 -0
- package/dist/index.js.map +12 -0
- package/dist/normalize.d.ts +5 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/run-sync-job.d.ts +16 -0
- package/dist/run-sync-job.d.ts.map +1 -0
- package/dist/tsconfig.json +5 -0
- package/dist/types.d.ts +49 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/worker.d.ts +26 -0
- package/dist/worker.d.ts.map +1 -0
- package/package.json +58 -0
- package/src/index.ts +2 -0
- package/src/normalize.ts +83 -0
- package/src/run-sync-job.ts +337 -0
- package/src/types.ts +70 -0
- package/src/worker.ts +218 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sixb contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @sixb/sync-worker
|
|
2
|
+
|
|
3
|
+
Queue worker helpers for running Sixb sync jobs.
|
|
4
|
+
|
|
5
|
+
The sync worker turns one queued sync job into one sync run record and one lake dataset
|
|
6
|
+
version. It is intentionally small: queue polling, retries, scheduling, and run-id
|
|
7
|
+
generation belong to the caller.
|
|
8
|
+
|
|
9
|
+
## Responsibilities
|
|
10
|
+
|
|
11
|
+
- look up the sync definition for a queued job
|
|
12
|
+
- create and finalize the sync-run record
|
|
13
|
+
- resolve the sync connector client
|
|
14
|
+
- normalize rows returned by the sync read handler
|
|
15
|
+
- write rows into lake storage and commit the dataset version
|
|
16
|
+
- mark pre-commit failures as `failed` or `cancelled`
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { runSyncJob, type SyncWorkerContext } from "@sixb/sync-worker"
|
|
22
|
+
|
|
23
|
+
const runtime: SyncWorkerContext = {
|
|
24
|
+
id: sixb.id,
|
|
25
|
+
syncRunsStorage,
|
|
26
|
+
lakeStorage,
|
|
27
|
+
getSyncById(syncId) {
|
|
28
|
+
return sixb.getSyncById(syncId)
|
|
29
|
+
},
|
|
30
|
+
connector(definition) {
|
|
31
|
+
return sixb.connector(definition)
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const result = await runSyncJob({
|
|
36
|
+
runtime,
|
|
37
|
+
job: {
|
|
38
|
+
id: "run_123",
|
|
39
|
+
syncId: "sync-orders",
|
|
40
|
+
expectedLatestVersionId: "version_001",
|
|
41
|
+
commitMessage: "sync orders from queue",
|
|
42
|
+
},
|
|
43
|
+
signal,
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`runSyncJob` returns the finalized run id, sync id, dataset id, write mode, timing,
|
|
48
|
+
row count, and committed `DatasetVersion`.
|
|
49
|
+
|
|
50
|
+
## Notes
|
|
51
|
+
|
|
52
|
+
- `job.id` is the sync-run id supplied by the queue layer.
|
|
53
|
+
- `job.expectedLatestVersionId` is forwarded to the lake commit for optimistic
|
|
54
|
+
concurrency checks.
|
|
55
|
+
- a failed sync-run finalization after a successful lake commit throws a
|
|
56
|
+
`[SixbSyncWorker]` bookkeeping error so the durable dataset version can be
|
|
57
|
+
repaired or reconciled.
|
|
58
|
+
- supported sync read results are a single row object, an iterable, or an async
|
|
59
|
+
iterable.
|
|
60
|
+
|
|
61
|
+
## Development
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
bun --filter @sixb/sync-worker typecheck
|
|
65
|
+
bun test packages/sync-worker/tests/run-sync-job.test.ts
|
|
66
|
+
bun --filter @sixb/sync-worker build
|
|
67
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/worker.ts
|
|
3
|
+
import { reportRunFailure } from "@sixb/core/internal/error-reporting";
|
|
4
|
+
import { QueueWorker } from "@sixb/core/internal/workers";
|
|
5
|
+
|
|
6
|
+
// src/run-sync-job.ts
|
|
7
|
+
import {
|
|
8
|
+
assertJsonValue,
|
|
9
|
+
cloneJsonValue,
|
|
10
|
+
getDatasetRowValidationError,
|
|
11
|
+
isFileRef
|
|
12
|
+
} from "@sixb/core";
|
|
13
|
+
import { resolveLogsRuntime } from "@sixb/core/internal/logging";
|
|
14
|
+
|
|
15
|
+
// src/normalize.ts
|
|
16
|
+
function isPlainObject(value) {
|
|
17
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const prototype = Object.getPrototypeOf(value);
|
|
21
|
+
return prototype === Object.prototype || prototype === null;
|
|
22
|
+
}
|
|
23
|
+
function isIterable(value) {
|
|
24
|
+
return value !== null && value !== undefined && typeof value[Symbol.iterator] === "function";
|
|
25
|
+
}
|
|
26
|
+
function isAsyncIterable(value) {
|
|
27
|
+
return value !== null && value !== undefined && typeof value[Symbol.asyncIterator] === "function";
|
|
28
|
+
}
|
|
29
|
+
function toAbortError(signal) {
|
|
30
|
+
if (signal.reason instanceof Error) {
|
|
31
|
+
return signal.reason;
|
|
32
|
+
}
|
|
33
|
+
const message = typeof signal.reason === "string" && signal.reason.length > 0 ? signal.reason : "[SixbSyncWorker] Operation was cancelled.";
|
|
34
|
+
const error = new Error(message);
|
|
35
|
+
error.name = "AbortError";
|
|
36
|
+
return error;
|
|
37
|
+
}
|
|
38
|
+
function throwIfAborted(signal) {
|
|
39
|
+
if (signal.aborted) {
|
|
40
|
+
throw toAbortError(signal);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function assertDatasetRow(value, syncId, itemIndex) {
|
|
44
|
+
if (isPlainObject(value)) {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
throw new Error(`[SixbSyncWorker] Sync '${syncId}' returned an invalid row at item ${itemIndex}. Dataset rows must be plain objects.`);
|
|
48
|
+
}
|
|
49
|
+
async function* normalizeReadResult(readResult, syncId) {
|
|
50
|
+
if (isAsyncIterable(readResult)) {
|
|
51
|
+
yield* readResult;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (isIterable(readResult)) {
|
|
55
|
+
for (const item of readResult) {
|
|
56
|
+
yield item;
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (isPlainObject(readResult)) {
|
|
61
|
+
yield readResult;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
throw new Error(`[SixbSyncWorker] Sync '${syncId}' returned an unsupported read result. Expected a row object, iterable, or async iterable.`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/run-sync-job.ts
|
|
68
|
+
class SyncRunAlreadyStartedError extends Error {
|
|
69
|
+
run;
|
|
70
|
+
name = "SyncRunAlreadyStartedError";
|
|
71
|
+
constructor(run) {
|
|
72
|
+
super(`[SixbSyncWorker] Sync run '${run.id}' has already started.`);
|
|
73
|
+
this.run = run;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function toSyncRunFailure(error) {
|
|
77
|
+
if (error instanceof Error) {
|
|
78
|
+
return {
|
|
79
|
+
name: error.name,
|
|
80
|
+
message: error.message
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
message: String(error)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function createBookkeepingError(options) {
|
|
88
|
+
return new Error(`[SixbSyncWorker] Sync '${options.syncId}' committed dataset version '${options.version.versionId}', but failed to finalize sync run '${options.runId}'. The dataset commit may already have succeeded and the sync run record may need repair.`, { cause: options.cause });
|
|
89
|
+
}
|
|
90
|
+
function requireFinishedAt(runId, finishedAt) {
|
|
91
|
+
if (finishedAt) {
|
|
92
|
+
return finishedAt;
|
|
93
|
+
}
|
|
94
|
+
throw new Error(`[SixbSyncWorker] Sync run '${runId}' finished without a finishedAt timestamp.`);
|
|
95
|
+
}
|
|
96
|
+
async function verifyFileRef(options) {
|
|
97
|
+
const blobInfo = await options.blobStorage.stat(options.fileRef.blobId);
|
|
98
|
+
if (!blobInfo) {
|
|
99
|
+
throw new Error(`[SixbSyncWorker] Sync '${options.syncId}' returned row ${options.itemIndex} with dataset '${options.datasetId}' column '${options.columnName}' referencing unknown blob '${options.fileRef.blobId}'.`);
|
|
100
|
+
}
|
|
101
|
+
if (blobInfo.digest !== options.fileRef.digest) {
|
|
102
|
+
throw new Error(`[SixbSyncWorker] Sync '${options.syncId}' returned row ${options.itemIndex} with dataset '${options.datasetId}' column '${options.columnName}' referencing blob '${options.fileRef.blobId}' with digest '${options.fileRef.digest}', but blob storage has '${blobInfo.digest}'.`);
|
|
103
|
+
}
|
|
104
|
+
if (blobInfo.sizeBytes !== options.fileRef.sizeBytes) {
|
|
105
|
+
throw new Error(`[SixbSyncWorker] Sync '${options.syncId}' returned row ${options.itemIndex} with dataset '${options.datasetId}' column '${options.columnName}' referencing blob '${options.fileRef.blobId}' with size ${options.fileRef.sizeBytes}, but blob storage has ${blobInfo.sizeBytes}.`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function verifyRowFileRefs(options) {
|
|
109
|
+
const fileRefColumns = options.dataset.schema.columns.filter((column) => column.type === "fileRef");
|
|
110
|
+
for (const column of fileRefColumns) {
|
|
111
|
+
const value = options.row[column.name];
|
|
112
|
+
if (!isFileRef(value)) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
await verifyFileRef({
|
|
116
|
+
blobStorage: options.blobStorage,
|
|
117
|
+
syncId: options.syncId,
|
|
118
|
+
datasetId: options.dataset.id,
|
|
119
|
+
columnName: column.name,
|
|
120
|
+
itemIndex: options.itemIndex,
|
|
121
|
+
fileRef: value
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function runSyncJob(input) {
|
|
126
|
+
const { runtime, job } = input;
|
|
127
|
+
const signal = input.signal ?? new AbortController().signal;
|
|
128
|
+
const { syncRunsStorage, lakeStorage, blobStorage } = runtime;
|
|
129
|
+
const sync = runtime.getSyncById(job.syncId);
|
|
130
|
+
if (!sync) {
|
|
131
|
+
throw new Error(`[SixbSyncWorker] Unknown sync '${job.syncId}'.`);
|
|
132
|
+
}
|
|
133
|
+
const dataset = runtime.getDatasetById(sync.target.dataset.id);
|
|
134
|
+
if (!dataset) {
|
|
135
|
+
throw new Error(`[SixbSyncWorker] Sync '${sync.id}' targets unknown dataset '${sync.target.dataset.id}'.`);
|
|
136
|
+
}
|
|
137
|
+
throwIfAborted(signal);
|
|
138
|
+
let startedRun;
|
|
139
|
+
try {
|
|
140
|
+
startedRun = await syncRunsStorage.start({
|
|
141
|
+
projectId: runtime.id,
|
|
142
|
+
id: job.id,
|
|
143
|
+
syncId: sync.id,
|
|
144
|
+
datasetId: dataset.id,
|
|
145
|
+
mode: sync.config.mode,
|
|
146
|
+
expectedLatestVersionId: job.expectedLatestVersionId,
|
|
147
|
+
commitMessage: job.commitMessage
|
|
148
|
+
});
|
|
149
|
+
} catch (error) {
|
|
150
|
+
const existing = await syncRunsStorage.getById({ projectId: runtime.id, id: job.id });
|
|
151
|
+
if (existing?.syncId === sync.id && existing.datasetId === dataset.id) {
|
|
152
|
+
throw new SyncRunAlreadyStartedError(existing);
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
await input.onRunStarted?.(startedRun);
|
|
157
|
+
const logSession = resolveLogsRuntime(runtime.id, runtime.logs).startExecution({
|
|
158
|
+
kind: "sync",
|
|
159
|
+
id: job.id
|
|
160
|
+
});
|
|
161
|
+
const logger = logSession.logger;
|
|
162
|
+
let write;
|
|
163
|
+
let rowsRead = 0;
|
|
164
|
+
let committedVersion;
|
|
165
|
+
try {
|
|
166
|
+
throwIfAborted(signal);
|
|
167
|
+
await lakeStorage.createDataset(dataset);
|
|
168
|
+
const latestSuccessfulRuns = await syncRunsStorage.list({
|
|
169
|
+
projectId: runtime.id,
|
|
170
|
+
syncId: sync.id,
|
|
171
|
+
statuses: ["succeeded"],
|
|
172
|
+
limit: 1,
|
|
173
|
+
order: "desc"
|
|
174
|
+
});
|
|
175
|
+
const previousCheckpoint = latestSuccessfulRuns.runs[0]?.checkpoint;
|
|
176
|
+
let nextCheckpoint = previousCheckpoint !== undefined ? cloneJsonValue(previousCheckpoint) : undefined;
|
|
177
|
+
const client = await runtime.connector(sync.connector);
|
|
178
|
+
const readResult = await sync.read(client, {
|
|
179
|
+
projectId: runtime.id,
|
|
180
|
+
syncId: sync.id,
|
|
181
|
+
signal,
|
|
182
|
+
blobs: blobStorage,
|
|
183
|
+
logger,
|
|
184
|
+
checkpoint: previousCheckpoint !== undefined ? cloneJsonValue(previousCheckpoint) : undefined,
|
|
185
|
+
setCheckpoint(next) {
|
|
186
|
+
assertJsonValue(next, `Sync '${sync.id}' checkpoint`);
|
|
187
|
+
nextCheckpoint = cloneJsonValue(next);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const rows = normalizeReadResult(readResult, sync.id);
|
|
191
|
+
throwIfAborted(signal);
|
|
192
|
+
write = await lakeStorage.beginWrite({
|
|
193
|
+
dataset,
|
|
194
|
+
mode: sync.config.mode,
|
|
195
|
+
producer: {
|
|
196
|
+
kind: "sync",
|
|
197
|
+
id: sync.id,
|
|
198
|
+
runId: job.id
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
await write.writeRows(async function* () {
|
|
202
|
+
let itemIndex = 0;
|
|
203
|
+
for await (const value of rows) {
|
|
204
|
+
throwIfAborted(signal);
|
|
205
|
+
itemIndex += 1;
|
|
206
|
+
const row = assertDatasetRow(value, sync.id, itemIndex);
|
|
207
|
+
const validationError = getDatasetRowValidationError(row, dataset);
|
|
208
|
+
if (validationError) {
|
|
209
|
+
throw new Error(`[SixbSyncWorker] Sync '${sync.id}' returned an invalid row at item ${itemIndex}. ${validationError}`);
|
|
210
|
+
}
|
|
211
|
+
await verifyRowFileRefs({
|
|
212
|
+
blobStorage,
|
|
213
|
+
syncId: sync.id,
|
|
214
|
+
dataset,
|
|
215
|
+
row,
|
|
216
|
+
itemIndex
|
|
217
|
+
});
|
|
218
|
+
rowsRead += 1;
|
|
219
|
+
yield row;
|
|
220
|
+
}
|
|
221
|
+
}());
|
|
222
|
+
throwIfAborted(signal);
|
|
223
|
+
if (sync.config.mode === "append" && rowsRead === 0) {
|
|
224
|
+
await write.abort();
|
|
225
|
+
write = undefined;
|
|
226
|
+
const version2 = await lakeStorage.getLatestVersion(dataset.id);
|
|
227
|
+
const finishedRun2 = await syncRunsStorage.finish({
|
|
228
|
+
projectId: runtime.id,
|
|
229
|
+
id: job.id,
|
|
230
|
+
status: "succeeded",
|
|
231
|
+
rowsRead,
|
|
232
|
+
...version2 ? { output: { datasetId: version2.datasetId, versionId: version2.versionId } } : {},
|
|
233
|
+
checkpoint: nextCheckpoint
|
|
234
|
+
});
|
|
235
|
+
return {
|
|
236
|
+
id: job.id,
|
|
237
|
+
syncId: sync.id,
|
|
238
|
+
datasetId: dataset.id,
|
|
239
|
+
mode: sync.config.mode,
|
|
240
|
+
startedAt: startedRun.startedAt,
|
|
241
|
+
finishedAt: requireFinishedAt(job.id, finishedRun2.finishedAt),
|
|
242
|
+
rowsRead,
|
|
243
|
+
...version2 ? { version: version2 } : {},
|
|
244
|
+
versionCreated: false
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
const commit = await write.commit({
|
|
248
|
+
expectedLatestVersionId: job.expectedLatestVersionId,
|
|
249
|
+
commitMessage: job.commitMessage ?? `sync ${sync.id} run ${job.id}`
|
|
250
|
+
});
|
|
251
|
+
const { outcome, ...version } = commit;
|
|
252
|
+
committedVersion = version;
|
|
253
|
+
let finishedRun;
|
|
254
|
+
try {
|
|
255
|
+
finishedRun = await syncRunsStorage.finish({
|
|
256
|
+
projectId: runtime.id,
|
|
257
|
+
id: job.id,
|
|
258
|
+
status: "succeeded",
|
|
259
|
+
rowsRead,
|
|
260
|
+
output: {
|
|
261
|
+
datasetId: version.datasetId,
|
|
262
|
+
versionId: version.versionId
|
|
263
|
+
},
|
|
264
|
+
checkpoint: nextCheckpoint
|
|
265
|
+
});
|
|
266
|
+
} catch (error) {
|
|
267
|
+
throw createBookkeepingError({
|
|
268
|
+
syncId: sync.id,
|
|
269
|
+
runId: job.id,
|
|
270
|
+
version,
|
|
271
|
+
cause: error
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
id: job.id,
|
|
276
|
+
syncId: sync.id,
|
|
277
|
+
datasetId: dataset.id,
|
|
278
|
+
mode: sync.config.mode,
|
|
279
|
+
startedAt: startedRun.startedAt,
|
|
280
|
+
finishedAt: requireFinishedAt(job.id, finishedRun.finishedAt),
|
|
281
|
+
rowsRead,
|
|
282
|
+
version,
|
|
283
|
+
versionCreated: outcome === "created"
|
|
284
|
+
};
|
|
285
|
+
} catch (error) {
|
|
286
|
+
if (!committedVersion) {
|
|
287
|
+
await write?.abort().catch(() => {});
|
|
288
|
+
const status = signal.aborted ? "cancelled" : "failed";
|
|
289
|
+
try {
|
|
290
|
+
const run = await syncRunsStorage.finish({
|
|
291
|
+
projectId: runtime.id,
|
|
292
|
+
id: job.id,
|
|
293
|
+
status,
|
|
294
|
+
rowsRead,
|
|
295
|
+
error: toSyncRunFailure(error)
|
|
296
|
+
});
|
|
297
|
+
if (status === "failed" && run.status === "failed")
|
|
298
|
+
input.onRunFailed?.(error, run);
|
|
299
|
+
} catch {}
|
|
300
|
+
}
|
|
301
|
+
throw error;
|
|
302
|
+
} finally {
|
|
303
|
+
await logSession.flush();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// src/worker.ts
|
|
308
|
+
var SOURCE = "SixbSyncWorker";
|
|
309
|
+
|
|
310
|
+
class SyncWorker extends QueueWorker {
|
|
311
|
+
context;
|
|
312
|
+
sixb;
|
|
313
|
+
constructor(sixb) {
|
|
314
|
+
if (sixb.listSyncs().length === 0) {
|
|
315
|
+
throw new Error("[SixbSyncWorker] No sync definitions are registered.");
|
|
316
|
+
}
|
|
317
|
+
super({
|
|
318
|
+
projectId: sixb.id,
|
|
319
|
+
queue: sixb.queues.syncRuns,
|
|
320
|
+
workerId: `sync-worker-${sixb.id}`
|
|
321
|
+
});
|
|
322
|
+
this.context = buildSyncContext(sixb);
|
|
323
|
+
this.sixb = sixb;
|
|
324
|
+
}
|
|
325
|
+
async execute(claimed, signal) {
|
|
326
|
+
const { job } = claimed;
|
|
327
|
+
const syncJob = {
|
|
328
|
+
id: job.payload.runId ?? `${job.id}:attempt:${job.attempt}`,
|
|
329
|
+
syncId: job.payload.syncId,
|
|
330
|
+
expectedLatestVersionId: job.payload.expectedLatestVersionId,
|
|
331
|
+
commitMessage: job.payload.commitMessage
|
|
332
|
+
};
|
|
333
|
+
let result;
|
|
334
|
+
try {
|
|
335
|
+
result = await runSyncJob({
|
|
336
|
+
runtime: this.context,
|
|
337
|
+
job: syncJob,
|
|
338
|
+
signal,
|
|
339
|
+
onRunStarted: (run) => emitSyncRunStarted(this.sixb, run),
|
|
340
|
+
onRunFailed: (error, run) => {
|
|
341
|
+
reportRunFailure(this.sixb, error, {
|
|
342
|
+
projectId: this.sixb.id,
|
|
343
|
+
occurredAt: run.finishedAt,
|
|
344
|
+
attempt: job.attempt,
|
|
345
|
+
run: {
|
|
346
|
+
kind: "sync",
|
|
347
|
+
runId: run.id,
|
|
348
|
+
syncId: run.syncId
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
} catch (error) {
|
|
354
|
+
if (error instanceof SyncRunAlreadyStartedError)
|
|
355
|
+
return;
|
|
356
|
+
throw error;
|
|
357
|
+
}
|
|
358
|
+
await emitSyncSucceededEvents(this.sixb, syncJob, result);
|
|
359
|
+
}
|
|
360
|
+
async onExecutionError(claimed, _error) {
|
|
361
|
+
const { job } = claimed;
|
|
362
|
+
await emitSyncRunFinished(this.sixb, {
|
|
363
|
+
id: job.payload.runId ?? `${job.id}:attempt:${job.attempt}`,
|
|
364
|
+
syncId: job.payload.syncId
|
|
365
|
+
});
|
|
366
|
+
return { kind: "fail" };
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
async function emitSyncRunStarted(sixb, run) {
|
|
370
|
+
await sixb.events?.emit({
|
|
371
|
+
events: [
|
|
372
|
+
{
|
|
373
|
+
type: "sync.run.started",
|
|
374
|
+
payload: {
|
|
375
|
+
syncId: run.syncId,
|
|
376
|
+
runId: run.id,
|
|
377
|
+
startedAt: run.startedAt.toISOString()
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
]
|
|
381
|
+
}, { source: SOURCE });
|
|
382
|
+
}
|
|
383
|
+
async function emitSyncSucceededEvents(sixb, job, result) {
|
|
384
|
+
await sixb.events?.emit({
|
|
385
|
+
events: [
|
|
386
|
+
...result.versionCreated ? [
|
|
387
|
+
{
|
|
388
|
+
type: "dataset.version.committed",
|
|
389
|
+
payload: {
|
|
390
|
+
datasetId: result.datasetId,
|
|
391
|
+
versionId: result.version.versionId,
|
|
392
|
+
createdAt: result.version.createdAt.toISOString(),
|
|
393
|
+
producer: {
|
|
394
|
+
kind: "sync",
|
|
395
|
+
id: job.syncId,
|
|
396
|
+
runId: job.id
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
] : [],
|
|
401
|
+
{
|
|
402
|
+
type: "sync.run.finished",
|
|
403
|
+
payload: {
|
|
404
|
+
syncId: job.syncId,
|
|
405
|
+
runId: job.id,
|
|
406
|
+
status: "succeeded",
|
|
407
|
+
datasetId: result.datasetId,
|
|
408
|
+
...result.version ? { versionId: result.version.versionId } : {}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
]
|
|
412
|
+
}, { source: SOURCE });
|
|
413
|
+
}
|
|
414
|
+
async function emitSyncRunFinished(sixb, job) {
|
|
415
|
+
await sixb.events?.emit({
|
|
416
|
+
events: [
|
|
417
|
+
{
|
|
418
|
+
type: "sync.run.finished",
|
|
419
|
+
payload: {
|
|
420
|
+
syncId: job.syncId,
|
|
421
|
+
runId: job.id,
|
|
422
|
+
status: "failed"
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
]
|
|
426
|
+
}, { source: SOURCE });
|
|
427
|
+
}
|
|
428
|
+
function buildSyncContext(sixb) {
|
|
429
|
+
const syncRunsStorage = sixb.storage.syncRuns;
|
|
430
|
+
if (!syncRunsStorage) {
|
|
431
|
+
throw new Error("[SixbSyncWorker] Sync workers require storage.syncRuns support.");
|
|
432
|
+
}
|
|
433
|
+
return {
|
|
434
|
+
id: sixb.id,
|
|
435
|
+
syncRunsStorage,
|
|
436
|
+
lakeStorage: sixb.lakeStorage,
|
|
437
|
+
blobStorage: sixb.blobStorage,
|
|
438
|
+
logs: sixb.logs,
|
|
439
|
+
getSyncById(syncId) {
|
|
440
|
+
return sixb.getSyncById(syncId);
|
|
441
|
+
},
|
|
442
|
+
getDatasetById(datasetId) {
|
|
443
|
+
return sixb.getDatasetById(datasetId);
|
|
444
|
+
},
|
|
445
|
+
connector(definition) {
|
|
446
|
+
return sixb.connector(definition);
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
export {
|
|
451
|
+
SyncWorker
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
//# debugId=33375B9F4568F6E364756E2164756E21
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/worker.ts", "../src/run-sync-job.ts", "../src/normalize.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type {\n BlobStorage,\n ConnectorAdapter,\n ConnectorClient,\n ConnectorDefinition,\n DatasetDefinition,\n DomainEventLog,\n LakeStorage,\n Queues,\n Storage,\n SyncDefinition,\n} from \"@sixb/core\"\nimport { reportRunFailure } from \"@sixb/core/internal/error-reporting\"\nimport type { LogsRuntime } from \"@sixb/core/internal/logging\"\nimport type { QueueWorkerFailureDecision } from \"@sixb/core/internal/workers\"\nimport { QueueWorker } from \"@sixb/core/internal/workers\"\nimport type { ClaimedQueueJob, SyncRunRequestedQueueJob } from \"@sixb/core/queues\"\nimport type { SyncRunRecord } from \"@sixb/core/storage\"\nimport { runSyncJob, SyncRunAlreadyStartedError } from \"./run-sync-job\"\nimport type { SyncJob, SyncRunResult, SyncWorkerContext } from \"./types\"\n\nconst SOURCE = \"SixbSyncWorker\"\n\nexport interface SyncWorkerSixb {\n readonly id: string\n readonly events?: DomainEventLog\n readonly logs?: LogsRuntime\n readonly lakeStorage: LakeStorage\n readonly blobStorage: BlobStorage\n readonly queues: Queues\n readonly storage: Storage\n listSyncs(): readonly SyncDefinition[]\n getSyncById(syncId: string): SyncDefinition | null\n getDatasetById(datasetId: string): DatasetDefinition | null\n connector<TAdapter extends ConnectorAdapter>(\n definition: ConnectorDefinition<string, TAdapter>\n ): Promise<ConnectorClient<TAdapter>>\n}\n\nexport class SyncWorker extends QueueWorker<SyncRunRequestedQueueJob> {\n private readonly context: SyncWorkerContext\n private readonly sixb: SyncWorkerSixb\n\n constructor(sixb: SyncWorkerSixb) {\n if (sixb.listSyncs().length === 0) {\n throw new Error(\"[SixbSyncWorker] No sync definitions are registered.\")\n }\n\n super({\n projectId: sixb.id,\n queue: sixb.queues.syncRuns,\n workerId: `sync-worker-${sixb.id}`,\n })\n\n this.context = buildSyncContext(sixb)\n this.sixb = sixb\n }\n\n protected async execute(\n claimed: ClaimedQueueJob<SyncRunRequestedQueueJob>,\n signal: AbortSignal\n ): Promise<void> {\n const { job } = claimed\n const syncJob: SyncJob = {\n id: job.payload.runId ?? `${job.id}:attempt:${job.attempt}`,\n syncId: job.payload.syncId,\n expectedLatestVersionId: job.payload.expectedLatestVersionId,\n commitMessage: job.payload.commitMessage,\n }\n\n let result: SyncRunResult\n try {\n result = await runSyncJob({\n runtime: this.context,\n job: syncJob,\n signal,\n onRunStarted: (run) => emitSyncRunStarted(this.sixb, run),\n onRunFailed: (error, run) => {\n reportRunFailure(this.sixb, error, {\n projectId: this.sixb.id,\n occurredAt: run.finishedAt,\n attempt: job.attempt,\n run: {\n kind: \"sync\",\n runId: run.id,\n syncId: run.syncId,\n },\n })\n },\n })\n } catch (error) {\n if (error instanceof SyncRunAlreadyStartedError) return\n throw error\n }\n\n await emitSyncSucceededEvents(this.sixb, syncJob, result)\n }\n\n protected override async onExecutionError(\n claimed: ClaimedQueueJob<SyncRunRequestedQueueJob>,\n _error: unknown\n ): Promise<QueueWorkerFailureDecision> {\n const { job } = claimed\n await emitSyncRunFinished(this.sixb, {\n id: job.payload.runId ?? `${job.id}:attempt:${job.attempt}`,\n syncId: job.payload.syncId,\n })\n\n return { kind: \"fail\" }\n }\n}\n\nasync function emitSyncRunStarted(\n sixb: SyncWorkerSixb,\n run: Pick<SyncRunRecord, \"id\" | \"syncId\" | \"startedAt\">\n): Promise<void> {\n await sixb.events?.emit(\n {\n events: [\n {\n type: \"sync.run.started\",\n payload: {\n syncId: run.syncId,\n runId: run.id,\n startedAt: run.startedAt.toISOString(),\n },\n },\n ],\n },\n { source: SOURCE }\n )\n}\n\nasync function emitSyncSucceededEvents(\n sixb: SyncWorkerSixb,\n job: Pick<SyncJob, \"id\" | \"syncId\">,\n result: SyncRunResult\n): Promise<void> {\n await sixb.events?.emit(\n {\n events: [\n ...(result.versionCreated\n ? [\n {\n type: \"dataset.version.committed\" as const,\n payload: {\n datasetId: result.datasetId,\n versionId: result.version.versionId,\n createdAt: result.version.createdAt.toISOString(),\n producer: {\n kind: \"sync\" as const,\n id: job.syncId,\n runId: job.id,\n },\n },\n },\n ]\n : []),\n {\n type: \"sync.run.finished\",\n payload: {\n syncId: job.syncId,\n runId: job.id,\n status: \"succeeded\",\n datasetId: result.datasetId,\n ...(result.version ? { versionId: result.version.versionId } : {}),\n },\n },\n ],\n },\n { source: SOURCE }\n )\n}\n\nasync function emitSyncRunFinished(\n sixb: SyncWorkerSixb,\n job: Pick<SyncJob, \"id\" | \"syncId\">\n): Promise<void> {\n await sixb.events?.emit(\n {\n events: [\n {\n type: \"sync.run.finished\",\n payload: {\n syncId: job.syncId,\n runId: job.id,\n status: \"failed\",\n },\n },\n ],\n },\n { source: SOURCE }\n )\n}\n\nfunction buildSyncContext(sixb: SyncWorkerSixb): SyncWorkerContext {\n const syncRunsStorage = sixb.storage.syncRuns\n if (!syncRunsStorage) {\n throw new Error(\"[SixbSyncWorker] Sync workers require storage.syncRuns support.\")\n }\n\n return {\n id: sixb.id,\n syncRunsStorage,\n lakeStorage: sixb.lakeStorage,\n blobStorage: sixb.blobStorage,\n logs: sixb.logs,\n getSyncById(syncId) {\n return sixb.getSyncById(syncId)\n },\n getDatasetById(datasetId) {\n return sixb.getDatasetById(datasetId)\n },\n connector(definition) {\n return sixb.connector(definition)\n },\n }\n}\n",
|
|
6
|
+
"import {\n assertJsonValue,\n type BlobStorage,\n cloneJsonValue,\n type FileRef,\n getDatasetRowValidationError,\n isFileRef,\n type JsonValue,\n} from \"@sixb/core\"\nimport { resolveLogsRuntime } from \"@sixb/core/internal/logging\"\nimport type { DatasetVersion, LakeWriteSession } from \"@sixb/core/lake-storage\"\nimport type { SyncRunFailure, SyncRunRecord } from \"@sixb/core/storage\"\nimport { assertDatasetRow, normalizeReadResult, throwIfAborted } from \"./normalize\"\nimport type { RunSyncJobInput, SyncRunResult } from \"./types\"\n\nexport class SyncRunAlreadyStartedError extends Error {\n override readonly name = \"SyncRunAlreadyStartedError\"\n\n constructor(readonly run: SyncRunRecord) {\n super(`[SixbSyncWorker] Sync run '${run.id}' has already started.`)\n }\n}\n\nfunction toSyncRunFailure(error: unknown): SyncRunFailure {\n if (error instanceof Error) {\n return {\n name: error.name,\n message: error.message,\n }\n }\n\n return {\n message: String(error),\n }\n}\n\nfunction createBookkeepingError(options: {\n syncId: string\n runId: string\n version: DatasetVersion\n cause: unknown\n}): Error {\n // The lake commit is already durable here, so we surface an explicit repair-needed error.\n return new Error(\n `[SixbSyncWorker] Sync '${options.syncId}' committed dataset version '${options.version.versionId}', but failed to finalize sync run '${options.runId}'. The dataset commit may already have succeeded and the sync run record may need repair.`,\n { cause: options.cause }\n )\n}\n\nfunction requireFinishedAt(runId: string, finishedAt: Date | undefined): Date {\n if (finishedAt) {\n return finishedAt\n }\n\n throw new Error(`[SixbSyncWorker] Sync run '${runId}' finished without a finishedAt timestamp.`)\n}\n\nasync function verifyFileRef(options: {\n blobStorage: BlobStorage\n syncId: string\n datasetId: string\n columnName: string\n itemIndex: number\n fileRef: FileRef\n}): Promise<void> {\n const blobInfo = await options.blobStorage.stat(options.fileRef.blobId)\n if (!blobInfo) {\n throw new Error(\n `[SixbSyncWorker] Sync '${options.syncId}' returned row ${options.itemIndex} with dataset '${options.datasetId}' column '${options.columnName}' referencing unknown blob '${options.fileRef.blobId}'.`\n )\n }\n\n if (blobInfo.digest !== options.fileRef.digest) {\n throw new Error(\n `[SixbSyncWorker] Sync '${options.syncId}' returned row ${options.itemIndex} with dataset '${options.datasetId}' column '${options.columnName}' referencing blob '${options.fileRef.blobId}' with digest '${options.fileRef.digest}', but blob storage has '${blobInfo.digest}'.`\n )\n }\n\n if (blobInfo.sizeBytes !== options.fileRef.sizeBytes) {\n throw new Error(\n `[SixbSyncWorker] Sync '${options.syncId}' returned row ${options.itemIndex} with dataset '${options.datasetId}' column '${options.columnName}' referencing blob '${options.fileRef.blobId}' with size ${options.fileRef.sizeBytes}, but blob storage has ${blobInfo.sizeBytes}.`\n )\n }\n}\n\nasync function verifyRowFileRefs(options: {\n blobStorage: BlobStorage\n syncId: string\n dataset: { id: string; schema: { columns: readonly { name: string; type: string }[] } }\n row: Record<string, unknown>\n itemIndex: number\n}): Promise<void> {\n const fileRefColumns = options.dataset.schema.columns.filter(\n (column) => column.type === \"fileRef\"\n )\n for (const column of fileRefColumns) {\n const value = options.row[column.name]\n if (!isFileRef(value)) {\n continue\n }\n\n await verifyFileRef({\n blobStorage: options.blobStorage,\n syncId: options.syncId,\n datasetId: options.dataset.id,\n columnName: column.name,\n itemIndex: options.itemIndex,\n fileRef: value,\n })\n }\n}\n\n/**\n * Run one sync job end to end using a caller-supplied run id.\n *\n * The worker creates the operational sync-run record, streams rows into lake\n * storage, commits one dataset version, and then finalizes the run record with\n * the outcome. It does not own scheduling, retries, or run-id generation.\n */\nexport async function runSyncJob(input: RunSyncJobInput): Promise<SyncRunResult> {\n const { runtime, job } = input\n const signal = input.signal ?? new AbortController().signal\n const { syncRunsStorage, lakeStorage, blobStorage } = runtime\n\n const sync = runtime.getSyncById(job.syncId)\n if (!sync) {\n throw new Error(`[SixbSyncWorker] Unknown sync '${job.syncId}'.`)\n }\n\n const dataset = runtime.getDatasetById(sync.target.dataset.id)\n if (!dataset) {\n throw new Error(\n `[SixbSyncWorker] Sync '${sync.id}' targets unknown dataset '${sync.target.dataset.id}'.`\n )\n }\n\n throwIfAborted(signal)\n\n let startedRun: SyncRunRecord\n try {\n startedRun = await syncRunsStorage.start({\n projectId: runtime.id,\n id: job.id,\n syncId: sync.id,\n datasetId: dataset.id,\n mode: sync.config.mode,\n expectedLatestVersionId: job.expectedLatestVersionId,\n commitMessage: job.commitMessage,\n })\n } catch (error) {\n const existing = await syncRunsStorage.getById({ projectId: runtime.id, id: job.id })\n if (existing?.syncId === sync.id && existing.datasetId === dataset.id) {\n throw new SyncRunAlreadyStartedError(existing)\n }\n throw error\n }\n await input.onRunStarted?.(startedRun)\n\n const logSession = resolveLogsRuntime(runtime.id, runtime.logs).startExecution({\n kind: \"sync\",\n id: job.id,\n })\n const logger = logSession.logger\n let write: LakeWriteSession | undefined\n let rowsRead = 0\n let committedVersion: DatasetVersion | undefined\n\n try {\n throwIfAborted(signal)\n await lakeStorage.createDataset(dataset)\n\n const latestSuccessfulRuns = await syncRunsStorage.list({\n projectId: runtime.id,\n syncId: sync.id,\n statuses: [\"succeeded\"],\n limit: 1,\n order: \"desc\",\n })\n const previousCheckpoint = latestSuccessfulRuns.runs[0]?.checkpoint\n let nextCheckpoint: JsonValue | undefined =\n previousCheckpoint !== undefined ? cloneJsonValue(previousCheckpoint) : undefined\n\n const client = await runtime.connector(sync.connector)\n const readResult = await sync.read(client, {\n projectId: runtime.id,\n syncId: sync.id,\n signal,\n blobs: blobStorage,\n logger,\n checkpoint: previousCheckpoint !== undefined ? cloneJsonValue(previousCheckpoint) : undefined,\n setCheckpoint(next: unknown) {\n assertJsonValue(next, `Sync '${sync.id}' checkpoint`)\n nextCheckpoint = cloneJsonValue(next)\n },\n })\n const rows = normalizeReadResult(readResult, sync.id)\n\n throwIfAborted(signal)\n\n write = await lakeStorage.beginWrite({\n dataset,\n mode: sync.config.mode,\n producer: {\n kind: \"sync\",\n id: sync.id,\n runId: job.id,\n },\n })\n\n await write.writeRows(\n (async function* () {\n let itemIndex = 0\n\n for await (const value of rows) {\n throwIfAborted(signal)\n itemIndex += 1\n\n const row = assertDatasetRow(value, sync.id, itemIndex)\n // Validate before handing rows to lake storage so sync failures include\n // the source item index; lake storage still re-validates as the final boundary.\n const validationError = getDatasetRowValidationError(row, dataset)\n if (validationError) {\n throw new Error(\n `[SixbSyncWorker] Sync '${sync.id}' returned an invalid row at item ${itemIndex}. ${validationError}`\n )\n }\n\n // Lake storage validates fileRef shape; the worker owns existence checks against blob storage.\n await verifyRowFileRefs({\n blobStorage,\n syncId: sync.id,\n dataset,\n row,\n itemIndex,\n })\n\n rowsRead += 1\n yield row\n }\n })()\n )\n\n throwIfAborted(signal)\n\n if (sync.config.mode === \"append\" && rowsRead === 0) {\n await write.abort()\n write = undefined\n const version = await lakeStorage.getLatestVersion(dataset.id)\n const finishedRun = await syncRunsStorage.finish({\n projectId: runtime.id,\n id: job.id,\n status: \"succeeded\",\n rowsRead,\n ...(version\n ? { output: { datasetId: version.datasetId, versionId: version.versionId } }\n : {}),\n checkpoint: nextCheckpoint,\n })\n\n return {\n id: job.id,\n syncId: sync.id,\n datasetId: dataset.id,\n mode: sync.config.mode,\n startedAt: startedRun.startedAt,\n finishedAt: requireFinishedAt(job.id, finishedRun.finishedAt),\n rowsRead,\n ...(version ? { version } : {}),\n versionCreated: false,\n }\n }\n\n const commit = await write.commit({\n expectedLatestVersionId: job.expectedLatestVersionId,\n commitMessage: job.commitMessage ?? `sync ${sync.id} run ${job.id}`,\n })\n const { outcome, ...version } = commit\n committedVersion = version\n let finishedRun: SyncRunRecord\n\n try {\n finishedRun = await syncRunsStorage.finish({\n projectId: runtime.id,\n id: job.id,\n status: \"succeeded\",\n rowsRead,\n output: {\n datasetId: version.datasetId,\n versionId: version.versionId,\n },\n checkpoint: nextCheckpoint,\n })\n } catch (error) {\n throw createBookkeepingError({\n syncId: sync.id,\n runId: job.id,\n version,\n cause: error,\n })\n }\n\n return {\n id: job.id,\n syncId: sync.id,\n datasetId: dataset.id,\n mode: sync.config.mode,\n startedAt: startedRun.startedAt,\n finishedAt: requireFinishedAt(job.id, finishedRun.finishedAt),\n rowsRead,\n version,\n versionCreated: outcome === \"created\",\n }\n } catch (error) {\n if (!committedVersion) {\n // Before commit succeeds we can still best-effort clean up both the write session and run record.\n await write?.abort().catch(() => {})\n\n const status = signal.aborted ? \"cancelled\" : \"failed\"\n try {\n const run = await syncRunsStorage.finish({\n projectId: runtime.id,\n id: job.id,\n status,\n rowsRead,\n error: toSyncRunFailure(error),\n })\n if (status === \"failed\" && run.status === \"failed\") input.onRunFailed?.(error, run)\n } catch {\n // The run did not transition to the requested terminal status.\n }\n }\n\n throw error\n } finally {\n await logSession.flush()\n }\n}\n",
|
|
7
|
+
"import type { DatasetRow, SyncReadResult } from \"@sixb/core\"\n\nfunction isPlainObject(value: unknown): value is DatasetRow {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === Object.prototype || prototype === null\n}\n\nfunction isIterable(value: unknown): value is Iterable<unknown> {\n return (\n value !== null &&\n value !== undefined &&\n typeof (value as { [Symbol.iterator]?: unknown })[Symbol.iterator] === \"function\"\n )\n}\n\nfunction isAsyncIterable(value: unknown): value is AsyncIterable<unknown> {\n return (\n value !== null &&\n value !== undefined &&\n typeof (value as { [Symbol.asyncIterator]?: unknown })[Symbol.asyncIterator] === \"function\"\n )\n}\n\nfunction toAbortError(signal: AbortSignal): Error {\n if (signal.reason instanceof Error) {\n return signal.reason\n }\n\n const message =\n typeof signal.reason === \"string\" && signal.reason.length > 0\n ? signal.reason\n : \"[SixbSyncWorker] Operation was cancelled.\"\n\n const error = new Error(message)\n error.name = \"AbortError\"\n return error\n}\n\nexport function throwIfAborted(signal: AbortSignal): void {\n if (signal.aborted) {\n throw toAbortError(signal)\n }\n}\n\nexport function assertDatasetRow(value: unknown, syncId: string, itemIndex: number): DatasetRow {\n if (isPlainObject(value)) {\n return value\n }\n\n throw new Error(\n `[SixbSyncWorker] Sync '${syncId}' returned an invalid row at item ${itemIndex}. Dataset rows must be plain objects.`\n )\n}\n\nexport async function* normalizeReadResult(\n readResult: SyncReadResult,\n syncId: string\n): AsyncIterable<unknown> {\n if (isAsyncIterable(readResult)) {\n yield* readResult\n return\n }\n\n if (isIterable(readResult)) {\n for (const item of readResult) {\n yield item\n }\n return\n }\n\n if (isPlainObject(readResult)) {\n yield readResult\n return\n }\n\n throw new Error(\n `[SixbSyncWorker] Sync '${syncId}' returned an unsupported read result. Expected a row object, iterable, or async iterable.`\n )\n}\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": ";;AAYA;AAGA;;;ACfA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA;;;ACPA,SAAS,aAAa,CAAC,OAAqC;AAAA,EAC1D,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GAAG;AAAA,IACvE,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,YAAY,OAAO,eAAe,KAAK;AAAA,EAC7C,OAAO,cAAc,OAAO,aAAa,cAAc;AAAA;AAGzD,SAAS,UAAU,CAAC,OAA4C;AAAA,EAC9D,OACE,UAAU,QACV,UAAU,aACV,OAAQ,MAA0C,OAAO,cAAc;AAAA;AAI3E,SAAS,eAAe,CAAC,OAAiD;AAAA,EACxE,OACE,UAAU,QACV,UAAU,aACV,OAAQ,MAA+C,OAAO,mBAAmB;AAAA;AAIrF,SAAS,YAAY,CAAC,QAA4B;AAAA,EAChD,IAAI,OAAO,kBAAkB,O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|
+
import type { DatasetRow, SyncReadResult } from "@sixb/core";
|
|
2
|
+
export declare function throwIfAborted(signal: AbortSignal): void;
|
|
3
|
+
export declare function assertDatasetRow(value: unknown, syncId: string, itemIndex: number): DatasetRow;
|
|
4
|
+
export declare function normalizeReadResult(readResult: SyncReadResult, syncId: string): AsyncIterable<unknown>;
|
|
5
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AA0C5D,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAIxD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CAQ9F;AAED,wBAAuB,mBAAmB,CACxC,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,MAAM,GACb,aAAa,CAAC,OAAO,CAAC,CAqBxB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SyncRunRecord } from "@sixb/core/storage";
|
|
2
|
+
import type { RunSyncJobInput, SyncRunResult } from "./types";
|
|
3
|
+
export declare class SyncRunAlreadyStartedError extends Error {
|
|
4
|
+
readonly run: SyncRunRecord;
|
|
5
|
+
readonly name = "SyncRunAlreadyStartedError";
|
|
6
|
+
constructor(run: SyncRunRecord);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Run one sync job end to end using a caller-supplied run id.
|
|
10
|
+
*
|
|
11
|
+
* The worker creates the operational sync-run record, streams rows into lake
|
|
12
|
+
* storage, commits one dataset version, and then finalizes the run record with
|
|
13
|
+
* the outcome. It does not own scheduling, retries, or run-id generation.
|
|
14
|
+
*/
|
|
15
|
+
export declare function runSyncJob(input: RunSyncJobInput): Promise<SyncRunResult>;
|
|
16
|
+
//# sourceMappingURL=run-sync-job.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-sync-job.d.ts","sourceRoot":"","sources":["../src/run-sync-job.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvE,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE7D,qBAAa,0BAA2B,SAAQ,KAAK;IAGvC,QAAQ,CAAC,GAAG,EAAE,aAAa;IAFvC,SAAkB,IAAI,gCAA+B;gBAEhC,GAAG,EAAE,aAAa;CAGxC;AA2FD;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAyN/E"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Written by scripts/build-package.ts, and published on purpose.
|
|
2
|
+
// Bun applies the nearest tsconfig paths map to every import it resolves, node_modules
|
|
3
|
+
// included. An empty map here keeps a consumer's aliases from sending a module in this
|
|
4
|
+
// directory back into a second copy of its own source.
|
|
5
|
+
{ "compilerOptions": { "paths": {} } }
|