@sonamu-kit/tasks 0.2.0 → 0.3.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/.oxlintrc.json +3 -0
- package/AGENTS.md +21 -0
- package/dist/backend.d.ts +126 -107
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +4 -1
- package/dist/backend.js.map +1 -1
- package/dist/client.d.ts +145 -132
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +219 -213
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +15 -8
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +22 -17
- package/dist/config.js.map +1 -1
- package/dist/core/duration.d.ts +5 -4
- package/dist/core/duration.d.ts.map +1 -1
- package/dist/core/duration.js +54 -59
- package/dist/core/duration.js.map +1 -1
- package/dist/core/error.d.ts +10 -7
- package/dist/core/error.d.ts.map +1 -1
- package/dist/core/error.js +21 -21
- package/dist/core/error.js.map +1 -1
- package/dist/core/json.d.ts +8 -3
- package/dist/core/json.d.ts.map +1 -1
- package/dist/core/result.d.ts +10 -14
- package/dist/core/result.d.ts.map +1 -1
- package/dist/core/result.js +21 -16
- package/dist/core/result.js.map +1 -1
- package/dist/core/retry.d.ts +37 -31
- package/dist/core/retry.d.ts.map +1 -1
- package/dist/core/retry.js +44 -51
- package/dist/core/retry.js.map +1 -1
- package/dist/core/schema.d.ts +57 -53
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/step.d.ts +28 -78
- package/dist/core/step.d.ts.map +1 -1
- package/dist/core/step.js +53 -63
- package/dist/core/step.js.map +1 -1
- package/dist/core/workflow.d.ts +33 -61
- package/dist/core/workflow.d.ts.map +1 -1
- package/dist/core/workflow.js +31 -41
- package/dist/core/workflow.js.map +1 -1
- package/dist/database/backend.d.ts +53 -46
- package/dist/database/backend.d.ts.map +1 -1
- package/dist/database/backend.js +544 -577
- package/dist/database/backend.js.map +1 -1
- package/dist/database/base.js +48 -25
- package/dist/database/base.js.map +1 -1
- package/dist/database/migrations/20251212000000_0_init.d.ts +10 -0
- package/dist/database/migrations/20251212000000_0_init.d.ts.map +1 -0
- package/dist/database/migrations/20251212000000_0_init.js +8 -4
- package/dist/database/migrations/20251212000000_0_init.js.map +1 -1
- package/dist/database/migrations/20251212000000_1_tables.d.ts +10 -0
- package/dist/database/migrations/20251212000000_1_tables.d.ts.map +1 -0
- package/dist/database/migrations/20251212000000_1_tables.js +81 -83
- package/dist/database/migrations/20251212000000_1_tables.js.map +1 -1
- package/dist/database/migrations/20251212000000_2_fk.d.ts +10 -0
- package/dist/database/migrations/20251212000000_2_fk.d.ts.map +1 -0
- package/dist/database/migrations/20251212000000_2_fk.js +20 -43
- package/dist/database/migrations/20251212000000_2_fk.js.map +1 -1
- package/dist/database/migrations/20251212000000_3_indexes.d.ts +10 -0
- package/dist/database/migrations/20251212000000_3_indexes.d.ts.map +1 -0
- package/dist/database/migrations/20251212000000_3_indexes.js +88 -102
- package/dist/database/migrations/20251212000000_3_indexes.js.map +1 -1
- package/dist/database/pubsub.d.ts +7 -16
- package/dist/database/pubsub.d.ts.map +1 -1
- package/dist/database/pubsub.js +75 -73
- package/dist/database/pubsub.js.map +1 -1
- package/dist/execution.d.ts +20 -59
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +175 -188
- package/dist/execution.js.map +1 -1
- package/dist/index.d.ts +5 -8
- package/dist/index.js +5 -5
- package/dist/internal.d.ts +12 -13
- package/dist/internal.js +4 -4
- package/dist/registry.d.ts +33 -27
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +58 -49
- package/dist/registry.js.map +1 -1
- package/dist/worker.d.ts +57 -50
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +194 -199
- package/dist/worker.js.map +1 -1
- package/dist/workflow.d.ts +26 -30
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +20 -15
- package/dist/workflow.js.map +1 -1
- package/nodemon.json +1 -1
- package/package.json +17 -19
- package/src/backend.ts +25 -9
- package/src/chaos.test.ts +3 -1
- package/src/client.test.ts +2 -0
- package/src/client.ts +30 -8
- package/src/config.test.ts +1 -0
- package/src/config.ts +3 -2
- package/src/core/duration.test.ts +2 -1
- package/src/core/duration.ts +1 -1
- package/src/core/error.test.ts +1 -0
- package/src/core/error.ts +1 -1
- package/src/core/result.test.ts +1 -0
- package/src/core/retry.test.ts +3 -2
- package/src/core/retry.ts +1 -1
- package/src/core/schema.ts +2 -2
- package/src/core/step.test.ts +2 -1
- package/src/core/step.ts +4 -3
- package/src/core/workflow.test.ts +2 -1
- package/src/core/workflow.ts +4 -3
- package/src/database/backend.test.ts +1 -0
- package/src/database/backend.testsuite.ts +44 -40
- package/src/database/backend.ts +207 -25
- package/src/database/base.test.ts +41 -0
- package/src/database/base.ts +51 -2
- package/src/database/migrations/20251212000000_0_init.ts +2 -1
- package/src/database/migrations/20251212000000_1_tables.ts +2 -1
- package/src/database/migrations/20251212000000_2_fk.ts +2 -1
- package/src/database/migrations/20251212000000_3_indexes.ts +2 -1
- package/src/database/pubsub.test.ts +6 -3
- package/src/database/pubsub.ts +55 -33
- package/src/execution.test.ts +2 -0
- package/src/execution.ts +49 -10
- package/src/internal.ts +15 -15
- package/src/practices/01-remote-workflow.ts +1 -0
- package/src/registry.test.ts +1 -0
- package/src/registry.ts +1 -1
- package/src/testing/connection.ts +3 -1
- package/src/worker.test.ts +2 -0
- package/src/worker.ts +30 -9
- package/src/workflow.test.ts +1 -0
- package/src/workflow.ts +3 -3
- package/templates/openworkflow.config.ts +2 -1
- package/tsdown.config.ts +31 -0
- package/.swcrc +0 -17
- package/dist/chaos.test.d.ts +0 -2
- package/dist/chaos.test.d.ts.map +0 -1
- package/dist/chaos.test.js +0 -92
- package/dist/chaos.test.js.map +0 -1
- package/dist/client.test.d.ts +0 -2
- package/dist/client.test.d.ts.map +0 -1
- package/dist/client.test.js +0 -340
- package/dist/client.test.js.map +0 -1
- package/dist/config.test.d.ts +0 -2
- package/dist/config.test.d.ts.map +0 -1
- package/dist/config.test.js +0 -24
- package/dist/config.test.js.map +0 -1
- 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 -265
- package/dist/core/duration.test.js.map +0 -1
- 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 -63
- package/dist/core/error.test.js.map +0 -1
- package/dist/core/json.js +0 -3
- package/dist/core/json.js.map +0 -1
- 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 -19
- package/dist/core/result.test.js.map +0 -1
- package/dist/core/retry.test.d.ts +0 -2
- package/dist/core/retry.test.d.ts.map +0 -1
- package/dist/core/retry.test.js +0 -198
- package/dist/core/retry.test.js.map +0 -1
- package/dist/core/schema.js +0 -4
- package/dist/core/schema.js.map +0 -1
- 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 -356
- package/dist/core/step.test.js.map +0 -1
- 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 -172
- package/dist/core/workflow.test.js.map +0 -1
- package/dist/database/backend.test.d.ts +0 -2
- package/dist/database/backend.test.d.ts.map +0 -1
- package/dist/database/backend.test.js +0 -19
- package/dist/database/backend.test.js.map +0 -1
- package/dist/database/backend.testsuite.d.ts +0 -20
- package/dist/database/backend.testsuite.d.ts.map +0 -1
- package/dist/database/backend.testsuite.js +0 -1280
- package/dist/database/backend.testsuite.js.map +0 -1
- package/dist/database/base.d.ts +0 -12
- package/dist/database/base.d.ts.map +0 -1
- package/dist/database/pubsub.test.d.ts +0 -2
- package/dist/database/pubsub.test.d.ts.map +0 -1
- package/dist/database/pubsub.test.js +0 -86
- package/dist/database/pubsub.test.js.map +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 -662
- package/dist/execution.test.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal.d.ts.map +0 -1
- package/dist/internal.js.map +0 -1
- package/dist/practices/01-remote-workflow.d.ts +0 -2
- package/dist/practices/01-remote-workflow.d.ts.map +0 -1
- package/dist/practices/01-remote-workflow.js +0 -70
- package/dist/practices/01-remote-workflow.js.map +0 -1
- package/dist/registry.test.d.ts +0 -2
- package/dist/registry.test.d.ts.map +0 -1
- package/dist/registry.test.js +0 -95
- package/dist/registry.test.js.map +0 -1
- package/dist/testing/connection.d.ts +0 -7
- package/dist/testing/connection.d.ts.map +0 -1
- package/dist/testing/connection.js +0 -39
- package/dist/testing/connection.js.map +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 -1164
- package/dist/worker.test.js.map +0 -1
- package/dist/workflow.test.d.ts +0 -2
- package/dist/workflow.test.d.ts.map +0 -1
- package/dist/workflow.test.js +0 -73
- package/dist/workflow.test.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonamu-kit/tasks",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.3.0",
|
|
5
4
|
"description": "Sonamu Task - Simple & Distributed Task Queue",
|
|
5
|
+
"author": "CartaNova <dev@cartanova.ai>",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/cartanova-ai/sonamu.git"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
6
11
|
"main": "./dist/index.js",
|
|
7
12
|
"exports": {
|
|
8
13
|
".": {
|
|
@@ -16,12 +21,8 @@
|
|
|
16
21
|
"development": "./src/internal.ts"
|
|
17
22
|
}
|
|
18
23
|
},
|
|
19
|
-
"author": "CartaNova <dev@cartanova.ai>",
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "https://github.com/cartanova-ai/sonamu.git"
|
|
23
|
-
},
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"c12": "^3.3.2",
|
|
25
26
|
"date-fns": "^4.1.0",
|
|
26
27
|
"date-fns-tz": "^3.2.0",
|
|
27
28
|
"inflection": "^3.0.2",
|
|
@@ -30,33 +31,30 @@
|
|
|
30
31
|
"pg": "^8.16.3",
|
|
31
32
|
"rou3": "^0.7.10",
|
|
32
33
|
"uuid": "^13.0.0",
|
|
33
|
-
"zod": "^4.
|
|
34
|
-
"c12": "^3.3.2"
|
|
34
|
+
"zod": "^4.3.6"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/inflection": "^2.0.0",
|
|
38
|
-
"@biomejs/biome": "^2.3.10",
|
|
39
|
-
"@swc/cli": "^0.7.8",
|
|
40
|
-
"@swc/core": "^1.13.5",
|
|
41
38
|
"@types/node": "25.0.7",
|
|
42
39
|
"nodemon": "^3.1.10",
|
|
40
|
+
"tsdown": "^0.12.5",
|
|
43
41
|
"tsx": "^4.20.6",
|
|
44
|
-
"typescript": "^
|
|
45
|
-
"vitest": "^4.
|
|
42
|
+
"typescript": "^6.0.0",
|
|
43
|
+
"vitest": "^4.1.2"
|
|
46
44
|
},
|
|
47
45
|
"peerDependencies": {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
46
|
+
"@logtape/logtape": "2.0.0",
|
|
47
|
+
"knex": "^3.1.0"
|
|
50
48
|
},
|
|
51
49
|
"optionalDependencies": {
|
|
52
50
|
"pg-native": "^3.5.2"
|
|
53
51
|
},
|
|
54
52
|
"scripts": {
|
|
55
53
|
"dev": "nodemon exec",
|
|
56
|
-
"build": "
|
|
57
|
-
"check": "tsc --noEmit &&
|
|
54
|
+
"build": "tsdown",
|
|
55
|
+
"check": "tsc --noEmit && oxlint src && oxfmt --check src",
|
|
58
56
|
"check:type": "tsc --noEmit",
|
|
59
|
-
"check:format": "
|
|
57
|
+
"check:format": "oxfmt src",
|
|
60
58
|
"pretest": "tsx scripts/migrate.ts",
|
|
61
59
|
"test": "vitest run",
|
|
62
60
|
"test:watch": "vitest watch --standalone",
|
package/src/backend.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
5
|
-
import type
|
|
6
|
-
import type
|
|
1
|
+
import { type SerializedError } from "./core/error";
|
|
2
|
+
import { type JsonValue } from "./core/json";
|
|
3
|
+
import { type SerializableRetryPolicy } from "./core/retry";
|
|
4
|
+
import { type StepAttempt, type StepAttemptContext, type StepKind } from "./core/step";
|
|
5
|
+
import { type WorkflowRun } from "./core/workflow";
|
|
6
|
+
import { type OnSubscribed } from "./database/pubsub";
|
|
7
7
|
|
|
8
8
|
export const DEFAULT_NAMESPACE_ID = "default";
|
|
9
9
|
|
|
@@ -27,6 +27,8 @@ export interface Backend {
|
|
|
27
27
|
completeWorkflowRun(params: Readonly<CompleteWorkflowRunParams>): Promise<WorkflowRun>;
|
|
28
28
|
failWorkflowRun(params: Readonly<FailWorkflowRunParams>): Promise<WorkflowRun>;
|
|
29
29
|
cancelWorkflowRun(params: Readonly<CancelWorkflowRunParams>): Promise<WorkflowRun>;
|
|
30
|
+
pauseWorkflowRun(params: Readonly<PauseWorkflowRunParams>): Promise<WorkflowRun>;
|
|
31
|
+
resumeWorkflowRun(params: Readonly<ResumeWorkflowRunParams>): Promise<WorkflowRun>;
|
|
30
32
|
|
|
31
33
|
// Step Attempts
|
|
32
34
|
createStepAttempt(params: Readonly<CreateStepAttemptParams>): Promise<StepAttempt>;
|
|
@@ -34,8 +36,8 @@ export interface Backend {
|
|
|
34
36
|
listStepAttempts(
|
|
35
37
|
params: Readonly<ListStepAttemptsParams>,
|
|
36
38
|
): Promise<PaginatedResponse<StepAttempt>>;
|
|
37
|
-
completeStepAttempt(params: Readonly<CompleteStepAttemptParams>): Promise<StepAttempt>;
|
|
38
|
-
failStepAttempt(params: Readonly<FailStepAttemptParams>): Promise<StepAttempt>;
|
|
39
|
+
completeStepAttempt(params: Readonly<CompleteStepAttemptParams>): Promise<StepAttempt | null>;
|
|
40
|
+
failStepAttempt(params: Readonly<FailStepAttemptParams>): Promise<StepAttempt | null>;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export interface CreateWorkflowRunParams {
|
|
@@ -54,7 +56,12 @@ export interface GetWorkflowRunParams {
|
|
|
54
56
|
workflowRunId: string;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
export
|
|
59
|
+
export interface ListWorkflowRunsParams extends PaginationOptions {
|
|
60
|
+
status?: string[];
|
|
61
|
+
workflowName?: string;
|
|
62
|
+
createdAfter?: Date;
|
|
63
|
+
createdBefore?: Date;
|
|
64
|
+
}
|
|
58
65
|
|
|
59
66
|
export interface ClaimWorkflowRunParams {
|
|
60
67
|
workerId: string;
|
|
@@ -91,6 +98,14 @@ export interface CancelWorkflowRunParams {
|
|
|
91
98
|
workflowRunId: string;
|
|
92
99
|
}
|
|
93
100
|
|
|
101
|
+
export interface PauseWorkflowRunParams {
|
|
102
|
+
workflowRunId: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface ResumeWorkflowRunParams {
|
|
106
|
+
workflowRunId: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
94
109
|
export interface CreateStepAttemptParams {
|
|
95
110
|
workflowRunId: string;
|
|
96
111
|
workerId: string;
|
|
@@ -126,6 +141,7 @@ export interface PaginationOptions {
|
|
|
126
141
|
limit?: number;
|
|
127
142
|
after?: string;
|
|
128
143
|
before?: string;
|
|
144
|
+
order?: "asc" | "desc";
|
|
129
145
|
}
|
|
130
146
|
|
|
131
147
|
export interface PaginatedResponse<T> {
|
package/src/chaos.test.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { randomInt } from "node:crypto";
|
|
2
|
+
|
|
2
3
|
import { describe, expect, test } from "vitest";
|
|
4
|
+
|
|
3
5
|
import { OpenWorkflow } from "./client";
|
|
4
6
|
import { createBackend } from "./testing/connection";
|
|
5
|
-
import type
|
|
7
|
+
import { type Worker } from "./worker";
|
|
6
8
|
|
|
7
9
|
const TOTAL_STEPS = 50;
|
|
8
10
|
const WORKER_COUNT = 3;
|
package/src/client.test.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
+
|
|
2
3
|
import { afterEach, beforeEach, describe, expect, test } from "vitest";
|
|
3
4
|
import { z } from "zod";
|
|
5
|
+
|
|
4
6
|
import { BackendPostgres } from ".";
|
|
5
7
|
import { declareWorkflow, OpenWorkflow } from "./client";
|
|
6
8
|
import { KNEX_GLOBAL_CONFIG } from "./testing/connection";
|
package/src/client.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Backend } from "./backend";
|
|
2
2
|
import { serializeRetryPolicy } from "./core/retry";
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
3
|
+
import { type StandardSchemaV1 } from "./core/schema";
|
|
4
|
+
import { type SchemaInput, type SchemaOutput, type WorkflowRun } from "./core/workflow";
|
|
5
5
|
import { validateInput } from "./core/workflow";
|
|
6
|
-
import type
|
|
6
|
+
import { type WorkflowFunction } from "./execution";
|
|
7
7
|
import { WorkflowRegistry } from "./registry";
|
|
8
|
-
import { Worker
|
|
9
|
-
import {
|
|
8
|
+
import { Worker } from "./worker";
|
|
9
|
+
import { type WorkerOptions } from "./worker";
|
|
10
|
+
import { defineWorkflow, defineWorkflowSpec } from "./workflow";
|
|
11
|
+
import { type Workflow, type WorkflowSpec } from "./workflow";
|
|
10
12
|
|
|
11
13
|
const DEFAULT_RESULT_POLL_INTERVAL_MS = 1000; // 1s
|
|
12
14
|
const DEFAULT_RESULT_TIMEOUT_MS = 5 * 60 * 1000; // 5m
|
|
@@ -321,12 +323,32 @@ export class WorkflowRunHandle<Output> {
|
|
|
321
323
|
}
|
|
322
324
|
|
|
323
325
|
/**
|
|
324
|
-
* Cancels the workflow run. Only workflows in pending, running,
|
|
325
|
-
* status can be canceled.
|
|
326
|
+
* Cancels the workflow run. Only workflows in pending, running, sleeping,
|
|
327
|
+
* or paused status can be canceled.
|
|
326
328
|
*/
|
|
327
329
|
async cancel(): Promise<void> {
|
|
328
330
|
await this.backend.cancelWorkflowRun({
|
|
329
331
|
workflowRunId: this.workflowRun.id,
|
|
330
332
|
});
|
|
331
333
|
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Pauses the workflow run. Only workflows in pending, running, or sleeping
|
|
337
|
+
* status can be paused.
|
|
338
|
+
*/
|
|
339
|
+
async pause(): Promise<void> {
|
|
340
|
+
await this.backend.pauseWorkflowRun({
|
|
341
|
+
workflowRunId: this.workflowRun.id,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Resumes a paused workflow run. Sets the status back to pending so that
|
|
347
|
+
* a worker can reclaim it.
|
|
348
|
+
*/
|
|
349
|
+
async resume(): Promise<void> {
|
|
350
|
+
await this.backend.resumeWorkflowRun({
|
|
351
|
+
workflowRunId: this.workflowRun.id,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
332
354
|
}
|
package/src/config.test.ts
CHANGED
package/src/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { loadConfig as loadC12Config } from "c12";
|
|
2
|
-
|
|
3
|
-
import type
|
|
2
|
+
|
|
3
|
+
import { type Backend } from "./backend";
|
|
4
|
+
import { type WorkerOptions } from "./worker";
|
|
4
5
|
|
|
5
6
|
export interface OpenWorkflowConfig {
|
|
6
7
|
backend: Backend;
|
package/src/core/duration.ts
CHANGED
package/src/core/error.test.ts
CHANGED
package/src/core/error.ts
CHANGED
package/src/core/result.test.ts
CHANGED
package/src/core/retry.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
|
|
3
|
+
import { type SerializedError } from "./error";
|
|
4
|
+
import { type DynamicRetryPolicy, type StaticRetryPolicy } from "./retry";
|
|
4
5
|
import {
|
|
5
6
|
calculateRetryDelayMs,
|
|
6
7
|
DEFAULT_RETRY_POLICY,
|
package/src/core/retry.ts
CHANGED
package/src/core/schema.ts
CHANGED
|
@@ -68,7 +68,7 @@ export declare namespace StandardSchemaV1 {
|
|
|
68
68
|
Schema["~standard"]["types"]
|
|
69
69
|
>["output"];
|
|
70
70
|
|
|
71
|
-
//
|
|
72
|
-
//
|
|
71
|
+
// needed for granular visibility control of TS namespace
|
|
72
|
+
// oxlint-disable-next-line
|
|
73
73
|
export {};
|
|
74
74
|
}
|
package/src/core/step.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
|
+
|
|
2
3
|
import { ok } from "./result";
|
|
3
|
-
import type
|
|
4
|
+
import { type StepAttempt, type StepAttemptCache } from "./step";
|
|
4
5
|
import {
|
|
5
6
|
addToStepAttemptCache,
|
|
6
7
|
calculateSleepResumeAt,
|
package/src/core/step.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DurationString } from "./duration";
|
|
2
2
|
import { parseDuration } from "./duration";
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
3
|
+
import { type JsonValue } from "./json";
|
|
4
|
+
import { type Result } from "./result";
|
|
5
5
|
import { err, ok } from "./result";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -14,6 +14,7 @@ export type StepKind = "function" | "sleep";
|
|
|
14
14
|
*/
|
|
15
15
|
export type StepAttemptStatus =
|
|
16
16
|
| "running"
|
|
17
|
+
| "paused"
|
|
17
18
|
| "succeeded" // deprecated in favor of 'completed'
|
|
18
19
|
| "completed"
|
|
19
20
|
| "failed";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { type StandardSchemaV1 } from "./schema";
|
|
3
4
|
import { DEFAULT_WORKFLOW_RESULT_CONFIG, isTerminalStatus, validateInput } from "./workflow";
|
|
4
5
|
|
|
5
6
|
describe("validateInput", () => {
|
package/src/core/workflow.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
1
|
+
import { type SerializedError } from "./error";
|
|
2
|
+
import { type JsonValue } from "./json";
|
|
3
|
+
import { type StandardSchemaV1 } from "./schema";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Status of a workflow run through its lifecycle.
|
|
@@ -9,6 +9,7 @@ export type WorkflowRunStatus =
|
|
|
9
9
|
| "pending"
|
|
10
10
|
| "running"
|
|
11
11
|
| "sleeping"
|
|
12
|
+
| "paused"
|
|
12
13
|
| "succeeded" // deprecated in favor of 'completed'
|
|
13
14
|
| "completed"
|
|
14
15
|
| "failed"
|