deltafold 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -16
- package/dist/index.d.ts +188 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +268 -200
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/features/execution/executor.ts +296 -154
- package/src/features/execution/handler.ts +302 -74
- package/src/features/execution/settlement.ts +13 -10
package/README.md
CHANGED
|
@@ -127,24 +127,25 @@ ancestor, because its author asserts that it is equivalent.
|
|
|
127
127
|
|
|
128
128
|
## Run a plan with Promise handlers
|
|
129
129
|
|
|
130
|
-
Handlers bind to action instances. A
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
Handlers bind to action instances. A handler either applies its action
|
|
131
|
+
directly, or first runs a read-only `prepare` phase. `prepare` returns
|
|
132
|
+
`Handler.prepared(value)`, and `apply` then receives that value, or
|
|
133
|
+
`Handler.skip(reason)`, which skips the action and reports the reason. In this
|
|
134
|
+
example, `renameKey` and `fileExists` stand for your own file access.
|
|
133
135
|
|
|
134
136
|
```ts
|
|
135
137
|
import { Executor, Handler } from "deltafold";
|
|
136
138
|
|
|
137
139
|
const handlers = [
|
|
138
|
-
Handler.promise(
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
Handler.promise(renameTimeout, {
|
|
141
|
+
prepare: async ({ file }) =>
|
|
142
|
+
(await fileExists(file))
|
|
143
|
+
? Handler.prepared()
|
|
144
|
+
: Handler.skip("This project has no app.json"),
|
|
145
|
+
apply: async (_prepared, { payload: { file, from, to }, signal }) => {
|
|
141
146
|
await renameKey(file, from, to, { signal });
|
|
142
147
|
},
|
|
143
|
-
|
|
144
|
-
when: ({ file }) => fileExists(file),
|
|
145
|
-
skipReason: "This project has no app.json",
|
|
146
|
-
},
|
|
147
|
-
),
|
|
148
|
+
}),
|
|
148
149
|
];
|
|
149
150
|
|
|
150
151
|
try {
|
|
@@ -166,10 +167,10 @@ try {
|
|
|
166
167
|
the partial report.
|
|
167
168
|
- Nothing is rolled back and progress is not saved: running the plan again
|
|
168
169
|
repeats completed actions.
|
|
169
|
-
- `dryRun: true`
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
- `signal` cancels and `timeout` limits each
|
|
170
|
+
- `dryRun: true` runs `prepare` phases and never runs `apply`. A prepare phase
|
|
171
|
+
that may depend on an earlier action is reported `Undetermined`, because the
|
|
172
|
+
dry run does not apply that action.
|
|
173
|
+
- `signal` cancels and `timeout` limits each phase; both reject with
|
|
173
174
|
`ExecutionInterrupted`. Cancellation is cooperative: a callback that ignores
|
|
174
175
|
its signal can keep running after the run ends, and the report marks it as
|
|
175
176
|
possibly still running.
|
|
@@ -204,7 +205,10 @@ const report = await Effect.runPromise(
|
|
|
204
205
|
);
|
|
205
206
|
```
|
|
206
207
|
|
|
207
|
-
Here `configFiles` is your implementation of the service.
|
|
208
|
+
Here `configFiles` is your implementation of the service. `Handler.effect`
|
|
209
|
+
also accepts `{ prepare, apply }`. Both phases run in the action's own scope,
|
|
210
|
+
so a resource acquired in `prepare`, such as a lock, stays open until the
|
|
211
|
+
action ends. To cancel an Effect
|
|
208
212
|
execution, interrupt its fiber; it ends as interrupted, without a report.
|
|
209
213
|
|
|
210
214
|
The handler array must cover every action of the history: a missing handler is
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { _ as Any$1, a as Occurrence, c as shortcut_d_exports, g as change_d_exports, i as Coverage, l as rule_d_exports, n as package_d_exports, o as Plan, p as version_d_exports, r as history_d_exports, s as plan_d_exports, u as migration_d_exports, v as action_d_exports } from "./package-BfBYnaCz.js";
|
|
2
|
-
import { Cause, Context, Duration, Effect, Layer, Schema } from "effect";
|
|
2
|
+
import { Cause, Context, Duration, Effect, Layer, Schema, Scope } from "effect";
|
|
3
3
|
/** The union of an object type's property values. */
|
|
4
4
|
type ValueOf<T> = T[keyof T];
|
|
5
5
|
declare namespace handler_d_exports {
|
|
6
|
-
export { ActionId, Any,
|
|
6
|
+
export { ActionId, Any, EffectApplyContext, EffectPhases, Error, ErrorGuard, Handler, Phase, Preparation, Prepared, PromiseApplyContext, PromiseContext, PromiseOptions$1 as PromiseOptions, PromisePhases, ServiceMap, Services, Skip, Step, UnexpectedHandlerError, effect$1 as effect, isHandler, prepared, promise, skip };
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Where a handler failure happened
|
|
9
|
+
* Where a handler failure happened: the read-only prepare phase, or the apply phase that
|
|
10
|
+
* changes state.
|
|
10
11
|
*
|
|
11
12
|
* @since @next
|
|
12
13
|
*/
|
|
13
|
-
type Phase = "
|
|
14
|
+
type Phase = "prepare" | "apply";
|
|
14
15
|
declare const UnexpectedHandlerError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
15
16
|
readonly _tag: "UnexpectedHandlerError";
|
|
16
17
|
} & Readonly<A>;
|
|
17
18
|
/**
|
|
18
19
|
* A Promise handler rejected or threw a value that none of its declared error guards
|
|
19
|
-
* recognized.
|
|
20
|
+
* recognized, or its prepare phase returned something other than `Handler.prepared` or
|
|
21
|
+
* `Handler.skip`.
|
|
20
22
|
*
|
|
21
23
|
* @since @next
|
|
22
24
|
*/
|
|
@@ -28,22 +30,80 @@ declare class UnexpectedHandlerError extends UnexpectedHandlerError_base<{
|
|
|
28
30
|
}> {
|
|
29
31
|
get message(): string;
|
|
30
32
|
}
|
|
33
|
+
declare const PreparationTypeId = "~deltafold/Preparation";
|
|
34
|
+
/**
|
|
35
|
+
* A prepare phase decided to apply. The apply phase receives `value` unchanged; the
|
|
36
|
+
* executor never reads, validates, or serializes it.
|
|
37
|
+
*
|
|
38
|
+
* @since @next
|
|
39
|
+
*/
|
|
40
|
+
type Prepared<out P> = {
|
|
41
|
+
readonly [PreparationTypeId]: typeof PreparationTypeId;
|
|
42
|
+
readonly _tag: "Prepared";
|
|
43
|
+
readonly value: P;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A prepare phase decided that the action does not apply. The occurrence is skipped
|
|
47
|
+
* with `reason`.
|
|
48
|
+
*
|
|
49
|
+
* @since @next
|
|
50
|
+
*/
|
|
51
|
+
type Skip = {
|
|
52
|
+
readonly [PreparationTypeId]: typeof PreparationTypeId;
|
|
53
|
+
readonly _tag: "Skip";
|
|
54
|
+
readonly reason: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* What a prepare phase returns: `Handler.prepared(value)` or `Handler.skip(reason)`.
|
|
58
|
+
*
|
|
59
|
+
* @since @next
|
|
60
|
+
*/
|
|
61
|
+
type Preparation<P> = Prepared<P> | Skip;
|
|
62
|
+
/** The value that a prepare phase passes to its apply phase. */
|
|
63
|
+
type PreparedValue<T> = T extends Prepared<infer P> ? P : never;
|
|
64
|
+
/**
|
|
65
|
+
* Ends a prepare phase with the value its apply phase receives. Wrapping the value keeps
|
|
66
|
+
* it apart from a skip, whatever its shape.
|
|
67
|
+
*
|
|
68
|
+
* @since @next
|
|
69
|
+
*/
|
|
70
|
+
declare function prepared(): Prepared<void>;
|
|
71
|
+
declare function prepared<P>(value: P): Prepared<P>;
|
|
72
|
+
/**
|
|
73
|
+
* Ends a prepare phase by skipping the occurrence. The apply phase does not run.
|
|
74
|
+
*
|
|
75
|
+
* @since @next
|
|
76
|
+
*/
|
|
77
|
+
declare const skip: (reason: string) => Skip;
|
|
78
|
+
/**
|
|
79
|
+
* How an occurrence continues after its prepare phase: skipped, or applied by an effect
|
|
80
|
+
* that already holds the prepared value.
|
|
81
|
+
*
|
|
82
|
+
* @since @next
|
|
83
|
+
*/
|
|
84
|
+
type Step<E, R> = Skip | {
|
|
85
|
+
readonly _tag: "Apply";
|
|
86
|
+
readonly apply: Effect.Effect<void, E, R>;
|
|
87
|
+
};
|
|
31
88
|
declare const TypeId = "~deltafold/Handler";
|
|
32
89
|
/**
|
|
33
|
-
* Implements one action instance. `E` and `R` are the errors and Effect services of
|
|
34
|
-
*
|
|
90
|
+
* Implements one action instance. `E` and `R` are the errors and Effect services of both
|
|
91
|
+
* phases together. A prepared value stays inside the handler, so handlers with
|
|
92
|
+
* different prepared values share this type.
|
|
35
93
|
*
|
|
36
94
|
* @since @next
|
|
37
95
|
*/
|
|
38
96
|
type Handler<out A extends Any$1, out E = never, out R = never> = {
|
|
39
97
|
readonly [TypeId]: typeof TypeId;
|
|
40
98
|
readonly action: A;
|
|
41
|
-
/**
|
|
42
|
-
readonly
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
99
|
+
/** Whether the handler has a prepare phase. */
|
|
100
|
+
readonly prepares: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Runs the prepare phase, if any, and resolves to the next step. Both phases share
|
|
103
|
+
* `scope`, the occurrence's scope, so resources acquired while preparing stay open
|
|
104
|
+
* until the executor closes it after the occurrence ends.
|
|
105
|
+
*/
|
|
106
|
+
readonly prepare: (scope: Scope.Scope) => Effect.Effect<Step<E, R>, E, R>;
|
|
47
107
|
};
|
|
48
108
|
/**
|
|
49
109
|
* Any handler.
|
|
@@ -71,7 +131,6 @@ type Services<H> = H extends Handler<any, any, infer R> ? R : never;
|
|
|
71
131
|
type ActionId<H> = H extends Handler<infer A, any, any> ? A["id"] : never;
|
|
72
132
|
/** @since @next */
|
|
73
133
|
declare const isHandler: (value: unknown) => value is Any;
|
|
74
|
-
type SkipReason<P> = string | ((payload: P) => string);
|
|
75
134
|
/**
|
|
76
135
|
* Named Effect services that a Promise handler declares.
|
|
77
136
|
*
|
|
@@ -91,6 +150,26 @@ type PromiseContext<S extends ServiceMap = NoServices> = {
|
|
|
91
150
|
readonly signal: AbortSignal;
|
|
92
151
|
readonly services: { readonly [K in keyof S]: S[K]["Service"]; };
|
|
93
152
|
};
|
|
153
|
+
/**
|
|
154
|
+
* The second argument of a Promise apply phase: the Promise context and the action
|
|
155
|
+
* payload.
|
|
156
|
+
*
|
|
157
|
+
* @since @next
|
|
158
|
+
*/
|
|
159
|
+
type PromiseApplyContext<Payload, S extends ServiceMap = NoServices> = PromiseContext<S> & {
|
|
160
|
+
readonly payload: Payload;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* A Promise handler with a prepare phase. `prepare` reads state and returns
|
|
164
|
+
* `Handler.prepared(value)` or `Handler.skip(reason)`; `apply` receives the value. Each
|
|
165
|
+
* phase gets its own signal.
|
|
166
|
+
*
|
|
167
|
+
* @since @next
|
|
168
|
+
*/
|
|
169
|
+
type PromisePhases<Payload, T extends Preparation<unknown>, S extends ServiceMap> = {
|
|
170
|
+
readonly prepare: (payload: Payload, context: PromiseContext<S>) => PromiseLike<T> | T;
|
|
171
|
+
readonly apply: (prepared: PreparedValue<T>, context: PromiseApplyContext<Payload, S>) => PromiseLike<unknown>;
|
|
172
|
+
};
|
|
94
173
|
type ServiceIds<S extends ServiceMap> = ValueOf<{ [K in keyof S]: S[K] extends Context.Key<infer I, any> ? I : never; }>;
|
|
95
174
|
/**
|
|
96
175
|
* Recognizes a declared rejection: a schema, or a type guard such as an `instanceof`
|
|
@@ -102,7 +181,7 @@ type ServiceIds<S extends ServiceMap> = ValueOf<{ [K in keyof S]: S[K] extends C
|
|
|
102
181
|
type ErrorGuard = Schema.Top | ((cause: unknown) => cause is any);
|
|
103
182
|
type GuardedError<G> = G extends Schema.Top ? G["Type"] : G extends ((cause: unknown) => cause is infer E) ? E : never;
|
|
104
183
|
/** @since @next */
|
|
105
|
-
type PromiseOptions$1<
|
|
184
|
+
type PromiseOptions$1<S extends ServiceMap, G extends ReadonlyArray<ErrorGuard>> = {
|
|
106
185
|
/** Effect services resolved for the callbacks and added to the handler requirements. */
|
|
107
186
|
readonly services?: S;
|
|
108
187
|
/**
|
|
@@ -111,14 +190,15 @@ type PromiseOptions$1<P, S extends ServiceMap, G extends ReadonlyArray<ErrorGuar
|
|
|
111
190
|
* those errors.
|
|
112
191
|
*/
|
|
113
192
|
readonly errors?: G;
|
|
114
|
-
/** Read-only precondition. Returning `false` skips the occurrence. */
|
|
115
|
-
readonly when?: (payload: P, context: PromiseContext<S>) => boolean | PromiseLike<boolean>;
|
|
116
|
-
readonly skipReason?: SkipReason<P>;
|
|
117
193
|
};
|
|
194
|
+
type PromiseHandler<A extends Any$1, S extends ServiceMap, G> = Handler<A, GuardedError<G> | UnexpectedHandlerError, ServiceIds<S>>;
|
|
118
195
|
/**
|
|
119
196
|
* Implements an action with Promise callbacks. The callbacks run lazily through
|
|
120
|
-
* `Effect.tryPromise`, and receive its `AbortSignal` and the declared services
|
|
121
|
-
*
|
|
197
|
+
* `Effect.tryPromise`, and receive its `AbortSignal` and the declared services.
|
|
198
|
+
*
|
|
199
|
+
* Pass one callback to apply the action directly, or `{ prepare, apply }` to decide
|
|
200
|
+
* first. `prepare` must only read: a dry run calls it and never calls `apply`. A real
|
|
201
|
+
* run calls `apply` once with the prepared value.
|
|
122
202
|
*
|
|
123
203
|
* @example
|
|
124
204
|
* ```ts
|
|
@@ -131,22 +211,68 @@ type PromiseOptions$1<P, S extends ServiceMap, G extends ReadonlyArray<ErrorGuar
|
|
|
131
211
|
* );
|
|
132
212
|
* ```
|
|
133
213
|
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* Handler.promise(renameTimeout, {
|
|
217
|
+
* prepare: async ({ file, from }, { signal }) => {
|
|
218
|
+
* const config = await readConfig(file, { signal });
|
|
219
|
+
* return from in config ? Handler.prepared(config) : Handler.skip(`${file} has no ${from}`);
|
|
220
|
+
* },
|
|
221
|
+
* apply: async (config, { payload, signal }) => {
|
|
222
|
+
* await writeConfig(payload.file, rename(config, payload), { signal });
|
|
223
|
+
* },
|
|
224
|
+
* });
|
|
225
|
+
* ```
|
|
226
|
+
*
|
|
134
227
|
* @since @next
|
|
135
228
|
*/
|
|
136
|
-
declare
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
229
|
+
declare function promise<A extends Any$1, const S extends ServiceMap = NoServices, const G extends ReadonlyArray<ErrorGuard> = []>(action: A, apply: (payload: A["payload"], context: PromiseContext<S>) => PromiseLike<unknown>, options?: PromiseOptions$1<S, G>): PromiseHandler<A, S, G[number]>;
|
|
230
|
+
declare function promise<A extends Any$1, T extends Preparation<unknown> = Skip, const S extends ServiceMap = NoServices, const G extends ReadonlyArray<ErrorGuard> = []>(action: A, phases: PromisePhases<A["payload"], T, S>, options?: PromiseOptions$1<S, G>): PromiseHandler<A, S, G[number]>;
|
|
231
|
+
/**
|
|
232
|
+
* The second argument of an Effect apply phase.
|
|
233
|
+
*
|
|
234
|
+
* @since @next
|
|
235
|
+
*/
|
|
236
|
+
type EffectApplyContext<Payload> = {
|
|
237
|
+
readonly payload: Payload;
|
|
142
238
|
};
|
|
143
239
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
240
|
+
* An Effect handler with a prepare phase. `prepare` reads state and succeeds with
|
|
241
|
+
* `Handler.prepared(value)` or `Handler.skip(reason)`; `apply` receives the value.
|
|
146
242
|
*
|
|
147
243
|
* @since @next
|
|
148
244
|
*/
|
|
149
|
-
|
|
245
|
+
type EffectPhases<Payload, T extends Preparation<unknown>, E1, R1, E2, R2> = {
|
|
246
|
+
readonly prepare: (payload: Payload) => Effect.Effect<T, E1, R1>;
|
|
247
|
+
readonly apply: (prepared: PreparedValue<T>, context: EffectApplyContext<Payload>) => Effect.Effect<unknown, E2, R2>;
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Implements an action with an Effect. The handler keeps its own errors and services,
|
|
251
|
+
* and stops through native Effect interruption.
|
|
252
|
+
*
|
|
253
|
+
* Pass one function to apply the action directly, or `{ prepare, apply }` to decide
|
|
254
|
+
* first. `prepare` must only read: a dry run runs it and never runs `apply`. A real run
|
|
255
|
+
* runs `apply` once with the prepared value. Both phases run in the occurrence's
|
|
256
|
+
* `Scope`, so a resource acquired while preparing, such as a lock, stays open until the
|
|
257
|
+
* occurrence ends; the handler does not require `Scope`.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* Handler.effect(renameTimeout, {
|
|
262
|
+
* prepare: ({ file, from }) =>
|
|
263
|
+
* Effect.gen(function* () {
|
|
264
|
+
* const files = yield* ConfigFiles;
|
|
265
|
+
* const config = yield* files.lock(file);
|
|
266
|
+
* return from in config.data ? Handler.prepared(config) : Handler.skip(`${file} has no ${from}`);
|
|
267
|
+
* }),
|
|
268
|
+
* apply: (config, { payload }) => config.write(rename(config.data, payload)),
|
|
269
|
+
* });
|
|
270
|
+
* ```
|
|
271
|
+
*
|
|
272
|
+
* @since @next
|
|
273
|
+
*/
|
|
274
|
+
declare function effect$1<A extends Any$1, E = never, R = never>(action: A, apply: (payload: A["payload"]) => Effect.Effect<unknown, E, R>): Handler<A, E, Exclude<R, Scope.Scope>>;
|
|
275
|
+
declare function effect$1<A extends Any$1, T extends Preparation<unknown> = Skip, E1 = never, R1 = never, E2 = never, R2 = never>(action: A, phases: EffectPhases<A["payload"], T, E1, R1, E2, R2>): Handler<A, E1 | E2, Exclude<R1 | R2, Scope.Scope>>;
|
|
150
276
|
declare namespace executor_d_exports {
|
|
151
277
|
export { CoverageIssue, Errors, ExecutionError, ExecutionFailed, ExecutionInterrupted, HandlerCoverageError, InterruptReason, OccurrenceReport, Options, Outcome, PromiseOptions, Report, Requirements, Uncovered, effect, runPromise };
|
|
152
278
|
}
|
|
@@ -181,7 +307,9 @@ type Outcome<E = unknown> = {
|
|
|
181
307
|
/** Not started because execution stopped first. */
|
|
182
308
|
{
|
|
183
309
|
readonly _tag: "Unattempted";
|
|
184
|
-
} |
|
|
310
|
+
} |
|
|
311
|
+
/** `evaluated`: whether a prepare phase ran and decided to apply. */
|
|
312
|
+
{
|
|
185
313
|
readonly _tag: "WouldExecute";
|
|
186
314
|
readonly evaluated: boolean;
|
|
187
315
|
} | {
|
|
@@ -191,7 +319,7 @@ type Outcome<E = unknown> = {
|
|
|
191
319
|
readonly _tag: "Undetermined";
|
|
192
320
|
readonly reason: string;
|
|
193
321
|
} | {
|
|
194
|
-
readonly _tag: "
|
|
322
|
+
readonly _tag: "PreparationFailed";
|
|
195
323
|
readonly error: E | undefined;
|
|
196
324
|
readonly cause: Cause.Cause<E>;
|
|
197
325
|
};
|
|
@@ -210,7 +338,10 @@ type Report<A extends Any$1 = Any$1, E = unknown> = {
|
|
|
210
338
|
readonly route: string;
|
|
211
339
|
/** Every occurrence in plan order. */
|
|
212
340
|
readonly occurrences: ReadonlyArray<OccurrenceReport<A, E>>;
|
|
213
|
-
/**
|
|
341
|
+
/**
|
|
342
|
+
* Whether any apply phase started. A started apply phase may have partially changed
|
|
343
|
+
* state.
|
|
344
|
+
*/
|
|
214
345
|
readonly bodiesStarted: boolean;
|
|
215
346
|
/** Progress is not persisted. Rerunning the plan repeats completed actions. */
|
|
216
347
|
readonly persistence: "none";
|
|
@@ -238,10 +369,10 @@ declare const HandlerCoverageBase: new <A extends Record<string, any> = {}>(args
|
|
|
238
369
|
readonly _tag: "HandlerCoverageError";
|
|
239
370
|
} & Readonly<A>;
|
|
240
371
|
/**
|
|
241
|
-
* Handler coverage failed before any
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
372
|
+
* Handler coverage failed before any handler phase ran. Every occurrence needs exactly
|
|
373
|
+
* one handler, for the same action definition: the same identifier, kind, and payload.
|
|
374
|
+
* For an occurrence that a rule produced, the issue names the rule and the occurrences
|
|
375
|
+
* it replaced.
|
|
245
376
|
*
|
|
246
377
|
* @since @next
|
|
247
378
|
*/
|
|
@@ -316,14 +447,15 @@ type Requirements<H> = Services<H>;
|
|
|
316
447
|
type Options<H extends Any> = {
|
|
317
448
|
readonly handlers?: ReadonlyArray<H>;
|
|
318
449
|
/**
|
|
319
|
-
*
|
|
320
|
-
* depend on an earlier action is reported `Undetermined`, because the dry run does
|
|
321
|
-
* apply that action.
|
|
450
|
+
* Run prepare phases without running any apply phase. A prepare phase that may
|
|
451
|
+
* depend on an earlier action is reported `Undetermined`, because the dry run does
|
|
452
|
+
* not apply that action.
|
|
322
453
|
*/
|
|
323
454
|
readonly dryRun?: boolean;
|
|
324
455
|
/**
|
|
325
|
-
*
|
|
326
|
-
*
|
|
456
|
+
* Limit for each phase of an occurrence: the prepare phase and the apply phase each
|
|
457
|
+
* get the full limit. Exceeding it interrupts that action and stops admitting new
|
|
458
|
+
* ones. It applies to dry-run prepare phases too.
|
|
327
459
|
*/
|
|
328
460
|
readonly timeout?: Duration.Input;
|
|
329
461
|
/**
|
|
@@ -333,10 +465,15 @@ type Options<H extends Any> = {
|
|
|
333
465
|
readonly settleTimeout?: Duration.Input;
|
|
334
466
|
};
|
|
335
467
|
/**
|
|
336
|
-
* Runs a plan as an Effect. Coverage is checked before any
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
468
|
+
* Runs a plan as an Effect. Coverage is checked before any handler phase runs. Steps
|
|
469
|
+
* are sequential barriers; parallel groups run their branches concurrently. On failure,
|
|
470
|
+
* no new action starts, and actions already running settle before the effect fails
|
|
471
|
+
* with the partial report.
|
|
472
|
+
*
|
|
473
|
+
* Each occurrence has its own scope, shared by its phases and closed when it ends. An
|
|
474
|
+
* interrupted Promise that has not settled keeps its occurrence's scope open until it
|
|
475
|
+
* settles, after the effect has ended. Services that the caller provides stay the
|
|
476
|
+
* caller's to release.
|
|
340
477
|
*
|
|
341
478
|
* To cancel, interrupt the fiber. Interruption reaches running actions and aborts the
|
|
342
479
|
* signal passed to Promise callbacks. The effect then ends as interrupted, without a
|
|
@@ -366,10 +503,12 @@ type PromiseOptions<H extends Any> = Options<H> & {
|
|
|
366
503
|
* Building a supplied services layer can also reject with the layer's own error,
|
|
367
504
|
* without a report.
|
|
368
505
|
*
|
|
369
|
-
* A services layer is built for this run
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
506
|
+
* A services layer is built for this run. A services context stays owned by the
|
|
507
|
+
* caller. A Promise callback that ignores its signal can keep running after
|
|
508
|
+
* cancellation or a timeout, beyond `settleTimeout`; the report marks it as possibly
|
|
509
|
+
* still running. Its occurrence's scope and the run's services layer then stay open
|
|
510
|
+
* until it settles, possibly forever, and close in that order. A cleanup failure after
|
|
511
|
+
* the Promise resolved is logged through Effect.
|
|
373
512
|
*
|
|
374
513
|
* @since @next
|
|
375
514
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["Action.Any","PromiseOptions","effect","Handler.Phase","Action.Any","Plan.Coverage","Handler.ActionId","Handler.Error","Handler.Services","Handler.Any","Plan.Plan"],"sources":["../src/types.ts","../src/features/execution/handler.ts","../src/features/execution/executor.ts"],"mappings":";;;KACY,QAAQ,KAAK,QAAQ
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["Action.Any","PromiseOptions","effect","Handler.Phase","Action.Any","Plan.Coverage","Handler.ActionId","Handler.Error","Handler.Services","Handler.Any","Plan.Plan"],"sources":["../src/types.ts","../src/features/execution/handler.ts","../src/features/execution/executor.ts"],"mappings":";;;KACY,QAAQ,KAAK,QAAQ;;;;;;;;;;KCWrB;;;;;;;;;;;cASC,+BAA+B;WAClC;WACA;WACA,OAAO;WACP;;MAEI;;cAKR;;;;;;;KAQM,aAAa;YACd,2BAA2B;WAC5B;WACA,OAAO;;;;;;;;KASL;YACD,2BAA2B;WAC5B;WACA;;;;;;;KAQE,YAAY,KAAK,SAAS,KAAK;;KAGtC,cAAc,KAAK,UAAU,eAAe,KAAK;;;;;;;iBAQtC,YAAY;iBACZ,SAAS,GAAG,OAAO,IAAI,SAAS;;;;;;cAUnC,OAAI,mBAAqB;;;;;;;KAkB1B,KAAK,GAAG,KACjB;WACW;WAAwB,OAAO,OAAO,aAAa,GAAG;;cAO9D;;;;;;;;KASM,YAAY,UAAUA,WAAgB,eAAe;YACtD,gBAAgB;WACjB,QAAQ;;WAER;;;;;;WA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