@deessejs/functions 0.0.42 → 0.0.44
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
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// defineContext.ts
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.defineContext = defineContext;
|
|
4
5
|
function defineContext() {
|
|
5
6
|
return {
|
|
6
7
|
withExtensions: (config) => {
|
|
7
|
-
//
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const result = {
|
|
11
|
-
context: runtimeContext,
|
|
12
|
-
};
|
|
8
|
+
// runtime builder (inchangé)
|
|
9
|
+
const runtimeBuilder = {};
|
|
10
|
+
const dummyContext = {};
|
|
13
11
|
for (const extension of config.extensions) {
|
|
14
|
-
//
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
Object.assign(result, methods);
|
|
12
|
+
// appele runtime, pour construire les méthodes effectives
|
|
13
|
+
const extensionMethods = extension.functions(dummyContext);
|
|
14
|
+
Object.assign(runtimeBuilder, extensionMethods);
|
|
18
15
|
}
|
|
19
|
-
|
|
16
|
+
// On retourne runtimeBuilder mais on force le type public attendu.
|
|
17
|
+
return {
|
|
18
|
+
...runtimeBuilder,
|
|
19
|
+
context: {},
|
|
20
|
+
};
|
|
20
21
|
},
|
|
21
22
|
};
|
|
22
23
|
}
|
package/dist/context/types.d.ts
CHANGED
|
@@ -14,11 +14,11 @@ export type MutationDefinition<TContext, TArgs extends ZodType, TOutput, TError
|
|
|
14
14
|
};
|
|
15
15
|
export type CommandsDefinition = QueryDefinition<any, any, any, any> | MutationDefinition<any, any, any, any>;
|
|
16
16
|
export type FunctionsForContext<C> = {
|
|
17
|
-
query: <TArgs extends ZodType, TOutput, TError extends Exception>(def: QueryDefinition<C, TArgs, TOutput, TError>) =>
|
|
18
|
-
mutation: <TArgs extends ZodType, TOutput, TError extends Exception>(def: MutationDefinition<C, TArgs, TOutput, TError>) =>
|
|
17
|
+
query: <TArgs extends ZodType, TOutput, TError extends Exception>(def: QueryDefinition<C, TArgs, TOutput, TError>) => any;
|
|
18
|
+
mutation: <TArgs extends ZodType, TOutput, TError extends Exception>(def: MutationDefinition<C, TArgs, TOutput, TError>) => any;
|
|
19
19
|
on?: <TEvent extends string, TPayload>(config: {
|
|
20
20
|
event: TEvent;
|
|
21
21
|
handler: (ctx: C, payload: TPayload) => AsyncResult<any, any>;
|
|
22
22
|
}) => any;
|
|
23
|
-
group?: <TGroup extends Record<string, CommandsDefinition>>(defs: TGroup) =>
|
|
23
|
+
group?: <TGroup extends Record<string, CommandsDefinition>>(defs: TGroup) => any;
|
|
24
24
|
};
|
package/dist/extensions/rpc.d.ts
CHANGED
|
@@ -16,5 +16,4 @@ export declare const rpc: import("./types").Extension<undefined, Record<string,
|
|
|
16
16
|
handler: (ctx: C, args: z.infer<TArgs>) => AsyncResult<TOutput_1, TError_1>;
|
|
17
17
|
}) => MutationDefinition<C, TArgs, TOutput_1, TError_1>;
|
|
18
18
|
group: <T extends Record<string, APINode>>(definitions: T) => T;
|
|
19
|
-
_contextType: C;
|
|
20
19
|
}>;
|
package/dist/extensions/rpc.js
CHANGED
|
@@ -10,10 +10,10 @@ type FnCallSignatureMatchesWith<C, F> = F extends {
|
|
|
10
10
|
export type MergeExtensions<TContext, TExtensions extends readonly any[]> = TExtensions extends readonly [infer Head, ...infer Tail] ? (Head extends {
|
|
11
11
|
functions: infer F;
|
|
12
12
|
} ? FnCallSignatureMatchesWith<TContext, F> : {}) & MergeExtensions<TContext, Tail> : {};
|
|
13
|
-
/** Ici : functions est une
|
|
13
|
+
/** Ici : functions est *explicitement* une call signature générique */
|
|
14
14
|
export type ExtensionBase = {
|
|
15
15
|
context: any;
|
|
16
|
-
functions: <
|
|
16
|
+
functions: <C>(context: C) => FunctionsForContext<C>;
|
|
17
17
|
};
|
|
18
18
|
/** Helpers pour extensions/InferOptions et définition d'Extension */
|
|
19
19
|
export type InferOptions<T extends ZodType | undefined> = T extends ZodType ? z.infer<T> : undefined;
|
package/package.json
CHANGED