@deessejs/functions 0.0.33 → 0.0.34

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.
@@ -7,7 +7,6 @@ function defineContext() {
7
7
  const builder = {};
8
8
  const dummyContext = {};
9
9
  for (const extension of config.extensions) {
10
- // runtime : on appelle la factory avec le contexte (dummy)
11
10
  const extensionMethods = extension.functions(dummyContext);
12
11
  Object.assign(builder, extensionMethods);
13
12
  }
@@ -4,11 +4,11 @@ export type ExtensionBase = {
4
4
  context: any;
5
5
  functions: (context: any) => any;
6
6
  };
7
- export type MergeExtensions<TContext, TExtensions extends readonly any[]> = TExtensions extends readonly [infer Head, ...infer Tail] ? (Head extends {
8
- functions: (context: TContext) => infer R;
9
- } ? R : Head extends {
10
- functions: (context: any) => infer R;
11
- } ? R : {}) & MergeExtensions<TContext, Tail> : {};
7
+ type ExtractFunctionsReturn<F, C> = F extends (context: C) => infer R ? R : F extends (context: any) => infer R ? R : never;
8
+ export type MergeExtensions<TContext, TExtensions extends readonly any[]> = TExtensions extends readonly [infer Head, ...infer Tail] ? // On récupère 'functions' du Head (s'il existe) et on l'instancie avec TContext
9
+ (Head extends {
10
+ functions: infer F;
11
+ } ? ExtractFunctionsReturn<F, TContext> : {}) & MergeExtensions<TContext, Tail> : {};
12
12
  export type ExtensionConfig<TSchema extends ZodType | undefined, TContextAddon extends Record<string, unknown>> = {
13
13
  name: string;
14
14
  schema?: TSchema;
@@ -19,3 +19,4 @@ export type Extension<TSchema extends ZodType | undefined, TContextAddon extends
19
19
  context: TContextAddon;
20
20
  functions: TFunctionsFactory;
21
21
  };
22
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deessejs/functions",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
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",