@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/stream.js CHANGED
@@ -1,155 +1,129 @@
1
- import { AsyncIteratorClass } from '@standard-server/shared';
2
- import { once } from './function.js';
3
- import { isPlainObject } from './object.js';
4
- import { promiseWithResolvers } from './promise.js';
5
- import { recordSpanError, runInSpanContext, startSpan } from './tracing.js';
6
- export function replicateReadableStream(stream, count) {
7
- if (count <= 0) {
8
- return [];
9
- }
10
- const replicated = [];
11
- let pending = stream;
12
- for (let index = 0; index < count - 1; index++) {
13
- const [replica, remainder] = pending.tee();
14
- replicated.push(replica);
15
- pending = remainder;
16
- }
17
- replicated.push(pending);
18
- return replicated;
1
+ import { once } from "./function.js";
2
+ import { isPlainObject } from "./object.js";
3
+ import { promiseWithResolvers } from "./promise.js";
4
+ import { recordSpanError, runInSpanContext, startSpan } from "./tracing.js";
5
+ import { AsyncIteratorClass } from "@standard-server/shared";
6
+ // src/stream.ts
7
+ function replicateReadableStream(stream, count) {
8
+ if (count <= 0) return [];
9
+ const replicated = [];
10
+ let pending = stream;
11
+ for (let index = 0; index < count - 1; index++) {
12
+ const [replica, remainder] = pending.tee();
13
+ replicated.push(replica);
14
+ pending = remainder;
15
+ }
16
+ replicated.push(pending);
17
+ return replicated;
19
18
  }
20
- export function wrapReadableStream(stream, { runWith, mapResult, mapError, onError, onFinish }) {
21
- runWith ??= (run) => run();
22
- const reader = once(() => stream.getReader());
23
- const finish = once(async () => onFinish?.());
24
- // TODO:
25
- return new ReadableStream({
26
- async pull(controller) {
27
- let result;
28
- try {
29
- const readResult = await runWith(() => reader().read());
30
- result = mapResult
31
- ? await mapResult(readResult)
32
- : readResult;
33
- }
34
- catch (error) {
35
- try {
36
- await onError?.(error);
37
- controller.error(mapError ? await mapError(error) : error);
38
- }
39
- finally {
40
- await finish();
41
- }
42
- return;
43
- }
44
- if (result.done) {
45
- controller.close();
46
- await finish();
47
- }
48
- else {
49
- controller.enqueue(result.value);
50
- }
51
- },
52
- async cancel(reason) {
53
- try {
54
- try {
55
- await runWith(() => reader().cancel(reason));
56
- }
57
- catch (error) {
58
- await onError?.(error);
59
- throw error;
60
- }
61
- }
62
- finally {
63
- await finish();
64
- }
65
- },
66
- }, { highWaterMark: 0 });
19
+ function wrapReadableStream(stream, { runWith, mapResult, mapError, onError, onFinish }) {
20
+ runWith ??= (run) => run();
21
+ const reader = once(() => stream.getReader());
22
+ const finish = once(async () => onFinish?.());
23
+ return new ReadableStream({
24
+ async pull(controller) {
25
+ let result;
26
+ try {
27
+ const readResult = await runWith(() => reader().read());
28
+ result = mapResult ? await mapResult(readResult) : readResult;
29
+ } catch (error) {
30
+ try {
31
+ await onError?.(error);
32
+ controller.error(mapError ? await mapError(error) : error);
33
+ } finally {
34
+ await finish();
35
+ }
36
+ return;
37
+ }
38
+ if (result.done) {
39
+ controller.close();
40
+ await finish();
41
+ } else controller.enqueue(result.value);
42
+ },
43
+ async cancel(reason) {
44
+ try {
45
+ try {
46
+ await runWith(() => reader().cancel(reason));
47
+ } catch (error) {
48
+ await onError?.(error);
49
+ throw error;
50
+ }
51
+ } finally {
52
+ await finish();
53
+ }
54
+ }
55
+ }, { highWaterMark: 0 });
67
56
  }
68
- export function traceReadableStream(options, stream) {
69
- const getSpan = once(() => startSpan(options));
70
- return wrapReadableStream(stream, {
71
- runWith: (run) => runInSpanContext(getSpan(), run),
72
- mapResult(result) {
73
- getSpan()?.addEvent(result.done ? 'closed' : 'enqueued');
74
- return result;
75
- },
76
- onError(error) {
77
- recordSpanError(getSpan(), error);
78
- },
79
- onFinish() {
80
- getSpan()?.end();
81
- },
82
- });
57
+ function traceReadableStream(options, stream) {
58
+ const getSpan = once(() => startSpan(options));
59
+ return wrapReadableStream(stream, {
60
+ runWith: (run) => runInSpanContext(getSpan(), run),
61
+ mapResult(result) {
62
+ getSpan()?.addEvent(result.done ? "closed" : "enqueued");
63
+ return result;
64
+ },
65
+ onError(error) {
66
+ recordSpanError(getSpan(), error);
67
+ },
68
+ onFinish() {
69
+ getSpan()?.end();
70
+ }
71
+ });
83
72
  }
84
73
  /**
85
- * Converts a {@link ReadableStream} into an {@link AsyncIteratorClass}.
86
- *
87
- * @see {@link https://orpc.dev/docs/integrations/ai-sdk | AI SDK Integration}
88
- */
89
- export function streamToAsyncIteratorObject(stream, { signal } = {}) {
90
- const reader = stream.getReader();
91
- let cancelledBySignal = false;
92
- return new AsyncIteratorClass(async () => {
93
- if (signal?.aborted) {
94
- cancelledBySignal = true;
95
- throw signal.reason;
96
- }
97
- if (!signal) {
98
- return reader.read();
99
- }
100
- const { promise, reject } = promiseWithResolvers();
101
- const onAbort = () => reject(signal.reason);
102
- signal.addEventListener('abort', onAbort, { once: true });
103
- try {
104
- return await Promise.race([
105
- reader.read(),
106
- promise.catch(async (reason) => {
107
- cancelledBySignal = true;
108
- throw reason;
109
- }),
110
- ]);
111
- }
112
- finally {
113
- signal.removeEventListener('abort', onAbort);
114
- }
115
- }, async ({ kind, error }) => {
116
- if (kind === 'cancelled' || (kind === 'error' && cancelledBySignal)) {
117
- await reader.cancel(error);
118
- }
119
- });
74
+ * Converts a {@link ReadableStream} into an {@link AsyncIteratorClass}.
75
+ *
76
+ * @see {@link https://orpc.dev/docs/integrations/ai-sdk | AI SDK Integration}
77
+ */
78
+ function streamToAsyncIteratorObject(stream, { signal } = {}) {
79
+ const reader = stream.getReader();
80
+ let cancelledBySignal = false;
81
+ return new AsyncIteratorClass(async () => {
82
+ if (signal?.aborted) {
83
+ cancelledBySignal = true;
84
+ throw signal.reason;
85
+ }
86
+ if (!signal) return reader.read();
87
+ const { promise, reject } = promiseWithResolvers();
88
+ const onAbort = () => reject(signal.reason);
89
+ signal.addEventListener("abort", onAbort, { once: true });
90
+ try {
91
+ return await Promise.race([reader.read(), promise.catch(async (reason) => {
92
+ cancelledBySignal = true;
93
+ throw reason;
94
+ })]);
95
+ } finally {
96
+ signal.removeEventListener("abort", onAbort);
97
+ }
98
+ }, async ({ kind, error }) => {
99
+ if (kind === "cancelled" || kind === "error" && cancelledBySignal) await reader.cancel(error);
100
+ });
120
101
  }
121
102
  /**
122
- * Converts an `AsyncIterator` into a `ReadableStream`.
123
- */
124
- export function asyncIteratorToStream(iterator) {
125
- return createIteratorStream(iterator, (value) => value);
103
+ * Converts an `AsyncIterator` into a `ReadableStream`.
104
+ */
105
+ function asyncIteratorToStream(iterator) {
106
+ return createIteratorStream(iterator, (value) => value);
126
107
  }
127
108
  /**
128
- * Converts an `AsyncIterator` into a `ReadableStream`, ensuring that
129
- * all emitted object values are *unproxied* before enqueuing.
130
- *
131
- * @see {@link https://orpc.dev/docs/integrations/ai-sdk | AI SDK Integration}
132
- */
133
- export function asyncIteratorToUnproxiedDataStream(iterator) {
134
- return createIteratorStream(iterator, (value) => isPlainObject(value)
135
- ? { ...value }
136
- : Array.isArray(value)
137
- ? value.map((i) => i) // use .map instead of ... to deal with sparse arrays
138
- : value);
109
+ * Converts an `AsyncIterator` into a `ReadableStream`, ensuring that
110
+ * all emitted object values are *unproxied* before enqueuing.
111
+ *
112
+ * @see {@link https://orpc.dev/docs/integrations/ai-sdk | AI SDK Integration}
113
+ */
114
+ function asyncIteratorToUnproxiedDataStream(iterator) {
115
+ return createIteratorStream(iterator, (value) => isPlainObject(value) ? { ...value } : Array.isArray(value) ? value.map((i) => i) : value);
139
116
  }
140
117
  function createIteratorStream(iterator, map) {
141
- return new ReadableStream({
142
- async pull(controller) {
143
- const { done, value } = await iterator.next();
144
- if (done) {
145
- controller.close();
146
- }
147
- else {
148
- controller.enqueue(map(value));
149
- }
150
- },
151
- async cancel() {
152
- await iterator.return?.();
153
- },
154
- }, { highWaterMark: 0 });
118
+ return new ReadableStream({
119
+ async pull(controller) {
120
+ const { done, value } = await iterator.next();
121
+ if (done) controller.close();
122
+ else controller.enqueue(map(value));
123
+ },
124
+ async cancel() {
125
+ await iterator.return?.();
126
+ }
127
+ }, { highWaterMark: 0 });
155
128
  }
129
+ export { asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, replicateReadableStream, streamToAsyncIteratorObject, traceReadableStream, wrapReadableStream };
package/dist/tracing.d.ts CHANGED
@@ -1,28 +1,28 @@
1
- import type { Promisable } from 'type-fest';
1
+ import { Promisable } from "type-fest";
2
2
  export type TracingAttributeValue = string | number | boolean | string[] | number[] | boolean[];
3
3
  export interface TracingException {
4
- name?: string;
5
- message: string;
6
- stack?: string;
7
- code?: string | number;
4
+ name?: string;
5
+ message: string;
6
+ stack?: string;
7
+ code?: string | number;
8
8
  }
9
9
  export type TracingHeaders = Record<string, string | string[] | undefined>;
10
- export type TracingExceptionLevel = 'error' | 'info';
10
+ export type TracingExceptionLevel = "error" | "info";
11
11
  export interface TracingSpan {
12
- setAttribute(key: string, value: TracingAttributeValue): void;
13
- /**
14
- * Renames the span. Backends that cannot rename spans ignore it.
15
- */
16
- updateName(name: string): void;
17
- /**
18
- * Adds an event to the span. Backends without span events ignore it.
19
- */
20
- addEvent(name: string): void;
21
- /**
22
- * Records an exception on the span. The `error` level also marks the span as failed.
23
- */
24
- recordException(level: TracingExceptionLevel, exception: TracingException): void;
25
- end(): void;
12
+ setAttribute(key: string, value: TracingAttributeValue): void;
13
+ /**
14
+ * Renames the span. Backends that cannot rename spans ignore it.
15
+ */
16
+ updateName(name: string): void;
17
+ /**
18
+ * Adds an event to the span. Backends without span events ignore it.
19
+ */
20
+ addEvent(name: string): void;
21
+ /**
22
+ * Records an exception on the span. The `error` level also marks the span as failed.
23
+ */
24
+ recordException(level: TracingExceptionLevel, exception: TracingException): void;
25
+ end(): void;
26
26
  }
27
27
  /**
28
28
  * The tracing backend oRPC records spans with, see `@orpc/opentelemetry` and `@orpc/cloudflare`.
@@ -30,39 +30,39 @@ export interface TracingSpan {
30
30
  * A `parent` defaults to the active span of the backend when omitted.
31
31
  */
32
32
  export interface Tracer {
33
- /**
34
- * Starts a span without making it active. The caller must end it.
35
- */
36
- startSpan(name: string, parent?: TracingSpan): TracingSpan;
37
- /**
38
- * Starts a span, makes it active while `fn` runs, and passes it to `fn`. The caller must end it.
39
- */
40
- startActiveSpan<T>(name: string, parent: TracingSpan | undefined, fn: (span: TracingSpan) => Promise<T>): Promise<T>;
41
- getActiveSpan(): TracingSpan | undefined;
42
- /**
43
- * Runs `fn` with `span` as the active span. Backends that cannot activate a span run `fn` directly.
44
- */
45
- withActiveSpan<T>(span: TracingSpan, fn: () => Promisable<T>): Promisable<T>;
46
- /**
47
- * Writes the trace context of `span` into `headers`. Absent when the backend does not propagate context.
48
- */
49
- inject?(span: TracingSpan, headers: TracingHeaders): void;
50
- /**
51
- * Reads the remote parent from `headers`. Absent when the backend does not propagate context.
52
- */
53
- extract?(headers: TracingHeaders): TracingSpan | undefined;
33
+ /**
34
+ * Starts a span without making it active. The caller must end it.
35
+ */
36
+ startSpan(name: string, parent?: TracingSpan): TracingSpan;
37
+ /**
38
+ * Starts a span, makes it active while `fn` runs, and passes it to `fn`. The caller must end it.
39
+ */
40
+ startActiveSpan<T>(name: string, parent: TracingSpan | undefined, fn: (span: TracingSpan) => Promise<T>): Promise<T>;
41
+ getActiveSpan(): TracingSpan | undefined;
42
+ /**
43
+ * Runs `fn` with `span` as the active span. Backends that cannot activate a span run `fn` directly.
44
+ */
45
+ withActiveSpan<T>(span: TracingSpan, fn: () => Promisable<T>): Promisable<T>;
46
+ /**
47
+ * Writes the trace context of `span` into `headers`. Absent when the backend does not propagate context.
48
+ */
49
+ inject?(span: TracingSpan, headers: TracingHeaders): void;
50
+ /**
51
+ * Reads the remote parent from `headers`. Absent when the backend does not propagate context.
52
+ */
53
+ extract?(headers: TracingHeaders): TracingSpan | undefined;
54
54
  }
55
55
  export declare function setTracer(tracer: Tracer | undefined): void;
56
56
  export declare function getTracer(): Tracer | undefined;
57
57
  export interface StartSpanOptions {
58
- /**
59
- * The name of the span to create.
60
- */
61
- name: string;
62
- /**
63
- * The span to use as parent. Defaults to the active span of the backend.
64
- */
65
- parent?: TracingSpan | undefined;
58
+ /**
59
+ * The name of the span to create.
60
+ */
61
+ name: string;
62
+ /**
63
+ * The span to use as parent. Defaults to the active span of the backend.
64
+ */
65
+ parent?: TracingSpan | undefined;
66
66
  }
67
67
  export declare function startSpan(options: StartSpanOptions | string): TracingSpan | undefined;
68
68
  export declare function recordSpanError(span: TracingSpan | undefined, error: unknown): void;
@@ -70,4 +70,4 @@ export declare function setSpanAttributeIfDefined(span: TracingSpan | undefined,
70
70
  export declare function toTracingException(error: unknown): TracingException;
71
71
  export declare function toSpanAttributeValue(data: unknown): string;
72
72
  export declare function runWithSpan<T>(options: string | StartSpanOptions, fn: (span?: TracingSpan) => Promisable<T>): Promise<T>;
73
- export declare function runInSpanContext<T>(span: TracingSpan | undefined, fn: () => Promisable<T>): Promisable<T>;
73
+ export declare function runInSpanContext<T>(span: TracingSpan | undefined, fn: () => Promisable<T>): Promisable<T>;
package/dist/tracing.js CHANGED
@@ -1,94 +1,69 @@
1
- import { isAbortError } from './error.js';
2
- const TRACER_SYMBOL = /* @__PURE__ */ Symbol.for('ORPC_TRACER');
3
- export function setTracer(tracer) {
4
- ;
5
- globalThis[TRACER_SYMBOL] = tracer;
1
+ import { isAbortError } from "./error.js";
2
+ // src/tracing.ts
3
+ const TRACER_SYMBOL = /* @__PURE__ */ Symbol.for("ORPC_TRACER");
4
+ function setTracer(tracer) {
5
+ globalThis[TRACER_SYMBOL] = tracer;
6
6
  }
7
- export function getTracer() {
8
- return globalThis[TRACER_SYMBOL];
7
+ function getTracer() {
8
+ return globalThis[TRACER_SYMBOL];
9
9
  }
10
- export function startSpan(options) {
11
- const tracer = getTracer();
12
- if (!tracer) {
13
- return undefined;
14
- }
15
- if (typeof options === 'string') {
16
- return tracer.startSpan(options);
17
- }
18
- return tracer.startSpan(options.name, options.parent);
10
+ function startSpan(options) {
11
+ const tracer = getTracer();
12
+ if (!tracer) return;
13
+ if (typeof options === "string") return tracer.startSpan(options);
14
+ return tracer.startSpan(options.name, options.parent);
19
15
  }
20
- export function recordSpanError(span, error) {
21
- if (!span) {
22
- return;
23
- }
24
- // DO NOT treat aborted error as error if happen during business logic (assumed)
25
- span.recordException(isAbortError(error) ? 'info' : 'error', toTracingException(error));
16
+ function recordSpanError(span, error) {
17
+ if (!span) return;
18
+ span.recordException(isAbortError(error) ? "info" : "error", toTracingException(error));
26
19
  }
27
- export function setSpanAttributeIfDefined(span, key, value) {
28
- if (!span || value === undefined) {
29
- return;
30
- }
31
- span.setAttribute(key, value);
20
+ function setSpanAttributeIfDefined(span, key, value) {
21
+ if (!span || value === void 0) return;
22
+ span.setAttribute(key, value);
32
23
  }
33
- export function toTracingException(error) {
34
- if (error instanceof Error) {
35
- const exception = {
36
- message: error.message,
37
- name: error.name,
38
- stack: error.stack,
39
- };
40
- if ('code' in error && (typeof error.code === 'string' || typeof error.code === 'number')) {
41
- exception.code = error.code;
42
- }
43
- return exception;
44
- }
45
- return { message: String(error) };
24
+ function toTracingException(error) {
25
+ if (error instanceof Error) {
26
+ const exception = {
27
+ message: error.message,
28
+ name: error.name,
29
+ stack: error.stack
30
+ };
31
+ if ("code" in error && (typeof error.code === "string" || typeof error.code === "number")) exception.code = error.code;
32
+ return exception;
33
+ }
34
+ return { message: String(error) };
46
35
  }
47
- export function toSpanAttributeValue(data) {
48
- if (data === undefined) {
49
- return 'undefined';
50
- }
51
- try {
52
- // oxlint-disable-next-line no-restricted-properties
53
- return JSON.stringify(data, (_, value) => {
54
- if (typeof value === 'bigint') {
55
- return value.toString();
56
- }
57
- if (value instanceof Map || value instanceof Set) {
58
- return Array.from(value);
59
- }
60
- return value;
61
- });
62
- }
63
- catch {
64
- // oxlint-disable-next-line typescript/no-base-to-string
65
- return String(data);
66
- }
36
+ function toSpanAttributeValue(data) {
37
+ if (data === void 0) return "undefined";
38
+ try {
39
+ return JSON.stringify(data, (_, value) => {
40
+ if (typeof value === "bigint") return value.toString();
41
+ if (value instanceof Map || value instanceof Set) return Array.from(value);
42
+ return value;
43
+ });
44
+ } catch {
45
+ return String(data);
46
+ }
67
47
  }
68
- export async function runWithSpan(options, fn) {
69
- const tracer = getTracer();
70
- if (!tracer) {
71
- return fn();
72
- }
73
- const name = typeof options === 'string' ? options : options.name;
74
- const parent = typeof options === 'string' ? undefined : options.parent;
75
- return tracer.startActiveSpan(name, parent, async (span) => {
76
- try {
77
- return await fn(span);
78
- }
79
- catch (e) {
80
- recordSpanError(span, e);
81
- throw e;
82
- }
83
- finally {
84
- span.end();
85
- }
86
- });
48
+ async function runWithSpan(options, fn) {
49
+ const tracer = getTracer();
50
+ if (!tracer) return fn();
51
+ const name = typeof options === "string" ? options : options.name;
52
+ const parent = typeof options === "string" ? void 0 : options.parent;
53
+ return tracer.startActiveSpan(name, parent, async (span) => {
54
+ try {
55
+ return await fn(span);
56
+ } catch (e) {
57
+ recordSpanError(span, e);
58
+ throw e;
59
+ } finally {
60
+ span.end();
61
+ }
62
+ });
87
63
  }
88
- export function runInSpanContext(span, fn) {
89
- const tracer = getTracer();
90
- if (!span || !tracer) {
91
- return fn();
92
- }
93
- return tracer.withActiveSpan(span, fn);
64
+ function runInSpanContext(span, fn) {
65
+ const tracer = getTracer();
66
+ if (!span || !tracer) return fn();
67
+ return tracer.withActiveSpan(span, fn);
94
68
  }
69
+ export { getTracer, recordSpanError, runInSpanContext, runWithSpan, setSpanAttributeIfDefined, setTracer, startSpan, toSpanAttributeValue, toTracingException };
package/dist/types.d.ts CHANGED
@@ -2,25 +2,22 @@ export type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
2
2
  /**
3
3
  * Like `Omit`, but distributes over unions and keeps known keys beside index signatures.
4
4
  */
5
- export type DistributiveOmit<T, K extends PropertyKey> = {
6
- [P in keyof T as P extends K ? never : P]: T[P];
7
- };
5
+ export type DistributiveOmit<T, K extends PropertyKey> = { [P in keyof T as P extends K ? never : P]: T[P]; };
8
6
  /**
9
7
  * Remove protected/private properties/methods
10
8
  */
11
9
  export type Public<T> = Pick<T, keyof T>;
12
10
  export type PromiseWithError<T, TError> = Promise<T> & {
13
- __error?: {
14
- type: TError;
15
- };
11
+ __error?: {
12
+ type: TError;
13
+ };
16
14
  };
17
15
  /**
18
16
  * The place where you can config the orpc types.
19
17
  *
20
18
  * - `ThrowableError` the error type that represent throwable errors should be `Error` or `null | undefined | {}` if you want more strict.
21
19
  */
22
- export interface Registry {
23
- }
20
+ export interface Registry {}
24
21
  export type ThrowableError = Registry extends {
25
- ThrowableError: infer T;
26
- } ? T : Error;
22
+ ThrowableError: infer T;
23
+ } ? T : Error;
package/dist/value.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
2
- export declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
2
+ export declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
package/dist/value.js CHANGED
@@ -1,6 +1,6 @@
1
- export function value(value, ...args) {
2
- if (typeof value === 'function') {
3
- return value(...args);
4
- }
5
- return value;
1
+ // src/value.ts
2
+ function value(value, ...args) {
3
+ if (typeof value === "function") return value(...args);
4
+ return value;
6
5
  }
6
+ export { value };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orpc/shared",
3
- "version": "2.0.0-beta.49",
3
+ "version": "2.0.0-beta.50",
4
4
  "description": "Internal utilities shared across oRPC packages",
5
5
  "keywords": [
6
6
  "orpc"
@@ -30,7 +30,7 @@
30
30
  }
31
31
  },
32
32
  "dependencies": {
33
- "@standard-server/shared": "~0.15.0",
33
+ "@standard-server/shared": "~0.16.0",
34
34
  "type-fest": "^5.10.0"
35
35
  },
36
36
  "devDependencies": {
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- export {};