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

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 +189 -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 +685 -0
  26. package/dist/cjs/Node.d.ts.map +1 -0
  27. package/dist/cjs/Node.js +230 -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 +685 -0
  111. package/dist/esm/Node.d.ts.map +1 -0
  112. package/dist/esm/Node.js +591 -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 +974 -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,685 @@
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
+ * Maximum eagerly nested branch arms. Arm construction precedes graph walking;
393
+ * this bound leaves native stack headroom for a typed refusal.
394
+ *
395
+ * @since 1.0.0
396
+ * @category constants
397
+ */
398
+ export declare const maximumArmDepth = 512;
399
+ /**
400
+ * Decides between two arms, both of them static topology.
401
+ *
402
+ * Each arm builder is evaluated exactly once, here, against a
403
+ * {@link module:Planned.Planned} placeholder, and the resulting ASTs are what
404
+ * the node stores — so a plan shows the exit condition and both continuations
405
+ * before it runs. The predicate is digested and evaluated at run time on the
406
+ * real value, which is why none of the plan-time placeholder machinery leaks
407
+ * into control flow.
408
+ *
409
+ * Both arms contribute their requirements, because both arms are topology the
410
+ * plan carries. A run takes one of them, but which one is not known until the
411
+ * predicate sees the real value, so an execution has to be able to take either.
412
+ *
413
+ * @since 0.1.0
414
+ * @category sequencing
415
+ * @slop
416
+ */
417
+ export declare const branch: {
418
+ <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>;
419
+ <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>;
420
+ };
421
+ /**
422
+ * Recovers from matching typed failures with static failure topology.
423
+ *
424
+ * The protected graph and failure arm are both stored in the AST. The arm is
425
+ * built once at plan time against a strict planned error placeholder. With no
426
+ * schema the whole typed error channel is handled. A schema handles only the
427
+ * values it accepts, so its overloads retain E: a refinement can reject values
428
+ * without narrowing its TypeScript type. Runtime schema callbacks enter the
429
+ * filter identity along with its JSON Schema. Uncaptured callbacks are local
430
+ * to this process, just like uncaptured mappers.
431
+ *
432
+ * The failure arm contributes its requirements to the node's, for the same
433
+ * reason a branch's arms do: it is topology the plan carries, and a run reaches
434
+ * it whenever the protected graph fails.
435
+ *
436
+ * @since 0.1.0
437
+ * @category sequencing
438
+ * @slop
439
+ */
440
+ declare const catch_: {
441
+ <Handled, B, E2, R2>(options: CatchOptions<unknown, B, E2, R2, Handled> & {
442
+ readonly error: Schema.Schema<Handled>;
443
+ }): <A, E, R>(self: Node<A, E, R>) => Node<A | B, E | E2, R | R2>;
444
+ <E, B, E2, R2>(options: CatchOptions<E, B, E2, R2> & {
445
+ readonly error?: undefined;
446
+ }): <A, R>(self: Node<A, E, R>) => Node<A | B, E2, R | R2>;
447
+ <A, E, R, Handled, B, E2, R2>(self: Node<A, E, R>, options: CatchOptions<E, B, E2, R2, Handled> & {
448
+ readonly error: Schema.Schema<Handled>;
449
+ }): Node<A | B, E | E2, R | R2>;
450
+ <A, E, R, B, E2, R2>(self: Node<A, E, R>, options: CatchOptions<E, B, E2, R2> & {
451
+ readonly error?: undefined;
452
+ }): Node<A | B, E2, R | R2>;
453
+ };
454
+ export { catch_ as catch };
455
+ /**
456
+ * Attaches a scheduling priority to a node, leaving the original unchanged.
457
+ *
458
+ * The scheduler runs ready work with a higher number first, so a priority
459
+ * changes LATENCY and nothing else. It never enters key material: a node
460
+ * ordered ahead of another still computes the same result, so re-keying it
461
+ * would throw away a legitimate cache hit. Children inherit the value
462
+ * lexically when the graph is built, and a child that states its own keeps it.
463
+ *
464
+ * @since 0.1.0
465
+ * @category annotations
466
+ * @slop
467
+ */
468
+ export declare const priority: {
469
+ (value: number): <A, E, R>(self: Node<A, E, R>) => Node<A, E, R>;
470
+ <A, E, R>(self: Node<A, E, R>, value: number): Node<A, E, R>;
471
+ };
472
+ /**
473
+ * Reads the scheduling priority a node carries, or `undefined` when it states
474
+ * none and inherits from whatever encloses it.
475
+ *
476
+ * @since 0.1.0
477
+ * @category accessors
478
+ * @slop
479
+ */
480
+ export declare const declaredPriority: (ast: Ast) => number | undefined;
481
+ /**
482
+ * Constructs the flow-call node used by `@smthrs/flow` without making flow
483
+ * calls part of the public authoring surface of this package.
484
+ *
485
+ * Reserved for `@smthrs/flow`, which owns flow authoring. It is not part
486
+ * of this package's authoring surface, and it validates nothing: an unknown
487
+ * flow tag becomes a call node the graph keeps as a leaf.
488
+ *
489
+ * @since 0.1.0
490
+ * @category engine
491
+ * @slop
492
+ */
493
+ export declare const flowCall: <A = unknown, E = never, R = never>(declaration: unknown, flow: string, mode: CallMode, payload: unknown) => Node<A, E, R>;
494
+ /**
495
+ * Constructs the action-call node used by `@smthrs/flow` without making
496
+ * action calls part of the public authoring surface of this package.
497
+ *
498
+ * Reserved for `@smthrs/flow`, which owns action authoring. It is not part
499
+ * of this package's authoring surface, and an unknown action tag becomes a
500
+ * call node the graph keeps as a leaf.
501
+ *
502
+ * @since 0.1.0
503
+ * @category engine
504
+ * @slop
505
+ */
506
+ export declare const actionCall: <A = unknown, E = never, R = never>(declaration: unknown, action: string, payload: unknown) => Node<A, E, R>;
507
+ /**
508
+ * Reads the flow or action declaration a call node names, so `@smthrs/flow`
509
+ * can expand a call it recorded. It is `undefined` for an AST that was
510
+ * rehydrated from JSON, because the declaration lives beside the AST rather
511
+ * than inside it — a graph built from such an AST keeps the call as a leaf.
512
+ *
513
+ * Reserved for `@smthrs/flow`, which files the declaration when it builds
514
+ * the call. Authors never call it.
515
+ *
516
+ * @since 0.1.0
517
+ * @category engine
518
+ * @slop
519
+ */
520
+ export declare const declaration: (ast: Extract<Ast, {
521
+ readonly _tag: "ActionCall" | "FlowCall";
522
+ }>) => unknown;
523
+ /**
524
+ * Reads the continuation builder of a sequenced node, which graph building
525
+ * evaluates once against a placeholder. It is `undefined` when the author
526
+ * supplied a node directly — the topology is already in `next` — and for a
527
+ * rehydrated AST, whose side table did not survive serialization.
528
+ *
529
+ * Reserved for `@smthrs/flow`'s graph walk. Authors never call it.
530
+ *
531
+ * @since 0.1.0
532
+ * @category engine
533
+ * @slop
534
+ */
535
+ export declare const continuation: (ast: Extract<Ast, {
536
+ readonly _tag: "AndThen";
537
+ }>) => ((value: Planned.Planned<unknown>) => unknown) | undefined;
538
+ /**
539
+ * Reads the deferred mapper of a {@link map} node, which a driver applies to
540
+ * the real upstream value once it has one. It is `undefined` for every other
541
+ * variant, and for a rehydrated AST whose side table did not survive
542
+ * serialization.
543
+ *
544
+ * Reserved for `@smthrs/flow`'s interpreter. Authors never call it.
545
+ *
546
+ * @since 0.1.0
547
+ * @category engine
548
+ * @slop
549
+ */
550
+ export declare const mapper: (ast: Ast) => ((value: unknown) => unknown) | undefined;
551
+ /**
552
+ * Reads the run-time predicate of a {@link branch} node, which a driver
553
+ * evaluates on the real subject value to choose an arm. It is `undefined` for
554
+ * every other variant, and for a rehydrated AST whose side table did not
555
+ * survive serialization.
556
+ *
557
+ * Reserved for `@smthrs/flow`'s interpreter. Authors never call it.
558
+ *
559
+ * @since 0.1.0
560
+ * @category engine
561
+ * @slop
562
+ */
563
+ export declare const predicate: (ast: Ast) => ((value: unknown) => boolean) | undefined;
564
+ /**
565
+ * Reads the optional schema selecting failures handled by a {@link catch_}.
566
+ *
567
+ * Reserved for `@smthrs/flow`'s interpreter. It is `undefined` for every
568
+ * variant but `catch_`, and for a rehydrated AST whose side table did not
569
+ * survive serialization.
570
+ *
571
+ * @since 0.1.0
572
+ * @category engine
573
+ * @slop
574
+ */
575
+ export declare const catchFilter: (ast: Ast) => Schema.Top | undefined;
576
+ /**
577
+ * Identifies a plan-time function the AST does NOT store, a flow's `body`,
578
+ * exactly as the AST identifies the mapper and continuation it does store.
579
+ * A call that keeps its callee as a leaf still has to re-key when that
580
+ * callee's body is edited, and this is the identity it folds in. Unannotated
581
+ * functions fail closed with process-local identity; use {@link capture} to
582
+ * declare inert captures and obtain deterministic identity.
583
+ *
584
+ * Reserved for `@smthrs/flow`, which folds a callee body's identity into a
585
+ * call it keeps as a leaf. Authors never call it; it throws a `TypeError`
586
+ * when handed anything but a function.
587
+ *
588
+ * @since 0.1.0
589
+ * @category engine
590
+ * @slop
591
+ */
592
+ export declare const functionIdentity: (operation: unknown) => FunctionIdentity;
593
+ /**
594
+ * The document a schema's identity is: JSON-Schema-shaped, and the same bytes
595
+ * under every `effect` release this package supports.
596
+ *
597
+ * @since 1.0.0
598
+ * @category engine
599
+ */
600
+ export type SchemaIdentity = internalSchemaIdentity.Document;
601
+ /**
602
+ * The one option a schema's identity is taken under: whether an object closes
603
+ * over the keys it declares (`"error"`) or leaves others open (`"ignore"`,
604
+ * the default). It has the meaning it has in `Schema.toJsonSchemaDocument`.
605
+ *
606
+ * @since 1.0.0
607
+ * @category engine
608
+ */
609
+ export type SchemaIdentityOptions = internalSchemaIdentity.Options;
610
+ /**
611
+ * The refusal `schemaIdentity` and `representationIdentity` raise for a schema
612
+ * a step key cannot be derived from. Its message is the one
613
+ * `effect@4.0.0-rc.115` gave for the same schema, where it gave one.
614
+ *
615
+ * @since 1.0.0
616
+ * @category errors
617
+ */
618
+ export declare const SchemaIdentityError: typeof internalSchemaIdentity.SchemaIdentityError;
619
+ /**
620
+ * The type of {@link SchemaIdentityError}.
621
+ *
622
+ * @since 1.0.0
623
+ * @category errors
624
+ */
625
+ export type SchemaIdentityError = internalSchemaIdentity.SchemaIdentityError;
626
+ /**
627
+ * Identifies a schema by the constraints it documents, so a call re-keys when
628
+ * what its callee accepts or produces changes, and a catch re-keys when its
629
+ * filter does.
630
+ *
631
+ * The document is what `Schema.toJsonSchemaDocument(schema, options)`
632
+ * returned under `effect@4.0.0-rc.115`. It is printed by this package, not by
633
+ * the installed `effect`, because a later release prints a different document
634
+ * for the same schema and a moved identity re-keys every recorded step. Use
635
+ * it wherever the document is hashed, compared or pinned; a JSON Schema shown
636
+ * to a model or a person comes from `Schema.toJsonSchemaDocument`.
637
+ *
638
+ * Reserved for the packages that derive identities. Authors never call it; it
639
+ * throws for a schema that has no JSON Schema form.
640
+ *
641
+ * @since 1.0.0
642
+ * @category engine
643
+ */
644
+ export declare const schemaIdentity: (schema: Schema.Top, options?: SchemaIdentityOptions) => SchemaIdentity;
645
+ /**
646
+ * Identifies a schema AST by its encoded representation, the material a
647
+ * sealed action's step key folds in for its success and error schemas.
648
+ *
649
+ * The value is what `SchemaRepresentation.toJson(SchemaRepresentation.toRepresentation(ast))`
650
+ * returned under `effect@4.0.0-rc.115`, so a later `effect` release does not
651
+ * re-key recorded steps. The one exception is `Schema.brand`: from
652
+ * `effect@4.0.4` on a brand is not part of the AST, so a declaration with a
653
+ * brand re-keys once.
654
+ *
655
+ * Reserved for the packages that derive step keys. Authors never call it; it
656
+ * throws for an AST that has no representation.
657
+ *
658
+ * @since 1.0.0
659
+ * @category engine
660
+ */
661
+ export declare const representationIdentity: (ast: SchemaAST.AST) => Schema.Json;
662
+ /**
663
+ * Binds a frozen plain copy of inert captures as the callback's this receiver.
664
+ *
665
+ * Use a function expression to read the snapshot while keeping the ordinary
666
+ * callback arguments: Node.capture({ factor: 3 }, function(value: number) {
667
+ * return value * this.factor
668
+ * }). Caller objects remain unchanged; lexical aliases still name originals
669
+ * and must not be used as mutable semantic inputs. Nested captures retain the
670
+ * inner callback's snapshot and compose the two identities.
671
+ *
672
+ * Admission walks original descriptors once, rejects built-in brands and
673
+ * non-plain prototypes without evaluating getters, then uses structuredClone
674
+ * to refuse Proxies. Hosts without that API refuse object capture. Only the
675
+ * owned frozen copy enters identity and the wrapper. Sealed, non-extensible,
676
+ * frozen and Immer ordinary data are supported equally. Unsupported values
677
+ * raise a TypeError naming the path. See core docs/api.md#nodecapture for the
678
+ * complete algorithm and the migration from original-object locking.
679
+ *
680
+ * @category constructors
681
+ * @since 0.1.0
682
+ * @slop
683
+ */
684
+ 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;
685
+ //# sourceMappingURL=Node.d.ts.map