@orpc/shared 2.0.0-beta.49 → 2.0.0-beta.50

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.
Files changed (49) hide show
  1. package/dist/args.d.ts +1 -1
  2. package/dist/args.js +4 -2
  3. package/dist/array.d.ts +4 -1
  4. package/dist/array.js +11 -5
  5. package/dist/bigint.d.ts +1 -1
  6. package/dist/bigint.js +12 -16
  7. package/dist/buffer.d.ts +4 -4
  8. package/dist/buffer.js +44 -67
  9. package/dist/compare.d.ts +1 -1
  10. package/dist/compare.js +23 -42
  11. package/dist/consts.d.ts +1 -1
  12. package/dist/consts.js +3 -1
  13. package/dist/error.d.ts +1 -1
  14. package/dist/error.js +4 -2
  15. package/dist/function.d.ts +1 -1
  16. package/dist/function.js +27 -32
  17. package/dist/http.d.ts +29 -0
  18. package/dist/http.js +128 -94
  19. package/dist/id.d.ts +1 -1
  20. package/dist/id.js +11 -11
  21. package/dist/index.d.ts +26 -34
  22. package/dist/index.js +23 -32
  23. package/dist/interceptor.d.ts +17 -17
  24. package/dist/interceptor.js +106 -126
  25. package/dist/iterator.d.ts +41 -41
  26. package/dist/iterator.js +136 -152
  27. package/dist/object.d.ts +10 -8
  28. package/dist/object.js +176 -227
  29. package/dist/plugin.d.ts +7 -7
  30. package/dist/plugin.js +41 -57
  31. package/dist/promise.d.ts +4 -4
  32. package/dist/promise.js +28 -28
  33. package/dist/proxy.d.ts +2 -2
  34. package/dist/proxy.js +23 -22
  35. package/dist/queue.d.ts +13 -13
  36. package/dist/queue.js +64 -79
  37. package/dist/regex.d.ts +9 -0
  38. package/dist/regex.js +11 -0
  39. package/dist/signal.d.ts +7 -2
  40. package/dist/signal.js +83 -80
  41. package/dist/stream.d.ts +23 -23
  42. package/dist/stream.js +118 -144
  43. package/dist/tracing.d.ts +50 -50
  44. package/dist/tracing.js +60 -85
  45. package/dist/types.d.ts +7 -10
  46. package/dist/value.d.ts +1 -1
  47. package/dist/value.js +5 -5
  48. package/package.json +2 -2
  49. package/dist/types.js +0 -1
