deltafold 0.2.0 → 0.2.2
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 +33 -1
- package/dist/changelog.d.ts +10 -10
- package/dist/changelog.js +4 -4
- package/dist/changelog.js.map +1 -1
- package/dist/{document-BZcZo9nr.js → document-HfPyYxEd.js} +20 -20
- package/dist/{document-BZcZo9nr.js.map → document-HfPyYxEd.js.map} +1 -1
- package/dist/{document-DWHsgywm.d.ts → document-f2Zy7NQO.d.ts} +41 -41
- package/dist/{document-DWHsgywm.d.ts.map → document-f2Zy7NQO.d.ts.map} +1 -1
- package/dist/html.d.ts +2 -2
- package/dist/html.js +2 -2
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +437 -105
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +750 -273
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +2 -2
- package/dist/markdown.js.map +1 -1
- package/dist/{mdast-DiRsYwPU.js → mdast-Oqkh0Gs1.js} +2 -2
- package/dist/{mdast-DiRsYwPU.js.map → mdast-Oqkh0Gs1.js.map} +1 -1
- package/dist/{package-BfBYnaCz.d.ts → package-BsMlK5xD.d.ts} +126 -116
- package/dist/{package-BfBYnaCz.d.ts.map → package-BsMlK5xD.d.ts.map} +1 -1
- package/package.json +5 -5
- package/src/features/documents/changelog.ts +8 -8
- package/src/features/documents/document.ts +39 -39
- package/src/features/documents/index.ts +2 -2
- package/src/features/execution/executor.ts +485 -313
- package/src/features/execution/handler.ts +30 -30
- package/src/features/execution/interaction.ts +11 -11
- package/src/features/execution/observation.ts +489 -0
- package/src/features/execution/observer.ts +395 -0
- package/src/features/package.ts +13 -8
- package/src/features/planning/history.ts +10 -10
- package/src/features/planning/identifiers.ts +7 -4
- package/src/features/planning/resolve-error.ts +13 -13
- package/src/features/planning/resolve.ts +11 -4
- package/src/features/planning/validate.ts +1 -1
- package/src/foundation/action.ts +17 -17
- package/src/foundation/change.ts +10 -10
- package/src/foundation/instruction.ts +5 -5
- package/src/foundation/migration.ts +12 -12
- package/src/foundation/plan.ts +23 -18
- package/src/foundation/rule.ts +6 -6
- package/src/foundation/shortcut.ts +6 -6
- package/src/foundation/version.ts +6 -6
- package/src/index.ts +14 -12
- package/src/renderers/html.ts +1 -1
- package/src/renderers/markdown.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { Cause, Context, Duration, Effect, Layer, Schema, Scope } from "effect";
|
|
1
|
+
import { _ as change_d_exports, a as Direction, c as plan_d_exports, d as migration_d_exports, i as Coverage, l as shortcut_d_exports, m as version_d_exports, n as package_d_exports, o as Occurrence, r as history_d_exports, s as Plan, u as rule_d_exports, v as Any$3, y as action_d_exports } from "./package-BsMlK5xD.js";
|
|
2
|
+
import { Cause, Context, Duration, Effect, Exit, 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
|
/** Named Effect services that Promise callbacks declare. */
|
|
@@ -17,7 +17,7 @@ type ServiceIds$1<S extends ServiceMap$1> = ValueOf<{ [K in keyof S]: S[K] exten
|
|
|
17
17
|
type ErrorGuard$1 = Schema.Top | ((cause: unknown) => cause is any);
|
|
18
18
|
type GuardedError$1<G> = G extends Schema.Top ? G["Type"] : G extends ((cause: unknown) => cause is infer E) ? E : never;
|
|
19
19
|
declare namespace handler_d_exports {
|
|
20
|
-
export { ActionId, Any$
|
|
20
|
+
export { ActionId, Any$2 as Any, EffectApplyContext, EffectPhases, Error$1 as Error, ErrorGuard, Handler, ManualEffectOptions, ManualOptions, Performer, Phase, Preparation, Prepared, PromiseApplyContext, PromiseContext, PromiseOptions$2 as PromiseOptions, PromisePhases, ServiceMap, Services$2 as Services, Skip, Step, UnexpectedHandlerError, VerificationFailed, effect$3 as effect, isHandler, manual, manualEffect, prepared, promise$2 as promise, skip };
|
|
21
21
|
}
|
|
22
22
|
type NoServices = NoServices$1;
|
|
23
23
|
type ServiceIds<S extends ServiceMap> = ServiceIds$1<S>;
|
|
@@ -27,14 +27,14 @@ type GuardedError<G> = GuardedError$1<G>;
|
|
|
27
27
|
* apply phase that changes state. A manual handler has neither: the executor waits for a
|
|
28
28
|
* person in `confirmation`, then runs the handler's optional check in `verification`.
|
|
29
29
|
*
|
|
30
|
-
* @since
|
|
30
|
+
* @since 0.0.1
|
|
31
31
|
*/
|
|
32
32
|
type Phase = "prepare" | "apply" | "confirmation" | "verification";
|
|
33
33
|
/**
|
|
34
34
|
* Who performs an action: a handler's apply phase, or a person whose confirmation the
|
|
35
35
|
* executor waits for.
|
|
36
36
|
*
|
|
37
|
-
* @since
|
|
37
|
+
* @since 0.2.0
|
|
38
38
|
*/
|
|
39
39
|
type Performer = "automated" | "manual";
|
|
40
40
|
declare const VerificationFailed_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 & {
|
|
@@ -43,7 +43,7 @@ declare const VerificationFailed_base: new <A extends Record<string, any> = {}>(
|
|
|
43
43
|
/**
|
|
44
44
|
* A person confirmed manual work, and the handler's `verify` check returned `false`.
|
|
45
45
|
*
|
|
46
|
-
* @since
|
|
46
|
+
* @since 0.2.0
|
|
47
47
|
*/
|
|
48
48
|
declare class VerificationFailed extends VerificationFailed_base<{
|
|
49
49
|
readonly actionId: string;
|
|
@@ -59,7 +59,7 @@ declare const UnexpectedHandlerError_base: new <A extends Record<string, any> =
|
|
|
59
59
|
* recognized, or its prepare phase returned something other than `Handler.prepared` or
|
|
60
60
|
* `Handler.skip`.
|
|
61
61
|
*
|
|
62
|
-
* @since
|
|
62
|
+
* @since 0.0.1
|
|
63
63
|
*/
|
|
64
64
|
declare class UnexpectedHandlerError extends UnexpectedHandlerError_base<{
|
|
65
65
|
readonly actionId: string;
|
|
@@ -74,7 +74,7 @@ declare const PreparationTypeId = "~deltafold/Preparation";
|
|
|
74
74
|
* A prepare phase decided to apply. The apply phase receives `value` unchanged; the
|
|
75
75
|
* executor never reads, validates, or serializes it.
|
|
76
76
|
*
|
|
77
|
-
* @since
|
|
77
|
+
* @since 0.1.0
|
|
78
78
|
*/
|
|
79
79
|
type Prepared<out P> = {
|
|
80
80
|
readonly [PreparationTypeId]: typeof PreparationTypeId;
|
|
@@ -85,7 +85,7 @@ type Prepared<out P> = {
|
|
|
85
85
|
* A prepare phase decided that the action does not apply. The occurrence is skipped
|
|
86
86
|
* with `reason`.
|
|
87
87
|
*
|
|
88
|
-
* @since
|
|
88
|
+
* @since 0.1.0
|
|
89
89
|
*/
|
|
90
90
|
type Skip = {
|
|
91
91
|
readonly [PreparationTypeId]: typeof PreparationTypeId;
|
|
@@ -95,7 +95,7 @@ type Skip = {
|
|
|
95
95
|
/**
|
|
96
96
|
* What a prepare phase returns: `Handler.prepared(value)` or `Handler.skip(reason)`.
|
|
97
97
|
*
|
|
98
|
-
* @since
|
|
98
|
+
* @since 0.1.0
|
|
99
99
|
*/
|
|
100
100
|
type Preparation<P> = Prepared<P> | Skip;
|
|
101
101
|
/** The value that a prepare phase passes to its apply phase. */
|
|
@@ -104,14 +104,14 @@ type PreparedValue<T> = T extends Prepared<infer P> ? P : never;
|
|
|
104
104
|
* Ends a prepare phase with the value its apply phase receives. Wrapping the value keeps
|
|
105
105
|
* it apart from a skip, whatever its shape.
|
|
106
106
|
*
|
|
107
|
-
* @since
|
|
107
|
+
* @since 0.1.0
|
|
108
108
|
*/
|
|
109
109
|
declare function prepared(): Prepared<void>;
|
|
110
110
|
declare function prepared<P>(value: P): Prepared<P>;
|
|
111
111
|
/**
|
|
112
112
|
* Ends a prepare phase by skipping the occurrence. The apply phase does not run.
|
|
113
113
|
*
|
|
114
|
-
* @since
|
|
114
|
+
* @since 0.1.0
|
|
115
115
|
*/
|
|
116
116
|
declare const skip: (reason: string) => Skip;
|
|
117
117
|
/**
|
|
@@ -119,7 +119,7 @@ declare const skip: (reason: string) => Skip;
|
|
|
119
119
|
* that already holds the prepared value, or confirmed by a person. `verify` checks
|
|
120
120
|
* confirmed work and fails when the check does not pass.
|
|
121
121
|
*
|
|
122
|
-
* @since
|
|
122
|
+
* @since 0.1.0
|
|
123
123
|
*/
|
|
124
124
|
type Step<E, R> = Skip | {
|
|
125
125
|
readonly _tag: "Apply";
|
|
@@ -128,16 +128,16 @@ type Step<E, R> = Skip | {
|
|
|
128
128
|
readonly _tag: "Confirm";
|
|
129
129
|
readonly verify: Effect.Effect<void, E, R> | undefined;
|
|
130
130
|
};
|
|
131
|
-
declare const TypeId$
|
|
131
|
+
declare const TypeId$2 = "~deltafold/Handler";
|
|
132
132
|
/**
|
|
133
133
|
* Implements one action instance. `E` and `R` are the errors and Effect services of both
|
|
134
134
|
* phases together. A prepared value stays inside the handler, so handlers with
|
|
135
135
|
* different prepared values share this type.
|
|
136
136
|
*
|
|
137
|
-
* @since
|
|
137
|
+
* @since 0.0.1
|
|
138
138
|
*/
|
|
139
|
-
type Handler<out A extends Any$
|
|
140
|
-
readonly [TypeId$
|
|
139
|
+
type Handler<out A extends Any$3, out E = never, out R = never> = {
|
|
140
|
+
readonly [TypeId$2]: typeof TypeId$2;
|
|
141
141
|
readonly action: A;
|
|
142
142
|
/** A `manual` handler has no phases of its own: a person does the work. */
|
|
143
143
|
readonly performer: Performer;
|
|
@@ -153,47 +153,47 @@ type Handler<out A extends Any$2, out E = never, out R = never> = {
|
|
|
153
153
|
/**
|
|
154
154
|
* Any handler.
|
|
155
155
|
*
|
|
156
|
-
* @since
|
|
156
|
+
* @since 0.0.1
|
|
157
157
|
*/
|
|
158
|
-
type Any$
|
|
158
|
+
type Any$2 = Handler<Any$3, any, any>;
|
|
159
159
|
/**
|
|
160
160
|
* The errors of a handler or a union of handlers.
|
|
161
161
|
*
|
|
162
|
-
* @since
|
|
162
|
+
* @since 0.0.1
|
|
163
163
|
*/
|
|
164
164
|
type Error$1<H> = H extends Handler<any, infer E, any> ? E : never;
|
|
165
165
|
/**
|
|
166
166
|
* The Effect services of a handler or a union of handlers.
|
|
167
167
|
*
|
|
168
|
-
* @since
|
|
168
|
+
* @since 0.0.1
|
|
169
169
|
*/
|
|
170
|
-
type Services$
|
|
170
|
+
type Services$2<H> = H extends Handler<any, any, infer R> ? R : never;
|
|
171
171
|
/**
|
|
172
172
|
* The action identifiers implemented by a handler or a union of handlers.
|
|
173
173
|
*
|
|
174
|
-
* @since
|
|
174
|
+
* @since 0.0.1
|
|
175
175
|
*/
|
|
176
176
|
type ActionId<H> = H extends Handler<infer A, any, any> ? A["id"] : never;
|
|
177
|
-
/** @since
|
|
178
|
-
declare const isHandler: (value: unknown) => value is Any$
|
|
177
|
+
/** @since 0.0.1 */
|
|
178
|
+
declare const isHandler: (value: unknown) => value is Any$2;
|
|
179
179
|
/**
|
|
180
180
|
* Named Effect services that a Promise handler declares.
|
|
181
181
|
*
|
|
182
|
-
* @since
|
|
182
|
+
* @since 0.0.1
|
|
183
183
|
*/
|
|
184
184
|
type ServiceMap = ServiceMap$1;
|
|
185
185
|
/**
|
|
186
186
|
* The second argument of Promise handler callbacks: the `AbortSignal` that
|
|
187
187
|
* `Effect.tryPromise` aborts on interruption, and the declared services, resolved.
|
|
188
188
|
*
|
|
189
|
-
* @since
|
|
189
|
+
* @since 0.0.1
|
|
190
190
|
*/
|
|
191
191
|
type PromiseContext<S extends ServiceMap = NoServices> = PromiseContext$1<S>;
|
|
192
192
|
/**
|
|
193
193
|
* The second argument of a Promise apply phase: the Promise context and the action
|
|
194
194
|
* payload.
|
|
195
195
|
*
|
|
196
|
-
* @since
|
|
196
|
+
* @since 0.1.0
|
|
197
197
|
*/
|
|
198
198
|
type PromiseApplyContext<Payload, S extends ServiceMap = NoServices> = PromiseContext<S> & {
|
|
199
199
|
readonly payload: Payload;
|
|
@@ -203,7 +203,7 @@ type PromiseApplyContext<Payload, S extends ServiceMap = NoServices> = PromiseCo
|
|
|
203
203
|
* `Handler.prepared(value)` or `Handler.skip(reason)`; `apply` receives the value. Each
|
|
204
204
|
* phase gets its own signal.
|
|
205
205
|
*
|
|
206
|
-
* @since
|
|
206
|
+
* @since 0.1.0
|
|
207
207
|
*/
|
|
208
208
|
type PromisePhases<Payload, T extends Preparation<unknown>, S extends ServiceMap> = {
|
|
209
209
|
readonly prepare: (payload: Payload, context: PromiseContext<S>) => PromiseLike<T> | T;
|
|
@@ -214,10 +214,10 @@ type PromisePhases<Payload, T extends Preparation<unknown>, S extends ServiceMap
|
|
|
214
214
|
* check. Guards must declare their parameter type, for example
|
|
215
215
|
* `(cause: unknown): cause is NotFound => cause instanceof NotFound`.
|
|
216
216
|
*
|
|
217
|
-
* @since
|
|
217
|
+
* @since 0.0.1
|
|
218
218
|
*/
|
|
219
219
|
type ErrorGuard = ErrorGuard$1;
|
|
220
|
-
/** @since
|
|
220
|
+
/** @since 0.0.1 */
|
|
221
221
|
type PromiseOptions$2<S extends ServiceMap, G extends ReadonlyArray<ErrorGuard>> = {
|
|
222
222
|
/** Effect services resolved for the callbacks and added to the handler requirements. */
|
|
223
223
|
readonly services?: S;
|
|
@@ -228,7 +228,7 @@ type PromiseOptions$2<S extends ServiceMap, G extends ReadonlyArray<ErrorGuard>>
|
|
|
228
228
|
*/
|
|
229
229
|
readonly errors?: G;
|
|
230
230
|
};
|
|
231
|
-
type PromiseHandler<A extends Any$
|
|
231
|
+
type PromiseHandler<A extends Any$3, S extends ServiceMap, G> = Handler<A, GuardedError<G> | UnexpectedHandlerError, ServiceIds<S>>;
|
|
232
232
|
/**
|
|
233
233
|
* Implements an action with Promise callbacks. The callbacks run lazily through
|
|
234
234
|
* `Effect.tryPromise`, and receive its `AbortSignal` and the declared services.
|
|
@@ -261,14 +261,14 @@ type PromiseHandler<A extends Any$2, S extends ServiceMap, G> = Handler<A, Guard
|
|
|
261
261
|
* });
|
|
262
262
|
* ```
|
|
263
263
|
*
|
|
264
|
-
* @since
|
|
264
|
+
* @since 0.0.1
|
|
265
265
|
*/
|
|
266
|
-
declare function promise$
|
|
267
|
-
declare function promise$
|
|
266
|
+
declare function promise$2<A extends Any$3, const S extends ServiceMap = NoServices, const G extends ReadonlyArray<ErrorGuard> = []>(action: A, apply: (payload: A["payload"], context: PromiseContext<S>) => PromiseLike<unknown>, options?: PromiseOptions$2<S, G>): PromiseHandler<A, S, G[number]>;
|
|
267
|
+
declare function promise$2<A extends Any$3, 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$2<S, G>): PromiseHandler<A, S, G[number]>;
|
|
268
268
|
/**
|
|
269
269
|
* The second argument of an Effect apply phase.
|
|
270
270
|
*
|
|
271
|
-
* @since
|
|
271
|
+
* @since 0.1.0
|
|
272
272
|
*/
|
|
273
273
|
type EffectApplyContext<Payload> = {
|
|
274
274
|
readonly payload: Payload;
|
|
@@ -277,7 +277,7 @@ type EffectApplyContext<Payload> = {
|
|
|
277
277
|
* An Effect handler with a prepare phase. `prepare` reads state and succeeds with
|
|
278
278
|
* `Handler.prepared(value)` or `Handler.skip(reason)`; `apply` receives the value.
|
|
279
279
|
*
|
|
280
|
-
* @since
|
|
280
|
+
* @since 0.1.0
|
|
281
281
|
*/
|
|
282
282
|
type EffectPhases<Payload, T extends Preparation<unknown>, E1, R1, E2, R2> = {
|
|
283
283
|
readonly prepare: (payload: Payload) => Effect.Effect<T, E1, R1>;
|
|
@@ -306,11 +306,11 @@ type EffectPhases<Payload, T extends Preparation<unknown>, E1, R1, E2, R2> = {
|
|
|
306
306
|
* });
|
|
307
307
|
* ```
|
|
308
308
|
*
|
|
309
|
-
* @since
|
|
309
|
+
* @since 0.0.1
|
|
310
310
|
*/
|
|
311
|
-
declare function effect$
|
|
312
|
-
declare function effect$
|
|
313
|
-
/** @since
|
|
311
|
+
declare function effect$3<A extends Any$3, E = never, R = never>(action: A, apply: (payload: A["payload"]) => Effect.Effect<unknown, E, R>): Handler<A, E, Exclude<R, Scope.Scope>>;
|
|
312
|
+
declare function effect$3<A extends Any$3, 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>>;
|
|
313
|
+
/** @since 0.2.0 */
|
|
314
314
|
type ManualOptions<Payload, S extends ServiceMap, G extends ReadonlyArray<ErrorGuard>> = {
|
|
315
315
|
/** Effect services resolved for `verify` and added to the handler requirements. */
|
|
316
316
|
readonly services?: S;
|
|
@@ -341,11 +341,11 @@ type ManualOptions<Payload, S extends ServiceMap, G extends ReadonlyArray<ErrorG
|
|
|
341
341
|
* });
|
|
342
342
|
* ```
|
|
343
343
|
*
|
|
344
|
-
* @since
|
|
344
|
+
* @since 0.2.0
|
|
345
345
|
*/
|
|
346
|
-
declare function manual<A extends Any$
|
|
347
|
-
declare function manual<A extends Any$
|
|
348
|
-
/** @since
|
|
346
|
+
declare function manual<A extends Any$3>(action: A): Handler<A>;
|
|
347
|
+
declare function manual<A extends Any$3, const S extends ServiceMap = NoServices, const G extends ReadonlyArray<ErrorGuard> = []>(action: A, options: ManualOptions<A["payload"], S, G>): Handler<A, GuardedError<G[number]> | UnexpectedHandlerError | VerificationFailed, ServiceIds<S>>;
|
|
348
|
+
/** @since 0.2.0 */
|
|
349
349
|
type ManualEffectOptions<Payload, E, R> = {
|
|
350
350
|
/**
|
|
351
351
|
* Read-only check that runs after the person confirms. Succeeding with `false` fails
|
|
@@ -357,27 +357,27 @@ type ManualEffectOptions<Payload, E, R> = {
|
|
|
357
357
|
* `Handler.manual` with an Effect `verify` check, which keeps its own errors and
|
|
358
358
|
* services.
|
|
359
359
|
*
|
|
360
|
-
* @since
|
|
360
|
+
* @since 0.2.0
|
|
361
361
|
*/
|
|
362
|
-
declare function manualEffect<A extends Any$
|
|
363
|
-
declare function manualEffect<A extends Any$
|
|
362
|
+
declare function manualEffect<A extends Any$3>(action: A): Handler<A>;
|
|
363
|
+
declare function manualEffect<A extends Any$3, E = never, R = never>(action: A, options: ManualEffectOptions<A["payload"], E, R>): Handler<A, E | VerificationFailed, Exclude<R, Scope.Scope>>;
|
|
364
364
|
declare namespace interaction_d_exports {
|
|
365
|
-
export { Answer, Any, Error, Interaction, PromiseOptions$1 as PromiseOptions, Request, Services, UnexpectedInteractionError, effect$
|
|
365
|
+
export { Answer, Any$1 as Any, Error, Interaction, PromiseOptions$1 as PromiseOptions, Request, Services$1 as Services, UnexpectedInteractionError, effect$2 as effect, isInteraction, promise$1 as promise };
|
|
366
366
|
}
|
|
367
367
|
/**
|
|
368
368
|
* What a person says about manual work. There is no other answer: free-form input never
|
|
369
369
|
* reaches a report.
|
|
370
370
|
*
|
|
371
|
-
* @since
|
|
371
|
+
* @since 0.2.0
|
|
372
372
|
*/
|
|
373
373
|
type Answer = "confirmed" | "declined";
|
|
374
374
|
/**
|
|
375
375
|
* A request to confirm manual work. The occurrence carries the action, its description,
|
|
376
376
|
* and the migration instruction that declared it, which is what to show the person.
|
|
377
377
|
*
|
|
378
|
-
* @since
|
|
378
|
+
* @since 0.2.0
|
|
379
379
|
*/
|
|
380
|
-
type Request<A extends Any$
|
|
380
|
+
type Request<A extends Any$3 = Any$3> = {
|
|
381
381
|
readonly occurrence: Occurrence<A>;
|
|
382
382
|
};
|
|
383
383
|
declare const UnexpectedInteractionError_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 & {
|
|
@@ -389,7 +389,7 @@ declare const UnexpectedInteractionError_base: new <A extends Record<string, any
|
|
|
389
389
|
* `"confirmed"` or `"declined"` (`invalid-answer`). An invalid answer is never kept: it
|
|
390
390
|
* may be text that the person typed.
|
|
391
391
|
*
|
|
392
|
-
* @since
|
|
392
|
+
* @since 0.2.0
|
|
393
393
|
*/
|
|
394
394
|
declare class UnexpectedInteractionError extends UnexpectedInteractionError_base<{
|
|
395
395
|
readonly occurrenceId: string;
|
|
@@ -399,7 +399,7 @@ declare class UnexpectedInteractionError extends UnexpectedInteractionError_base
|
|
|
399
399
|
}> {
|
|
400
400
|
get message(): string;
|
|
401
401
|
}
|
|
402
|
-
declare const TypeId = "~deltafold/Interaction";
|
|
402
|
+
declare const TypeId$1 = "~deltafold/Interaction";
|
|
403
403
|
/**
|
|
404
404
|
* Asks a person to confirm the manual work of a plan. The executor has no terminal or
|
|
405
405
|
* user interface of its own: the consumer running the plan supplies one of these.
|
|
@@ -408,33 +408,33 @@ declare const TypeId = "~deltafold/Interaction";
|
|
|
408
408
|
* serializes its own prompts. A failure or a decline elsewhere stops new actions but
|
|
409
409
|
* does not withdraw a request that was already made; only cancellation does.
|
|
410
410
|
*
|
|
411
|
-
* @since
|
|
411
|
+
* @since 0.2.0
|
|
412
412
|
*/
|
|
413
413
|
type Interaction<out E = never, out R = never> = {
|
|
414
|
-
readonly [TypeId]: typeof TypeId;
|
|
414
|
+
readonly [TypeId$1]: typeof TypeId$1;
|
|
415
415
|
readonly confirm: (request: Request) => Effect.Effect<Answer, E, R>;
|
|
416
416
|
};
|
|
417
417
|
/**
|
|
418
418
|
* Any interaction.
|
|
419
419
|
*
|
|
420
|
-
* @since
|
|
420
|
+
* @since 0.2.0
|
|
421
421
|
*/
|
|
422
|
-
type Any = Interaction<any, any>;
|
|
422
|
+
type Any$1 = Interaction<any, any>;
|
|
423
423
|
/**
|
|
424
424
|
* The errors of an interaction.
|
|
425
425
|
*
|
|
426
|
-
* @since
|
|
426
|
+
* @since 0.2.0
|
|
427
427
|
*/
|
|
428
428
|
type Error<I> = I extends Interaction<infer E, any> ? E : never;
|
|
429
429
|
/**
|
|
430
430
|
* The Effect services of an interaction.
|
|
431
431
|
*
|
|
432
|
-
* @since
|
|
432
|
+
* @since 0.2.0
|
|
433
433
|
*/
|
|
434
|
-
type Services<I> = I extends Interaction<any, infer R> ? R : never;
|
|
435
|
-
/** @since
|
|
436
|
-
declare const isInteraction: (value: unknown) => value is Any;
|
|
437
|
-
/** @since
|
|
434
|
+
type Services$1<I> = I extends Interaction<any, infer R> ? R : never;
|
|
435
|
+
/** @since 0.2.0 */
|
|
436
|
+
declare const isInteraction: (value: unknown) => value is Any$1;
|
|
437
|
+
/** @since 0.2.0 */
|
|
438
438
|
type PromiseOptions$1<S extends ServiceMap$1, G extends ReadonlyArray<ErrorGuard$1>> = {
|
|
439
439
|
/** Effect services resolved for the callback and added to the run's requirements. */
|
|
440
440
|
readonly services?: S;
|
|
@@ -459,23 +459,344 @@ type PromiseOptions$1<S extends ServiceMap$1, G extends ReadonlyArray<ErrorGuard
|
|
|
459
459
|
* );
|
|
460
460
|
* ```
|
|
461
461
|
*
|
|
462
|
-
* @since
|
|
462
|
+
* @since 0.2.0
|
|
463
463
|
*/
|
|
464
|
-
declare const promise: <const S extends ServiceMap$1 = NoServices$1, const G extends ReadonlyArray<ErrorGuard$1> = []>(confirm: (request: Request, context: PromiseContext$1<S>) => PromiseLike<Answer>, options?: PromiseOptions$1<S, G>) => Interaction<GuardedError$1<G[number]> | UnexpectedInteractionError, ServiceIds$1<S>>;
|
|
464
|
+
declare const promise$1: <const S extends ServiceMap$1 = NoServices$1, const G extends ReadonlyArray<ErrorGuard$1> = []>(confirm: (request: Request, context: PromiseContext$1<S>) => PromiseLike<Answer>, options?: PromiseOptions$1<S, G>) => Interaction<GuardedError$1<G[number]> | UnexpectedInteractionError, ServiceIds$1<S>>;
|
|
465
465
|
/**
|
|
466
466
|
* Confirms manual work with an Effect, which keeps its own errors and services and
|
|
467
467
|
* stops through Effect interruption when the run is cancelled.
|
|
468
468
|
*
|
|
469
|
-
* @since
|
|
469
|
+
* @since 0.2.0
|
|
470
|
+
*/
|
|
471
|
+
declare const effect$2: <E = never, R = never>(confirm: (request: Request) => Effect.Effect<Answer, E, R>) => Interaction<E | UnexpectedInteractionError, R>;
|
|
472
|
+
declare namespace observer_d_exports {
|
|
473
|
+
export { ActionInfo, ActionPhaseStarted, ActionSettled, Any, Counts, Event, ObservationFailure, Observer, OutcomeSummary, Progress, Run, RunFinished, RunStarted, Services, StepInfo, StepSettled, StepStarted, effect$1 as effect, isObserver, promise, sync };
|
|
474
|
+
}
|
|
475
|
+
declare const TypeId = "~deltafold/Observer";
|
|
476
|
+
/**
|
|
477
|
+
* The run that emitted an event.
|
|
478
|
+
*
|
|
479
|
+
* @since 0.2.1
|
|
480
|
+
*/
|
|
481
|
+
type Run = {
|
|
482
|
+
/** The `runId` passed to the executor, if any. Shared observers use it to tell runs apart. */
|
|
483
|
+
readonly id: string | undefined;
|
|
484
|
+
readonly mode: Report["mode"];
|
|
485
|
+
readonly from: string;
|
|
486
|
+
readonly to: string;
|
|
487
|
+
readonly route: string;
|
|
488
|
+
};
|
|
489
|
+
/**
|
|
490
|
+
* Counters at the moment an event was emitted. Counters never decrease during a run.
|
|
491
|
+
*
|
|
492
|
+
* @since 0.2.1
|
|
493
|
+
*/
|
|
494
|
+
type Progress = {
|
|
495
|
+
/** Steps with actions and prose-only steps. Omitted steps are not counted. */
|
|
496
|
+
readonly steps: {
|
|
497
|
+
readonly total: number;
|
|
498
|
+
readonly finished: number;
|
|
499
|
+
};
|
|
500
|
+
readonly actions: {
|
|
501
|
+
readonly total: number;
|
|
502
|
+
/** Occurrences whose prepare or apply phase has started and that have not settled. */
|
|
503
|
+
readonly running: number;
|
|
504
|
+
readonly finished: number;
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* One step of the route, as observers see it.
|
|
509
|
+
*
|
|
510
|
+
* - `execute`: the step has actions after optimization.
|
|
511
|
+
* - `prose`: the step has instruction prose but no actions. The executor runs nothing
|
|
512
|
+
* for it and does not wait at it.
|
|
513
|
+
* - `omitted`: a noop, or a step whose actions rules removed or moved into another step.
|
|
514
|
+
*
|
|
515
|
+
* @since 0.2.1
|
|
516
|
+
*/
|
|
517
|
+
type StepInfo = {
|
|
518
|
+
/** The plan step's `id`. */
|
|
519
|
+
readonly id: string;
|
|
520
|
+
/** Position in `plan.steps`, including omitted steps. */
|
|
521
|
+
readonly index: number;
|
|
522
|
+
readonly migration: string;
|
|
523
|
+
readonly direction: Direction;
|
|
524
|
+
readonly from: string;
|
|
525
|
+
readonly to: string;
|
|
526
|
+
/** Occurrence identifiers of the step, in plan order. */
|
|
527
|
+
readonly occurrences: ReadonlyArray<string>;
|
|
528
|
+
/**
|
|
529
|
+
* Other steps whose declared actions this step's replacements stand for. Running this
|
|
530
|
+
* step performs work that those steps declared.
|
|
531
|
+
*/
|
|
532
|
+
readonly absorbs: ReadonlyArray<string>;
|
|
533
|
+
} & ({
|
|
534
|
+
readonly kind: "execute" | "prose";
|
|
535
|
+
} | {
|
|
536
|
+
readonly kind: "omitted";
|
|
537
|
+
readonly reason: "noop" | "all-actions-removed";
|
|
538
|
+
});
|
|
539
|
+
/**
|
|
540
|
+
* One occurrence of the plan, as observers see it.
|
|
541
|
+
*
|
|
542
|
+
* @since 0.2.1
|
|
543
|
+
*/
|
|
544
|
+
type ActionInfo = {
|
|
545
|
+
readonly occurrence: string;
|
|
546
|
+
readonly action: string;
|
|
547
|
+
readonly kind: string;
|
|
548
|
+
readonly description: string;
|
|
549
|
+
readonly migration: string;
|
|
550
|
+
readonly direction: Direction;
|
|
551
|
+
/** The step that runs the occurrence. */
|
|
552
|
+
readonly step: string;
|
|
553
|
+
readonly origin: {
|
|
554
|
+
readonly _tag: "Declared";
|
|
555
|
+
} | {
|
|
556
|
+
readonly _tag: "Replacement";
|
|
557
|
+
readonly rule: string;
|
|
558
|
+
/** Identifiers of the replaced occurrences, in order. */
|
|
559
|
+
readonly replaces: ReadonlyArray<string>;
|
|
560
|
+
};
|
|
561
|
+
/** Steps that declared the actions behind this occurrence, in plan order. */
|
|
562
|
+
readonly sources: ReadonlyArray<string>;
|
|
563
|
+
};
|
|
564
|
+
/**
|
|
565
|
+
* An outcome as observers see it. Each variant lists its fields explicitly, so a field
|
|
566
|
+
* added to the report's outcome never reaches observers unreviewed. A failure keeps only
|
|
567
|
+
* the error's string `_tag`; the full error is in the execution's report.
|
|
568
|
+
*
|
|
569
|
+
* @since 0.2.1
|
|
570
|
+
*/
|
|
571
|
+
type OutcomeSummary = {
|
|
572
|
+
readonly _tag: "Completed";
|
|
573
|
+
readonly performer: "automated";
|
|
574
|
+
} | {
|
|
575
|
+
readonly _tag: "Completed";
|
|
576
|
+
readonly performer: "manual";
|
|
577
|
+
readonly confirmation: "asserted" | "verified";
|
|
578
|
+
} | {
|
|
579
|
+
readonly _tag: "Skipped";
|
|
580
|
+
readonly reason: string;
|
|
581
|
+
} | {
|
|
582
|
+
readonly _tag: "Declined";
|
|
583
|
+
} | {
|
|
584
|
+
readonly _tag: "Failed";
|
|
585
|
+
readonly phase: Phase;
|
|
586
|
+
readonly errorTag: string | undefined;
|
|
587
|
+
} | {
|
|
588
|
+
readonly _tag: "Interrupted";
|
|
589
|
+
readonly phase: Phase;
|
|
590
|
+
readonly reason: InterruptReason;
|
|
591
|
+
readonly settled: boolean;
|
|
592
|
+
} | {
|
|
593
|
+
readonly _tag: "Unattempted";
|
|
594
|
+
} | {
|
|
595
|
+
readonly _tag: "WouldExecute";
|
|
596
|
+
readonly evaluated: boolean;
|
|
597
|
+
readonly performer: Performer;
|
|
598
|
+
} | {
|
|
599
|
+
readonly _tag: "WouldSkip";
|
|
600
|
+
readonly reason: string;
|
|
601
|
+
} | {
|
|
602
|
+
readonly _tag: "Undetermined";
|
|
603
|
+
readonly reason: string;
|
|
604
|
+
readonly performer: Performer;
|
|
605
|
+
} | {
|
|
606
|
+
readonly _tag: "PreparationFailed";
|
|
607
|
+
readonly errorTag: string | undefined;
|
|
608
|
+
};
|
|
609
|
+
/**
|
|
610
|
+
* Occurrences by outcome tag. `unsettled` counts interrupted occurrences that may still be
|
|
611
|
+
* running.
|
|
612
|
+
*
|
|
613
|
+
* @since 0.2.1
|
|
614
|
+
*/
|
|
615
|
+
type Counts = { readonly [K in Outcome["_tag"]]: number; } & {
|
|
616
|
+
readonly unsettled: number;
|
|
617
|
+
};
|
|
618
|
+
type Base = {
|
|
619
|
+
readonly run: Run;
|
|
620
|
+
/** Position of the event in its run, starting at 0. */
|
|
621
|
+
readonly seq: number;
|
|
622
|
+
/** Milliseconds since the Unix epoch, from Effect's `Clock`. */
|
|
623
|
+
readonly timestamp: number;
|
|
624
|
+
readonly progress: Progress;
|
|
625
|
+
};
|
|
626
|
+
/**
|
|
627
|
+
* The run is starting: every action has a handler, and manual work has an interaction to
|
|
628
|
+
* ask with. A run that fails either check emits no events. Lists every step of the route,
|
|
629
|
+
* including omitted ones.
|
|
630
|
+
*
|
|
631
|
+
* @since 0.2.1
|
|
632
|
+
*/
|
|
633
|
+
type RunStarted = Base & {
|
|
634
|
+
readonly _tag: "RunStarted";
|
|
635
|
+
readonly steps: ReadonlyArray<StepInfo>;
|
|
636
|
+
};
|
|
637
|
+
/** @since 0.2.1 */
|
|
638
|
+
type StepStarted = Base & {
|
|
639
|
+
readonly _tag: "StepStarted";
|
|
640
|
+
readonly step: StepInfo;
|
|
641
|
+
};
|
|
642
|
+
/**
|
|
643
|
+
* A phase of an occurrence started: its prepare or apply phase, the confirmation of
|
|
644
|
+
* manual work, or its verification. `prepare` appears only for handlers that have a
|
|
645
|
+
* prepare phase. `confirmation` means the run is waiting for a person. An occurrence
|
|
646
|
+
* emits this once per phase that starts.
|
|
647
|
+
*
|
|
648
|
+
* @since 0.2.1
|
|
649
|
+
*/
|
|
650
|
+
type ActionPhaseStarted = Base & {
|
|
651
|
+
readonly _tag: "ActionPhaseStarted";
|
|
652
|
+
readonly action: ActionInfo;
|
|
653
|
+
readonly phase: Phase;
|
|
654
|
+
};
|
|
655
|
+
/**
|
|
656
|
+
* An occurrence has its final outcome. Emitted once for each occurrence whose outcome is
|
|
657
|
+
* known, and as `Unattempted` for an occurrence that started but stopped before applying
|
|
658
|
+
* or asking. It arrives after the occurrence's scope has closed, except when an
|
|
659
|
+
* interrupted Promise has not settled: then the scope stays open until it does, the
|
|
660
|
+
* reported outcome is already final, and a later cleanup failure is only logged. Dry-run
|
|
661
|
+
* outcomes that need no prepare phase arrive without a start.
|
|
662
|
+
*
|
|
663
|
+
* @since 0.2.1
|
|
664
|
+
*/
|
|
665
|
+
type ActionSettled = Base & {
|
|
666
|
+
readonly _tag: "ActionSettled";
|
|
667
|
+
readonly action: ActionInfo;
|
|
668
|
+
readonly outcome: OutcomeSummary;
|
|
669
|
+
};
|
|
670
|
+
/**
|
|
671
|
+
* A started step ended. `counts` covers the step's occurrences.
|
|
672
|
+
*
|
|
673
|
+
* @since 0.2.1
|
|
674
|
+
*/
|
|
675
|
+
type StepSettled = Base & {
|
|
676
|
+
readonly _tag: "StepSettled";
|
|
677
|
+
readonly step: StepInfo;
|
|
678
|
+
readonly counts: Counts;
|
|
679
|
+
};
|
|
680
|
+
/**
|
|
681
|
+
* The run ended. `status` and `counts` match the execution's report. When the fiber of
|
|
682
|
+
* `Executor.effect` is interrupted, there is no report: `report` is `false`, the status is
|
|
683
|
+
* `"interrupted"`, and running occurrences count as unsettled interruptions. If the
|
|
684
|
+
* interruption cuts short the delivery of `RunFinished`, the observers that had not yet
|
|
685
|
+
* received it get the report-less one with the same `seq`, so each observer receives
|
|
686
|
+
* exactly one.
|
|
687
|
+
*
|
|
688
|
+
* @since 0.2.1
|
|
689
|
+
*/
|
|
690
|
+
type RunFinished = Base & {
|
|
691
|
+
readonly _tag: "RunFinished";
|
|
692
|
+
readonly status: Report["status"];
|
|
693
|
+
readonly counts: Counts;
|
|
694
|
+
readonly report: boolean;
|
|
695
|
+
};
|
|
696
|
+
/**
|
|
697
|
+
* What an observer receives. A run emits `RunStarted`; then, for each step that is not
|
|
698
|
+
* omitted, `StepStarted`, an `ActionPhaseStarted` for each phase that starts, an
|
|
699
|
+
* `ActionSettled` for each occurrence, and `StepSettled`; and finally `RunFinished`. Action
|
|
700
|
+
* events of parallel branches interleave.
|
|
701
|
+
*
|
|
702
|
+
* Events carry identifiers and plain data, never payloads, errors, or causes. Action
|
|
703
|
+
* descriptions are included, so they must not contain secrets.
|
|
704
|
+
*
|
|
705
|
+
* @since 0.2.1
|
|
706
|
+
*/
|
|
707
|
+
type Event = RunStarted | StepStarted | ActionPhaseStarted | ActionSettled | StepSettled | RunFinished;
|
|
708
|
+
/**
|
|
709
|
+
* An observer that failed, or that was abandoned after cancellation or a timeout because
|
|
710
|
+
* it did not finish within the settlement grace period. An abandoned callback is
|
|
711
|
+
* interrupted but not awaited, so one that cannot be interrupted may keep running. The
|
|
712
|
+
* cause can hold arbitrary values, so do not serialize it as a whole.
|
|
713
|
+
*
|
|
714
|
+
* @since 0.2.1
|
|
470
715
|
*/
|
|
471
|
-
|
|
716
|
+
type ObservationFailure = {
|
|
717
|
+
/** Position of the observer in the `observers` array. */
|
|
718
|
+
readonly observer: number;
|
|
719
|
+
readonly event: Event["_tag"];
|
|
720
|
+
readonly seq: number;
|
|
721
|
+
readonly reason: "failed" | "abandoned";
|
|
722
|
+
readonly cause: Cause.Cause<unknown>;
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* Receives the events of a run. Pass observers to the executor's `observers` option. `R`
|
|
726
|
+
* is the Effect services an observer requires, which become requirements of the execution.
|
|
727
|
+
*
|
|
728
|
+
* The executor delivers one event at a time, to each observer in array order, and waits
|
|
729
|
+
* for each delivery before it continues, so every observer sees the same order. After
|
|
730
|
+
* cancellation or a timeout, each delivery waits at most `settleTimeout` and is then
|
|
731
|
+
* abandoned. A failed or abandoned delivery is listed in the report's `observation` and
|
|
732
|
+
* never changes an outcome. Observers only receive events: they cannot answer a manual
|
|
733
|
+
* confirmation.
|
|
734
|
+
*
|
|
735
|
+
* @since 0.2.1
|
|
736
|
+
*/
|
|
737
|
+
type Observer<out R = never> = {
|
|
738
|
+
readonly [TypeId]: typeof TypeId;
|
|
739
|
+
/** Delivers one event and captures how the delivery ended. It never fails. */
|
|
740
|
+
readonly notify: (event: Event) => Effect.Effect<Exit.Exit<unknown, unknown>, never, R>;
|
|
741
|
+
};
|
|
742
|
+
/**
|
|
743
|
+
* Any observer.
|
|
744
|
+
*
|
|
745
|
+
* @since 0.2.1
|
|
746
|
+
*/
|
|
747
|
+
type Any = Observer<any>;
|
|
748
|
+
/**
|
|
749
|
+
* The Effect services of an observer or a union of observers.
|
|
750
|
+
*
|
|
751
|
+
* @since 0.2.1
|
|
752
|
+
*/
|
|
753
|
+
type Services<O> = O extends Observer<infer R> ? R : never;
|
|
754
|
+
/** @since 0.2.1 */
|
|
755
|
+
declare const isObserver: (value: unknown) => value is Any;
|
|
756
|
+
/**
|
|
757
|
+
* Observes with a synchronous callback. A thrown value is recorded as an observation
|
|
758
|
+
* failure.
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* ```ts
|
|
762
|
+
* Observer.sync((event) => {
|
|
763
|
+
* if (event._tag === "ActionSettled") console.error(event.action.occurrence, event.outcome._tag);
|
|
764
|
+
* });
|
|
765
|
+
* ```
|
|
766
|
+
*
|
|
767
|
+
* @since 0.2.1
|
|
768
|
+
*/
|
|
769
|
+
declare const sync: (callback: (event: Event) => void) => Observer;
|
|
770
|
+
/**
|
|
771
|
+
* Observes with a Promise callback. The executor waits for the Promise. The `signal`
|
|
772
|
+
* aborts when the executor stops waiting: after cancellation or a timeout, once the
|
|
773
|
+
* settlement grace period has passed, or when the execution is interrupted. A services
|
|
774
|
+
* layer that `Executor.runPromise` built stays open until an abandoned Promise settles.
|
|
775
|
+
*
|
|
776
|
+
* @since 0.2.1
|
|
777
|
+
*/
|
|
778
|
+
declare const promise: (callback: (event: Event, context: {
|
|
779
|
+
readonly signal: AbortSignal;
|
|
780
|
+
}) => PromiseLike<unknown>) => Observer;
|
|
781
|
+
/**
|
|
782
|
+
* Observes with an Effect. Its services become requirements of the execution. Its
|
|
783
|
+
* failures are recorded as observation failures and never fail the execution.
|
|
784
|
+
*
|
|
785
|
+
* @example
|
|
786
|
+
* ```ts
|
|
787
|
+
* Observer.effect((event) => Effect.logDebug(event._tag));
|
|
788
|
+
* ```
|
|
789
|
+
*
|
|
790
|
+
* @since 0.2.1
|
|
791
|
+
*/
|
|
792
|
+
declare const effect$1: <E = never, R = never>(callback: (event: Event) => Effect.Effect<unknown, E, R>) => Observer<R>;
|
|
472
793
|
declare namespace executor_d_exports {
|
|
473
794
|
export { CoverageIssue, Errors, ExecutionError, ExecutionFailed, ExecutionInterrupted, HandlerCoverageError, InteractionUnavailable, InterruptReason, OccurrenceReport, Options, Outcome, PromiseOptions, Report, Requirements, Uncovered, effect, runPromise };
|
|
474
795
|
}
|
|
475
796
|
/**
|
|
476
797
|
* What happened to one occurrence, or what a dry run predicts.
|
|
477
798
|
*
|
|
478
|
-
* @since
|
|
799
|
+
* @since 0.0.1
|
|
479
800
|
*/
|
|
480
801
|
type Outcome<E = unknown> = {
|
|
481
802
|
readonly _tag: "Completed";
|
|
@@ -539,13 +860,13 @@ type Outcome<E = unknown> = {
|
|
|
539
860
|
readonly error: E | undefined;
|
|
540
861
|
readonly cause: Cause.Cause<E>;
|
|
541
862
|
};
|
|
542
|
-
/** @since
|
|
543
|
-
type OccurrenceReport<A extends Any$
|
|
863
|
+
/** @since 0.0.1 */
|
|
864
|
+
type OccurrenceReport<A extends Any$3 = Any$3, E = unknown> = {
|
|
544
865
|
readonly occurrence: Occurrence<A>;
|
|
545
866
|
readonly outcome: Outcome<E>;
|
|
546
867
|
};
|
|
547
|
-
/** @since
|
|
548
|
-
type Report<A extends Any$
|
|
868
|
+
/** @since 0.0.1 */
|
|
869
|
+
type Report<A extends Any$3 = Any$3, E = unknown> = {
|
|
549
870
|
readonly _tag: "Report";
|
|
550
871
|
readonly mode: "execute" | "dry-run";
|
|
551
872
|
readonly status: "completed" | "failed" | "interrupted" | "not-started" | "would-complete" | "would-fail";
|
|
@@ -561,11 +882,13 @@ type Report<A extends Any$2 = Any$2, E = unknown> = {
|
|
|
561
882
|
readonly bodiesStarted: boolean;
|
|
562
883
|
/** Progress is not persisted. Rerunning the plan repeats completed actions. */
|
|
563
884
|
readonly persistence: "none";
|
|
885
|
+
/** Observers that failed or were abandoned. Never affects outcomes or status. */
|
|
886
|
+
readonly observation: ReadonlyArray<ObservationFailure>;
|
|
564
887
|
};
|
|
565
888
|
/**
|
|
566
889
|
* A handler is missing, duplicated, or bound to a different definition.
|
|
567
890
|
*
|
|
568
|
-
* @since
|
|
891
|
+
* @since 0.0.1
|
|
569
892
|
*/
|
|
570
893
|
type CoverageIssue = {
|
|
571
894
|
readonly _tag: "Missing" | "Duplicate" | "Mismatched";
|
|
@@ -590,9 +913,9 @@ declare const HandlerCoverageBase: new <A extends Record<string, any> = {}>(args
|
|
|
590
913
|
* For an occurrence that a rule produced, the issue names the rule and the occurrences
|
|
591
914
|
* it replaced.
|
|
592
915
|
*
|
|
593
|
-
* @since
|
|
916
|
+
* @since 0.0.1
|
|
594
917
|
*/
|
|
595
|
-
declare class HandlerCoverageError<A extends Any$
|
|
918
|
+
declare class HandlerCoverageError<A extends Any$3 = Any$3> extends HandlerCoverageBase<{
|
|
596
919
|
readonly issues: ReadonlyArray<CoverageIssue>;
|
|
597
920
|
readonly report: Report<A, never>;
|
|
598
921
|
}> {
|
|
@@ -605,9 +928,9 @@ declare const InteractionUnavailableBase: new <A extends Record<string, any> = {
|
|
|
605
928
|
* The plan has manual handlers, and the run has no `interaction` to ask a person. The
|
|
606
929
|
* run fails before any handler phase or prompt.
|
|
607
930
|
*
|
|
608
|
-
* @since
|
|
931
|
+
* @since 0.2.0
|
|
609
932
|
*/
|
|
610
|
-
declare class InteractionUnavailable<A extends Any$
|
|
933
|
+
declare class InteractionUnavailable<A extends Any$3 = Any$3> extends InteractionUnavailableBase<{
|
|
611
934
|
/** The occurrences that a manual handler covers, in plan order. */
|
|
612
935
|
readonly occurrences: ReadonlyArray<Occurrence<A>>;
|
|
613
936
|
readonly report: Report<A, never>;
|
|
@@ -621,9 +944,9 @@ declare const ExecutionFailedBase: new <A extends Record<string, any> = {}>(args
|
|
|
621
944
|
* An occurrence failed, or a person declined manual work. Execution stopped admitting
|
|
622
945
|
* new actions; started ones settled.
|
|
623
946
|
*
|
|
624
|
-
* @since
|
|
947
|
+
* @since 0.0.1
|
|
625
948
|
*/
|
|
626
|
-
declare class ExecutionFailed<A extends Any$
|
|
949
|
+
declare class ExecutionFailed<A extends Any$3 = Any$3, E = unknown> extends ExecutionFailedBase<{
|
|
627
950
|
readonly failures: ReadonlyArray<OccurrenceReport<A, E>>;
|
|
628
951
|
/** Manual occurrences that a person declined. */
|
|
629
952
|
readonly declined: ReadonlyArray<OccurrenceReport<A, E>>;
|
|
@@ -638,49 +961,49 @@ declare const ExecutionInterruptedBase: new <A extends Record<string, any> = {}>
|
|
|
638
961
|
* Why an execution or an occurrence was interrupted: explicit cancellation, a configured
|
|
639
962
|
* timeout, or an Effect handler that interrupted itself.
|
|
640
963
|
*
|
|
641
|
-
* @since
|
|
964
|
+
* @since 0.0.1
|
|
642
965
|
*/
|
|
643
966
|
type InterruptReason = "cancelled" | "timeout" | "handler";
|
|
644
967
|
/**
|
|
645
968
|
* Explicit cancellation, a configured timeout, or a handler's own interruption stopped
|
|
646
969
|
* execution.
|
|
647
970
|
*
|
|
648
|
-
* @since
|
|
971
|
+
* @since 0.0.1
|
|
649
972
|
*/
|
|
650
|
-
declare class ExecutionInterrupted<A extends Any$
|
|
973
|
+
declare class ExecutionInterrupted<A extends Any$3 = Any$3, E = unknown> extends ExecutionInterruptedBase<{
|
|
651
974
|
readonly reason: InterruptReason;
|
|
652
975
|
readonly report: Report<A, E>;
|
|
653
976
|
}> {
|
|
654
977
|
get message(): string;
|
|
655
978
|
}
|
|
656
|
-
/** @since
|
|
657
|
-
type ExecutionError<A extends Any$
|
|
979
|
+
/** @since 0.0.1 */
|
|
980
|
+
type ExecutionError<A extends Any$3, E> = HandlerCoverageError<A> | InteractionUnavailable<A> | ExecutionFailed<A, E> | ExecutionInterrupted<A, E>;
|
|
658
981
|
/**
|
|
659
982
|
* Action identifiers of a statically covered plan that no handler in the array
|
|
660
983
|
* implements.
|
|
661
984
|
*
|
|
662
|
-
* @since
|
|
985
|
+
* @since 0.0.1
|
|
663
986
|
*/
|
|
664
|
-
type Uncovered<A extends Any$
|
|
987
|
+
type Uncovered<A extends Any$3, H, C extends Coverage> = "runtime" extends C ? never : A extends Any$3 ? string extends A["id"] ? never : A["id"] extends ActionId<H> ? never : A["id"] : never;
|
|
665
988
|
/** Rejects a handler array that leaves statically known actions uncovered, naming them. */
|
|
666
|
-
type CoverageCheck<A extends Any$
|
|
989
|
+
type CoverageCheck<A extends Any$3, H, C extends Coverage> = [Uncovered<A, H, C>] extends [never] ? unknown : {
|
|
667
990
|
readonly handlers: `Missing a handler for action "${Uncovered<A, H, C>}"`;
|
|
668
991
|
};
|
|
669
992
|
/**
|
|
670
993
|
* Errors an execution can report for its occurrences.
|
|
671
994
|
*
|
|
672
|
-
* @since
|
|
995
|
+
* @since 0.0.1
|
|
673
996
|
*/
|
|
674
997
|
type Errors<H, I = never> = Error$1<H> | Error<I>;
|
|
675
998
|
/**
|
|
676
|
-
* Effect services an execution requires: the services of its handlers
|
|
677
|
-
* interaction.
|
|
999
|
+
* Effect services an execution requires: the services of its handlers, its
|
|
1000
|
+
* interaction, and its observers.
|
|
678
1001
|
*
|
|
679
|
-
* @since
|
|
1002
|
+
* @since 0.0.1
|
|
680
1003
|
*/
|
|
681
|
-
type Requirements<H, I = never> = Services$
|
|
682
|
-
/** @since
|
|
683
|
-
type Options<H extends Any$
|
|
1004
|
+
type Requirements<H, I = never, O = never> = Services$2<H> | Services$1<I> | Services<O>;
|
|
1005
|
+
/** @since 0.0.1 */
|
|
1006
|
+
type Options<H extends Any$2, I extends Any$1 = never, O extends Any = never> = {
|
|
684
1007
|
readonly handlers?: ReadonlyArray<H>;
|
|
685
1008
|
/**
|
|
686
1009
|
* Asks a person to confirm the work of manual handlers. A run whose plan has manual
|
|
@@ -688,6 +1011,14 @@ type Options<H extends Any$1, I extends Any = never> = {
|
|
|
688
1011
|
* A dry run never asks and does not need it.
|
|
689
1012
|
*/
|
|
690
1013
|
readonly interaction?: I;
|
|
1014
|
+
/**
|
|
1015
|
+
* Receive the run's events, in array order. The executor waits for each observer
|
|
1016
|
+
* before it continues; an observer failure is recorded in `report.observation` and never changes
|
|
1017
|
+
* the outcome.
|
|
1018
|
+
*/
|
|
1019
|
+
readonly observers?: ReadonlyArray<O>;
|
|
1020
|
+
/** Identifies the run in observer events. */
|
|
1021
|
+
readonly runId?: string;
|
|
691
1022
|
/**
|
|
692
1023
|
* Run prepare phases without running any apply phase. A prepare phase that may
|
|
693
1024
|
* depend on an earlier action is reported `Undetermined`, because the dry run does
|
|
@@ -722,20 +1053,21 @@ type Options<H extends Any$1, I extends Any = never> = {
|
|
|
722
1053
|
*
|
|
723
1054
|
* To cancel, interrupt the fiber. Interruption reaches running actions and aborts the
|
|
724
1055
|
* signal passed to Promise callbacks. The effect then ends as interrupted, without a
|
|
725
|
-
* report.
|
|
1056
|
+
* report. Observers receive a final `RunFinished` event without a report, delivered
|
|
1057
|
+
* within `settleTimeout`.
|
|
726
1058
|
*
|
|
727
|
-
* @since
|
|
1059
|
+
* @since 0.0.1
|
|
728
1060
|
*/
|
|
729
|
-
declare const effect: <A extends Any$
|
|
1061
|
+
declare const effect: <A extends Any$3, C extends Coverage, H extends Any$2 = never, I extends Any$1 = never, O extends Any = never>(plan: Plan<A, C>, options: Options<H, I, O> & CoverageCheck<A, H, C>) => Effect.Effect<Report<A, Errors<H, I>>, ExecutionError<A, Errors<H, I>>, Requirements<H, I, O>>;
|
|
730
1062
|
type ServicesOption<R, LE> = [R] extends [never] ? {
|
|
731
|
-
/** Handlers and
|
|
1063
|
+
/** Handlers, interactions, and observers without Effect services need none. */
|
|
732
1064
|
readonly services?: Context.Context<never> | Layer.Layer<never, LE>;
|
|
733
1065
|
} : {
|
|
734
|
-
/** Supplies the Effect services of the handlers and the
|
|
1066
|
+
/** Supplies the Effect services of the handlers, the interaction, and the observers. */
|
|
735
1067
|
readonly services: Context.Context<R> | Layer.Layer<R, LE>;
|
|
736
1068
|
};
|
|
737
|
-
/** @since
|
|
738
|
-
type PromiseOptions<H extends Any$
|
|
1069
|
+
/** @since 0.0.1 */
|
|
1070
|
+
type PromiseOptions<H extends Any$2, I extends Any$1 = never, O extends Any = never> = Options<H, I, O> & {
|
|
739
1071
|
/**
|
|
740
1072
|
* Explicit cancellation. Aborting stops admission, interrupts running actions and
|
|
741
1073
|
* pending confirmations, and rejects with `ExecutionInterrupted` and the partial
|
|
@@ -757,8 +1089,8 @@ type PromiseOptions<H extends Any$1, I extends Any = never> = Options<H, I> & {
|
|
|
757
1089
|
* until it settles, possibly forever, and close in that order. A cleanup failure after
|
|
758
1090
|
* the Promise resolved is logged through Effect.
|
|
759
1091
|
*
|
|
760
|
-
* @since
|
|
1092
|
+
* @since 0.0.1
|
|
761
1093
|
*/
|
|
762
|
-
declare const runPromise: <A extends Any$
|
|
763
|
-
export { action_d_exports as Action, change_d_exports as Change, executor_d_exports as Executor, handler_d_exports as Handler, history_d_exports as History, interaction_d_exports as Interaction, migration_d_exports as Migration, package_d_exports as Package, plan_d_exports as Plan, rule_d_exports as Rule, shortcut_d_exports as Shortcut, version_d_exports as Version };
|
|
1094
|
+
declare const runPromise: <A extends Any$3, C extends Coverage, H extends Any$2 = never, I extends Any$1 = never, LE = never, O extends Any = never>(plan: Plan<A, C>, options: PromiseOptions<H, I, O> & ServicesOption<Requirements<H, I, O>, LE> & CoverageCheck<A, H, C>) => Promise<Report<A, Errors<H, I>>>;
|
|
1095
|
+
export { action_d_exports as Action, change_d_exports as Change, executor_d_exports as Executor, handler_d_exports as Handler, history_d_exports as History, interaction_d_exports as Interaction, migration_d_exports as Migration, observer_d_exports as Observer, package_d_exports as Package, plan_d_exports as Plan, rule_d_exports as Rule, shortcut_d_exports as Shortcut, version_d_exports as Version };
|
|
764
1096
|
//# sourceMappingURL=index.d.ts.map
|