@ayepi/work 0.1.0 → 0.2.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 +30 -18
- package/ayepi-work-deps-schedule.md +312 -0
- package/ayepi-work-ports.md +408 -0
- package/ayepi-work.md +926 -0
- package/dist/index.cjs +234 -56
- package/dist/index.d.cts +151 -50
- package/dist/index.d.ts +151 -50
- package/dist/index.js +234 -57
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ import { MaybePromise } from "@ayepi/core";
|
|
|
3
3
|
|
|
4
4
|
//#region src/internal.d.ts
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Override how work/group ids are generated process-wide — e.g. sortable or prefixed ids. Affects
|
|
8
|
+
* **build-time** work ids (builders are minted outside a system) and any engine ids without their own
|
|
9
|
+
* `generateId`. Pass nothing to reset to the default UUID generator.
|
|
10
|
+
*/
|
|
11
|
+
declare const setIdGenerator: (fn?: () => string) => void;
|
|
12
|
+
/** Generate an id via the active generator. */
|
|
13
|
+
|
|
6
14
|
/** The signature of a `logWith`-style context wrapper (`@ayepi/log`'s `logWith`). */
|
|
7
15
|
type LogWith = <R>(add: object, inner: () => R) => R;
|
|
8
16
|
/** The default {@link LogWith}: runs `inner` with no added context. */
|
|
@@ -414,18 +422,58 @@ declare function retry<R>(fn: (state: RetryState) => Promise<R>, options?: Retry
|
|
|
414
422
|
/**
|
|
415
423
|
* A queueable, type-carrying unit of work produced by a {@link WorkBuilder}. Its `id`
|
|
416
424
|
* is assigned at build time (so you can reference it before queueing — e.g. to depend
|
|
417
|
-
* on it).
|
|
418
|
-
*
|
|
425
|
+
* on it). It carries **two** phantom types: `S` — what `.result()` resolves to when this
|
|
426
|
+
* item is awaited alone — and `G` — what it contributes to the **group** when group-awaited
|
|
427
|
+
* (its own value plus everything it queues, transitively). Phantoms never exist at runtime.
|
|
419
428
|
*/
|
|
420
|
-
interface Work<Name extends string = string,
|
|
429
|
+
interface Work<Name extends string = string, S = unknown, G = unknown> {
|
|
421
430
|
/** Stable id, assigned when the instance is built. */
|
|
422
431
|
readonly id: string;
|
|
423
432
|
/** The work type name (the registry key). */
|
|
424
433
|
readonly type: Name;
|
|
425
434
|
/** The (already type-checked) input payload. */
|
|
426
435
|
readonly input: unknown;
|
|
427
|
-
/** Phantom
|
|
428
|
-
readonly
|
|
436
|
+
/** Phantom: the *awaited-alone* result type. */
|
|
437
|
+
readonly __self: S;
|
|
438
|
+
/** Phantom: the *group-awaited* contribution type. */
|
|
439
|
+
readonly __group: G;
|
|
440
|
+
}
|
|
441
|
+
/** Brand for {@link WorkResult} — also makes the result distinguishable from a raw value at runtime. */
|
|
442
|
+
declare const WORK_RESULT: unique symbol;
|
|
443
|
+
/** An item that contributes to a group: a built {@link Work} or a {@link WorkResult}. */
|
|
444
|
+
type GroupItem = Work<string, unknown, unknown> | WorkResult<unknown, unknown>;
|
|
445
|
+
/** The group contribution `G` of one {@link GroupItem}. */
|
|
446
|
+
type GroupOfItem<X> = X extends Work<string, unknown, infer G> ? G : X extends WorkResult<unknown, infer G> ? G : never;
|
|
447
|
+
/** The group contribution of one item or a tuple/array of items. */
|
|
448
|
+
type GroupOf<Is> = Is extends readonly GroupItem[] ? GroupOfItem<Is[number]> : GroupOfItem<Is>;
|
|
449
|
+
/**
|
|
450
|
+
* What a handler **returns**: an instruction the system carries out, typed by its *awaited-alone*
|
|
451
|
+
* result `S` and its *group* contribution `G`. Built by {@link WorkContext.result} (a value),
|
|
452
|
+
* {@link WorkContext.queue} (run sub-works), or {@link WorkContext.void} (nothing). Chain native
|
|
453
|
+
* dependencies with {@link next}.
|
|
454
|
+
*
|
|
455
|
+
* The chain method is **`next`**, not `then` — a `then` member would make this a *thenable*, and the
|
|
456
|
+
* engine's `Promise.resolve(...)` of the handler's return would try to adopt/await it.
|
|
457
|
+
*/
|
|
458
|
+
interface WorkResult<S, G> {
|
|
459
|
+
/** Phantom brand (type-only; the runtime object carries a separate symbol). */
|
|
460
|
+
readonly [WORK_RESULT]: true;
|
|
461
|
+
/** Phantom: the *awaited-alone* result type. */
|
|
462
|
+
readonly __self: S;
|
|
463
|
+
/** Phantom: the *group* contribution type. */
|
|
464
|
+
readonly __group: G;
|
|
465
|
+
/**
|
|
466
|
+
* Native dependency: once the works this result queued satisfy `condition` (default `'all-success'`),
|
|
467
|
+
* queue `next`. Returns a result whose group widens by `next`'s contribution.
|
|
468
|
+
*/
|
|
469
|
+
next<const Ns extends GroupItem | readonly GroupItem[]>(next: Ns, condition?: DependencyCondition, options?: WorkInstanceOptions): WorkResult<S, G | GroupOf<Ns>>;
|
|
470
|
+
}
|
|
471
|
+
/** Options for {@link WorkContext.result}. */
|
|
472
|
+
interface ResultOptions<R> {
|
|
473
|
+
/** Lock the group result to this value — later contributors can't overwrite it. */
|
|
474
|
+
readonly final?: boolean;
|
|
475
|
+
/** Accumulate instead of overwrite: fold this work's value into the existing group result. */
|
|
476
|
+
readonly append?: (existing: R | undefined) => R;
|
|
429
477
|
}
|
|
430
478
|
/** The execution context handed to a {@link WorkHandler}. */
|
|
431
479
|
interface WorkContext {
|
|
@@ -435,18 +483,23 @@ interface WorkContext {
|
|
|
435
483
|
readonly groupId: string;
|
|
436
484
|
/** Delivery attempt (1 = first try; higher after a retry). */
|
|
437
485
|
readonly attempt: number;
|
|
438
|
-
/**
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
486
|
+
/** The id of the work that queued this one (undefined for a top-level `enqueue`). */
|
|
487
|
+
readonly parent?: string;
|
|
488
|
+
/** When this work was queued by a fired dependency, the ids it depended on. */
|
|
489
|
+
readonly dependents?: readonly string[];
|
|
490
|
+
/** Contribute a **value** to the group (and to this item's own `.result()`). */
|
|
491
|
+
result<R>(value: R, options?: ResultOptions<R>): WorkResult<R, R>;
|
|
492
|
+
/** Queue sub-work into the same group (works and/or nested results); this item delegates (`.result()` = void). */
|
|
493
|
+
queue<const Is extends GroupItem | readonly GroupItem[]>(items: Is, options?: WorkInstanceOptions): WorkResult<void, GroupOf<Is>>;
|
|
494
|
+
/** Contribute nothing. */
|
|
495
|
+
void(): WorkResult<void, void>;
|
|
443
496
|
/** Read the current {@link WorkState} of other work items (for dependency-style coordination). */
|
|
444
497
|
states(ids: readonly string[]): Promise<(WorkState | undefined)[]>;
|
|
445
498
|
/** Win a one-time distributed claim for `key` (returns `true` once across the fleet). */
|
|
446
499
|
claim(key: string): Promise<boolean>;
|
|
447
500
|
}
|
|
448
|
-
/** A work handler: maps typed input (+ context) to
|
|
449
|
-
type WorkHandler<I,
|
|
501
|
+
/** A work handler: maps typed input (+ context) to a {@link WorkResult} describing what it produced. */
|
|
502
|
+
type WorkHandler<I, S, G> = (input: I, ctx: WorkContext) => WorkResult<S, G> | Promise<WorkResult<S, G>>;
|
|
450
503
|
/**
|
|
451
504
|
* Per-instance options resolved at enqueue time and **serialized with the instance**.
|
|
452
505
|
* Provided at queue time, as per-type constants, or computed by {@link WorkOptions.options}.
|
|
@@ -467,6 +520,13 @@ interface WorkInstanceOptions {
|
|
|
467
520
|
readonly priority?: number;
|
|
468
521
|
/** Fairness group label — consumed by `balancedDoer`. */
|
|
469
522
|
readonly group?: string;
|
|
523
|
+
/**
|
|
524
|
+
* Absolute time (epoch ms) by which the item must have **started and finished**. Past it, the item
|
|
525
|
+
* is no longer retried — it goes terminal and an `'expired'` event fires. Wins over {@link timeout}.
|
|
526
|
+
*/
|
|
527
|
+
readonly deadline?: number;
|
|
528
|
+
/** Relative deadline (ms from enqueue) — `deadline = queueAt + timeout`. See {@link deadline}. */
|
|
529
|
+
readonly timeout?: number;
|
|
470
530
|
/** Skip the durable queue and run this item directly via the doer (in-process; see {@link WorkOptions.skipQueue}). */
|
|
471
531
|
readonly skipQueue?: boolean;
|
|
472
532
|
}
|
|
@@ -536,6 +596,14 @@ interface WorkOptions<I> {
|
|
|
536
596
|
readonly onFailure?: FailureClassifier;
|
|
537
597
|
/** Derive `logWith` context from this type's input (merged over the global hook). */
|
|
538
598
|
readonly logContext?: (input: I) => object;
|
|
599
|
+
/** Default relative deadline (ms from enqueue) for this type — see {@link WorkInstanceOptions.timeout}. */
|
|
600
|
+
readonly timeout?: number;
|
|
601
|
+
/**
|
|
602
|
+
* Require every `ctx.queue`/`ctx.result`/`.next` to be **returned** from the handler (so the group
|
|
603
|
+
* type reflects it) — an un-returned instruction throws. Overrides {@link WorkSystemOptions.strictReturn}.
|
|
604
|
+
* Set `false` to allow detached `ctx.queue` (the work still runs, but its group type won't include it).
|
|
605
|
+
*/
|
|
606
|
+
readonly strictReturn?: boolean;
|
|
539
607
|
/**
|
|
540
608
|
* Run this type **without the durable queue** — straight to the doer, in-process.
|
|
541
609
|
* Retries, grouping, priority, events, and results still work; there is no queue,
|
|
@@ -544,50 +612,55 @@ interface WorkOptions<I> {
|
|
|
544
612
|
*/
|
|
545
613
|
readonly skipQueue?: boolean;
|
|
546
614
|
}
|
|
547
|
-
/** The full definition behind a {@link WorkBuilder}. */
|
|
548
|
-
interface WorkDefinition<I,
|
|
615
|
+
/** The full definition behind a {@link WorkBuilder}. `S`/`G` are the work's self/group result types. */
|
|
616
|
+
interface WorkDefinition<I, S, G> {
|
|
549
617
|
readonly name: string;
|
|
550
|
-
readonly handler: WorkHandler<I,
|
|
618
|
+
readonly handler: WorkHandler<I, S, G>;
|
|
551
619
|
readonly options: WorkOptions<I>;
|
|
552
|
-
/** Present for batched work types (see {@link defineBatchWork}). */
|
|
553
|
-
readonly batch?: BatchConfig<I,
|
|
620
|
+
/** Present for batched work types (see {@link defineBatchWork}); a batch produces a value per item. */
|
|
621
|
+
readonly batch?: BatchConfig<I, S>;
|
|
554
622
|
}
|
|
555
623
|
/**
|
|
556
624
|
* A callable work builder. Invoke it with the work's input to mint a queueable
|
|
557
625
|
* {@link Work} (with a fresh id); it also exposes its `type` and underlying `def`.
|
|
558
626
|
*/
|
|
559
|
-
interface WorkBuilder<Name extends string, I,
|
|
627
|
+
interface WorkBuilder<Name extends string, I, S, G> {
|
|
560
628
|
/** Build a type-checked, queueable instance from this work's input. */
|
|
561
|
-
(input: I): Work<Name,
|
|
629
|
+
(input: I): Work<Name, S, G>;
|
|
562
630
|
/** The work type name. */
|
|
563
631
|
readonly type: Name;
|
|
564
632
|
/** The underlying definition (handler + options). */
|
|
565
|
-
readonly def: WorkDefinition<I,
|
|
633
|
+
readonly def: WorkDefinition<I, S, G>;
|
|
566
634
|
}
|
|
567
635
|
/** The loose base every {@link WorkBuilder} satisfies regardless of its input type. */
|
|
568
|
-
type AnyWorkBuilder = WorkBuilder<string, never, unknown>;
|
|
636
|
+
type AnyWorkBuilder = WorkBuilder<string, never, unknown, unknown>;
|
|
569
637
|
/**
|
|
570
|
-
* Define a work type.
|
|
571
|
-
*
|
|
638
|
+
* Define a work type. The handler **returns a {@link WorkResult}** — `ctx.result(value)`,
|
|
639
|
+
* `ctx.queue(...)`, `ctx.void()`, or a `.next(...)` chain — and its `S`/`G` types are inferred
|
|
640
|
+
* from that return: `S` is what `.result()` resolves to alone, `G` what it contributes to the group.
|
|
572
641
|
*/
|
|
573
|
-
declare function defineWork<Name extends string, I,
|
|
642
|
+
declare function defineWork<Name extends string, I, S, G>(name: Name, handler: WorkHandler<I, S, G>, opts?: WorkOptions<I>): WorkBuilder<Name, I, S, NonVoidUnion<G>>;
|
|
574
643
|
/**
|
|
575
|
-
* Define a **batched** work type. Items still enqueue, retry, prioritize, and join
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
644
|
+
* Define a **batched** work type. Items still enqueue, retry, prioritize, and join groups
|
|
645
|
+
* individually, but execute together via {@link BatchConfig.run} once `size` accumulate or `maxWait`
|
|
646
|
+
* ms elapse — so each `.result()` resolves to its aligned output `O` (which is also its group
|
|
647
|
+
* contribution). The per-type {@link WorkOptions.doer} governs how many *batches* run at once.
|
|
579
648
|
*/
|
|
580
|
-
declare function defineBatchWork<Name extends string, I, O>(name: Name, config: BatchConfig<I, O> & WorkOptions<I>): WorkBuilder<Name, I, O
|
|
649
|
+
declare function defineBatchWork<Name extends string, I, O>(name: Name, config: BatchConfig<I, O> & WorkOptions<I>): WorkBuilder<Name, I, O, NonVoidUnion<O>>;
|
|
581
650
|
/** The input type a builder accepts. */
|
|
582
651
|
type InputOf<B> = B extends ((input: infer I) => unknown) ? I : never;
|
|
583
|
-
/** The
|
|
584
|
-
type
|
|
652
|
+
/** The *awaited-alone* result type a builder's instances carry. */
|
|
653
|
+
type SelfOf<B> = B extends ((...args: never[]) => Work<string, infer S, unknown>) ? S : never;
|
|
654
|
+
/** The *group* contribution type a builder's instances carry. */
|
|
655
|
+
type GroupOfBuilder<B> = B extends ((...args: never[]) => Work<string, unknown, infer G>) ? G : never;
|
|
585
656
|
/** The name of a builder. */
|
|
586
657
|
type NameOf<B> = B extends {
|
|
587
658
|
readonly type: infer N extends string;
|
|
588
659
|
} ? N : never;
|
|
589
|
-
/** The
|
|
590
|
-
type
|
|
660
|
+
/** The *awaited-alone* result type carried by a {@link Work}. */
|
|
661
|
+
type SelfOfWork<W> = W extends Work<string, infer S, unknown> ? S : unknown;
|
|
662
|
+
/** The *group* contribution type carried by a {@link Work}. */
|
|
663
|
+
type GroupOfWork<W> = W extends Work<string, unknown, infer G> ? G : unknown;
|
|
591
664
|
/** Drop `void`/`undefined` from a union (work that returns "nothing"). */
|
|
592
665
|
type NonVoidUnion<U> = Exclude<U, void | undefined>;
|
|
593
666
|
/** The union of every registered work name. */
|
|
@@ -598,16 +671,13 @@ type BuilderForName<Defs extends readonly AnyWorkBuilder[], K extends string> =
|
|
|
598
671
|
}>;
|
|
599
672
|
/** The input type of the registry's work named `K`. */
|
|
600
673
|
type InputForName<Defs extends readonly AnyWorkBuilder[], K extends string> = InputOf<BuilderForName<Defs, K>>;
|
|
601
|
-
/** The
|
|
602
|
-
type
|
|
603
|
-
/**
|
|
604
|
-
|
|
605
|
-
* output. The value a top-level `await enqueue(...)` resolves to.
|
|
606
|
-
*/
|
|
607
|
-
type GroupResult<Defs extends readonly AnyWorkBuilder[]> = NonVoidUnion<OutputOf<Defs[number]>>;
|
|
674
|
+
/** The *awaited-alone* result type of the registry's work named `K`. */
|
|
675
|
+
type SelfForName<Defs extends readonly AnyWorkBuilder[], K extends string> = SelfOf<BuilderForName<Defs, K>>;
|
|
676
|
+
/** The *group* contribution type of the registry's work named `K`. */
|
|
677
|
+
type GroupForName<Defs extends readonly AnyWorkBuilder[], K extends string> = GroupOfBuilder<BuilderForName<Defs, K>>;
|
|
608
678
|
/**
|
|
609
|
-
* The thenable returned by `enqueue`. **Awaiting it resolves to the group result**
|
|
610
|
-
*
|
|
679
|
+
* The thenable returned by `enqueue`. **Awaiting it resolves to the group result** (the
|
|
680
|
+
* root work's `Group` contribution); use {@link result} for this item's own output and
|
|
611
681
|
* {@link group} for the explicit group form.
|
|
612
682
|
*/
|
|
613
683
|
interface WorkHandle<Self, Group> extends PromiseLike<Group> {
|
|
@@ -669,6 +739,8 @@ type WorkEvent = {
|
|
|
669
739
|
readonly id: string;
|
|
670
740
|
readonly type: string;
|
|
671
741
|
readonly groupId: string;
|
|
742
|
+
readonly parent?: string;
|
|
743
|
+
readonly dependents?: readonly string[];
|
|
672
744
|
readonly at: number;
|
|
673
745
|
} | {
|
|
674
746
|
readonly kind: 'started';
|
|
@@ -676,6 +748,8 @@ type WorkEvent = {
|
|
|
676
748
|
readonly type: string;
|
|
677
749
|
readonly groupId: string;
|
|
678
750
|
readonly attempt: number;
|
|
751
|
+
readonly parent?: string;
|
|
752
|
+
readonly dependents?: readonly string[];
|
|
679
753
|
readonly at: number;
|
|
680
754
|
} | {
|
|
681
755
|
readonly kind: 'deferred';
|
|
@@ -691,6 +765,8 @@ type WorkEvent = {
|
|
|
691
765
|
readonly groupId: string;
|
|
692
766
|
readonly attempt: number;
|
|
693
767
|
readonly result: unknown;
|
|
768
|
+
readonly parent?: string;
|
|
769
|
+
readonly dependents?: readonly string[];
|
|
694
770
|
readonly at: number;
|
|
695
771
|
} | {
|
|
696
772
|
readonly kind: 'failed';
|
|
@@ -700,6 +776,17 @@ type WorkEvent = {
|
|
|
700
776
|
readonly attempt: number;
|
|
701
777
|
readonly error: string;
|
|
702
778
|
readonly willRetry: boolean;
|
|
779
|
+
readonly parent?: string;
|
|
780
|
+
readonly dependents?: readonly string[];
|
|
781
|
+
readonly at: number;
|
|
782
|
+
} | {
|
|
783
|
+
readonly kind: 'expired';
|
|
784
|
+
readonly id: string;
|
|
785
|
+
readonly type: string;
|
|
786
|
+
readonly groupId: string;
|
|
787
|
+
readonly deadline: number;
|
|
788
|
+
readonly parent?: string;
|
|
789
|
+
readonly dependents?: readonly string[];
|
|
703
790
|
readonly at: number;
|
|
704
791
|
} | {
|
|
705
792
|
readonly kind: 'group-done';
|
|
@@ -844,6 +931,17 @@ interface WorkSystemOptions {
|
|
|
844
931
|
* Exposed back as {@link WorkSystem.metrics}.
|
|
845
932
|
*/
|
|
846
933
|
readonly metrics?: Metrics;
|
|
934
|
+
/**
|
|
935
|
+
* Require a handler to **return** every `ctx.queue`/`ctx.result`/`.next` it creates (so the work's
|
|
936
|
+
* group type reflects it); an un-returned instruction throws (default `true`). Per-type
|
|
937
|
+
* {@link WorkOptions.strictReturn} overrides. Turn off if you don't care about precise group typing.
|
|
938
|
+
*/
|
|
939
|
+
readonly strictReturn?: boolean;
|
|
940
|
+
/**
|
|
941
|
+
* Generate the ids the **engine** mints (group ids, name-form item ids, dependency keys, re-pushes).
|
|
942
|
+
* Defaults to the process generator (see `setIdGenerator`, which also governs build-time work ids).
|
|
943
|
+
*/
|
|
944
|
+
readonly generateId?: () => string;
|
|
847
945
|
/** Start the worker loop immediately (default true). */
|
|
848
946
|
readonly autoStart?: boolean;
|
|
849
947
|
/** Clock injection for tests (default `Date.now`). */
|
|
@@ -853,10 +951,10 @@ interface WorkSystemOptions {
|
|
|
853
951
|
}
|
|
854
952
|
/** The work system returned by `createWork`. */
|
|
855
953
|
interface WorkSystem<Defs extends readonly AnyWorkBuilder[]> {
|
|
856
|
-
/** Enqueue a built instance; await the handle for the group result, `.result()` for its own. */
|
|
857
|
-
enqueue<W extends Work>(work: W, options?: WorkInstanceOptions): WorkHandle<
|
|
954
|
+
/** Enqueue a built instance; await the handle for the **group** result, `.result()` for its own. */
|
|
955
|
+
enqueue<W extends Work>(work: W, options?: WorkInstanceOptions): WorkHandle<SelfOfWork<W>, GroupOfWork<W>>;
|
|
858
956
|
/** Enqueue by registered name with a type-checked input. */
|
|
859
|
-
enqueue<K extends RegistryNames<Defs>>(name: K, input: InputForName<Defs, K>, options?: WorkInstanceOptions): WorkHandle<
|
|
957
|
+
enqueue<K extends RegistryNames<Defs>>(name: K, input: InputForName<Defs, K>, options?: WorkInstanceOptions): WorkHandle<SelfForName<Defs, K>, GroupForName<Defs, K>>;
|
|
860
958
|
/** Register a recurring schedule; returns a cancel function. */
|
|
861
959
|
schedule(config: ScheduleConfig): () => void;
|
|
862
960
|
/** Start the worker + scheduler loops (idempotent). */
|
|
@@ -939,6 +1037,7 @@ declare const WORK_METRICS: {
|
|
|
939
1037
|
readonly retried: "work.retried";
|
|
940
1038
|
readonly deferred: "work.deferred";
|
|
941
1039
|
readonly rescheduled: "work.rescheduled";
|
|
1040
|
+
readonly expired: "work.expired";
|
|
942
1041
|
readonly active: "work.active";
|
|
943
1042
|
readonly pending: "work.pending";
|
|
944
1043
|
readonly running: "work.running";
|
|
@@ -1113,7 +1212,7 @@ declare function conditionMet(condition: DependencyCondition, states: readonly (
|
|
|
1113
1212
|
* Build a dependency: when the works it waits `on` satisfy `config`, it queues its
|
|
1114
1213
|
* `queue` dependents (once). Enqueue it like any work.
|
|
1115
1214
|
*/
|
|
1116
|
-
declare function dependency(opts: DependencyOptions): Work<typeof DEPENDENCY_TYPE, void>;
|
|
1215
|
+
declare function dependency(opts: DependencyOptions): Work<typeof DEPENDENCY_TYPE, void, void>;
|
|
1117
1216
|
/**
|
|
1118
1217
|
* The non-blocking handler for {@link DEPENDENCY_TYPE}: check once, then fire or
|
|
1119
1218
|
* re-queue. Registered automatically by every work system. Remembers terminal statuses
|
|
@@ -1148,12 +1247,14 @@ declare function nextAfter(expr: string, fromMs: number): number | undefined;
|
|
|
1148
1247
|
declare const work: WorkSystem<readonly AnyWorkBuilder[]>;
|
|
1149
1248
|
/** Enqueue on the default system (instance form). */
|
|
1150
1249
|
declare const enqueue: {
|
|
1151
|
-
<W extends Work>(work: W, options?: WorkInstanceOptions): WorkHandle<
|
|
1250
|
+
<W extends Work>(work: W, options?: WorkInstanceOptions): WorkHandle<SelfOfWork<W>, GroupOfWork<W>>;
|
|
1152
1251
|
<K extends string>(name: K, input: InputOf<Extract<AnyWorkBuilder, {
|
|
1153
1252
|
readonly type: K;
|
|
1154
|
-
}>>, options?: WorkInstanceOptions): WorkHandle<
|
|
1253
|
+
}>>, options?: WorkInstanceOptions): WorkHandle<SelfOf<Extract<AnyWorkBuilder, {
|
|
1254
|
+
readonly type: K;
|
|
1255
|
+
}>>, GroupOfBuilder<Extract<AnyWorkBuilder, {
|
|
1155
1256
|
readonly type: K;
|
|
1156
|
-
}
|
|
1257
|
+
}>>>;
|
|
1157
1258
|
};
|
|
1158
1259
|
/** Register a recurring schedule on the default system. */
|
|
1159
1260
|
declare const schedule: (config: ScheduleConfig) => () => void;
|
|
@@ -1164,4 +1265,4 @@ declare const stop: () => Promise<void>;
|
|
|
1164
1265
|
/** Snapshot the default system's known work states. */
|
|
1165
1266
|
declare const list: () => Promise<WorkState[]>;
|
|
1166
1267
|
//#endregion
|
|
1167
|
-
export { type ActiveWork, type AdaptiveDelay, type AdaptiveDelayOptions, type AnyWorkBuilder, type Backend, type BackpressureContext, type BatchConfig, type BoundedDoerOptions, type BuilderForName, type Counter, DEFAULT_BUCKETS, DEFAULT_RETRY_OPTIONS, DEPENDENCY_TYPE, type DeadLettered, type DependencyCondition, type DependencyOptions, type Doer, type DoerTaskOptions, type FailureClassifier, type FailureDecision, type Gauge, type
|
|
1268
|
+
export { type ActiveWork, type AdaptiveDelay, type AdaptiveDelayOptions, type AnyWorkBuilder, type Backend, type BackpressureContext, type BatchConfig, type BoundedDoerOptions, type BuilderForName, type Counter, DEFAULT_BUCKETS, DEFAULT_RETRY_OPTIONS, DEPENDENCY_TYPE, type DeadLettered, type DependencyCondition, type DependencyOptions, type Doer, type DoerTaskOptions, type FailureClassifier, type FailureDecision, type Gauge, type GroupForName, type GroupItem, type GroupOf, type GroupOfBuilder, type GroupOfItem, type GroupOfWork, type InputForName, type InputOf, type JsonCodec, type Labels, type MemoryBackendOptions, type MemoryOptions, type MemoryQueue, type MemoryQueueOptions, type MemoryQueuePersistence, type Metrics, type MetricsOptions, type NameOf, type NonVoidUnion, type PubSub, type PulledWork, type PushOptions, type Queue, type QueueFsLike, type RegistryNames, type ResultOptions, RetryAbort, type RetryOptions, type RetryState, type ScheduleConfig, type SelfForName, type SelfOf, type SelfOfWork, type StatBucket, type StatKind, type StatMeta, type StatSummary, type StatValue, type Store, type Summary, type UnhandledWorkGroupInfo, type UnlimitedDoerOptions, WORK_METRICS, type Work, type WorkAcceptInfo, type WorkBuilder, type WorkContext, type WorkDefinition, WorkDelayError, type WorkDelaySpec, type WorkEvent, type WorkFailureInfo, type WorkHandle, type WorkHandler, type WorkInstanceOptions, type WorkOptions, type WorkResult, type WorkState, type WorkStatus, type WorkSystem, type WorkSystemOptions, adaptiveDelay, ageDoer, backoff, balancedDoer, conditionMet, createMetrics, createWork, defaultCodec, defineBatchWork, defineWork, dependency, enqueue, formatPrometheus, getDefaultRetryOptions, list, memoryBackend, memoryPubSub, memoryQueue, memoryStore, nextAfter, parseCron, priorityDoer, retry, schedule, setDefaultRetryOptions, setIdGenerator, start, stop, unlimitedDoer, work };
|