@smthrs/plan 0.0.0-stage → 1.0.0-rc.12

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 (209) hide show
  1. package/CHANGELOG.md +185 -0
  2. package/LICENSE +21 -0
  3. package/README.md +230 -2
  4. package/THIRD_PARTY_NOTICES.md +48 -0
  5. package/dist/cjs/CachePolicy.d.ts +131 -0
  6. package/dist/cjs/CachePolicy.d.ts.map +1 -0
  7. package/dist/cjs/CachePolicy.js +50 -0
  8. package/dist/cjs/CachePolicy.js.map +7 -0
  9. package/dist/cjs/Effects.d.ts +258 -0
  10. package/dist/cjs/Effects.d.ts.map +1 -0
  11. package/dist/cjs/Effects.js +76 -0
  12. package/dist/cjs/Effects.js.map +7 -0
  13. package/dist/cjs/FileSet.d.ts +366 -0
  14. package/dist/cjs/FileSet.d.ts.map +1 -0
  15. package/dist/cjs/FileSet.js +196 -0
  16. package/dist/cjs/FileSet.js.map +7 -0
  17. package/dist/cjs/GraphBuildError.d.ts +120 -0
  18. package/dist/cjs/GraphBuildError.d.ts.map +1 -0
  19. package/dist/cjs/GraphBuildError.js +71 -0
  20. package/dist/cjs/GraphBuildError.js.map +7 -0
  21. package/dist/cjs/KeyMaterial.d.ts +107 -0
  22. package/dist/cjs/KeyMaterial.d.ts.map +1 -0
  23. package/dist/cjs/KeyMaterial.js +64 -0
  24. package/dist/cjs/KeyMaterial.js.map +7 -0
  25. package/dist/cjs/Node.d.ts +677 -0
  26. package/dist/cjs/Node.d.ts.map +1 -0
  27. package/dist/cjs/Node.js +229 -0
  28. package/dist/cjs/Node.js.map +7 -0
  29. package/dist/cjs/Placement.d.ts +117 -0
  30. package/dist/cjs/Placement.d.ts.map +1 -0
  31. package/dist/cjs/Placement.js +46 -0
  32. package/dist/cjs/Placement.js.map +7 -0
  33. package/dist/cjs/Plan.d.ts +489 -0
  34. package/dist/cjs/Plan.d.ts.map +1 -0
  35. package/dist/cjs/Plan.js +511 -0
  36. package/dist/cjs/Plan.js.map +7 -0
  37. package/dist/cjs/PlanDiff.d.ts +77 -0
  38. package/dist/cjs/PlanDiff.d.ts.map +1 -0
  39. package/dist/cjs/PlanDiff.js +149 -0
  40. package/dist/cjs/PlanDiff.js.map +7 -0
  41. package/dist/cjs/Planned.d.ts +121 -0
  42. package/dist/cjs/Planned.d.ts.map +1 -0
  43. package/dist/cjs/Planned.js +72 -0
  44. package/dist/cjs/Planned.js.map +7 -0
  45. package/dist/cjs/Repetition.d.ts +31 -0
  46. package/dist/cjs/Repetition.d.ts.map +1 -0
  47. package/dist/cjs/Repetition.js +36 -0
  48. package/dist/cjs/Repetition.js.map +7 -0
  49. package/dist/cjs/Scheduling.d.ts +89 -0
  50. package/dist/cjs/Scheduling.d.ts.map +1 -0
  51. package/dist/cjs/Scheduling.js +76 -0
  52. package/dist/cjs/Scheduling.js.map +7 -0
  53. package/dist/cjs/StepKey.d.ts +354 -0
  54. package/dist/cjs/StepKey.d.ts.map +1 -0
  55. package/dist/cjs/StepKey.js +313 -0
  56. package/dist/cjs/StepKey.js.map +7 -0
  57. package/dist/cjs/index.d.ts +91 -0
  58. package/dist/cjs/index.d.ts.map +1 -0
  59. package/dist/cjs/index.js +59 -0
  60. package/dist/cjs/index.js.map +7 -0
  61. package/dist/cjs/internal/ConflictAnnotation.d.ts +59 -0
  62. package/dist/cjs/internal/ConflictAnnotation.d.ts.map +1 -0
  63. package/dist/cjs/internal/ConflictAnnotation.js +247 -0
  64. package/dist/cjs/internal/ConflictAnnotation.js.map +7 -0
  65. package/dist/cjs/internal/EffectCandidates.d.ts +19 -0
  66. package/dist/cjs/internal/EffectCandidates.d.ts.map +1 -0
  67. package/dist/cjs/internal/EffectCandidates.js +92 -0
  68. package/dist/cjs/internal/EffectCandidates.js.map +7 -0
  69. package/dist/cjs/internal/JsonMirror.d.ts +34 -0
  70. package/dist/cjs/internal/JsonMirror.d.ts.map +1 -0
  71. package/dist/cjs/internal/JsonMirror.js +195 -0
  72. package/dist/cjs/internal/JsonMirror.js.map +7 -0
  73. package/dist/cjs/internal/SchemaIdentity.d.ts +140 -0
  74. package/dist/cjs/internal/SchemaIdentity.d.ts.map +1 -0
  75. package/dist/cjs/internal/SchemaIdentity.js +718 -0
  76. package/dist/cjs/internal/SchemaIdentity.js.map +7 -0
  77. package/dist/cjs/internal/effects.d.ts +245 -0
  78. package/dist/cjs/internal/effects.d.ts.map +1 -0
  79. package/dist/cjs/internal/effects.js +290 -0
  80. package/dist/cjs/internal/effects.js.map +7 -0
  81. package/dist/cjs/internal/node.d.ts +526 -0
  82. package/dist/cjs/internal/node.d.ts.map +1 -0
  83. package/dist/cjs/internal/node.js +313 -0
  84. package/dist/cjs/internal/node.js.map +7 -0
  85. package/dist/cjs/package.json +1 -0
  86. package/dist/cjs/test/PlanFixtures.d.ts +127 -0
  87. package/dist/cjs/test/PlanFixtures.d.ts.map +1 -0
  88. package/dist/cjs/test/PlanFixtures.js +59 -0
  89. package/dist/cjs/test/PlanFixtures.js.map +7 -0
  90. package/dist/esm/CachePolicy.d.ts +131 -0
  91. package/dist/esm/CachePolicy.d.ts.map +1 -0
  92. package/dist/esm/CachePolicy.js +117 -0
  93. package/dist/esm/CachePolicy.js.map +1 -0
  94. package/dist/esm/Effects.d.ts +258 -0
  95. package/dist/esm/Effects.d.ts.map +1 -0
  96. package/dist/esm/Effects.js +178 -0
  97. package/dist/esm/Effects.js.map +1 -0
  98. package/dist/esm/FileSet.d.ts +366 -0
  99. package/dist/esm/FileSet.d.ts.map +1 -0
  100. package/dist/esm/FileSet.js +398 -0
  101. package/dist/esm/FileSet.js.map +1 -0
  102. package/dist/esm/GraphBuildError.d.ts +120 -0
  103. package/dist/esm/GraphBuildError.d.ts.map +1 -0
  104. package/dist/esm/GraphBuildError.js +145 -0
  105. package/dist/esm/GraphBuildError.js.map +1 -0
  106. package/dist/esm/KeyMaterial.d.ts +107 -0
  107. package/dist/esm/KeyMaterial.d.ts.map +1 -0
  108. package/dist/esm/KeyMaterial.js +92 -0
  109. package/dist/esm/KeyMaterial.js.map +1 -0
  110. package/dist/esm/Node.d.ts +677 -0
  111. package/dist/esm/Node.d.ts.map +1 -0
  112. package/dist/esm/Node.js +586 -0
  113. package/dist/esm/Node.js.map +1 -0
  114. package/dist/esm/Placement.d.ts +117 -0
  115. package/dist/esm/Placement.d.ts.map +1 -0
  116. package/dist/esm/Placement.js +65 -0
  117. package/dist/esm/Placement.js.map +1 -0
  118. package/dist/esm/Plan.d.ts +489 -0
  119. package/dist/esm/Plan.d.ts.map +1 -0
  120. package/dist/esm/Plan.js +718 -0
  121. package/dist/esm/Plan.js.map +1 -0
  122. package/dist/esm/PlanDiff.d.ts +77 -0
  123. package/dist/esm/PlanDiff.d.ts.map +1 -0
  124. package/dist/esm/PlanDiff.js +205 -0
  125. package/dist/esm/PlanDiff.js.map +1 -0
  126. package/dist/esm/Planned.d.ts +121 -0
  127. package/dist/esm/Planned.d.ts.map +1 -0
  128. package/dist/esm/Planned.js +147 -0
  129. package/dist/esm/Planned.js.map +1 -0
  130. package/dist/esm/Repetition.d.ts +31 -0
  131. package/dist/esm/Repetition.d.ts.map +1 -0
  132. package/dist/esm/Repetition.js +24 -0
  133. package/dist/esm/Repetition.js.map +1 -0
  134. package/dist/esm/Scheduling.d.ts +89 -0
  135. package/dist/esm/Scheduling.d.ts.map +1 -0
  136. package/dist/esm/Scheduling.js +82 -0
  137. package/dist/esm/Scheduling.js.map +1 -0
  138. package/dist/esm/StepKey.d.ts +354 -0
  139. package/dist/esm/StepKey.d.ts.map +1 -0
  140. package/dist/esm/StepKey.js +503 -0
  141. package/dist/esm/StepKey.js.map +1 -0
  142. package/dist/esm/index.d.ts +91 -0
  143. package/dist/esm/index.d.ts.map +1 -0
  144. package/dist/esm/index.js +91 -0
  145. package/dist/esm/index.js.map +1 -0
  146. package/dist/esm/internal/ConflictAnnotation.d.ts +59 -0
  147. package/dist/esm/internal/ConflictAnnotation.d.ts.map +1 -0
  148. package/dist/esm/internal/ConflictAnnotation.js +332 -0
  149. package/dist/esm/internal/ConflictAnnotation.js.map +1 -0
  150. package/dist/esm/internal/EffectCandidates.d.ts +19 -0
  151. package/dist/esm/internal/EffectCandidates.d.ts.map +1 -0
  152. package/dist/esm/internal/EffectCandidates.js +86 -0
  153. package/dist/esm/internal/EffectCandidates.js.map +1 -0
  154. package/dist/esm/internal/JsonMirror.d.ts +34 -0
  155. package/dist/esm/internal/JsonMirror.d.ts.map +1 -0
  156. package/dist/esm/internal/JsonMirror.js +204 -0
  157. package/dist/esm/internal/JsonMirror.js.map +1 -0
  158. package/dist/esm/internal/SchemaIdentity.d.ts +140 -0
  159. package/dist/esm/internal/SchemaIdentity.d.ts.map +1 -0
  160. package/dist/esm/internal/SchemaIdentity.js +1002 -0
  161. package/dist/esm/internal/SchemaIdentity.js.map +1 -0
  162. package/dist/esm/internal/effects.d.ts +245 -0
  163. package/dist/esm/internal/effects.d.ts.map +1 -0
  164. package/dist/esm/internal/effects.js +459 -0
  165. package/dist/esm/internal/effects.js.map +1 -0
  166. package/dist/esm/internal/node.d.ts +526 -0
  167. package/dist/esm/internal/node.d.ts.map +1 -0
  168. package/dist/esm/internal/node.js +565 -0
  169. package/dist/esm/internal/node.js.map +1 -0
  170. package/dist/esm/test/PlanFixtures.d.ts +127 -0
  171. package/dist/esm/test/PlanFixtures.d.ts.map +1 -0
  172. package/dist/esm/test/PlanFixtures.js +60 -0
  173. package/dist/esm/test/PlanFixtures.js.map +1 -0
  174. package/docs/README.md +167 -0
  175. package/docs/api.md +1485 -0
  176. package/docs/concepts/authoring-ast.md +204 -0
  177. package/docs/concepts/effects-and-conflicts.md +135 -0
  178. package/docs/concepts/plan-value.md +168 -0
  179. package/docs/concepts/step-keys.md +179 -0
  180. package/docs/guides/author-a-node-graph.md +182 -0
  181. package/docs/guides/compile-a-plan.md +146 -0
  182. package/docs/guides/declare-file-effects.md +143 -0
  183. package/docs/guides/diff-two-plans.md +310 -0
  184. package/docs/installation.md +75 -0
  185. package/docs/quickstart.md +128 -0
  186. package/docs/testing.md +73 -0
  187. package/docs/troubleshooting.md +314 -0
  188. package/package.json +255 -3
  189. package/src/CachePolicy.ts +143 -0
  190. package/src/Effects.ts +302 -0
  191. package/src/FileSet.ts +493 -0
  192. package/src/GraphBuildError.ts +156 -0
  193. package/src/KeyMaterial.ts +111 -0
  194. package/src/Node.ts +969 -0
  195. package/src/Placement.ts +99 -0
  196. package/src/Plan.ts +911 -0
  197. package/src/PlanDiff.ts +244 -0
  198. package/src/Planned.ts +208 -0
  199. package/src/Repetition.ts +33 -0
  200. package/src/Scheduling.ts +154 -0
  201. package/src/StepKey.ts +736 -0
  202. package/src/index.ts +103 -0
  203. package/src/internal/ConflictAnnotation.ts +374 -0
  204. package/src/internal/EffectCandidates.ts +89 -0
  205. package/src/internal/JsonMirror.ts +255 -0
  206. package/src/internal/SchemaIdentity.ts +1096 -0
  207. package/src/internal/effects.ts +543 -0
  208. package/src/internal/node.ts +859 -0
  209. package/src/test/PlanFixtures.ts +76 -0
