@barnum/barnum 0.0.0-main-dc436849 → 0.0.0-main-baf9644f

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.
Binary file
@@ -1 +1 @@
1
- {"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/builtins/scalar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,WAAW,CAAC;AAM1D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAKxE;AAMD,wBAAgB,QAAQ,CAAC,MAAM,GAAG,GAAG,KAAK,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAKpE;AAMD,eAAO,MAAM,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,IAAI,CAGtC,CAAC;AAMH;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAK9D"}
1
+ {"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/builtins/scalar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,WAAW,CAAC;AAM1D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAQxE;AAMD,wBAAgB,QAAQ,CAAC,MAAM,GAAG,GAAG,KAAK,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAKpE;AAMD,eAAO,MAAM,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,IAAI,CAGtC,CAAC;AAMH;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAK9D"}
@@ -5,7 +5,10 @@ import { typedAction } from "../ast.js";
5
5
  export function constant(value) {
6
6
  return typedAction({
7
7
  kind: "Invoke",
8
- handler: { kind: "Builtin", builtin: { kind: "Constant", value } },
8
+ handler: {
9
+ kind: "Builtin",
10
+ builtin: { kind: "Constant", value: value ?? null },
11
+ },
9
12
  });
10
13
  }
11
14
  // ---------------------------------------------------------------------------
@@ -1 +1 @@
1
- {"version":3,"file":"with-resource.d.ts","sourceRoot":"","sources":["../../src/builtins/with-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAY,MAAM,WAAW,CAAC;AAWtE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,IAAI,EACJ,WAAW,GAAG,OAAO,EACrB,EACA,MAAM,EACN,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,QAAQ,CAAC,SAAS,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC;IACxC,OAAO,EAAE,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;CAC3C,GAAG,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CA4BzB"}
1
+ {"version":3,"file":"with-resource.d.ts","sourceRoot":"","sources":["../../src/builtins/with-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAY,MAAM,WAAW,CAAC;AAWtE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,IAAI,EACJ,WAAW,GAAG,OAAO,EACrB,EACA,MAAM,EACN,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,QAAQ,CAAC,SAAS,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC;IACxC,OAAO,EAAE,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;CAC3C,GAAG,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CA6BzB"}
@@ -24,12 +24,13 @@ import { getIndex } from "./array.js";
24
24
  * ```
25
25
  */
26
26
  export function withResource({ create, action, dispose, }) {
27
- // Step 1: all(create, identity) → [TResource, TIn] → merge → TResource & TIn
28
- const acquireAndMerge = chain(toAction(all(create, identity())), toAction(merge()));
29
- // Step 2: all(action, identity) → [TOut, TResource & TIn]
30
- const actionAndKeepMerged = all(toAction(action), toAction(identity()));
31
- // Step 3: all(getIndex(0).unwrap(), chain(getIndex(1).unwrap(), dispose)) → [TOut, unknown]
27
+ // Step 1: all(create, identity) → [TResource, TIn]
28
+ const acquireParallel = all(create, identity());
29
+ // Step 2: all(merge → action, getIndex(0) → keep resource) → [TOut, TResource]
30
+ // Run action on merged input, but keep raw TResource for dispose
31
+ const runActionKeepResource = all(chain(toAction(merge()), toAction(action)), toAction(getIndex(0).unwrap()));
32
+ // Step 3: all(getIndex(0) → TOut, getIndex(1) → dispose) → [TOut, TDisposeOut]
32
33
  const disposeAndKeepResult = all(toAction(getIndex(0).unwrap()), chain(toAction(getIndex(1).unwrap()), toAction(dispose)));
33
34
  // Step 4: getIndex(0).unwrap() → TOut
34
- return chain(toAction(chain(toAction(chain(toAction(acquireAndMerge), toAction(actionAndKeepMerged))), toAction(disposeAndKeepResult))), toAction(getIndex(0).unwrap()));
35
+ return chain(toAction(chain(toAction(chain(toAction(acquireParallel), toAction(runActionKeepResource))), toAction(disposeAndKeepResult))), toAction(getIndex(0).unwrap()));
35
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barnum/barnum",
3
- "version": "0.0.0-main-dc436849",
3
+ "version": "0.0.0-main-baf9644f",
4
4
  "description": "Barnum workflow engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -7,7 +7,10 @@ import { type TypedAction, typedAction } from "../ast.js";
7
7
  export function constant<TValue>(value: TValue): TypedAction<any, TValue> {
8
8
  return typedAction({
9
9
  kind: "Invoke",
10
- handler: { kind: "Builtin", builtin: { kind: "Constant", value } },
10
+ handler: {
11
+ kind: "Builtin",
12
+ builtin: { kind: "Constant", value: value ?? null },
13
+ },
11
14
  });
12
15
  }
13
16
 
@@ -39,16 +39,17 @@ export function withResource<
39
39
  action: Pipeable<TResource & TIn, TOut>;
40
40
  dispose: Pipeable<TResource, TDisposeOut>;
41
41
  }): TypedAction<TIn, TOut> {
42
- // Step 1: all(create, identity) → [TResource, TIn] → merge → TResource & TIn
43
- const acquireAndMerge = chain(
44
- toAction(all(create, identity())),
45
- toAction(merge()),
46
- );
42
+ // Step 1: all(create, identity) → [TResource, TIn]
43
+ const acquireParallel = all(create, identity());
47
44
 
48
- // Step 2: all(action, identity) → [TOut, TResource & TIn]
49
- const actionAndKeepMerged = all(toAction(action), toAction(identity()));
45
+ // Step 2: all(merge → action, getIndex(0) → keep resource) → [TOut, TResource]
46
+ // Run action on merged input, but keep raw TResource for dispose
47
+ const runActionKeepResource = all(
48
+ chain(toAction(merge()), toAction(action)),
49
+ toAction(getIndex(0).unwrap()),
50
+ );
50
51
 
51
- // Step 3: all(getIndex(0).unwrap(), chain(getIndex(1).unwrap(), dispose)) → [TOut, unknown]
52
+ // Step 3: all(getIndex(0) → TOut, getIndex(1) dispose) → [TOut, TDisposeOut]
52
53
  const disposeAndKeepResult = all(
53
54
  toAction(getIndex(0).unwrap()),
54
55
  chain(toAction(getIndex(1).unwrap()), toAction(dispose)),
@@ -59,7 +60,7 @@ export function withResource<
59
60
  toAction(
60
61
  chain(
61
62
  toAction(
62
- chain(toAction(acquireAndMerge), toAction(actionAndKeepMerged)),
63
+ chain(toAction(acquireParallel), toAction(runActionKeepResource)),
63
64
  ),
64
65
  toAction(disposeAndKeepResult),
65
66
  ),