vovk 3.5.0 → 3.7.0
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/dist/client/create-rpc.d.ts +13 -0
- package/dist/client/create-rpc.js +147 -0
- package/dist/client/default-handler.d.ts +6 -0
- package/dist/client/default-handler.js +25 -0
- package/dist/client/default-stream-handler.d.ts +16 -0
- package/dist/client/default-stream-handler.js +282 -0
- package/dist/client/fetcher.d.ts +1 -1
- package/dist/client/fetcher.js +2 -2
- package/dist/client/serialize-query.d.ts +13 -0
- package/dist/client/serialize-query.js +62 -0
- package/dist/core/apply-decorator-adapter.d.ts +7 -0
- package/dist/core/apply-decorator-adapter.js +50 -0
- package/dist/core/controllers-to-static-params.d.ts +13 -0
- package/dist/core/controllers-to-static-params.js +32 -0
- package/dist/core/create-decorator.d.ts +12 -0
- package/dist/core/create-decorator.js +52 -0
- package/dist/core/decorators.js +4 -4
- package/dist/core/get-schema.d.ts +21 -0
- package/dist/core/get-schema.js +31 -0
- package/dist/core/http-exception.d.ts +16 -0
- package/dist/core/http-exception.js +26 -0
- package/dist/core/init-segment.d.ts +33 -0
- package/dist/core/init-segment.js +62 -0
- package/dist/core/json-lines-responder.d.ts +42 -0
- package/dist/core/json-lines-responder.js +94 -0
- package/dist/core/resolve-generator-config-values.d.ts +19 -0
- package/dist/core/resolve-generator-config-values.js +59 -0
- package/dist/core/set-handler-schema.d.ts +4 -0
- package/dist/core/set-handler-schema.js +12 -0
- package/dist/core/to-download-response.d.ts +11 -0
- package/dist/core/to-download-response.js +25 -0
- package/dist/core/vovk-app.d.ts +36 -0
- package/dist/core/vovk-app.js +318 -0
- package/dist/index.d.ts +10 -10
- package/dist/index.js +10 -10
- package/dist/internal.d.ts +10 -10
- package/dist/internal.js +9 -9
- package/dist/openapi/error.js +1 -1
- package/dist/openapi/openapi-to-vovk-schema/apply-components-schemas.d.ts +23 -0
- package/dist/openapi/openapi-to-vovk-schema/apply-components-schemas.js +90 -0
- package/dist/openapi/openapi-to-vovk-schema/index.d.ts +5 -0
- package/dist/openapi/openapi-to-vovk-schema/index.js +179 -0
- package/dist/openapi/openapi-to-vovk-schema/inline-refs.d.ts +9 -0
- package/dist/openapi/openapi-to-vovk-schema/inline-refs.js +99 -0
- package/dist/openapi/openapi-to-vovk-schema/prune-components-schemas.d.ts +7 -0
- package/dist/openapi/openapi-to-vovk-schema/prune-components-schemas.js +51 -0
- package/dist/openapi/operation.js +1 -1
- package/dist/openapi/tool.js +1 -1
- package/dist/openapi/vovk-schema-to-openapi.d.ts +21 -0
- package/dist/openapi/vovk-schema-to-openapi.js +250 -0
- package/dist/req/buffer-body.d.ts +1 -0
- package/dist/req/buffer-body.js +30 -0
- package/dist/req/parse-body.d.ts +4 -0
- package/dist/req/parse-body.js +49 -0
- package/dist/req/parse-form.d.ts +1 -0
- package/dist/req/parse-form.js +24 -0
- package/dist/req/parse-query.d.ts +24 -0
- package/dist/req/parse-query.js +156 -0
- package/dist/req/req-meta.d.ts +2 -0
- package/dist/req/req-meta.js +10 -0
- package/dist/req/req-query.d.ts +2 -0
- package/dist/req/req-query.js +4 -0
- package/dist/req/validate-content-type.d.ts +1 -0
- package/dist/req/validate-content-type.js +32 -0
- package/dist/samples/create-code-samples.d.ts +20 -0
- package/dist/samples/create-code-samples.js +293 -0
- package/dist/samples/object-to-code.d.ts +8 -0
- package/dist/samples/object-to-code.js +38 -0
- package/dist/samples/schema-to-code.d.ts +11 -0
- package/dist/samples/schema-to-code.js +264 -0
- package/dist/samples/schema-to-object.d.ts +2 -0
- package/dist/samples/schema-to-object.js +164 -0
- package/dist/samples/schema-to-ts-type.d.ts +2 -0
- package/dist/samples/schema-to-ts-type.js +114 -0
- package/dist/tools/create-tool-factory.d.ts +135 -0
- package/dist/tools/create-tool-factory.js +62 -0
- package/dist/tools/create-tool.d.ts +126 -0
- package/dist/tools/create-tool.js +6 -0
- package/dist/tools/derive-tools.d.ts +46 -0
- package/dist/tools/derive-tools.js +131 -0
- package/dist/tools/to-model-output-default.d.ts +7 -0
- package/dist/tools/to-model-output-default.js +7 -0
- package/dist/tools/to-model-output-mcp.d.ts +30 -0
- package/dist/tools/to-model-output-mcp.js +54 -0
- package/dist/tools/to-model-output.d.ts +8 -0
- package/dist/tools/to-model-output.js +10 -0
- package/dist/types/client.d.ts +3 -3
- package/dist/types/core.d.ts +1 -1
- package/dist/types/inference.d.ts +1 -1
- package/dist/types/validation.d.ts +1 -1
- package/dist/utils/camel-case.d.ts +6 -0
- package/dist/utils/camel-case.js +34 -0
- package/dist/utils/deep-extend.d.ts +54 -0
- package/dist/utils/deep-extend.js +127 -0
- package/dist/utils/file-name-to-disposition.d.ts +1 -0
- package/dist/utils/file-name-to-disposition.js +3 -0
- package/dist/utils/to-kebab-case.d.ts +1 -0
- package/dist/utils/to-kebab-case.js +5 -0
- package/dist/utils/trim-path.d.ts +1 -0
- package/dist/utils/trim-path.js +1 -0
- package/dist/utils/upper-first.d.ts +1 -0
- package/dist/utils/upper-first.js +3 -0
- package/dist/validation/create-standard-validation.d.ts +268 -0
- package/dist/validation/create-standard-validation.js +45 -0
- package/dist/validation/create-validate-on-client.d.ts +14 -0
- package/dist/validation/create-validate-on-client.js +23 -0
- package/dist/validation/procedure.d.ts +24 -24
- package/dist/validation/procedure.js +1 -1
- package/dist/validation/validation-schemas-object-to-single-validation-schema.d.ts +17 -0
- package/dist/validation/validation-schemas-object-to-single-validation-schema.js +92 -0
- package/dist/validation/with-validation-library.d.ts +119 -0
- package/dist/validation/with-validation-library.js +184 -0
- package/package.json +13 -5
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HttpException } from '../core/http-exception.js';
|
|
2
|
+
import { HttpStatus } from '../types/enums.js';
|
|
3
|
+
// types and enums required for client validation libs
|
|
4
|
+
export { createValidateOnClient, HttpException, HttpStatus, };
|
|
5
|
+
/**
|
|
6
|
+
* Creates a validation function for client-side input validation.
|
|
7
|
+
*/
|
|
8
|
+
function createValidateOnClient({ validate, }) {
|
|
9
|
+
const validateOnClient = async function validateOnClient(input, validation, meta) {
|
|
10
|
+
const newInput = { ...input };
|
|
11
|
+
if (input.body && validation.body) {
|
|
12
|
+
newInput.body = (await validate(input.body, validation.body, { ...meta, type: 'body' })) ?? input.body;
|
|
13
|
+
}
|
|
14
|
+
if (input.query && validation.query) {
|
|
15
|
+
newInput.query = (await validate(input.query, validation.query, { ...meta, type: 'query' })) ?? input.query;
|
|
16
|
+
}
|
|
17
|
+
if (input.params && validation.params) {
|
|
18
|
+
newInput.params = (await validate(input.params, validation.params, { ...meta, type: 'params' })) ?? input.params;
|
|
19
|
+
}
|
|
20
|
+
return newInput;
|
|
21
|
+
};
|
|
22
|
+
return validateOnClient;
|
|
23
|
+
}
|
|
@@ -141,8 +141,8 @@ export declare const procedure: (<TBody extends CombinedSpec, TQuery extends Com
|
|
|
141
141
|
name: string;
|
|
142
142
|
title?: string;
|
|
143
143
|
description: string;
|
|
144
|
-
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/
|
|
145
|
-
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/
|
|
144
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
145
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
146
146
|
target?: CombinedSpec.Target;
|
|
147
147
|
} & {
|
|
148
148
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
@@ -151,13 +151,13 @@ export declare const procedure: (<TBody extends CombinedSpec, TQuery extends Com
|
|
|
151
151
|
} & {
|
|
152
152
|
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
153
153
|
toModelOutput: TToModelOutput;
|
|
154
|
-
}): import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/
|
|
154
|
+
}): import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
155
155
|
<TInput, TOutput>(options: {
|
|
156
156
|
name: string;
|
|
157
157
|
title?: string;
|
|
158
158
|
description: string;
|
|
159
|
-
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/
|
|
160
|
-
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/
|
|
159
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
160
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
161
161
|
target?: CombinedSpec.Target;
|
|
162
162
|
} & {
|
|
163
163
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
@@ -166,13 +166,13 @@ export declare const procedure: (<TBody extends CombinedSpec, TQuery extends Com
|
|
|
166
166
|
} & {
|
|
167
167
|
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
168
168
|
toModelOutput?: undefined;
|
|
169
|
-
}): import("../index.js").VovkTool<TInput, TOutput, import("../tools/
|
|
169
|
+
}): import("../index.js").VovkTool<TInput, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>;
|
|
170
170
|
<TInput, TOutput, TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => import("../types/utils.js").KnownAny>(options: {
|
|
171
171
|
name: string;
|
|
172
172
|
title?: string;
|
|
173
173
|
description: string;
|
|
174
|
-
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/
|
|
175
|
-
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/
|
|
174
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
175
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
176
176
|
target?: CombinedSpec.Target;
|
|
177
177
|
} & {
|
|
178
178
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
@@ -181,13 +181,13 @@ export declare const procedure: (<TBody extends CombinedSpec, TQuery extends Com
|
|
|
181
181
|
} & {
|
|
182
182
|
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
183
183
|
toModelOutput: TToModelOutput;
|
|
184
|
-
}): import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/
|
|
184
|
+
}): import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
185
185
|
<TInput, TOutput>(options: {
|
|
186
186
|
name: string;
|
|
187
187
|
title?: string;
|
|
188
188
|
description: string;
|
|
189
|
-
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/
|
|
190
|
-
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/
|
|
189
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
190
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
191
191
|
target?: CombinedSpec.Target;
|
|
192
192
|
} & {
|
|
193
193
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
@@ -196,13 +196,13 @@ export declare const procedure: (<TBody extends CombinedSpec, TQuery extends Com
|
|
|
196
196
|
} & {
|
|
197
197
|
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
198
198
|
toModelOutput?: undefined;
|
|
199
|
-
}): import("../index.js").VovkTool<TInput, TOutput, import("../tools/
|
|
199
|
+
}): import("../index.js").VovkTool<TInput, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>;
|
|
200
200
|
<TOutput, TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => import("../types/utils.js").KnownAny>(options: {
|
|
201
201
|
name: string;
|
|
202
202
|
title?: string;
|
|
203
203
|
description: string;
|
|
204
|
-
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/
|
|
205
|
-
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/
|
|
204
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
205
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
206
206
|
target?: CombinedSpec.Target;
|
|
207
207
|
} & {
|
|
208
208
|
inputSchema?: undefined;
|
|
@@ -211,13 +211,13 @@ export declare const procedure: (<TBody extends CombinedSpec, TQuery extends Com
|
|
|
211
211
|
} & {
|
|
212
212
|
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
213
213
|
toModelOutput: TToModelOutput;
|
|
214
|
-
}): import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/
|
|
214
|
+
}): import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
215
215
|
<TOutput>(options: {
|
|
216
216
|
name: string;
|
|
217
217
|
title?: string;
|
|
218
218
|
description: string;
|
|
219
|
-
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/
|
|
220
|
-
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/
|
|
219
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
220
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
221
221
|
target?: CombinedSpec.Target;
|
|
222
222
|
} & {
|
|
223
223
|
inputSchema?: undefined;
|
|
@@ -226,13 +226,13 @@ export declare const procedure: (<TBody extends CombinedSpec, TQuery extends Com
|
|
|
226
226
|
} & {
|
|
227
227
|
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
228
228
|
toModelOutput?: undefined;
|
|
229
|
-
}): import("../index.js").VovkTool<null, TOutput, import("../tools/
|
|
229
|
+
}): import("../index.js").VovkTool<null, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>;
|
|
230
230
|
<TOutput, TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => import("../types/utils.js").KnownAny>(options: {
|
|
231
231
|
name: string;
|
|
232
232
|
title?: string;
|
|
233
233
|
description: string;
|
|
234
|
-
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/
|
|
235
|
-
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/
|
|
234
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
235
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
236
236
|
target?: CombinedSpec.Target;
|
|
237
237
|
} & {
|
|
238
238
|
inputSchema?: undefined;
|
|
@@ -241,13 +241,13 @@ export declare const procedure: (<TBody extends CombinedSpec, TQuery extends Com
|
|
|
241
241
|
} & {
|
|
242
242
|
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
243
243
|
toModelOutput: TToModelOutput;
|
|
244
|
-
}): import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/
|
|
244
|
+
}): import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/to-model-output-default.js").ToModelOutputDefaultFn ? import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
245
245
|
<TOutput>(options: {
|
|
246
246
|
name: string;
|
|
247
247
|
title?: string;
|
|
248
248
|
description: string;
|
|
249
|
-
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/
|
|
250
|
-
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/
|
|
249
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
250
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
251
251
|
target?: CombinedSpec.Target;
|
|
252
252
|
} & {
|
|
253
253
|
inputSchema?: undefined;
|
|
@@ -256,6 +256,6 @@ export declare const procedure: (<TBody extends CombinedSpec, TQuery extends Com
|
|
|
256
256
|
} & {
|
|
257
257
|
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
258
258
|
toModelOutput?: undefined;
|
|
259
|
-
}): import("../index.js").VovkTool<null, TOutput, import("../tools/
|
|
259
|
+
}): import("../index.js").VovkTool<null, TOutput, import("../tools/to-model-output-default.js").DefaultModelOutput<TOutput>>;
|
|
260
260
|
};
|
|
261
261
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CombinedSpec } from '../types/validation.js';
|
|
2
|
+
type SchemasObject = {
|
|
3
|
+
body?: CombinedSpec;
|
|
4
|
+
query?: CombinedSpec;
|
|
5
|
+
params?: CombinedSpec;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Combine optional `body` / `query` / `params` Standard Schemas into a single
|
|
9
|
+
* `CombinedSpec` whose `~standard` interface fully conforms to Standard Schema
|
|
10
|
+
* + Standard JSON Schema. Top-level validation (object shape, key presence,
|
|
11
|
+
* rejection of unknown keys) is handled here; per-slot value validation and
|
|
12
|
+
* JSON Schema conversion are delegated to the slot schemas.
|
|
13
|
+
*
|
|
14
|
+
* Internal helper. Not exported from the public `vovk` entrypoint.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validationSchemasObjectToSingleValidationSchema<TSchemas extends SchemasObject>(schemas: TSchemas): CombinedSpec & TSchemas;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const SLOT_KEYS = ['body', 'query', 'params'];
|
|
2
|
+
function isThenable(value) {
|
|
3
|
+
return typeof value === 'object' && value !== null && typeof value.then === 'function';
|
|
4
|
+
}
|
|
5
|
+
function prefixIssues(issues, slot) {
|
|
6
|
+
return issues.map((issue) => ({
|
|
7
|
+
message: issue.message,
|
|
8
|
+
path: [{ key: slot }, ...(issue.path ?? [])],
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Combine optional `body` / `query` / `params` Standard Schemas into a single
|
|
13
|
+
* `CombinedSpec` whose `~standard` interface fully conforms to Standard Schema
|
|
14
|
+
* + Standard JSON Schema. Top-level validation (object shape, key presence,
|
|
15
|
+
* rejection of unknown keys) is handled here; per-slot value validation and
|
|
16
|
+
* JSON Schema conversion are delegated to the slot schemas.
|
|
17
|
+
*
|
|
18
|
+
* Internal helper. Not exported from the public `vovk` entrypoint.
|
|
19
|
+
*/
|
|
20
|
+
export function validationSchemasObjectToSingleValidationSchema(schemas) {
|
|
21
|
+
const definedSlots = SLOT_KEYS.filter((key) => schemas[key] !== undefined);
|
|
22
|
+
const definedSlotSet = new Set(definedSlots);
|
|
23
|
+
const validate = (input) => {
|
|
24
|
+
if (typeof input !== 'object' || input === null || Array.isArray(input)) {
|
|
25
|
+
return { issues: [{ message: 'Expected object', path: [] }] };
|
|
26
|
+
}
|
|
27
|
+
const topLevelIssues = [];
|
|
28
|
+
const inputRecord = input;
|
|
29
|
+
for (const slot of definedSlots) {
|
|
30
|
+
if (!(slot in inputRecord)) {
|
|
31
|
+
topLevelIssues.push({ message: 'Required', path: [{ key: slot }] });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const key of Object.keys(inputRecord)) {
|
|
35
|
+
if (!definedSlotSet.has(key)) {
|
|
36
|
+
topLevelIssues.push({ message: 'Unexpected key', path: [{ key }] });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const pending = [];
|
|
40
|
+
for (const slot of definedSlots) {
|
|
41
|
+
if (slot in inputRecord) {
|
|
42
|
+
pending.push({ slot, result: schemas[slot]['~standard'].validate(inputRecord[slot]) });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const combine = (resolved) => {
|
|
46
|
+
const issues = [...topLevelIssues];
|
|
47
|
+
const value = {};
|
|
48
|
+
for (const { slot, result } of resolved) {
|
|
49
|
+
if (result.issues?.length) {
|
|
50
|
+
issues.push(...prefixIssues(result.issues, slot));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
value[slot] = result.value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return issues.length > 0 ? { issues } : { value };
|
|
57
|
+
};
|
|
58
|
+
if (pending.some(({ result }) => isThenable(result))) {
|
|
59
|
+
return Promise.all(pending.map(async ({ slot, result }) => ({ slot, result: await result }))).then(combine);
|
|
60
|
+
}
|
|
61
|
+
return combine(pending);
|
|
62
|
+
};
|
|
63
|
+
const buildJSONSchema = (options, direction) => {
|
|
64
|
+
const properties = {};
|
|
65
|
+
for (const slot of definedSlots) {
|
|
66
|
+
properties[slot] = schemas[slot]['~standard'].jsonSchema?.[direction](options) ?? {};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties,
|
|
71
|
+
required: [...definedSlots],
|
|
72
|
+
additionalProperties: false,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
const standard = {
|
|
76
|
+
version: 1,
|
|
77
|
+
vendor: 'vovk',
|
|
78
|
+
validate,
|
|
79
|
+
jsonSchema: {
|
|
80
|
+
input: (options) => buildJSONSchema(options, 'input'),
|
|
81
|
+
output: (options) => buildJSONSchema(options, 'output'),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
const result = { '~standard': standard };
|
|
85
|
+
if (schemas.body !== undefined)
|
|
86
|
+
result.body = schemas.body;
|
|
87
|
+
if (schemas.query !== undefined)
|
|
88
|
+
result.query = schemas.query;
|
|
89
|
+
if (schemas.params !== undefined)
|
|
90
|
+
result.params = schemas.params;
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { VovkHandlerSchema, VovkValidationType } from '../types/core.js';
|
|
2
|
+
import type { VovkRequest } from '../types/request.js';
|
|
3
|
+
import type { BodyTypeFromContentType, ContentType, VovkTypedProcedure } from '../types/validation.js';
|
|
4
|
+
import type { VovkOperationObject } from '../types/operation.js';
|
|
5
|
+
import type { KnownAny } from '../types/utils.js';
|
|
6
|
+
type VovkRequestAny = VovkRequest<KnownAny, KnownAny, KnownAny>;
|
|
7
|
+
type Meta = {
|
|
8
|
+
__disableClientValidation?: boolean;
|
|
9
|
+
[key: string]: KnownAny;
|
|
10
|
+
};
|
|
11
|
+
export declare function withValidationLibrary<THandle extends VovkTypedProcedure<(req: KnownAny, params: KnownAny) => KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, ContentType[]>, TBodyModel, TQueryModel, TParamsModel, TOutputModel, TIterationModel, TContentType extends ContentType[] = ['application/json']>({ contentType, disableServerSideValidation, skipSchemaEmission, validateEachIteration, body, query, params, output, iteration, handle, toJSONSchema, validate, preferTransformed, operationObject, }: {
|
|
12
|
+
contentType: TContentType | undefined;
|
|
13
|
+
disableServerSideValidation: boolean | VovkValidationType[] | undefined;
|
|
14
|
+
skipSchemaEmission: boolean | VovkValidationType[] | undefined;
|
|
15
|
+
validateEachIteration: boolean | undefined;
|
|
16
|
+
body: TBodyModel | undefined;
|
|
17
|
+
query: TQueryModel | undefined;
|
|
18
|
+
params: TParamsModel | undefined;
|
|
19
|
+
output: TOutputModel | undefined;
|
|
20
|
+
iteration: TIterationModel | undefined;
|
|
21
|
+
handle: THandle;
|
|
22
|
+
toJSONSchema: ((model: KnownAny, meta: {
|
|
23
|
+
validationType: VovkValidationType;
|
|
24
|
+
}) => KnownAny) | undefined;
|
|
25
|
+
validate: (data: unknown, model: NonNullable<TBodyModel | TQueryModel | TParamsModel | TOutputModel | TIterationModel>, meta: {
|
|
26
|
+
validationType: VovkValidationType;
|
|
27
|
+
req: VovkRequestAny;
|
|
28
|
+
status?: number;
|
|
29
|
+
i?: number;
|
|
30
|
+
}) => unknown;
|
|
31
|
+
preferTransformed: boolean | undefined;
|
|
32
|
+
operationObject: VovkOperationObject | undefined;
|
|
33
|
+
}): THandle & {
|
|
34
|
+
schema: Omit<VovkHandlerSchema, "httpMethod" | "path"> & Partial<VovkHandlerSchema>;
|
|
35
|
+
wrapper?: (req: VovkRequestAny, params: Parameters<THandle>[1]) => ReturnType<THandle>;
|
|
36
|
+
} & {
|
|
37
|
+
fn: {
|
|
38
|
+
<TTransformed>(input: Omit<{
|
|
39
|
+
disableClientValidation?: boolean;
|
|
40
|
+
transform?: undefined;
|
|
41
|
+
} & (undefined extends TBodyModel | undefined ? {
|
|
42
|
+
body?: BodyTypeFromContentType<TContentType, THandle["__types"]["body"]>;
|
|
43
|
+
} : {
|
|
44
|
+
body: BodyTypeFromContentType<TContentType, THandle["__types"]["body"]>;
|
|
45
|
+
}) & (undefined extends TQueryModel | undefined ? {
|
|
46
|
+
query?: THandle["__types"]["query"];
|
|
47
|
+
} : {
|
|
48
|
+
query: THandle["__types"]["query"];
|
|
49
|
+
}) & (undefined extends TParamsModel | undefined ? {
|
|
50
|
+
params?: THandle["__types"]["params"];
|
|
51
|
+
} : {
|
|
52
|
+
params: THandle["__types"]["params"];
|
|
53
|
+
}) & {
|
|
54
|
+
meta?: Meta;
|
|
55
|
+
}, "transform"> & {
|
|
56
|
+
transform: (result: Awaited<ReturnType<THandle>>, fakeReq: Pick<VovkRequestAny, "vovk">) => TTransformed;
|
|
57
|
+
}): Promise<TTransformed>;
|
|
58
|
+
<TReturnType = ReturnType<THandle>>(input?: {
|
|
59
|
+
disableClientValidation?: boolean;
|
|
60
|
+
transform?: undefined;
|
|
61
|
+
} & (undefined extends TBodyModel | undefined ? {
|
|
62
|
+
body?: BodyTypeFromContentType<TContentType, THandle["__types"]["body"]>;
|
|
63
|
+
} : {
|
|
64
|
+
body: BodyTypeFromContentType<TContentType, THandle["__types"]["body"]>;
|
|
65
|
+
}) & (undefined extends TQueryModel | undefined ? {
|
|
66
|
+
query?: THandle["__types"]["query"];
|
|
67
|
+
} : {
|
|
68
|
+
query: THandle["__types"]["query"];
|
|
69
|
+
}) & (undefined extends TParamsModel | undefined ? {
|
|
70
|
+
params?: THandle["__types"]["params"];
|
|
71
|
+
} : {
|
|
72
|
+
params: THandle["__types"]["params"];
|
|
73
|
+
}) & {
|
|
74
|
+
meta?: Meta;
|
|
75
|
+
}): TReturnType;
|
|
76
|
+
<TReturnType = ReturnType<THandle>>(input?: (undefined extends TBodyModel | undefined ? undefined extends TQueryModel | undefined ? undefined extends TParamsModel | undefined ? true : false : false : false) extends true ? {
|
|
77
|
+
disableClientValidation?: boolean;
|
|
78
|
+
transform?: undefined;
|
|
79
|
+
} & (undefined extends TBodyModel | undefined ? {
|
|
80
|
+
body?: BodyTypeFromContentType<TContentType, THandle["__types"]["body"]>;
|
|
81
|
+
} : {
|
|
82
|
+
body: BodyTypeFromContentType<TContentType, THandle["__types"]["body"]>;
|
|
83
|
+
}) & (undefined extends TQueryModel | undefined ? {
|
|
84
|
+
query?: THandle["__types"]["query"];
|
|
85
|
+
} : {
|
|
86
|
+
query: THandle["__types"]["query"];
|
|
87
|
+
}) & (undefined extends TParamsModel | undefined ? {
|
|
88
|
+
params?: THandle["__types"]["params"];
|
|
89
|
+
} : {
|
|
90
|
+
params: THandle["__types"]["params"];
|
|
91
|
+
}) & {
|
|
92
|
+
meta?: Meta;
|
|
93
|
+
} : never): (undefined extends TBodyModel | undefined ? undefined extends TQueryModel | undefined ? undefined extends TParamsModel | undefined ? true : false : false : false) extends true ? TReturnType : never;
|
|
94
|
+
};
|
|
95
|
+
definition: {
|
|
96
|
+
contentType: TContentType | undefined;
|
|
97
|
+
disableServerSideValidation: boolean | VovkValidationType[] | undefined;
|
|
98
|
+
skipSchemaEmission: boolean | VovkValidationType[] | undefined;
|
|
99
|
+
validateEachIteration: boolean | undefined;
|
|
100
|
+
body: TBodyModel | undefined;
|
|
101
|
+
query: TQueryModel | undefined;
|
|
102
|
+
params: TParamsModel | undefined;
|
|
103
|
+
output: TOutputModel | undefined;
|
|
104
|
+
iteration: TIterationModel | undefined;
|
|
105
|
+
handle: THandle;
|
|
106
|
+
toJSONSchema: ((model: KnownAny, meta: {
|
|
107
|
+
validationType: VovkValidationType;
|
|
108
|
+
}) => KnownAny) | undefined;
|
|
109
|
+
validate: (data: unknown, model: NonNullable<TBodyModel | TQueryModel | TParamsModel | TOutputModel | TIterationModel>, meta: {
|
|
110
|
+
validationType: VovkValidationType;
|
|
111
|
+
req: VovkRequestAny;
|
|
112
|
+
status?: number;
|
|
113
|
+
i?: number;
|
|
114
|
+
}) => unknown;
|
|
115
|
+
preferTransformed: boolean;
|
|
116
|
+
operationObject: VovkOperationObject | undefined;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export {};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { HttpException } from '../core/http-exception.js';
|
|
2
|
+
import { reqMeta } from '../req/req-meta.js';
|
|
3
|
+
import { setHandlerSchema } from '../core/set-handler-schema.js';
|
|
4
|
+
import { JSONLinesResponder } from '../core/json-lines-responder.js';
|
|
5
|
+
import { HttpStatus } from '../types/enums.js';
|
|
6
|
+
import { validateContentType } from '../req/validate-content-type.js';
|
|
7
|
+
import { bufferBody } from '../req/buffer-body.js';
|
|
8
|
+
import { parseForm } from '../req/parse-form.js';
|
|
9
|
+
const validationTypes = ['body', 'query', 'params', 'output', 'iteration'];
|
|
10
|
+
export function withValidationLibrary({ contentType, disableServerSideValidation, skipSchemaEmission, validateEachIteration, body, query, params, output, iteration, handle, toJSONSchema, validate, preferTransformed, operationObject, }) {
|
|
11
|
+
preferTransformed = preferTransformed ?? true;
|
|
12
|
+
const disableServerSideValidationKeys = disableServerSideValidation === false
|
|
13
|
+
? []
|
|
14
|
+
: disableServerSideValidation === true
|
|
15
|
+
? validationTypes
|
|
16
|
+
: (disableServerSideValidation ?? []);
|
|
17
|
+
const skipSchemaEmissionKeys = skipSchemaEmission === false ? [] : skipSchemaEmission === true ? validationTypes : (skipSchemaEmission ?? []);
|
|
18
|
+
const outputHandler = async (req, handlerParams) => {
|
|
19
|
+
const { __disableClientValidation } = req.vovk.meta();
|
|
20
|
+
const data = await handle(req, handlerParams);
|
|
21
|
+
if (__disableClientValidation) {
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
if (output && iteration) {
|
|
25
|
+
throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR, "Output and iteration are mutually exclusive. You can't use them together.");
|
|
26
|
+
}
|
|
27
|
+
if (output && !disableServerSideValidationKeys.includes('output')) {
|
|
28
|
+
if (!data) {
|
|
29
|
+
throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR, 'Output is required. You probably forgot to return something from your handler.');
|
|
30
|
+
}
|
|
31
|
+
const parsed = (await validate(data, output, { validationType: 'output', req })) ?? data;
|
|
32
|
+
return preferTransformed ? parsed : data;
|
|
33
|
+
}
|
|
34
|
+
if (iteration && !disableServerSideValidationKeys.includes('iteration')) {
|
|
35
|
+
// We assume `data` is an async iterable here; you might want to check that:
|
|
36
|
+
if (!data || (typeof data[Symbol.asyncIterator] !== 'function' && !(data instanceof JSONLinesResponder))) {
|
|
37
|
+
throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR, 'Data is not an async iterable, neither JSONLinesResponder but iteration validation is defined.');
|
|
38
|
+
}
|
|
39
|
+
if (data instanceof JSONLinesResponder) {
|
|
40
|
+
data.onBeforeSend = async (item, i) => {
|
|
41
|
+
let parsed;
|
|
42
|
+
if (validateEachIteration || i === 0) {
|
|
43
|
+
parsed = (await validate(item, iteration, { validationType: 'iteration', req, status: 200, i })) ?? item;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
parsed = item;
|
|
47
|
+
}
|
|
48
|
+
return preferTransformed ? parsed : item;
|
|
49
|
+
};
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
// Return a brand-new async generator that yields validated items
|
|
53
|
+
return (async function* () {
|
|
54
|
+
let i = 0;
|
|
55
|
+
for await (const item of data) {
|
|
56
|
+
let parsed;
|
|
57
|
+
if (validateEachIteration || i === 0) {
|
|
58
|
+
parsed = (await validate(item, iteration, { validationType: 'iteration', req, status: 200, i })) ?? item;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
parsed = item;
|
|
62
|
+
}
|
|
63
|
+
i++;
|
|
64
|
+
yield preferTransformed ? parsed : item;
|
|
65
|
+
}
|
|
66
|
+
})();
|
|
67
|
+
}
|
|
68
|
+
else if (validateEachIteration) {
|
|
69
|
+
throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR, 'validateEachIteration is set but iteration is not defined.');
|
|
70
|
+
}
|
|
71
|
+
return data;
|
|
72
|
+
};
|
|
73
|
+
const resultHandler = (async (req, handlerParams) => {
|
|
74
|
+
const { __disableClientValidation } = req.vovk.meta();
|
|
75
|
+
if (!__disableClientValidation) {
|
|
76
|
+
if (body && !disableServerSideValidationKeys.includes('body')) {
|
|
77
|
+
if (typeof req.url === 'string')
|
|
78
|
+
await bufferBody(req); // buffer the body to make it replayable for validation and actual parsing
|
|
79
|
+
validateContentType(req, contentType ?? ['application/json']);
|
|
80
|
+
const data = await req.vovk.body();
|
|
81
|
+
const parsed = (await validate(data, body, { validationType: 'body', req })) ?? data;
|
|
82
|
+
const instance = preferTransformed ? parsed : data;
|
|
83
|
+
req.vovk.body = () => Promise.resolve(instance);
|
|
84
|
+
}
|
|
85
|
+
if (query && !disableServerSideValidationKeys.includes('query')) {
|
|
86
|
+
const data = req.vovk.query();
|
|
87
|
+
const parsed = (await validate(data, query, { validationType: 'query', req })) ?? data;
|
|
88
|
+
const instance = preferTransformed ? parsed : data;
|
|
89
|
+
req.vovk.query = () => instance;
|
|
90
|
+
}
|
|
91
|
+
if (params && !disableServerSideValidationKeys.includes('params')) {
|
|
92
|
+
const data = req.vovk.params();
|
|
93
|
+
const parsed = (await validate(data, params, { validationType: 'params', req })) ?? data;
|
|
94
|
+
const instance = preferTransformed ? parsed : data;
|
|
95
|
+
req.vovk.params = () => instance;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return outputHandler(req, handlerParams);
|
|
99
|
+
});
|
|
100
|
+
function fn(input) {
|
|
101
|
+
let bodyCache;
|
|
102
|
+
const fakeReq = {
|
|
103
|
+
vovk: {
|
|
104
|
+
body: () => {
|
|
105
|
+
if (input && input.body instanceof FormData) {
|
|
106
|
+
bodyCache ??= parseForm(input.body);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
bodyCache = input?.body;
|
|
110
|
+
}
|
|
111
|
+
return Promise.resolve(bodyCache ?? null);
|
|
112
|
+
},
|
|
113
|
+
query: () => input?.query ?? {},
|
|
114
|
+
params: () => input?.params ?? {},
|
|
115
|
+
meta: (meta) => reqMeta(fakeReq, meta),
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
fakeReq.vovk.meta({ __disableClientValidation: input?.disableClientValidation, ...input?.meta });
|
|
119
|
+
const result = (resultHandler.wrapper ?? resultHandler)(fakeReq, (input?.params ?? {}));
|
|
120
|
+
if (input && 'transform' in input && typeof input.transform === 'function') {
|
|
121
|
+
return Promise.resolve(result).then((resolvedResult) => input.transform(resolvedResult, fakeReq));
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
const definition = {
|
|
126
|
+
contentType,
|
|
127
|
+
disableServerSideValidation,
|
|
128
|
+
skipSchemaEmission,
|
|
129
|
+
validateEachIteration,
|
|
130
|
+
body,
|
|
131
|
+
query,
|
|
132
|
+
params,
|
|
133
|
+
output,
|
|
134
|
+
iteration,
|
|
135
|
+
handle,
|
|
136
|
+
toJSONSchema,
|
|
137
|
+
validate,
|
|
138
|
+
preferTransformed,
|
|
139
|
+
operationObject,
|
|
140
|
+
};
|
|
141
|
+
const resultHandlerEnhanced = Object.assign(resultHandler, { fn, definition });
|
|
142
|
+
const validation = {};
|
|
143
|
+
if (toJSONSchema) {
|
|
144
|
+
const getJSONSchema = (model, validationType) => Object.assign(toJSONSchema(model, { validationType }), validationType === 'body' ? { 'x-contentType': contentType } : {});
|
|
145
|
+
if (body && !skipSchemaEmissionKeys.includes('body')) {
|
|
146
|
+
let bodyJSONSchema;
|
|
147
|
+
Object.defineProperty(validation, 'body', {
|
|
148
|
+
enumerable: true,
|
|
149
|
+
get: () => (bodyJSONSchema ??= getJSONSchema(body, 'body')),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
if (query && !skipSchemaEmissionKeys.includes('query')) {
|
|
153
|
+
let queryJSONSchema;
|
|
154
|
+
Object.defineProperty(validation, 'query', {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
get: () => (queryJSONSchema ??= getJSONSchema(query, 'query')),
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (params && !skipSchemaEmissionKeys.includes('params')) {
|
|
160
|
+
let paramsJSONSchema;
|
|
161
|
+
Object.defineProperty(validation, 'params', {
|
|
162
|
+
enumerable: true,
|
|
163
|
+
get: () => (paramsJSONSchema ??= getJSONSchema(params, 'params')),
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (output && !skipSchemaEmissionKeys.includes('output')) {
|
|
167
|
+
let outputJSONSchema;
|
|
168
|
+
Object.defineProperty(validation, 'output', {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: () => (outputJSONSchema ??= getJSONSchema(output, 'output')),
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (iteration && !skipSchemaEmissionKeys.includes('iteration')) {
|
|
174
|
+
let iterationJSONSchema;
|
|
175
|
+
Object.defineProperty(validation, 'iteration', {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: () => (iterationJSONSchema ??= getJSONSchema(iteration, 'iteration')),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
resultHandlerEnhanced.schema = { validation, operationObject };
|
|
182
|
+
setHandlerSchema(resultHandlerEnhanced, { validation, operationObject });
|
|
183
|
+
return resultHandlerEnhanced;
|
|
184
|
+
}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
],
|
|
8
8
|
"main": "./dist/index.js",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
|
-
"version": "3.
|
|
10
|
+
"version": "3.7.0",
|
|
11
11
|
"bin": {
|
|
12
12
|
"vovk-cli-npx": "./bin/index.mjs"
|
|
13
13
|
},
|
|
@@ -24,13 +24,21 @@
|
|
|
24
24
|
"types": "./dist/client/fetcher.d.ts",
|
|
25
25
|
"default": "./dist/client/fetcher.js"
|
|
26
26
|
},
|
|
27
|
+
"./create-rpc": {
|
|
28
|
+
"types": "./dist/client/create-rpc.d.ts",
|
|
29
|
+
"default": "./dist/client/create-rpc.js"
|
|
30
|
+
},
|
|
31
|
+
"./create-validate-on-client": {
|
|
32
|
+
"types": "./dist/validation/create-validate-on-client.d.ts",
|
|
33
|
+
"default": "./dist/validation/create-validate-on-client.js"
|
|
34
|
+
},
|
|
27
35
|
"./createRPC": {
|
|
28
|
-
"types": "./dist/client/
|
|
29
|
-
"default": "./dist/client/
|
|
36
|
+
"types": "./dist/client/create-rpc.d.ts",
|
|
37
|
+
"default": "./dist/client/create-rpc.js"
|
|
30
38
|
},
|
|
31
39
|
"./createValidateOnClient": {
|
|
32
|
-
"types": "./dist/validation/
|
|
33
|
-
"default": "./dist/validation/
|
|
40
|
+
"types": "./dist/validation/create-validate-on-client.d.ts",
|
|
41
|
+
"default": "./dist/validation/create-validate-on-client.js"
|
|
34
42
|
}
|
|
35
43
|
},
|
|
36
44
|
"description": "Back-end Framework for Next.js App Router",
|