package/dist/promise.js CHANGED
@@ -1,32 +1,32 @@
1
+ // src/promise.ts
1
2
  /**
2
- * Creates a promise together with its associated `resolve` and `reject`
3
- * functions.
4
- *
5
- * Equivalent to `Promise.withResolvers()`, but works in environments
6
- * where that API is not yet available.
7
- */
8
- export function promiseWithResolvers() {
9
- const result = {};
10
- result.promise = new Promise((resolve, reject) => {
11
- result.resolve = resolve;
12
- result.reject = reject;
13
- });
14
- return result;
3
+ * Creates a promise together with its associated `resolve` and `reject`
4
+ * functions.
5
+ *
6
+ * Equivalent to `Promise.withResolvers()`, but works in environments
7
+ * where that API is not yet available.
8
+ */
9
+ function promiseWithResolvers() {
10
+ const result = {};
11
+ result.promise = new Promise((resolve, reject) => {
12
+ result.resolve = resolve;
13
+ result.reject = reject;
14
+ });
15
+ return result;
15
16
  }
16
17
  /**
17
- * Captures the current async context (such as AsyncLocalStorage) through a promise reaction, so no runtime API is needed.
18
- * The returned function runs a callback inside it once; later calls reject.
19
- */
20
- export function captureAsyncContext() {
21
- const { promise, resolve } = promiseWithResolvers();
22
- const result = promise.then((callback) => callback());
23
- let called = false;
24
- return (callback) => {
25
- if (called) {
26
- return Promise.reject(new Error('A captured async context can be run only once.'));
27
- }
28
- called = true;
29
- resolve(callback);
30
- return result;
31
- };
18
+ * Captures the current async context (such as AsyncLocalStorage) through a promise reaction, so no runtime API is needed.
19
+ * The returned function runs a callback inside it once; later calls reject.
20
+ */
21
+ function captureAsyncContext() {
22
+ const { promise, resolve } = promiseWithResolvers();
23
+ const result = promise.then((callback) => callback());
24
+ let called = false;
25
+ return (callback) => {
26
+ if (called) return Promise.reject(/* @__PURE__ */ new Error("A captured async context can be run only once."));
27
+ called = true;
28
+ resolve(callback);
29
+ return result;
30
+ };
32
31
  }
32
+ export { captureAsyncContext, promiseWithResolvers };
package/dist/proxy.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Value } from './value.ts';
1
+ import { Value } from "./value.js";
2
2
  /**
3
3
  * Creates a proxy that overlays a `partial` object on top of a `target`.
4
4
  *
@@ -9,4 +9,4 @@ import type { Value } from './value.ts';
9
9
  * Useful for overriding specific properties of an object while delegating
10
10
  * all other access to the original target without needing to know its full structure.
11
11
  */
12
- export declare function override<T extends object, U extends object>(target: Value<T>, partial: U): U & Omit<T, keyof U>;
12
+ export declare function override<T extends object, U extends object>(target: Value<T>, partial: U): U & Omit<T, keyof U>;
package/dist/proxy.js CHANGED
@@ -1,24 +1,25 @@
1
- import { getOrBind } from '@standard-server/shared';
2
- import { value } from './value.js';
1
+ import { value } from "./value.js";
2
+ import { getOrBind } from "@standard-server/shared";
3
+ // src/proxy.ts
3
4
  /**
4
- * Creates a proxy that overlays a `partial` object on top of a `target`.
5
- *
6
- * - Properties from `partial` take precedence.
7
- * - Properties not present in `partial` fall back to the resolved `target`.
8
- * - Methods are bound to the proxy to ensure a consistent `this` context.
9
- *
10
- * Useful for overriding specific properties of an object while delegating
11
- * all other access to the original target without needing to know its full structure.
12
- */
13
- export function override(target, partial) {
14
- const proxy = new Proxy(typeof target === 'function' ? partial : target, {
15
- get(_, prop) {
16
- const targetValue = prop in partial ? partial : value(target);
17
- return getOrBind(targetValue, prop);
18
- },
19
- has(_, prop) {
20
- return Reflect.has(partial, prop) || Reflect.has(value(target), prop);
21
- },
22
- });
23
- return proxy;
5
+ * Creates a proxy that overlays a `partial` object on top of a `target`.
6
+ *
7
+ * - Properties from `partial` take precedence.
8
+ * - Properties not present in `partial` fall back to the resolved `target`.
9
+ * - Methods are bound to the proxy to ensure a consistent `this` context.
10
+ *
11
+ * Useful for overriding specific properties of an object while delegating
12
+ * all other access to the original target without needing to know its full structure.
13
+ */
14
+ function override(target, partial) {
15
+ return new Proxy(typeof target === "function" ? partial : target, {
16
+ get(_, prop) {
17
+ const targetValue = prop in partial ? partial : value(target);
18
+ return getOrBind(targetValue, prop);
19
+ },
20
+ has(_, prop) {
21
+ return Reflect.has(partial, prop) || Reflect.has(value(target), prop);
22
+ }
23
+ });
24
24
  }
25
+ export { override };
package/dist/queue.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  export interface AsyncIdQueueCloseOptions {
2
- id?: string | undefined;
3
- reason?: unknown;
2
+ id?: string | undefined;
3
+ reason?: unknown;
4
4
  }
5
5
  export declare class AsyncIdQueue<T> {
6
- private readonly openIds;
7
- private readonly queues;
8
- private readonly waiters;
9
- get size(): number;
10
- open(id: string): void;
11
- isOpen(id: string): boolean;
12
- push(id: string, item: T): void;
13
- pull(id: string): Promise<T>;
14
- close({ id, reason }?: AsyncIdQueueCloseOptions): void;
15
- private assertOpen;
16
- }
6
+ private readonly openIds;
7
+ private readonly queues;
8
+ private readonly waiters;
9
+ get size(): number;
10
+ open(id: string): void;
11
+ isOpen(id: string): boolean;
12
+ push(id: string, item: T): void;
13
+ pull(id: string): Promise<T>;
14
+ close({ id, reason }?: AsyncIdQueueCloseOptions): void;
15
+ private assertOpen;
16
+ }
package/dist/queue.js CHANGED
@@ -1,79 +1,64 @@
1
- import { AbortError } from '@standard-server/shared';
2
- export class AsyncIdQueue {
3
- openIds = new Set();
4
- queues = new Map();
5
- waiters = new Map();
6
- get size() {
7
- return this.openIds.size;
8
- }
9
- open(id) {
10
- this.openIds.add(id);
11
- }
12
- isOpen(id) {
13
- return this.openIds.has(id);
14
- }
15
- push(id, item) {
16
- this.assertOpen(id);
17
- const pending = this.waiters.get(id);
18
- if (pending?.length) {
19
- pending.shift()[0](item);
20
- if (pending.length === 0) {
21
- this.waiters.delete(id);
22
- }
23
- }
24
- else {
25
- const items = this.queues.get(id);
26
- if (items) {
27
- items.push(item);
28
- }
29
- else {
30
- this.queues.set(id, [item]);
31
- }
32
- }
33
- }
34
- async pull(id) {
35
- this.assertOpen(id);
36
- const items = this.queues.get(id);
37
- if (items?.length) {
38
- const item = items.shift();
39
- if (items.length === 0) {
40
- this.queues.delete(id);
41
- }
42
- return item;
43
- }
44
- return new Promise((resolve, reject) => {
45
- const waitingPulls = this.waiters.get(id);
46
- const pending = [resolve, reject];
47
- if (waitingPulls) {
48
- waitingPulls.push(pending);
49
- }
50
- else {
51
- this.waiters.set(id, [pending]);
52
- }
53
- });
54
- }
55
- close({ id, reason } = {}) {
56
- if (id === undefined) {
57
- this.waiters.forEach((pendingPulls, id) => {
58
- const error = reason ??
59
- new AbortError(`[AsyncIdQueue] Queue[${id}] was closed or aborted while waiting for pulling.`);
60
- pendingPulls.forEach(([, reject]) => reject(error));
61
- });
62
- this.waiters.clear();
63
- this.openIds.clear();
64
- this.queues.clear();
65
- return;
66
- }
67
- const error = reason ??
68
- new AbortError(`[AsyncIdQueue] Queue[${id}] was closed or aborted while waiting for pulling.`);
69
- this.waiters.get(id)?.forEach(([, reject]) => reject(error));
70
- this.waiters.delete(id);
71
- this.openIds.delete(id);
72
- this.queues.delete(id);
73
- }
74
- assertOpen(id) {
75
- if (!this.isOpen(id)) {
76
- throw new Error(`[AsyncIdQueue] Cannot access queue[${id}] because it is not open or aborted.`);
77
- }
78
- }
79
- }
1
+ import { AbortError } from "@standard-server/shared";
2
+ // src/queue.ts
3
+ var AsyncIdQueue = class {
4
+ openIds = /* @__PURE__ */ new Set();
5
+ queues = /* @__PURE__ */ new Map();
6
+ waiters = /* @__PURE__ */ new Map();
7
+ get size() {
8
+ return this.openIds.size;
9
+ }
10
+ open(id) {
11
+ this.openIds.add(id);
12
+ }
13
+ isOpen(id) {
14
+ return this.openIds.has(id);
15
+ }
16
+ push(id, item) {
17
+ this.assertOpen(id);
18
+ const pending = this.waiters.get(id);
19
+ if (pending?.length) {
20
+ pending.shift()[0](item);
21
+ if (pending.length === 0) this.waiters.delete(id);
22
+ } else {
23
+ const items = this.queues.get(id);
24
+ if (items) items.push(item);
25
+ else this.queues.set(id, [item]);
26
+ }
27
+ }
28
+ async pull(id) {
29
+ this.assertOpen(id);
30
+ const items = this.queues.get(id);
31
+ if (items?.length) {
32
+ const item = items.shift();
33
+ if (items.length === 0) this.queues.delete(id);
34
+ return item;
35
+ }
36
+ return new Promise((resolve, reject) => {
37
+ const waitingPulls = this.waiters.get(id);
38
+ const pending = [resolve, reject];
39
+ if (waitingPulls) waitingPulls.push(pending);
40
+ else this.waiters.set(id, [pending]);
41
+ });
42
+ }
43
+ close({ id, reason } = {}) {
44
+ if (id === void 0) {
45
+ this.waiters.forEach((pendingPulls, id) => {
46
+ const error = reason ?? new AbortError(`[AsyncIdQueue] Queue[${id}] was closed or aborted while waiting for pulling.`);
47
+ pendingPulls.forEach(([, reject]) => reject(error));
48
+ });
49
+ this.waiters.clear();
50
+ this.openIds.clear();
51
+ this.queues.clear();
52
+ return;
53
+ }
54
+ const error = reason ?? new AbortError(`[AsyncIdQueue] Queue[${id}] was closed or aborted while waiting for pulling.`);
55
+ this.waiters.get(id)?.forEach(([, reject]) => reject(error));
56
+ this.waiters.delete(id);
57
+ this.openIds.delete(id);
58
+ this.queues.delete(id);
59
+ }
60
+ assertOpen(id) {
61
+ if (!this.isOpen(id)) throw new Error(`[AsyncIdQueue] Cannot access queue[${id}] because it is not open or aborted.`);
62
+ }
63
+ };
64
+ export { AsyncIdQueue };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Matches an integer string: an optional `-`, then digits without leading zeros (`007` is rejected).
3
+ * Note that `-0` is accepted.
4
+ */
5
+ export declare const INTEGER_REGEX: RegExp;
6
+ /**
7
+ * Matches a non-negative integer string without leading zeros, such as an array index.
8
+ */
9
+ export declare const NON_NEGATIVE_INTEGER_REGEX: RegExp;
package/dist/regex.js ADDED
@@ -0,0 +1,11 @@
1
+ // src/regex.ts
2
+ /**
3
+ * Matches an integer string: an optional `-`, then digits without leading zeros (`007` is rejected).
4
+ * Note that `-0` is accepted.
5
+ */
6
+ const INTEGER_REGEX = /^-?(?:0|[1-9]\d*)$/;
7
+ /**
8
+ * Matches a non-negative integer string without leading zeros, such as an array index.
9
+ */
10
+ const NON_NEGATIVE_INTEGER_REGEX = /^(?:0|[1-9]\d*)$/;
11
+ export { INTEGER_REGEX, NON_NEGATIVE_INTEGER_REGEX };
package/dist/signal.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export interface DisposableAllAbortSignal {
2
- signal: AbortSignal | undefined;
3
- dispose: () => void;
2
+ signal: AbortSignal | undefined;
3
+ dispose: () => void;
4
4
  }
5
5
  /**
6
6
  * Returns a signal that aborts only after all provided signals are aborted,
@@ -16,3 +16,8 @@ export declare function disposableAllAbortSignal(signals: readonly (AbortSignal
16
16
  */
17
17
  export declare function anyAbortSignal(signals: readonly (AbortSignal | undefined)[]): AbortSignal | undefined;
18
18
  export declare function runWithSignal<T>(signal: AbortSignal | undefined, fn: () => Promise<T>): Promise<T>;
19
+ /**
20
+ * Calls `onAbort` with the abort reason once the signal aborts, or synchronously, before returning,
21
+ * if it is already aborted. Does nothing without a signal. Returns a function that removes the listener.
22
+ */
23
+ export declare function listenAbort(signal: AbortSignal | undefined, onAbort: (reason: unknown) => void): () => void;
package/dist/signal.js CHANGED
@@ -1,85 +1,88 @@
1
- import { throwIfAborted } from '@standard-server/shared';
2
- import { promiseWithResolvers } from './promise.js';
1
+ import { promiseWithResolvers } from "./promise.js";
2
+ import { throwIfAborted } from "@standard-server/shared";
3
+ // src/signal.ts
3
4
  /**
4
- * Returns a signal that aborts only after all provided signals are aborted,
5
- * and a `dispose` function that removes the listeners added to the input signals.
6
- */
7
- export function disposableAllAbortSignal(signals) {
8
- const realSignals = signals.filter((signal) => signal !== undefined);
9
- if (realSignals.length === 0 || realSignals.length !== signals.length) {
10
- return { signal: undefined, dispose: () => { } };
11
- }
12
- const controller = new AbortController();
13
- const listenersController = new AbortController();
14
- const dispose = () => listenersController.abort();
15
- const abortIfAllAborted = () => {
16
- if (realSignals.every((signal) => signal.aborted)) {
17
- controller.abort();
18
- dispose();
19
- }
20
- };
21
- abortIfAllAborted();
22
- for (const signal of realSignals) {
23
- signal.addEventListener('abort', abortIfAllAborted, {
24
- once: true,
25
- signal: listenersController.signal,
26
- });
27
- }
28
- return { signal: controller.signal, dispose };
5
+ * Returns a signal that aborts only after all provided signals are aborted,
6
+ * and a `dispose` function that removes the listeners added to the input signals.
7
+ */
8
+ function disposableAllAbortSignal(signals) {
9
+ const realSignals = signals.filter((signal) => signal !== void 0);
10
+ if (realSignals.length === 0 || realSignals.length !== signals.length) return {
11
+ signal: void 0,
12
+ dispose: () => {}
13
+ };
14
+ const controller = new AbortController();
15
+ const listenersController = new AbortController();
16
+ const dispose = () => listenersController.abort();
17
+ const abortIfAllAborted = () => {
18
+ if (realSignals.every((signal) => signal.aborted)) {
19
+ controller.abort();
20
+ dispose();
21
+ }
22
+ };
23
+ abortIfAllAborted();
24
+ for (const signal of realSignals) signal.addEventListener("abort", abortIfAllAborted, {
25
+ once: true,
26
+ signal: listenersController.signal
27
+ });
28
+ return {
29
+ signal: controller.signal,
30
+ dispose
31
+ };
29
32
  }
30
33
  /**
31
- * Returns a signal that aborts as soon as any of the provided signals aborts,
32
- * with the same abort reason.
33
- *
34
- * Prefers the native `AbortSignal.any` when available, and falls back to a manual
35
- * implementation otherwise, including in runtimes without the `AbortSignal` global.
36
- */
37
- export function anyAbortSignal(signals) {
38
- const realSignals = signals.filter((signal) => signal !== undefined);
39
- if (realSignals.length === 0) {
40
- return undefined;
41
- }
42
- if (realSignals.length === 1) {
43
- return realSignals[0];
44
- }
45
- // oxlint-disable-next-line no-restricted-globals, no-restricted-properties
46
- if (typeof AbortSignal !== 'undefined' && typeof AbortSignal.any === 'function') {
47
- // oxlint-disable-next-line no-restricted-properties, no-restricted-globals
48
- return AbortSignal.any(realSignals);
49
- }
50
- const controller = new AbortController();
51
- for (const signal of realSignals) {
52
- if (signal.aborted) {
53
- controller.abort(signal.reason);
54
- break;
55
- }
56
- signal.addEventListener('abort', () => {
57
- controller.abort(signal.reason);
58
- }, {
59
- once: true,
60
- signal: controller.signal,
61
- });
62
- }
63
- return controller.signal;
34
+ * Returns a signal that aborts as soon as any of the provided signals aborts,
35
+ * with the same abort reason.
36
+ *
37
+ * Prefers the native `AbortSignal.any` when available, and falls back to a manual
38
+ * implementation otherwise, including in runtimes without the `AbortSignal` global.
39
+ */
40
+ function anyAbortSignal(signals) {
41
+ const realSignals = signals.filter((signal) => signal !== void 0);
42
+ if (realSignals.length === 0) return;
43
+ if (realSignals.length === 1) return realSignals[0];
44
+ if (typeof AbortSignal !== "undefined" && typeof AbortSignal.any === "function") return AbortSignal.any(realSignals);
45
+ const controller = new AbortController();
46
+ for (const signal of realSignals) {
47
+ if (signal.aborted) {
48
+ controller.abort(signal.reason);
49
+ break;
50
+ }
51
+ signal.addEventListener("abort", () => {
52
+ controller.abort(signal.reason);
53
+ }, {
54
+ once: true,
55
+ signal: controller.signal
56
+ });
57
+ }
58
+ return controller.signal;
64
59
  }
65
- export async function runWithSignal(signal, fn) {
66
- if (!signal) {
67
- return fn();
68
- }
69
- throwIfAborted(signal);
70
- const { promise, reject, resolve } = promiseWithResolvers();
71
- let abortListener;
72
- signal.addEventListener('abort', (abortListener = () => {
73
- reject(signal.reason);
74
- abortListener = undefined;
75
- }));
76
- try {
77
- fn().then(resolve, reject);
78
- return await promise;
79
- }
80
- finally {
81
- if (abortListener) {
82
- signal.removeEventListener('abort', abortListener);
83
- }
84
- }
60
+ async function runWithSignal(signal, fn) {
61
+ if (!signal) return fn();
62
+ throwIfAborted(signal);
63
+ const { promise, reject, resolve } = promiseWithResolvers();
64
+ let abortListener;
65
+ signal.addEventListener("abort", abortListener = () => {
66
+ reject(signal.reason);
67
+ abortListener = void 0;
68
+ });
69
+ try {
70
+ fn().then(resolve, reject);
71
+ return await promise;
72
+ } finally {
73
+ if (abortListener) signal.removeEventListener("abort", abortListener);
74
+ }
85
75
  }
76
+ const noop = () => {};
77
+ /**
78
+ * Calls `onAbort` with the abort reason once the signal aborts, or synchronously, before returning,
79
+ * if it is already aborted. Does nothing without a signal. Returns a function that removes the listener.
80
+ */
81
+ function listenAbort(signal, onAbort) {
82
+ if (!signal) return noop;
83
+ const listener = () => onAbort(signal.reason);
84
+ if (signal.aborted) listener();
85
+ else signal.addEventListener("abort", listener, { once: true });
86
+ return () => signal.removeEventListener("abort", listener);
87
+ }
88
+ export { anyAbortSignal, disposableAllAbortSignal, listenAbort, runWithSignal };
package/dist/stream.d.ts CHANGED
@@ -1,29 +1,29 @@
1
- import { AsyncIteratorClass } from '@standard-server/shared';
2
- import type { Promisable } from 'type-fest';
3
- import type { StartSpanOptions } from './tracing.ts';
4
- import type { ThrowableError } from './types.ts';
1
+ import { StartSpanOptions } from "./tracing.js";
2
+ import { ThrowableError } from "./types.js";
3
+ import { AsyncIteratorClass } from "@standard-server/shared";
4
+ import { Promisable } from "type-fest";
5
5
  export declare function replicateReadableStream<T>(stream: ReadableStream<T>, count: number): ReadableStream<T>[];
6
6
  export type ReadableStreamReadResult<T> = {
7
- done: false;
8
- value: T;
7
+ done: false;
8
+ value: T;
9
9
  } | {
10
- done: true;
11
- value?: T | undefined;
10
+ done: true;
11
+ value?: T | undefined;
12
12
  };
13
13
  export interface WrapReadableStreamOptions<T, TMapped> {
14
- /**
15
- * Any call to the original stream reader will be executed inside this function.
16
- * Useful when you want execution to happen within a specific context,
17
- * such as AsyncLocalStorage.
18
- */
19
- runWith?: (<T>(run: () => Promise<T>) => Promisable<T>) | undefined;
20
- mapResult?: ((result: ReadableStreamReadResult<T>) => Promisable<ReadableStreamReadResult<TMapped>>) | undefined;
21
- mapError?: ((error: ThrowableError) => Promisable<ThrowableError>) | undefined;
22
- onError?: ((error: ThrowableError) => Promisable<void>) | undefined;
23
- /**
24
- * Guaranteed to execute exactly once after the stream finishes or is cancelled.
25
- */
26
- onFinish?: (() => Promisable<void>) | undefined;
14
+ /**
15
+ * Any call to the original stream reader will be executed inside this function.
16
+ * Useful when you want execution to happen within a specific context,
17
+ * such as AsyncLocalStorage.
18
+ */
19
+ runWith?: (<T>(run: () => Promise<T>) => Promisable<T>) | undefined;
20
+ mapResult?: ((result: ReadableStreamReadResult<T>) => Promisable<ReadableStreamReadResult<TMapped>>) | undefined;
21
+ mapError?: ((error: ThrowableError) => Promisable<ThrowableError>) | undefined;
22
+ onError?: ((error: ThrowableError) => Promisable<void>) | undefined;
23
+ /**
24
+ * Guaranteed to execute exactly once after the stream finishes or is cancelled.
25
+ */
26
+ onFinish?: (() => Promisable<void>) | undefined;
27
27
  }
28
28
  export declare function wrapReadableStream<T, TMapped = T>(stream: ReadableStream<T>, { runWith, mapResult, mapError, onError, onFinish }: WrapReadableStreamOptions<T, TMapped>): NoInfer<ReadableStream<TMapped>>;
29
29
  export declare function traceReadableStream<T>(options: StartSpanOptions | string, stream: ReadableStream<T>): ReadableStream<T>;
@@ -33,7 +33,7 @@ export declare function traceReadableStream<T>(options: StartSpanOptions | strin
33
33
  * @see {@link https://orpc.dev/docs/integrations/ai-sdk | AI SDK Integration}
34
34
  */
35
35
  export declare function streamToAsyncIteratorObject<T>(stream: ReadableStream<T>, { signal }?: {
36
- signal?: AbortSignal | undefined;
36
+ signal?: AbortSignal | undefined;
37
37
  }): AsyncIteratorClass<T>;
38
38
  /**
39
39
  * Converts an `AsyncIterator` into a `ReadableStream`.
@@ -45,4 +45,4 @@ export declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): Re
45
45
  *
46
46
  * @see {@link https://orpc.dev/docs/integrations/ai-sdk | AI SDK Integration}
47
47
  */
48
- export declare function asyncIteratorToUnproxiedDataStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
48
+ export declare function asyncIteratorToUnproxiedDataStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;