@deessejs/functions 0.0.37 → 0.0.38

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.
@@ -13,3 +13,12 @@ export type MutationDefinition<TContext, TArgs extends ZodType, TOutput, TError
13
13
  _type: "mutation";
14
14
  };
15
15
  export type CommandsDefinition = QueryDefinition<any, any, any, any> | MutationDefinition<any, any, any, any>;
16
+ export type FunctionsForContext<C> = {
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
+ on?: <TEvent extends string, TPayload>(config: {
20
+ event: TEvent;
21
+ handler: (ctx: C, payload: TPayload) => AsyncResult<any, any>;
22
+ }) => any;
23
+ group?: <TGroup extends Record<string, CommandsDefinition>>(defs: TGroup) => any;
24
+ };
@@ -1,6 +1,7 @@
1
1
  import { ZodType } from "zod";
2
2
  import { Extension, InferOptions } from "./types";
3
- export declare function extensions<TSchema extends ZodType | undefined = undefined, TContextAddon extends Record<string, unknown> = Record<string, unknown>, TFunctionsFactory extends (<C>(context: C) => any) = (<C>(context: C) => any)>(config: {
3
+ import { FunctionsForContext } from "../context";
4
+ export declare function extensions<TSchema extends ZodType | undefined = undefined, TContextAddon extends Record<string, unknown> = Record<string, unknown>, TFunctionsFactory extends (<C>(context: C) => FunctionsForContext<C>) = (<C>(context: C) => FunctionsForContext<C>)>(config: {
4
5
  name: string;
5
6
  schema?: TSchema;
6
7
  context?: (options: InferOptions<TSchema>) => TContextAddon;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // extensions/index.ts (ou extensions.ts)
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.extensions = extensions;
4
5
  function extensions(config) {
@@ -1,4 +1,5 @@
1
1
  import z, { ZodType } from "zod";
2
+ import { FunctionsForContext } from "../context";
2
3
  /** Utilitaire d'inférence d'appel générique (déjà présent chez toi) */
3
4
  type FnCallSignatureMatchesWith<C, F> = F extends {
4
5
  (context: C): infer R;
@@ -12,7 +13,7 @@ export type MergeExtensions<TContext, TExtensions extends readonly any[]> = TExt
12
13
  /** Ici : functions est *explicitement* une call signature générique */
13
14
  export type ExtensionBase = {
14
15
  context: any;
15
- functions: <C>(context: C) => any;
16
+ functions: <C>(context: C) => FunctionsForContext<C>;
16
17
  };
17
18
  /** Helpers pour extensions/InferOptions et définition d'Extension */
18
19
  export type InferOptions<T extends ZodType | undefined> = T extends ZodType ? z.infer<T> : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deessejs/functions",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
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",