@orpc/shared 1.2.0 → 1.3.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/README.md +1 -0
- package/dist/index.d.mts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.mjs +9 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
54
54
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
55
55
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
56
56
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
57
|
+
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with NestJS.
|
|
57
58
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
58
59
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
|
59
60
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
package/dist/index.d.mts
CHANGED
|
@@ -40,10 +40,10 @@ type ThrowableError = Registry extends {
|
|
|
40
40
|
} ? T : Error;
|
|
41
41
|
|
|
42
42
|
type InterceptableOptions = Record<string, any>;
|
|
43
|
-
type InterceptorOptions<TOptions extends InterceptableOptions, TResult
|
|
44
|
-
next(options?: TOptions):
|
|
43
|
+
type InterceptorOptions<TOptions extends InterceptableOptions, TResult> = Omit<TOptions, 'next'> & {
|
|
44
|
+
next(options?: TOptions): TResult;
|
|
45
45
|
};
|
|
46
|
-
type Interceptor<TOptions extends InterceptableOptions, TResult
|
|
46
|
+
type Interceptor<TOptions extends InterceptableOptions, TResult> = (options: InterceptorOptions<TOptions, TResult>) => TResult;
|
|
47
47
|
/**
|
|
48
48
|
* Can used for interceptors or middlewares
|
|
49
49
|
*/
|
|
@@ -69,7 +69,7 @@ type OnFinishState<TResult, TError> = [error: TError, data: undefined, isSuccess
|
|
|
69
69
|
declare function onFinish<T, TOptions extends {
|
|
70
70
|
next(): any;
|
|
71
71
|
}, TRest extends any[]>(callback: NoInfer<(state: OnFinishState<Awaited<ReturnType<TOptions['next']>>, ReturnType<TOptions['next']> extends PromiseWithError<any, infer E> ? E : ThrowableError>, options: TOptions, ...rest: TRest) => Promisable<void>>): (options: TOptions, ...rest: TRest) => T | Promise<Awaited<ReturnType<TOptions['next']>>>;
|
|
72
|
-
declare function intercept<TOptions extends InterceptableOptions, TResult
|
|
72
|
+
declare function intercept<TOptions extends InterceptableOptions, TResult>(interceptors: Interceptor<TOptions, TResult>[], options: NoInfer<TOptions>, main: NoInfer<(options: TOptions) => TResult>): TResult;
|
|
73
73
|
|
|
74
74
|
declare function isAsyncIteratorObject(maybe: unknown): maybe is AsyncIteratorObject<any, any, any>;
|
|
75
75
|
interface CreateAsyncIteratorObjectCleanupFn {
|
|
@@ -95,6 +95,7 @@ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>
|
|
|
95
95
|
declare function isTypescriptObject(value: unknown): value is object & Record<PropertyKey, unknown>;
|
|
96
96
|
declare function clone<T>(value: T): T;
|
|
97
97
|
declare function get(object: object, path: readonly string[]): unknown;
|
|
98
|
+
declare function isPropertyKey(value: unknown): value is PropertyKey;
|
|
98
99
|
|
|
99
100
|
interface AsyncIdQueueCloseOptions {
|
|
100
101
|
id?: number;
|
|
@@ -113,8 +114,8 @@ declare class AsyncIdQueue<T> {
|
|
|
113
114
|
assertOpen(id: number): void;
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) =>
|
|
117
|
-
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>):
|
|
117
|
+
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
118
|
+
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
118
119
|
|
|
119
|
-
export { AsyncIdQueue, SequentialIdGenerator, clone, createAsyncIteratorObject, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
120
|
+
export { AsyncIdQueue, SequentialIdGenerator, clone, createAsyncIteratorObject, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
120
121
|
export type { AnyFunction, AsyncIdQueueCloseOptions, CreateAsyncIteratorObjectCleanupFn, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, PromiseWithError, Registry, Segment, SetOptional, ThrowableError, Value };
|
package/dist/index.d.ts
CHANGED
|
@@ -40,10 +40,10 @@ type ThrowableError = Registry extends {
|
|
|
40
40
|
} ? T : Error;
|
|
41
41
|
|
|
42
42
|
type InterceptableOptions = Record<string, any>;
|
|
43
|
-
type InterceptorOptions<TOptions extends InterceptableOptions, TResult
|
|
44
|
-
next(options?: TOptions):
|
|
43
|
+
type InterceptorOptions<TOptions extends InterceptableOptions, TResult> = Omit<TOptions, 'next'> & {
|
|
44
|
+
next(options?: TOptions): TResult;
|
|
45
45
|
};
|
|
46
|
-
type Interceptor<TOptions extends InterceptableOptions, TResult
|
|
46
|
+
type Interceptor<TOptions extends InterceptableOptions, TResult> = (options: InterceptorOptions<TOptions, TResult>) => TResult;
|
|
47
47
|
/**
|
|
48
48
|
* Can used for interceptors or middlewares
|
|
49
49
|
*/
|
|
@@ -69,7 +69,7 @@ type OnFinishState<TResult, TError> = [error: TError, data: undefined, isSuccess
|
|
|
69
69
|
declare function onFinish<T, TOptions extends {
|
|
70
70
|
next(): any;
|
|
71
71
|
}, TRest extends any[]>(callback: NoInfer<(state: OnFinishState<Awaited<ReturnType<TOptions['next']>>, ReturnType<TOptions['next']> extends PromiseWithError<any, infer E> ? E : ThrowableError>, options: TOptions, ...rest: TRest) => Promisable<void>>): (options: TOptions, ...rest: TRest) => T | Promise<Awaited<ReturnType<TOptions['next']>>>;
|
|
72
|
-
declare function intercept<TOptions extends InterceptableOptions, TResult
|
|
72
|
+
declare function intercept<TOptions extends InterceptableOptions, TResult>(interceptors: Interceptor<TOptions, TResult>[], options: NoInfer<TOptions>, main: NoInfer<(options: TOptions) => TResult>): TResult;
|
|
73
73
|
|
|
74
74
|
declare function isAsyncIteratorObject(maybe: unknown): maybe is AsyncIteratorObject<any, any, any>;
|
|
75
75
|
interface CreateAsyncIteratorObjectCleanupFn {
|
|
@@ -95,6 +95,7 @@ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>
|
|
|
95
95
|
declare function isTypescriptObject(value: unknown): value is object & Record<PropertyKey, unknown>;
|
|
96
96
|
declare function clone<T>(value: T): T;
|
|
97
97
|
declare function get(object: object, path: readonly string[]): unknown;
|
|
98
|
+
declare function isPropertyKey(value: unknown): value is PropertyKey;
|
|
98
99
|
|
|
99
100
|
interface AsyncIdQueueCloseOptions {
|
|
100
101
|
id?: number;
|
|
@@ -113,8 +114,8 @@ declare class AsyncIdQueue<T> {
|
|
|
113
114
|
assertOpen(id: number): void;
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) =>
|
|
117
|
-
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>):
|
|
117
|
+
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
118
|
+
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
118
119
|
|
|
119
|
-
export { AsyncIdQueue, SequentialIdGenerator, clone, createAsyncIteratorObject, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
120
|
+
export { AsyncIdQueue, SequentialIdGenerator, clone, createAsyncIteratorObject, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
120
121
|
export type { AnyFunction, AsyncIdQueueCloseOptions, CreateAsyncIteratorObjectCleanupFn, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, PromiseWithError, Registry, Segment, SetOptional, ThrowableError, Value };
|
package/dist/index.mjs
CHANGED
|
@@ -82,13 +82,13 @@ function onFinish(callback) {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
const next =
|
|
85
|
+
function intercept(interceptors, options, main) {
|
|
86
|
+
const next = (options2, index) => {
|
|
87
87
|
const interceptor = interceptors[index];
|
|
88
88
|
if (!interceptor) {
|
|
89
|
-
return
|
|
89
|
+
return main(options2);
|
|
90
90
|
}
|
|
91
|
-
return
|
|
91
|
+
return interceptor({
|
|
92
92
|
...options2,
|
|
93
93
|
next: (newOptions = options2) => next(newOptions, index + 1)
|
|
94
94
|
});
|
|
@@ -217,6 +217,10 @@ function get(object, path) {
|
|
|
217
217
|
}
|
|
218
218
|
return current;
|
|
219
219
|
}
|
|
220
|
+
function isPropertyKey(value) {
|
|
221
|
+
const type = typeof value;
|
|
222
|
+
return type === "string" || type === "number" || type === "symbol";
|
|
223
|
+
}
|
|
220
224
|
|
|
221
225
|
class AsyncIdQueue {
|
|
222
226
|
openIds = /* @__PURE__ */ new Set();
|
|
@@ -301,4 +305,4 @@ function value(value2, ...args) {
|
|
|
301
305
|
return value2;
|
|
302
306
|
}
|
|
303
307
|
|
|
304
|
-
export { AsyncIdQueue, SequentialIdGenerator, clone, createAsyncIteratorObject, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
308
|
+
export { AsyncIdQueue, SequentialIdGenerator, clone, createAsyncIteratorObject, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|