openworkflow 0.6.0 → 0.6.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/README.md +2 -0
- package/dist/bin/openworkflow.js +0 -0
- package/dist/internal.d.ts +0 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +0 -1
- package/package.json +6 -2
- package/dist/backend-test/backend.testsuite.d.ts +0 -20
- package/dist/backend-test/backend.testsuite.d.ts.map +0 -1
- package/dist/backend-test/backend.testsuite.js +0 -1090
- package/dist/backend-test/index.d.ts +0 -2
- package/dist/backend-test/index.d.ts.map +0 -1
- package/dist/backend-test/index.js +0 -1
- package/dist/backend.testsuite.d.ts +0 -20
- package/dist/backend.testsuite.d.ts.map +0 -1
- package/dist/backend.testsuite.js +0 -1090
- package/dist/chaos.test.d.ts +0 -2
- package/dist/chaos.test.d.ts.map +0 -1
- package/dist/chaos.test.js +0 -88
- package/dist/client.test.d.ts +0 -2
- package/dist/client.test.d.ts.map +0 -1
- package/dist/client.test.js +0 -311
- package/dist/core/duration.test.d.ts +0 -2
- package/dist/core/duration.test.d.ts.map +0 -1
- package/dist/core/duration.test.js +0 -263
- package/dist/core/error.test.d.ts +0 -2
- package/dist/core/error.test.d.ts.map +0 -1
- package/dist/core/error.test.js +0 -60
- package/dist/core/result.test.d.ts +0 -2
- package/dist/core/result.test.d.ts.map +0 -1
- package/dist/core/result.test.js +0 -11
- package/dist/core/step.test.d.ts +0 -2
- package/dist/core/step.test.d.ts.map +0 -1
- package/dist/core/step.test.js +0 -266
- package/dist/core/workflow.test.d.ts +0 -2
- package/dist/core/workflow.test.d.ts.map +0 -1
- package/dist/core/workflow.test.js +0 -113
- package/dist/driver.d.ts +0 -116
- package/dist/driver.d.ts.map +0 -1
- package/dist/driver.js +0 -1
- package/dist/execution.test.d.ts +0 -2
- package/dist/execution.test.d.ts.map +0 -1
- package/dist/execution.test.js +0 -381
- package/dist/factory.d.ts +0 -74
- package/dist/factory.d.ts.map +0 -1
- package/dist/factory.js +0 -72
- package/dist/node-sqlite/backend.d.ts +0 -52
- package/dist/node-sqlite/backend.d.ts.map +0 -1
- package/dist/node-sqlite/backend.js +0 -673
- package/dist/node-sqlite/index.d.ts +0 -11
- package/dist/node-sqlite/index.d.ts.map +0 -1
- package/dist/node-sqlite/index.js +0 -7
- package/dist/node-sqlite/sqlite.d.ts +0 -60
- package/dist/node-sqlite/sqlite.d.ts.map +0 -1
- package/dist/node-sqlite/sqlite.js +0 -246
- package/dist/postgres/backend.test.d.ts +0 -2
- package/dist/postgres/backend.test.d.ts.map +0 -1
- package/dist/postgres/backend.test.js +0 -19
- package/dist/postgres/driver.d.ts +0 -81
- package/dist/postgres/driver.d.ts.map +0 -1
- package/dist/postgres/driver.js +0 -63
- package/dist/postgres/index.d.ts +0 -11
- package/dist/postgres/index.d.ts.map +0 -1
- package/dist/postgres/index.js +0 -7
- package/dist/postgres/internal.d.ts +0 -2
- package/dist/postgres/internal.d.ts.map +0 -1
- package/dist/postgres/internal.js +0 -1
- package/dist/postgres/postgres.test.d.ts +0 -2
- package/dist/postgres/postgres.test.d.ts.map +0 -1
- package/dist/postgres/postgres.test.js +0 -45
- package/dist/postgres/vitest.global-setup.d.ts +0 -3
- package/dist/postgres/vitest.global-setup.d.ts.map +0 -1
- package/dist/postgres/vitest.global-setup.js +0 -7
- package/dist/registry.test.d.ts +0 -2
- package/dist/registry.test.d.ts.map +0 -1
- package/dist/registry.test.js +0 -109
- package/dist/sqlite/backend.test.d.ts +0 -2
- package/dist/sqlite/backend.test.d.ts.map +0 -1
- package/dist/sqlite/backend.test.js +0 -50
- package/dist/sqlite/driver.d.ts +0 -79
- package/dist/sqlite/driver.d.ts.map +0 -1
- package/dist/sqlite/driver.js +0 -62
- package/dist/sqlite/index.d.ts +0 -13
- package/dist/sqlite/index.d.ts.map +0 -1
- package/dist/sqlite/index.js +0 -11
- package/dist/sqlite/internal.d.ts +0 -2
- package/dist/sqlite/internal.d.ts.map +0 -1
- package/dist/sqlite/internal.js +0 -1
- package/dist/sqlite/sqlite.test.d.ts +0 -2
- package/dist/sqlite/sqlite.test.d.ts.map +0 -1
- package/dist/sqlite/sqlite.test.js +0 -171
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/worker.test.d.ts +0 -2
- package/dist/worker.test.d.ts.map +0 -1
- package/dist/worker.test.js +0 -900
- package/dist/workflow.test.d.ts +0 -2
- package/dist/workflow.test.d.ts.map +0 -1
- package/dist/workflow.test.js +0 -84
package/dist/factory.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Drizzle-style factory function for creating OpenWorkflow instances.
|
|
3
|
-
*
|
|
4
|
-
* This module provides a factory function that follows the Drizzle ORM pattern
|
|
5
|
-
* for creating database instances. It supports multiple calling conventions:
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* // With a pre-configured driver
|
|
9
|
-
* const ow = openworkflow(postgres(url));
|
|
10
|
-
*
|
|
11
|
-
* // With inline configuration
|
|
12
|
-
* const ow = openworkflow(postgres({ connection: url, namespace: 'app' }));
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
import type { Backend } from "./backend.js";
|
|
16
|
-
import { OpenWorkflow } from "./client.js";
|
|
17
|
-
import type { Driver } from "./driver.js";
|
|
18
|
-
/**
|
|
19
|
-
* Extended OpenWorkflow instance with driver metadata.
|
|
20
|
-
*/
|
|
21
|
-
export interface OpenWorkflowWithDriver extends OpenWorkflow {
|
|
22
|
-
/**
|
|
23
|
-
* The underlying driver used to create this instance.
|
|
24
|
-
*/
|
|
25
|
-
readonly $driver: Driver;
|
|
26
|
-
/**
|
|
27
|
-
* The underlying backend instance.
|
|
28
|
-
*/
|
|
29
|
-
readonly $backend: Backend;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new OpenWorkflow instance from a driver.
|
|
33
|
-
*
|
|
34
|
-
* This is the Drizzle-style factory function that provides a clean API for
|
|
35
|
-
* creating OpenWorkflow instances with different database backends.
|
|
36
|
-
* @param driver - A configured driver (e.g., from `postgres()` or `sqlite()`)
|
|
37
|
-
* @returns A promise that resolves to an OpenWorkflow instance
|
|
38
|
-
* @example
|
|
39
|
-
* ```ts
|
|
40
|
-
* import { openworkflow } from 'openworkflow';
|
|
41
|
-
* import { postgres } from 'openworkflow/postgres';
|
|
42
|
-
*
|
|
43
|
-
* // Simple usage
|
|
44
|
-
* const ow = await openworkflow(postgres(process.env.DATABASE_URL));
|
|
45
|
-
*
|
|
46
|
-
* // With SQLite
|
|
47
|
-
* import { sqlite } from 'openworkflow/sqlite';
|
|
48
|
-
* const ow = await openworkflow(sqlite(':memory:'));
|
|
49
|
-
*
|
|
50
|
-
* // Define and run workflows
|
|
51
|
-
* const myWorkflow = ow.defineWorkflow(
|
|
52
|
-
* { name: 'my-workflow' },
|
|
53
|
-
* async ({ input, step }) => {
|
|
54
|
-
* const result = await step.run({ name: 'do-work' }, async () => {
|
|
55
|
-
* return 'done';
|
|
56
|
-
* });
|
|
57
|
-
* return result;
|
|
58
|
-
* }
|
|
59
|
-
* );
|
|
60
|
-
*
|
|
61
|
-
* const handle = await myWorkflow.run({ data: 'test' });
|
|
62
|
-
* const result = await handle.result();
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
export declare function openworkflow(driver: Driver): Promise<OpenWorkflowWithDriver>;
|
|
66
|
-
/**
|
|
67
|
-
* Synchronous version of openworkflow for drivers that support sync creation.
|
|
68
|
-
* Note: Most drivers require async creation due to migrations.
|
|
69
|
-
* @param driver - A configured driver
|
|
70
|
-
* @returns An OpenWorkflow instance
|
|
71
|
-
* @throws {TypeError} If driver requires async setup
|
|
72
|
-
*/
|
|
73
|
-
export declare function openworkflowSync(driver: Driver): OpenWorkflowWithDriver;
|
|
74
|
-
//# sourceMappingURL=factory.d.ts.map
|
package/dist/factory.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAA4B,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,YAAY;IAC1D;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,sBAAsB,CAAC,CAgBjC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB,CAsBvE"}
|
package/dist/factory.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { OpenWorkflow } from "./client.js";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a new OpenWorkflow instance from a driver.
|
|
4
|
-
*
|
|
5
|
-
* This is the Drizzle-style factory function that provides a clean API for
|
|
6
|
-
* creating OpenWorkflow instances with different database backends.
|
|
7
|
-
* @param driver - A configured driver (e.g., from `postgres()` or `sqlite()`)
|
|
8
|
-
* @returns A promise that resolves to an OpenWorkflow instance
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { openworkflow } from 'openworkflow';
|
|
12
|
-
* import { postgres } from 'openworkflow/postgres';
|
|
13
|
-
*
|
|
14
|
-
* // Simple usage
|
|
15
|
-
* const ow = await openworkflow(postgres(process.env.DATABASE_URL));
|
|
16
|
-
*
|
|
17
|
-
* // With SQLite
|
|
18
|
-
* import { sqlite } from 'openworkflow/sqlite';
|
|
19
|
-
* const ow = await openworkflow(sqlite(':memory:'));
|
|
20
|
-
*
|
|
21
|
-
* // Define and run workflows
|
|
22
|
-
* const myWorkflow = ow.defineWorkflow(
|
|
23
|
-
* { name: 'my-workflow' },
|
|
24
|
-
* async ({ input, step }) => {
|
|
25
|
-
* const result = await step.run({ name: 'do-work' }, async () => {
|
|
26
|
-
* return 'done';
|
|
27
|
-
* });
|
|
28
|
-
* return result;
|
|
29
|
-
* }
|
|
30
|
-
* );
|
|
31
|
-
*
|
|
32
|
-
* const handle = await myWorkflow.run({ data: 'test' });
|
|
33
|
-
* const result = await handle.result();
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export async function openworkflow(driver) {
|
|
37
|
-
// Create the backend from the driver
|
|
38
|
-
const backend = await driver.createBackend();
|
|
39
|
-
// Create the OpenWorkflow instance
|
|
40
|
-
const options = {
|
|
41
|
-
backend,
|
|
42
|
-
};
|
|
43
|
-
const ow = new OpenWorkflow(options);
|
|
44
|
-
// Return an extended instance with driver metadata
|
|
45
|
-
return Object.assign(ow, {
|
|
46
|
-
$driver: driver,
|
|
47
|
-
$backend: backend,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Synchronous version of openworkflow for drivers that support sync creation.
|
|
52
|
-
* Note: Most drivers require async creation due to migrations.
|
|
53
|
-
* @param driver - A configured driver
|
|
54
|
-
* @returns An OpenWorkflow instance
|
|
55
|
-
* @throws {TypeError} If driver requires async setup
|
|
56
|
-
*/
|
|
57
|
-
export function openworkflowSync(driver) {
|
|
58
|
-
// Try to create the backend synchronously
|
|
59
|
-
const backendOrPromise = driver.createBackend();
|
|
60
|
-
if (backendOrPromise instanceof Promise) {
|
|
61
|
-
throw new TypeError(`Driver '${driver.dialect}' requires async setup. Use 'await openworkflow()' instead of 'openworkflowSync()'.`);
|
|
62
|
-
}
|
|
63
|
-
const backend = backendOrPromise;
|
|
64
|
-
const options = {
|
|
65
|
-
backend,
|
|
66
|
-
};
|
|
67
|
-
const ow = new OpenWorkflow(options);
|
|
68
|
-
return Object.assign(ow, {
|
|
69
|
-
$driver: driver,
|
|
70
|
-
$backend: backend,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Backend, CancelWorkflowRunParams, ClaimWorkflowRunParams, CompleteStepAttemptParams, CompleteWorkflowRunParams, CreateStepAttemptParams, CreateWorkflowRunParams, ExtendWorkflowRunLeaseParams, FailStepAttemptParams, FailWorkflowRunParams, GetStepAttemptParams, GetWorkflowRunParams, ListStepAttemptsParams, ListWorkflowRunsParams, PaginatedResponse, SleepWorkflowRunParams } from "../backend.js";
|
|
2
|
-
import { StepAttempt } from "../core/step.js";
|
|
3
|
-
import { WorkflowRun } from "../core/workflow.js";
|
|
4
|
-
import type { DatabaseSync } from "node:sqlite";
|
|
5
|
-
interface BackendSqliteOptions {
|
|
6
|
-
namespaceId?: string;
|
|
7
|
-
runMigrations?: boolean;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Manages a connection to a SQLite database for workflow operations.
|
|
11
|
-
*/
|
|
12
|
-
export declare class BackendSqlite implements Backend {
|
|
13
|
-
private db;
|
|
14
|
-
private namespaceId;
|
|
15
|
-
private constructor();
|
|
16
|
-
/**
|
|
17
|
-
* Create and initialize a new BackendSqlite instance. This will
|
|
18
|
-
* automatically run migrations on startup unless `runMigrations` is set to
|
|
19
|
-
* false.
|
|
20
|
-
* @param path - Database path
|
|
21
|
-
* @param options - Backend options
|
|
22
|
-
* @returns A connected backend instance
|
|
23
|
-
*/
|
|
24
|
-
static connect(path: string, options?: BackendSqliteOptions): BackendSqlite;
|
|
25
|
-
/**
|
|
26
|
-
* Create and initialize a new BackendSqlite instance from an existing
|
|
27
|
-
* SQLite database connection. This will automatically run migrations on
|
|
28
|
-
* startup unless `runMigrations` is set to false.
|
|
29
|
-
* @param db - SQLite database connection
|
|
30
|
-
* @param options - Backend options
|
|
31
|
-
* @returns A connected backend instance
|
|
32
|
-
*/
|
|
33
|
-
static fromClient(db: DatabaseSync, options?: BackendSqliteOptions): BackendSqlite;
|
|
34
|
-
stop(): Promise<void>;
|
|
35
|
-
createWorkflowRun(params: CreateWorkflowRunParams): Promise<WorkflowRun>;
|
|
36
|
-
getWorkflowRun(params: GetWorkflowRunParams): Promise<WorkflowRun | null>;
|
|
37
|
-
claimWorkflowRun(params: ClaimWorkflowRunParams): Promise<WorkflowRun | null>;
|
|
38
|
-
extendWorkflowRunLease(params: ExtendWorkflowRunLeaseParams): Promise<WorkflowRun>;
|
|
39
|
-
sleepWorkflowRun(params: SleepWorkflowRunParams): Promise<WorkflowRun>;
|
|
40
|
-
completeWorkflowRun(params: CompleteWorkflowRunParams): Promise<WorkflowRun>;
|
|
41
|
-
failWorkflowRun(params: FailWorkflowRunParams): Promise<WorkflowRun>;
|
|
42
|
-
cancelWorkflowRun(params: CancelWorkflowRunParams): Promise<WorkflowRun>;
|
|
43
|
-
listWorkflowRuns(params: ListWorkflowRunsParams): Promise<PaginatedResponse<WorkflowRun>>;
|
|
44
|
-
listStepAttempts(params: ListStepAttemptsParams): Promise<PaginatedResponse<StepAttempt>>;
|
|
45
|
-
private processPaginationResults;
|
|
46
|
-
createStepAttempt(params: CreateStepAttemptParams): Promise<StepAttempt>;
|
|
47
|
-
getStepAttempt(params: GetStepAttemptParams): Promise<StepAttempt | null>;
|
|
48
|
-
completeStepAttempt(params: CompleteStepAttemptParams): Promise<StepAttempt>;
|
|
49
|
-
failStepAttempt(params: FailStepAttemptParams): Promise<StepAttempt>;
|
|
50
|
-
}
|
|
51
|
-
export {};
|
|
52
|
-
//# sourceMappingURL=backend.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../node-sqlite/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EACP,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,u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