@@ -0,0 +1,677 @@
1
+ /**
2
+ * Pure, pipeable nodes: the shape a flow body describes and nothing more.
3
+ *
4
+ * Building a node records an inspectable AST and executes nothing — the same
5
+ * split as Bazel's `ctx.actions.run`, which declares an action rather than
6
+ * running one. A plan is
7
+ * always a DAG, so there is no loop node here and never will be: repetition
8
+ * lives one level up, in what a flow settles with.
9
+ *
10
+ * A node also carries Effect's requirement channel, `R`, and carries it as a
11
+ * PHANTOM: building a plan demands nothing, and every combinator here unions
12
+ * `R` without ever reading it. What fills the channel is a call to something
13
+ * whose code lives elsewhere — an action — so the type of a plan states which
14
+ * implementations executing it will need, and the place that executes it is
15
+ * where the compiler asks for them.
16
+ *
17
+ * Control flow is structure. {@link branch} takes both arms and evaluates each
18
+ * ONCE, symbolically, so the exit condition and the handoff site are visible
19
+ * topology before anything runs; its predicate is digested and runs later on
20
+ * the real value. {@link map} is transformation only. The rule the authoring
21
+ * note states, and this module encodes: **map transforms; branch decides.**
22
+ *
23
+ * Adapted from `@smthrs/core` (`packages/smithers/flows/core`) `Node.ts`.
24
+ * `Dynamic` is gone — a model call is an ordinary action, and nothing
25
+ * model-shaped belongs in this package — and node annotations are gone with
26
+ * it, because the AST has to stay JSON serializable.
27
+ *
28
+ * @since 0.1.0
29
+ */
30
+ import type * as Pipeable from "effect/Pipeable";
31
+ import type * as Schema from "effect/Schema";
32
+ import type * as SchemaAST from "effect/SchemaAST";
33
+ import type * as Types from "effect/Types";
34
+ import * as internal from "./internal/node.ts";
35
+ import * as internalSchemaIdentity from "./internal/SchemaIdentity.ts";
36
+ import * as Planned from "./Planned.ts";
37
+ /**
38
+ * The runtime type identifier carried by every node.
39
+ *
40
+ * @since 0.1.0
41
+ * @category type ids
42
+ * @slop
43
+ */
44
+ export declare const TypeId: TypeId;
45
+ /**
46
+ * The type-level form of {@link TypeId}.
47
+ *
48
+ * @since 0.1.0
49
+ * @category type ids
50
+ * @slop
51
+ */
52
+ export type TypeId = "~@smthrs/plan/Node";
53
+ /**
54
+ * The inspectable AST a node stores: closure-free, and JSON serializable for
55
+ * every JSON payload an author puts in it.
56
+ *
57
+ * @since 0.1.0
58
+ * @category models
59
+ * @slop
60
+ */
61
+ export type Ast = internal.NodeAst;
62
+ /**
63
+ * How a flow call joins the caller's plan: `inline` splices the callee's body
64
+ * in, `boundary` makes it one child execution, and `handoff` names the next
65
+ * trampoline round.
66
+ *
67
+ * This is the ONE call-mode vocabulary. {@link flowCall} takes it and
68
+ * `@smthrs/flow`'s graph builder switches on it, so a second spelling in
69
+ * either package would fork the moment one gained a mode.
70
+ *
71
+ * @since 0.1.0
72
+ * @category models
73
+ * @slop
74
+ */
75
+ export declare const CallMode: Schema.Literals<readonly ["inline", "boundary", "handoff"]>;
76
+ /**
77
+ * The value form of {@link CallMode}.
78
+ *
79
+ * @since 0.1.0
80
+ * @category models
81
+ * @slop
82
+ */
83
+ export type CallMode = internal.CallMode;
84
+ /**
85
+ * The serializable stand-in an AST keeps for a plan-time function: a digest of
86
+ * its normalized source, hashed in place of a closure that could not be
87
+ * shipped, stored, or compared.
88
+ *
89
+ * @since 0.1.0
90
+ * @category models
91
+ * @slop
92
+ */
93
+ export type FunctionIdentity = Extract<Ast, {
94
+ readonly _tag: "Map";
95
+ }>["mapper"];
96
+ /**
97
+ * Reads the inert AST reference created for a planned value.
98
+ *
99
+ * Structural lookalikes remain ordinary payload data. This accessor is the
100
+ * only recognition path because the marker itself is deliberately private to
101
+ * the AST cloner.
102
+ *
103
+ * @since 1.0.0
104
+ * @category accessors
105
+ */
106
+ export declare const plannedReference: (value: unknown) => internal.PlannedReference | undefined;
107
+ /**
108
+ * A pure graph-building value, covariant in what it will succeed and fail
109
+ * with and in what it will need to run. It is a description: holding one has
110
+ * run nothing.
111
+ *
112
+ * `R` is Effect's requirement channel, and it is PHANTOM here. Nothing at plan
113
+ * time reads it: the AST, the graph built from it, its key material, and every
114
+ * digest are identical whatever `R` says. It exists so a value that names an
115
+ * implementation it does not carry — an action call — can say so in its type,
116
+ * and so the place that finally has to run that implementation can demand it.
117
+ * Building a plan therefore stays requirement-free; only executing one is not.
118
+ *
119
+ * @since 0.1.0
120
+ * @category models
121
+ * @slop
122
+ */
123
+ export interface Node<out A, out E = never, out R = never> extends Pipeable.Pipeable {
124
+ readonly [TypeId]: {
125
+ readonly _A: Types.Covariant<A>;
126
+ readonly _E: Types.Covariant<E>;
127
+ readonly _R: Types.Covariant<R>;
128
+ };
129
+ readonly ast: Ast;
130
+ }
131
+ /**
132
+ * Any node, whatever it succeeds or fails with and whatever it requires.
133
+ *
134
+ * @since 0.1.0
135
+ * @category models
136
+ * @slop
137
+ */
138
+ export type Any = Node<unknown, unknown, any>;
139
+ /**
140
+ * The success type of a node.
141
+ *
142
+ * @since 0.1.0
143
+ * @category models
144
+ * @slop
145
+ */
146
+ export type Success<N> = N extends Node<infer A, infer _E, infer _R> ? A : never;
147
+ /**
148
+ * The error type of a node.
149
+ *
150
+ * @since 0.1.0
151
+ * @category models
152
+ * @slop
153
+ */
154
+ export type Error<N> = N extends Node<infer _A, infer E, infer _R> ? E : never;
155
+ /**
156
+ * The requirements of a node: what has to be provided wherever it is finally
157
+ * executed, and nothing that has to be provided to build it.
158
+ *
159
+ * @since 0.1.0
160
+ * @category models
161
+ * @slop
162
+ */
163
+ export type Services<N> = N extends Node<infer _A, infer _E, infer R> ? R : never;
164
+ /**
165
+ * The node reference a branch arm's symbolic subject carries. Arms are built
166
+ * before the graph assigns ids, so every reference an arm records names this
167
+ * placeholder, and graph building rewrites it to the branch's own upstream
168
+ * node — which is `first`, structurally, and therefore not a guess.
169
+ *
170
+ * @since 0.1.0
171
+ * @category constants
172
+ * @slop
173
+ */
174
+ export declare const branchSubject = "branch/subject";
175
+ /**
176
+ * The prefix of the node reference a catch failure arm's symbolic error
177
+ * carries. Each {@link catch_} mints its own token under this prefix, so an
178
+ * outer error captured inside a nested failure arm keeps naming the outer
179
+ * catch, and graph building rewrites each token to the node that catch
180
+ * protects.
181
+ *
182
+ * @since 0.1.0
183
+ * @category constants
184
+ * @slop
185
+ */
186
+ export declare const catchSubject = "catch/subject";
187
+ /**
188
+ * The two arms of a decision plus the predicate that chooses between them.
189
+ *
190
+ * `if` runs at RUN time on the real value. `then` and `else` run at PLAN time,
191
+ * once each, against a {@link module:Planned.Planned} placeholder — they
192
+ * describe topology, so they may pass the value on but never compute on it.
193
+ *
194
+ * @since 0.1.0
195
+ * @category models
196
+ * @slop
197
+ */
198
+ export interface BranchOptions<A, B1, E1, R1, B2, E2, R2> {
199
+ readonly if: (value: A) => boolean;
200
+ readonly then: (value: Planned.Planned<A>) => Node<B1, E1, R1>;
201
+ readonly else: (value: Planned.Planned<A>) => Node<B2, E2, R2>;
202
+ }
203
+ /**
204
+ * The statically planned recovery arm and optional schema selecting which
205
+ * typed failures it handles.
206
+ *
207
+ * @since 0.1.0
208
+ * @category models
209
+ * @slop
210
+ */
211
+ export interface CatchOptions<E, B, E2, R2 = never, Handled = E> {
212
+ readonly error?: Schema.Schema<Handled> | undefined;
213
+ readonly onFailure: (error: Planned.Planned<Handled>) => Node<B, E2, R2>;
214
+ }
215
+ /**
216
+ * Checks whether a value is a node.
217
+ *
218
+ * A node this package built is recognized by registration at construction. A
219
+ * node that crossed a serialization boundary, an object sharing the node
220
+ * prototype whose own `ast` is a well-formed AST, is recognized by that shape,
221
+ * because `@smthrs/flow` hands a rehydrated AST back as a node and its side
222
+ * tables are all a round trip loses. The {@link TypeId} marker is a public
223
+ * string any object can carry, so it counts for nothing on its own: every
224
+ * combinator that admits a node reads its `ast` as trusted topology, and an
225
+ * object carrying the marker on any other prototype, one inheriting it from a
226
+ * node, and one whose `ast` is missing, malformed, cyclic, or an accessor are
227
+ * all refused with the same `GraphBuildError` as any other non-node. A proxy
228
+ * is judged by the shape it forwards: one that forwards a node unchanged
229
+ * passes, and one that diverges from it does not.
230
+ *
231
+ * @since 0.1.0
232
+ * @category guards
233
+ * @slop
234
+ */
235
+ export declare const isNode: (value: unknown) => value is Any;
236
+ /**
237
+ * The inert value delivered by {@link succeed}. Planned references resolve to
238
+ * their result type; other values follow the payload's JSON projection.
239
+ * Invalid dates serialize to null. Members without a JSON representation are
240
+ * omitted from objects and replaced with null in arrays.
241
+ *
242
+ * @since 1.0.0
243
+ * @category models
244
+ */
245
+ export type Succeed<A> = A extends Planned.Planned<infer Value> ? Value : A extends Date ? string | null : A extends {
246
+ toJSON: (...args: any) => infer Value;
247
+ } ? Succeed<Value> : A extends (...args: any) => any ? undefined : A extends symbol ? undefined : A extends ReadonlyArray<unknown> ? {
248
+ [K in keyof A]: SucceedArrayMember<A[K]>;
249
+ } : A extends object ? {
250
+ [K in keyof A as K extends string | number ? [Succeed<A[K]>] extends [undefined] ? never : K : never]: Succeed<A[K]>;
251
+ } : A;
252
+ /** @private */
253
+ type SucceedArrayMember<A> = A extends Planned.Planned<infer Value> ? Value : A extends unknown ? Succeed<A> extends infer Value ? Value extends undefined ? null : Value : never : never;
254
+ /**
255
+ * A node that succeeds with the constant's inert JSON projection.
256
+ *
257
+ * Dates produce strings (or null for invalid dates), URLs produce strings,
258
+ * and callable object members are omitted. Use {@link map} to reconstruct a
259
+ * domain value explicitly after this serialization boundary.
260
+ *
261
+ * @since 0.1.0
262
+ * @category constructors
263
+ */
264
+ export declare const succeed: <A>(value: A) => Node<Succeed<A>>;
265
+ /**
266
+ * The inert error delivered by {@link fail}: the same JSON projection
267
+ * {@link Succeed} describes, because a plan stores an error exactly as it
268
+ * stores a value.
269
+ *
270
+ * @since 1.0.0
271
+ * @category models
272
+ */
273
+ export type Fail<E> = Succeed<E>;
274
+ /**
275
+ * A node that fails with the constant's inert JSON projection, in the typed
276
+ * error channel.
277
+ *
278
+ * It is how a plan states a refusal it already knows about — an unsupported
279
+ * input, an exhausted budget, a compensation that has nothing left to undo —
280
+ * without an action that exists only to fail. {@link catch} recovers it exactly
281
+ * as it recovers an action's failure, and an uncaught one is the flow's typed
282
+ * failure.
283
+ *
284
+ * @since 1.0.0
285
+ * @category constructors
286
+ */
287
+ export declare const fail: <E>(error: E) => Node<never, Fail<E>>;
288
+ /**
289
+ * Combines independent children into one node, keyed by name.
290
+ *
291
+ * Width is fixed here, at plan time. Fanning out over something a step
292
+ * discovered is not this: end the round and carry the list in the next flow's
293
+ * payload, where it is real data.
294
+ *
295
+ * @since 0.1.0
296
+ * @category constructors
297
+ * @slop
298
+ */
299
+ export declare const all: <const Nodes extends Readonly<Record<string, Any>>>(nodes: Nodes) => Node<Types.Simplify<{ readonly [K in keyof Nodes]: Success<Nodes[K]>; }>, Error<Nodes[keyof Nodes]>, Services<Nodes[keyof Nodes]>>;
300
+ /**
301
+ * The members of an early-settling join, keyed by name.
302
+ *
303
+ * @since 1.0.0
304
+ * @category models
305
+ */
306
+ export type Members = Readonly<Record<string, Any>>;
307
+ /**
308
+ * Settles with the first member to settle, success or typed failure.
309
+ *
310
+ * The other members are interrupted. The winner is journaled, so a resumed run
311
+ * settles the same member and never starts the others again.
312
+ *
313
+ * @since 1.0.0
314
+ * @category constructors
315
+ */
316
+ export declare const race: <const Nodes extends Members>(nodes: Nodes) => Node<Success<Nodes[keyof Nodes]>, Error<Nodes[keyof Nodes]>, Services<Nodes[keyof Nodes]>>;
317
+ /**
318
+ * Settles with the first member to succeed, ignoring typed failures while a
319
+ * member is still running.
320
+ *
321
+ * It fails with the last failure when every member fails. The other members
322
+ * are interrupted, and the winner is journaled as {@link race} journals it.
323
+ *
324
+ * @since 1.0.0
325
+ * @category constructors
326
+ */
327
+ export declare const any: <const Nodes extends Members>(nodes: Nodes) => Node<Success<Nodes[keyof Nodes]>, Error<Nodes[keyof Nodes]>, Services<Nodes[keyof Nodes]>>;
328
+ /**
329
+ * Succeeds once `count` members succeed, with exactly those members' values
330
+ * keyed by name.
331
+ *
332
+ * It fails with the failure that leaves fewer than `count` members able to
333
+ * succeed. Either way the members still running are interrupted, and the
334
+ * members that decided are journaled as {@link race} journals its winner.
335
+ *
336
+ * @since 1.0.0
337
+ * @category constructors
338
+ */
339
+ export declare const quorum: <const Nodes extends Members>(count: number, nodes: Nodes) => Node<Types.Simplify<{ readonly [K in keyof Nodes]?: Success<Nodes[K]>; }>, Error<Nodes[keyof Nodes]>, Services<Nodes[keyof Nodes]>>;
340
+ /**
341
+ * Transforms an eventual success value with a deferred pure function.
342
+ *
343
+ * The function is digested, not run: it executes later, on the real value.
344
+ * This is where computation on a step result belongs — and only computation. A
345
+ * `map` that decides what happens next is a `branch` written wrongly.
346
+ *
347
+ * @since 0.1.0
348
+ * @category mapping
349
+ * @slop
350
+ */
351
+ export declare const map: {
352
+ <A, B>(f: (a: A) => B): <E, R>(self: Node<A, E, R>) => Node<B, E, R>;
353
+ <A, E, R, B>(self: Node<A, E, R>, f: (a: A) => B): Node<B, E, R>;
354
+ };
355
+ /**
356
+ * Starts the entire next subtree only after this node succeeds, without
357
+ * consuming its result. Failure or interruption prevents that subtree from
358
+ * starting, including actions nested inside combinations or inline flows.
359
+ *
360
+ * Use {@link bindPlanned} to build a dependency from a symbolic result, or
361
+ * {@link map} to compute on the eventual value.
362
+ *
363
+ * @since 0.1.0
364
+ * @category sequencing
365
+ * @slop
366
+ */
367
+ export declare const andThen: {
368
+ <B, E2, R2>(next: Node<B, E2, R2>): <A, E, R>(self: Node<A, E, R>) => Node<B, E | E2, R | R2>;
369
+ <A, E, R, B, E2, R2>(self: Node<A, E, R>, next: Node<B, E2, R2>): Node<B, E | E2, R | R2>;
370
+ };
371
+ /**
372
+ * Builds a dependency using a symbolic reference to this node's future result.
373
+ *
374
+ * The builder runs during planning. Its argument is a {@link module:Planned.Planned}
375
+ * reference, not the value the node will eventually produce. Pass references
376
+ * into action payloads; use {@link branch} for decisions and {@link map} for
377
+ * computation on real results. JavaScript truthiness and reference equality
378
+ * cannot inspect a planned result. Enable type-aware ESLint's
379
+ * `@typescript-eslint/strict-boolean-expressions` to reject planned conditions.
380
+ * Independent descendants of the built subtree can start while this producer
381
+ * is running; consumers of its reference wait for its value. Use
382
+ * {@link andThen} when the whole next subtree must wait for success.
383
+ *
384
+ * @since 1.0.0
385
+ * @category sequencing
386
+ */
387
+ export declare const bindPlanned: {
388
+ <A, B, E2, R2>(build: (reference: Planned.Planned<A>) => Node<B, E2, R2>): <E, R>(self: Node<A, E, R>) => Node<B, E | E2, R | R2>;
389
+ <A, E, R, B, E2, R2>(self: Node<A, E, R>, build: (reference: Planned.Planned<A>) => Node<B, E2, R2>): Node<B, E | E2, R | R2>;
390
+ };
391
+ /**
392
+ * Decides between two arms, both of them static topology.
393
+ *
394
+ * Each arm builder is evaluated exactly once, here, against a
395
+ * {@link module:Planned.Planned} placeholder, and the resulting ASTs are what
396
+ * the node stores — so a plan shows the exit condition and both continuations
397
+ * before it runs. The predicate is digested and evaluated at run time on the
398
+ * real value, which is why none of the plan-time placeholder machinery leaks
399
+ * into control flow.
400
+ *
401
+ * Both arms contribute their requirements, because both arms are topology the
402
+ * plan carries. A run takes one of them, but which one is not known until the
403
+ * predicate sees the real value, so an execution has to be able to take either.
404
+ *
405
+ * @since 0.1.0
406
+ * @category sequencing
407
+ * @slop
408
+ */
409
+ export declare const branch: {
410
+ <A, B1, E1, R1, B2, E2, R2>(options: BranchOptions<A, B1, E1, R1, B2, E2, R2>): <E, R>(self: Node<A, E, R>) => Node<B1 | B2, E | E1 | E2, R | R1 | R2>;
411
+ <A, E, R, B1, E1, R1, B2, E2, R2>(self: Node<A, E, R>, options: BranchOptions<A, B1, E1, R1, B2, E2, R2>): Node<B1 | B2, E | E1 | E2, R | R1 | R2>;
412
+ };
413
+ /**
414
+ * Recovers from matching typed failures with static failure topology.
415
+ *
416
+ * The protected graph and failure arm are both stored in the AST. The arm is
417
+ * built once at plan time against a strict planned error placeholder. With no
418
+ * schema the whole typed error channel is handled. A schema handles only the
419
+ * values it accepts, so its overloads retain E: a refinement can reject values
420
+ * without narrowing its TypeScript type. Runtime schema callbacks enter the
421
+ * filter identity along with its JSON Schema. Uncaptured callbacks are local
422
+ * to this process, just like uncaptured mappers.
423
+ *
424
+ * The failure arm contributes its requirements to the node's, for the same
425
+ * reason a branch's arms do: it is topology the plan carries, and a run reaches
426
+ * it whenever the protected graph fails.
427
+ *
428
+ * @since 0.1.0
429
+ * @category sequencing
430
+ * @slop
431
+ */
432
+ declare const catch_: {
433
+ <Handled, B, E2, R2>(options: CatchOptions<unknown, B, E2, R2, Handled> & {
434
+ readonly error: Schema.Schema<Handled>;
435
+ }): <A, E, R>(self: Node<A, E, R>) => Node<A | B, E | E2, R | R2>;
436
+ <E, B, E2, R2>(options: CatchOptions<E, B, E2, R2> & {
437
+ readonly error?: undefined;
438
+ }): <A, R>(self: Node<A, E, R>) => Node<A | B, E2, R | R2>;
439
+ <A, E, R, Handled, B, E2, R2>(self: Node<A, E, R>, options: CatchOptions<E, B, E2, R2, Handled> & {
440
+ readonly error: Schema.Schema<Handled>;
441
+ }): Node<A | B, E | E2, R | R2>;
442
+ <A, E, R, B, E2, R2>(self: Node<A, E, R>, options: CatchOptions<E, B, E2, R2> & {
443
+ readonly error?: undefined;
444
+ }): Node<A | B, E2, R | R2>;
445
+ };
446
+ export { catch_ as catch };
447
+ /**
448
+ * Attaches a scheduling priority to a node, leaving the original unchanged.
449
+ *
450
+ * The scheduler runs ready work with a higher number first, so a priority
451
+ * changes LATENCY and nothing else. It never enters key material: a node
452
+ * ordered ahead of another still computes the same result, so re-keying it
453
+ * would throw away a legitimate cache hit. Children inherit the value
454
+ * lexically when the graph is built, and a child that states its own keeps it.
455
+ *
456
+ * @since 0.1.0
457
+ * @category annotations
458
+ * @slop
459
+ */
460
+ export declare const priority: {
461
+ (value: number): <A, E, R>(self: Node<A, E, R>) => Node<A, E, R>;
462
+ <A, E, R>(self: Node<A, E, R>, value: number): Node<A, E, R>;
463
+ };
464
+ /**
465
+ * Reads the scheduling priority a node carries, or `undefined` when it states
466
+ * none and inherits from whatever encloses it.
467
+ *
468
+ * @since 0.1.0
469
+ * @category accessors
470
+ * @slop
471
+ */
472
+ export declare const declaredPriority: (ast: Ast) => number | undefined;
473
+ /**
474
+ * Constructs the flow-call node used by `@smthrs/flow` without making flow
475
+ * calls part of the public authoring surface of this package.
476
+ *
477
+ * Reserved for `@smthrs/flow`, which owns flow authoring. It is not part
478
+ * of this package's authoring surface, and it validates nothing: an unknown
479
+ * flow tag becomes a call node the graph keeps as a leaf.
480
+ *
481
+ * @since 0.1.0
482
+ * @category engine
483
+ * @slop
484
+ */
485
+ export declare const flowCall: <A = unknown, E = never, R = never>(declaration: unknown, flow: string, mode: CallMode, payload: unknown) => Node<A, E, R>;
486
+ /**
487
+ * Constructs the action-call node used by `@smthrs/flow` without making
488
+ * action calls part of the public authoring surface of this package.
489
+ *
490
+ * Reserved for `@smthrs/flow`, which owns action authoring. It is not part
491
+ * of this package's authoring surface, and an unknown action tag becomes a
492
+ * call node the graph keeps as a leaf.
493
+ *
494
+ * @since 0.1.0
495
+ * @category engine
496
+ * @slop
497
+ */
498
+ export declare const actionCall: <A = unknown, E = never, R = never>(declaration: unknown, action: string, payload: unknown) => Node<A, E, R>;
499
+ /**
500
+ * Reads the flow or action declaration a call node names, so `@smthrs/flow`
501
+ * can expand a call it recorded. It is `undefined` for an AST that was
502
+ * rehydrated from JSON, because the declaration lives beside the AST rather
503
+ * than inside it — a graph built from such an AST keeps the call as a leaf.
504
+ *
505
+ * Reserved for `@smthrs/flow`, which files the declaration when it builds
506
+ * the call. Authors never call it.
507
+ *
508
+ * @since 0.1.0
509
+ * @category engine
510
+ * @slop
511
+ */
512
+ export declare const declaration: (ast: Extract<Ast, {
513
+ readonly _tag: "ActionCall" | "FlowCall";
514
+ }>) => unknown;
515
+ /**
516
+ * Reads the continuation builder of a sequenced node, which graph building
517
+ * evaluates once against a placeholder. It is `undefined` when the author
518
+ * supplied a node directly — the topology is already in `next` — and for a
519
+ * rehydrated AST, whose side table did not survive serialization.
520
+ *
521
+ * Reserved for `@smthrs/flow`'s graph walk. Authors never call it.
522
+ *
523
+ * @since 0.1.0
524
+ * @category engine
525
+ * @slop
526
+ */
527
+ export declare const continuation: (ast: Extract<Ast, {
528
+ readonly _tag: "AndThen";
529
+ }>) => ((value: Planned.Planned<unknown>) => unknown) | undefined;
530
+ /**
531
+ * Reads the deferred mapper of a {@link map} node, which a driver applies to
532
+ * the real upstream value once it has one. It is `undefined` for every other
533
+ * variant, and for a rehydrated AST whose side table did not survive
534
+ * serialization.
535
+ *
536
+ * Reserved for `@smthrs/flow`'s interpreter. Authors never call it.
537
+ *
538
+ * @since 0.1.0
539
+ * @category engine
540
+ * @slop
541
+ */
542
+ export declare const mapper: (ast: Ast) => ((value: unknown) => unknown) | undefined;
543
+ /**
544
+ * Reads the run-time predicate of a {@link branch} node, which a driver
545
+ * evaluates on the real subject value to choose an arm. It is `undefined` for
546
+ * every other variant, and for a rehydrated AST whose side table did not
547
+ * survive serialization.
548
+ *
549
+ * Reserved for `@smthrs/flow`'s interpreter. Authors never call it.
550
+ *
551
+ * @since 0.1.0
552
+ * @category engine
553
+ * @slop
554
+ */
555
+ export declare const predicate: (ast: Ast) => ((value: unknown) => boolean) | undefined;
556
+ /**
557
+ * Reads the optional schema selecting failures handled by a {@link catch_}.
558
+ *
559
+ * Reserved for `@smthrs/flow`'s interpreter. It is `undefined` for every
560
+ * variant but `catch_`, and for a rehydrated AST whose side table did not
561
+ * survive serialization.
562
+ *
563
+ * @since 0.1.0
564
+ * @category engine
565
+ * @slop
566
+ */
567
+ export declare const catchFilter: (ast: Ast) => Schema.Top | undefined;
568
+ /**
569
+ * Identifies a plan-time function the AST does NOT store, a flow's `body`,
570
+ * exactly as the AST identifies the mapper and continuation it does store.
571
+ * A call that keeps its callee as a leaf still has to re-key when that
572
+ * callee's body is edited, and this is the identity it folds in. Unannotated
573
+ * functions fail closed with process-local identity; use {@link capture} to
574
+ * declare inert captures and obtain deterministic identity.
575
+ *
576
+ * Reserved for `@smthrs/flow`, which folds a callee body's identity into a
577
+ * call it keeps as a leaf. Authors never call it; it throws a `TypeError`
578
+ * when handed anything but a function.
579
+ *
580
+ * @since 0.1.0
581
+ * @category engine
582
+ * @slop
583
+ */
584
+ export declare const functionIdentity: (operation: unknown) => FunctionIdentity;
585
+ /**
586
+ * The document a schema's identity is: JSON-Schema-shaped, and the same bytes
587
+ * under every `effect` release this package supports.
588
+ *
589
+ * @since 1.0.0
590
+ * @category engine
591
+ */
592
+ export type SchemaIdentity = internalSchemaIdentity.Document;
593
+ /**
594
+ * The one option a schema's identity is taken under: whether an object closes
595
+ * over the keys it declares (`"error"`) or leaves others open (`"ignore"`,
596
+ * the default). It has the meaning it has in `Schema.toJsonSchemaDocument`.
597
+ *
598
+ * @since 1.0.0
599
+ * @category engine
600
+ */
601
+ export type SchemaIdentityOptions = internalSchemaIdentity.Options;
602
+ /**
603
+ * The refusal `schemaIdentity` and `representationIdentity` raise for a schema
604
+ * a step key cannot be derived from. Its message is the one
605
+ * `effect@4.0.0-rc.115` gave for the same schema, where it gave one.
606
+ *
607
+ * @since 1.0.0
608
+ * @category errors
609
+ */
610
+ export declare const SchemaIdentityError: typeof internalSchemaIdentity.SchemaIdentityError;
611
+ /**
612
+ * The type of {@link SchemaIdentityError}.
613
+ *
614
+ * @since 1.0.0
615
+ * @category errors
616
+ */
617
+ export type SchemaIdentityError = internalSchemaIdentity.SchemaIdentityError;
618
+ /**
619
+ * Identifies a schema by the constraints it documents, so a call re-keys when
620
+ * what its callee accepts or produces changes, and a catch re-keys when its
621
+ * filter does.
622
+ *
623
+ * The document is what `Schema.toJsonSchemaDocument(schema, options)`
624
+ * returned under `effect@4.0.0-rc.115`. It is printed by this package, not by
625
+ * the installed `effect`, because a later release prints a different document
626
+ * for the same schema and a moved identity re-keys every recorded step. Use
627
+ * it wherever the document is hashed, compared or pinned; a JSON Schema shown
628
+ * to a model or a person comes from `Schema.toJsonSchemaDocument`.
629
+ *
630
+ * Reserved for the packages that derive identities. Authors never call it; it
631
+ * throws for a schema that has no JSON Schema form.
632
+ *
633
+ * @since 1.0.0
634
+ * @category engine
635
+ */
636
+ export declare const schemaIdentity: (schema: Schema.Top, options?: SchemaIdentityOptions) => SchemaIdentity;
637
+ /**
638
+ * Identifies a schema AST by its encoded representation, the material a
639
+ * sealed action's step key folds in for its success and error schemas.
640
+ *
641
+ * The value is what `SchemaRepresentation.toJson(SchemaRepresentation.toRepresentation(ast))`
642
+ * returned under `effect@4.0.0-rc.115`, so a later `effect` release does not
643
+ * re-key recorded steps. The one exception is `Schema.brand`: from
644
+ * `effect@4.0.4` on a brand is not part of the AST, so a declaration with a
645
+ * brand re-keys once.
646
+ *
647
+ * Reserved for the packages that derive step keys. Authors never call it; it
648
+ * throws for an AST that has no representation.
649
+ *
650
+ * @since 1.0.0
651
+ * @category engine
652
+ */
653
+ export declare const representationIdentity: (ast: SchemaAST.AST) => Schema.Json;
654
+ /**
655
+ * Binds a frozen plain copy of inert captures as the callback's this receiver.
656
+ *
657
+ * Use a function expression to read the snapshot while keeping the ordinary
658
+ * callback arguments: Node.capture({ factor: 3 }, function(value: number) {
659
+ * return value * this.factor
660
+ * }). Caller objects remain unchanged; lexical aliases still name originals
661
+ * and must not be used as mutable semantic inputs. Nested captures retain the
662
+ * inner callback's snapshot and compose the two identities.
663
+ *
664
+ * Admission walks original descriptors once, rejects built-in brands and
665
+ * non-plain prototypes without evaluating getters, then uses structuredClone
666
+ * to refuse Proxies. Hosts without that API refuse object capture. Only the
667
+ * owned frozen copy enters identity and the wrapper. Sealed, non-extensible,
668
+ * frozen and Immer ordinary data are supported equally. Unsupported values
669
+ * raise a TypeError naming the path. See core docs/api.md#nodecapture for the
670
+ * complete algorithm and the migration from original-object locking.
671
+ *
672
+ * @category constructors
673
+ * @since 0.1.0
674
+ * @slop
675
+ */
676
+ export declare const capture: <C extends Readonly<Record<string, unknown>>, Args extends ReadonlyArray<unknown>, A>(captures: C, operation: (this: Readonly<C>, ...args: Args) => A) => (...args: Args) => A;
677
+ //# sourceMappingURL=Node.d.ts.map