@deessejs/functions 0.0.33 → 0.0.35
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/context/define.js
CHANGED
|
@@ -7,7 +7,6 @@ function defineContext() {
|
|
|
7
7
|
const builder = {};
|
|
8
8
|
const dummyContext = {};
|
|
9
9
|
for (const extension of config.extensions) {
|
|
10
|
-
// runtime : on appelle la factory avec le contexte (dummy)
|
|
11
10
|
const extensionMethods = extension.functions(dummyContext);
|
|
12
11
|
Object.assign(builder, extensionMethods);
|
|
13
12
|
}
|
|
@@ -4,11 +4,14 @@ export type ExtensionBase = {
|
|
|
4
4
|
context: any;
|
|
5
5
|
functions: (context: any) => any;
|
|
6
6
|
};
|
|
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;
|
|
7
12
|
export type MergeExtensions<TContext, TExtensions extends readonly any[]> = TExtensions extends readonly [infer Head, ...infer Tail] ? (Head extends {
|
|
8
|
-
functions:
|
|
9
|
-
} ?
|
|
10
|
-
functions: (context: any) => infer R;
|
|
11
|
-
} ? R : {}) & MergeExtensions<TContext, Tail> : {};
|
|
13
|
+
functions: infer F;
|
|
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;
|
|
@@ -19,3 +22,4 @@ export type Extension<TSchema extends ZodType | undefined, TContextAddon extends
|
|
|
19
22
|
context: TContextAddon;
|
|
20
23
|
functions: TFunctionsFactory;
|
|
21
24
|
};
|
|
25
|
+
export {};
|
package/package.json
CHANGED