vovk 3.0.0-draft.252 → 3.0.0-draft.255

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.
@@ -31,7 +31,8 @@ const assignSchema = ({ controller, propertyKey, path, options, httpMethod, vovk
31
31
  originalMethod._sourceMethod = originalMethod._sourceMethod ?? originalMethod;
32
32
  const schema = originalMethod._sourceMethod._getSchema?.(controller);
33
33
  originalMethod.schema = schema;
34
- originalMethod.func = originalMethod._sourceMethod?.func;
34
+ originalMethod.fn = originalMethod._sourceMethod?.fn;
35
+ originalMethod.models = originalMethod._sourceMethod?.models;
35
36
  controller._handlers = {
36
37
  ...controller._handlers,
37
38
  [propertyKey]: {
package/cjs/types.d.ts CHANGED
@@ -220,10 +220,17 @@ export interface VovkLLMTool {
220
220
  name: string;
221
221
  description: string;
222
222
  parameters?: {
223
- type: string;
224
- properties: Record<string, KnownAny>;
225
- required: string[];
226
- additionalProperties: boolean;
223
+ type: 'object';
224
+ properties?: Record<string, KnownAny>;
225
+ required?: string[];
226
+ additionalProperties?: boolean;
227
+ };
228
+ models?: {
229
+ body?: KnownAny;
230
+ query?: KnownAny;
231
+ params?: KnownAny;
232
+ output?: KnownAny;
233
+ iteration?: KnownAny;
227
234
  };
228
235
  type: 'function';
229
236
  }
@@ -3,6 +3,13 @@ type Handler = ((...args: KnownAny[]) => KnownAny) & {
3
3
  fn?: (input: KnownAny) => KnownAny;
4
4
  isRPC?: boolean;
5
5
  schema?: VovkHandlerSchema;
6
+ models?: {
7
+ body?: KnownAny;
8
+ query?: KnownAny;
9
+ params?: KnownAny;
10
+ output?: KnownAny;
11
+ iteration?: KnownAny;
12
+ };
6
13
  };
7
14
  type CallerInput = {
8
15
  handler: Handler;
@@ -10,6 +17,13 @@ type CallerInput = {
10
17
  query: KnownAny;
11
18
  params: KnownAny;
12
19
  schema: VovkHandlerSchema;
20
+ models: {
21
+ body?: KnownAny;
22
+ query?: KnownAny;
23
+ params?: KnownAny;
24
+ output?: KnownAny;
25
+ iteration?: KnownAny;
26
+ } | undefined;
13
27
  init?: RequestInit;
14
28
  meta?: Record<string, KnownAny>;
15
29
  handlerName: string;
@@ -9,7 +9,7 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
9
9
  if (!handler) {
10
10
  throw new Error(`Handler "${handlerName}" not found in module "${moduleName}".`);
11
11
  }
12
- const { schema } = handler;
12
+ const { schema, models } = handler;
13
13
  if (!schema || !schema.openapi) {
14
14
  throw new Error(`Handler "${handlerName}" in module "${moduleName}" does not have a valid schema.`);
15
15
  }
@@ -17,6 +17,7 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
17
17
  const { body, query, params } = input;
18
18
  const callerInput = {
19
19
  schema,
20
+ models,
20
21
  handler,
21
22
  body,
22
23
  query,
@@ -51,17 +52,17 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
51
52
  type: 'function',
52
53
  execute,
53
54
  name: `${moduleName}__${handlerName}`,
54
- description: [schema.openapi?.summary ?? '', schema.openapi?.description ?? ''].filter(Boolean).join('\n') || handlerName,
55
- ...(Object.keys(parametersProperties).length
55
+ description: schema.openapi?.['x-tool-description'] ??
56
+ ([schema.openapi?.summary ?? '', schema.openapi?.description ?? ''].filter(Boolean).join('\n') || handlerName),
57
+ parameters: Object.keys(parametersProperties).length
56
58
  ? {
57
- parameters: {
58
- type: 'object',
59
- properties: parametersProperties,
60
- required: Object.keys(parametersProperties),
61
- additionalProperties: false,
62
- },
59
+ type: 'object',
60
+ properties: parametersProperties,
61
+ required: Object.keys(parametersProperties),
62
+ additionalProperties: false,
63
63
  }
64
- : {}),
64
+ : { type: 'object' },
65
+ models,
65
66
  };
66
67
  };
67
68
  async function defaultCaller({ handler, body, query, params, init },
@@ -25,6 +25,13 @@ export declare function withStandard<T extends (req: REQ, params: PARAMS extends
25
25
  isRPC?: boolean;
26
26
  } & {
27
27
  schema: import("../types").VovkHandlerSchema;
28
+ models: {
29
+ body?: BODY | undefined;
30
+ query?: QUERY | undefined;
31
+ params?: PARAMS | undefined;
32
+ output?: OUTPUT | undefined;
33
+ iteration?: ITERATION | undefined;
34
+ };
28
35
  } & {
29
36
  fn: {
30
37
  <RETURN_TYPE = ReturnType<VovkTypedMethod<T, BODY extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<BODY> : any, QUERY extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<QUERY> : any, PARAMS extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<PARAMS> : any, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM extends true ? true : any>>>(input?: ((undefined extends BODY | undefined ? undefined extends QUERY | undefined ? undefined extends PARAMS | undefined ? true : false : false : false) extends true ? {
@@ -26,6 +26,13 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
26
26
  }) => KnownAny;
27
27
  }): T & {
28
28
  schema: VovkHandlerSchema;
29
+ models: {
30
+ body?: BODY_MODEL;
31
+ query?: QUERY_MODEL;
32
+ params?: PARAMS_MODEL;
33
+ output?: OUTPUT_MODEL;
34
+ iteration?: ITERATION_MODEL;
35
+ };
29
36
  } & {
30
37
  fn: {
31
38
  <RETURN_TYPE = ReturnType<T>>(input?: (undefined extends BODY_MODEL | undefined ? undefined extends QUERY_MODEL | undefined ? undefined extends PARAMS_MODEL | undefined ? true : false : false : false) extends true ? {
@@ -31,7 +31,8 @@ const assignSchema = ({ controller, propertyKey, path, options, httpMethod, vovk
31
31
  originalMethod._sourceMethod = originalMethod._sourceMethod ?? originalMethod;
32
32
  const schema = originalMethod._sourceMethod._getSchema?.(controller);
33
33
  originalMethod.schema = schema;
34
- originalMethod.func = originalMethod._sourceMethod?.func;
34
+ originalMethod.fn = originalMethod._sourceMethod?.fn;
35
+ originalMethod.models = originalMethod._sourceMethod?.models;
35
36
  controller._handlers = {
36
37
  ...controller._handlers,
37
38
  [propertyKey]: {
package/mjs/types.d.ts CHANGED
@@ -220,10 +220,17 @@ export interface VovkLLMTool {
220
220
  name: string;
221
221
  description: string;
222
222
  parameters?: {
223
- type: string;
224
- properties: Record<string, KnownAny>;
225
- required: string[];
226
- additionalProperties: boolean;
223
+ type: 'object';
224
+ properties?: Record<string, KnownAny>;
225
+ required?: string[];
226
+ additionalProperties?: boolean;
227
+ };
228
+ models?: {
229
+ body?: KnownAny;
230
+ query?: KnownAny;
231
+ params?: KnownAny;
232
+ output?: KnownAny;
233
+ iteration?: KnownAny;
227
234
  };
228
235
  type: 'function';
229
236
  }
@@ -3,6 +3,13 @@ type Handler = ((...args: KnownAny[]) => KnownAny) & {
3
3
  fn?: (input: KnownAny) => KnownAny;
4
4
  isRPC?: boolean;
5
5
  schema?: VovkHandlerSchema;
6
+ models?: {
7
+ body?: KnownAny;
8
+ query?: KnownAny;
9
+ params?: KnownAny;
10
+ output?: KnownAny;
11
+ iteration?: KnownAny;
12
+ };
6
13
  };
7
14
  type CallerInput = {
8
15
  handler: Handler;
@@ -10,6 +17,13 @@ type CallerInput = {
10
17
  query: KnownAny;
11
18
  params: KnownAny;
12
19
  schema: VovkHandlerSchema;
20
+ models: {
21
+ body?: KnownAny;
22
+ query?: KnownAny;
23
+ params?: KnownAny;
24
+ output?: KnownAny;
25
+ iteration?: KnownAny;
26
+ } | undefined;
13
27
  init?: RequestInit;
14
28
  meta?: Record<string, KnownAny>;
15
29
  handlerName: string;
@@ -9,7 +9,7 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
9
9
  if (!handler) {
10
10
  throw new Error(`Handler "${handlerName}" not found in module "${moduleName}".`);
11
11
  }
12
- const { schema } = handler;
12
+ const { schema, models } = handler;
13
13
  if (!schema || !schema.openapi) {
14
14
  throw new Error(`Handler "${handlerName}" in module "${moduleName}" does not have a valid schema.`);
15
15
  }
@@ -17,6 +17,7 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
17
17
  const { body, query, params } = input;
18
18
  const callerInput = {
19
19
  schema,
20
+ models,
20
21
  handler,
21
22
  body,
22
23
  query,
@@ -51,17 +52,17 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
51
52
  type: 'function',
52
53
  execute,
53
54
  name: `${moduleName}__${handlerName}`,
54
- description: [schema.openapi?.summary ?? '', schema.openapi?.description ?? ''].filter(Boolean).join('\n') || handlerName,
55
- ...(Object.keys(parametersProperties).length
55
+ description: schema.openapi?.['x-tool-description'] ??
56
+ ([schema.openapi?.summary ?? '', schema.openapi?.description ?? ''].filter(Boolean).join('\n') || handlerName),
57
+ parameters: Object.keys(parametersProperties).length
56
58
  ? {
57
- parameters: {
58
- type: 'object',
59
- properties: parametersProperties,
60
- required: Object.keys(parametersProperties),
61
- additionalProperties: false,
62
- },
59
+ type: 'object',
60
+ properties: parametersProperties,
61
+ required: Object.keys(parametersProperties),
62
+ additionalProperties: false,
63
63
  }
64
- : {}),
64
+ : { type: 'object' },
65
+ models,
65
66
  };
66
67
  };
67
68
  async function defaultCaller({ handler, body, query, params, init },
@@ -25,6 +25,13 @@ export declare function withStandard<T extends (req: REQ, params: PARAMS extends
25
25
  isRPC?: boolean;
26
26
  } & {
27
27
  schema: import("../types").VovkHandlerSchema;
28
+ models: {
29
+ body?: BODY | undefined;
30
+ query?: QUERY | undefined;
31
+ params?: PARAMS | undefined;
32
+ output?: OUTPUT | undefined;
33
+ iteration?: ITERATION | undefined;
34
+ };
28
35
  } & {
29
36
  fn: {
30
37
  <RETURN_TYPE = ReturnType<VovkTypedMethod<T, BODY extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<BODY> : any, QUERY extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<QUERY> : any, PARAMS extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<PARAMS> : any, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM extends true ? true : any>>>(input?: ((undefined extends BODY | undefined ? undefined extends QUERY | undefined ? undefined extends PARAMS | undefined ? true : false : false : false) extends true ? {
@@ -26,6 +26,13 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
26
26
  }) => KnownAny;
27
27
  }): T & {
28
28
  schema: VovkHandlerSchema;
29
+ models: {
30
+ body?: BODY_MODEL;
31
+ query?: QUERY_MODEL;
32
+ params?: PARAMS_MODEL;
33
+ output?: OUTPUT_MODEL;
34
+ iteration?: ITERATION_MODEL;
35
+ };
29
36
  } & {
30
37
  fn: {
31
38
  <RETURN_TYPE = ReturnType<T>>(input?: (undefined extends BODY_MODEL | undefined ? undefined extends QUERY_MODEL | undefined ? undefined extends PARAMS_MODEL | undefined ? true : false : false : false) extends true ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.252",
3
+ "version": "3.0.0-draft.255",
4
4
  "main": "./cjs/index.js",
5
5
  "module": "./mjs/index.js",
6
6
  "types": "./mjs/index.d.ts",