@orpc/shared 2.0.0-beta.51 → 2.0.0-beta.53

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 CHANGED
@@ -63,7 +63,7 @@ Read the full documentation at [orpc.dev](https://orpc.dev), starting with the [
63
63
 
64
64
  | Package | Purpose | Docs |
65
65
  | -------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
66
- | [@orpc/contract](https://www.npmjs.com/package/@orpc/contract) | Define API contract as the single source of truth. | [Procedure Contract](https://orpc.dev/docs/contract/procedure), [Contract Router](https://orpc.dev/docs/contract/router), [Implementation](https://orpc.dev/docs/contract/implementation), [Generate from OpenAPI](https://orpc.dev/docs/contract/generate-from-openapi) |
66
+ | [@orpc/contract](https://www.npmjs.com/package/@orpc/contract) | Define API contract as the single source of truth. | [Procedure Contract](https://orpc.dev/docs/contract/procedure), [Router Contract](https://orpc.dev/docs/contract/router), [Implementation](https://orpc.dev/docs/contract/implementation), [Generate from OpenAPI](https://orpc.dev/docs/contract/generate-from-openapi) |
67
67
  | [@orpc/server](https://www.npmjs.com/package/@orpc/server) | Build APIs or implement contracts. | [Procedure](https://orpc.dev/docs/procedure), [Router](https://orpc.dev/docs/router), [Middleware](https://orpc.dev/docs/middleware), [Context](https://orpc.dev/docs/context), [RPC Handler](https://orpc.dev/docs/rpc/handler) |
68
68
  | [@orpc/client](https://www.npmjs.com/package/@orpc/client) | Consume APIs with end-to-end type safety. | [Client-Side Clients](https://orpc.dev/docs/client/client-side), [Server-Side Clients](https://orpc.dev/docs/client/server-side), [RPC Link](https://orpc.dev/docs/rpc/link), [Error Handling](https://orpc.dev/docs/client/error-handling) |
69
69
  | [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi) | Add OpenAPI compatibility to APIs. | [OpenAPI Handler](https://orpc.dev/docs/openapi/handler), [OpenAPI Link](https://orpc.dev/docs/openapi/link), [Specification](https://orpc.dev/docs/openapi/specification), [Scalar](https://orpc.dev/docs/openapi/scalar) |
@@ -183,25 +183,24 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
183
183
  <td align="center"><a href="https://github.com/pumpkinlink?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Denis"><img src="https://avatars.githubusercontent.com/u/11864620?u=5f47bbe6c65d0f6f5cf011021490238e4b0593d0&amp;v=4" width="139" alt="Denis"/><br />Denis</a></td>
184
184
  <td align="center"><a href="https://github.com/christopher-kapic?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Christopher Kapic"><img src="https://avatars.githubusercontent.com/u/59740769?u=e7ad4b72b5bf6c9eb1644c26dbf3332a8f987377&amp;v=4" width="139" alt="Christopher Kapic"/><br />Christopher Kapic</a></td>
185
185
  <td align="center"><a href="http://ballingt.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Tom Ballinger"><img src="https://avatars.githubusercontent.com/u/458879?u=4b045ac75d721b6ac2b42a74d7d37f61f0414031&amp;v=4" width="139" alt="Tom Ballinger"/><br />Tom Ballinger</a></td>
186
- <td align="center"><a href="https://lee-sam.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Sam"><img src="https://avatars.githubusercontent.com/u/102863520?u=3c89611f549d5070be232eb4532f690c8f2e7a65&amp;v=4" width="139" alt="Sam"/><br />Sam</a></td>
187
186
  <td align="center"><a href="https://github.com/Titoine?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Titoine"><img src="https://avatars.githubusercontent.com/u/3514286?u=1bb1e86b0c99c8a1121372e56d51a177eea12191&amp;v=4" width="139" alt="Titoine"/><br />Titoine</a></td>
188
187
  <td align="center"><a href="https://rigtch.fm/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Igor Makowski"><img src="https://avatars.githubusercontent.com/u/56691628?u=ee8c879478f7c151b9156aef6c74243fa3e247a8&amp;v=4" width="139" alt="Igor Makowski"/><br />Igor Makowski</a></td>
188
+ <td align="center"><a href="https://blog.cwang.io/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="hanayashiki"><img src="https://avatars.githubusercontent.com/u/26056783?u=06c3b9205a16fd41a871e82da1cc2a09306d53f5&amp;v=4" width="139" alt="hanayashiki"/><br />hanayashiki</a></td>
189
189
  </tr>
190
190
  <tr>
191
- <td align="center"><a href="https://blog.cwang.io/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="hanayashiki"><img src="https://avatars.githubusercontent.com/u/26056783?u=06c3b9205a16fd41a871e82da1cc2a09306d53f5&amp;v=4" width="139" alt="hanayashiki"/><br />hanayashiki</a></td>
192
191
  <td align="center"><a href="https://dubinets.io/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Lev Dubinets"><img src="https://avatars.githubusercontent.com/u/3114081?u=f547f5d5012cab54851f1b1ad72d10e537f78fc2&amp;v=4" width="139" alt="Lev Dubinets"/><br />Lev Dubinets</a></td>
193
192
  <td align="center"><a href="https://kellychan.im/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&amp;v=4" width="139" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
194
193
  <td align="center"><a href="https://guyariely.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guy Ariely"><img src="https://avatars.githubusercontent.com/u/42813496?u=edb6b7f563bf28e160a290832e7da57c0506f8ca&amp;v=4" width="139" alt="Guy Ariely"/><br />Guy Ariely</a></td>
195
194
  <td align="center"><a href="https://paulsenon.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="PaulSenon"><img src="https://avatars.githubusercontent.com/u/19531087?u=6385741eb91d200b8c513ec6045482e301767ca6&amp;v=4" width="139" alt="PaulSenon"/><br />PaulSenon</a></td>
196
195
  <td align="center"><a href="https://usagerail.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="UsageRail"><img src="https://avatars.githubusercontent.com/u/347653714?v=4" width="139" alt="UsageRail"/><br />UsageRail</a></td>
196
+ <td align="center"><a href="https://piscis.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&amp;v=4" width="139" alt="Alex"/><br />Alex</a></td>
197
197
  </tr>
198
198
  <tr>
199
- <td align="center"><a href="https://piscis.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&amp;v=4" width="139" alt="Alex"/><br />Alex</a></td>
200
199
  <td align="center"><a href="https://opensource.gubanov.eu/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=c5f2daf7ebece498e85c83367bb37b4e10e2649d&amp;v=4" width="139" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
201
200
  </tr>
202
201
  </table>
203
202
 
204
- With thanks to [40 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
203
+ With thanks to [41 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
205
204
 
206
205
  ## Open Source Programs
207
206
 
package/dist/error.d.ts CHANGED
@@ -1 +1,10 @@
1
+ /**
2
+ * Error for an operation that exceeded its time limit.
3
+ * Named like the error of `AbortSignal.timeout()`.
4
+ *
5
+ * @see {@link https://orpc.dev/docs/plugins/timeout | Timeout Plugin}
6
+ */
7
+ export declare class TimeoutError extends Error {
8
+ override readonly name = "TimeoutError";
9
+ }
1
10
  export declare function isAbortError(error: unknown): error is Error;
package/dist/error.js CHANGED
@@ -1,5 +1,14 @@
1
1
  // src/error.ts
2
+ /**
3
+ * Error for an operation that exceeded its time limit.
4
+ * Named like the error of `AbortSignal.timeout()`.
5
+ *
6
+ * @see {@link https://orpc.dev/docs/plugins/timeout | Timeout Plugin}
7
+ */
8
+ var TimeoutError = class extends Error {
9
+ name = "TimeoutError";
10
+ };
2
11
  function isAbortError(error) {
3
12
  return error instanceof Error && error.name.includes("Abort");
4
13
  }
5
- export { isAbortError };
14
+ export { TimeoutError, isAbortError };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { DEFAULT_MAX_BIGINT_DIGITS, parseBigIntString } from "./bigint.js";
4
4
  import { encodeBase64, loadBytes, toStringOrBytes } from "./buffer.js";
5
5
  import { isDeepEqual } from "./compare.js";
6
6
  import { ORPC_NAME } from "./consts.js";
7
- import { isAbortError } from "./error.js";
7
+ import { TimeoutError, isAbortError } from "./error.js";
8
8
  import { AnyFunction, defer, isAsyncGeneratorFunction, once, tryOrUndefined } from "./function.js";
9
9
  import { CompressionEncoding, estimateCompressibleFormDataSize, estimateUtf8ByteLength, isAcceptableEncoding, isCompressibleContentType, isCompressionEncoding, isNoTransformCacheControl, matchesHttpPath, matchesHttpPathPrefix, mergeHttpPath, normalizeHttpPath, parseAcceptEncodingQualities, parseContentEncodings, pathToHttpPath, stripHttpPathPrefix, varyByAcceptEncoding } from "./http.js";
10
10
  import { compareSequentialIds } from "./id.js";
@@ -18,9 +18,9 @@ import { AsyncIdQueue, AsyncIdQueueCloseOptions } from "./queue.js";
18
18
  import { INTEGER_REGEX, NON_NEGATIVE_INTEGER_REGEX } from "./regex.js";
19
19
  import { DisposableAllAbortSignal, anyAbortSignal, disposableAllAbortSignal, listenAbort, runWithSignal } from "./signal.js";
20
20
  import { ReadableStreamReadResult, WrapReadableStreamOptions, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, replicateReadableStream, streamToAsyncIteratorObject, traceReadableStream, wrapReadableStream } from "./stream.js";
21
- import { StartSpanOptions, Tracer, TracingAttributeValue, TracingException, TracingExceptionLevel, TracingHeaders, TracingSpan, getTracer, recordSpanError, runInSpanContext, runWithSpan, setSpanAttributeIfDefined, setTracer, startSpan, toSpanAttributeValue, toTracingException } from "./tracing.js";
21
+ import { StartSpanOptions, Tracer, TracingAttributeValue, TracingExceptionLevel, TracingHeaders, TracingSpan, getTracer, recordSpanError, runInSpanContext, runWithSpan, setSpanAttributeIfDefined, setTracer, startSpan, toSpanAttributeValue } from "./tracing.js";
22
22
  import { DistributiveOmit, IntersectPick, Promisable, PromiseWithError, Public, Registry, ThrowableError } from "./types.js";
23
23
  import { Value, value } from "./value.js";
24
24
  import { AbortError, AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isNonPrimitive, isNonPrimitive as isTypescriptObject, parseEmptyableJSON, safeDecodeURIComponent, safeEncodeURIComponent, sequential, sleep, stringifyJSON, throwIfAborted, toArray } from "@standard-server/shared";
25
25
  import { Arrayable, IsEqual, PartialDeep, Writable } from "type-fest";
26
- export { AbortError, AnyFunction, type Arrayable, type AsyncCleanupFn, AsyncIdQueue, AsyncIdQueueCloseOptions, AsyncIteratorClass, type AsyncIteratorClassNextFn, CompressionEncoding, ConsumeAsyncIteratorOptions, DEFAULT_MAX_BIGINT_DIGITS, DisposableAllAbortSignal, DistributiveOmit, INTEGER_REGEX, InferNextError, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, type IsEqual, MaybeOptionalOptions, NON_NEGATIVE_INTEGER_REGEX, NullProtoObj, ORPC_NAME, OnFinishState, OrderablePlugin, type PartialDeep, Promisable, PromiseWithError, Public, ReadableStreamReadResult, Registry, Segment, SequentialIdGenerator, StartSpanOptions, ThrowableError, Tracer, TracingAttributeValue, TracingException, TracingExceptionLevel, TracingHeaders, TracingSpan, Value, WrapAsyncIteratorOptions, WrapReadableStreamOptions, type Writable, anyAbortSignal, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, bindMethods, captureAsyncContext, clone, compareSequentialIds, consumeAsyncIterator, copyOnWrite, defer, disposableAllAbortSignal, encodeBase64, estimateCompressibleFormDataSize, estimateUtf8ByteLength, findDeepMatches, get, getConstructor, getConstructors, getOrBind, getOwn, getTracer, intercept, isAbortError, isAcceptableEncoding, isAsyncGeneratorFunction, isAsyncIteratorObject, isCompressibleContentType, isCompressionEncoding, isDeepEqual, isNoTransformCacheControl, isNonPrimitive, isPlainObject as isObject, isPlainObject, isPlainObjectOrArray, isPropertyKey, isTypescriptObject, listenAbort, loadBytes, matchesHttpPath, matchesHttpPathPrefix, mergeHttpPath, mergeTwoLevels, normalizeHttpPath, omit, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, once, override, parseAcceptEncodingQualities, parseBigIntString, parseContentEncodings, parseEmptyableJSON, pathToHttpPath, pick, promiseWithResolvers, recordSpanError, replicateAsyncIterator, replicateReadableStream, resolveMaybeOptionalOptions, runInSpanContext, runWithSignal, runWithSpan, safeDecodeURIComponent, safeEncodeURIComponent, sequential, set, setOwn, setSpanAttributeIfDefined, setTracer, sleep, sortPlugins, splitInHalf, startSpan, streamToAsyncIteratorObject, stringifyJSON, stripHttpPathPrefix, takeLast, throwIfAborted, toArray, toSpanAttributeValue, toStringOrBytes, toTracingException, traceAsyncIterator, traceReadableStream, tryOrUndefined, value, varyByAcceptEncoding, wrapAsyncIterator, wrapReadableStream };
26
+ export { AbortError, AnyFunction, type Arrayable, type AsyncCleanupFn, AsyncIdQueue, AsyncIdQueueCloseOptions, AsyncIteratorClass, type AsyncIteratorClassNextFn, CompressionEncoding, ConsumeAsyncIteratorOptions, DEFAULT_MAX_BIGINT_DIGITS, DisposableAllAbortSignal, DistributiveOmit, INTEGER_REGEX, InferNextError, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, type IsEqual, MaybeOptionalOptions, NON_NEGATIVE_INTEGER_REGEX, NullProtoObj, ORPC_NAME, OnFinishState, OrderablePlugin, type PartialDeep, Promisable, PromiseWithError, Public, ReadableStreamReadResult, Registry, Segment, SequentialIdGenerator, StartSpanOptions, ThrowableError, TimeoutError, Tracer, TracingAttributeValue, TracingExceptionLevel, TracingHeaders, TracingSpan, Value, WrapAsyncIteratorOptions, WrapReadableStreamOptions, type Writable, anyAbortSignal, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, bindMethods, captureAsyncContext, clone, compareSequentialIds, consumeAsyncIterator, copyOnWrite, defer, disposableAllAbortSignal, encodeBase64, estimateCompressibleFormDataSize, estimateUtf8ByteLength, findDeepMatches, get, getConstructor, getConstructors, getOrBind, getOwn, getTracer, intercept, isAbortError, isAcceptableEncoding, isAsyncGeneratorFunction, isAsyncIteratorObject, isCompressibleContentType, isCompressionEncoding, isDeepEqual, isNoTransformCacheControl, isNonPrimitive, isPlainObject as isObject, isPlainObject, isPlainObjectOrArray, isPropertyKey, isTypescriptObject, listenAbort, loadBytes, matchesHttpPath, matchesHttpPathPrefix, mergeHttpPath, mergeTwoLevels, normalizeHttpPath, omit, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, once, override, parseAcceptEncodingQualities, parseBigIntString, parseContentEncodings, parseEmptyableJSON, pathToHttpPath, pick, promiseWithResolvers, recordSpanError, replicateAsyncIterator, replicateReadableStream, resolveMaybeOptionalOptions, runInSpanContext, runWithSignal, runWithSpan, safeDecodeURIComponent, safeEncodeURIComponent, sequential, set, setOwn, setSpanAttributeIfDefined, setTracer, sleep, sortPlugins, splitInHalf, startSpan, streamToAsyncIteratorObject, stringifyJSON, stripHttpPathPrefix, takeLast, throwIfAborted, toArray, toSpanAttributeValue, toStringOrBytes, traceAsyncIterator, traceReadableStream, tryOrUndefined, value, varyByAcceptEncoding, wrapAsyncIterator, wrapReadableStream };
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ export { DEFAULT_MAX_BIGINT_DIGITS, parseBigIntString } from "./bigint.js";
4
4
  export { encodeBase64, loadBytes, toStringOrBytes } from "./buffer.js";
5
5
  export { isDeepEqual } from "./compare.js";
6
6
  export { ORPC_NAME } from "./consts.js";
7
- export { isAbortError } from "./error.js";
7
+ export { TimeoutError, isAbortError } from "./error.js";
8
8
  export { defer, isAsyncGeneratorFunction, once, tryOrUndefined } from "./function.js";
9
9
  export { estimateCompressibleFormDataSize, estimateUtf8ByteLength, isAcceptableEncoding, isCompressibleContentType, isCompressionEncoding, isNoTransformCacheControl, matchesHttpPath, matchesHttpPathPrefix, mergeHttpPath, normalizeHttpPath, parseAcceptEncodingQualities, parseContentEncodings, pathToHttpPath, stripHttpPathPrefix, varyByAcceptEncoding } from "./http.js";
10
10
  export { compareSequentialIds } from "./id.js";
@@ -18,6 +18,6 @@ export { AsyncIdQueue } from "./queue.js";
18
18
  export { INTEGER_REGEX, NON_NEGATIVE_INTEGER_REGEX } from "./regex.js";
19
19
  export { anyAbortSignal, disposableAllAbortSignal, listenAbort, runWithSignal } from "./signal.js";
20
20
  export { asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, replicateReadableStream, streamToAsyncIteratorObject, traceReadableStream, wrapReadableStream } from "./stream.js";
21
- export { getTracer, recordSpanError, runInSpanContext, runWithSpan, setSpanAttributeIfDefined, setTracer, startSpan, toSpanAttributeValue, toTracingException } from "./tracing.js";
21
+ export { getTracer, recordSpanError, runInSpanContext, runWithSpan, setSpanAttributeIfDefined, setTracer, startSpan, toSpanAttributeValue } from "./tracing.js";
22
22
  export { value } from "./value.js";
23
23
  export { AbortError, AsyncIteratorClass, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isNonPrimitive, isNonPrimitive as isTypescriptObject, parseEmptyableJSON, safeDecodeURIComponent, safeEncodeURIComponent, sequential, sleep, stringifyJSON, throwIfAborted, toArray } from "@standard-server/shared";
@@ -1,5 +1,4 @@
1
1
  import { wrapAsyncIterator } from "./iterator.js";
2
- import { override } from "./proxy.js";
3
2
  import { wrapReadableStream } from "./stream.js";
4
3
  import { isAsyncIteratorObject } from "@standard-server/shared";
5
4
  // src/interceptor.ts
@@ -77,11 +76,7 @@ function onAsyncIteratorObjectError(callback) {
77
76
  return async (options, ...rest) => {
78
77
  const output = await options.next();
79
78
  if (!isAsyncIteratorObject(output)) return output;
80
- /**
81
- * @warning
82
- * Remember use `override` for AsyncIteratorObject to remain other special properties
83
- */
84
- return override(output, wrapAsyncIterator(output, { onError: (error) => callback(error, options, ...rest) }));
79
+ return wrapAsyncIterator(output, { onError: (error) => callback(error, options, ...rest) });
85
80
  };
86
81
  }
87
82
  /**
@@ -97,11 +92,7 @@ function onReadableStreamError(callback) {
97
92
  return async (options, ...rest) => {
98
93
  const output = await options.next();
99
94
  if (!(output instanceof ReadableStream)) return output;
100
- /**
101
- * @warning
102
- * Remember use `override` for ReadableStream to remain other special properties
103
- */
104
- return override(output, wrapReadableStream(output, { onError: (error) => callback(error, options, ...rest) }));
95
+ return wrapReadableStream(output, { onError: (error) => callback(error, options, ...rest) });
105
96
  };
106
97
  }
107
98
  function intercept(interceptors, options, main) {
package/dist/plugin.d.ts CHANGED
@@ -1,12 +1,24 @@
1
+ /**
2
+ * A plugin ordered relative to others by name.
3
+ *
4
+ * `before` and `after` order the `init()` calls, not the interceptors:
5
+ * - A plugin that prepends its interceptor and is initialized later wraps the earlier ones.
6
+ * - A plugin that appends its interceptor and is initialized later runs inside the earlier ones.
7
+ * - A prepended interceptor always wraps an appended one, whatever the init order.
8
+ */
1
9
  export interface OrderablePlugin {
2
- /** Unique name of the plugin, used for ordering and identification. */
3
- name: string;
4
- /** Plugins this plugin should execute before. */
5
- before?: string[] | undefined;
6
- /** Plugins this plugin should execute after. */
7
- after?: string[] | undefined;
10
+ /**
11
+ * Name other plugins refer to in `before` and `after`.
12
+ * The `~` prefix is reserved for built-in plugins.
13
+ */
14
+ readonly name: string;
15
+ /** Plugins to initialize after this one. Unknown names are ignored. */
16
+ readonly before?: readonly string[] | undefined;
17
+ /** Plugins to initialize before this one. Unknown names are ignored. */
18
+ readonly after?: readonly string[] | undefined;
8
19
  }
9
20
  /**
10
- * Sorts plugins based on their `before` and `after` dependencies.
21
+ * Sorts plugins into init order by their `before` and `after`.
22
+ * Throws on a circular dependency.
11
23
  */
12
- export declare function sortPlugins<T extends OrderablePlugin>(plugins: T[]): T[];
24
+ export declare function sortPlugins<T extends OrderablePlugin>(plugins: readonly T[]): T[];
package/dist/plugin.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/plugin.ts
2
2
  /**
3
- * Sorts plugins based on their `before` and `after` dependencies.
3
+ * Sorts plugins into init order by their `before` and `after`.
4
+ * Throws on a circular dependency.
4
5
  */
5
6
  function sortPlugins(plugins) {
6
7
  const pluginCount = plugins.length;
package/dist/tracing.d.ts CHANGED
@@ -1,11 +1,5 @@
1
1
  import { Promisable } from "./types.js";
2
2
  export type TracingAttributeValue = string | number | boolean | string[] | number[] | boolean[];
3
- export interface TracingException {
4
- name?: string;
5
- message: string;
6
- stack?: string;
7
- code?: string | number;
8
- }
9
3
  export type TracingHeaders = Record<string, string | string[] | undefined>;
10
4
  export type TracingExceptionLevel = "error" | "info";
11
5
  export interface TracingSpan {
@@ -19,9 +13,10 @@ export interface TracingSpan {
19
13
  */
20
14
  addEvent(name: string): void;
21
15
  /**
22
- * Records an exception on the span. The `error` level also marks the span as failed.
16
+ * Records a thrown value on the span, the backend decides how to serialize it.
17
+ * The `error` level also marks the span as failed.
23
18
  */
24
- recordException(level: TracingExceptionLevel, exception: TracingException): void;
19
+ recordException(level: TracingExceptionLevel, error: unknown): void;
25
20
  end(): void;
26
21
  }
27
22
  /**
@@ -67,7 +62,6 @@ export interface StartSpanOptions {
67
62
  export declare function startSpan(options: StartSpanOptions | string): TracingSpan | undefined;
68
63
  export declare function recordSpanError(span: TracingSpan | undefined, error: unknown): void;
69
64
  export declare function setSpanAttributeIfDefined(span: TracingSpan | undefined, key: string, value: TracingAttributeValue | undefined): void;
70
- export declare function toTracingException(error: unknown): TracingException;
71
65
  export declare function toSpanAttributeValue(data: unknown): string;
72
66
  export declare function runWithSpan<T>(options: string | StartSpanOptions, fn: (span?: TracingSpan) => Promisable<T>): Promise<T>;
73
67
  export declare function runInSpanContext<T>(span: TracingSpan | undefined, fn: () => Promisable<T>): Promisable<T>;
package/dist/tracing.js CHANGED
@@ -15,24 +15,12 @@ function startSpan(options) {
15
15
  }
16
16
  function recordSpanError(span, error) {
17
17
  if (!span) return;
18
- span.recordException(isAbortError(error) ? "info" : "error", toTracingException(error));
18
+ span.recordException(isAbortError(error) ? "info" : "error", error);
19
19
  }
20
20
  function setSpanAttributeIfDefined(span, key, value) {
21
21
  if (!span || value === void 0) return;
22
22
  span.setAttribute(key, value);
23
23
  }
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) };
35
- }
36
24
  function toSpanAttributeValue(data) {
37
25
  if (data === void 0) return "undefined";
38
26
  try {
@@ -73,4 +61,4 @@ function runInSpanContext(span, fn) {
73
61
  if (!span || !tracer) return fn();
74
62
  return tracer.withActiveSpan(span, fn);
75
63
  }
76
- export { getTracer, recordSpanError, runInSpanContext, runWithSpan, setSpanAttributeIfDefined, setTracer, startSpan, toSpanAttributeValue, toTracingException };
64
+ export { getTracer, recordSpanError, runInSpanContext, runWithSpan, setSpanAttributeIfDefined, setTracer, startSpan, toSpanAttributeValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orpc/shared",
3
- "version": "2.0.0-beta.51",
3
+ "version": "2.0.0-beta.53",
4
4
  "description": "Internal utilities shared across oRPC packages",
5
5
  "keywords": [
6
6
  "orpc"