@nlozgachev/pipelined 0.63.0 → 0.64.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/dist/core.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as Maybe, R as Result, T as Task } from './Validation-KFUpea_k.cjs';
2
- export { E as Equality, a as Err, F as Failed, N as None, O as Ok, b as Ordering, P as Passed, S as Some, V as Validation } from './Validation-KFUpea_k.cjs';
1
+ import { M as Maybe, R as Result, T as Task } from './Task-C_goFYQ1.cjs';
2
+ export { E as Equality, a as Err, F as Failed, N as None, O as Ok, b as Ordering, P as Passed, S as Some, V as Validation } from './Task-C_goFYQ1.cjs';
3
3
  import { o as WithValue, i as WithLog, D as Deferred, R as RetryOptions, n as WithTimeout, j as WithMinInterval, c as WithCooldown, W as WithConcurrency, m as WithSize, d as WithDuration, k as WithN, h as WithKind, e as WithError, b as TimeoutOptions, g as WithFirst, l as WithSecond } from './InternalTypes-GFn4RTwD.cjs';
4
4
  import { D as Duration } from './Duration-DeyxG6VQ.cjs';
5
5
  import './types.cjs';
@@ -565,10 +565,10 @@ declare function interpretFn<I, E, A, O extends AllInterpretOptions<I, E>>(op: O
565
565
  *
566
566
  * const manager = Op.interpret(fetchUser, { strategy: "restartable" });
567
567
  * manager.subscribe(state => {
568
- * if (Op.isPending(state)) showSpinner();
569
- * if (Op.isOk(state)) render(state.value);
570
- * if (Op.isErr(state)) showError(state.error);
571
- * if (Op.isNil(state)) resetUI();
568
+ * if (Op.is.pending(state)) showSpinner();
569
+ * if (Op.is.ok(state)) render(state.value);
570
+ * if (Op.is.err(state)) showError(state.error);
571
+ * if (Op.is.nil(state)) resetUI();
572
572
  * });
573
573
  * manager.run(userId);
574
574
  * ```
@@ -581,18 +581,116 @@ type Op<I, E, A> = {
581
581
  readonly _factory: (input: I, signal: AbortSignal) => Deferred<Result<E, A> | null>;
582
582
  };
583
583
  declare const Op: {
584
- nil: (reason: Op.NilReason) => Op.Nil;
584
+ make: {
585
+ /**
586
+ * Creates an Ok outcome with the given value.
587
+ *
588
+ * @example
589
+ * ```ts
590
+ * Op.make.ok(42); // { kind: "OpOk", value: 42 }
591
+ * ```
592
+ */
593
+ ok: <A>(value: A) => Op.Ok<A>;
594
+ /**
595
+ * Creates an Err outcome with the given error.
596
+ *
597
+ * @example
598
+ * ```ts
599
+ * Op.make.err("Something went wrong"); // { kind: "OpErr", error: "Something went wrong" }
600
+ * ```
601
+ */
602
+ err: <E>(error: E) => Op.Err<E>;
603
+ /**
604
+ * Creates a Nil outcome with the given cancellation/drop reason.
605
+ *
606
+ * @example
607
+ * ```ts
608
+ * Op.make.nil("aborted"); // { kind: "OpNil", reason: "aborted" }
609
+ * ```
610
+ */
611
+ nil: (reason: Op.NilReason) => Op.Nil;
612
+ };
613
+ is: {
614
+ /**
615
+ * Type guard that checks if an Op state is Idle.
616
+ *
617
+ * @example
618
+ * ```ts
619
+ * if (Op.is.idle(manager.state)) {
620
+ * console.log("Ready to execute");
621
+ * }
622
+ * ```
623
+ */
624
+ idle: <E, A>(state: Op.State<E, A>) => state is Op.Idle;
625
+ /**
626
+ * Type guard that checks if an Op state is Pending (actively executing).
627
+ *
628
+ * @example
629
+ * ```ts
630
+ * if (Op.is.pending(manager.state)) {
631
+ * showSpinner();
632
+ * }
633
+ * ```
634
+ */
635
+ pending: <E, A>(state: Op.State<E, A>) => state is Op.Pending;
636
+ /**
637
+ * Type guard that checks if an Op state is Queued (waiting in a concurrency queue).
638
+ *
639
+ * @example
640
+ * ```ts
641
+ * if (Op.is.queued(manager.state)) {
642
+ * console.log("Position in queue:", manager.state.position);
643
+ * }
644
+ * ```
645
+ */
646
+ queued: <E, A>(state: Op.State<E, A>) => state is Op.Queued;
647
+ /**
648
+ * Type guard that checks if an Op state is Retrying after a failure.
649
+ *
650
+ * @example
651
+ * ```ts
652
+ * if (Op.is.retrying(manager.state)) {
653
+ * console.log("Retry attempt:", manager.state.attempt);
654
+ * }
655
+ * ```
656
+ */
657
+ retrying: <E, A>(state: Op.State<E, A>) => state is Op.Retrying<E>;
658
+ /**
659
+ * Type guard that checks if an Op state or outcome is Ok.
660
+ *
661
+ * @example
662
+ * ```ts
663
+ * if (Op.is.ok(outcome)) {
664
+ * render(outcome.value);
665
+ * }
666
+ * ```
667
+ */
668
+ ok: <E, A>(state: Op.State<E, A>) => state is Op.Ok<A>;
669
+ /**
670
+ * Type guard that checks if an Op state or outcome is Err.
671
+ *
672
+ * @example
673
+ * ```ts
674
+ * if (Op.is.err(outcome)) {
675
+ * showError(outcome.error);
676
+ * }
677
+ * ```
678
+ */
679
+ err: <E, A>(state: Op.State<E, A>) => state is Op.Err<E>;
680
+ /**
681
+ * Type guard that checks if an Op state or outcome is Nil.
682
+ *
683
+ * @example
684
+ * ```ts
685
+ * if (Op.is.nil(outcome)) {
686
+ * console.log("Skipped due to:", outcome.reason);
687
+ * }
688
+ * ```
689
+ */
690
+ nil: <E, A>(state: Op.State<E, A>) => state is Op.Nil;
691
+ };
585
692
  create: <E, A, I = void>(factory: (signal: AbortSignal) => (input: I) => Promise<A>, onError: (e: unknown) => E) => Op<I, E, A>;
586
693
  lift: <I, A>(f: (input: I, signal: AbortSignal) => Promise<A>) => Op<I, unknown, A>;
587
- ok: <A>(value: A) => Op.Ok<A>;
588
- err: <E>(error: E) => Op.Err<E>;
589
- isIdle: <E, A>(state: Op.State<E, A>) => state is Op.Idle;
590
- isPending: <E, A>(state: Op.State<E, A>) => state is Op.Pending;
591
- isQueued: <E, A>(state: Op.State<E, A>) => state is Op.Queued;
592
- isRetrying: <E, A>(state: Op.State<E, A>) => state is Op.Retrying<E>;
593
- isOk: <E, A>(state: Op.State<E, A>) => state is Op.Ok<A>;
594
- isErr: <E, A>(state: Op.State<E, A>) => state is Op.Err<E>;
595
- isNil: <E, A>(state: Op.State<E, A>) => state is Op.Nil;
596
694
  match: <E, A, B>(cases: {
597
695
  ok: (a: A) => B;
598
696
  err: (e: E) => B;
package/dist/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as Maybe, R as Result, T as Task } from './Validation-C5RGZUXy.js';
2
- export { E as Equality, a as Err, F as Failed, N as None, O as Ok, b as Ordering, P as Passed, S as Some, V as Validation } from './Validation-C5RGZUXy.js';
1
+ import { M as Maybe, R as Result, T as Task } from './Task-9SJCMtG4.js';
2
+ export { E as Equality, a as Err, F as Failed, N as None, O as Ok, b as Ordering, P as Passed, S as Some, V as Validation } from './Task-9SJCMtG4.js';
3
3
  import { o as WithValue, i as WithLog, D as Deferred, R as RetryOptions, n as WithTimeout, j as WithMinInterval, c as WithCooldown, W as WithConcurrency, m as WithSize, d as WithDuration, k as WithN, h as WithKind, e as WithError, b as TimeoutOptions, g as WithFirst, l as WithSecond } from './InternalTypes-CCXa8Kvr.js';
4
4
  import { D as Duration } from './Duration-DeyxG6VQ.js';
5
5
  import './types.js';
@@ -565,10 +565,10 @@ declare function interpretFn<I, E, A, O extends AllInterpretOptions<I, E>>(op: O
565
565
  *
566
566
  * const manager = Op.interpret(fetchUser, { strategy: "restartable" });
567
567
  * manager.subscribe(state => {
568
- * if (Op.isPending(state)) showSpinner();
569
- * if (Op.isOk(state)) render(state.value);
570
- * if (Op.isErr(state)) showError(state.error);
571
- * if (Op.isNil(state)) resetUI();
568
+ * if (Op.is.pending(state)) showSpinner();
569
+ * if (Op.is.ok(state)) render(state.value);
570
+ * if (Op.is.err(state)) showError(state.error);
571
+ * if (Op.is.nil(state)) resetUI();
572
572
  * });
573
573
  * manager.run(userId);
574
574
  * ```
@@ -581,18 +581,116 @@ type Op<I, E, A> = {
581
581
  readonly _factory: (input: I, signal: AbortSignal) => Deferred<Result<E, A> | null>;
582
582
  };
583
583
  declare const Op: {
584
- nil: (reason: Op.NilReason) => Op.Nil;
584
+ make: {
585
+ /**
586
+ * Creates an Ok outcome with the given value.
587
+ *
588
+ * @example
589
+ * ```ts
590
+ * Op.make.ok(42); // { kind: "OpOk", value: 42 }
591
+ * ```
592
+ */
593
+ ok: <A>(value: A) => Op.Ok<A>;
594
+ /**
595
+ * Creates an Err outcome with the given error.
596
+ *
597
+ * @example
598
+ * ```ts
599
+ * Op.make.err("Something went wrong"); // { kind: "OpErr", error: "Something went wrong" }
600
+ * ```
601
+ */
602
+ err: <E>(error: E) => Op.Err<E>;
603
+ /**
604
+ * Creates a Nil outcome with the given cancellation/drop reason.
605
+ *
606
+ * @example
607
+ * ```ts
608
+ * Op.make.nil("aborted"); // { kind: "OpNil", reason: "aborted" }
609
+ * ```
610
+ */
611
+ nil: (reason: Op.NilReason) => Op.Nil;
612
+ };
613
+ is: {
614
+ /**
615
+ * Type guard that checks if an Op state is Idle.
616
+ *
617
+ * @example
618
+ * ```ts
619
+ * if (Op.is.idle(manager.state)) {
620
+ * console.log("Ready to execute");
621
+ * }
622
+ * ```
623
+ */
624
+ idle: <E, A>(state: Op.State<E, A>) => state is Op.Idle;
625
+ /**
626
+ * Type guard that checks if an Op state is Pending (actively executing).
627
+ *
628
+ * @example
629
+ * ```ts
630
+ * if (Op.is.pending(manager.state)) {
631
+ * showSpinner();
632
+ * }
633
+ * ```
634
+ */
635
+ pending: <E, A>(state: Op.State<E, A>) => state is Op.Pending;
636
+ /**
637
+ * Type guard that checks if an Op state is Queued (waiting in a concurrency queue).
638
+ *
639
+ * @example
640
+ * ```ts
641
+ * if (Op.is.queued(manager.state)) {
642
+ * console.log("Position in queue:", manager.state.position);
643
+ * }
644
+ * ```
645
+ */
646
+ queued: <E, A>(state: Op.State<E, A>) => state is Op.Queued;
647
+ /**
648
+ * Type guard that checks if an Op state is Retrying after a failure.
649
+ *
650
+ * @example
651
+ * ```ts
652
+ * if (Op.is.retrying(manager.state)) {
653
+ * console.log("Retry attempt:", manager.state.attempt);
654
+ * }
655
+ * ```
656
+ */
657
+ retrying: <E, A>(state: Op.State<E, A>) => state is Op.Retrying<E>;
658
+ /**
659
+ * Type guard that checks if an Op state or outcome is Ok.
660
+ *
661
+ * @example
662
+ * ```ts
663
+ * if (Op.is.ok(outcome)) {
664
+ * render(outcome.value);
665
+ * }
666
+ * ```
667
+ */
668
+ ok: <E, A>(state: Op.State<E, A>) => state is Op.Ok<A>;
669
+ /**
670
+ * Type guard that checks if an Op state or outcome is Err.
671
+ *
672
+ * @example
673
+ * ```ts
674
+ * if (Op.is.err(outcome)) {
675
+ * showError(outcome.error);
676
+ * }
677
+ * ```
678
+ */
679
+ err: <E, A>(state: Op.State<E, A>) => state is Op.Err<E>;
680
+ /**
681
+ * Type guard that checks if an Op state or outcome is Nil.
682
+ *
683
+ * @example
684
+ * ```ts
685
+ * if (Op.is.nil(outcome)) {
686
+ * console.log("Skipped due to:", outcome.reason);
687
+ * }
688
+ * ```
689
+ */
690
+ nil: <E, A>(state: Op.State<E, A>) => state is Op.Nil;
691
+ };
585
692
  create: <E, A, I = void>(factory: (signal: AbortSignal) => (input: I) => Promise<A>, onError: (e: unknown) => E) => Op<I, E, A>;
586
693
  lift: <I, A>(f: (input: I, signal: AbortSignal) => Promise<A>) => Op<I, unknown, A>;
587
- ok: <A>(value: A) => Op.Ok<A>;
588
- err: <E>(error: E) => Op.Err<E>;
589
- isIdle: <E, A>(state: Op.State<E, A>) => state is Op.Idle;
590
- isPending: <E, A>(state: Op.State<E, A>) => state is Op.Pending;
591
- isQueued: <E, A>(state: Op.State<E, A>) => state is Op.Queued;
592
- isRetrying: <E, A>(state: Op.State<E, A>) => state is Op.Retrying<E>;
593
- isOk: <E, A>(state: Op.State<E, A>) => state is Op.Ok<A>;
594
- isErr: <E, A>(state: Op.State<E, A>) => state is Op.Err<E>;
595
- isNil: <E, A>(state: Op.State<E, A>) => state is Op.Nil;
596
694
  match: <E, A, B>(cases: {
597
695
  ok: (a: A) => B;
598
696
  err: (e: E) => B;