@orpc/shared 0.0.0-next.fd13879 → 0.0.0-next.fd6982a
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 +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
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 {
|
|
@@ -114,8 +114,8 @@ declare class AsyncIdQueue<T> {
|
|
|
114
114
|
assertOpen(id: number): void;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) =>
|
|
118
|
-
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;
|
|
119
119
|
|
|
120
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 };
|
|
121
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 {
|
|
@@ -114,8 +114,8 @@ declare class AsyncIdQueue<T> {
|
|
|
114
114
|
assertOpen(id: number): void;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) =>
|
|
118
|
-
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;
|
|
119
119
|
|
|
120
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 };
|
|
121
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
|
});
|