@expressive/steps 0.0.0-stage → 0.1.1
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 +57 -2
- package/dist/index.d.ts +374 -0
- package/dist/index.js +1683 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -4
- package/skills/expressive-steps/SKILL.md +234 -0
package/README.md
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @expressive/steps
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Multi-step processes as Expressive Models. Extend `Steps` and every method is a step: a step schedules the next by calling it, fields carry data between them. `run()` takes the arguments, schedules, waits for the run with `await this`, and returns the result. Each step is atomic and registers its own reset, so a failure unwinds what committed. Runs repeat, queue and park on waits answered from outside; status is reactive on `this.then`.
|
|
4
|
+
|
|
5
|
+
In-process only for now - no durable persistence.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @expressive/steps @expressive/mvc
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Steps } from '@expressive/steps';
|
|
13
|
+
|
|
14
|
+
class SubmitOrder extends Steps {
|
|
15
|
+
cart!: Cart;
|
|
16
|
+
charge?: Charge = undefined;
|
|
17
|
+
tracking = '';
|
|
18
|
+
|
|
19
|
+
async run() {
|
|
20
|
+
this.reserve();
|
|
21
|
+
|
|
22
|
+
await this;
|
|
23
|
+
|
|
24
|
+
return { orderId: this.charge!.id, tracking: this.tracking };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
protected async reserve() {
|
|
28
|
+
const hold = await inventory.hold(this.cart.items);
|
|
29
|
+
|
|
30
|
+
this.then.on({ reset: () => inventory.release(hold) });
|
|
31
|
+
this.pay();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
protected async pay() {
|
|
35
|
+
this.charge = await stripe.charge(this.cart.total);
|
|
36
|
+
this.then.on({ reset: () => stripe.refund(this.charge!.id) });
|
|
37
|
+
|
|
38
|
+
this.then(this.ship(this.charge.id), this.receipt(this.charge.receiptUrl));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
protected async ship(chargeId: string) {
|
|
42
|
+
this.tracking = (await courier.book(this.cart, chargeId)).id;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected async receipt(url: string) {
|
|
46
|
+
await mail.send(this.cart.email, url);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const order = SubmitOrder.new({ cart });
|
|
51
|
+
|
|
52
|
+
order.then.status; // 'idle' - reactive, like any field
|
|
53
|
+
const { orderId } = await order; // runs run(), typed by its return
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
A failed `courier.book` unwinds newest first: `refund`, then `release`, then every taken-back step's fields restored.
|
|
57
|
+
|
|
58
|
+
Reference: [docs/](docs/README.md), and the package's agent skill ([skills/expressive-steps](skills/expressive-steps/SKILL.md)).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { Model } from "@expressive/mvc";
|
|
2
|
+
|
|
3
|
+
//#region src/steps.d.ts
|
|
4
|
+
declare namespace Steps {
|
|
5
|
+
/**
|
|
6
|
+
* Where the instance stands - reactive through `then.status`.
|
|
7
|
+
*
|
|
8
|
+
* `idle` - no run, or the last ended cleanly. `running`. `waiting` - parked on an open wait.
|
|
9
|
+
* `stopped`, `aborted`, `failed` - how the last run ended; held until the next one starts.
|
|
10
|
+
*/
|
|
11
|
+
type Status = 'idle' | 'running' | 'waiting' | 'stopped' | 'aborted' | 'failed';
|
|
12
|
+
/** The run's result - what `run` resolves with; types `x.run()` and `await x`. */
|
|
13
|
+
type Result<T> = T extends {
|
|
14
|
+
run(...args: any[]): infer R;
|
|
15
|
+
} ? Awaited<R> : unknown;
|
|
16
|
+
/** A planned item: a step, a parallel group (`group`), or a wait (`answers`). */
|
|
17
|
+
interface Node {
|
|
18
|
+
id: string;
|
|
19
|
+
key: string;
|
|
20
|
+
/** Arguments - a duration wait's milliseconds. */
|
|
21
|
+
args: unknown[];
|
|
22
|
+
group?: Node[];
|
|
23
|
+
/** Keys of the steps which may answer this wait - none for a duration. */
|
|
24
|
+
answers?: string[];
|
|
25
|
+
/** Steps raced against the answers - cancelled once one answers. */
|
|
26
|
+
race?: Node;
|
|
27
|
+
/** Caught by `.catch()`: a step given the error (its key), `then` for a function, or `true` for none. */
|
|
28
|
+
rescue?: string | true;
|
|
29
|
+
}
|
|
30
|
+
/** What calling a step inside a step returns - inert, not awaitable; scheduled once the caller settles. */
|
|
31
|
+
type Token = Readonly<Node>;
|
|
32
|
+
/**
|
|
33
|
+
* A committed step, as `after` receives it - keys and arguments, no values.
|
|
34
|
+
*
|
|
35
|
+
* `id` is `key#n`, e.g. `pay#1`. The Runner keeps no journal - collect entries in `after`.
|
|
36
|
+
*/
|
|
37
|
+
interface Entry {
|
|
38
|
+
id: string;
|
|
39
|
+
key: string;
|
|
40
|
+
args: unknown[];
|
|
41
|
+
/** What the step scheduled. */
|
|
42
|
+
next: Node[];
|
|
43
|
+
/** Fields the step wrote, collections changed in place included. */
|
|
44
|
+
wrote: string[];
|
|
45
|
+
/** Handlers the step registered with `then.on()`, by outcome, in order: a step method given uncalled or steps called for one (by key), or `then` for a function. */
|
|
46
|
+
on?: { [K in keyof On]?: Node[] };
|
|
47
|
+
/** Taken back by an unwind - resets run, fields restored; `'failed'` when a handler threw. */
|
|
48
|
+
unwound?: true | 'failed';
|
|
49
|
+
/** Id of the wait this step answered. */
|
|
50
|
+
wake?: string;
|
|
51
|
+
/** How many times `then.retry()` replayed the step, when past its first run. */
|
|
52
|
+
retried?: number;
|
|
53
|
+
/** What the step threw - a caught failure, or one which kept its writes. */
|
|
54
|
+
error?: unknown;
|
|
55
|
+
/** Collections changed in a way no restore can undo - the unwind stops here. */
|
|
56
|
+
irreversible?: string[];
|
|
57
|
+
/** The step called `then.commit()` - not retried, restored or undone; the unwind stops here. */
|
|
58
|
+
committed?: true;
|
|
59
|
+
/** The unwind stopped at this entry; it and every entry before it stay applied. */
|
|
60
|
+
halted?: true;
|
|
61
|
+
/** An `end` the runtime added - the plan drained without one. */
|
|
62
|
+
implicit?: true;
|
|
63
|
+
}
|
|
64
|
+
/** An open wait, as listed by `then.waiting`. */
|
|
65
|
+
interface Wait {
|
|
66
|
+
id: string;
|
|
67
|
+
/** Key of the step which opened the wait. */
|
|
68
|
+
step: string;
|
|
69
|
+
/** Arguments of the step which opened the wait. */
|
|
70
|
+
args: unknown[];
|
|
71
|
+
/** Keys of the steps which may answer it. */
|
|
72
|
+
answers: string[];
|
|
73
|
+
/** When a duration wait closes, in epoch milliseconds. */
|
|
74
|
+
until?: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A `then.on` handler.
|
|
78
|
+
*
|
|
79
|
+
* A function - given the error, or nothing on a cancellation; process-local. For a durable run:
|
|
80
|
+
* a step method uncalled - given the same, recorded - or steps called for it, an array a group.
|
|
81
|
+
*/
|
|
82
|
+
type Handler = {
|
|
83
|
+
handler(reason?: unknown): unknown;
|
|
84
|
+
}['handler'] | Promise<void> | readonly Promise<void>[];
|
|
85
|
+
/**
|
|
86
|
+
* Handlers for the outcomes of a step and everything it schedules.
|
|
87
|
+
*
|
|
88
|
+
* Per step they fire `catch`, `abort`, `reset`, `close`; across steps deepest first, newest first.
|
|
89
|
+
* Handlers run before fields are restored and see the step's partial writes; keys they write are kept.
|
|
90
|
+
*/
|
|
91
|
+
interface On {
|
|
92
|
+
/**
|
|
93
|
+
* The step is taken back - reset its effects.
|
|
94
|
+
*
|
|
95
|
+
* A failure leaving its subtree, `abort()`, a lost race; not `stop()`. Fields are restored after it.
|
|
96
|
+
*/
|
|
97
|
+
reset?: Handler;
|
|
98
|
+
/**
|
|
99
|
+
* A failure below that no closer `.catch` took - return to recover, throw to pass it on.
|
|
100
|
+
*
|
|
101
|
+
* Recovering unwinds the failed part of the subtree; the step's own effects stay and its `reset`
|
|
102
|
+
* does not run; steps it schedules replace the rest. One per step; runs before a `.catch` on the
|
|
103
|
+
* step's call. `then.retry()` replays the step.
|
|
104
|
+
*/
|
|
105
|
+
catch?: Handler;
|
|
106
|
+
/**
|
|
107
|
+
* The subtree ended without completing - `commit()`'s counterpart.
|
|
108
|
+
*
|
|
109
|
+
* Given the error of a failure no `catch` recovered; nothing for a cancellation (`abort()`, `stop()`,
|
|
110
|
+
* a lost race) - `then.status` tells which. Skips a clean end, a recovered failure and `then.end()`.
|
|
111
|
+
*/
|
|
112
|
+
abort?: Handler;
|
|
113
|
+
/** The subtree ended, any way - a finally over it, last. */
|
|
114
|
+
close?: Handler;
|
|
115
|
+
}
|
|
116
|
+
/** Why a run or subtree ended: `abort()`, or a lost race. */
|
|
117
|
+
type Aborted = InstanceType<typeof Steps.Aborted>;
|
|
118
|
+
/** Why a run or subtree ended: `stop()`. */
|
|
119
|
+
type Stopped = InstanceType<typeof Steps.Stopped>;
|
|
120
|
+
/** A plain copy of the controller's reactive fields - `then.get()`. */
|
|
121
|
+
interface Snapshot {
|
|
122
|
+
status: Status;
|
|
123
|
+
active: string | undefined;
|
|
124
|
+
queue: unknown[][];
|
|
125
|
+
waiting: Wait[];
|
|
126
|
+
runs: number;
|
|
127
|
+
error: unknown;
|
|
128
|
+
}
|
|
129
|
+
interface Controller<T extends Model = Model> {
|
|
130
|
+
/**
|
|
131
|
+
* Inside a step: park the plan for a duration - units summed.
|
|
132
|
+
*
|
|
133
|
+
* A wait nothing answers, journaled `wait#n` with `args: [ms]`. The next step in sequence runs once
|
|
134
|
+
* it passes - backoff, timeouts, nudges.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* this.then({ sec: 30 });
|
|
138
|
+
* this.retryUpload();
|
|
139
|
+
*/
|
|
140
|
+
<This>(this: This, duration: {
|
|
141
|
+
ms?: number;
|
|
142
|
+
sec?: number;
|
|
143
|
+
min?: number;
|
|
144
|
+
hr?: number;
|
|
145
|
+
day?: number;
|
|
146
|
+
}): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Inside a step: one parallel group of `each`, called per item.
|
|
149
|
+
*
|
|
150
|
+
* `each` is a function issuing a step, or a step itself. The next step in sequence runs once every
|
|
151
|
+
* member, and all it schedules, is done.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* this.then(this.files, this.upload);
|
|
155
|
+
* this.then(this.sites, (site) => this.scan(site, 'deep'));
|
|
156
|
+
*/
|
|
157
|
+
<I, This>(this: This, items: Iterable<I>, each: (item: I, index: number) => unknown): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Inside a step: park the plan until one of these steps is called.
|
|
160
|
+
*
|
|
161
|
+
* Status `waiting`. Answering steps read `undefined` from outside unless an open wait accepts them.
|
|
162
|
+
* An outside call answers the wait whose opening step's first argument `===` its own, else the
|
|
163
|
+
* oldest; its Promise resolves when that answer's subtree is done. A call no wait accepts throws.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* this.then(this.approve, this.reject);
|
|
167
|
+
*/
|
|
168
|
+
<This>(this: This, ...steps: ((...args: any[]) => unknown)[]): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Inside a step: run these tokens as one parallel group.
|
|
171
|
+
*
|
|
172
|
+
* The next step in sequence runs once every member, and all it schedules, is done. Beside steps
|
|
173
|
+
* uncalled, each called step is a racer, started when the plan reaches the wait: the first answer
|
|
174
|
+
* wins and keeps all it did; losers' signals abort, what they scheduled drops, and each losing
|
|
175
|
+
* branch unwinds - resets run, fields restored.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* this.then(this.ship(order), this.receipt(order));
|
|
179
|
+
* this.then(this.allow, this.deny, this.timeout(call));
|
|
180
|
+
*/
|
|
181
|
+
<This>(this: This, ...steps: unknown[]): Promise<void>;
|
|
182
|
+
/** The instance this controller runs. */
|
|
183
|
+
readonly self: T;
|
|
184
|
+
/** Where the instance stands - see {@link Steps.Status}. */
|
|
185
|
+
readonly status: Steps.Status;
|
|
186
|
+
/** Key of a step in flight - the latest invoked, with a group in flight. */
|
|
187
|
+
readonly active: string | undefined;
|
|
188
|
+
/** Arguments of each `run()` waiting for the active run to finish. */
|
|
189
|
+
readonly queue: readonly unknown[][];
|
|
190
|
+
/** Open waits, oldest first - durations included. */
|
|
191
|
+
readonly waiting: readonly Steps.Wait[];
|
|
192
|
+
/** Runs finished - ended, failed, stopped or aborted. */
|
|
193
|
+
readonly runs: number;
|
|
194
|
+
/** What failed the last run; cleared when the next starts. */
|
|
195
|
+
readonly error: unknown;
|
|
196
|
+
/** A plain snapshot of status, active, queue, waiting, runs and error. */
|
|
197
|
+
get(): Steps.Snapshot;
|
|
198
|
+
/**
|
|
199
|
+
* End the run early, keeping everything.
|
|
200
|
+
*
|
|
201
|
+
* Inside a step, where the plan reaches it; from outside, now. Steps in flight settle, what they
|
|
202
|
+
* schedule drops, only `close` fires; `run`'s tail then builds the result from fields. Takes no
|
|
203
|
+
* value - write why it ended to a field first. To halt now, `stop()` or `abort()`.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* if (this.found) this.then.end();
|
|
207
|
+
* else this.next();
|
|
208
|
+
*/
|
|
209
|
+
end(): void;
|
|
210
|
+
/**
|
|
211
|
+
* Inside a step: a gate - only `max` at once; what the step schedules after it holds a slot until done.
|
|
212
|
+
*
|
|
213
|
+
* Queues FIFO. `max` as a function of `$`, the tracking proxy, is re-read live; `0` pauses. `key`
|
|
214
|
+
* shares the queue: an object across groups and instances (`only(1, this.manager)` is a mutex), any
|
|
215
|
+
* other value across this instance. Default: the enclosing group's, else the instance's. A delay
|
|
216
|
+
* before queueing is a duration ahead of it.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* this.then.only(($) => $.concurrency);
|
|
220
|
+
* this.upload(file);
|
|
221
|
+
*/
|
|
222
|
+
only(max: number | (($: T) => number), key?: unknown): void;
|
|
223
|
+
/**
|
|
224
|
+
* Halt, keeping what was done - status `stopped`.
|
|
225
|
+
*
|
|
226
|
+
* Pending steps and queued runs drop; in-flight steps settle and commit. The run, the queue and
|
|
227
|
+
* in-flight signals reject with a `Steps.Stopped` - `reason` as its `cause`, and its message when a string.
|
|
228
|
+
* `set(null)` on the instance stops too.
|
|
229
|
+
*/
|
|
230
|
+
stop(reason?: unknown): void;
|
|
231
|
+
/**
|
|
232
|
+
* Halt and unwind, as a failure would - status `aborted`.
|
|
233
|
+
*
|
|
234
|
+
* The run's resets run, newest first, and fields are restored. The run and queue reject with a
|
|
235
|
+
* `Steps.Aborted`, `reason` as for `stop`. A reset which throws fails the run: its error, given the
|
|
236
|
+
* `Steps.Aborted` as `cause`.
|
|
237
|
+
*/
|
|
238
|
+
abort(reason?: unknown): void;
|
|
239
|
+
/**
|
|
240
|
+
* Inside a step: a point of no return.
|
|
241
|
+
*
|
|
242
|
+
* The step is not caught, retried, restored or undone; an unwind stops here and what came before stands.
|
|
243
|
+
*/
|
|
244
|
+
commit(): void;
|
|
245
|
+
/**
|
|
246
|
+
* Inside a step: handlers for the outcomes of this step and all it schedules - see {@link Steps.On}.
|
|
247
|
+
*
|
|
248
|
+
* Register right after the effect it undoes. An unknown key throws.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* const hold = await inventory.hold(this.cart.items);
|
|
252
|
+
*
|
|
253
|
+
* this.then.on({ reset: () => inventory.release(hold) });
|
|
254
|
+
* this.pay();
|
|
255
|
+
*/
|
|
256
|
+
on(handlers: Steps.On): void;
|
|
257
|
+
/** Inside a `.catch` handler: restore the caught branch's fields now; writes after it stand. */
|
|
258
|
+
restore(): void;
|
|
259
|
+
/**
|
|
260
|
+
* Inside a step: its `AbortSignal` - pass it to the call the step awaits.
|
|
261
|
+
*
|
|
262
|
+
* Aborted on `stop()` or `abort()`, an outside `end`, a failure elsewhere, a race lost, and once the
|
|
263
|
+
* step settles. A step rejecting with its reason is not a failure.
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* this.page = await fetch(this.url, { signal: this.then.signal });
|
|
267
|
+
*/
|
|
268
|
+
readonly signal: AbortSignal;
|
|
269
|
+
/** Inside a step: how many times `then.retry()` replayed it - `0` on a first run. In a handler, the failed one's. */
|
|
270
|
+
readonly retried: number;
|
|
271
|
+
/**
|
|
272
|
+
* Inside a `.catch` handler: schedule what the catch is attached to again, under the same handler.
|
|
273
|
+
*
|
|
274
|
+
* The failed step or the whole group, with its recorded args. The handler holds the policy; backoff
|
|
275
|
+
* belongs in the retried step. Throws outside a handler.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* this.scan(site).catch((error) => {
|
|
279
|
+
* if (this.then.retried >= 3) throw error;
|
|
280
|
+
* this.then.retry();
|
|
281
|
+
* });
|
|
282
|
+
*/
|
|
283
|
+
retry(): void;
|
|
284
|
+
}
|
|
285
|
+
interface Thenable<T extends Model = Model> {
|
|
286
|
+
/**
|
|
287
|
+
* Join the active run - or, idle, call `run()`; settles with the last queued run's result.
|
|
288
|
+
*
|
|
289
|
+
* Rejects if idle and `run` takes arguments - give an optional one a default.
|
|
290
|
+
*/
|
|
291
|
+
<R1 = Steps.Result<T>, R2 = never>(onfulfilled?: ((value: Steps.Result<T>) => R1 | PromiseLike<R1>) | null, onrejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null): Promise<R1 | R2>;
|
|
292
|
+
then: Steps.Runner<T>;
|
|
293
|
+
}
|
|
294
|
+
/** The controller, and a thenable - so the instance, with it as `then`, is awaitable. */
|
|
295
|
+
type Runner<T extends Model = Model> = Controller<T> & Thenable<T>;
|
|
296
|
+
}
|
|
297
|
+
declare class Aborted extends Error {
|
|
298
|
+
name: string;
|
|
299
|
+
}
|
|
300
|
+
declare class Stopped extends Error {
|
|
301
|
+
name: string;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* A runnable Model: every method is a step, a step schedules the next by calling it.
|
|
305
|
+
*
|
|
306
|
+
* Fields carry data between steps. Each step is atomic and registers its own reset; a failure unwinds
|
|
307
|
+
* what committed. `run()` starts a run; awaiting the instance joins it. In-process only.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* class Checkout extends Steps {
|
|
311
|
+
* cart!: Cart;
|
|
312
|
+
* charge?: Charge = undefined;
|
|
313
|
+
*
|
|
314
|
+
* async run() {
|
|
315
|
+
* this.pay();
|
|
316
|
+
* await this;
|
|
317
|
+
* return this.charge!.id;
|
|
318
|
+
* }
|
|
319
|
+
*
|
|
320
|
+
* protected async pay() {
|
|
321
|
+
* this.charge = await stripe.charge(this.cart.total);
|
|
322
|
+
* this.then.on({ reset: () => stripe.refund(this.charge!.id) });
|
|
323
|
+
* }
|
|
324
|
+
* }
|
|
325
|
+
*
|
|
326
|
+
* const id = await Checkout.new({ cart });
|
|
327
|
+
*/
|
|
328
|
+
declare class Steps extends Model {
|
|
329
|
+
/** Why a run or subtree ended: `abort()`, or a lost race. */
|
|
330
|
+
static readonly Aborted: typeof Aborted;
|
|
331
|
+
/** Why a run or subtree ended: `stop()`. */
|
|
332
|
+
static readonly Stopped: typeof Stopped;
|
|
333
|
+
/**
|
|
334
|
+
* The controller - plan tokens inside a step, status and control from outside.
|
|
335
|
+
*
|
|
336
|
+
* Its fields are reactive through the instance: `x.get(($) => $.then.status)`, or read in a render.
|
|
337
|
+
* Enumerable - `{ ...x.then }` snapshots; not in `instance.get()`. Awaiting the instance awaits it.
|
|
338
|
+
*/
|
|
339
|
+
readonly then: Steps.Runner<this>;
|
|
340
|
+
constructor(...args: Model.Args);
|
|
341
|
+
/**
|
|
342
|
+
* The entry - starts a run, or queues one while a run is active; settles with what it returns.
|
|
343
|
+
*
|
|
344
|
+
* Must be `async`; the only step callable from outside. Before `await this`: field writes and step
|
|
345
|
+
* calls only. After it, the tail: read fields, return or throw - step calls throw. Without `await this`
|
|
346
|
+
* it settles at once. `return await this` is a TS circularity - return from fields. Inside a step,
|
|
347
|
+
* `this.run()` throws.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* async run(url: string) {
|
|
351
|
+
* this.fetch(url);
|
|
352
|
+
* await this;
|
|
353
|
+
* return this.rows;
|
|
354
|
+
* }
|
|
355
|
+
*/
|
|
356
|
+
run?(...args: any[]): Promise<unknown>;
|
|
357
|
+
/** Hook: before each step. Synchronous, the raw instance as `this`; writes are unjournaled. */
|
|
358
|
+
protected before?(step: string, args: unknown[]): void;
|
|
359
|
+
/**
|
|
360
|
+
* Hook: after each step commits, given its entry - the only journal there is.
|
|
361
|
+
*
|
|
362
|
+
* Synchronous, the raw instance as `this`; writes are unjournaled. A try a catch took, and the failure
|
|
363
|
+
* ending the run, arrive with `entry.error`; a called `end` arrives too, an implicit one does not.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* protected after(step: string, entry: Steps.Entry) {
|
|
367
|
+
* this.log.push(entry);
|
|
368
|
+
* }
|
|
369
|
+
*/
|
|
370
|
+
protected after?(step: string, entry: Steps.Entry): void;
|
|
371
|
+
}
|
|
372
|
+
//#endregion
|
|
373
|
+
export { Steps };
|
|
374
|
+
//# sourceMappingURL=index.d.ts.map
|