flowcraft 1.0.0 → 2.0.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.
Files changed (201) hide show
  1. package/README.md +37 -134
  2. package/dist/analysis.d.ts +43 -0
  3. package/dist/analysis.js +3 -0
  4. package/dist/chunk-55J6XMHW.js +3 -0
  5. package/dist/{chunk-7XUN3OQT.js.map → chunk-55J6XMHW.js.map} +1 -1
  6. package/dist/chunk-6DNEDIIT.js +123 -0
  7. package/dist/chunk-6DNEDIIT.js.map +1 -0
  8. package/dist/chunk-734J4PTM.js +100 -0
  9. package/dist/chunk-734J4PTM.js.map +1 -0
  10. package/dist/chunk-DSZSR7UE.js +40 -0
  11. package/dist/chunk-DSZSR7UE.js.map +1 -0
  12. package/dist/chunk-GTZC6PQI.js +22 -0
  13. package/dist/chunk-GTZC6PQI.js.map +1 -0
  14. package/dist/chunk-HMR2GEGE.js +3 -0
  15. package/dist/{chunk-F2RSES6P.js.map → chunk-HMR2GEGE.js.map} +1 -1
  16. package/dist/chunk-J3RNCPED.js +27 -0
  17. package/dist/chunk-J3RNCPED.js.map +1 -0
  18. package/dist/chunk-M23P46ZL.js +105 -0
  19. package/dist/chunk-M23P46ZL.js.map +1 -0
  20. package/dist/chunk-MICPMOTW.js +49 -0
  21. package/dist/chunk-MICPMOTW.js.map +1 -0
  22. package/dist/chunk-NPAJNLXQ.js +106 -0
  23. package/dist/chunk-NPAJNLXQ.js.map +1 -0
  24. package/dist/chunk-RAZXOMZC.js +64 -0
  25. package/dist/chunk-RAZXOMZC.js.map +1 -0
  26. package/dist/chunk-REH55ZXV.js +13 -0
  27. package/dist/chunk-REH55ZXV.js.map +1 -0
  28. package/dist/chunk-RW4FH7IL.js +135 -0
  29. package/dist/chunk-RW4FH7IL.js.map +1 -0
  30. package/dist/chunk-RYTIQZIB.js +303 -0
  31. package/dist/chunk-RYTIQZIB.js.map +1 -0
  32. package/dist/chunk-UYPIWXZG.js +62 -0
  33. package/dist/chunk-UYPIWXZG.js.map +1 -0
  34. package/dist/chunk-VFC342WL.js +29 -0
  35. package/dist/chunk-VFC342WL.js.map +1 -0
  36. package/dist/chunk-WXT3YEWU.js +28 -0
  37. package/dist/chunk-WXT3YEWU.js.map +1 -0
  38. package/dist/context.d.ts +23 -105
  39. package/dist/context.js +1 -1
  40. package/dist/errors.d.ts +15 -31
  41. package/dist/errors.js +1 -1
  42. package/dist/evaluator.d.ts +22 -0
  43. package/dist/evaluator.js +3 -0
  44. package/dist/evaluator.js.map +1 -0
  45. package/dist/flow.d.ts +54 -0
  46. package/dist/flow.js +4 -0
  47. package/dist/flow.js.map +1 -0
  48. package/dist/index.d.ts +14 -16
  49. package/dist/index.js +17 -25
  50. package/dist/linter.d.ts +24 -0
  51. package/dist/linter.js +4 -0
  52. package/dist/linter.js.map +1 -0
  53. package/dist/logger.d.ts +11 -36
  54. package/dist/logger.js +1 -1
  55. package/dist/node.d.ts +1 -0
  56. package/dist/node.js +3 -0
  57. package/dist/node.js.map +1 -0
  58. package/dist/runtime/adapter.d.ts +78 -0
  59. package/dist/runtime/adapter.js +15 -0
  60. package/dist/runtime/adapter.js.map +1 -0
  61. package/dist/runtime/executors.d.ts +26 -0
  62. package/dist/runtime/executors.js +4 -0
  63. package/dist/runtime/executors.js.map +1 -0
  64. package/dist/runtime/index.d.ts +7 -0
  65. package/dist/runtime/index.js +16 -0
  66. package/dist/runtime/runtime.d.ts +33 -0
  67. package/dist/runtime/runtime.js +14 -0
  68. package/dist/runtime/runtime.js.map +1 -0
  69. package/dist/runtime/state.d.ts +21 -0
  70. package/dist/runtime/state.js +4 -0
  71. package/dist/runtime/state.js.map +1 -0
  72. package/dist/runtime/traverser.d.ts +24 -0
  73. package/dist/runtime/traverser.js +5 -0
  74. package/dist/runtime/traverser.js.map +1 -0
  75. package/dist/runtime/types.d.ts +15 -0
  76. package/dist/runtime/types.js +3 -0
  77. package/dist/sanitizer.d.ts +10 -0
  78. package/dist/sanitizer.js +3 -0
  79. package/dist/{utils/sanitize.js.map → sanitizer.js.map} +1 -1
  80. package/dist/serializer.d.ts +15 -0
  81. package/dist/serializer.js +3 -0
  82. package/dist/serializer.js.map +1 -0
  83. package/dist/types-CZN_FcB6.d.ts +201 -0
  84. package/dist/types.d.ts +1 -3
  85. package/dist/types.js +1 -1
  86. package/package.json +9 -20
  87. package/LICENSE +0 -21
  88. package/dist/builder/graph/graph.d.ts +0 -57
  89. package/dist/builder/graph/graph.js +0 -21
  90. package/dist/builder/graph/graph.js.map +0 -1
  91. package/dist/builder/graph/index.d.ts +0 -8
  92. package/dist/builder/graph/index.js +0 -23
  93. package/dist/builder/graph/internal-nodes.d.ts +0 -59
  94. package/dist/builder/graph/internal-nodes.js +0 -20
  95. package/dist/builder/graph/internal-nodes.js.map +0 -1
  96. package/dist/builder/graph/runner.d.ts +0 -51
  97. package/dist/builder/graph/runner.js +0 -21
  98. package/dist/builder/graph/runner.js.map +0 -1
  99. package/dist/builder/graph/types.d.ts +0 -3
  100. package/dist/builder/graph/types.js +0 -3
  101. package/dist/builder/index.d.ts +0 -8
  102. package/dist/builder/index.js +0 -24
  103. package/dist/builder/index.js.map +0 -1
  104. package/dist/builder/patterns.d.ts +0 -136
  105. package/dist/builder/patterns.js +0 -19
  106. package/dist/builder/patterns.js.map +0 -1
  107. package/dist/chunk-3YMBNZ77.js +0 -441
  108. package/dist/chunk-3YMBNZ77.js.map +0 -1
  109. package/dist/chunk-64DNBF5W.js +0 -36
  110. package/dist/chunk-64DNBF5W.js.map +0 -1
  111. package/dist/chunk-6QCXIRLA.js +0 -18
  112. package/dist/chunk-6QCXIRLA.js.map +0 -1
  113. package/dist/chunk-7XUN3OQT.js +0 -3
  114. package/dist/chunk-AOHBHYF6.js +0 -7
  115. package/dist/chunk-AOHBHYF6.js.map +0 -1
  116. package/dist/chunk-BRFMFLR6.js +0 -85
  117. package/dist/chunk-BRFMFLR6.js.map +0 -1
  118. package/dist/chunk-ELEHMJPM.js +0 -13
  119. package/dist/chunk-ELEHMJPM.js.map +0 -1
  120. package/dist/chunk-F2RSES6P.js +0 -3
  121. package/dist/chunk-F6C6J7HK.js +0 -3
  122. package/dist/chunk-F6C6J7HK.js.map +0 -1
  123. package/dist/chunk-GMKJ34T2.js +0 -3
  124. package/dist/chunk-GMKJ34T2.js.map +0 -1
  125. package/dist/chunk-HEO3XL4Z.js +0 -328
  126. package/dist/chunk-HEO3XL4Z.js.map +0 -1
  127. package/dist/chunk-IIKTTIW5.js +0 -56
  128. package/dist/chunk-IIKTTIW5.js.map +0 -1
  129. package/dist/chunk-KOBEU2EM.js +0 -3
  130. package/dist/chunk-KOBEU2EM.js.map +0 -1
  131. package/dist/chunk-L5PK5VL2.js +0 -178
  132. package/dist/chunk-L5PK5VL2.js.map +0 -1
  133. package/dist/chunk-P3RPDZHO.js +0 -36
  134. package/dist/chunk-P3RPDZHO.js.map +0 -1
  135. package/dist/chunk-PNWOW52F.js +0 -19
  136. package/dist/chunk-PNWOW52F.js.map +0 -1
  137. package/dist/chunk-R27FIYR5.js +0 -62
  138. package/dist/chunk-R27FIYR5.js.map +0 -1
  139. package/dist/chunk-S4WFNGQG.js +0 -17
  140. package/dist/chunk-S4WFNGQG.js.map +0 -1
  141. package/dist/chunk-TS3M7MWA.js +0 -3
  142. package/dist/chunk-TS3M7MWA.js.map +0 -1
  143. package/dist/chunk-UY4PNPBX.js +0 -156
  144. package/dist/chunk-UY4PNPBX.js.map +0 -1
  145. package/dist/chunk-VMH2LRM6.js +0 -114
  146. package/dist/chunk-VMH2LRM6.js.map +0 -1
  147. package/dist/chunk-VZDHIOCH.js +0 -76
  148. package/dist/chunk-VZDHIOCH.js.map +0 -1
  149. package/dist/chunk-WGVHM7DU.js +0 -66
  150. package/dist/chunk-WGVHM7DU.js.map +0 -1
  151. package/dist/chunk-WR5PDOPP.js +0 -91
  152. package/dist/chunk-WR5PDOPP.js.map +0 -1
  153. package/dist/chunk-YR433ZDA.js +0 -20
  154. package/dist/chunk-YR433ZDA.js.map +0 -1
  155. package/dist/executors/in-memory.d.ts +0 -39
  156. package/dist/executors/in-memory.js +0 -6
  157. package/dist/executors/in-memory.js.map +0 -1
  158. package/dist/executors/types.d.ts +0 -3
  159. package/dist/executors/types.js +0 -3
  160. package/dist/executors/types.js.map +0 -1
  161. package/dist/functions.d.ts +0 -88
  162. package/dist/functions.js +0 -21
  163. package/dist/functions.js.map +0 -1
  164. package/dist/types-U76Ukj96.d.ts +0 -609
  165. package/dist/utils/analysis.d.ts +0 -75
  166. package/dist/utils/analysis.js +0 -3
  167. package/dist/utils/index.d.ts +0 -8
  168. package/dist/utils/index.js +0 -10
  169. package/dist/utils/index.js.map +0 -1
  170. package/dist/utils/mermaid.d.ts +0 -46
  171. package/dist/utils/mermaid.js +0 -4
  172. package/dist/utils/mermaid.js.map +0 -1
  173. package/dist/utils/middleware.d.ts +0 -11
  174. package/dist/utils/middleware.js +0 -3
  175. package/dist/utils/middleware.js.map +0 -1
  176. package/dist/utils/sanitize.d.ts +0 -19
  177. package/dist/utils/sanitize.js +0 -3
  178. package/dist/utils/sleep.d.ts +0 -9
  179. package/dist/utils/sleep.js +0 -4
  180. package/dist/utils/sleep.js.map +0 -1
  181. package/dist/workflow/AbstractNode.d.ts +0 -3
  182. package/dist/workflow/AbstractNode.js +0 -4
  183. package/dist/workflow/AbstractNode.js.map +0 -1
  184. package/dist/workflow/Flow.d.ts +0 -3
  185. package/dist/workflow/Flow.js +0 -16
  186. package/dist/workflow/Flow.js.map +0 -1
  187. package/dist/workflow/Node.d.ts +0 -3
  188. package/dist/workflow/Node.js +0 -15
  189. package/dist/workflow/Node.js.map +0 -1
  190. package/dist/workflow/index.d.ts +0 -4
  191. package/dist/workflow/index.js +0 -18
  192. package/dist/workflow/index.js.map +0 -1
  193. package/dist/workflow/node-patterns.d.ts +0 -55
  194. package/dist/workflow/node-patterns.js +0 -16
  195. package/dist/workflow/node-patterns.js.map +0 -1
  196. package/dist/workflow/registry.d.ts +0 -17
  197. package/dist/workflow/registry.js +0 -3
  198. package/dist/workflow/registry.js.map +0 -1
  199. /package/dist/{utils/analysis.js.map → analysis.js.map} +0 -0
  200. /package/dist/{builder/graph → runtime}/index.js.map +0 -0
  201. /package/dist/{builder/graph → runtime}/types.js.map +0 -0
