deltafold 0.0.0 → 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 +278 -4
- package/dist/changelog.d.ts +116 -0
- package/dist/changelog.d.ts.map +1 -0
- package/dist/changelog.js +304 -0
- package/dist/changelog.js.map +1 -0
- package/dist/document-BZcZo9nr.js +171 -0
- package/dist/document-BZcZo9nr.js.map +1 -0
- package/dist/document-DWHsgywm.d.ts +257 -0
- package/dist/document-DWHsgywm.d.ts.map +1 -0
- package/dist/html.d.ts +8 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/html.js +13 -0
- package/dist/html.js.map +1 -0
- package/dist/index.d.ts +517 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2126 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown.d.ts +8 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +16 -0
- package/dist/markdown.js.map +1 -0
- package/dist/mdast-DiRsYwPU.js +108 -0
- package/dist/mdast-DiRsYwPU.js.map +1 -0
- package/dist/package-BfBYnaCz.d.ts +1125 -0
- package/dist/package-BfBYnaCz.d.ts.map +1 -0
- package/dist/rolldown-runtime-D8jQpDG7.js +12 -0
- package/package.json +13 -1
- package/src/features/documents/changelog.ts +450 -0
- package/src/features/documents/document.ts +357 -0
- package/src/features/documents/index.ts +4 -0
- package/src/features/documents/public-document.ts +31 -0
- package/src/features/documents/sections.ts +44 -0
- package/src/features/execution/executor.ts +968 -0
- package/src/features/execution/handler.ts +485 -0
- package/src/features/execution/settlement.ts +52 -0
- package/src/features/package.ts +32 -0
- package/src/features/planning/guide.ts +56 -0
- package/src/features/planning/history.ts +174 -0
- package/src/features/planning/identifiers.ts +43 -0
- package/src/features/planning/resolve-error.ts +201 -0
- package/src/features/planning/resolve.ts +724 -0
- package/src/features/planning/rewrite.ts +331 -0
- package/src/features/planning/validate.ts +388 -0
- package/src/foundation/action.ts +188 -0
- package/src/foundation/change.ts +147 -0
- package/src/foundation/instruction.ts +110 -0
- package/src/foundation/migration.ts +236 -0
- package/src/foundation/plan.ts +245 -0
- package/src/foundation/rule.ts +74 -0
- package/src/foundation/shortcut.ts +79 -0
- package/src/foundation/template.ts +28 -0
- package/src/foundation/version.ts +78 -0
- package/src/index.ts +22 -11
- package/src/renderers/html.ts +12 -0
- package/src/renderers/markdown.ts +12 -0
- package/src/renderers/mdast.ts +120 -0
- package/src/types.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,517 @@
|
|
|
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, Scope } from "effect";
|
|
3
|
+
/** The union of an object type's property values. */
|
|
4
|
+
type ValueOf<T> = T[keyof T];
|
|
5
|
+
declare namespace handler_d_exports {
|
|
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
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Where a handler failure happened: the read-only prepare phase, or the apply phase that
|
|
10
|
+
* changes state.
|
|
11
|
+
*
|
|
12
|
+
* @since @next
|
|
13
|
+
*/
|
|
14
|
+
type Phase = "prepare" | "apply";
|
|
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 & {
|
|
16
|
+
readonly _tag: "UnexpectedHandlerError";
|
|
17
|
+
} & Readonly<A>;
|
|
18
|
+
/**
|
|
19
|
+
* A Promise handler rejected or threw a value that none of its declared error guards
|
|
20
|
+
* recognized, or its prepare phase returned something other than `Handler.prepared` or
|
|
21
|
+
* `Handler.skip`.
|
|
22
|
+
*
|
|
23
|
+
* @since @next
|
|
24
|
+
*/
|
|
25
|
+
declare class UnexpectedHandlerError extends UnexpectedHandlerError_base<{
|
|
26
|
+
readonly actionId: string;
|
|
27
|
+
readonly kind: string;
|
|
28
|
+
readonly phase: Phase;
|
|
29
|
+
readonly cause: unknown;
|
|
30
|
+
}> {
|
|
31
|
+
get message(): string;
|
|
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
|
+
};
|
|
88
|
+
declare const TypeId = "~deltafold/Handler";
|
|
89
|
+
/**
|
|
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.
|
|
93
|
+
*
|
|
94
|
+
* @since @next
|
|
95
|
+
*/
|
|
96
|
+
type Handler<out A extends Any$1, out E = never, out R = never> = {
|
|
97
|
+
readonly [TypeId]: typeof TypeId;
|
|
98
|
+
readonly action: A;
|
|
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>;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Any handler.
|
|
110
|
+
*
|
|
111
|
+
* @since @next
|
|
112
|
+
*/
|
|
113
|
+
type Any = Handler<Any$1, any, any>;
|
|
114
|
+
/**
|
|
115
|
+
* The errors of a handler or a union of handlers.
|
|
116
|
+
*
|
|
117
|
+
* @since @next
|
|
118
|
+
*/
|
|
119
|
+
type Error<H> = H extends Handler<any, infer E, any> ? E : never;
|
|
120
|
+
/**
|
|
121
|
+
* The Effect services of a handler or a union of handlers.
|
|
122
|
+
*
|
|
123
|
+
* @since @next
|
|
124
|
+
*/
|
|
125
|
+
type Services<H> = H extends Handler<any, any, infer R> ? R : never;
|
|
126
|
+
/**
|
|
127
|
+
* The action identifiers implemented by a handler or a union of handlers.
|
|
128
|
+
*
|
|
129
|
+
* @since @next
|
|
130
|
+
*/
|
|
131
|
+
type ActionId<H> = H extends Handler<infer A, any, any> ? A["id"] : never;
|
|
132
|
+
/** @since @next */
|
|
133
|
+
declare const isHandler: (value: unknown) => value is Any;
|
|
134
|
+
/**
|
|
135
|
+
* Named Effect services that a Promise handler declares.
|
|
136
|
+
*
|
|
137
|
+
* @since @next
|
|
138
|
+
*/
|
|
139
|
+
type ServiceMap = {
|
|
140
|
+
readonly [name: string | symbol]: Context.Key<any, any>;
|
|
141
|
+
};
|
|
142
|
+
type NoServices = Record<never, never>;
|
|
143
|
+
/**
|
|
144
|
+
* The second argument of Promise handler callbacks: the `AbortSignal` that
|
|
145
|
+
* `Effect.tryPromise` aborts on interruption, and the declared services, resolved.
|
|
146
|
+
*
|
|
147
|
+
* @since @next
|
|
148
|
+
*/
|
|
149
|
+
type PromiseContext<S extends ServiceMap = NoServices> = {
|
|
150
|
+
readonly signal: AbortSignal;
|
|
151
|
+
readonly services: { readonly [K in keyof S]: S[K]["Service"]; };
|
|
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
|
+
};
|
|
173
|
+
type ServiceIds<S extends ServiceMap> = ValueOf<{ [K in keyof S]: S[K] extends Context.Key<infer I, any> ? I : never; }>;
|
|
174
|
+
/**
|
|
175
|
+
* Recognizes a declared rejection: a schema, or a type guard such as an `instanceof`
|
|
176
|
+
* check. Guards must declare their parameter type, for example
|
|
177
|
+
* `(cause: unknown): cause is NotFound => cause instanceof NotFound`.
|
|
178
|
+
*
|
|
179
|
+
* @since @next
|
|
180
|
+
*/
|
|
181
|
+
type ErrorGuard = Schema.Top | ((cause: unknown) => cause is any);
|
|
182
|
+
type GuardedError<G> = G extends Schema.Top ? G["Type"] : G extends ((cause: unknown) => cause is infer E) ? E : never;
|
|
183
|
+
/** @since @next */
|
|
184
|
+
type PromiseOptions$1<S extends ServiceMap, G extends ReadonlyArray<ErrorGuard>> = {
|
|
185
|
+
/** Effect services resolved for the callbacks and added to the handler requirements. */
|
|
186
|
+
readonly services?: S;
|
|
187
|
+
/**
|
|
188
|
+
* Guards for rejections that keep their own type. Other rejections become
|
|
189
|
+
* `UnexpectedHandlerError`. A guard does not prove that the callback throws only
|
|
190
|
+
* those errors.
|
|
191
|
+
*/
|
|
192
|
+
readonly errors?: G;
|
|
193
|
+
};
|
|
194
|
+
type PromiseHandler<A extends Any$1, S extends ServiceMap, G> = Handler<A, GuardedError<G> | UnexpectedHandlerError, ServiceIds<S>>;
|
|
195
|
+
/**
|
|
196
|
+
* Implements an action with Promise callbacks. The callbacks run lazily through
|
|
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.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* Handler.promise(
|
|
206
|
+
* updateRemoteConfig,
|
|
207
|
+
* async (payload, { signal, services: { editor } }) => {
|
|
208
|
+
* await editor.update(payload, { signal });
|
|
209
|
+
* },
|
|
210
|
+
* { services: { editor: ConfigEditor } },
|
|
211
|
+
* );
|
|
212
|
+
* ```
|
|
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
|
+
*
|
|
227
|
+
* @since @next
|
|
228
|
+
*/
|
|
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;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
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.
|
|
242
|
+
*
|
|
243
|
+
* @since @next
|
|
244
|
+
*/
|
|
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>>;
|
|
276
|
+
declare namespace executor_d_exports {
|
|
277
|
+
export { CoverageIssue, Errors, ExecutionError, ExecutionFailed, ExecutionInterrupted, HandlerCoverageError, InterruptReason, OccurrenceReport, Options, Outcome, PromiseOptions, Report, Requirements, Uncovered, effect, runPromise };
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* What happened to one occurrence, or what a dry run predicts.
|
|
281
|
+
*
|
|
282
|
+
* @since @next
|
|
283
|
+
*/
|
|
284
|
+
type Outcome<E = unknown> = {
|
|
285
|
+
readonly _tag: "Completed";
|
|
286
|
+
} | {
|
|
287
|
+
readonly _tag: "Skipped";
|
|
288
|
+
readonly reason: string;
|
|
289
|
+
} | {
|
|
290
|
+
readonly _tag: "Failed";
|
|
291
|
+
readonly phase: Phase;
|
|
292
|
+
/** The typed failure, when the cause has one. Defects only appear in `cause`. */
|
|
293
|
+
readonly error: E | undefined;
|
|
294
|
+
readonly cause: Cause.Cause<E>;
|
|
295
|
+
} | {
|
|
296
|
+
readonly _tag: "Interrupted";
|
|
297
|
+
readonly phase: Phase;
|
|
298
|
+
/** `handler`: an Effect handler interrupted itself. */
|
|
299
|
+
readonly reason: InterruptReason;
|
|
300
|
+
/**
|
|
301
|
+
* Whether the interrupted work is known to have stopped. An interrupted Promise
|
|
302
|
+
* that has not settled within the grace period may still be changing external
|
|
303
|
+
* state.
|
|
304
|
+
*/
|
|
305
|
+
readonly settled: boolean;
|
|
306
|
+
} |
|
|
307
|
+
/** Not started because execution stopped first. */
|
|
308
|
+
{
|
|
309
|
+
readonly _tag: "Unattempted";
|
|
310
|
+
} |
|
|
311
|
+
/** `evaluated`: whether a prepare phase ran and decided to apply. */
|
|
312
|
+
{
|
|
313
|
+
readonly _tag: "WouldExecute";
|
|
314
|
+
readonly evaluated: boolean;
|
|
315
|
+
} | {
|
|
316
|
+
readonly _tag: "WouldSkip";
|
|
317
|
+
readonly reason: string;
|
|
318
|
+
} | {
|
|
319
|
+
readonly _tag: "Undetermined";
|
|
320
|
+
readonly reason: string;
|
|
321
|
+
} | {
|
|
322
|
+
readonly _tag: "PreparationFailed";
|
|
323
|
+
readonly error: E | undefined;
|
|
324
|
+
readonly cause: Cause.Cause<E>;
|
|
325
|
+
};
|
|
326
|
+
/** @since @next */
|
|
327
|
+
type OccurrenceReport<A extends Any$1 = Any$1, E = unknown> = {
|
|
328
|
+
readonly occurrence: Occurrence<A>;
|
|
329
|
+
readonly outcome: Outcome<E>;
|
|
330
|
+
};
|
|
331
|
+
/** @since @next */
|
|
332
|
+
type Report<A extends Any$1 = Any$1, E = unknown> = {
|
|
333
|
+
readonly _tag: "Report";
|
|
334
|
+
readonly mode: "execute" | "dry-run";
|
|
335
|
+
readonly status: "completed" | "failed" | "interrupted" | "not-started" | "would-complete" | "would-fail";
|
|
336
|
+
readonly from: string;
|
|
337
|
+
readonly to: string;
|
|
338
|
+
readonly route: string;
|
|
339
|
+
/** Every occurrence in plan order. */
|
|
340
|
+
readonly occurrences: ReadonlyArray<OccurrenceReport<A, E>>;
|
|
341
|
+
/**
|
|
342
|
+
* Whether any apply phase started. A started apply phase may have partially changed
|
|
343
|
+
* state.
|
|
344
|
+
*/
|
|
345
|
+
readonly bodiesStarted: boolean;
|
|
346
|
+
/** Progress is not persisted. Rerunning the plan repeats completed actions. */
|
|
347
|
+
readonly persistence: "none";
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* A handler is missing, duplicated, or bound to a different definition.
|
|
351
|
+
*
|
|
352
|
+
* @since @next
|
|
353
|
+
*/
|
|
354
|
+
type CoverageIssue = {
|
|
355
|
+
readonly _tag: "Missing" | "Duplicate" | "Mismatched";
|
|
356
|
+
readonly occurrenceId: string;
|
|
357
|
+
readonly actionId: string;
|
|
358
|
+
readonly description: string;
|
|
359
|
+
readonly migrationId: string;
|
|
360
|
+
/** The rule that produced the occurrence, for replacements. */
|
|
361
|
+
readonly rule: string | undefined;
|
|
362
|
+
/** The occurrences a replacement stands for, so the missing handler is discoverable. */
|
|
363
|
+
readonly replaces: ReadonlyArray<{
|
|
364
|
+
readonly occurrenceId: string;
|
|
365
|
+
readonly description: string;
|
|
366
|
+
}>;
|
|
367
|
+
};
|
|
368
|
+
declare const HandlerCoverageBase: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
369
|
+
readonly _tag: "HandlerCoverageError";
|
|
370
|
+
} & Readonly<A>;
|
|
371
|
+
/**
|
|
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.
|
|
376
|
+
*
|
|
377
|
+
* @since @next
|
|
378
|
+
*/
|
|
379
|
+
declare class HandlerCoverageError<A extends Any$1 = Any$1> extends HandlerCoverageBase<{
|
|
380
|
+
readonly issues: ReadonlyArray<CoverageIssue>;
|
|
381
|
+
readonly report: Report<A, never>;
|
|
382
|
+
}> {
|
|
383
|
+
get message(): string;
|
|
384
|
+
}
|
|
385
|
+
declare const ExecutionFailedBase: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
386
|
+
readonly _tag: "ExecutionFailed";
|
|
387
|
+
} & Readonly<A>;
|
|
388
|
+
/**
|
|
389
|
+
* An occurrence failed. Execution stopped admitting new actions; started ones settled.
|
|
390
|
+
*
|
|
391
|
+
* @since @next
|
|
392
|
+
*/
|
|
393
|
+
declare class ExecutionFailed<A extends Any$1 = Any$1, E = unknown> extends ExecutionFailedBase<{
|
|
394
|
+
readonly failures: ReadonlyArray<OccurrenceReport<A, E>>;
|
|
395
|
+
readonly report: Report<A, E>;
|
|
396
|
+
}> {
|
|
397
|
+
get message(): string;
|
|
398
|
+
}
|
|
399
|
+
declare const ExecutionInterruptedBase: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
400
|
+
readonly _tag: "ExecutionInterrupted";
|
|
401
|
+
} & Readonly<A>;
|
|
402
|
+
/**
|
|
403
|
+
* Why an execution or an occurrence was interrupted: explicit cancellation, a configured
|
|
404
|
+
* timeout, or an Effect handler that interrupted itself.
|
|
405
|
+
*
|
|
406
|
+
* @since @next
|
|
407
|
+
*/
|
|
408
|
+
type InterruptReason = "cancelled" | "timeout" | "handler";
|
|
409
|
+
/**
|
|
410
|
+
* Explicit cancellation, a configured timeout, or a handler's own interruption stopped
|
|
411
|
+
* execution.
|
|
412
|
+
*
|
|
413
|
+
* @since @next
|
|
414
|
+
*/
|
|
415
|
+
declare class ExecutionInterrupted<A extends Any$1 = Any$1, E = unknown> extends ExecutionInterruptedBase<{
|
|
416
|
+
readonly reason: InterruptReason;
|
|
417
|
+
readonly report: Report<A, E>;
|
|
418
|
+
}> {
|
|
419
|
+
get message(): string;
|
|
420
|
+
}
|
|
421
|
+
/** @since @next */
|
|
422
|
+
type ExecutionError<A extends Any$1, E> = HandlerCoverageError<A> | ExecutionFailed<A, E> | ExecutionInterrupted<A, E>;
|
|
423
|
+
/**
|
|
424
|
+
* Action identifiers of a statically covered plan that no handler in the array
|
|
425
|
+
* implements.
|
|
426
|
+
*
|
|
427
|
+
* @since @next
|
|
428
|
+
*/
|
|
429
|
+
type Uncovered<A extends Any$1, H, C extends Coverage> = "runtime" extends C ? never : A extends Any$1 ? string extends A["id"] ? never : A["id"] extends ActionId<H> ? never : A["id"] : never;
|
|
430
|
+
/** Rejects a handler array that leaves statically known actions uncovered, naming them. */
|
|
431
|
+
type CoverageCheck<A extends Any$1, H, C extends Coverage> = [Uncovered<A, H, C>] extends [never] ? unknown : {
|
|
432
|
+
readonly handlers: `Missing a handler for action "${Uncovered<A, H, C>}"`;
|
|
433
|
+
};
|
|
434
|
+
/**
|
|
435
|
+
* Errors an execution can report for its occurrences.
|
|
436
|
+
*
|
|
437
|
+
* @since @next
|
|
438
|
+
*/
|
|
439
|
+
type Errors<H> = Error<H>;
|
|
440
|
+
/**
|
|
441
|
+
* Effect services an execution requires: the services of its handlers.
|
|
442
|
+
*
|
|
443
|
+
* @since @next
|
|
444
|
+
*/
|
|
445
|
+
type Requirements<H> = Services<H>;
|
|
446
|
+
/** @since @next */
|
|
447
|
+
type Options<H extends Any> = {
|
|
448
|
+
readonly handlers?: ReadonlyArray<H>;
|
|
449
|
+
/**
|
|
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.
|
|
453
|
+
*/
|
|
454
|
+
readonly dryRun?: boolean;
|
|
455
|
+
/**
|
|
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.
|
|
459
|
+
*/
|
|
460
|
+
readonly timeout?: Duration.Input;
|
|
461
|
+
/**
|
|
462
|
+
* How long to wait for an interrupted Promise callback to settle before reporting it
|
|
463
|
+
* as possibly still running. Defaults to 5 seconds.
|
|
464
|
+
*/
|
|
465
|
+
readonly settleTimeout?: Duration.Input;
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
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.
|
|
477
|
+
*
|
|
478
|
+
* To cancel, interrupt the fiber. Interruption reaches running actions and aborts the
|
|
479
|
+
* signal passed to Promise callbacks. The effect then ends as interrupted, without a
|
|
480
|
+
* report.
|
|
481
|
+
*
|
|
482
|
+
* @since @next
|
|
483
|
+
*/
|
|
484
|
+
declare const effect: <A extends Any$1, C extends Coverage, H extends Any = never>(plan: Plan<A, C>, options: Options<H> & CoverageCheck<A, H, C>) => Effect.Effect<Report<A, Errors<H>>, ExecutionError<A, Errors<H>>, Requirements<H>>;
|
|
485
|
+
type ServicesOption<R, LE> = [R] extends [never] ? {
|
|
486
|
+
/** Handlers without Effect services need none. */
|
|
487
|
+
readonly services?: Context.Context<never> | Layer.Layer<never, LE>;
|
|
488
|
+
} : {
|
|
489
|
+
/** Supplies the handlers' Effect services. */
|
|
490
|
+
readonly services: Context.Context<R> | Layer.Layer<R, LE>;
|
|
491
|
+
};
|
|
492
|
+
/** @since @next */
|
|
493
|
+
type PromiseOptions<H extends Any> = Options<H> & {
|
|
494
|
+
/**
|
|
495
|
+
* Explicit cancellation. Aborting stops admission, interrupts running actions, and
|
|
496
|
+
* rejects with `ExecutionInterrupted` and the partial report.
|
|
497
|
+
*/
|
|
498
|
+
readonly signal?: AbortSignal;
|
|
499
|
+
};
|
|
500
|
+
/**
|
|
501
|
+
* Runs a plan and returns a Promise. It rejects with `HandlerCoverageError`,
|
|
502
|
+
* `ExecutionFailed`, or `ExecutionInterrupted`, each carrying the partial report.
|
|
503
|
+
* Building a supplied services layer can also reject with the layer's own error,
|
|
504
|
+
* without a report.
|
|
505
|
+
*
|
|
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.
|
|
512
|
+
*
|
|
513
|
+
* @since @next
|
|
514
|
+
*/
|
|
515
|
+
declare const runPromise: <A extends Any$1, C extends Coverage, H extends Any = never, LE = never>(plan: Plan<A, C>, options: PromiseOptions<H> & ServicesOption<Requirements<H>, LE> & CoverageCheck<A, H, C>) => Promise<Report<A, Errors<H>>>;
|
|
516
|
+
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, 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 };
|
|
517
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;;;KCWrB;;;;;;;;;;;cASC,+BAA+B;WAClC;WACA;WACA,OAAO;WACP;;MAEI;;cAKR;;;;;;;KAQM,aAAa;YACd,2BAA2B;WAC5B;WACA,OA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