@sixb/pipeline-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 +34 -0
- package/dist/errors.d.ts +34 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/events.d.ts +15 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/execute-run-step.d.ts +19 -0
- package/dist/execute-run-step.d.ts.map +1 -0
- package/dist/execute-sql-step.d.ts +18 -0
- package/dist/execute-sql-step.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +654 -0
- package/dist/index.js.map +17 -0
- package/dist/run-pipeline-job.d.ts +9 -0
- package/dist/run-pipeline-job.d.ts.map +1 -0
- package/dist/run-step.d.ts +14 -0
- package/dist/run-step.d.ts.map +1 -0
- package/dist/step-inputs.d.ts +16 -0
- package/dist/step-inputs.d.ts.map +1 -0
- package/dist/tsconfig.json +5 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/worker.d.ts +13 -0
- package/dist/worker.d.ts.map +1 -0
- package/package.json +57 -0
- package/src/errors.ts +110 -0
- package/src/events.ts +189 -0
- package/src/execute-run-step.ts +98 -0
- package/src/execute-sql-step.ts +115 -0
- package/src/index.ts +2 -0
- package/src/run-pipeline-job.ts +130 -0
- package/src/run-step.ts +154 -0
- package/src/step-inputs.ts +84 -0
- package/src/types.ts +88 -0
- package/src/worker.ts +165 -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,34 @@
|
|
|
1
|
+
# @sixb/pipeline-worker
|
|
2
|
+
|
|
3
|
+
Worker that runs Sixb pipelines.
|
|
4
|
+
|
|
5
|
+
Dequeues pipeline runs, executes each step in order, and records the run in `storage.pipelineRuns`.
|
|
6
|
+
Pipelines are how dataset rows become objects, links, and telemetry, so without this worker running a
|
|
7
|
+
pipeline request simply waits in the queue.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun add @sixb/pipeline-worker
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
You normally do not import it. `sixb worker pipeline` and `sixb worker-group` construct it for you,
|
|
16
|
+
and that is the supported way to run it.
|
|
17
|
+
|
|
18
|
+
## Running it yourself
|
|
19
|
+
|
|
20
|
+
Construct it directly only when you host workers inside your own process:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { PipelineWorker } from "@sixb/pipeline-worker"
|
|
24
|
+
import { sixb } from "./sixb.config"
|
|
25
|
+
|
|
26
|
+
const worker = new PipelineWorker(sixb)
|
|
27
|
+
await worker.start()
|
|
28
|
+
// on shutdown
|
|
29
|
+
await worker.stop()
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Requires a lake storage provider — pipeline steps read dataset versions from it — and a storage
|
|
33
|
+
provider with `pipelineRuns` support. Both are checked at construction, so a missing provider fails at
|
|
34
|
+
boot rather than on the first job.
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DatasetDefinition, PipelineDefinition } from "@sixb/core";
|
|
2
|
+
import type { DatasetVersion } from "@sixb/core/lake-storage";
|
|
3
|
+
import type { PipelineRunFailure, PipelineRunStatus } from "@sixb/core/storage";
|
|
4
|
+
import type { PipelineJob } from "./types";
|
|
5
|
+
export declare class PipelineWorkerError extends Error {
|
|
6
|
+
readonly name = "PipelineWorkerError";
|
|
7
|
+
}
|
|
8
|
+
export declare function toPipelineRunFailure(error: unknown): PipelineRunFailure;
|
|
9
|
+
export declare function throwIfAborted(signal: AbortSignal): void;
|
|
10
|
+
export declare function statusForFailure(signal: AbortSignal, error: unknown): Extract<PipelineRunStatus, "failed" | "cancelled">;
|
|
11
|
+
export declare function requireFinishedAt(runId: string, finishedAt: Date | undefined): Date;
|
|
12
|
+
export declare function createStepBookkeepingError(options: {
|
|
13
|
+
readonly pipelineId: string;
|
|
14
|
+
readonly stepId: string;
|
|
15
|
+
readonly runId: string;
|
|
16
|
+
readonly version: DatasetVersion;
|
|
17
|
+
readonly cause: unknown;
|
|
18
|
+
}): Error;
|
|
19
|
+
export declare function createPipelineBookkeepingError(options: {
|
|
20
|
+
readonly pipelineId: string;
|
|
21
|
+
readonly runId: string;
|
|
22
|
+
readonly version: DatasetVersion;
|
|
23
|
+
readonly cause: unknown;
|
|
24
|
+
}): Error;
|
|
25
|
+
export declare function requirePipeline(pipeline: PipelineDefinition | null, job: PipelineJob): PipelineDefinition;
|
|
26
|
+
export declare function requireRegisteredDataset(options: {
|
|
27
|
+
readonly dataset: DatasetDefinition | null;
|
|
28
|
+
readonly pipelineId: string;
|
|
29
|
+
readonly stepId: string;
|
|
30
|
+
readonly role: "input" | "output";
|
|
31
|
+
readonly name?: string;
|
|
32
|
+
readonly datasetId: string;
|
|
33
|
+
}): DatasetDefinition;
|
|
34
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,yBAAwB;CACtC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAWvE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAIxD;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,iBAAiB,EAAE,QAAQ,GAAG,WAAW,CAAC,CAEpD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,GAAG,SAAS,GAAG,IAAI,CAQnF;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;IAChC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,GAAG,KAAK,CAMR;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE;IACtD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;IAChC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,GAAG,KAAK,CAKR;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,kBAAkB,GAAG,IAAI,EACnC,GAAG,EAAE,WAAW,GACf,kBAAkB,CAMpB;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAA;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B,GAAG,iBAAiB,CAUpB"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DomainEventLog } from "@sixb/core";
|
|
2
|
+
import type { PipelineRunRecord, PipelineStepRunRecord } from "@sixb/core/storage";
|
|
3
|
+
import type { PipelineJob, PipelineStepLifecycleContext, PipelineStepRunResult } from "./types";
|
|
4
|
+
export declare function emitPipelineRunStarted(events: DomainEventLog | undefined, run: Pick<PipelineRunRecord, "id" | "pipelineId" | "startedAt">): Promise<void>;
|
|
5
|
+
export declare function emitPipelineRunStepStarted(events: DomainEventLog | undefined, step: Pick<PipelineStepRunRecord, "id" | "pipelineRunId" | "pipelineId" | "stepId" | "datasetId" | "startedAt">, context: PipelineStepLifecycleContext): Promise<void>;
|
|
6
|
+
export declare function emitPipelineRunStepFinished(events: DomainEventLog | undefined, step: Pick<PipelineStepRunRecord, "id" | "pipelineRunId" | "pipelineId" | "stepId" | "datasetId" | "status" | "finishedAt" | "output" | "rowsWritten" | "error">, context: PipelineStepLifecycleContext): Promise<void>;
|
|
7
|
+
export declare function emitDatasetVersionCommitted(events: DomainEventLog | undefined, job: PipelineJob, step: PipelineStepRunResult): Promise<void>;
|
|
8
|
+
export declare function emitPipelineRunFinished(events: DomainEventLog | undefined, job: {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly pipelineId: string;
|
|
11
|
+
readonly status: "succeeded" | "failed" | "cancelled";
|
|
12
|
+
readonly datasetId?: string;
|
|
13
|
+
readonly versionId?: string;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EACV,iBAAiB,EAEjB,qBAAqB,EACtB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAI/F,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,GAAG,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,GAAG,YAAY,GAAG,WAAW,CAAC,GAC9D,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,IAAI,EAAE,IAAI,CACR,qBAAqB,EACrB,IAAI,GAAG,eAAe,GAAG,YAAY,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,CAC7E,EACD,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,IAAI,CAAC,CAqBf;AAED,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,IAAI,EAAE,IAAI,CACR,qBAAqB,EACnB,IAAI,GACJ,eAAe,GACf,YAAY,GACZ,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,YAAY,GACZ,QAAQ,GACR,aAAa,GACb,OAAO,CACV,EACD,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,cAAc,GAAG,SAAS,EAClC,GAAG,EAAE;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAA;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B,GACA,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DatasetDefinition, PipelineDefinition, PipelineStepDefinition } from "@sixb/core";
|
|
2
|
+
import type { DatasetVersion } from "@sixb/core/lake-storage";
|
|
3
|
+
import { type ResolvedStepInput } from "./step-inputs";
|
|
4
|
+
import type { PipelineJob, PipelineLogSession, PipelineWorkerContext } from "./types";
|
|
5
|
+
export declare function executeRunStep(input: {
|
|
6
|
+
readonly runtime: PipelineWorkerContext;
|
|
7
|
+
readonly pipeline: PipelineDefinition;
|
|
8
|
+
readonly step: PipelineStepDefinition;
|
|
9
|
+
readonly job: PipelineJob;
|
|
10
|
+
readonly signal: AbortSignal;
|
|
11
|
+
readonly logSession: PipelineLogSession;
|
|
12
|
+
readonly outputDataset: DatasetDefinition;
|
|
13
|
+
readonly resolvedInputs: readonly ResolvedStepInput[];
|
|
14
|
+
}): Promise<{
|
|
15
|
+
readonly version: DatasetVersion;
|
|
16
|
+
readonly versionCreated: boolean;
|
|
17
|
+
readonly rowsWritten: number;
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=execute-run-step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-run-step.d.ts","sourceRoot":"","sources":["../src/execute-run-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,kBAAkB,EAClB,sBAAsB,EAEvB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAE7D,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAErF,wBAAsB,cAAc,CAAC,KAAK,EAAE;IAC1C,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAA;IACvC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAA;IACrC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;IACrC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAA;IACvC,QAAQ,CAAC,aAAa,EAAE,iBAAiB,CAAA;IACzC,QAAQ,CAAC,cAAc,EAAE,SAAS,iBAAiB,EAAE,CAAA;CACtD,GAAG,OAAO,CAAC;IACV,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;IAChC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B,CAAC,CA4DD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DatasetDefinition, PipelineDefinition, PipelineStepDefinition } from "@sixb/core";
|
|
2
|
+
import type { DatasetVersion } from "@sixb/core/lake-storage";
|
|
3
|
+
import type { ResolvedStepInput } from "./step-inputs";
|
|
4
|
+
import type { PipelineJob, PipelineWorkerContext } from "./types";
|
|
5
|
+
export declare function executeSqlStep(input: {
|
|
6
|
+
readonly runtime: PipelineWorkerContext;
|
|
7
|
+
readonly pipeline: PipelineDefinition;
|
|
8
|
+
readonly step: PipelineStepDefinition;
|
|
9
|
+
readonly job: PipelineJob;
|
|
10
|
+
readonly signal: AbortSignal;
|
|
11
|
+
readonly outputDataset: DatasetDefinition;
|
|
12
|
+
readonly resolvedInputs: readonly ResolvedStepInput[];
|
|
13
|
+
}): Promise<{
|
|
14
|
+
readonly version: DatasetVersion;
|
|
15
|
+
readonly versionCreated: boolean;
|
|
16
|
+
readonly rowsWritten?: number;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=execute-sql-step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-sql-step.d.ts","sourceRoot":"","sources":["../src/execute-sql-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAGjB,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AA6BjE,wBAAsB,cAAc,CAAC,KAAK,EAAE;IAC1C,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAA;IACvC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAA;IACrC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;IACrC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,QAAQ,CAAC,aAAa,EAAE,iBAAiB,CAAA;IACzC,QAAQ,CAAC,cAAc,EAAE,SAAS,iBAAiB,EAAE,CAAA;CACtD,GAAG,OAAO,CAAC;IACV,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;IAChC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC9B,CAAC,CA2DD"}
|
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,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
|