@deessejs/functions 0.0.55 → 0.0.56
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,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.defineContext = defineContext;
|
|
4
4
|
function defineContext() {
|
|
5
5
|
return {
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
6
|
+
// ON UTILISE 'any[]' pour TExtensions.
|
|
7
|
+
// Pourquoi ? Pour que 'TExtensions' capture le type EXACT de 'rpc' (avec son générique).
|
|
8
|
+
// Si on met 'ExtensionBase[]', TS peut simplifier le générique trop tôt.
|
|
9
9
|
withExtensions: (config) => {
|
|
10
10
|
const runtimeBuilder = {};
|
|
11
11
|
const dummyContext = {};
|
|
12
12
|
for (const extension of config.extensions) {
|
|
13
|
-
// Cast runtime
|
|
13
|
+
// Cast simple pour le runtime
|
|
14
14
|
const ext = extension;
|
|
15
15
|
if (ext && typeof ext.functions === 'function') {
|
|
16
16
|
const extensionMethods = ext.functions(dummyContext);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import z, { ZodType } from "zod";
|
|
2
|
-
type ApplyContext<F, C> =
|
|
2
|
+
type ApplyContext<F, C> = ReturnType<F & ((context: C) => unknown)>;
|
|
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
|
-
} ? ApplyContext<F, TContext> : {}) & MergeExtensions<TContext, Tail> : {};
|
|
5
|
+
} ? F extends (c: any) => any ? ApplyContext<F, TContext> : {} : {}) & MergeExtensions<TContext, Tail> : {};
|
|
6
6
|
export type ExtensionBase = {
|
|
7
7
|
context: any;
|
|
8
8
|
functions: (context: any) => any;
|
package/package.json
CHANGED