vovk 3.0.0-draft.248 → 3.0.0-draft.250

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/cjs/VovkApp.js CHANGED
@@ -123,6 +123,11 @@ class VovkApp {
123
123
  const controllers = this.routes[httpMethod];
124
124
  const path = params[Object.keys(params)[0]];
125
125
  const handlers = {};
126
+ const headersList = await (0, headers_1.headers)();
127
+ const xMeta = headersList.get('x-meta');
128
+ const meta = xMeta ? JSON.parse(xMeta) : {};
129
+ if (meta)
130
+ (0, reqMeta_1.default)(req, meta);
126
131
  controllers.forEach((staticMethods, controller) => {
127
132
  const prefix = controller._prefix ?? '';
128
133
  Object.entries(staticMethods ?? {}).forEach(([path, staticMethod]) => {
@@ -152,7 +157,7 @@ class VovkApp {
152
157
  (Reflect.has(result, Symbol.asyncIterator) &&
153
158
  typeof result[Symbol.asyncIterator] === 'function'));
154
159
  if (isIterator && !(result instanceof Array)) {
155
- const streamResponse = new JSONLinesResponse_1.JSONLinesResponse(await (0, headers_1.headers)(), {
160
+ const streamResponse = new JSONLinesResponse_1.JSONLinesResponse(headersList, {
156
161
  headers: {
157
162
  ..._a.getHeadersFromOptions(staticMethod._options),
158
163
  },
@@ -68,6 +68,7 @@ const createRPC = (schema, segmentName, rpcModuleName, fetcher = fetcher_1.fetch
68
68
  body: input.body ?? null,
69
69
  query: input.query ?? {},
70
70
  params: input.params ?? {},
71
+ meta: input.meta,
71
72
  };
72
73
  if (!fetcher)
73
74
  throw new Error('Fetcher is not provided');
@@ -9,14 +9,12 @@ const defaultHandler = async (response) => {
9
9
  result = await response.json();
10
10
  }
11
11
  catch (e) {
12
- console.log('ERROR', e);
13
12
  // handle parsing errors
14
13
  throw new HttpException_1.HttpException(response.status, e?.message ?? exports.DEFAULT_ERROR_MESSAGE);
15
14
  }
16
15
  if (!response.ok) {
17
16
  // handle server errors
18
17
  const errorResponse = result;
19
- console.log('errorResponse', errorResponse);
20
18
  throw new HttpException_1.HttpException(response.status, errorResponse?.message ?? exports.DEFAULT_ERROR_MESSAGE, errorResponse?.cause ?? errorResponse);
21
19
  }
22
20
  return result;
@@ -9,7 +9,7 @@ function createFetcher({ prepareRequestInit, transformResponse, } = {}) {
9
9
  // fetcher uses HttpException class to throw errors of fake HTTP status 0 if client-side error occurs
10
10
  // For normal HTTP errors, it uses message and status code from the response of VovkErrorResponse type
11
11
  const newFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandler, defaultStreamHandler }, options) => {
12
- const { params, query, body, apiRoot, disableClientValidation, init, interpretAs } = options;
12
+ const { params, query, body, meta, apiRoot, disableClientValidation, init, interpretAs } = options;
13
13
  const endpoint = getEndpoint({ apiRoot, params, query });
14
14
  const unusedParams = Array.from(new URL(endpoint.startsWith('/') ? `http://localhost${endpoint}` : endpoint).pathname.matchAll(/\{([^}]+)\}/g)).map((m) => m[1]);
15
15
  if (unusedParams.length) {
@@ -43,6 +43,7 @@ function createFetcher({ prepareRequestInit, transformResponse, } = {}) {
43
43
  headers: {
44
44
  accept: 'application/jsonl, application/json',
45
45
  ...(body instanceof FormData ? {} : { 'content-type': 'application/json' }),
46
+ ...(meta ? { 'x-meta': JSON.stringify(meta) } : {}),
46
47
  ...init?.headers,
47
48
  },
48
49
  };
@@ -56,7 +57,6 @@ function createFetcher({ prepareRequestInit, transformResponse, } = {}) {
56
57
  ? ((await prepareRequestInit(requestInit, options)) ?? requestInit)
57
58
  : requestInit;
58
59
  let response;
59
- console.log('endpoint, requestInit', endpoint, requestInit);
60
60
  try {
61
61
  response = await fetch(endpoint, requestInit);
62
62
  }
@@ -15,7 +15,11 @@ export type StaticMethodInput<T extends ((req: VovkRequest<KnownAny, KnownAny, K
15
15
  query: QUERY;
16
16
  } : Empty) & (PARAMS extends Record<KnownAny, KnownAny> ? {
17
17
  params: PARAMS;
18
- } : Empty) : Empty) & (Parameters<T>[1] extends Record<KnownAny, KnownAny> ? {
18
+ } : Empty) & {
19
+ meta?: {
20
+ [key: string]: KnownAny;
21
+ };
22
+ } : Empty) & (Parameters<T>[1] extends Record<KnownAny, KnownAny> ? {
19
23
  params: Parameters<T>[1];
20
24
  } : Empty)>;
21
25
  type ToPromise<T> = T extends PromiseLike<unknown> ? T : Promise<T>;
@@ -89,6 +93,9 @@ export type VovkClientFetcher<OPTS> = (options: {
89
93
  params: {
90
94
  [key: string]: string;
91
95
  };
96
+ meta?: {
97
+ [key: string]: KnownAny;
98
+ };
92
99
  } & OPTS) => Promise<[KnownAny, Response]>;
93
100
  export type VovkDefaultFetcherOptions<T> = T & {
94
101
  apiRoot?: string;
@@ -11,6 +11,7 @@ type CallerInput = {
11
11
  params: KnownAny;
12
12
  schema: VovkHandlerSchema;
13
13
  init?: RequestInit;
14
+ meta?: Record<string, KnownAny>;
14
15
  handlerName: string;
15
16
  moduleName: string;
16
17
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createLLMTools = createLLMTools;
4
- const createLLMTool = ({ moduleName, handlerName, caller, module, init, onExecute, onError, }) => {
4
+ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, onExecute, onError, }) => {
5
5
  if (!module) {
6
6
  throw new Error(`Module "${moduleName}" not found.`);
7
7
  }
@@ -22,6 +22,7 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, onExecut
22
22
  query,
23
23
  params,
24
24
  init,
25
+ meta,
25
26
  handlerName,
26
27
  moduleName,
27
28
  };
@@ -41,7 +41,12 @@ export declare function withStandard<T extends (req: REQ, params: PARAMS extends
41
41
  params?: 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>["__types"]["params"] | undefined;
42
42
  } : {
43
43
  params: 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>["__types"]["params"];
44
- }) : never) | undefined): (undefined extends BODY | undefined ? undefined extends QUERY | undefined ? undefined extends PARAMS | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
44
+ }) & {
45
+ meta?: {
46
+ [key: string]: any;
47
+ __disableClientValidation?: boolean;
48
+ };
49
+ } : never) | undefined): (undefined extends BODY | undefined ? undefined extends QUERY | undefined ? undefined extends PARAMS | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
45
50
  <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: {
46
51
  disableClientValidation?: boolean;
47
52
  } & (undefined extends BODY | undefined ? {
@@ -56,7 +61,12 @@ export declare function withStandard<T extends (req: REQ, params: PARAMS extends
56
61
  params?: 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>["__types"]["params"] | undefined;
57
62
  } : {
58
63
  params: 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>["__types"]["params"];
59
- })): RETURN_TYPE;
64
+ }) & {
65
+ meta?: {
66
+ [key: string]: any;
67
+ __disableClientValidation?: boolean;
68
+ };
69
+ }): RETURN_TYPE;
60
70
  };
61
71
  models: {
62
72
  body: BODY | undefined;
@@ -1,5 +1,9 @@
1
1
  import { VovkHandlerSchema, VovkTypedMethod, VovkValidationType, type KnownAny, type VovkRequest } from '../types';
2
2
  type VovkRequestAny = VovkRequest<KnownAny, KnownAny, KnownAny>;
3
+ type Meta = {
4
+ __disableClientValidation?: boolean;
5
+ [key: string]: KnownAny;
6
+ };
3
7
  export declare function withValidationLibrary<T extends VovkTypedMethod<(req: KnownAny, params: KnownAny) => KnownAny>, BODY_MODEL, QUERY_MODEL, PARAMS_MODEL, OUTPUT_MODEL, ITERATION_MODEL, IS_FORM extends boolean = false>({ isForm, disableServerSideValidation, skipSchemaEmission, validateEachIteration, body, query, params, output, iteration, handle, toJSONSchema, validate, }: {
4
8
  isForm?: IS_FORM;
5
9
  disableServerSideValidation?: boolean | VovkValidationType[];
@@ -38,7 +42,9 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
38
42
  params?: T["__types"]["params"];
39
43
  } : {
40
44
  params: T["__types"]["params"];
41
- }) : never): (undefined extends BODY_MODEL | undefined ? undefined extends QUERY_MODEL | undefined ? undefined extends PARAMS_MODEL | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
45
+ }) & {
46
+ meta?: Meta;
47
+ } : never): (undefined extends BODY_MODEL | undefined ? undefined extends QUERY_MODEL | undefined ? undefined extends PARAMS_MODEL | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
42
48
  <RETURN_TYPE = ReturnType<T>>(input: {
43
49
  disableClientValidation?: boolean;
44
50
  } & (undefined extends BODY_MODEL | undefined ? {
@@ -53,7 +59,9 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
53
59
  params?: T["__types"]["params"];
54
60
  } : {
55
61
  params: T["__types"]["params"];
56
- })): RETURN_TYPE;
62
+ }) & {
63
+ meta?: Meta;
64
+ }): RETURN_TYPE;
57
65
  };
