@orpc/shared 1.8.9 → 1.9.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 +20 -6
- package/dist/index.d.ts +20 -6
- package/dist/index.mjs +30 -14
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Promisable } from 'type-fest';
|
|
2
2
|
export { IsEqual, IsNever, JsonValue, PartialDeep, Promisable } from 'type-fest';
|
|
3
3
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
4
|
-
export { group, guard, mapEntries, mapValues, omit } from 'radash';
|
|
4
|
+
export { group, guard, mapEntries, mapValues, omit, retry, sleep } from 'radash';
|
|
5
5
|
|
|
6
6
|
type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
7
7
|
declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
|
|
@@ -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.9.0";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Error thrown when an operation is aborted.
|
|
@@ -283,12 +283,29 @@ declare const NullProtoObj: ({
|
|
|
283
283
|
new <T extends Record<PropertyKey, unknown>>(): T;
|
|
284
284
|
});
|
|
285
285
|
|
|
286
|
+
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
287
|
+
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
288
|
+
/**
|
|
289
|
+
* Returns the value if it is defined, otherwise returns the fallback
|
|
290
|
+
*/
|
|
291
|
+
declare function fallback<T>(value: T | undefined, fallback: T): T;
|
|
292
|
+
|
|
286
293
|
/**
|
|
287
294
|
* Prevents objects from being awaitable by intercepting the `then` method
|
|
288
295
|
* when called by the native await mechanism. This is useful for preventing
|
|
289
296
|
* accidental awaiting of objects that aren't meant to be promises.
|
|
290
297
|
*/
|
|
291
298
|
declare function preventNativeAwait<T extends object>(target: T): T;
|
|
299
|
+
/**
|
|
300
|
+
* Create a proxy that overlays one object (`overlay`) on top of another (`target`).
|
|
301
|
+
*
|
|
302
|
+
* - Properties from `overlay` take precedence.
|
|
303
|
+
* - Properties not in `overlay` fall back to `target`.
|
|
304
|
+
* - Methods from either object are bound to `overlay` so `this` is consistent.
|
|
305
|
+
*
|
|
306
|
+
* Useful when you want to override or extend behavior without fully copying/merging objects.
|
|
307
|
+
*/
|
|
308
|
+
declare function overlayProxy<T extends object, U extends object>(target: Value<T>, partial: U): U & Omit<T, keyof U>;
|
|
292
309
|
|
|
293
310
|
interface AsyncIdQueueCloseOptions {
|
|
294
311
|
id?: string;
|
|
@@ -314,8 +331,5 @@ declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableS
|
|
|
314
331
|
|
|
315
332
|
declare function tryDecodeURIComponent(value: string): string;
|
|
316
333
|
|
|
317
|
-
|
|
318
|
-
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
319
|
-
|
|
320
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
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 };
|
|
321
335
|
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Promisable } from 'type-fest';
|
|
2
2
|
export { IsEqual, IsNever, JsonValue, PartialDeep, Promisable } from 'type-fest';
|
|
3
3
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
4
|
-
export { group, guard, mapEntries, mapValues, omit } from 'radash';
|
|
4
|
+
export { group, guard, mapEntries, mapValues, omit, retry, sleep } from 'radash';
|
|
5
5
|
|
|
6
6
|
type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
7
7
|
declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
|
|
@@ -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.9.0";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Error thrown when an operation is aborted.
|
|
@@ -283,12 +283,29 @@ declare const NullProtoObj: ({
|
|
|
283
283
|
new <T extends Record<PropertyKey, unknown>>(): T;
|
|
284
284
|
});
|
|
285
285
|
|
|
286
|
+
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
287
|
+
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
288
|
+
/**
|
|
289
|
+
* Returns the value if it is defined, otherwise returns the fallback
|
|
290
|
+
*/
|
|
291
|
+
declare function fallback<T>(value: T | undefined, fallback: T): T;
|
|
292
|
+
|
|
286
293
|
/**
|
|
287
294
|
* Prevents objects from being awaitable by intercepting the `then` method
|
|
288
295
|
* when called by the native await mechanism. This is useful for preventing
|
|
289
296
|
* accidental awaiting of objects that aren't meant to be promises.
|
|
290
297
|
*/
|
|
291
298
|
declare function preventNativeAwait<T extends object>(target: T): T;
|
|
299
|
+
/**
|
|
300
|
+
* Create a proxy that overlays one object (`overlay`) on top of another (`target`).
|
|
301
|
+
*
|
|
302
|
+
* - Properties from `overlay` take precedence.
|
|
303
|
+
* - Properties not in `overlay` fall back to `target`.
|
|
304
|
+
* - Methods from either object are bound to `overlay` so `this` is consistent.
|
|
305
|
+
*
|
|
306
|
+
* Useful when you want to override or extend behavior without fully copying/merging objects.
|
|
307
|
+
*/
|
|
308
|
+
declare function overlayProxy<T extends object, U extends object>(target: Value<T>, partial: U): U & Omit<T, keyof U>;
|
|
292
309
|
|
|
293
310
|
interface AsyncIdQueueCloseOptions {
|
|
294
311
|
id?: string;
|
|
@@ -314,8 +331,5 @@ declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableS
|
|
|
314
331
|
|
|
315
332
|
declare function tryDecodeURIComponent(value: string): string;
|
|
316
333
|
|
|
317
|
-
|
|
318
|
-
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
319
|
-
|
|
320
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
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 };
|
|
321
335
|
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { group, guard, mapEntries, mapValues, omit } from 'radash';
|
|
1
|
+
export { group, guard, mapEntries, mapValues, omit, retry, sleep } from 'radash';
|
|
2
2
|
|
|
3
3
|
function resolveMaybeOptionalOptions(rest) {
|
|
4
4
|
return rest[0] ?? {};
|
|
@@ -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.9.0";
|
|
25
25
|
|
|
26
26
|
class AbortError extends Error {
|
|
27
27
|
constructor(...rest) {
|
|
@@ -593,14 +593,24 @@ const NullProtoObj = /* @__PURE__ */ (() => {
|
|
|
593
593
|
return e;
|
|
594
594
|
})();
|
|
595
595
|
|
|
596
|
+
function value(value2, ...args) {
|
|
597
|
+
if (typeof value2 === "function") {
|
|
598
|
+
return value2(...args);
|
|
599
|
+
}
|
|
600
|
+
return value2;
|
|
601
|
+
}
|
|
602
|
+
function fallback(value2, fallback2) {
|
|
603
|
+
return value2 === void 0 ? fallback2 : value2;
|
|
604
|
+
}
|
|
605
|
+
|
|
596
606
|
function preventNativeAwait(target) {
|
|
597
607
|
return new Proxy(target, {
|
|
598
608
|
get(target2, prop, receiver) {
|
|
599
|
-
const
|
|
600
|
-
if (prop !== "then" || typeof
|
|
601
|
-
return
|
|
609
|
+
const value2 = Reflect.get(target2, prop, receiver);
|
|
610
|
+
if (prop !== "then" || typeof value2 !== "function") {
|
|
611
|
+
return value2;
|
|
602
612
|
}
|
|
603
|
-
return new Proxy(
|
|
613
|
+
return new Proxy(value2, {
|
|
604
614
|
apply(targetFn, thisArg, args) {
|
|
605
615
|
if (args.length !== 2 || args.some((arg) => !isNativeFunction(arg))) {
|
|
606
616
|
return Reflect.apply(targetFn, thisArg, args);
|
|
@@ -624,6 +634,19 @@ const NATIVE_FUNCTION_REGEX = /^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s
|
|
|
624
634
|
function isNativeFunction(fn) {
|
|
625
635
|
return typeof fn === "function" && NATIVE_FUNCTION_REGEX.test(fn.toString());
|
|
626
636
|
}
|
|
637
|
+
function overlayProxy(target, partial) {
|
|
638
|
+
const proxy = new Proxy(typeof target === "function" ? partial : target, {
|
|
639
|
+
get(_, prop) {
|
|
640
|
+
const targetValue = prop in partial ? partial : value(target);
|
|
641
|
+
const v = Reflect.get(targetValue, prop);
|
|
642
|
+
return typeof v === "function" ? v.bind(targetValue) : v;
|
|
643
|
+
},
|
|
644
|
+
has(_, prop) {
|
|
645
|
+
return Reflect.has(partial, prop) || Reflect.has(value(target), prop);
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
return proxy;
|
|
649
|
+
}
|
|
627
650
|
|
|
628
651
|
function streamToAsyncIteratorClass(stream) {
|
|
629
652
|
const reader = stream.getReader();
|
|
@@ -660,11 +683,4 @@ function tryDecodeURIComponent(value) {
|
|
|
660
683
|
}
|
|
661
684
|
}
|
|
662
685
|
|
|
663
|
-
|
|
664
|
-
if (typeof value2 === "function") {
|
|
665
|
-
return value2(...args);
|
|
666
|
-
}
|
|
667
|
-
return value2;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
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 };
|
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.9.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": "^
|
|
36
|
+
"type-fest": "^5.0.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@opentelemetry/api": "^1.9.0",
|
|
40
|
-
"arktype": "2.1.
|
|
40
|
+
"arktype": "2.1.22",
|
|
41
41
|
"valibot": "^1.1.0",
|
|
42
|
-
"zod": "^4.1.
|
|
42
|
+
"zod": "^4.1.11"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "unbuild",
|