vovk 3.0.0-draft.462 → 3.0.0-draft.464
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/index.d.ts +2 -2
- package/cjs/openapi/vovkSchemaToOpenAPI.d.ts +2 -2
- package/cjs/types.d.ts +8 -8
- package/cjs/utils/createStandardValidation.d.ts +26 -26
- package/cjs/utils/resolveGeneratorConfigValues.d.ts +4 -4
- package/cjs/utils/resolveGeneratorConfigValues.js +16 -16
- package/cjs/utils/withValidationLibrary.d.ts +23 -23
- package/mjs/index.d.ts +2 -2
- package/mjs/openapi/vovkSchemaToOpenAPI.d.ts +2 -2
- package/mjs/types.d.ts +8 -8
- package/mjs/utils/createStandardValidation.d.ts +26 -26
- package/mjs/utils/resolveGeneratorConfigValues.d.ts +4 -4
- package/mjs/utils/resolveGeneratorConfigValues.js +16 -16
- package/mjs/utils/withValidationLibrary.d.ts +23 -23
- package/package.json +1 -1
package/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createVovkApp } from './createVovkApp';
|
|
2
|
-
import { HttpStatus, HttpMethod, VovkSchemaIdEnum, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkOutput, type VovkIteration, type VovkMetaSchema, type VovkSegmentSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type
|
|
2
|
+
import { HttpStatus, HttpMethod, VovkSchemaIdEnum, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkOutput, type VovkIteration, type VovkMetaSchema, type VovkSegmentSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkOutputConfig, type VovkReadmeConfig, type VovkSamplesConfig, type VovkPackageJson, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkStrictConfig, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject } from './types';
|
|
3
3
|
import { type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkValidateOnClient, type VovkStreamAsyncIterable, createRPC, fetcher, createFetcher, progressive } from './client';
|
|
4
4
|
import { operation, openAPIToVovkSchema, vovkSchemaToOpenAPI } from './openapi';
|
|
5
5
|
import { HttpException } from './HttpException';
|
|
@@ -13,7 +13,7 @@ import { createLLMTools } from './utils/createLLMTools';
|
|
|
13
13
|
import { createCodeSamples } from './utils/createCodeSamples';
|
|
14
14
|
import { createValidateOnClient } from './utils/createValidateOnClient';
|
|
15
15
|
import { resolveGeneratorConfigValues } from './utils/resolveGeneratorConfigValues';
|
|
16
|
-
export { type KnownAny, type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkOutput, type VovkIteration, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkMetaSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkStrictConfig, type
|
|
16
|
+
export { type KnownAny, type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkOutput, type VovkIteration, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkMetaSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkStrictConfig, type VovkOutputConfig, type VovkPackageJson, type VovkReadmeConfig, type VovkSamplesConfig, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject, VovkSchemaIdEnum, JSONLinesResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, createRPC, fetcher, createFetcher, generateStaticAPI, withValidationLibrary, createStandardValidation, multitenant, createLLMTools, createCodeSamples, createValidateOnClient, progressive, operation, openAPIToVovkSchema, vovkSchemaToOpenAPI, resolveGeneratorConfigValues, };
|
|
17
17
|
export declare const get: {
|
|
18
18
|
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
19
19
|
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import { type VovkSchema, type
|
|
2
|
+
import { type VovkSchema, type VovkOutputConfig } from '../types';
|
|
3
3
|
export declare function vovkSchemaToOpenAPI({ rootEntry, schema: fullSchema, configs, segmentName: givenSegmentName, }: {
|
|
4
4
|
rootEntry?: string;
|
|
5
5
|
schema: VovkSchema;
|
|
6
|
-
configs?:
|
|
6
|
+
configs?: VovkOutputConfig[];
|
|
7
7
|
segmentName?: string;
|
|
8
8
|
}): OpenAPIObject;
|
package/cjs/types.d.ts
CHANGED
|
@@ -129,14 +129,14 @@ export type ControllerStaticMethod<REQ extends VovkRequest<KnownAny, KnownAny, K
|
|
|
129
129
|
} = KnownAny> = ((req: REQ, params: TParams) => unknown) & {
|
|
130
130
|
_controller?: VovkController;
|
|
131
131
|
};
|
|
132
|
-
export type VovkTypedMethod<T extends (...args: KnownAny[]) => KnownAny, B = KnownAny, Q = KnownAny, P = KnownAny, O = KnownAny, I = KnownAny,
|
|
132
|
+
export type VovkTypedMethod<T extends (...args: KnownAny[]) => KnownAny, B = KnownAny, Q = KnownAny, P = KnownAny, O = KnownAny, I = KnownAny, TIsForm extends boolean = false> = T & {
|
|
133
133
|
__types: {
|
|
134
134
|
body: B;
|
|
135
135
|
query: Q;
|
|
136
136
|
params: P;
|
|
137
137
|
output: O;
|
|
138
138
|
iteration: I;
|
|
139
|
-
isForm:
|
|
139
|
+
isForm: TIsForm;
|
|
140
140
|
};
|
|
141
141
|
isRPC?: boolean;
|
|
142
142
|
};
|
|
@@ -352,7 +352,7 @@ type BundleConfig = {
|
|
|
352
352
|
prebundleDir: string;
|
|
353
353
|
entry: string;
|
|
354
354
|
}) => Promise<void>;
|
|
355
|
-
|
|
355
|
+
outputConfig?: VovkOutputConfig<GeneratorConfigImports>;
|
|
356
356
|
} & ({
|
|
357
357
|
excludeSegments?: never;
|
|
358
358
|
includeSegments?: string[];
|
|
@@ -369,7 +369,7 @@ type SegmentConfigImports = {
|
|
|
369
369
|
fetcher?: string | [string, string] | [string];
|
|
370
370
|
validateOnClient?: string | [string, string] | [string] | null;
|
|
371
371
|
};
|
|
372
|
-
export interface
|
|
372
|
+
export interface VovkOutputConfig<TImports extends GeneratorConfigImports = GeneratorConfigImports> {
|
|
373
373
|
origin?: string | null;
|
|
374
374
|
package?: VovkPackageJson;
|
|
375
375
|
readme?: VovkReadmeConfig;
|
|
@@ -384,7 +384,7 @@ export type ClientTemplateDef = {
|
|
|
384
384
|
composedClient?: Omit<ClientConfigComposed, 'fromTemplates' | 'enabled'>;
|
|
385
385
|
segmentedClient?: Omit<ClientConfigSegmented, 'fromTemplates' | 'enabled'>;
|
|
386
386
|
requires?: Record<string, string>;
|
|
387
|
-
|
|
387
|
+
outputConfig?: VovkOutputConfig<GeneratorConfigImports>;
|
|
388
388
|
};
|
|
389
389
|
export type GetOpenAPINameFn = (config: {
|
|
390
390
|
operationObject: VovkOperationObject;
|
|
@@ -416,7 +416,7 @@ export interface VovkOpenAPIMixinNormalized extends Omit<VovkOpenAPIMixin, 'sour
|
|
|
416
416
|
getMethodName: GetOpenAPINameFn;
|
|
417
417
|
getModuleName: GetOpenAPINameFn;
|
|
418
418
|
}
|
|
419
|
-
export interface VovkSegmentConfig extends
|
|
419
|
+
export interface VovkSegmentConfig extends VovkOutputConfig<SegmentConfigImports> {
|
|
420
420
|
rootEntry?: string;
|
|
421
421
|
segmentNameOverride?: string;
|
|
422
422
|
openAPIMixin?: VovkOpenAPIMixin;
|
|
@@ -443,7 +443,7 @@ type VovkUserConfig = {
|
|
|
443
443
|
controller?: string;
|
|
444
444
|
[key: string]: string | undefined;
|
|
445
445
|
};
|
|
446
|
-
|
|
446
|
+
outputConfig?: VovkOutputConfig<GeneratorConfigImports> & {
|
|
447
447
|
segments?: Record<string, VovkSegmentConfig>;
|
|
448
448
|
};
|
|
449
449
|
};
|
|
@@ -454,7 +454,7 @@ export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'emitConfig' | 'lib
|
|
|
454
454
|
libs: Record<string, KnownAny>;
|
|
455
455
|
composedClient: RequireFields<ClientConfigComposed, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
|
|
456
456
|
segmentedClient: RequireFields<ClientConfigSegmented, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
|
|
457
|
-
|
|
457
|
+
outputConfig: VovkOutputConfig<GeneratorConfigImports> & {
|
|
458
458
|
segments?: Record<string, Omit<VovkSegmentConfig, 'openAPIMixin'> & {
|
|
459
459
|
openAPIMixin?: VovkOpenAPIMixinNormalized;
|
|
460
460
|
}>;
|
|
@@ -4,13 +4,13 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
4
4
|
toJSONSchema: (model: KnownAny, meta: {
|
|
5
5
|
type: VovkValidationType;
|
|
6
6
|
}) => KnownAny;
|
|
7
|
-
}): <T extends (req:
|
|
8
|
-
isForm?:
|
|
7
|
+
}): <T extends (req: TReq, params: TParams extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TParams> : Record<string, string>) => KnownAny, TBody extends StandardSchemaV1, TQuery extends StandardSchemaV1, TParams extends StandardSchemaV1, TOutput extends StandardSchemaV1, TIteration extends StandardSchemaV1, TReq extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : undefined, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : undefined, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : undefined>, TIsForm extends boolean = false>({ isForm, body, query, params, output, iteration, handle, disableServerSideValidation, skipSchemaEmission, validateEachIteration, preferTransformed, operationObject, }: {
|
|
8
|
+
isForm?: TIsForm;
|
|
9
9
|
body?: TBody;
|
|
10
10
|
query?: TQuery;
|
|
11
11
|
params?: TParams;
|
|
12
|
-
output?:
|
|
13
|
-
iteration?:
|
|
12
|
+
output?: TOutput;
|
|
13
|
+
iteration?: TIteration;
|
|
14
14
|
handle: T;
|
|
15
15
|
disableServerSideValidation?: boolean | VovkValidationType[];
|
|
16
16
|
skipSchemaEmission?: boolean | VovkValidationType[];
|
|
@@ -22,60 +22,60 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
22
22
|
body: TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any;
|
|
23
23
|
query: TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any;
|
|
24
24
|
params: TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any;
|
|
25
|
-
output:
|
|
26
|
-
iteration:
|
|
27
|
-
isForm:
|
|
25
|
+
output: TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any;
|
|
26
|
+
iteration: TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any;
|
|
27
|
+
isForm: TIsForm;
|
|
28
28
|
};
|
|
29
29
|
isRPC?: boolean;
|
|
30
30
|
} & {
|
|
31
31
|
schema: Omit<import("../types").VovkHandlerSchema, "httpMethod" | "path"> & Partial<import("../types").VovkHandlerSchema>;
|
|
32
|
-
wrapper?: ((req: VovkRequest<any, any, any>, params: Parameters<VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
32
|
+
wrapper?: ((req: VovkRequest<any, any, any>, params: Parameters<VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>>[1]) => ReturnType<VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>>) | undefined;
|
|
33
33
|
} & {
|
|
34
34
|
fn: {
|
|
35
|
-
<
|
|
35
|
+
<TReturnType = ReturnType<VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>>>(input?: ((undefined extends TBody | undefined ? undefined extends TQuery | undefined ? undefined extends TParams | undefined ? true : false : false : false) extends true ? {
|
|
36
36
|
disableClientValidation?: boolean;
|
|
37
37
|
} & (undefined extends TBody | undefined ? {
|
|
38
|
-
body?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
38
|
+
body?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["body"] | undefined;
|
|
39
39
|
} : {
|
|
40
|
-
body: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
40
|
+
body: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["body"];
|
|
41
41
|
}) & (undefined extends TQuery | undefined ? {
|
|
42
|
-
query?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
42
|
+
query?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["query"] | undefined;
|
|
43
43
|
} : {
|
|
44
|
-
query: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
44
|
+
query: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["query"];
|
|
45
45
|
}) & (undefined extends TParams | undefined ? {
|
|
46
|
-
params?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
46
|
+
params?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["params"] | undefined;
|
|
47
47
|
} : {
|
|
48
|
-
params: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
48
|
+
params: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["params"];
|
|
49
49
|
}) & {
|
|
50
50
|
meta?: {
|
|
51
51
|
[key: string]: any;
|
|
52
52
|
__disableClientValidation?: boolean;
|
|
53
53
|
};
|
|
54
|
-
} : never) | undefined): (undefined extends TBody | undefined ? undefined extends TQuery | undefined ? undefined extends TParams | undefined ? true : false : false : false) extends true ?
|
|
55
|
-
<
|
|
54
|
+
} : never) | undefined): (undefined extends TBody | undefined ? undefined extends TQuery | undefined ? undefined extends TParams | undefined ? true : false : false : false) extends true ? TReturnType : never;
|
|
55
|
+
<TReturnType = ReturnType<VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>>>(input: {
|
|
56
56
|
disableClientValidation?: boolean;
|
|
57
57
|
} & (undefined extends TBody | undefined ? {
|
|
58
|
-
body?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
58
|
+
body?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["body"] | undefined;
|
|
59
59
|
} : {
|
|
60
|
-
body: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
60
|
+
body: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["body"];
|
|
61
61
|
}) & (undefined extends TQuery | undefined ? {
|
|
62
|
-
query?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
62
|
+
query?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["query"] | undefined;
|
|
63
63
|
} : {
|
|
64
|
-
query: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
64
|
+
query: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["query"];
|
|
65
65
|
}) & (undefined extends TParams | undefined ? {
|
|
66
|
-
params?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
66
|
+
params?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["params"] | undefined;
|
|
67
67
|
} : {
|
|
68
|
-
params: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
68
|
+
params: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["params"];
|
|
69
69
|
}) & {
|
|
70
70
|
meta?: {
|
|
71
71
|
[key: string]: any;
|
|
72
72
|
__disableClientValidation?: boolean;
|
|
73
73
|
};
|
|
74
|
-
}):
|
|
74
|
+
}): TReturnType;
|
|
75
75
|
};
|
|
76
76
|
models: {
|
|
77
|
-
iteration?: (
|
|
78
|
-
output?: (
|
|
77
|
+
iteration?: (TIteration & ({} | null)) | undefined;
|
|
78
|
+
output?: (TOutput & ({} | null)) | undefined;
|
|
79
79
|
params?: (TParams & ({} | null)) | undefined;
|
|
80
80
|
query?: (TQuery & ({} | null)) | undefined;
|
|
81
81
|
body?: (TBody & ({} | null)) | undefined;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { PackageJson } from 'type-fest';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VovkOutputConfig, VovkReadmeConfig, VovkSamplesConfig, VovkSchema } from '../types';
|
|
3
3
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
4
4
|
export declare function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle, projectPackageJson, }: {
|
|
5
5
|
schema: VovkSchema;
|
|
6
|
-
configs?:
|
|
6
|
+
configs?: VovkOutputConfig[];
|
|
7
7
|
segmentName: string | null;
|
|
8
8
|
isBundle?: boolean;
|
|
9
9
|
projectPackageJson?: PackageJson;
|
|
@@ -13,6 +13,6 @@ export declare function resolveGeneratorConfigValues({ schema, configs, segmentN
|
|
|
13
13
|
samples: VovkSamplesConfig;
|
|
14
14
|
origin: string;
|
|
15
15
|
package: PackageJson;
|
|
16
|
-
imports:
|
|
17
|
-
reExports:
|
|
16
|
+
imports: VovkOutputConfig['imports'];
|
|
17
|
+
reExports: VovkOutputConfig['reExports'];
|
|
18
18
|
};
|
|
@@ -27,8 +27,8 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
27
27
|
types: './openapi.d.cts',
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
|
-
}, projectPackageJson, schema.meta?.config?.
|
|
31
|
-
? schema.meta?.config?.
|
|
30
|
+
}, projectPackageJson, schema.meta?.config?.outputConfig?.package, isBundle ? schema.meta?.config?.bundle?.outputConfig?.package : undefined, typeof segmentName === 'string' ? schema.segments?.[segmentName]?.meta?.package : undefined, typeof segmentName === 'string'
|
|
31
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.package
|
|
32
32
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.package), {}));
|
|
33
33
|
return {
|
|
34
34
|
package: Object.fromEntries(Object.entries(packageJson).filter(([key]) => ['name', 'version', 'description', 'license', 'authors', 'repository', 'homepage', 'bugs', 'keywords'].includes(key))),
|
|
@@ -39,21 +39,21 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
39
39
|
version: packageJson.version,
|
|
40
40
|
description: packageJson.description,
|
|
41
41
|
},
|
|
42
|
-
}, schema.meta?.config?.
|
|
43
|
-
? schema.meta?.config?.
|
|
42
|
+
}, schema.meta?.config?.outputConfig?.openAPIObject, isBundle ? schema.meta?.config?.bundle?.outputConfig?.openAPIObject : undefined, typeof segmentName === 'string' ? schema?.segments?.[segmentName]?.meta?.openAPIObject : undefined, typeof segmentName === 'string'
|
|
43
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.openAPIObject
|
|
44
44
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.openAPIObject), {})),
|
|
45
|
-
samples: (0, deepExtend_1.default)({}, schema.meta?.config?.
|
|
46
|
-
? schema.meta?.config?.
|
|
45
|
+
samples: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.samples, isBundle ? schema.meta?.config?.bundle?.outputConfig?.samples : undefined, typeof segmentName === 'string'
|
|
46
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.samples
|
|
47
47
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.samples), {})),
|
|
48
|
-
readme: (0, deepExtend_1.default)({}, schema.meta?.config?.
|
|
49
|
-
? schema.meta?.config?.
|
|
48
|
+
readme: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.readme, isBundle ? schema.meta?.config?.bundle?.outputConfig?.readme : undefined, typeof segmentName === 'string'
|
|
49
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.readme
|
|
50
50
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.readme), {})),
|
|
51
51
|
origin: [
|
|
52
|
-
isBundle ? schema.meta?.config?.bundle?.
|
|
52
|
+
isBundle ? schema.meta?.config?.bundle?.outputConfig?.origin : undefined,
|
|
53
53
|
typeof segmentName === 'string'
|
|
54
|
-
? schema.meta?.config?.
|
|
54
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.origin
|
|
55
55
|
: undefined,
|
|
56
|
-
schema.meta?.config?.
|
|
56
|
+
schema.meta?.config?.outputConfig?.origin,
|
|
57
57
|
...(configs?.map((config) => config.origin) ?? []),
|
|
58
58
|
]
|
|
59
59
|
.filter(Boolean)
|
|
@@ -64,19 +64,19 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
64
64
|
fetcher: ['vovk'],
|
|
65
65
|
validateOnClient: null,
|
|
66
66
|
createRPC: ['vovk'],
|
|
67
|
-
}, schema.meta?.config?.
|
|
68
|
-
? schema.meta?.config?.
|
|
67
|
+
}, schema.meta?.config?.outputConfig?.imports, isBundle ? schema.meta?.config?.bundle?.outputConfig?.imports : undefined, typeof segmentName === 'string'
|
|
68
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.imports
|
|
69
69
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.imports), {})),
|
|
70
70
|
reExports: (0, deepExtend_1.default)(
|
|
71
71
|
// segmentName can be an empty string (for the root segment) and null (for composed clients)
|
|
72
72
|
// therefore, !segmentName indicates that this either a composed client or a root segment of a segmented client
|
|
73
|
-
{}, !segmentName && schema.meta?.config?.
|
|
73
|
+
{}, !segmentName && schema.meta?.config?.outputConfig?.reExports, !segmentName && isBundle ? schema.meta?.config?.bundle?.outputConfig?.reExports : undefined,
|
|
74
74
|
// for segmented client, apply all reExports from all segments
|
|
75
75
|
typeof segmentName !== 'string' &&
|
|
76
|
-
Object.values(schema.meta?.config?.
|
|
76
|
+
Object.values(schema.meta?.config?.outputConfig?.segments ?? {}).reduce((acc, segmentConfig) => (0, deepExtend_1.default)(acc, segmentConfig.reExports ?? {}), {}),
|
|
77
77
|
// for a specific segment, apply reExports from that segment
|
|
78
78
|
typeof segmentName === 'string'
|
|
79
|
-
? schema.meta?.config?.
|
|
79
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.reExports
|
|
80
80
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.reExports), {})),
|
|
81
81
|
};
|
|
82
82
|
}
|
|
@@ -4,22 +4,22 @@ type Meta = {
|
|
|
4
4
|
__disableClientValidation?: boolean;
|
|
5
5
|
[key: string]: KnownAny;
|
|
6
6
|
};
|
|
7
|
-
export declare function withValidationLibrary<T extends VovkTypedMethod<(req: KnownAny, params: KnownAny) => KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, boolean>,
|
|
8
|
-
isForm:
|
|
7
|
+
export declare function withValidationLibrary<T extends VovkTypedMethod<(req: KnownAny, params: KnownAny) => KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, boolean>, TBodyModel, TQueryModel, TParamsModel, TOutputModel, TIterationModel, TIsForm extends boolean = false>({ isForm, disableServerSideValidation, skipSchemaEmission, validateEachIteration, body, query, params, output, iteration, handle, toJSONSchema, validate, preferTransformed, operationObject, }: {
|
|
8
|
+
isForm: TIsForm | undefined;
|
|
9
9
|
disableServerSideValidation: boolean | VovkValidationType[] | undefined;
|
|
10
10
|
skipSchemaEmission: boolean | VovkValidationType[] | undefined;
|
|
11
11
|
validateEachIteration: boolean | undefined;
|
|
12
|
-
body:
|
|
13
|
-
query:
|
|
14
|
-
params:
|
|
15
|
-
output:
|
|
16
|
-
iteration:
|
|
12
|
+
body: TBodyModel | undefined;
|
|
13
|
+
query: TQueryModel | undefined;
|
|
14
|
+
params: TParamsModel | undefined;
|
|
15
|
+
output: TOutputModel | undefined;
|
|
16
|
+
iteration: TIterationModel | undefined;
|
|
17
17
|
handle: T;
|
|
18
18
|
toJSONSchema: ((model: KnownAny, // performance concern
|
|
19
19
|
meta: {
|
|
20
20
|
type: VovkValidationType;
|
|
21
21
|
}) => KnownAny) | undefined;
|
|
22
|
-
validate: (data: KnownAny, model: NonNullable<
|
|
22
|
+
validate: (data: KnownAny, model: NonNullable<TBodyModel | TQueryModel | TParamsModel | TOutputModel | TIterationModel>, meta: {
|
|
23
23
|
type: VovkValidationType | 'form';
|
|
24
24
|
req: VovkRequestAny;
|
|
25
25
|
status?: number;
|
|
@@ -32,47 +32,47 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
|
|
|
32
32
|
wrapper?: (req: VovkRequestAny, params: Parameters<T>[1]) => ReturnType<T>;
|
|
33
33
|
} & {
|
|
34
34
|
fn: {
|
|
35
|
-
<
|
|
35
|
+
<TReturnType = ReturnType<T>>(input?: (undefined extends TBodyModel | undefined ? undefined extends TQueryModel | undefined ? undefined extends TParamsModel | undefined ? true : false : false : false) extends true ? {
|
|
36
36
|
disableClientValidation?: boolean;
|
|
37
|
-
} & (undefined extends
|
|
37
|
+
} & (undefined extends TBodyModel | undefined ? {
|
|
38
38
|
body?: T["__types"]["body"];
|
|
39
39
|
} : {
|
|
40
40
|
body: T["__types"]["body"];
|
|
41
|
-
}) & (undefined extends
|
|
41
|
+
}) & (undefined extends TQueryModel | undefined ? {
|
|
42
42
|
query?: T["__types"]["query"];
|
|
43
43
|
} : {
|
|
44
44
|
query: T["__types"]["query"];
|
|
45
|
-
}) & (undefined extends
|
|
45
|
+
}) & (undefined extends TParamsModel | undefined ? {
|
|
46
46
|
params?: T["__types"]["params"];
|
|
47
47
|
} : {
|
|
48
48
|
params: T["__types"]["params"];
|
|
49
49
|
}) & {
|
|
50
50
|
meta?: Meta;
|
|
51
|
-
} : never): (undefined extends
|
|
52
|
-
<
|
|
51
|
+
} : never): (undefined extends TBodyModel | undefined ? undefined extends TQueryModel | undefined ? undefined extends TParamsModel | undefined ? true : false : false : false) extends true ? TReturnType : never;
|
|
52
|
+
<TReturnType = ReturnType<T>>(input: {
|
|
53
53
|
disableClientValidation?: boolean;
|
|
54
|
-
} & (undefined extends
|
|
54
|
+
} & (undefined extends TBodyModel | undefined ? {
|
|
55
55
|
body?: T["__types"]["body"];
|
|
56
56
|
} : {
|
|
57
57
|
body: T["__types"]["body"];
|
|
58
|
-
}) & (undefined extends
|
|
58
|
+
}) & (undefined extends TQueryModel | undefined ? {
|
|
59
59
|
query?: T["__types"]["query"];
|
|
60
60
|
} : {
|
|
61
61
|
query: T["__types"]["query"];
|
|
62
|
-
}) & (undefined extends
|
|
62
|
+
}) & (undefined extends TParamsModel | undefined ? {
|
|
63
63
|
params?: T["__types"]["params"];
|
|
64
64
|
} : {
|
|
65
65
|
params: T["__types"]["params"];
|
|
66
66
|
}) & {
|
|
67
67
|
meta?: Meta;
|
|
68
|
-
}):
|
|
68
|
+
}): TReturnType;
|
|
69
69
|
};
|
|
70
70
|
models: {
|
|
71
|
-
iteration?: (
|
|
72
|
-
output?: (
|
|
73
|
-
params?: (
|
|
74
|
-
query?: (
|
|
75
|
-
body?: (
|
|
71
|
+
iteration?: (TIterationModel & ({} | null)) | undefined;
|
|
72
|
+
output?: (TOutputModel & ({} | null)) | undefined;
|
|
73
|
+
params?: (TParamsModel & ({} | null)) | undefined;
|
|
74
|
+
query?: (TQueryModel & ({} | null)) | undefined;
|
|
75
|
+
body?: (TBodyModel & ({} | null)) | undefined;
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
78
|
export {};
|
package/mjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createVovkApp } from './createVovkApp';
|
|
2
|
-
import { HttpStatus, HttpMethod, VovkSchemaIdEnum, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkOutput, type VovkIteration, type VovkMetaSchema, type VovkSegmentSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type
|
|
2
|
+
import { HttpStatus, HttpMethod, VovkSchemaIdEnum, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkOutput, type VovkIteration, type VovkMetaSchema, type VovkSegmentSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkOutputConfig, type VovkReadmeConfig, type VovkSamplesConfig, type VovkPackageJson, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkStrictConfig, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject } from './types';
|
|
3
3
|
import { type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkValidateOnClient, type VovkStreamAsyncIterable, createRPC, fetcher, createFetcher, progressive } from './client';
|
|
4
4
|
import { operation, openAPIToVovkSchema, vovkSchemaToOpenAPI } from './openapi';
|
|
5
5
|
import { HttpException } from './HttpException';
|
|
@@ -13,7 +13,7 @@ import { createLLMTools } from './utils/createLLMTools';
|
|
|
13
13
|
import { createCodeSamples } from './utils/createCodeSamples';
|
|
14
14
|
import { createValidateOnClient } from './utils/createValidateOnClient';
|
|
15
15
|
import { resolveGeneratorConfigValues } from './utils/resolveGeneratorConfigValues';
|
|
16
|
-
export { type KnownAny, type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkOutput, type VovkIteration, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkMetaSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkStrictConfig, type
|
|
16
|
+
export { type KnownAny, type VovkRPCModule, type VovkFetcher, type VovkFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSegmentSchema, type VovkErrorResponse, type VovkRequest, type VovkOutput, type VovkIteration, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkMetaSchema, type VovkControllerSchema, type VovkHandlerSchema, type VovkSchema, type VovkConfig, type VovkStrictConfig, type VovkOutputConfig, type VovkPackageJson, type VovkReadmeConfig, type VovkSamplesConfig, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject, VovkSchemaIdEnum, JSONLinesResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, createRPC, fetcher, createFetcher, generateStaticAPI, withValidationLibrary, createStandardValidation, multitenant, createLLMTools, createCodeSamples, createValidateOnClient, progressive, operation, openAPIToVovkSchema, vovkSchemaToOpenAPI, resolveGeneratorConfigValues, };
|
|
17
17
|
export declare const get: {
|
|
18
18
|
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): (givenTarget: KnownAny, propertyKey: string) => void;
|
|
19
19
|
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import { type VovkSchema, type
|
|
2
|
+
import { type VovkSchema, type VovkOutputConfig } from '../types';
|
|
3
3
|
export declare function vovkSchemaToOpenAPI({ rootEntry, schema: fullSchema, configs, segmentName: givenSegmentName, }: {
|
|
4
4
|
rootEntry?: string;
|
|
5
5
|
schema: VovkSchema;
|
|
6
|
-
configs?:
|
|
6
|
+
configs?: VovkOutputConfig[];
|
|
7
7
|
segmentName?: string;
|
|
8
8
|
}): OpenAPIObject;
|
package/mjs/types.d.ts
CHANGED
|
@@ -129,14 +129,14 @@ export type ControllerStaticMethod<REQ extends VovkRequest<KnownAny, KnownAny, K
|
|
|
129
129
|
} = KnownAny> = ((req: REQ, params: TParams) => unknown) & {
|
|
130
130
|
_controller?: VovkController;
|
|
131
131
|
};
|
|
132
|
-
export type VovkTypedMethod<T extends (...args: KnownAny[]) => KnownAny, B = KnownAny, Q = KnownAny, P = KnownAny, O = KnownAny, I = KnownAny,
|
|
132
|
+
export type VovkTypedMethod<T extends (...args: KnownAny[]) => KnownAny, B = KnownAny, Q = KnownAny, P = KnownAny, O = KnownAny, I = KnownAny, TIsForm extends boolean = false> = T & {
|
|
133
133
|
__types: {
|
|
134
134
|
body: B;
|
|
135
135
|
query: Q;
|
|
136
136
|
params: P;
|
|
137
137
|
output: O;
|
|
138
138
|
iteration: I;
|
|
139
|
-
isForm:
|
|
139
|
+
isForm: TIsForm;
|
|
140
140
|
};
|
|
141
141
|
isRPC?: boolean;
|
|
142
142
|
};
|
|
@@ -352,7 +352,7 @@ type BundleConfig = {
|
|
|
352
352
|
prebundleDir: string;
|
|
353
353
|
entry: string;
|
|
354
354
|
}) => Promise<void>;
|
|
355
|
-
|
|
355
|
+
outputConfig?: VovkOutputConfig<GeneratorConfigImports>;
|
|
356
356
|
} & ({
|
|
357
357
|
excludeSegments?: never;
|
|
358
358
|
includeSegments?: string[];
|
|
@@ -369,7 +369,7 @@ type SegmentConfigImports = {
|
|
|
369
369
|
fetcher?: string | [string, string] | [string];
|
|
370
370
|
validateOnClient?: string | [string, string] | [string] | null;
|
|
371
371
|
};
|
|
372
|
-
export interface
|
|
372
|
+
export interface VovkOutputConfig<TImports extends GeneratorConfigImports = GeneratorConfigImports> {
|
|
373
373
|
origin?: string | null;
|
|
374
374
|
package?: VovkPackageJson;
|
|
375
375
|
readme?: VovkReadmeConfig;
|
|
@@ -384,7 +384,7 @@ export type ClientTemplateDef = {
|
|
|
384
384
|
composedClient?: Omit<ClientConfigComposed, 'fromTemplates' | 'enabled'>;
|
|
385
385
|
segmentedClient?: Omit<ClientConfigSegmented, 'fromTemplates' | 'enabled'>;
|
|
386
386
|
requires?: Record<string, string>;
|
|
387
|
-
|
|
387
|
+
outputConfig?: VovkOutputConfig<GeneratorConfigImports>;
|
|
388
388
|
};
|
|
389
389
|
export type GetOpenAPINameFn = (config: {
|
|
390
390
|
operationObject: VovkOperationObject;
|
|
@@ -416,7 +416,7 @@ export interface VovkOpenAPIMixinNormalized extends Omit<VovkOpenAPIMixin, 'sour
|
|
|
416
416
|
getMethodName: GetOpenAPINameFn;
|
|
417
417
|
getModuleName: GetOpenAPINameFn;
|
|
418
418
|
}
|
|
419
|
-
export interface VovkSegmentConfig extends
|
|
419
|
+
export interface VovkSegmentConfig extends VovkOutputConfig<SegmentConfigImports> {
|
|
420
420
|
rootEntry?: string;
|
|
421
421
|
segmentNameOverride?: string;
|
|
422
422
|
openAPIMixin?: VovkOpenAPIMixin;
|
|
@@ -443,7 +443,7 @@ type VovkUserConfig = {
|
|
|
443
443
|
controller?: string;
|
|
444
444
|
[key: string]: string | undefined;
|
|
445
445
|
};
|
|
446
|
-
|
|
446
|
+
outputConfig?: VovkOutputConfig<GeneratorConfigImports> & {
|
|
447
447
|
segments?: Record<string, VovkSegmentConfig>;
|
|
448
448
|
};
|
|
449
449
|
};
|
|
@@ -454,7 +454,7 @@ export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'emitConfig' | 'lib
|
|
|
454
454
|
libs: Record<string, KnownAny>;
|
|
455
455
|
composedClient: RequireFields<ClientConfigComposed, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
|
|
456
456
|
segmentedClient: RequireFields<ClientConfigSegmented, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
|
|
457
|
-
|
|
457
|
+
outputConfig: VovkOutputConfig<GeneratorConfigImports> & {
|
|
458
458
|
segments?: Record<string, Omit<VovkSegmentConfig, 'openAPIMixin'> & {
|
|
459
459
|
openAPIMixin?: VovkOpenAPIMixinNormalized;
|
|
460
460
|
}>;
|
|
@@ -4,13 +4,13 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
4
4
|
toJSONSchema: (model: KnownAny, meta: {
|
|
5
5
|
type: VovkValidationType;
|
|
6
6
|
}) => KnownAny;
|
|
7
|
-
}): <T extends (req:
|
|
8
|
-
isForm?:
|
|
7
|
+
}): <T extends (req: TReq, params: TParams extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TParams> : Record<string, string>) => KnownAny, TBody extends StandardSchemaV1, TQuery extends StandardSchemaV1, TParams extends StandardSchemaV1, TOutput extends StandardSchemaV1, TIteration extends StandardSchemaV1, TReq extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : undefined, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : undefined, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : undefined>, TIsForm extends boolean = false>({ isForm, body, query, params, output, iteration, handle, disableServerSideValidation, skipSchemaEmission, validateEachIteration, preferTransformed, operationObject, }: {
|
|
8
|
+
isForm?: TIsForm;
|
|
9
9
|
body?: TBody;
|
|
10
10
|
query?: TQuery;
|
|
11
11
|
params?: TParams;
|
|
12
|
-
output?:
|
|
13
|
-
iteration?:
|
|
12
|
+
output?: TOutput;
|
|
13
|
+
iteration?: TIteration;
|
|
14
14
|
handle: T;
|
|
15
15
|
disableServerSideValidation?: boolean | VovkValidationType[];
|
|
16
16
|
skipSchemaEmission?: boolean | VovkValidationType[];
|
|
@@ -22,60 +22,60 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
22
22
|
body: TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any;
|
|
23
23
|
query: TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any;
|
|
24
24
|
params: TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any;
|
|
25
|
-
output:
|
|
26
|
-
iteration:
|
|
27
|
-
isForm:
|
|
25
|
+
output: TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any;
|
|
26
|
+
iteration: TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any;
|
|
27
|
+
isForm: TIsForm;
|
|
28
28
|
};
|
|
29
29
|
isRPC?: boolean;
|
|
30
30
|
} & {
|
|
31
31
|
schema: Omit<import("../types").VovkHandlerSchema, "httpMethod" | "path"> & Partial<import("../types").VovkHandlerSchema>;
|
|
32
|
-
wrapper?: ((req: VovkRequest<any, any, any>, params: Parameters<VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
32
|
+
wrapper?: ((req: VovkRequest<any, any, any>, params: Parameters<VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>>[1]) => ReturnType<VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>>) | undefined;
|
|
33
33
|
} & {
|
|
34
34
|
fn: {
|
|
35
|
-
<
|
|
35
|
+
<TReturnType = ReturnType<VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>>>(input?: ((undefined extends TBody | undefined ? undefined extends TQuery | undefined ? undefined extends TParams | undefined ? true : false : false : false) extends true ? {
|
|
36
36
|
disableClientValidation?: boolean;
|
|
37
37
|
} & (undefined extends TBody | undefined ? {
|
|
38
|
-
body?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
38
|
+
body?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["body"] | undefined;
|
|
39
39
|
} : {
|
|
40
|
-
body: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
40
|
+
body: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["body"];
|
|
41
41
|
}) & (undefined extends TQuery | undefined ? {
|
|
42
|
-
query?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
42
|
+
query?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["query"] | undefined;
|
|
43
43
|
} : {
|
|
44
|
-
query: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
44
|
+
query: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["query"];
|
|
45
45
|
}) & (undefined extends TParams | undefined ? {
|
|
46
|
-
params?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
46
|
+
params?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["params"] | undefined;
|
|
47
47
|
} : {
|
|
48
|
-
params: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
48
|
+
params: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["params"];
|
|
49
49
|
}) & {
|
|
50
50
|
meta?: {
|
|
51
51
|
[key: string]: any;
|
|
52
52
|
__disableClientValidation?: boolean;
|
|
53
53
|
};
|
|
54
|
-
} : never) | undefined): (undefined extends TBody | undefined ? undefined extends TQuery | undefined ? undefined extends TParams | undefined ? true : false : false : false) extends true ?
|
|
55
|
-
<
|
|
54
|
+
} : never) | undefined): (undefined extends TBody | undefined ? undefined extends TQuery | undefined ? undefined extends TParams | undefined ? true : false : false : false) extends true ? TReturnType : never;
|
|
55
|
+
<TReturnType = ReturnType<VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>>>(input: {
|
|
56
56
|
disableClientValidation?: boolean;
|
|
57
57
|
} & (undefined extends TBody | undefined ? {
|
|
58
|
-
body?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
58
|
+
body?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["body"] | undefined;
|
|
59
59
|
} : {
|
|
60
|
-
body: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
60
|
+
body: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["body"];
|
|
61
61
|
}) & (undefined extends TQuery | undefined ? {
|
|
62
|
-
query?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
62
|
+
query?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["query"] | undefined;
|
|
63
63
|
} : {
|
|
64
|
-
query: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
64
|
+
query: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["query"];
|
|
65
65
|
}) & (undefined extends TParams | undefined ? {
|
|
66
|
-
params?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
66
|
+
params?: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["params"] | undefined;
|
|
67
67
|
} : {
|
|
68
|
-
params: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any,
|
|
68
|
+
params: VovkTypedMethod<T, TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any, TOutput extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TOutput> : any, TIteration extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TIteration> : any, TIsForm>["__types"]["params"];
|
|
69
69
|
}) & {
|
|
70
70
|
meta?: {
|
|
71
71
|
[key: string]: any;
|
|
72
72
|
__disableClientValidation?: boolean;
|
|
73
73
|
};
|
|
74
|
-
}):
|
|
74
|
+
}): TReturnType;
|
|
75
75
|
};
|
|
76
76
|
models: {
|
|
77
|
-
iteration?: (
|
|
78
|
-
output?: (
|
|
77
|
+
iteration?: (TIteration & ({} | null)) | undefined;
|
|
78
|
+
output?: (TOutput & ({} | null)) | undefined;
|
|
79
79
|
params?: (TParams & ({} | null)) | undefined;
|
|
80
80
|
query?: (TQuery & ({} | null)) | undefined;
|
|
81
81
|
body?: (TBody & ({} | null)) | undefined;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { PackageJson } from 'type-fest';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VovkOutputConfig, VovkReadmeConfig, VovkSamplesConfig, VovkSchema } from '../types';
|
|
3
3
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
4
4
|
export declare function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle, projectPackageJson, }: {
|
|
5
5
|
schema: VovkSchema;
|
|
6
|
-
configs?:
|
|
6
|
+
configs?: VovkOutputConfig[];
|
|
7
7
|
segmentName: string | null;
|
|
8
8
|
isBundle?: boolean;
|
|
9
9
|
projectPackageJson?: PackageJson;
|
|
@@ -13,6 +13,6 @@ export declare function resolveGeneratorConfigValues({ schema, configs, segmentN
|
|
|
13
13
|
samples: VovkSamplesConfig;
|
|
14
14
|
origin: string;
|
|
15
15
|
package: PackageJson;
|
|
16
|
-
imports:
|
|
17
|
-
reExports:
|
|
16
|
+
imports: VovkOutputConfig['imports'];
|
|
17
|
+
reExports: VovkOutputConfig['reExports'];
|
|
18
18
|
};
|
|
@@ -27,8 +27,8 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
27
27
|
types: './openapi.d.cts',
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
|
-
}, projectPackageJson, schema.meta?.config?.
|
|
31
|
-
? schema.meta?.config?.
|
|
30
|
+
}, projectPackageJson, schema.meta?.config?.outputConfig?.package, isBundle ? schema.meta?.config?.bundle?.outputConfig?.package : undefined, typeof segmentName === 'string' ? schema.segments?.[segmentName]?.meta?.package : undefined, typeof segmentName === 'string'
|
|
31
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.package
|
|
32
32
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.package), {}));
|
|
33
33
|
return {
|
|
34
34
|
package: Object.fromEntries(Object.entries(packageJson).filter(([key]) => ['name', 'version', 'description', 'license', 'authors', 'repository', 'homepage', 'bugs', 'keywords'].includes(key))),
|
|
@@ -39,21 +39,21 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
39
39
|
version: packageJson.version,
|
|
40
40
|
description: packageJson.description,
|
|
41
41
|
},
|
|
42
|
-
}, schema.meta?.config?.
|
|
43
|
-
? schema.meta?.config?.
|
|
42
|
+
}, schema.meta?.config?.outputConfig?.openAPIObject, isBundle ? schema.meta?.config?.bundle?.outputConfig?.openAPIObject : undefined, typeof segmentName === 'string' ? schema?.segments?.[segmentName]?.meta?.openAPIObject : undefined, typeof segmentName === 'string'
|
|
43
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.openAPIObject
|
|
44
44
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.openAPIObject), {})),
|
|
45
|
-
samples: (0, deepExtend_1.default)({}, schema.meta?.config?.
|
|
46
|
-
? schema.meta?.config?.
|
|
45
|
+
samples: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.samples, isBundle ? schema.meta?.config?.bundle?.outputConfig?.samples : undefined, typeof segmentName === 'string'
|
|
46
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.samples
|
|
47
47
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.samples), {})),
|
|
48
|
-
readme: (0, deepExtend_1.default)({}, schema.meta?.config?.
|
|
49
|
-
? schema.meta?.config?.
|
|
48
|
+
readme: (0, deepExtend_1.default)({}, schema.meta?.config?.outputConfig?.readme, isBundle ? schema.meta?.config?.bundle?.outputConfig?.readme : undefined, typeof segmentName === 'string'
|
|
49
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.readme
|
|
50
50
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.readme), {})),
|
|
51
51
|
origin: [
|
|
52
|
-
isBundle ? schema.meta?.config?.bundle?.
|
|
52
|
+
isBundle ? schema.meta?.config?.bundle?.outputConfig?.origin : undefined,
|
|
53
53
|
typeof segmentName === 'string'
|
|
54
|
-
? schema.meta?.config?.
|
|
54
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.origin
|
|
55
55
|
: undefined,
|
|
56
|
-
schema.meta?.config?.
|
|
56
|
+
schema.meta?.config?.outputConfig?.origin,
|
|
57
57
|
...(configs?.map((config) => config.origin) ?? []),
|
|
58
58
|
]
|
|
59
59
|
.filter(Boolean)
|
|
@@ -64,19 +64,19 @@ function resolveGeneratorConfigValues({ schema, configs, segmentName, isBundle,
|
|
|
64
64
|
fetcher: ['vovk'],
|
|
65
65
|
validateOnClient: null,
|
|
66
66
|
createRPC: ['vovk'],
|
|
67
|
-
}, schema.meta?.config?.
|
|
68
|
-
? schema.meta?.config?.
|
|
67
|
+
}, schema.meta?.config?.outputConfig?.imports, isBundle ? schema.meta?.config?.bundle?.outputConfig?.imports : undefined, typeof segmentName === 'string'
|
|
68
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.imports
|
|
69
69
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.imports), {})),
|
|
70
70
|
reExports: (0, deepExtend_1.default)(
|
|
71
71
|
// segmentName can be an empty string (for the root segment) and null (for composed clients)
|
|
72
72
|
// therefore, !segmentName indicates that this either a composed client or a root segment of a segmented client
|
|
73
|
-
{}, !segmentName && schema.meta?.config?.
|
|
73
|
+
{}, !segmentName && schema.meta?.config?.outputConfig?.reExports, !segmentName && isBundle ? schema.meta?.config?.bundle?.outputConfig?.reExports : undefined,
|
|
74
74
|
// for segmented client, apply all reExports from all segments
|
|
75
75
|
typeof segmentName !== 'string' &&
|
|
76
|
-
Object.values(schema.meta?.config?.
|
|
76
|
+
Object.values(schema.meta?.config?.outputConfig?.segments ?? {}).reduce((acc, segmentConfig) => (0, deepExtend_1.default)(acc, segmentConfig.reExports ?? {}), {}),
|
|
77
77
|
// for a specific segment, apply reExports from that segment
|
|
78
78
|
typeof segmentName === 'string'
|
|
79
|
-
? schema.meta?.config?.
|
|
79
|
+
? schema.meta?.config?.outputConfig?.segments?.[segmentName]?.reExports
|
|
80
80
|
: undefined, configs?.reduce((acc, config) => (0, deepExtend_1.default)(acc, config.reExports), {})),
|
|
81
81
|
};
|
|
82
82
|
}
|
|
@@ -4,22 +4,22 @@ type Meta = {
|
|
|
4
4
|
__disableClientValidation?: boolean;
|
|
5
5
|
[key: string]: KnownAny;
|
|
6
6
|
};
|
|
7
|
-
export declare function withValidationLibrary<T extends VovkTypedMethod<(req: KnownAny, params: KnownAny) => KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, boolean>,
|
|
8
|
-
isForm:
|
|
7
|
+
export declare function withValidationLibrary<T extends VovkTypedMethod<(req: KnownAny, params: KnownAny) => KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, boolean>, TBodyModel, TQueryModel, TParamsModel, TOutputModel, TIterationModel, TIsForm extends boolean = false>({ isForm, disableServerSideValidation, skipSchemaEmission, validateEachIteration, body, query, params, output, iteration, handle, toJSONSchema, validate, preferTransformed, operationObject, }: {
|
|
8
|
+
isForm: TIsForm | undefined;
|
|
9
9
|
disableServerSideValidation: boolean | VovkValidationType[] | undefined;
|
|
10
10
|
skipSchemaEmission: boolean | VovkValidationType[] | undefined;
|
|
11
11
|
validateEachIteration: boolean | undefined;
|
|
12
|
-
body:
|
|
13
|
-
query:
|
|
14
|
-
params:
|
|
15
|
-
output:
|
|
16
|
-
iteration:
|
|
12
|
+
body: TBodyModel | undefined;
|
|
13
|
+
query: TQueryModel | undefined;
|
|
14
|
+
params: TParamsModel | undefined;
|
|
15
|
+
output: TOutputModel | undefined;
|
|
16
|
+
iteration: TIterationModel | undefined;
|
|
17
17
|
handle: T;
|
|
18
18
|
toJSONSchema: ((model: KnownAny, // performance concern
|
|
19
19
|
meta: {
|
|
20
20
|
type: VovkValidationType;
|
|
21
21
|
}) => KnownAny) | undefined;
|
|
22
|
-
validate: (data: KnownAny, model: NonNullable<
|
|
22
|
+
validate: (data: KnownAny, model: NonNullable<TBodyModel | TQueryModel | TParamsModel | TOutputModel | TIterationModel>, meta: {
|
|
23
23
|
type: VovkValidationType | 'form';
|
|
24
24
|
req: VovkRequestAny;
|
|
25
25
|
status?: number;
|
|
@@ -32,47 +32,47 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
|
|
|
32
32
|
wrapper?: (req: VovkRequestAny, params: Parameters<T>[1]) => ReturnType<T>;
|
|
33
33
|
} & {
|
|
34
34
|
fn: {
|
|
35
|
-
<
|
|
35
|
+
<TReturnType = ReturnType<T>>(input?: (undefined extends TBodyModel | undefined ? undefined extends TQueryModel | undefined ? undefined extends TParamsModel | undefined ? true : false : false : false) extends true ? {
|
|
36
36
|
disableClientValidation?: boolean;
|
|
37
|
-
} & (undefined extends
|
|
37
|
+
} & (undefined extends TBodyModel | undefined ? {
|
|
38
38
|
body?: T["__types"]["body"];
|
|
39
39
|
} : {
|
|
40
40
|
body: T["__types"]["body"];
|
|
41
|
-
}) & (undefined extends
|
|
41
|
+
}) & (undefined extends TQueryModel | undefined ? {
|
|
42
42
|
query?: T["__types"]["query"];
|
|
43
43
|
} : {
|
|
44
44
|
query: T["__types"]["query"];
|
|
45
|
-
}) & (undefined extends
|
|
45
|
+
}) & (undefined extends TParamsModel | undefined ? {
|
|
46
46
|
params?: T["__types"]["params"];
|
|
47
47
|
} : {
|
|
48
48
|
params: T["__types"]["params"];
|
|
49
49
|
}) & {
|
|
50
50
|
meta?: Meta;
|
|
51
|
-
} : never): (undefined extends
|
|
52
|
-
<
|
|
51
|
+
} : never): (undefined extends TBodyModel | undefined ? undefined extends TQueryModel | undefined ? undefined extends TParamsModel | undefined ? true : false : false : false) extends true ? TReturnType : never;
|
|
52
|
+
<TReturnType = ReturnType<T>>(input: {
|
|
53
53
|
disableClientValidation?: boolean;
|
|
54
|
-
} & (undefined extends
|
|
54
|
+
} & (undefined extends TBodyModel | undefined ? {
|
|
55
55
|
body?: T["__types"]["body"];
|
|
56
56
|
} : {
|
|
57
57
|
body: T["__types"]["body"];
|
|
58
|
-
}) & (undefined extends
|
|
58
|
+
}) & (undefined extends TQueryModel | undefined ? {
|
|
59
59
|
query?: T["__types"]["query"];
|
|
60
60
|
} : {
|
|
61
61
|
query: T["__types"]["query"];
|
|
62
|
-
}) & (undefined extends
|
|
62
|
+
}) & (undefined extends TParamsModel | undefined ? {
|
|
63
63
|
params?: T["__types"]["params"];
|
|
64
64
|
} : {
|
|
65
65
|
params: T["__types"]["params"];
|
|
66
66
|
}) & {
|
|
67
67
|
meta?: Meta;
|
|
68
|
-
}):
|
|
68
|
+
}): TReturnType;
|
|
69
69
|
};
|
|
70
70
|
models: {
|
|
71
|
-
iteration?: (
|
|
72
|
-
output?: (
|
|
73
|
-
params?: (
|
|
74
|
-
query?: (
|
|
75
|
-
body?: (
|
|
71
|
+
iteration?: (TIterationModel & ({} | null)) | undefined;
|
|
72
|
+
output?: (TOutputModel & ({} | null)) | undefined;
|
|
73
|
+
params?: (TParamsModel & ({} | null)) | undefined;
|
|
74
|
+
query?: (TQueryModel & ({} | null)) | undefined;
|
|
75
|
+
body?: (TBodyModel & ({} | null)) | undefined;
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
78
|
export {};
|