@deessejs/functions 0.0.29 → 0.0.30

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.
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
- // src/context/index.ts (ou defineContext.ts)
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.defineContext = defineContext;
5
4
  function defineContext() {
6
5
  return {
6
+ // L'utilisation de `const` (si TS 5.0+) ou juste le pattern [...TExtensions]
7
+ // force TS à regarder chaque extension individuellement au lieu de généraliser le tableau.
7
8
  withExtensions: (config) => {
8
9
  const builder = {};
9
10
  const dummyContext = {};
10
11
  for (const extension of config.extensions) {
11
- // extension.functions est maintenant 'any' au niveau du type,
12
- // mais au runtime c'est bien la fonction.
13
12
  const extensionMethods = extension.functions(dummyContext);
14
13
  Object.assign(builder, extensionMethods);
15
14
  }
@@ -6,8 +6,11 @@ exports.rpc = (0, _1.extensions)({
6
6
  name: "rpc",
7
7
  schema: undefined,
8
8
  context: undefined,
9
- // La fonction accepte N'IMPORTE QUEL TContext.
10
- // C'est ApplyContext qui se chargera d'injecter le bon type (celui de defineContext).
9
+ // CORRECTION : On remet la contrainte Record<string, any>.
10
+ // Grâce à la correction de l'étape 1, cela passera.
11
+ // Si votre TContext (dans defineContext) n'a pas d'index signature,
12
+ // TypeScript pourrait râler. Dans ce cas, retirez simplement 'extends Record...'
13
+ // et gardez juste <TContext>. Le plus sûr est sans contrainte :
11
14
  functions: (_options) => (context) => ({
12
15
  query: (options) => {
13
16
  return { _type: "query", ...options };
@@ -4,7 +4,7 @@ export type InferOptions<T extends ZodType | undefined> = T extends ZodType ? z.
4
4
  type ApplyContext<TFunc, TContext> = TFunc extends (context: TContext) => infer R ? R : never;
5
5
  export type ExtensionInstance = {
6
6
  context: any;
7
- functions: any;
7
+ functions: (context: any) => any;
8
8
  };
9
9
  export type MergeExtensions<TContext, TExtensions extends Array<ExtensionInstance>> = UnionToIntersection<ApplyContext<TExtensions[number]["functions"], TContext>>;
10
10
  export type ExtensionConfig<TSchema extends ZodType | undefined, TContextAddon extends Record<string, unknown>> = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deessejs/functions",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "description": "A powerful utility library for building type-safe APIs and functions with context management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",