58
66
  models: {
59
67
  body: BODY_MODEL | undefined;
@@ -88,7 +88,7 @@ function withValidationLibrary({ isForm, disableServerSideValidation, skipSchema
88
88
  },
89
89
  },
90
90
  };
91
- fakeReq.vovk.meta({ __disableClientValidation: input?.disableClientValidation });
91
+ fakeReq.vovk.meta({ __disableClientValidation: input?.disableClientValidation, ...(input?.meta ?? {}) });
92
92
  return resultHandler(fakeReq, (input?.params ?? {}));
93
93
  }
94
94
  const models = {
package/mjs/VovkApp.js CHANGED
@@ -123,6 +123,11 @@ class VovkApp {
123
123
  const controllers = this.routes[httpMethod];
124
124
  const path = params[Object.keys(params)[0]];
125
125
  const handlers = {};
126
+ const headersList = await (0, headers_1.headers)();
127
+ const xMeta = headersList.get('x-meta');
128
+ const meta = xMeta ? JSON.parse(xMeta) : {};
129
+ if (meta)
130
+ (0, reqMeta_1.default)(req, meta);
126
131
  controllers.forEach((staticMethods, controller) => {
127
132
  const prefix = controller._prefix ?? '';
128
133
  Object.entries(staticMethods ?? {}).forEach(([path, staticMethod]) => {
@@ -152,7 +157,7 @@ class VovkApp {
152
157
  (Reflect.has(result, Symbol.asyncIterator) &&
153
158
  typeof result[Symbol.asyncIterator] === 'function'));
154
159
  if (isIterator && !(result instanceof Array)) {
155
- const streamResponse = new JSONLinesResponse_1.JSONLinesResponse(await (0, headers_1.headers)(), {
160
+ const streamResponse = new JSONLinesResponse_1.JSONLinesResponse(headersList, {
156
161
  headers: {
157
162
  ..._a.getHeadersFromOptions(staticMethod._options),
158
163
  },
@@ -68,6 +68,7 @@ const createRPC = (schema, segmentName, rpcModuleName, fetcher = fetcher_1.fetch
68
68
  body: input.body ?? null,
69
69
  query: input.query ?? {},
70
70
  params: input.params ?? {},
71
+ meta: input.meta,
71
72
  };
72
73
  if (!fetcher)
73
74
  throw new Error('Fetcher is not provided');
@@ -9,14 +9,12 @@ const defaultHandler = async (response) => {
9
9
  result = await response.json();
10
10
  }
11
11
  catch (e) {
12
- console.log('ERROR', e);
13
12
  // handle parsing errors
14
13
  throw new HttpException_1.HttpException(response.status, e?.message ?? exports.DEFAULT_ERROR_MESSAGE);
15
14
  }
16
15
  if (!response.ok) {
17
16
  // handle server errors
18
17
  const errorResponse = result;
19
- console.log('errorResponse', errorResponse);
20
18
  throw new HttpException_1.HttpException(response.status, errorResponse?.message ?? exports.DEFAULT_ERROR_MESSAGE, errorResponse?.cause ?? errorResponse);
21
19
  }
22
20
  return result;
@@ -9,7 +9,7 @@ function createFetcher({ prepareRequestInit, transformResponse, } = {}) {
9
9
  // fetcher uses HttpException class to throw errors of fake HTTP status 0 if client-side error occurs
10
10
  // For normal HTTP errors, it uses message and status code from the response of VovkErrorResponse type
11
11
  const newFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandler, defaultStreamHandler }, options) => {
12
- const { params, query, body, apiRoot, disableClientValidation, init, interpretAs } = options;
12
+ const { params, query, body, meta, apiRoot, disableClientValidation, init, interpretAs } = options;
13
13
  const endpoint = getEndpoint({ apiRoot, params, query });
14
14
  const unusedParams = Array.from(new URL(endpoint.startsWith('/') ? `http://localhost${endpoint}` : endpoint).pathname.matchAll(/\{([^}]+)\}/g)).map((m) => m[1]);
15
15
  if (unusedParams.length) {
@@ -43,6 +43,7 @@ function createFetcher({ prepareRequestInit, transformResponse, } = {}) {
43
43
  headers: {
44
44
  accept: 'application/jsonl, application/json',
45
45
  ...(body instanceof FormData ? {} : { 'content-type': 'application/json' }),
46
+ ...(meta ? { 'x-meta': JSON.stringify(meta) } : {}),
46
47
  ...init?.headers,
47
48
  },
48
49
  };
@@ -56,7 +57,6 @@ function createFetcher({ prepareRequestInit, transformResponse, } = {}) {
56
57
  ? ((await prepareRequestInit(requestInit, options)) ?? requestInit)
57
58
  : requestInit;
58
59
  let response;
59
- console.log('endpoint, requestInit', endpoint, requestInit);
60
60
  try {
61
61
  response = await fetch(endpoint, requestInit);
62
62
  }
@@ -15,7 +15,11 @@ export type StaticMethodInput<T extends ((req: VovkRequest<KnownAny, KnownAny, K
15
15
  query: QUERY;
16
16
  } : Empty) & (PARAMS extends Record<KnownAny, KnownAny> ? {
17
17
  params: PARAMS;
18
- } : Empty) : Empty) & (Parameters<T>[1] extends Record<KnownAny, KnownAny> ? {
18
+ } : Empty) & {
19
+ meta?: {
20
+ [key: string]: KnownAny;
21
+ };
22
+ } : Empty) & (Parameters<T>[1] extends Record<KnownAny, KnownAny> ? {
19
23
  params: Parameters<T>[1];
20
24
  } : Empty)>;
21
25
  type ToPromise<T> = T extends PromiseLike<unknown> ? T : Promise<T>;
@@ -89,6 +93,9 @@ export type VovkClientFetcher<OPTS> = (options: {
89
93
  params: {
90
94
  [key: string]: string;
91
95
  };
96
+ meta?: {
97
+ [key: string]: KnownAny;
98
+ };
92
99
  } & OPTS) => Promise<[KnownAny, Response]>;
93
100
  export type VovkDefaultFetcherOptions<T> = T & {
94
101
  apiRoot?: string;
@@ -11,6 +11,7 @@ type CallerInput = {
11
11
  params: KnownAny;
12
12
  schema: VovkHandlerSchema;
13
13
  init?: RequestInit;
14
+ meta?: Record<string, KnownAny>;
14
15
  handlerName: string;
15
16
  moduleName: string;
16
17
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createLLMTools = createLLMTools;
4
- const createLLMTool = ({ moduleName, handlerName, caller, module, init, onExecute, onError, }) => {
4
+ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, onExecute, onError, }) => {
5
5
  if (!module) {
6
6
  throw new Error(`Module "${moduleName}" not found.`);
7
7
  }
@@ -22,6 +22,7 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, onExecut
22
22
  query,
23
23
  params,
24
24
  init,
25
+ meta,
25
26
  handlerName,
26
27
  moduleName,
27
28
  };
@@ -41,7 +41,12 @@ export declare function withStandard<T extends (req: REQ, params: PARAMS extends
41
41
  params?: 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>["__types"]["params"] | undefined;
42
42
  } : {
43
43
  params: 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>["__types"]["params"];
44
- }) : never) | undefined): (undefined extends BODY | undefined ? undefined extends QUERY | undefined ? undefined extends PARAMS | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
44
+ }) & {
45
+ meta?: {
46
+ [key: string]: any;
47
+ __disableClientValidation?: boolean;
48
+ };
49
+ } : never) | undefined): (undefined extends BODY | undefined ? undefined extends QUERY | undefined ? undefined extends PARAMS | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
45
50
  <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: {
46
51
  disableClientValidation?: boolean;
47
52
  } & (undefined extends BODY | undefined ? {
@@ -56,7 +61,12 @@ export declare function withStandard<T extends (req: REQ, params: PARAMS extends
56
61
  params?: 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>["__types"]["params"] | undefined;
57
62
  } : {
58
63
  params: 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>["__types"]["params"];
59
- })): RETURN_TYPE;
64
+ }) & {
65
+ meta?: {
66
+ [key: string]: any;
67
+ __disableClientValidation?: boolean;
68
+ };
69
+ }): RETURN_TYPE;
60
70
  };
61
71
  models: {
62
72
  body: BODY | undefined;
@@ -1,5 +1,9 @@
1
1
  import { VovkHandlerSchema, VovkTypedMethod, VovkValidationType, type KnownAny, type VovkRequest } from '../types';
2
2
  type VovkRequestAny = VovkRequest<KnownAny, KnownAny, KnownAny>;
3
+ type Meta = {
4
+ __disableClientValidation?: boolean;
5
+ [key: string]: KnownAny;
6
+ };
3
7
  export declare function withValidationLibrary<T extends VovkTypedMethod<(req: KnownAny, params: KnownAny) => KnownAny>, BODY_MODEL, QUERY_MODEL, PARAMS_MODEL, OUTPUT_MODEL, ITERATION_MODEL, IS_FORM extends boolean = false>({ isForm, disableServerSideValidation, skipSchemaEmission, validateEachIteration, body, query, params, output, iteration, handle, toJSONSchema, validate, }: {
4
8
  isForm?: IS_FORM;
5
9
  disableServerSideValidation?: boolean | VovkValidationType[];
@@ -38,7 +42,9 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
38
42
  params?: T["__types"]["params"];
39
43
  } : {
40
44
  params: T["__types"]["params"];
41
- }) : never): (undefined extends BODY_MODEL | undefined ? undefined extends QUERY_MODEL | undefined ? undefined extends PARAMS_MODEL | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
45
+ }) & {
46
+ meta?: Meta;
47
+ } : never): (undefined extends BODY_MODEL | undefined ? undefined extends QUERY_MODEL | undefined ? undefined extends PARAMS_MODEL | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
42
48
  <RETURN_TYPE = ReturnType<T>>(input: {
43
49
  disableClientValidation?: boolean;
44
50
  } & (undefined extends BODY_MODEL | undefined ? {
@@ -53,7 +59,9 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
53
59
  params?: T["__types"]["params"];
54
60
  } : {
55
61
  params: T["__types"]["params"];
56
- })): RETURN_TYPE;
62
+ }) & {
63
+ meta?: Meta;
64
+ }): RETURN_TYPE;
57
65
  };
58
66
  models: {
59
67
  body: BODY_MODEL | undefined;
@@ -88,7 +88,7 @@ function withValidationLibrary({ isForm, disableServerSideValidation, skipSchema
88
88
  },
89
89
  },
90
90
  };
91
- fakeReq.vovk.meta({ __disableClientValidation: input?.disableClientValidation });
91
+ fakeReq.vovk.meta({ __disableClientValidation: input?.disableClientValidation, ...(input?.meta ?? {}) });
92
92
  return resultHandler(fakeReq, (input?.params ?? {}));
93
93
  }
94
94
  const models = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.248",
3
+ "version": "3.0.0-draft.250",
4
4
  "main": "./cjs/index.js",
5
5
  "module": "./mjs/index.js",
6
6
  "types": "./mjs/index.d.ts",