@@ -1,59 +0,0 @@
1
- import { Context } from '../../context.js';
2
- import { N as Node, b as NodeArgs, A as AbstractNode } from '../../types-U76Ukj96.js';
3
- import { ParallelFlow } from '../patterns.js';
4
- import '../../logger.js';
5
- import '../../functions.js';
6
-
7
- /**
8
- * An internal node used by the GraphBuilder to handle the `inputs` mapping
9
- * of an inlined sub-workflow. It copies data from the parent context scope
10
- * to the sub-workflow's context scope.
11
- * @internal
12
- */
13
- declare class InputMappingNode<TContext extends Context = Context> extends Node<void, void, any, any, TContext> {
14
- private mappings;
15
- constructor(options: {
16
- data: Record<string, string>;
17
- });
18
- prep({ ctx, logger }: NodeArgs<void, void, any, TContext>): Promise<void>;
19
- }
20
- /**
21
- * An internal node used by the GraphBuilder to handle the `outputs` mapping
22
- * of an inlined sub-workflow. It copies data from the sub-workflow's
23
- * context scope back to the parent's context scope.
24
- * @internal
25
- */
26
- declare class OutputMappingNode<TContext extends Context = Context> extends Node<void, void, any, any, TContext> {
27
- private mappings;
28
- constructor(options: {
29
- data: Record<string, string>;
30
- });
31
- prep({ ctx, logger }: NodeArgs<void, void, any, TContext>): Promise<void>;
32
- }
33
- /**
34
- * A private class used by the builder to represent the sub-workflow container itself.
35
- * It's a structural node that preserves the original node ID in the flattened graph.
36
- * @internal
37
- */
38
- declare class SubWorkflowContainerNode<TContext extends Context = Context> extends Node<void, void, any, any, TContext> {
39
- constructor();
40
- exec(): Promise<void>;
41
- }
42
- /** A private class used by the builder to represent parallel execution blocks. */
43
- declare class ParallelBranchContainer<TContext extends Context = Context> extends ParallelFlow<TContext> {
44
- /** A tag to reliably identify this node type in the visualizer. */
45
- readonly isParallelContainer = true;
46
- nodesToRun: AbstractNode[];
47
- constructor();
48
- }
49
- /**
50
- * A private class used by the builder to unify conditional branches
51
- * before they connect to a common successor. This ensures the successor
52
- * only has one predecessor, preventing false fan-in detection.
53
- * @internal
54
- */
55
- declare class ConditionalJoinNode<TContext extends Context = Context> extends Node<void, void, any, any, TContext> {
56
- constructor();
57
- }
58
-
59
- export { ConditionalJoinNode, InputMappingNode, OutputMappingNode, ParallelBranchContainer, SubWorkflowContainerNode };
@@ -1,20 +0,0 @@
1
- export { ConditionalJoinNode, InputMappingNode, OutputMappingNode, ParallelBranchContainer, SubWorkflowContainerNode } from '../../chunk-WGVHM7DU.js';
2
- import '../../chunk-L5PK5VL2.js';
3
- import '../../chunk-F6C6J7HK.js';
4
- import '../../chunk-UY4PNPBX.js';
5
- import '../../chunk-ELEHMJPM.js';
6
- import '../../chunk-HEO3XL4Z.js';
7
- import '../../chunk-7XUN3OQT.js';
8
- import '../../chunk-WR5PDOPP.js';
9
- import '../../chunk-VMH2LRM6.js';
10
- import '../../chunk-YR433ZDA.js';
11
- import '../../chunk-6QCXIRLA.js';
12
- import '../../chunk-BRFMFLR6.js';
13
- import '../../chunk-PNWOW52F.js';
14
- import '../../chunk-VZDHIOCH.js';
15
- import '../../chunk-S4WFNGQG.js';
16
- import '../../chunk-64DNBF5W.js';
17
- import '../../chunk-IIKTTIW5.js';
18
- import '../../chunk-AOHBHYF6.js';
19
- //# sourceMappingURL=internal-nodes.js.map
20
- //# sourceMappingURL=internal-nodes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"internal-nodes.js"}
@@ -1,51 +0,0 @@
1
- import { Context } from '../../context.js';
2
- import { I as IExecutor, F as Flow, A as AbstractNode, W as WorkflowBlueprint, n as NodeRegistry, i as TypedNodeRegistry, R as RunOptions } from '../../types-U76Ukj96.js';
3
- import '../../logger.js';
4
-
5
- /**
6
- * An execution engine that hydrates a runnable `Flow` from a serializable
7
- * `WorkflowBlueprint` and runs it. This is the recommended executor for
8
- * distributed systems where the workflow is built once and executed many times by workers.
9
- */
10
- declare class BlueprintExecutor implements IExecutor {
11
- private blueprint;
12
- private nodeOptionsContext;
13
- readonly flow: Flow;
14
- readonly nodeMap: Map<string, AbstractNode>;
15
- private readonly registry;
16
- constructor(blueprint: WorkflowBlueprint, registry: NodeRegistry | TypedNodeRegistry<any, any>, nodeOptionsContext?: Record<string, any>);
17
- private _populateContainers;
18
- /**
19
- * Retrieves a hydrated node instance from the blueprint by its ID.
20
- * This is useful for workers that need to execute a specific node from the graph.
21
- * @param nodeId The ID of the node to retrieve.
22
- * @returns The `AbstractNode` instance if found, otherwise `undefined`.
23
- */
24
- getNode(nodeId: string): AbstractNode | undefined;
25
- /**
26
- * Instantiates all node objects from the blueprint's definition.
27
- * @private
28
- */
29
- private _createNodeMap;
30
- /**
31
- * Wires the hydrated node instances together based on the blueprint's edges.
32
- * @private
33
- */
34
- private _wireGraph;
35
- /**
36
- * Executes the flow defined by the blueprint.
37
- * @param flow The flow to execute.
38
- * @param context The shared context for the workflow.
39
- * @param options Runtime options, including a logger, abort controller, or initial params.
40
- * @returns A promise that resolves with the final action of the workflow.
41
- */
42
- run<T>(flow: Flow<any, T>, context: Context, options?: RunOptions): Promise<T>;
43
- /**
44
- * Determines the next node to execute based on the action returned by the current node.
45
- * For distributed systems, this logic would live on the orchestrator.
46
- * @internal
47
- */
48
- getNextNode(curr: AbstractNode, action: any): AbstractNode | undefined;
49
- }
50
-
51
- export { BlueprintExecutor };
@@ -1,21 +0,0 @@
1
- export { BlueprintExecutor } from '../../chunk-3YMBNZ77.js';
2
- import '../../chunk-WGVHM7DU.js';
3
- import '../../chunk-L5PK5VL2.js';
4
- import '../../chunk-F6C6J7HK.js';
5
- import '../../chunk-UY4PNPBX.js';
6
- import '../../chunk-ELEHMJPM.js';
7
- import '../../chunk-HEO3XL4Z.js';
8
- import '../../chunk-7XUN3OQT.js';
9
- import '../../chunk-WR5PDOPP.js';
10
- import '../../chunk-VMH2LRM6.js';
11
- import '../../chunk-YR433ZDA.js';
12
- import '../../chunk-6QCXIRLA.js';
13
- import '../../chunk-BRFMFLR6.js';
14
- import '../../chunk-PNWOW52F.js';
15
- import '../../chunk-VZDHIOCH.js';
16
- import '../../chunk-S4WFNGQG.js';
17
- import '../../chunk-64DNBF5W.js';
18
- import '../../chunk-IIKTTIW5.js';
19
- import '../../chunk-AOHBHYF6.js';
20
- //# sourceMappingURL=runner.js.map
21
- //# sourceMappingURL=runner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"runner.js"}
@@ -1,3 +0,0 @@
1
- export { B as BlueprintBuildResult, k as BuildResult, o as GraphBuilderOptions, G as GraphEdge, l as GraphNode, g as NodeConstructorOptions, n as NodeRegistry, f as NodeTypeMap, O as OriginalPredecessorIdMap, j as PredecessorIdMap, S as SubWorkflowResolver, T as TypedGraphNode, i as TypedNodeRegistry, h as TypedWorkflowGraph, W as WorkflowBlueprint, m as WorkflowGraph } from '../../types-U76Ukj96.js';
2
- import '../../context.js';
3
- import '../../logger.js';
@@ -1,3 +0,0 @@
1
- import '../../chunk-KOBEU2EM.js';
2
- //# sourceMappingURL=types.js.map
3
- //# sourceMappingURL=types.js.map
@@ -1,8 +0,0 @@
1
- export { GraphBuilder, createNodeRegistry } from './graph/graph.js';
2
- export { ConditionalJoinNode, InputMappingNode, OutputMappingNode, ParallelBranchContainer, SubWorkflowContainerNode } from './graph/internal-nodes.js';
3
- export { BlueprintExecutor } from './graph/runner.js';
4
- export { B as BlueprintBuildResult, k as BuildResult, o as GraphBuilderOptions, G as GraphEdge, l as GraphNode, g as NodeConstructorOptions, n as NodeRegistry, f as NodeTypeMap, O as OriginalPredecessorIdMap, j as PredecessorIdMap, S as SubWorkflowResolver, T as TypedGraphNode, i as TypedNodeRegistry, h as TypedWorkflowGraph, W as WorkflowBlueprint, m as WorkflowGraph } from '../types-U76Ukj96.js';
5
- export { BatchFlow, ParallelBatchFlow, ParallelFlow, SequenceFlow, filterCollection, mapCollection, reduceCollection } from './patterns.js';
6
- import '../logger.js';
7
- import '../context.js';
8
- import '../functions.js';
@@ -1,24 +0,0 @@
1
- import '../chunk-F2RSES6P.js';
2
- import '../chunk-GMKJ34T2.js';
3
- import '../chunk-KOBEU2EM.js';
4
- export { BlueprintExecutor, GraphBuilder, createNodeRegistry } from '../chunk-3YMBNZ77.js';
5
- export { ConditionalJoinNode, InputMappingNode, OutputMappingNode, ParallelBranchContainer, SubWorkflowContainerNode } from '../chunk-WGVHM7DU.js';
6
- export { BatchFlow, ParallelBatchFlow, ParallelFlow, SequenceFlow, filterCollection, mapCollection, reduceCollection } from '../chunk-L5PK5VL2.js';
7
- import '../chunk-F6C6J7HK.js';
8
- import '../chunk-UY4PNPBX.js';
9
- import '../chunk-ELEHMJPM.js';
10
- import '../chunk-HEO3XL4Z.js';
11
- import '../chunk-7XUN3OQT.js';
12
- import '../chunk-WR5PDOPP.js';
13
- import '../chunk-VMH2LRM6.js';
14
- import '../chunk-YR433ZDA.js';
15
- import '../chunk-6QCXIRLA.js';
16
- import '../chunk-BRFMFLR6.js';
17
- import '../chunk-PNWOW52F.js';
18
- import '../chunk-VZDHIOCH.js';
19
- import '../chunk-S4WFNGQG.js';
20
- import '../chunk-64DNBF5W.js';
21
- import '../chunk-IIKTTIW5.js';
22
- import '../chunk-AOHBHYF6.js';
23
- //# sourceMappingURL=index.js.map
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -1,136 +0,0 @@
1
- import { Context } from '../context.js';
2
- import { NodeFunction } from '../functions.js';
3
- import { F as Flow, P as Params, A as AbstractNode, b as NodeArgs } from '../types-U76Ukj96.js';
4
- import '../logger.js';
5
-
6
- /**
7
- * A `Flow` that creates a linear workflow from a sequence of nodes,
8
- * automatically chaining them in order.
9
- */
10
- declare class SequenceFlow<PrepRes = any, ExecRes = any, TParams extends Params = Params, TContext extends Context = Context> extends Flow<PrepRes, ExecRes, TParams, TContext> {
11
- /**
12
- * @param nodes A sequence of `Node` or `Flow` instances to be executed in order.
13
- */
14
- constructor(...nodes: AbstractNode<any, any, TContext>[]);
15
- }
16
- /**
17
- * A `Flow` that executes a collection of different nodes concurrently.
18
- * This is the core of the "fan-out, fan-in" pattern for structural parallelism.
19
- * After all parallel branches complete, the flow can proceed to a single successor.
20
- */
21
- declare class ParallelFlow<TContext extends Context = Context> extends Flow<void, void, Params, TContext> {
22
- protected nodesToRun: AbstractNode<any, any, TContext>[];
23
- /** A tag to reliably identify this node type in the visualizer. */
24
- readonly isParallelContainer = true;
25
- /**
26
- * @param nodesToRun The array of nodes to execute concurrently.
27
- */
28
- constructor(nodesToRun?: AbstractNode<any, any, TContext>[]);
29
- /**
30
- * Orchestrates the parallel execution of all nodes.
31
- * @internal
32
- */
33
- exec({ ctx, params, signal, logger, executor, visitedInParallel }: NodeArgs<void, void, Params, TContext>): Promise<void>;
34
- }
35
- /**
36
- * An abstract `Flow` that processes a collection of items sequentially, one by one.
37
- * Subclasses must implement the `prep` method to provide the items and the
38
- * `nodeToRun` property to define the processing logic for each item.
39
- */
40
- declare abstract class BatchFlow<T = any, TContext extends Context = Context> extends Flow<Iterable<T>, null, Params, TContext> {
41
- /**
42
- * The `Node` instance that will be executed for each item in the batch.
43
- * This must be implemented by any subclass.
44
- */
45
- protected abstract nodeToRun: AbstractNode<any, any, TContext>;
46
- constructor();
47
- /**
48
- * (Abstract) Prepares the list of items to be processed.
49
- * This method is called once before the batch processing begins.
50
- * @param _args The arguments for the node, including `ctx` and `params`.
51
- * @returns An array or iterable of parameter objects, one for each item.
52
- * The `nodeToRun` will be executed once for each of these objects.
53
- */
54
- prep(_args: NodeArgs<void, void, Params, TContext>): Promise<Iterable<any>>;
55
- /**
56
- * Orchestrates the sequential execution of `nodeToRun` for each item.
57
- * @internal
58
- */
59
- exec(args: NodeArgs<void, void, Params, TContext>): Promise<null>;
60
- }
61
- /**
62
- * An abstract `Flow` that processes a collection of items concurrently.
63
- * Subclasses must implement the `prep` method to provide the items and the
64
- * `nodeToRun` property to define the processing logic for each item.
65
- * This provides a significant performance boost for I/O-bound tasks.
66
- */
67
- declare abstract class ParallelBatchFlow<T = any, TContext extends Context = Context> extends Flow<Iterable<T>, PromiseSettledResult<any>[], Params, TContext> {
68
- /**
69
- * The `Node` instance that will be executed concurrently for each item in the batch.
70
- * This must be implemented by any subclass.
71
- */
72
- protected abstract nodeToRun: AbstractNode<any, any, TContext>;
73
- constructor();
74
- /**
75
- * (Abstract) Prepares the list of items to be processed.
76
- * This method is called once before the batch processing begins.
77
- * @param _args The arguments for the node, including `ctx` and `params`.
78
- * @returns An array or iterable of parameter objects, one for each item.
79
- * The `nodeToRun` will be executed concurrently for each of these objects.
80
- */
81
- prep(_args: NodeArgs<void, void, Params, TContext>): Promise<Iterable<any>>;
82
- /**
83
- * Orchestrates the parallel execution of `nodeToRun` for each item.
84
- * @internal
85
- */
86
- exec(args: NodeArgs<any, void, Params, TContext>): Promise<PromiseSettledResult<any>[]>;
87
- }
88
- /**
89
- * Creates a flow that applies a mapping function to each item in a collection in parallel
90
- * and returns a new array containing the results.
91
- *
92
- * @example
93
- * const numbers = [1, 2, 3];
94
- * const double = (n: number) => n * 2;
95
- * const processingFlow = mapCollection(numbers, double);
96
- * // When run, processingFlow's result will be [2, 4, 6]
97
- *
98
- * @param items The initial array of items of type `T`.
99
- * @param fn An async or sync function that transforms an item from type `T` to type `U`.
100
- * @returns A `Flow` instance that, when run, will output an array of type `U[]`.
101
- */
102
- declare function mapCollection<T, U, TContext extends Context = Context>(items: T[], fn: NodeFunction<T, U>): Flow<void, U[], Params, TContext>;
103
- /**
104
- * Creates a flow that filters a collection based on a predicate function,
105
- * returning a new array containing only the items that pass the predicate.
106
- * The predicate is applied to all items concurrently.
107
- *
108
- * @example
109
- * const users = [{ id: 1, admin: true }, { id: 2, admin: false }];
110
- * const isAdmin = async (user: { admin: boolean }) => user.admin;
111
- * const adminFilterFlow = filterCollection(users, isAdmin);
112
- * // When run, the result will be [{ id: 1, admin: true }]
113
- *
114
- * @param items The initial array of items of type `T`.
115
- * @param predicate An async or sync function that returns `true` or `false` for an item.
116
- * @returns A `Flow` instance that, when run, will output a filtered array of type `T[]`.
117
- */
118
- declare function filterCollection<T, TContext extends Context = Context>(items: T[], predicate: (item: T) => boolean | Promise<boolean>): Flow<void, T[], Params, TContext>;
119
- /**
120
- * Creates a flow that reduces a collection to a single value by executing a
121
- * reducer function sequentially for each item, similar to `Array.prototype.reduce()`.
122
- *
123
- * @example
124
- * const numbers = [1, 2, 3, 4];
125
- * const sumReducer = (acc: number, val: number) => acc + val;
126
- * const sumFlow = reduceCollection(numbers, sumReducer, 0);
127
- * // When run, the result will be 10.
128
- *
129
- * @param items The array of items to be reduced.
130
- * @param reducer An async or sync function that processes the accumulator and the current item.
131
- * @param initialValue The initial value for the accumulator.
132
- * @returns A `Flow` instance that, when run, will output the final accumulated value of type `U`.
133
- */
134
- declare function reduceCollection<T, U, TContext extends Context = Context>(items: T[], reducer: (accumulator: U, item: T) => U | Promise<U>, initialValue: U): Flow<void, U, Params, TContext>;
135
-
136
- export { BatchFlow, ParallelBatchFlow, ParallelFlow, SequenceFlow, filterCollection, mapCollection, reduceCollection };
@@ -1,19 +0,0 @@
1
- export { BatchFlow, ParallelBatchFlow, ParallelFlow, SequenceFlow, filterCollection, mapCollection, reduceCollection } from '../chunk-L5PK5VL2.js';
2
- import '../chunk-F6C6J7HK.js';
3
- import '../chunk-UY4PNPBX.js';
4
- import '../chunk-ELEHMJPM.js';
5
- import '../chunk-HEO3XL4Z.js';
6
- import '../chunk-7XUN3OQT.js';
7
- import '../chunk-WR5PDOPP.js';
8
- import '../chunk-VMH2LRM6.js';
9
- import '../chunk-YR433ZDA.js';
10
- import '../chunk-6QCXIRLA.js';
11
- import '../chunk-BRFMFLR6.js';
12
- import '../chunk-PNWOW52F.js';
13
- import '../chunk-VZDHIOCH.js';
14
- import '../chunk-S4WFNGQG.js';
15
- import '../chunk-64DNBF5W.js';
16
- import '../chunk-IIKTTIW5.js';
17
- import '../chunk-AOHBHYF6.js';
18
- //# sourceMappingURL=patterns.js.map
19
- //# sourceMappingURL=patterns.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"patterns.js"}