@deessejs/functions 0.0.52 → 0.0.55
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
|
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.defineContext = defineContext;
|
|
4
4
|
function defineContext() {
|
|
5
5
|
return {
|
|
6
|
-
//
|
|
7
|
-
//
|
|
6
|
+
// CHANGEMENT CRITIQUE : on utilise <TExtensions extends readonly any[]>
|
|
7
|
+
// On ne veut AUCUNE modification ou validation du type ici.
|
|
8
|
+
// On veut passer l'objet "rpc" brut (avec son générique <C>) jusqu'à MergeExtensions.
|
|
8
9
|
withExtensions: (config) => {
|
|
9
10
|
const runtimeBuilder = {};
|
|
10
11
|
const dummyContext = {};
|
|
11
12
|
for (const extension of config.extensions) {
|
|
12
|
-
//
|
|
13
|
+
// Cast runtime uniquement
|
|
13
14
|
const ext = extension;
|
|
14
15
|
if (ext && typeof ext.functions === 'function') {
|
|
15
16
|
const extensionMethods = ext.functions(dummyContext);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import z, { ZodType } from "zod";
|
|
2
|
-
type ApplyContext<F, C> = F extends (context: C) => infer R ? R : F extends (context: any) =>
|
|
2
|
+
type ApplyContext<F, C> = F extends (context: C) => infer R ? R : F extends (context: any) => any ? ReturnType<F & ((context: C) => any)> : never;
|
|
3
3
|
export type MergeExtensions<TContext, TExtensions extends readonly any[]> = TExtensions extends readonly [infer Head, ...infer Tail] ? (Head extends {
|
|
4
4
|
functions: infer F;
|
|
5
5
|
} ? ApplyContext<F, TContext> : {}) & MergeExtensions<TContext, Tail> : {};
|
|
6
6
|
export type ExtensionBase = {
|
|
7
7
|
context: any;
|
|
8
|
-
functions: any;
|
|
8
|
+
functions: (context: any) => any;
|
|
9
9
|
};
|
|
10
10
|
export type InferOptions<T extends ZodType | undefined> = T extends ZodType ? z.infer<T> : undefined;
|
|
11
11
|
export type Extension<TSchema extends ZodType | undefined, TContextAddon extends Record<string, unknown>, TFunctionsFactory extends <C>(context: C) => any> = (...args: TSchema extends ZodType ? [options: z.input<TSchema>] : [options?: undefined]) => {
|
package/package.json
CHANGED