@orpc/shared 2.0.0-beta.51 → 2.0.0-beta.52
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 +3 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/interceptor.js +2 -11
- package/dist/tracing.d.ts +3 -9
- package/dist/tracing.js +2 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Denis"><img src="https://avatars.githubusercontent.com/u/11864620?u=5f47bbe6c65d0f6f5cf011021490238e4b0593d0&v=4" width="139" alt="Denis"/><br />Denis</a></td>
|
|
184
184
|
<td align="center"><a href="https://github.com/christopher-kapic?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Christopher Kapic"><img src="https://avatars.githubusercontent.com/u/59740769?u=e7ad4b72b5bf6c9eb1644c26dbf3332a8f987377&v=4" width="139" alt="Christopher Kapic"/><br />Christopher Kapic</a></td>
|
|
185
185
|
<td align="center"><a href="http://ballingt.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Tom Ballinger"><img src="https://avatars.githubusercontent.com/u/458879?u=4b045ac75d721b6ac2b42a74d7d37f61f0414031&v=4" width="139" alt="Tom Ballinger"/><br />Tom Ballinger</a></td>
|
|
186
|
-
<td align="center"><a href="https://lee-sam.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Sam"><img src="https://avatars.githubusercontent.com/u/102863520?u=3c89611f549d5070be232eb4532f690c8f2e7a65&v=4" width="139" alt="Sam"/><br />Sam</a></td>
|
|
187
186
|
<td align="center"><a href="https://github.com/Titoine?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Titoine"><img src="https://avatars.githubusercontent.com/u/3514286?u=1bb1e86b0c99c8a1121372e56d51a177eea12191&v=4" width="139" alt="Titoine"/><br />Titoine</a></td>
|
|
188
187
|
<td align="center"><a href="https://rigtch.fm/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Igor Makowski"><img src="https://avatars.githubusercontent.com/u/56691628?u=ee8c879478f7c151b9156aef6c74243fa3e247a8&v=4" width="139" alt="Igor Makowski"/><br />Igor Makowski</a></td>
|
|
188
|
+
<td align="center"><a href="https://blog.cwang.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="hanayashiki"><img src="https://avatars.githubusercontent.com/u/26056783?u=06c3b9205a16fd41a871e82da1cc2a09306d53f5&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&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="hanayashiki"><img src="https://avatars.githubusercontent.com/u/26056783?u=06c3b9205a16fd41a871e82da1cc2a09306d53f5&v=4" width="139" alt="hanayashiki"/><br />hanayashiki</a></td>
|
|
192
191
|
<td align="center"><a href="https://dubinets.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Lev Dubinets"><img src="https://avatars.githubusercontent.com/u/3114081?u=f547f5d5012cab54851f1b1ad72d10e537f78fc2&v=4" width="139" alt="Lev Dubinets"/><br />Lev Dubinets</a></td>
|
|
193
192
|
<td align="center"><a href="https://kellychan.im/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&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&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guy Ariely"><img src="https://avatars.githubusercontent.com/u/42813496?u=edb6b7f563bf28e160a290832e7da57c0506f8ca&v=4" width="139" alt="Guy Ariely"/><br />Guy Ariely</a></td>
|
|
195
194
|
<td align="center"><a href="https://paulsenon.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="PaulSenon"><img src="https://avatars.githubusercontent.com/u/19531087?u=6385741eb91d200b8c513ec6045482e301767ca6&v=4" width="139" alt="PaulSenon"/><br />PaulSenon</a></td>
|
|
196
195
|
<td align="center"><a href="https://usagerail.com/?ref=middleapi&utm_source=middleapi&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&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&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&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&v=4" width="139" alt="Alex"/><br />Alex</a></td>
|
|
200
199
|
<td align="center"><a href="https://opensource.gubanov.eu/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=c5f2daf7ebece498e85c83367bb37b4e10e2649d&v=4" width="139" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
|
|
201
200
|
</tr>
|
|
202
201
|
</table>
|
|
203
202
|
|
|
204
|
-
With thanks to [
|
|
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/index.d.ts
CHANGED
|
@@ -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,
|
|
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,
|
|
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, 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
|
@@ -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
|
|
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";
|
package/dist/interceptor.js
CHANGED
|
@@ -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/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
|
|
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,
|
|
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",
|
|
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
|
|
64
|
+
export { getTracer, recordSpanError, runInSpanContext, runWithSpan, setSpanAttributeIfDefined, setTracer, startSpan, toSpanAttributeValue };
|