@orpc/shared 0.0.0-next.dc23561 → 0.0.0-next.dcc5a52
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 -0
- package/dist/index.d.mts +26 -7
- package/dist/index.d.ts +26 -7
- package/dist/index.mjs +65 -47
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
+
<a href="https://deepwiki.com/unnoq/orpc">
|
|
21
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
|
+
</a>
|
|
20
23
|
</div>
|
|
21
24
|
|
|
22
25
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
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 = "0.0.0-next.
|
|
33
|
+
declare const ORPC_SHARED_PACKAGE_VERSION = "0.0.0-next.dcc5a52";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Error thrown when an operation is aborted.
|
|
@@ -60,7 +60,7 @@ interface EventPublisherSubscribeIteratorOptions extends EventPublisherOptions {
|
|
|
60
60
|
/**
|
|
61
61
|
* Aborts the async iterator. Throws if aborted before or during pulling.
|
|
62
62
|
*/
|
|
63
|
-
signal?: AbortSignal;
|
|
63
|
+
signal?: AbortSignal | undefined;
|
|
64
64
|
}
|
|
65
65
|
declare class EventPublisher<T extends Record<PropertyKey, any>> {
|
|
66
66
|
#private;
|
|
@@ -263,6 +263,11 @@ declare function findDeepMatches(check: (value: unknown) => boolean, payload: un
|
|
|
263
263
|
maps: Segment[][];
|
|
264
264
|
values: unknown[];
|
|
265
265
|
};
|
|
266
|
+
/**
|
|
267
|
+
* Get constructor of the value
|
|
268
|
+
*
|
|
269
|
+
*/
|
|
270
|
+
declare function getConstructor(value: unknown): Function | null | undefined;
|
|
266
271
|
/**
|
|
267
272
|
* Check if the value is an object even it created by `Object.create(null)` or more tricky way.
|
|
268
273
|
*/
|
|
@@ -278,12 +283,29 @@ declare const NullProtoObj: ({
|
|
|
278
283
|
new <T extends Record<PropertyKey, unknown>>(): T;
|
|
279
284
|
});
|
|
280
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
|
+
|
|
281
293
|
/**
|
|
282
294
|
* Prevents objects from being awaitable by intercepting the `then` method
|
|
283
295
|
* when called by the native await mechanism. This is useful for preventing
|
|
284
296
|
* accidental awaiting of objects that aren't meant to be promises.
|
|
285
297
|
*/
|
|
286
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>;
|
|
287
309
|
|
|
288
310
|
interface AsyncIdQueueCloseOptions {
|
|
289
311
|
id?: string;
|
|
@@ -309,8 +331,5 @@ declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableS
|
|
|
309
331
|
|
|
310
332
|
declare function tryDecodeURIComponent(value: string): string;
|
|
311
333
|
|
|
312
|
-
|
|
313
|
-
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
314
|
-
|
|
315
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, findDeepMatches, get, 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 };
|
|
316
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 = "0.0.0-next.
|
|
33
|
+
declare const ORPC_SHARED_PACKAGE_VERSION = "0.0.0-next.dcc5a52";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Error thrown when an operation is aborted.
|
|
@@ -60,7 +60,7 @@ interface EventPublisherSubscribeIteratorOptions extends EventPublisherOptions {
|
|
|
60
60
|
/**
|
|
61
61
|
* Aborts the async iterator. Throws if aborted before or during pulling.
|
|
62
62
|
*/
|
|
63
|
-
signal?: AbortSignal;
|
|
63
|
+
signal?: AbortSignal | undefined;
|
|
64
64
|
}
|
|
65
65
|
declare class EventPublisher<T extends Record<PropertyKey, any>> {
|
|
66
66
|
#private;
|
|
@@ -263,6 +263,11 @@ declare function findDeepMatches(check: (value: unknown) => boolean, payload: un
|
|
|
263
263
|
maps: Segment[][];
|
|
264
264
|
values: unknown[];
|
|
265
265
|
};
|
|
266
|
+
/**
|
|
267
|
+
* Get constructor of the value
|
|
268
|
+
*
|
|
269
|
+
*/
|
|
270
|
+
declare function getConstructor(value: unknown): Function | null | undefined;
|
|
266
271
|
/**
|
|
267
272
|
* Check if the value is an object even it created by `Object.create(null)` or more tricky way.
|
|
268
273
|
*/
|
|
@@ -278,12 +283,29 @@ declare const NullProtoObj: ({
|
|
|
278
283
|
new <T extends Record<PropertyKey, unknown>>(): T;
|
|
279
284
|
});
|
|
280
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
|
+
|
|
281
293
|
/**
|
|
282
294
|
* Prevents objects from being awaitable by intercepting the `then` method
|
|
283
295
|
* when called by the native await mechanism. This is useful for preventing
|
|
284
296
|
* accidental awaiting of objects that aren't meant to be promises.
|
|
285
297
|
*/
|
|
286
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>;
|
|
287
309
|
|
|
288
310
|
interface AsyncIdQueueCloseOptions {
|
|
289
311
|
id?: string;
|
|
@@ -309,8 +331,5 @@ declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableS
|
|
|
309
331
|
|
|
310
332
|
declare function tryDecodeURIComponent(value: string): string;
|
|
311
333
|
|
|
312
|
-
|
|
313
|
-
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
314
|
-
|
|
315
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, findDeepMatches, get, 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 };
|
|
316
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 = "0.0.0-next.
|
|
24
|
+
const ORPC_SHARED_PACKAGE_VERSION = "0.0.0-next.dcc5a52";
|
|
25
25
|
|
|
26
26
|
class AbortError extends Error {
|
|
27
27
|
constructor(...rest) {
|
|
@@ -210,18 +210,16 @@ class AsyncIdQueue {
|
|
|
210
210
|
close({ id, reason } = {}) {
|
|
211
211
|
if (id === void 0) {
|
|
212
212
|
this.waiters.forEach((pendingPulls, id2) => {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
});
|
|
213
|
+
const error2 = reason ?? new AbortError(`[AsyncIdQueue] Queue[${id2}] was closed or aborted while waiting for pulling.`);
|
|
214
|
+
pendingPulls.forEach(([, reject]) => reject(error2));
|
|
216
215
|
});
|
|
217
216
|
this.waiters.clear();
|
|
218
217
|
this.openIds.clear();
|
|
219
218
|
this.queues.clear();
|
|
220
219
|
return;
|
|
221
220
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
});
|
|
221
|
+
const error = reason ?? new AbortError(`[AsyncIdQueue] Queue[${id}] was closed or aborted while waiting for pulling.`);
|
|
222
|
+
this.waiters.get(id)?.forEach(([, reject]) => reject(error));
|
|
225
223
|
this.waiters.delete(id);
|
|
226
224
|
this.openIds.delete(id);
|
|
227
225
|
this.queues.delete(id);
|
|
@@ -304,53 +302,51 @@ class AsyncIteratorClass {
|
|
|
304
302
|
}
|
|
305
303
|
function replicateAsyncIterator(source, count) {
|
|
306
304
|
const queue = new AsyncIdQueue();
|
|
307
|
-
const
|
|
308
|
-
let
|
|
305
|
+
const ids = Array.from({ length: count }, (_, i) => i.toString());
|
|
306
|
+
let isSourceFinished = false;
|
|
309
307
|
const start = once(async () => {
|
|
310
308
|
try {
|
|
311
309
|
while (true) {
|
|
312
310
|
const item = await source.next();
|
|
313
|
-
|
|
314
|
-
const id = i.toString();
|
|
311
|
+
ids.forEach((id) => {
|
|
315
312
|
if (queue.isOpen(id)) {
|
|
316
|
-
queue.push(id, item);
|
|
313
|
+
queue.push(id, { next: item });
|
|
317
314
|
}
|
|
318
|
-
}
|
|
315
|
+
});
|
|
319
316
|
if (item.done) {
|
|
320
317
|
break;
|
|
321
318
|
}
|
|
322
319
|
}
|
|
323
|
-
} catch (
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
320
|
+
} catch (error) {
|
|
321
|
+
ids.forEach((id) => {
|
|
322
|
+
if (queue.isOpen(id)) {
|
|
323
|
+
queue.push(id, { error });
|
|
324
|
+
}
|
|
327
325
|
});
|
|
326
|
+
} finally {
|
|
327
|
+
isSourceFinished = true;
|
|
328
328
|
}
|
|
329
329
|
});
|
|
330
|
-
|
|
331
|
-
const id = i.toString();
|
|
330
|
+
const replicated = ids.map((id) => {
|
|
332
331
|
queue.open(id);
|
|
333
|
-
|
|
334
|
-
() => {
|
|
332
|
+
return new AsyncIteratorClass(
|
|
333
|
+
async () => {
|
|
335
334
|
start();
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
});
|
|
335
|
+
const item = await queue.pull(id);
|
|
336
|
+
if (item.next) {
|
|
337
|
+
return item.next;
|
|
338
|
+
}
|
|
339
|
+
throw item.error;
|
|
343
340
|
},
|
|
344
341
|
async (reason) => {
|
|
345
342
|
queue.close({ id });
|
|
346
|
-
if (reason !== "next") {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
343
|
+
if (reason !== "next" && !queue.length && !isSourceFinished) {
|
|
344
|
+
isSourceFinished = true;
|
|
345
|
+
await source?.return?.();
|
|
350
346
|
}
|
|
351
347
|
}
|
|
352
|
-
)
|
|
353
|
-
}
|
|
348
|
+
);
|
|
349
|
+
});
|
|
354
350
|
return replicated;
|
|
355
351
|
}
|
|
356
352
|
function asyncIteratorWithSpan({ name, ...options }, iterator) {
|
|
@@ -546,6 +542,12 @@ function findDeepMatches(check, payload, segments = [], maps = [], values = [])
|
|
|
546
542
|
}
|
|
547
543
|
return { maps, values };
|
|
548
544
|
}
|
|
545
|
+
function getConstructor(value) {
|
|
546
|
+
if (!isTypescriptObject(value)) {
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
return Object.getPrototypeOf(value)?.constructor;
|
|
550
|
+
}
|
|
549
551
|
function isObject(value) {
|
|
550
552
|
if (!value || typeof value !== "object") {
|
|
551
553
|
return false;
|
|
@@ -591,14 +593,24 @@ const NullProtoObj = /* @__PURE__ */ (() => {
|
|
|
591
593
|
return e;
|
|
592
594
|
})();
|
|
593
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
|
+
|
|
594
606
|
function preventNativeAwait(target) {
|
|
595
607
|
return new Proxy(target, {
|
|
596
608
|
get(target2, prop, receiver) {
|
|
597
|
-
const
|
|
598
|
-
if (prop !== "then" || typeof
|
|
599
|
-
return
|
|
609
|
+
const value2 = Reflect.get(target2, prop, receiver);
|
|
610
|
+
if (prop !== "then" || typeof value2 !== "function") {
|
|
611
|
+
return value2;
|
|
600
612
|
}
|
|
601
|
-
return new Proxy(
|
|
613
|
+
return new Proxy(value2, {
|
|
602
614
|
apply(targetFn, thisArg, args) {
|
|
603
615
|
if (args.length !== 2 || args.some((arg) => !isNativeFunction(arg))) {
|
|
604
616
|
return Reflect.apply(targetFn, thisArg, args);
|
|
@@ -622,6 +634,19 @@ const NATIVE_FUNCTION_REGEX = /^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s
|
|
|
622
634
|
function isNativeFunction(fn) {
|
|
623
635
|
return typeof fn === "function" && NATIVE_FUNCTION_REGEX.test(fn.toString());
|
|
624
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
|
+
}
|
|
625
650
|
|
|
626
651
|
function streamToAsyncIteratorClass(stream) {
|
|
627
652
|
const reader = stream.getReader();
|
|
@@ -658,11 +683,4 @@ function tryDecodeURIComponent(value) {
|
|
|
658
683
|
}
|
|
659
684
|
}
|
|
660
685
|
|
|
661
|
-
|
|
662
|
-
if (typeof value2 === "function") {
|
|
663
|
-
return value2(...args);
|
|
664
|
-
}
|
|
665
|
-
return value2;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, findDeepMatches, get, 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": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.dcc5a52",
|
|
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",
|