@deessejs/functions 0.0.34 → 0.0.36
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ZodType } from "zod";
|
|
2
2
|
import { Extension, InferOptions } from "./types";
|
|
3
|
-
export declare function extensions<TSchema extends ZodType | undefined = undefined, TContextAddon extends Record<string, unknown> = Record<string, unknown>, TFunctionsFactory extends (context:
|
|
3
|
+
export declare function extensions<TSchema extends ZodType | undefined = undefined, TContextAddon extends Record<string, unknown> = Record<string, unknown>, TFunctionsFactory extends (<C>(context: C) => any) = (<C>(context: C) => any)>(config: {
|
|
4
4
|
name: string;
|
|
5
5
|
schema?: TSchema;
|
|
6
6
|
context?: (options: InferOptions<TSchema>) => TContextAddon;
|
|
@@ -2,13 +2,16 @@ import z, { ZodType } from "zod";
|
|
|
2
2
|
export type InferOptions<T extends ZodType | undefined> = T extends ZodType ? z.infer<T> : undefined;
|
|
3
3
|
export type ExtensionBase = {
|
|
4
4
|
context: any;
|
|
5
|
-
functions: (context:
|
|
5
|
+
functions: <C>(context: C) => any;
|
|
6
6
|
};
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
type FnCallSignatureMatchesWith<C, F> = F extends {
|
|
8
|
+
(context: C): infer R;
|
|
9
|
+
} ? R : F extends {
|
|
10
|
+
<U>(context: U): infer RGeneric;
|
|
11
|
+
} ? RGeneric : F extends (context: any) => infer R ? R : never;
|
|
12
|
+
export type MergeExtensions<TContext, TExtensions extends readonly any[]> = TExtensions extends readonly [infer Head, ...infer Tail] ? (Head extends {
|
|
10
13
|
functions: infer F;
|
|
11
|
-
} ?
|
|
14
|
+
} ? FnCallSignatureMatchesWith<TContext, F> : {}) & MergeExtensions<TContext, Tail> : {};
|
|
12
15
|
export type ExtensionConfig<TSchema extends ZodType | undefined, TContextAddon extends Record<string, unknown>> = {
|
|
13
16
|
name: string;
|
|
14
17
|
schema?: TSchema;
|
package/package.json
CHANGED