@barnum/barnum 0.3.0 → 0.4.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/artifacts/linux-arm64/barnum +0 -0
- package/artifacts/linux-x64/barnum +0 -0
- package/artifacts/macos-arm64/barnum +0 -0
- package/artifacts/macos-x64/barnum +0 -0
- package/artifacts/win-x64/barnum.exe +0 -0
- package/dist/all.d.ts +41 -10
- package/dist/all.d.ts.map +1 -0
- package/dist/all.js +1 -1
- package/dist/ast.d.ts +199 -98
- package/dist/ast.d.ts.map +1 -0
- package/dist/ast.js +271 -233
- package/dist/bind.d.ts +9 -12
- package/dist/bind.d.ts.map +1 -0
- package/dist/bind.js +14 -51
- package/dist/builtins/array.d.ts +36 -0
- package/dist/builtins/array.d.ts.map +1 -0
- package/dist/builtins/array.js +93 -0
- package/dist/builtins/index.d.ts +6 -0
- package/dist/builtins/index.d.ts.map +1 -0
- package/dist/builtins/index.js +5 -0
- package/dist/builtins/scalar.d.ts +12 -0
- package/dist/builtins/scalar.d.ts.map +1 -0
- package/dist/builtins/scalar.js +41 -0
- package/dist/builtins/struct.d.ts +25 -0
- package/dist/builtins/struct.d.ts.map +1 -0
- package/dist/builtins/struct.js +67 -0
- package/dist/builtins/tagged-union.d.ts +54 -0
- package/dist/builtins/tagged-union.d.ts.map +1 -0
- package/dist/builtins/tagged-union.js +81 -0
- package/dist/builtins/with-resource.d.ts +23 -0
- package/dist/builtins/with-resource.d.ts.map +1 -0
- package/dist/builtins/with-resource.js +35 -0
- package/dist/chain.d.ts +1 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +3 -3
- package/dist/effect-id.d.ts +1 -0
- package/dist/effect-id.d.ts.map +1 -0
- package/dist/handler.d.ts +7 -6
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +5 -21
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -2
- package/dist/iterator.d.ts +32 -0
- package/dist/iterator.d.ts.map +1 -0
- package/dist/iterator.js +123 -0
- package/dist/option.d.ts +74 -0
- package/dist/option.d.ts.map +1 -0
- package/dist/option.js +141 -0
- package/dist/pipe.d.ts +11 -10
- package/dist/pipe.d.ts.map +1 -0
- package/dist/pipe.js +5 -4
- package/dist/race.d.ts +5 -4
- package/dist/race.d.ts.map +1 -0
- package/dist/race.js +17 -42
- package/dist/recursive.d.ts +9 -3
- package/dist/recursive.d.ts.map +1 -0
- package/dist/recursive.js +18 -13
- package/dist/result.d.ts +50 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +117 -0
- package/dist/run.d.ts +9 -2
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +37 -20
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +7 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schemas.d.ts +5 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +13 -0
- package/dist/try-catch.d.ts +2 -1
- package/dist/try-catch.d.ts.map +1 -0
- package/dist/try-catch.js +10 -9
- package/dist/values.d.ts +6 -0
- package/dist/values.d.ts.map +1 -0
- package/dist/values.js +12 -0
- package/dist/worker.d.ts +5 -1
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +15 -3
- package/package.json +8 -6
- package/src/all.ts +118 -74
- package/src/ast.ts +773 -350
- package/src/bind.ts +32 -62
- package/src/builtins/array.ts +121 -0
- package/src/builtins/index.ts +17 -0
- package/src/builtins/scalar.ts +49 -0
- package/src/builtins/struct.ts +111 -0
- package/src/builtins/tagged-union.ts +142 -0
- package/src/builtins/with-resource.ts +69 -0
- package/src/chain.ts +4 -4
- package/src/handler.ts +12 -28
- package/src/index.ts +24 -17
- package/src/iterator.ts +243 -0
- package/src/option.ts +199 -0
- package/src/pipe.ts +123 -78
- package/src/race.ts +41 -51
- package/src/recursive.ts +44 -27
- package/src/result.ts +168 -0
- package/src/run.ts +53 -25
- package/src/runtime.ts +16 -0
- package/src/schemas.ts +21 -0
- package/src/try-catch.ts +14 -10
- package/src/values.ts +21 -0
- package/src/worker.ts +17 -2
- package/dist/builtins.d.ts +0 -257
- package/dist/builtins.js +0 -600
- package/src/builtins.ts +0 -804
package/dist/worker.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Worker script: invoked as `tsx worker.ts <module> <export>`.
|
|
4
3
|
*
|
|
@@ -6,9 +5,17 @@
|
|
|
6
5
|
* Rust → stdin: JSON `{ "value": <any> }`
|
|
7
6
|
* stdout → Rust: JSON result (handler return value)
|
|
8
7
|
*
|
|
8
|
+
* stdout is reserved for the protocol. All console output is redirected to
|
|
9
|
+
* stderr so that handler code can freely use console.log for debugging.
|
|
10
|
+
*
|
|
9
11
|
* If the handler throws or the module/export can't be resolved, the
|
|
10
12
|
* process exits non-zero. Rust interprets that as a fatal workflow error.
|
|
11
13
|
*/
|
|
14
|
+
// Redirect all console output to stderr — stdout is the protocol channel.
|
|
15
|
+
// This must happen before any handler code is imported or executed.
|
|
16
|
+
import { Console } from "node:console";
|
|
17
|
+
const stderrConsole = new Console({ stdout: process.stderr });
|
|
18
|
+
globalThis.console = stderrConsole;
|
|
12
19
|
// Suppress EPIPE — when the Rust binary exits (e.g., a race was resolved),
|
|
13
20
|
// orphan workers get broken pipe on stdout. This is expected, not an error.
|
|
14
21
|
process.stdout.on("error", (error) => {
|
|
@@ -37,8 +44,13 @@ async function main() {
|
|
|
37
44
|
process.exit(1);
|
|
38
45
|
}
|
|
39
46
|
const result = await handler.__definition.handle({ value: input.value });
|
|
40
|
-
// Write result to stdout
|
|
41
|
-
|
|
47
|
+
// Write result to stdout, then exit. Explicit exit is required because
|
|
48
|
+
// importing the handler module may leave open handles (timers, servers,
|
|
49
|
+
// etc.) that keep the Node event loop alive indefinitely.
|
|
50
|
+
const json = JSON.stringify(result) ?? "null";
|
|
51
|
+
process.stdout.write(json, () => {
|
|
52
|
+
process.exit(0);
|
|
53
|
+
});
|
|
42
54
|
}
|
|
43
55
|
main().catch((error) => {
|
|
44
56
|
process.stderr.write(`worker: ${error}\n`);
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barnum/barnum",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Barnum workflow engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
"
|
|
9
|
+
"./pipeline": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./
|
|
14
|
-
|
|
13
|
+
"./runtime": {
|
|
14
|
+
"types": "./dist/runtime.d.ts",
|
|
15
|
+
"default": "./dist/runtime.js"
|
|
16
|
+
},
|
|
15
17
|
"./package.json": "./package.json"
|
|
16
18
|
},
|
|
17
19
|
"bin": {
|
|
@@ -48,10 +50,10 @@
|
|
|
48
50
|
"oxlint": "^1.57.0",
|
|
49
51
|
"prettier": "^3.8.1",
|
|
50
52
|
"tsx": "^4.21.0",
|
|
51
|
-
"typescript": "^
|
|
53
|
+
"typescript": "^6.0.3",
|
|
52
54
|
"vitest": "^3.0.0"
|
|
53
55
|
},
|
|
54
|
-
"
|
|
56
|
+
"peerDependencies": {
|
|
55
57
|
"zod": "^4.3.6"
|
|
56
58
|
}
|
|
57
59
|
}
|
package/src/all.ts
CHANGED
|
@@ -4,83 +4,127 @@ import {
|
|
|
4
4
|
type TypedAction,
|
|
5
5
|
typedAction,
|
|
6
6
|
} from "./ast.js";
|
|
7
|
-
import { constant } from "./builtins.js";
|
|
7
|
+
import { constant } from "./builtins/index.js";
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
10
|
export function all(): TypedAction<any, []>;
|
|
11
|
-
export function all<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
11
|
+
export function all<TInput, TOut1>(
|
|
12
|
+
a1: Pipeable<TInput, TOut1>,
|
|
13
|
+
): TypedAction<TInput, [TOut1]>;
|
|
14
|
+
export function all<TInput, TOut1, TOut2>(
|
|
15
|
+
a1: Pipeable<TInput, TOut1>,
|
|
16
|
+
a2: Pipeable<TInput, TOut2>,
|
|
17
|
+
): TypedAction<TInput, [TOut1, TOut2]>;
|
|
18
|
+
export function all<TInput, TOut1, TOut2, TOut3>(
|
|
19
|
+
a1: Pipeable<TInput, TOut1>,
|
|
20
|
+
a2: Pipeable<TInput, TOut2>,
|
|
21
|
+
a3: Pipeable<TInput, TOut3>,
|
|
22
|
+
): TypedAction<TInput, [TOut1, TOut2, TOut3]>;
|
|
23
|
+
export function all<TInput, TOut1, TOut2, TOut3, TOut4>(
|
|
24
|
+
a1: Pipeable<TInput, TOut1>,
|
|
25
|
+
a2: Pipeable<TInput, TOut2>,
|
|
26
|
+
a3: Pipeable<TInput, TOut3>,
|
|
27
|
+
a4: Pipeable<TInput, TOut4>,
|
|
28
|
+
): TypedAction<TInput, [TOut1, TOut2, TOut3, TOut4]>;
|
|
29
|
+
export function all<TInput, TOut1, TOut2, TOut3, TOut4, TOut5>(
|
|
30
|
+
a1: Pipeable<TInput, TOut1>,
|
|
31
|
+
a2: Pipeable<TInput, TOut2>,
|
|
32
|
+
a3: Pipeable<TInput, TOut3>,
|
|
33
|
+
a4: Pipeable<TInput, TOut4>,
|
|
34
|
+
a5: Pipeable<TInput, TOut5>,
|
|
35
|
+
): TypedAction<TInput, [TOut1, TOut2, TOut3, TOut4, TOut5]>;
|
|
36
|
+
export function all<TInput, TOut1, TOut2, TOut3, TOut4, TOut5, TOut6>(
|
|
37
|
+
a1: Pipeable<TInput, TOut1>,
|
|
38
|
+
a2: Pipeable<TInput, TOut2>,
|
|
39
|
+
a3: Pipeable<TInput, TOut3>,
|
|
40
|
+
a4: Pipeable<TInput, TOut4>,
|
|
41
|
+
a5: Pipeable<TInput, TOut5>,
|
|
42
|
+
a6: Pipeable<TInput, TOut6>,
|
|
43
|
+
): TypedAction<TInput, [TOut1, TOut2, TOut3, TOut4, TOut5, TOut6]>;
|
|
44
|
+
export function all<TInput, TOut1, TOut2, TOut3, TOut4, TOut5, TOut6, TOut7>(
|
|
45
|
+
a1: Pipeable<TInput, TOut1>,
|
|
46
|
+
a2: Pipeable<TInput, TOut2>,
|
|
47
|
+
a3: Pipeable<TInput, TOut3>,
|
|
48
|
+
a4: Pipeable<TInput, TOut4>,
|
|
49
|
+
a5: Pipeable<TInput, TOut5>,
|
|
50
|
+
a6: Pipeable<TInput, TOut6>,
|
|
51
|
+
a7: Pipeable<TInput, TOut7>,
|
|
52
|
+
): TypedAction<TInput, [TOut1, TOut2, TOut3, TOut4, TOut5, TOut6, TOut7]>;
|
|
53
|
+
export function all<
|
|
54
|
+
TInput,
|
|
55
|
+
TOut1,
|
|
56
|
+
TOut2,
|
|
57
|
+
TOut3,
|
|
58
|
+
TOut4,
|
|
59
|
+
TOut5,
|
|
60
|
+
TOut6,
|
|
61
|
+
TOut7,
|
|
62
|
+
TOut8,
|
|
63
|
+
>(
|
|
64
|
+
a1: Pipeable<TInput, TOut1>,
|
|
65
|
+
a2: Pipeable<TInput, TOut2>,
|
|
66
|
+
a3: Pipeable<TInput, TOut3>,
|
|
67
|
+
a4: Pipeable<TInput, TOut4>,
|
|
68
|
+
a5: Pipeable<TInput, TOut5>,
|
|
69
|
+
a6: Pipeable<TInput, TOut6>,
|
|
70
|
+
a7: Pipeable<TInput, TOut7>,
|
|
71
|
+
a8: Pipeable<TInput, TOut8>,
|
|
72
|
+
): TypedAction<
|
|
73
|
+
TInput,
|
|
74
|
+
[TOut1, TOut2, TOut3, TOut4, TOut5, TOut6, TOut7, TOut8]
|
|
75
|
+
>;
|
|
76
|
+
export function all<
|
|
77
|
+
TInput,
|
|
78
|
+
TOut1,
|
|
79
|
+
TOut2,
|
|
80
|
+
TOut3,
|
|
81
|
+
TOut4,
|
|
82
|
+
TOut5,
|
|
83
|
+
TOut6,
|
|
84
|
+
TOut7,
|
|
85
|
+
TOut8,
|
|
86
|
+
TOut9,
|
|
87
|
+
>(
|
|
88
|
+
a1: Pipeable<TInput, TOut1>,
|
|
89
|
+
a2: Pipeable<TInput, TOut2>,
|
|
90
|
+
a3: Pipeable<TInput, TOut3>,
|
|
91
|
+
a4: Pipeable<TInput, TOut4>,
|
|
92
|
+
a5: Pipeable<TInput, TOut5>,
|
|
93
|
+
a6: Pipeable<TInput, TOut6>,
|
|
94
|
+
a7: Pipeable<TInput, TOut7>,
|
|
95
|
+
a8: Pipeable<TInput, TOut8>,
|
|
96
|
+
a9: Pipeable<TInput, TOut9>,
|
|
97
|
+
): TypedAction<
|
|
98
|
+
TInput,
|
|
99
|
+
[TOut1, TOut2, TOut3, TOut4, TOut5, TOut6, TOut7, TOut8, TOut9]
|
|
100
|
+
>;
|
|
101
|
+
export function all<
|
|
102
|
+
TInput,
|
|
103
|
+
TOut1,
|
|
104
|
+
TOut2,
|
|
105
|
+
TOut3,
|
|
106
|
+
TOut4,
|
|
107
|
+
TOut5,
|
|
108
|
+
TOut6,
|
|
109
|
+
TOut7,
|
|
110
|
+
TOut8,
|
|
111
|
+
TOut9,
|
|
112
|
+
TOut10,
|
|
113
|
+
>(
|
|
114
|
+
a1: Pipeable<TInput, TOut1>,
|
|
115
|
+
a2: Pipeable<TInput, TOut2>,
|
|
116
|
+
a3: Pipeable<TInput, TOut3>,
|
|
117
|
+
a4: Pipeable<TInput, TOut4>,
|
|
118
|
+
a5: Pipeable<TInput, TOut5>,
|
|
119
|
+
a6: Pipeable<TInput, TOut6>,
|
|
120
|
+
a7: Pipeable<TInput, TOut7>,
|
|
121
|
+
a8: Pipeable<TInput, TOut8>,
|
|
122
|
+
a9: Pipeable<TInput, TOut9>,
|
|
123
|
+
a10: Pipeable<TInput, TOut10>,
|
|
124
|
+
): TypedAction<
|
|
125
|
+
TInput,
|
|
126
|
+
[TOut1, TOut2, TOut3, TOut4, TOut5, TOut6, TOut7, TOut8, TOut9, TOut10]
|
|
127
|
+
>;
|
|
84
128
|
export function all(...actions: Action[]): Action {
|
|
85
129
|
if (actions.length === 0) {
|
|
86
130
|
return constant([]);
|