@deessejs/functions 0.0.39 → 0.0.41
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 +10 -19
- package/dist/extensions/rpc.d.ts +1 -1
- package/dist/extensions/rpc.js +2 -2
- package/package.json +1 -1
package/dist/context/define.js
CHANGED
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// defineContext.ts
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.defineContext = defineContext;
|
|
5
4
|
function defineContext() {
|
|
6
5
|
return {
|
|
7
6
|
withExtensions: (config) => {
|
|
8
|
-
// runtime
|
|
9
|
-
const runtimeBuilder = {};
|
|
10
|
-
// Utiliser un contexte runtime vide, mais conserver le type complet
|
|
7
|
+
// Créer un contexte runtime vide mais avec le type complet
|
|
11
8
|
const runtimeContext = {};
|
|
9
|
+
// Appliquer les extensions en préservant les types
|
|
10
|
+
const result = {
|
|
11
|
+
context: runtimeContext,
|
|
12
|
+
};
|
|
12
13
|
for (const extension of config.extensions) {
|
|
13
|
-
//
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
// Forcer TypeScript à voir functions comme une fonction qui retourne une fonction
|
|
15
|
+
const methodsFactory = extension.functions(undefined);
|
|
16
|
+
const methods = methodsFactory(runtimeContext);
|
|
17
|
+
Object.assign(result, methods);
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
const contextProxy = new Proxy({}, {
|
|
19
|
-
get(_, prop) {
|
|
20
|
-
// Retourner undefined pour les propriétés inconnues, mais préserver le type
|
|
21
|
-
return runtimeContext[prop];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
// On retourne runtimeBuilder avec un contexte qui préserve les types
|
|
25
|
-
return {
|
|
26
|
-
...runtimeBuilder,
|
|
27
|
-
context: contextProxy,
|
|
28
|
-
};
|
|
19
|
+
return result;
|
|
29
20
|
},
|
|
30
21
|
};
|
|
31
22
|
}
|
package/dist/extensions/rpc.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ 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
|
-
|
|
19
|
+
_contextType: C;
|
|
20
20
|
}>;
|
package/dist/extensions/rpc.js
CHANGED
|
@@ -15,7 +15,7 @@ exports.rpc = (0, _1.extensions)({
|
|
|
15
15
|
return { _type: "mutation", ...options };
|
|
16
16
|
},
|
|
17
17
|
group: (definitions) => definitions,
|
|
18
|
-
//
|
|
19
|
-
|
|
18
|
+
// Exposer le type de contexte pour l'inférence
|
|
19
|
+
_contextType: context,
|
|
20
20
|
}),
|
|
21
21
|
});
|
package/package.json
CHANGED