@orpc/shared 1.9.3 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.mjs +32 -10
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -30,7 +30,7 @@ type OmitChainMethodDeep<T extends object, K extends keyof any> = {
|
|
|
30
30
|
|
|
31
31
|
declare const ORPC_NAME = "orpc";
|
|
32
32
|
declare const ORPC_SHARED_PACKAGE_NAME = "@orpc/shared";
|
|
33
|
-
declare const ORPC_SHARED_PACKAGE_VERSION = "1.
|
|
33
|
+
declare const ORPC_SHARED_PACKAGE_VERSION = "1.10.0";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Error thrown when an operation is aborted.
|
|
@@ -103,6 +103,14 @@ declare class SequentialIdGenerator {
|
|
|
103
103
|
private index;
|
|
104
104
|
generate(): string;
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Compares two sequential IDs.
|
|
108
|
+
* Returns:
|
|
109
|
+
* - negative if `a` < `b`
|
|
110
|
+
* - positive if `a` > `b`
|
|
111
|
+
* - 0 if equal
|
|
112
|
+
*/
|
|
113
|
+
declare function compareSequentialIds(a: string, b: string): number;
|
|
106
114
|
|
|
107
115
|
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
108
116
|
type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
|
|
@@ -326,10 +334,21 @@ declare class AsyncIdQueue<T> {
|
|
|
326
334
|
assertOpen(id: string): void;
|
|
327
335
|
}
|
|
328
336
|
|
|
337
|
+
/**
|
|
338
|
+
* Converts a `ReadableStream` into an `AsyncIteratorClass`.
|
|
339
|
+
*/
|
|
329
340
|
declare function streamToAsyncIteratorClass<T>(stream: ReadableStream<T>): AsyncIteratorClass<T>;
|
|
341
|
+
/**
|
|
342
|
+
* Converts an `AsyncIterator` into a `ReadableStream`.
|
|
343
|
+
*/
|
|
330
344
|
declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
|
|
345
|
+
/**
|
|
346
|
+
* Converts an `AsyncIterator` into a `ReadableStream`, ensuring that
|
|
347
|
+
* all emitted object values are *unproxied* before enqueuing.
|
|
348
|
+
*/
|
|
349
|
+
declare function asyncIteratorToUnproxiedDataStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
|
|
331
350
|
|
|
332
351
|
declare function tryDecodeURIComponent(value: string): string;
|
|
333
352
|
|
|
334
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, fallback, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
353
|
+
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorWithSpan, clone, compareSequentialIds, defer, fallback, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
335
354
|
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, InferAsyncIterableYield, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, OtelConfig, PromiseWithError, Registry, RunWithSpanOptions, Segment, SetOptional, SetSpanErrorOptions, ThrowableError, Value };
|
package/dist/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ type OmitChainMethodDeep<T extends object, K extends keyof any> = {
|
|
|
30
30
|
|
|
31
31
|
declare const ORPC_NAME = "orpc";
|
|
32
32
|
declare const ORPC_SHARED_PACKAGE_NAME = "@orpc/shared";
|
|
33
|
-
declare const ORPC_SHARED_PACKAGE_VERSION = "1.
|
|
33
|
+
declare const ORPC_SHARED_PACKAGE_VERSION = "1.10.0";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Error thrown when an operation is aborted.
|
|
@@ -103,6 +103,14 @@ declare class SequentialIdGenerator {
|
|
|
103
103
|
private index;
|
|
104
104
|
generate(): string;
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Compares two sequential IDs.
|
|
108
|
+
* Returns:
|
|
109
|
+
* - negative if `a` < `b`
|
|
110
|
+
* - positive if `a` > `b`
|
|
111
|
+
* - 0 if equal
|
|
112
|
+
*/
|
|
113
|
+
declare function compareSequentialIds(a: string, b: string): number;
|
|
106
114
|
|
|
107
115
|
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
108
116
|
type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
|
|
@@ -326,10 +334,21 @@ declare class AsyncIdQueue<T> {
|
|
|
326
334
|
assertOpen(id: string): void;
|
|
327
335
|
}
|
|
328
336
|
|
|
337
|
+
/**
|
|
338
|
+
* Converts a `ReadableStream` into an `AsyncIteratorClass`.
|
|
339
|
+
*/
|
|
329
340
|
declare function streamToAsyncIteratorClass<T>(stream: ReadableStream<T>): AsyncIteratorClass<T>;
|
|
341
|
+
/**
|
|
342
|
+
* Converts an `AsyncIterator` into a `ReadableStream`.
|
|
343
|
+
*/
|
|
330
344
|
declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
|
|
345
|
+
/**
|
|
346
|
+
* Converts an `AsyncIterator` into a `ReadableStream`, ensuring that
|
|
347
|
+
* all emitted object values are *unproxied* before enqueuing.
|
|
348
|
+
*/
|
|
349
|
+
declare function asyncIteratorToUnproxiedDataStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
|
|
331
350
|
|
|
332
351
|
declare function tryDecodeURIComponent(value: string): string;
|
|
333
352
|
|
|
334
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, fallback, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
353
|
+
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorWithSpan, clone, compareSequentialIds, defer, fallback, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
335
354
|
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, InferAsyncIterableYield, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, OtelConfig, PromiseWithError, Registry, RunWithSpanOptions, Segment, SetOptional, SetSpanErrorOptions, ThrowableError, Value };
|
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ function readAsBuffer(source) {
|
|
|
21
21
|
|
|
22
22
|
const ORPC_NAME = "orpc";
|
|
23
23
|
const ORPC_SHARED_PACKAGE_NAME = "@orpc/shared";
|
|
24
|
-
const ORPC_SHARED_PACKAGE_VERSION = "1.
|
|
24
|
+
const ORPC_SHARED_PACKAGE_VERSION = "1.10.0";
|
|
25
25
|
|
|
26
26
|
class AbortError extends Error {
|
|
27
27
|
constructor(...rest) {
|
|
@@ -403,15 +403,15 @@ class EventPublisher {
|
|
|
403
403
|
if (typeof listenerOrOptions === "function") {
|
|
404
404
|
let listeners = this.#listenersMap.get(event);
|
|
405
405
|
if (!listeners) {
|
|
406
|
-
this.#listenersMap.set(event, listeners =
|
|
406
|
+
this.#listenersMap.set(event, listeners = []);
|
|
407
407
|
}
|
|
408
|
-
listeners.
|
|
409
|
-
return () => {
|
|
410
|
-
listeners.
|
|
411
|
-
if (listeners.
|
|
408
|
+
listeners.push(listenerOrOptions);
|
|
409
|
+
return once(() => {
|
|
410
|
+
listeners.splice(listeners.indexOf(listenerOrOptions), 1);
|
|
411
|
+
if (listeners.length === 0) {
|
|
412
412
|
this.#listenersMap.delete(event);
|
|
413
413
|
}
|
|
414
|
-
};
|
|
414
|
+
});
|
|
415
415
|
}
|
|
416
416
|
const signal = listenerOrOptions?.signal;
|
|
417
417
|
const maxBufferedEvents = listenerOrOptions?.maxBufferedEvents ?? this.#maxBufferedEvents;
|
|
@@ -457,13 +457,19 @@ class EventPublisher {
|
|
|
457
457
|
}
|
|
458
458
|
|
|
459
459
|
class SequentialIdGenerator {
|
|
460
|
-
index = BigInt(
|
|
460
|
+
index = BigInt(1);
|
|
461
461
|
generate() {
|
|
462
|
-
const id = this.index.toString(
|
|
462
|
+
const id = this.index.toString(36);
|
|
463
463
|
this.index++;
|
|
464
464
|
return id;
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
+
function compareSequentialIds(a, b) {
|
|
468
|
+
if (a.length !== b.length) {
|
|
469
|
+
return a.length - b.length;
|
|
470
|
+
}
|
|
471
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
472
|
+
}
|
|
467
473
|
|
|
468
474
|
function onStart(callback) {
|
|
469
475
|
return async (options, ...rest) => {
|
|
@@ -674,6 +680,22 @@ function asyncIteratorToStream(iterator) {
|
|
|
674
680
|
}
|
|
675
681
|
});
|
|
676
682
|
}
|
|
683
|
+
function asyncIteratorToUnproxiedDataStream(iterator) {
|
|
684
|
+
return new ReadableStream({
|
|
685
|
+
async pull(controller) {
|
|
686
|
+
const { done, value } = await iterator.next();
|
|
687
|
+
if (done) {
|
|
688
|
+
controller.close();
|
|
689
|
+
} else {
|
|
690
|
+
const unproxied = isObject(value) ? { ...value } : Array.isArray(value) ? value.map((i) => i) : value;
|
|
691
|
+
controller.enqueue(unproxied);
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
async cancel() {
|
|
695
|
+
await iterator.return?.();
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
}
|
|
677
699
|
|
|
678
700
|
function tryDecodeURIComponent(value) {
|
|
679
701
|
try {
|
|
@@ -683,4 +705,4 @@ function tryDecodeURIComponent(value) {
|
|
|
683
705
|
}
|
|
684
706
|
}
|
|
685
707
|
|
|
686
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, fallback, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
708
|
+
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorWithSpan, clone, compareSequentialIds, defer, fallback, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.10.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"radash": "^12.1.1",
|
|
36
|
-
"type-fest": "^5.0
|
|
36
|
+
"type-fest": "^5.1.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@opentelemetry/api": "^1.9.0",
|
|
40
|
-
"arktype": "2.1.
|
|
40
|
+
"arktype": "2.1.23",
|
|
41
41
|
"valibot": "^1.1.0",
|
|
42
|
-
"zod": "^4.1.
|
|
42
|
+
"zod": "^4.1.12"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "unbuild",
|