vovk 3.0.0-draft.415 → 3.0.0-draft.417
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/client/createRPC.d.ts +4 -4
- package/cjs/client/fetcher.d.ts +7 -7
- package/cjs/client/index.d.ts +1 -1
- package/cjs/client/types.d.ts +12 -12
- package/cjs/index.d.ts +3 -3
- package/cjs/openapi/vovkSchemaToOpenAPI.d.ts +2 -2
- package/cjs/types.d.ts +47 -28
- package/cjs/types.js +3 -0
- package/cjs/utils/createStandardValidation.d.ts +32 -32
- package/cjs/utils/resolveGeneratorConfigValues.d.ts +4 -4
- package/cjs/utils/withValidationLibrary.d.ts +16 -16
- package/mjs/client/createRPC.d.ts +4 -4
- package/mjs/client/fetcher.d.ts +7 -7
- package/mjs/client/index.d.ts +1 -1
- package/mjs/client/types.d.ts +12 -12
- package/mjs/index.d.ts +3 -3
- package/mjs/openapi/vovkSchemaToOpenAPI.d.ts +2 -2
- package/mjs/types.d.ts +47 -28
- package/mjs/types.js +3 -0
- package/mjs/utils/createStandardValidation.d.ts +32 -32
- package/mjs/utils/resolveGeneratorConfigValues.d.ts +4 -4
- package/mjs/utils/withValidationLibrary.d.ts +16 -16
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { KnownAny } from '../types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const createRPC: <T, OPTS extends Record<string, KnownAny> = Record<string, never>>(givenSchema: unknown, segmentName: string, rpcModuleName: string, givenFetcher?:
|
|
4
|
-
fetcher:
|
|
5
|
-
}>, options?:
|
|
2
|
+
import type { VovkRPCModule, VovkFetcher, VovkFetcherOptions } from './types';
|
|
3
|
+
export declare const createRPC: <T, OPTS extends Record<string, KnownAny> = Record<string, never>>(givenSchema: unknown, segmentName: string, rpcModuleName: string, givenFetcher?: VovkFetcher<OPTS> | Promise<{
|
|
4
|
+
fetcher: VovkFetcher<OPTS>;
|
|
5
|
+
}>, options?: VovkFetcherOptions<OPTS>) => VovkRPCModule<T, OPTS>;
|
package/cjs/client/fetcher.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VovkFetcherOptions, VovkFetcher } from './types';
|
|
2
2
|
import { KnownAny } from '../types';
|
|
3
3
|
import { HttpException } from '../HttpException';
|
|
4
4
|
export declare const DEFAULT_ERROR_MESSAGE = "Unknown error at default fetcher";
|
|
5
5
|
export declare function createFetcher<T>({ prepareRequestInit, transformResponse, onSuccess, onError, }?: {
|
|
6
|
-
prepareRequestInit?: (init: RequestInit, options:
|
|
7
|
-
transformResponse?: (respData: KnownAny, options:
|
|
8
|
-
onSuccess?: (respData: KnownAny, options:
|
|
9
|
-
onError?: (error: HttpException, options:
|
|
10
|
-
}):
|
|
11
|
-
export declare const fetcher:
|
|
6
|
+
prepareRequestInit?: (init: RequestInit, options: VovkFetcherOptions<T>) => RequestInit | Promise<RequestInit>;
|
|
7
|
+
transformResponse?: (respData: KnownAny, options: VovkFetcherOptions<T>, response: Response, init: RequestInit) => unknown | Promise<unknown>;
|
|
8
|
+
onSuccess?: (respData: KnownAny, options: VovkFetcherOptions<T>, response: Response, init: RequestInit) => void | Promise<void>;
|
|
9
|
+
onError?: (error: HttpException, options: VovkFetcherOptions<T>, response: Response | null, init: RequestInit | null, respData: unknown | null) => void | Promise<void>;
|
|
10
|
+
}): VovkFetcher<VovkFetcherOptions<T>>;
|
|
11
|
+
export declare const fetcher: VovkFetcher<{
|
|
12
12
|
apiRoot?: string;
|
|
13
13
|
disableClientValidation?: boolean;
|
|
14
14
|
validateOnClient?: import("./types").VovkValidateOnClient<unknown> | Promise<{
|
package/cjs/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createRPC } from './createRPC';
|
|
2
2
|
export { fetcher, createFetcher } from './fetcher';
|
|
3
3
|
export { progressive } from './progressive';
|
|
4
|
-
export type {
|
|
4
|
+
export type { VovkRPCModule, VovkFetcher, VovkFetcherOptions, VovkValidateOnClient, VovkStreamAsyncIterable, } from './types';
|
package/cjs/client/types.d.ts
CHANGED
|
@@ -11,14 +11,14 @@ export type StaticMethodInput<T extends ((req: VovkRequest<KnownAny, KnownAny, K
|
|
|
11
11
|
__types?: {
|
|
12
12
|
isForm: boolean;
|
|
13
13
|
};
|
|
14
|
-
}> = OmitNullable<(Parameters<T>[0] extends VovkRequest<infer
|
|
14
|
+
}> = OmitNullable<(Parameters<T>[0] extends VovkRequest<infer TBody, infer TQuery, infer TParams> ? (TBody extends Record<KnownAny, KnownAny> ? {
|
|
15
15
|
body: T['__types'] extends {
|
|
16
16
|
isForm: true;
|
|
17
|
-
} ? FormData :
|
|
18
|
-
} : Empty) & (
|
|
19
|
-
query:
|
|
20
|
-
} : Empty) & (
|
|
21
|
-
params:
|
|
17
|
+
} ? FormData : TBody;
|
|
18
|
+
} : Empty) & (TQuery extends Record<KnownAny, KnownAny> ? {
|
|
19
|
+
query: TQuery;
|
|
20
|
+
} : Empty) & (TParams extends Record<KnownAny, KnownAny> ? {
|
|
21
|
+
params: TParams;
|
|
22
22
|
} : Empty) & {
|
|
23
23
|
meta?: {
|
|
24
24
|
[key: string]: KnownAny;
|
|
@@ -38,9 +38,9 @@ export type VovkStreamAsyncIterable<T> = {
|
|
|
38
38
|
};
|
|
39
39
|
type StaticMethodReturn<T extends ControllerStaticMethod> = ReturnType<T> extends NextResponse<infer U> | Promise<NextResponse<infer U>> ? U : ReturnType<T> extends Response | Promise<Response> ? Awaited<ReturnType<T>> : ReturnType<T>;
|
|
40
40
|
type StaticMethodReturnPromise<T extends ControllerStaticMethod> = ToPromise<StaticMethodReturn<T>>;
|
|
41
|
-
type StaticMethodOptions<T extends (req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<TStreamIteration> | Promise<JSONLinesResponse<TStreamIteration>>, TFetcherOptions extends Record<string, KnownAny>, TStreamIteration, R, F extends
|
|
41
|
+
type StaticMethodOptions<T extends (req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<TStreamIteration> | Promise<JSONLinesResponse<TStreamIteration>>, TFetcherOptions extends Record<string, KnownAny>, TStreamIteration, R, F extends VovkFetcherOptions<KnownAny>> = Partial<TFetcherOptions & {
|
|
42
42
|
transform: (staticMethodReturn: Awaited<StaticMethodReturn<T>>, resp: Response) => R;
|
|
43
|
-
fetcher:
|
|
43
|
+
fetcher: VovkFetcher<F>;
|
|
44
44
|
}>;
|
|
45
45
|
export type ClientMethodReturn<T extends (req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<TStreamIteration> | Promise<JSONLinesResponse<TStreamIteration>>, TStreamIteration, R> = ReturnType<T> extends Promise<JSONLinesResponse<infer U>> | JSONLinesResponse<infer U> | Iterator<infer U> | AsyncIterator<infer U> ? Promise<VovkStreamAsyncIterable<U>> : R extends object ? Promise<Awaited<R>> : StaticMethodReturnPromise<T>;
|
|
46
46
|
export type ClientMethod<T extends ((req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<TStreamIteration> | Promise<JSONLinesResponse<TStreamIteration>>) & {
|
|
@@ -52,7 +52,7 @@ export type ClientMethod<T extends ((req: VovkRequest<KnownAny, KnownAny, KnownA
|
|
|
52
52
|
iteration: KnownAny;
|
|
53
53
|
isForm: boolean;
|
|
54
54
|
};
|
|
55
|
-
}, TFetcherOptions extends Record<string, KnownAny>, TStreamIteration extends KnownAny = unknown> = (IsEmptyObject<StaticMethodInput<T>> extends true ? <R, F extends
|
|
55
|
+
}, TFetcherOptions extends Record<string, KnownAny>, TStreamIteration extends KnownAny = unknown> = (IsEmptyObject<StaticMethodInput<T>> extends true ? <R, F extends VovkFetcherOptions<KnownAny> = VovkFetcherOptions<TFetcherOptions>>(options?: Prettify<StaticMethodOptions<T, TFetcherOptions, TStreamIteration, R, F>>) => ClientMethodReturn<T, TStreamIteration, R> : <R, F extends VovkFetcherOptions<KnownAny> = VovkFetcherOptions<TFetcherOptions>>(options: Prettify<StaticMethodInput<T> & StaticMethodOptions<T, TFetcherOptions, TStreamIteration, R, F>>) => ClientMethodReturn<T, TStreamIteration, R>) & {
|
|
56
56
|
isRPC: true;
|
|
57
57
|
schema: VovkHandlerSchema;
|
|
58
58
|
controllerSchema: VovkControllerSchema;
|
|
@@ -70,10 +70,10 @@ type VovkClientWithNever<T, TFetcherOptions extends {
|
|
|
70
70
|
}> = {
|
|
71
71
|
[K in keyof T]: T[K] extends (...args: KnownAny) => KnownAny ? ClientMethod<T[K], TFetcherOptions> : never;
|
|
72
72
|
};
|
|
73
|
-
export type
|
|
73
|
+
export type VovkRPCModule<T, TFetcherOptions extends {
|
|
74
74
|
[key: string]: KnownAny;
|
|
75
75
|
}> = OmitNever<VovkClientWithNever<T, TFetcherOptions>>;
|
|
76
|
-
export type
|
|
76
|
+
export type VovkFetcher<TFetcherOptions> = (options: {
|
|
77
77
|
name: string;
|
|
78
78
|
httpMethod: HttpMethod;
|
|
79
79
|
getEndpoint: (data: {
|
|
@@ -98,7 +98,7 @@ export type VovkClientFetcher<TFetcherOptions> = (options: {
|
|
|
98
98
|
params?: unknown;
|
|
99
99
|
meta?: unknown;
|
|
100
100
|
} & TFetcherOptions) => Promise<[KnownAny, Response]>;
|
|
101
|
-
export type
|
|
101
|
+
export type VovkFetcherOptions<T> = T & {
|
|
102
102
|
apiRoot?: string;
|
|
103
103
|
disableClientValidation?: boolean;
|
|
104
104
|
validateOnClient?: VovkValidateOnClient<T> | Promise<{
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 VovkGeneratorConfig, type
|
|
3
|
-
import { 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 VovkGeneratorConfig, type VovkReadmeConfig, type VovkSamplesConfig, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkStrictConfig, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject } from './types';
|
|
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';
|
|
6
6
|
import { createDecorator } from './utils/createDecorator';
|
|
@@ -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
|
|
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 VovkGeneratorConfig, 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 VovkGeneratorConfig } 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?: VovkGeneratorConfig[];
|
|
7
7
|
segmentName?: string;
|
|
8
8
|
}): OpenAPIObject;
|
package/cjs/types.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ type VovkPackageJson = PackageJson & {
|
|
|
9
9
|
rs_name?: string;
|
|
10
10
|
py_name?: string;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Schema for an individual handler, available as MyRPC.myHandler.schema and MyController.myHandler.schema
|
|
14
|
+
*/
|
|
12
15
|
export type VovkHandlerSchema = {
|
|
13
16
|
path: string;
|
|
14
17
|
httpMethod: string;
|
|
@@ -22,6 +25,9 @@ export type VovkHandlerSchema = {
|
|
|
22
25
|
operationObject?: VovkOperationObject;
|
|
23
26
|
misc?: Record<string, KnownAny>;
|
|
24
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Represents the schema of a controller
|
|
30
|
+
*/
|
|
25
31
|
export type VovkControllerSchema = {
|
|
26
32
|
rpcModuleName: string;
|
|
27
33
|
originalControllerName?: string;
|
|
@@ -31,6 +37,9 @@ export type VovkControllerSchema = {
|
|
|
31
37
|
[key: string]: VovkHandlerSchema;
|
|
32
38
|
};
|
|
33
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Represents the schema of a segment
|
|
42
|
+
*/
|
|
34
43
|
export type VovkSegmentSchema = {
|
|
35
44
|
$schema: typeof VovkSchemaIdEnum.SEGMENT | (string & {});
|
|
36
45
|
emitSchema: boolean;
|
|
@@ -45,11 +54,17 @@ export type VovkSegmentSchema = {
|
|
|
45
54
|
package?: VovkPackageJson;
|
|
46
55
|
};
|
|
47
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Represents the meta schema
|
|
59
|
+
*/
|
|
48
60
|
export type VovkMetaSchema = {
|
|
49
61
|
$schema: typeof VovkSchemaIdEnum.META | (string & {});
|
|
50
62
|
config: RequireFields<Partial<VovkStrictConfig>, '$schema'>;
|
|
51
63
|
openAPIObject?: Partial<OpenAPIObject>;
|
|
52
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Represents the full schema of composed client or a segment in segmented client.
|
|
67
|
+
*/
|
|
53
68
|
export type VovkSchema = {
|
|
54
69
|
$schema: typeof VovkSchemaIdEnum.SCHEMA | (string & {});
|
|
55
70
|
segments: {
|
|
@@ -57,6 +72,9 @@ export type VovkSchema = {
|
|
|
57
72
|
};
|
|
58
73
|
meta?: VovkMetaSchema;
|
|
59
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* The shape of error responses
|
|
77
|
+
*/
|
|
60
78
|
export type VovkErrorResponse = {
|
|
61
79
|
cause?: unknown;
|
|
62
80
|
statusCode: HttpStatus;
|
|
@@ -84,29 +102,29 @@ export type DecoratorOptions = {
|
|
|
84
102
|
export type RouteHandler = ((req: VovkRequest, params: Record<string, string>) => Response | Promise<Response> | Iterable<unknown> | AsyncIterable<unknown>) & {
|
|
85
103
|
_options?: DecoratorOptions;
|
|
86
104
|
};
|
|
87
|
-
export interface VovkRequest<
|
|
88
|
-
json: () => Promise<
|
|
105
|
+
export interface VovkRequest<TBody extends KnownAny = undefined, TQuery extends KnownAny = undefined, TParams extends KnownAny = undefined> extends Omit<NextRequest, 'json' | 'nextUrl'> {
|
|
106
|
+
json: () => Promise<TBody>;
|
|
89
107
|
nextUrl: Omit<NextRequest['nextUrl'], 'searchParams'> & {
|
|
90
108
|
searchParams: Omit<NextRequest['nextUrl']['searchParams'], 'get' | 'getAll' | 'entries' | 'forEach' | 'keys' | 'values'> & {
|
|
91
|
-
get: <KEY extends keyof
|
|
92
|
-
getAll: <KEY extends keyof
|
|
93
|
-
entries: () => IterableIterator<[keyof
|
|
94
|
-
forEach: (callbackfn: (value:
|
|
95
|
-
keys: () => IterableIterator<keyof
|
|
96
|
-
values: () => IterableIterator<
|
|
109
|
+
get: <KEY extends keyof TQuery>(key: KEY) => TQuery[KEY] extends readonly (infer ITEM)[] ? ITEM : TQuery[KEY];
|
|
110
|
+
getAll: <KEY extends keyof TQuery>(key: KEY) => TQuery[KEY] extends KnownAny[] ? TQuery[KEY] : TQuery[KEY][];
|
|
111
|
+
entries: () => IterableIterator<[keyof TQuery, TQuery[keyof TQuery]]>;
|
|
112
|
+
forEach: (callbackfn: (value: TQuery[keyof TQuery], key: keyof TQuery, searchParams: NextRequest['nextUrl']['searchParams']) => void) => void;
|
|
113
|
+
keys: () => IterableIterator<keyof TQuery>;
|
|
114
|
+
values: () => IterableIterator<TQuery[keyof TQuery]>;
|
|
97
115
|
};
|
|
98
116
|
};
|
|
99
117
|
vovk: {
|
|
100
|
-
body: () => Promise<
|
|
101
|
-
query: () =>
|
|
118
|
+
body: () => Promise<TBody>;
|
|
119
|
+
query: () => TQuery;
|
|
102
120
|
meta: <T = Record<KnownAny, KnownAny>>(meta?: T | null) => T;
|
|
103
|
-
form: <T =
|
|
104
|
-
params: () =>
|
|
121
|
+
form: <T = TBody>() => Promise<T>;
|
|
122
|
+
params: () => TParams;
|
|
105
123
|
};
|
|
106
124
|
}
|
|
107
|
-
export type ControllerStaticMethod<REQ extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<unknown, unknown, unknown>,
|
|
125
|
+
export type ControllerStaticMethod<REQ extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<unknown, unknown, unknown>, TParams extends {
|
|
108
126
|
[key: string]: string;
|
|
109
|
-
} = KnownAny> = ((req: REQ, params:
|
|
127
|
+
} = KnownAny> = ((req: REQ, params: TParams) => unknown) & {
|
|
110
128
|
_controller?: VovkController;
|
|
111
129
|
};
|
|
112
130
|
export type VovkTypedMethod<T extends (...args: KnownAny[]) => KnownAny, B = KnownAny, Q = KnownAny, P = KnownAny, O = KnownAny, I = KnownAny, IS_FORM extends boolean = false> = T & {
|
|
@@ -290,6 +308,9 @@ export type VovkOperationObject = OperationObject & {
|
|
|
290
308
|
'x-tool-errorMessage'?: string;
|
|
291
309
|
'x-tool-includeResponse'?: boolean;
|
|
292
310
|
};
|
|
311
|
+
/**
|
|
312
|
+
* IDs of the JSON Schema files that can be generated by Vovk.ts
|
|
313
|
+
*/
|
|
293
314
|
export declare enum VovkSchemaIdEnum {
|
|
294
315
|
META = "https://vovk.dev/api/schema/v3/meta.json",
|
|
295
316
|
CONFIG = "https://vovk.dev/api/schema/v3/config.json",
|
|
@@ -324,7 +345,7 @@ type BundleConfig = {
|
|
|
324
345
|
prebundleOutDir?: string;
|
|
325
346
|
keepPrebundleDir?: boolean;
|
|
326
347
|
tsdownBuildOptions?: Parameters<typeof import('tsdown').build>[0];
|
|
327
|
-
generatorConfig?:
|
|
348
|
+
generatorConfig?: VovkGeneratorConfig;
|
|
328
349
|
} & ({
|
|
329
350
|
excludeSegments?: never;
|
|
330
351
|
includeSegments?: string[];
|
|
@@ -332,7 +353,7 @@ type BundleConfig = {
|
|
|
332
353
|
excludeSegments?: string[];
|
|
333
354
|
includeSegments?: never;
|
|
334
355
|
});
|
|
335
|
-
export interface
|
|
356
|
+
export interface VovkGeneratorConfig {
|
|
336
357
|
origin?: string | null;
|
|
337
358
|
package?: VovkPackageJson;
|
|
338
359
|
readme?: VovkReadmeConfig;
|
|
@@ -351,7 +372,7 @@ export type ClientTemplateDef = {
|
|
|
351
372
|
composedClient?: Omit<ClientConfigComposed, 'fromTemplates' | 'enabled'>;
|
|
352
373
|
segmentedClient?: Omit<ClientConfigSegmented, 'fromTemplates' | 'enabled'>;
|
|
353
374
|
requires?: Record<string, string>;
|
|
354
|
-
generatorConfig?:
|
|
375
|
+
generatorConfig?: VovkGeneratorConfig;
|
|
355
376
|
};
|
|
356
377
|
export type GetOpenAPINameFn = (config: {
|
|
357
378
|
operationObject: VovkOperationObject;
|
|
@@ -383,19 +404,11 @@ export interface VovkOpenAPIMixinNormalized extends Omit<VovkOpenAPIMixin, 'sour
|
|
|
383
404
|
getMethodName: GetOpenAPINameFn;
|
|
384
405
|
getModuleName: GetOpenAPINameFn;
|
|
385
406
|
}
|
|
386
|
-
export interface VovkSegmentConfig extends
|
|
407
|
+
export interface VovkSegmentConfig extends VovkGeneratorConfig {
|
|
387
408
|
rootEntry?: string;
|
|
388
409
|
segmentNameOverride?: string;
|
|
389
410
|
openAPIMixin?: VovkOpenAPIMixin;
|
|
390
411
|
}
|
|
391
|
-
export interface VovkGeneratorConfig extends VovkGeneratorConfigCommon {
|
|
392
|
-
segments?: Record<string, VovkSegmentConfig>;
|
|
393
|
-
}
|
|
394
|
-
export interface VovkGeneratorConfigStrict extends Omit<VovkGeneratorConfig, 'segments'> {
|
|
395
|
-
segments?: Record<string, Omit<VovkSegmentConfig, 'openAPIMixin'> & {
|
|
396
|
-
openAPIMixin?: VovkOpenAPIMixinNormalized;
|
|
397
|
-
}>;
|
|
398
|
-
}
|
|
399
412
|
type VovkUserConfig = {
|
|
400
413
|
$schema?: typeof VovkSchemaIdEnum.CONFIG | (string & {});
|
|
401
414
|
emitConfig?: boolean | (keyof VovkStrictConfig | (string & {}))[];
|
|
@@ -418,7 +431,9 @@ type VovkUserConfig = {
|
|
|
418
431
|
controller?: string;
|
|
419
432
|
[key: string]: string | undefined;
|
|
420
433
|
};
|
|
421
|
-
generatorConfig?: VovkGeneratorConfig
|
|
434
|
+
generatorConfig?: VovkGeneratorConfig & {
|
|
435
|
+
segments?: Record<string, VovkSegmentConfig>;
|
|
436
|
+
};
|
|
422
437
|
};
|
|
423
438
|
export type VovkConfig = VovkUserConfig;
|
|
424
439
|
export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'emitConfig' | 'libs' | 'imports' | 'composedClient' | 'segmentedClient' | 'bundle' | 'extendClientWithOpenAPI' | 'generator'>> & {
|
|
@@ -427,7 +442,11 @@ export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'emitConfig' | 'lib
|
|
|
427
442
|
libs: Record<string, KnownAny>;
|
|
428
443
|
composedClient: RequireFields<ClientConfigComposed, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
|
|
429
444
|
segmentedClient: RequireFields<ClientConfigSegmented, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
|
|
430
|
-
generatorConfig:
|
|
445
|
+
generatorConfig: VovkGeneratorConfig & {
|
|
446
|
+
segments?: Record<string, Omit<VovkSegmentConfig, 'openAPIMixin'> & {
|
|
447
|
+
openAPIMixin?: VovkOpenAPIMixinNormalized;
|
|
448
|
+
}>;
|
|
449
|
+
};
|
|
431
450
|
};
|
|
432
451
|
export type RequireFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
433
452
|
export type RequireAllExcept<T, K extends keyof T> = Required<Omit<T, K>> & Pick<T, K>;
|
package/cjs/types.js
CHANGED
|
@@ -65,6 +65,9 @@ var HttpStatus;
|
|
|
65
65
|
HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
66
66
|
})(HttpStatus || (exports.HttpStatus = HttpStatus = {}));
|
|
67
67
|
// -----
|
|
68
|
+
/**
|
|
69
|
+
* IDs of the JSON Schema files that can be generated by Vovk.ts
|
|
70
|
+
*/
|
|
68
71
|
var VovkSchemaIdEnum;
|
|
69
72
|
(function (VovkSchemaIdEnum) {
|
|
70
73
|
VovkSchemaIdEnum["META"] = "https://vovk.dev/api/schema/v3/meta.json";
|
|
@@ -4,11 +4,11 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
4
4
|
toJSONSchema: (model: KnownAny, meta: {
|
|
5
5
|
type: VovkValidationType;
|
|
6
6
|
}) => KnownAny;
|
|
7
|
-
}): <T extends (req: REQ, params:
|
|
7
|
+
}): <T extends (req: REQ, params: TParams extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TParams> : Record<string, string>) => KnownAny, TBody extends StandardSchemaV1, TQuery extends StandardSchemaV1, TParams extends StandardSchemaV1, OUTPUT extends StandardSchemaV1, ITERATION extends StandardSchemaV1, REQ extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TBody> : undefined, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TQuery> : undefined, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TParams> : undefined>, IS_FORM extends boolean = false>({ isForm, body, query, params, output, iteration, handle, disableServerSideValidation, skipSchemaEmission, validateEachIteration, operationObject, }: {
|
|
8
8
|
isForm?: IS_FORM;
|
|
9
|
-
body?:
|
|
10
|
-
query?:
|
|
11
|
-
params?:
|
|
9
|
+
body?: TBody;
|
|
10
|
+
query?: TQuery;
|
|
11
|
+
params?: TParams;
|
|
12
12
|
output?: OUTPUT;
|
|
13
13
|
iteration?: ITERATION;
|
|
14
14
|
handle: T;
|
|
@@ -18,9 +18,9 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
18
18
|
operationObject?: VovkOperationObject;
|
|
19
19
|
}) => T & {
|
|
20
20
|
__types: {
|
|
21
|
-
body:
|
|
22
|
-
query:
|
|
23
|
-
params:
|
|
21
|
+
body: TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any;
|
|
22
|
+
query: TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any;
|
|
23
|
+
params: TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any;
|
|
24
24
|
output: OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any;
|
|
25
25
|
iteration: ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any;
|
|
26
26
|
isForm: IS_FORM;
|
|
@@ -28,43 +28,43 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
28
28
|
isRPC?: boolean;
|
|
29
29
|
} & {
|
|
30
30
|
schema: Omit<import("../types").VovkHandlerSchema, "httpMethod" | "path"> & Partial<import("../types").VovkHandlerSchema>;
|
|
31
|
-
wrapper?: ((req: VovkRequest<any, any, any>, params: Parameters<VovkTypedMethod<T,
|
|
31
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>>[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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>>) | undefined;
|
|
32
32
|
} & {
|
|
33
33
|
fn: {
|
|
34
|
-
<RETURN_TYPE = ReturnType<VovkTypedMethod<T,
|
|
34
|
+
<RETURN_TYPE = 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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>>>(input?: ((undefined extends TBody | undefined ? undefined extends TQuery | undefined ? undefined extends TParams | undefined ? true : false : false : false) extends true ? {
|
|
35
35
|
disableClientValidation?: boolean;
|
|
36
|
-
} & (undefined extends
|
|
37
|
-
body?: VovkTypedMethod<T,
|
|
36
|
+
} & (undefined extends TBody | undefined ? {
|
|
37
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["body"] | undefined;
|
|
38
38
|
} : {
|
|
39
|
-
body: VovkTypedMethod<T,
|
|
40
|
-
}) & (undefined extends
|
|
41
|
-
query?: VovkTypedMethod<T,
|
|
39
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["body"];
|
|
40
|
+
}) & (undefined extends TQuery | undefined ? {
|
|
41
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["query"] | undefined;
|
|
42
42
|
} : {
|
|
43
|
-
query: VovkTypedMethod<T,
|
|
44
|
-
}) & (undefined extends
|
|
45
|
-
params?: VovkTypedMethod<T,
|
|
43
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["query"];
|
|
44
|
+
}) & (undefined extends TParams | undefined ? {
|
|
45
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["params"] | undefined;
|
|
46
46
|
} : {
|
|
47
|
-
params: VovkTypedMethod<T,
|
|
47
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["params"];
|
|
48
48
|
}) & {
|
|
49
49
|
meta?: {
|
|
50
50
|
[key: string]: any;
|
|
51
51
|
__disableClientValidation?: boolean;
|
|
52
52
|
};
|
|
53
|
-
} : never) | undefined): (undefined extends
|
|
54
|
-
<RETURN_TYPE = ReturnType<VovkTypedMethod<T,
|
|
53
|
+
} : never) | undefined): (undefined extends TBody | undefined ? undefined extends TQuery | undefined ? undefined extends TParams | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
|
|
54
|
+
<RETURN_TYPE = 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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>>>(input: {
|
|
55
55
|
disableClientValidation?: boolean;
|
|
56
|
-
} & (undefined extends
|
|
57
|
-
body?: VovkTypedMethod<T,
|
|
56
|
+
} & (undefined extends TBody | undefined ? {
|
|
57
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["body"] | undefined;
|
|
58
58
|
} : {
|
|
59
|
-
body: VovkTypedMethod<T,
|
|
60
|
-
}) & (undefined extends
|
|
61
|
-
query?: VovkTypedMethod<T,
|
|
59
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["body"];
|
|
60
|
+
}) & (undefined extends TQuery | undefined ? {
|
|
61
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["query"] | undefined;
|
|
62
62
|
} : {
|
|
63
|
-
query: VovkTypedMethod<T,
|
|
64
|
-
}) & (undefined extends
|
|
65
|
-
params?: VovkTypedMethod<T,
|
|
63
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["query"];
|
|
64
|
+
}) & (undefined extends TParams | undefined ? {
|
|
65
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["params"] | undefined;
|
|
66
66
|
} : {
|
|
67
|
-
params: VovkTypedMethod<T,
|
|
67
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["params"];
|
|
68
68
|
}) & {
|
|
69
69
|
meta?: {
|
|
70
70
|
[key: string]: any;
|
|
@@ -75,8 +75,8 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
75
75
|
models: {
|
|
76
76
|
iteration?: (ITERATION & ({} | null)) | undefined;
|
|
77
77
|
output?: (OUTPUT & ({} | null)) | undefined;
|
|
78
|
-
params?: (
|
|
79
|
-
query?: (
|
|
80
|
-
body?: (
|
|
78
|
+
params?: (TParams & ({} | null)) | undefined;
|
|
79
|
+
query?: (TQuery & ({} | null)) | undefined;
|
|
80
|
+
body?: (TBody & ({} | null)) | undefined;
|
|
81
81
|
};
|
|
82
82
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { PackageJson } from 'type-fest';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VovkGeneratorConfig, 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?: VovkGeneratorConfig[];
|
|
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: VovkGeneratorConfig['imports'];
|
|
17
|
+
reExports: VovkGeneratorConfig['reExports'];
|
|
18
18
|
};
|
|
@@ -4,14 +4,14 @@ 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>,
|
|
7
|
+
export declare function withValidationLibrary<T extends VovkTypedMethod<(req: KnownAny, params: KnownAny) => KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, boolean>, TBody_MODEL, TQuery_MODEL, TParams_MODEL, OUTPUT_MODEL, ITERATION_MODEL, IS_FORM extends boolean = false>({ isForm, disableServerSideValidation, skipSchemaEmission, validateEachIteration, body, query, params, output, iteration, handle, toJSONSchema, validate, operationObject, }: {
|
|
8
8
|
isForm?: IS_FORM;
|
|
9
9
|
disableServerSideValidation?: boolean | VovkValidationType[];
|
|
10
10
|
skipSchemaEmission?: boolean | VovkValidationType[];
|
|
11
11
|
validateEachIteration?: boolean;
|
|
12
|
-
body?:
|
|
13
|
-
query?:
|
|
14
|
-
params?:
|
|
12
|
+
body?: TBody_MODEL;
|
|
13
|
+
query?: TQuery_MODEL;
|
|
14
|
+
params?: TParams_MODEL;
|
|
15
15
|
output?: OUTPUT_MODEL;
|
|
16
16
|
iteration?: ITERATION_MODEL;
|
|
17
17
|
handle: T;
|
|
@@ -19,7 +19,7 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
|
|
|
19
19
|
meta: {
|
|
20
20
|
type: VovkValidationType;
|
|
21
21
|
}) => KnownAny;
|
|
22
|
-
validate: (data: KnownAny, model: NonNullable<
|
|
22
|
+
validate: (data: KnownAny, model: NonNullable<TBody_MODEL | TQuery_MODEL | TParams_MODEL | OUTPUT_MODEL | ITERATION_MODEL>, meta: {
|
|
23
23
|
type: VovkValidationType | 'form';
|
|
24
24
|
req: VovkRequestAny;
|
|
25
25
|
status?: number;
|
|
@@ -31,34 +31,34 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
|
|
|
31
31
|
wrapper?: (req: VovkRequestAny, params: Parameters<T>[1]) => ReturnType<T>;
|
|
32
32
|
} & {
|
|
33
33
|
fn: {
|
|
34
|
-
<RETURN_TYPE = ReturnType<T>>(input?: (undefined extends
|
|
34
|
+
<RETURN_TYPE = ReturnType<T>>(input?: (undefined extends TBody_MODEL | undefined ? undefined extends TQuery_MODEL | undefined ? undefined extends TParams_MODEL | undefined ? true : false : false : false) extends true ? {
|
|
35
35
|
disableClientValidation?: boolean;
|
|
36
|
-
} & (undefined extends
|
|
36
|
+
} & (undefined extends TBody_MODEL | undefined ? {
|
|
37
37
|
body?: T["__types"]["body"];
|
|
38
38
|
} : {
|
|
39
39
|
body: T["__types"]["body"];
|
|
40
|
-
}) & (undefined extends
|
|
40
|
+
}) & (undefined extends TQuery_MODEL | undefined ? {
|
|
41
41
|
query?: T["__types"]["query"];
|
|
42
42
|
} : {
|
|
43
43
|
query: T["__types"]["query"];
|
|
44
|
-
}) & (undefined extends
|
|
44
|
+
}) & (undefined extends TParams_MODEL | undefined ? {
|
|
45
45
|
params?: T["__types"]["params"];
|
|
46
46
|
} : {
|
|
47
47
|
params: T["__types"]["params"];
|
|
48
48
|
}) & {
|
|
49
49
|
meta?: Meta;
|
|
50
|
-
} : never): (undefined extends
|
|
50
|
+
} : never): (undefined extends TBody_MODEL | undefined ? undefined extends TQuery_MODEL | undefined ? undefined extends TParams_MODEL | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
|
|
51
51
|
<RETURN_TYPE = ReturnType<T>>(input: {
|
|
52
52
|
disableClientValidation?: boolean;
|
|
53
|
-
} & (undefined extends
|
|
53
|
+
} & (undefined extends TBody_MODEL | undefined ? {
|
|
54
54
|
body?: T["__types"]["body"];
|
|
55
55
|
} : {
|
|
56
56
|
body: T["__types"]["body"];
|
|
57
|
-
}) & (undefined extends
|
|
57
|
+
}) & (undefined extends TQuery_MODEL | undefined ? {
|
|
58
58
|
query?: T["__types"]["query"];
|
|
59
59
|
} : {
|
|
60
60
|
query: T["__types"]["query"];
|
|
61
|
-
}) & (undefined extends
|
|
61
|
+
}) & (undefined extends TParams_MODEL | undefined ? {
|
|
62
62
|
params?: T["__types"]["params"];
|
|
63
63
|
} : {
|
|
64
64
|
params: T["__types"]["params"];
|
|
@@ -69,9 +69,9 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
|
|
|
69
69
|
models: {
|
|
70
70
|
iteration?: (ITERATION_MODEL & ({} | null)) | undefined;
|
|
71
71
|
output?: (OUTPUT_MODEL & ({} | null)) | undefined;
|
|
72
|
-
params?: (
|
|
73
|
-
query?: (
|
|
74
|
-
body?: (
|
|
72
|
+
params?: (TParams_MODEL & ({} | null)) | undefined;
|
|
73
|
+
query?: (TQuery_MODEL & ({} | null)) | undefined;
|
|
74
|
+
body?: (TBody_MODEL & ({} | null)) | undefined;
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
77
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { KnownAny } from '../types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const createRPC: <T, OPTS extends Record<string, KnownAny> = Record<string, never>>(givenSchema: unknown, segmentName: string, rpcModuleName: string, givenFetcher?:
|
|
4
|
-
fetcher:
|
|
5
|
-
}>, options?:
|
|
2
|
+
import type { VovkRPCModule, VovkFetcher, VovkFetcherOptions } from './types';
|
|
3
|
+
export declare const createRPC: <T, OPTS extends Record<string, KnownAny> = Record<string, never>>(givenSchema: unknown, segmentName: string, rpcModuleName: string, givenFetcher?: VovkFetcher<OPTS> | Promise<{
|
|
4
|
+
fetcher: VovkFetcher<OPTS>;
|
|
5
|
+
}>, options?: VovkFetcherOptions<OPTS>) => VovkRPCModule<T, OPTS>;
|
package/mjs/client/fetcher.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VovkFetcherOptions, VovkFetcher } from './types';
|
|
2
2
|
import { KnownAny } from '../types';
|
|
3
3
|
import { HttpException } from '../HttpException';
|
|
4
4
|
export declare const DEFAULT_ERROR_MESSAGE = "Unknown error at default fetcher";
|
|
5
5
|
export declare function createFetcher<T>({ prepareRequestInit, transformResponse, onSuccess, onError, }?: {
|
|
6
|
-
prepareRequestInit?: (init: RequestInit, options:
|
|
7
|
-
transformResponse?: (respData: KnownAny, options:
|
|
8
|
-
onSuccess?: (respData: KnownAny, options:
|
|
9
|
-
onError?: (error: HttpException, options:
|
|
10
|
-
}):
|
|
11
|
-
export declare const fetcher:
|
|
6
|
+
prepareRequestInit?: (init: RequestInit, options: VovkFetcherOptions<T>) => RequestInit | Promise<RequestInit>;
|
|
7
|
+
transformResponse?: (respData: KnownAny, options: VovkFetcherOptions<T>, response: Response, init: RequestInit) => unknown | Promise<unknown>;
|
|
8
|
+
onSuccess?: (respData: KnownAny, options: VovkFetcherOptions<T>, response: Response, init: RequestInit) => void | Promise<void>;
|
|
9
|
+
onError?: (error: HttpException, options: VovkFetcherOptions<T>, response: Response | null, init: RequestInit | null, respData: unknown | null) => void | Promise<void>;
|
|
10
|
+
}): VovkFetcher<VovkFetcherOptions<T>>;
|
|
11
|
+
export declare const fetcher: VovkFetcher<{
|
|
12
12
|
apiRoot?: string;
|
|
13
13
|
disableClientValidation?: boolean;
|
|
14
14
|
validateOnClient?: import("./types").VovkValidateOnClient<unknown> | Promise<{
|
package/mjs/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createRPC } from './createRPC';
|
|
2
2
|
export { fetcher, createFetcher } from './fetcher';
|
|
3
3
|
export { progressive } from './progressive';
|
|
4
|
-
export type {
|
|
4
|
+
export type { VovkRPCModule, VovkFetcher, VovkFetcherOptions, VovkValidateOnClient, VovkStreamAsyncIterable, } from './types';
|
package/mjs/client/types.d.ts
CHANGED
|
@@ -11,14 +11,14 @@ export type StaticMethodInput<T extends ((req: VovkRequest<KnownAny, KnownAny, K
|
|
|
11
11
|
__types?: {
|
|
12
12
|
isForm: boolean;
|
|
13
13
|
};
|
|
14
|
-
}> = OmitNullable<(Parameters<T>[0] extends VovkRequest<infer
|
|
14
|
+
}> = OmitNullable<(Parameters<T>[0] extends VovkRequest<infer TBody, infer TQuery, infer TParams> ? (TBody extends Record<KnownAny, KnownAny> ? {
|
|
15
15
|
body: T['__types'] extends {
|
|
16
16
|
isForm: true;
|
|
17
|
-
} ? FormData :
|
|
18
|
-
} : Empty) & (
|
|
19
|
-
query:
|
|
20
|
-
} : Empty) & (
|
|
21
|
-
params:
|
|
17
|
+
} ? FormData : TBody;
|
|
18
|
+
} : Empty) & (TQuery extends Record<KnownAny, KnownAny> ? {
|
|
19
|
+
query: TQuery;
|
|
20
|
+
} : Empty) & (TParams extends Record<KnownAny, KnownAny> ? {
|
|
21
|
+
params: TParams;
|
|
22
22
|
} : Empty) & {
|
|
23
23
|
meta?: {
|
|
24
24
|
[key: string]: KnownAny;
|
|
@@ -38,9 +38,9 @@ export type VovkStreamAsyncIterable<T> = {
|
|
|
38
38
|
};
|
|
39
39
|
type StaticMethodReturn<T extends ControllerStaticMethod> = ReturnType<T> extends NextResponse<infer U> | Promise<NextResponse<infer U>> ? U : ReturnType<T> extends Response | Promise<Response> ? Awaited<ReturnType<T>> : ReturnType<T>;
|
|
40
40
|
type StaticMethodReturnPromise<T extends ControllerStaticMethod> = ToPromise<StaticMethodReturn<T>>;
|
|
41
|
-
type StaticMethodOptions<T extends (req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<TStreamIteration> | Promise<JSONLinesResponse<TStreamIteration>>, TFetcherOptions extends Record<string, KnownAny>, TStreamIteration, R, F extends
|
|
41
|
+
type StaticMethodOptions<T extends (req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<TStreamIteration> | Promise<JSONLinesResponse<TStreamIteration>>, TFetcherOptions extends Record<string, KnownAny>, TStreamIteration, R, F extends VovkFetcherOptions<KnownAny>> = Partial<TFetcherOptions & {
|
|
42
42
|
transform: (staticMethodReturn: Awaited<StaticMethodReturn<T>>, resp: Response) => R;
|
|
43
|
-
fetcher:
|
|
43
|
+
fetcher: VovkFetcher<F>;
|
|
44
44
|
}>;
|
|
45
45
|
export type ClientMethodReturn<T extends (req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<TStreamIteration> | Promise<JSONLinesResponse<TStreamIteration>>, TStreamIteration, R> = ReturnType<T> extends Promise<JSONLinesResponse<infer U>> | JSONLinesResponse<infer U> | Iterator<infer U> | AsyncIterator<infer U> ? Promise<VovkStreamAsyncIterable<U>> : R extends object ? Promise<Awaited<R>> : StaticMethodReturnPromise<T>;
|
|
46
46
|
export type ClientMethod<T extends ((req: VovkRequest<KnownAny, KnownAny, KnownAny>, params: KnownAny) => void | object | JSONLinesResponse<TStreamIteration> | Promise<JSONLinesResponse<TStreamIteration>>) & {
|
|
@@ -52,7 +52,7 @@ export type ClientMethod<T extends ((req: VovkRequest<KnownAny, KnownAny, KnownA
|
|
|
52
52
|
iteration: KnownAny;
|
|
53
53
|
isForm: boolean;
|
|
54
54
|
};
|
|
55
|
-
}, TFetcherOptions extends Record<string, KnownAny>, TStreamIteration extends KnownAny = unknown> = (IsEmptyObject<StaticMethodInput<T>> extends true ? <R, F extends
|
|
55
|
+
}, TFetcherOptions extends Record<string, KnownAny>, TStreamIteration extends KnownAny = unknown> = (IsEmptyObject<StaticMethodInput<T>> extends true ? <R, F extends VovkFetcherOptions<KnownAny> = VovkFetcherOptions<TFetcherOptions>>(options?: Prettify<StaticMethodOptions<T, TFetcherOptions, TStreamIteration, R, F>>) => ClientMethodReturn<T, TStreamIteration, R> : <R, F extends VovkFetcherOptions<KnownAny> = VovkFetcherOptions<TFetcherOptions>>(options: Prettify<StaticMethodInput<T> & StaticMethodOptions<T, TFetcherOptions, TStreamIteration, R, F>>) => ClientMethodReturn<T, TStreamIteration, R>) & {
|
|
56
56
|
isRPC: true;
|
|
57
57
|
schema: VovkHandlerSchema;
|
|
58
58
|
controllerSchema: VovkControllerSchema;
|
|
@@ -70,10 +70,10 @@ type VovkClientWithNever<T, TFetcherOptions extends {
|
|
|
70
70
|
}> = {
|
|
71
71
|
[K in keyof T]: T[K] extends (...args: KnownAny) => KnownAny ? ClientMethod<T[K], TFetcherOptions> : never;
|
|
72
72
|
};
|
|
73
|
-
export type
|
|
73
|
+
export type VovkRPCModule<T, TFetcherOptions extends {
|
|
74
74
|
[key: string]: KnownAny;
|
|
75
75
|
}> = OmitNever<VovkClientWithNever<T, TFetcherOptions>>;
|
|
76
|
-
export type
|
|
76
|
+
export type VovkFetcher<TFetcherOptions> = (options: {
|
|
77
77
|
name: string;
|
|
78
78
|
httpMethod: HttpMethod;
|
|
79
79
|
getEndpoint: (data: {
|
|
@@ -98,7 +98,7 @@ export type VovkClientFetcher<TFetcherOptions> = (options: {
|
|
|
98
98
|
params?: unknown;
|
|
99
99
|
meta?: unknown;
|
|
100
100
|
} & TFetcherOptions) => Promise<[KnownAny, Response]>;
|
|
101
|
-
export type
|
|
101
|
+
export type VovkFetcherOptions<T> = T & {
|
|
102
102
|
apiRoot?: string;
|
|
103
103
|
disableClientValidation?: boolean;
|
|
104
104
|
validateOnClient?: VovkValidateOnClient<T> | Promise<{
|
package/mjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 VovkGeneratorConfig, type
|
|
3
|
-
import { 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 VovkGeneratorConfig, type VovkReadmeConfig, type VovkSamplesConfig, type VovkOpenAPIMixin, type VovkOpenAPIMixinNormalized, type VovkStrictConfig, type VovkValidationType, type VovkLLMTool, type VovkTypedMethod, type VovkBasicJSONSchema, type VovkOperationObject } from './types';
|
|
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';
|
|
6
6
|
import { createDecorator } from './utils/createDecorator';
|
|
@@ -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
|
|
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 VovkGeneratorConfig, 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 VovkGeneratorConfig } 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?: VovkGeneratorConfig[];
|
|
7
7
|
segmentName?: string;
|
|
8
8
|
}): OpenAPIObject;
|
package/mjs/types.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ type VovkPackageJson = PackageJson & {
|
|
|
9
9
|
rs_name?: string;
|
|
10
10
|
py_name?: string;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Schema for an individual handler, available as MyRPC.myHandler.schema and MyController.myHandler.schema
|
|
14
|
+
*/
|
|
12
15
|
export type VovkHandlerSchema = {
|
|
13
16
|
path: string;
|
|
14
17
|
httpMethod: string;
|
|
@@ -22,6 +25,9 @@ export type VovkHandlerSchema = {
|
|
|
22
25
|
operationObject?: VovkOperationObject;
|
|
23
26
|
misc?: Record<string, KnownAny>;
|
|
24
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Represents the schema of a controller
|
|
30
|
+
*/
|
|
25
31
|
export type VovkControllerSchema = {
|
|
26
32
|
rpcModuleName: string;
|
|
27
33
|
originalControllerName?: string;
|
|
@@ -31,6 +37,9 @@ export type VovkControllerSchema = {
|
|
|
31
37
|
[key: string]: VovkHandlerSchema;
|
|
32
38
|
};
|
|
33
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Represents the schema of a segment
|
|
42
|
+
*/
|
|
34
43
|
export type VovkSegmentSchema = {
|
|
35
44
|
$schema: typeof VovkSchemaIdEnum.SEGMENT | (string & {});
|
|
36
45
|
emitSchema: boolean;
|
|
@@ -45,11 +54,17 @@ export type VovkSegmentSchema = {
|
|
|
45
54
|
package?: VovkPackageJson;
|
|
46
55
|
};
|
|
47
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Represents the meta schema
|
|
59
|
+
*/
|
|
48
60
|
export type VovkMetaSchema = {
|
|
49
61
|
$schema: typeof VovkSchemaIdEnum.META | (string & {});
|
|
50
62
|
config: RequireFields<Partial<VovkStrictConfig>, '$schema'>;
|
|
51
63
|
openAPIObject?: Partial<OpenAPIObject>;
|
|
52
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Represents the full schema of composed client or a segment in segmented client.
|
|
67
|
+
*/
|
|
53
68
|
export type VovkSchema = {
|
|
54
69
|
$schema: typeof VovkSchemaIdEnum.SCHEMA | (string & {});
|
|
55
70
|
segments: {
|
|
@@ -57,6 +72,9 @@ export type VovkSchema = {
|
|
|
57
72
|
};
|
|
58
73
|
meta?: VovkMetaSchema;
|
|
59
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* The shape of error responses
|
|
77
|
+
*/
|
|
60
78
|
export type VovkErrorResponse = {
|
|
61
79
|
cause?: unknown;
|
|
62
80
|
statusCode: HttpStatus;
|
|
@@ -84,29 +102,29 @@ export type DecoratorOptions = {
|
|
|
84
102
|
export type RouteHandler = ((req: VovkRequest, params: Record<string, string>) => Response | Promise<Response> | Iterable<unknown> | AsyncIterable<unknown>) & {
|
|
85
103
|
_options?: DecoratorOptions;
|
|
86
104
|
};
|
|
87
|
-
export interface VovkRequest<
|
|
88
|
-
json: () => Promise<
|
|
105
|
+
export interface VovkRequest<TBody extends KnownAny = undefined, TQuery extends KnownAny = undefined, TParams extends KnownAny = undefined> extends Omit<NextRequest, 'json' | 'nextUrl'> {
|
|
106
|
+
json: () => Promise<TBody>;
|
|
89
107
|
nextUrl: Omit<NextRequest['nextUrl'], 'searchParams'> & {
|
|
90
108
|
searchParams: Omit<NextRequest['nextUrl']['searchParams'], 'get' | 'getAll' | 'entries' | 'forEach' | 'keys' | 'values'> & {
|
|
91
|
-
get: <KEY extends keyof
|
|
92
|
-
getAll: <KEY extends keyof
|
|
93
|
-
entries: () => IterableIterator<[keyof
|
|
94
|
-
forEach: (callbackfn: (value:
|
|
95
|
-
keys: () => IterableIterator<keyof
|
|
96
|
-
values: () => IterableIterator<
|
|
109
|
+
get: <KEY extends keyof TQuery>(key: KEY) => TQuery[KEY] extends readonly (infer ITEM)[] ? ITEM : TQuery[KEY];
|
|
110
|
+
getAll: <KEY extends keyof TQuery>(key: KEY) => TQuery[KEY] extends KnownAny[] ? TQuery[KEY] : TQuery[KEY][];
|
|
111
|
+
entries: () => IterableIterator<[keyof TQuery, TQuery[keyof TQuery]]>;
|
|
112
|
+
forEach: (callbackfn: (value: TQuery[keyof TQuery], key: keyof TQuery, searchParams: NextRequest['nextUrl']['searchParams']) => void) => void;
|
|
113
|
+
keys: () => IterableIterator<keyof TQuery>;
|
|
114
|
+
values: () => IterableIterator<TQuery[keyof TQuery]>;
|
|
97
115
|
};
|
|
98
116
|
};
|
|
99
117
|
vovk: {
|
|
100
|
-
body: () => Promise<
|
|
101
|
-
query: () =>
|
|
118
|
+
body: () => Promise<TBody>;
|
|
119
|
+
query: () => TQuery;
|
|
102
120
|
meta: <T = Record<KnownAny, KnownAny>>(meta?: T | null) => T;
|
|
103
|
-
form: <T =
|
|
104
|
-
params: () =>
|
|
121
|
+
form: <T = TBody>() => Promise<T>;
|
|
122
|
+
params: () => TParams;
|
|
105
123
|
};
|
|
106
124
|
}
|
|
107
|
-
export type ControllerStaticMethod<REQ extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<unknown, unknown, unknown>,
|
|
125
|
+
export type ControllerStaticMethod<REQ extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<unknown, unknown, unknown>, TParams extends {
|
|
108
126
|
[key: string]: string;
|
|
109
|
-
} = KnownAny> = ((req: REQ, params:
|
|
127
|
+
} = KnownAny> = ((req: REQ, params: TParams) => unknown) & {
|
|
110
128
|
_controller?: VovkController;
|
|
111
129
|
};
|
|
112
130
|
export type VovkTypedMethod<T extends (...args: KnownAny[]) => KnownAny, B = KnownAny, Q = KnownAny, P = KnownAny, O = KnownAny, I = KnownAny, IS_FORM extends boolean = false> = T & {
|
|
@@ -290,6 +308,9 @@ export type VovkOperationObject = OperationObject & {
|
|
|
290
308
|
'x-tool-errorMessage'?: string;
|
|
291
309
|
'x-tool-includeResponse'?: boolean;
|
|
292
310
|
};
|
|
311
|
+
/**
|
|
312
|
+
* IDs of the JSON Schema files that can be generated by Vovk.ts
|
|
313
|
+
*/
|
|
293
314
|
export declare enum VovkSchemaIdEnum {
|
|
294
315
|
META = "https://vovk.dev/api/schema/v3/meta.json",
|
|
295
316
|
CONFIG = "https://vovk.dev/api/schema/v3/config.json",
|
|
@@ -324,7 +345,7 @@ type BundleConfig = {
|
|
|
324
345
|
prebundleOutDir?: string;
|
|
325
346
|
keepPrebundleDir?: boolean;
|
|
326
347
|
tsdownBuildOptions?: Parameters<typeof import('tsdown').build>[0];
|
|
327
|
-
generatorConfig?:
|
|
348
|
+
generatorConfig?: VovkGeneratorConfig;
|
|
328
349
|
} & ({
|
|
329
350
|
excludeSegments?: never;
|
|
330
351
|
includeSegments?: string[];
|
|
@@ -332,7 +353,7 @@ type BundleConfig = {
|
|
|
332
353
|
excludeSegments?: string[];
|
|
333
354
|
includeSegments?: never;
|
|
334
355
|
});
|
|
335
|
-
export interface
|
|
356
|
+
export interface VovkGeneratorConfig {
|
|
336
357
|
origin?: string | null;
|
|
337
358
|
package?: VovkPackageJson;
|
|
338
359
|
readme?: VovkReadmeConfig;
|
|
@@ -351,7 +372,7 @@ export type ClientTemplateDef = {
|
|
|
351
372
|
composedClient?: Omit<ClientConfigComposed, 'fromTemplates' | 'enabled'>;
|
|
352
373
|
segmentedClient?: Omit<ClientConfigSegmented, 'fromTemplates' | 'enabled'>;
|
|
353
374
|
requires?: Record<string, string>;
|
|
354
|
-
generatorConfig?:
|
|
375
|
+
generatorConfig?: VovkGeneratorConfig;
|
|
355
376
|
};
|
|
356
377
|
export type GetOpenAPINameFn = (config: {
|
|
357
378
|
operationObject: VovkOperationObject;
|
|
@@ -383,19 +404,11 @@ export interface VovkOpenAPIMixinNormalized extends Omit<VovkOpenAPIMixin, 'sour
|
|
|
383
404
|
getMethodName: GetOpenAPINameFn;
|
|
384
405
|
getModuleName: GetOpenAPINameFn;
|
|
385
406
|
}
|
|
386
|
-
export interface VovkSegmentConfig extends
|
|
407
|
+
export interface VovkSegmentConfig extends VovkGeneratorConfig {
|
|
387
408
|
rootEntry?: string;
|
|
388
409
|
segmentNameOverride?: string;
|
|
389
410
|
openAPIMixin?: VovkOpenAPIMixin;
|
|
390
411
|
}
|
|
391
|
-
export interface VovkGeneratorConfig extends VovkGeneratorConfigCommon {
|
|
392
|
-
segments?: Record<string, VovkSegmentConfig>;
|
|
393
|
-
}
|
|
394
|
-
export interface VovkGeneratorConfigStrict extends Omit<VovkGeneratorConfig, 'segments'> {
|
|
395
|
-
segments?: Record<string, Omit<VovkSegmentConfig, 'openAPIMixin'> & {
|
|
396
|
-
openAPIMixin?: VovkOpenAPIMixinNormalized;
|
|
397
|
-
}>;
|
|
398
|
-
}
|
|
399
412
|
type VovkUserConfig = {
|
|
400
413
|
$schema?: typeof VovkSchemaIdEnum.CONFIG | (string & {});
|
|
401
414
|
emitConfig?: boolean | (keyof VovkStrictConfig | (string & {}))[];
|
|
@@ -418,7 +431,9 @@ type VovkUserConfig = {
|
|
|
418
431
|
controller?: string;
|
|
419
432
|
[key: string]: string | undefined;
|
|
420
433
|
};
|
|
421
|
-
generatorConfig?: VovkGeneratorConfig
|
|
434
|
+
generatorConfig?: VovkGeneratorConfig & {
|
|
435
|
+
segments?: Record<string, VovkSegmentConfig>;
|
|
436
|
+
};
|
|
422
437
|
};
|
|
423
438
|
export type VovkConfig = VovkUserConfig;
|
|
424
439
|
export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'emitConfig' | 'libs' | 'imports' | 'composedClient' | 'segmentedClient' | 'bundle' | 'extendClientWithOpenAPI' | 'generator'>> & {
|
|
@@ -427,7 +442,11 @@ export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'emitConfig' | 'lib
|
|
|
427
442
|
libs: Record<string, KnownAny>;
|
|
428
443
|
composedClient: RequireFields<ClientConfigComposed, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
|
|
429
444
|
segmentedClient: RequireFields<ClientConfigSegmented, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
|
|
430
|
-
generatorConfig:
|
|
445
|
+
generatorConfig: VovkGeneratorConfig & {
|
|
446
|
+
segments?: Record<string, Omit<VovkSegmentConfig, 'openAPIMixin'> & {
|
|
447
|
+
openAPIMixin?: VovkOpenAPIMixinNormalized;
|
|
448
|
+
}>;
|
|
449
|
+
};
|
|
431
450
|
};
|
|
432
451
|
export type RequireFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
433
452
|
export type RequireAllExcept<T, K extends keyof T> = Required<Omit<T, K>> & Pick<T, K>;
|
package/mjs/types.js
CHANGED
|
@@ -65,6 +65,9 @@ var HttpStatus;
|
|
|
65
65
|
HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
66
66
|
})(HttpStatus || (exports.HttpStatus = HttpStatus = {}));
|
|
67
67
|
// -----
|
|
68
|
+
/**
|
|
69
|
+
* IDs of the JSON Schema files that can be generated by Vovk.ts
|
|
70
|
+
*/
|
|
68
71
|
var VovkSchemaIdEnum;
|
|
69
72
|
(function (VovkSchemaIdEnum) {
|
|
70
73
|
VovkSchemaIdEnum["META"] = "https://vovk.dev/api/schema/v3/meta.json";
|
|
@@ -4,11 +4,11 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
4
4
|
toJSONSchema: (model: KnownAny, meta: {
|
|
5
5
|
type: VovkValidationType;
|
|
6
6
|
}) => KnownAny;
|
|
7
|
-
}): <T extends (req: REQ, params:
|
|
7
|
+
}): <T extends (req: REQ, params: TParams extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TParams> : Record<string, string>) => KnownAny, TBody extends StandardSchemaV1, TQuery extends StandardSchemaV1, TParams extends StandardSchemaV1, OUTPUT extends StandardSchemaV1, ITERATION extends StandardSchemaV1, REQ extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest<TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TBody> : undefined, TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TQuery> : undefined, TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<TParams> : undefined>, IS_FORM extends boolean = false>({ isForm, body, query, params, output, iteration, handle, disableServerSideValidation, skipSchemaEmission, validateEachIteration, operationObject, }: {
|
|
8
8
|
isForm?: IS_FORM;
|
|
9
|
-
body?:
|
|
10
|
-
query?:
|
|
11
|
-
params?:
|
|
9
|
+
body?: TBody;
|
|
10
|
+
query?: TQuery;
|
|
11
|
+
params?: TParams;
|
|
12
12
|
output?: OUTPUT;
|
|
13
13
|
iteration?: ITERATION;
|
|
14
14
|
handle: T;
|
|
@@ -18,9 +18,9 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
18
18
|
operationObject?: VovkOperationObject;
|
|
19
19
|
}) => T & {
|
|
20
20
|
__types: {
|
|
21
|
-
body:
|
|
22
|
-
query:
|
|
23
|
-
params:
|
|
21
|
+
body: TBody extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TBody> : any;
|
|
22
|
+
query: TQuery extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TQuery> : any;
|
|
23
|
+
params: TParams extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<TParams> : any;
|
|
24
24
|
output: OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any;
|
|
25
25
|
iteration: ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any;
|
|
26
26
|
isForm: IS_FORM;
|
|
@@ -28,43 +28,43 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
28
28
|
isRPC?: boolean;
|
|
29
29
|
} & {
|
|
30
30
|
schema: Omit<import("../types").VovkHandlerSchema, "httpMethod" | "path"> & Partial<import("../types").VovkHandlerSchema>;
|
|
31
|
-
wrapper?: ((req: VovkRequest<any, any, any>, params: Parameters<VovkTypedMethod<T,
|
|
31
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>>[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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>>) | undefined;
|
|
32
32
|
} & {
|
|
33
33
|
fn: {
|
|
34
|
-
<RETURN_TYPE = ReturnType<VovkTypedMethod<T,
|
|
34
|
+
<RETURN_TYPE = 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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>>>(input?: ((undefined extends TBody | undefined ? undefined extends TQuery | undefined ? undefined extends TParams | undefined ? true : false : false : false) extends true ? {
|
|
35
35
|
disableClientValidation?: boolean;
|
|
36
|
-
} & (undefined extends
|
|
37
|
-
body?: VovkTypedMethod<T,
|
|
36
|
+
} & (undefined extends TBody | undefined ? {
|
|
37
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["body"] | undefined;
|
|
38
38
|
} : {
|
|
39
|
-
body: VovkTypedMethod<T,
|
|
40
|
-
}) & (undefined extends
|
|
41
|
-
query?: VovkTypedMethod<T,
|
|
39
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["body"];
|
|
40
|
+
}) & (undefined extends TQuery | undefined ? {
|
|
41
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["query"] | undefined;
|
|
42
42
|
} : {
|
|
43
|
-
query: VovkTypedMethod<T,
|
|
44
|
-
}) & (undefined extends
|
|
45
|
-
params?: VovkTypedMethod<T,
|
|
43
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["query"];
|
|
44
|
+
}) & (undefined extends TParams | undefined ? {
|
|
45
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["params"] | undefined;
|
|
46
46
|
} : {
|
|
47
|
-
params: VovkTypedMethod<T,
|
|
47
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["params"];
|
|
48
48
|
}) & {
|
|
49
49
|
meta?: {
|
|
50
50
|
[key: string]: any;
|
|
51
51
|
__disableClientValidation?: boolean;
|
|
52
52
|
};
|
|
53
|
-
} : never) | undefined): (undefined extends
|
|
54
|
-
<RETURN_TYPE = ReturnType<VovkTypedMethod<T,
|
|
53
|
+
} : never) | undefined): (undefined extends TBody | undefined ? undefined extends TQuery | undefined ? undefined extends TParams | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
|
|
54
|
+
<RETURN_TYPE = 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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>>>(input: {
|
|
55
55
|
disableClientValidation?: boolean;
|
|
56
|
-
} & (undefined extends
|
|
57
|
-
body?: VovkTypedMethod<T,
|
|
56
|
+
} & (undefined extends TBody | undefined ? {
|
|
57
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["body"] | undefined;
|
|
58
58
|
} : {
|
|
59
|
-
body: VovkTypedMethod<T,
|
|
60
|
-
}) & (undefined extends
|
|
61
|
-
query?: VovkTypedMethod<T,
|
|
59
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["body"];
|
|
60
|
+
}) & (undefined extends TQuery | undefined ? {
|
|
61
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["query"] | undefined;
|
|
62
62
|
} : {
|
|
63
|
-
query: VovkTypedMethod<T,
|
|
64
|
-
}) & (undefined extends
|
|
65
|
-
params?: VovkTypedMethod<T,
|
|
63
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["query"];
|
|
64
|
+
}) & (undefined extends TParams | undefined ? {
|
|
65
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["params"] | undefined;
|
|
66
66
|
} : {
|
|
67
|
-
params: VovkTypedMethod<T,
|
|
67
|
+
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, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM>["__types"]["params"];
|
|
68
68
|
}) & {
|
|
69
69
|
meta?: {
|
|
70
70
|
[key: string]: any;
|
|
@@ -75,8 +75,8 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
75
75
|
models: {
|
|
76
76
|
iteration?: (ITERATION & ({} | null)) | undefined;
|
|
77
77
|
output?: (OUTPUT & ({} | null)) | undefined;
|
|
78
|
-
params?: (
|
|
79
|
-
query?: (
|
|
80
|
-
body?: (
|
|
78
|
+
params?: (TParams & ({} | null)) | undefined;
|
|
79
|
+
query?: (TQuery & ({} | null)) | undefined;
|
|
80
|
+
body?: (TBody & ({} | null)) | undefined;
|
|
81
81
|
};
|
|
82
82
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { PackageJson } from 'type-fest';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VovkGeneratorConfig, 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?: VovkGeneratorConfig[];
|
|
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: VovkGeneratorConfig['imports'];
|
|
17
|
+
reExports: VovkGeneratorConfig['reExports'];
|
|
18
18
|
};
|
|
@@ -4,14 +4,14 @@ 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>,
|
|
7
|
+
export declare function withValidationLibrary<T extends VovkTypedMethod<(req: KnownAny, params: KnownAny) => KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, KnownAny, boolean>, TBody_MODEL, TQuery_MODEL, TParams_MODEL, OUTPUT_MODEL, ITERATION_MODEL, IS_FORM extends boolean = false>({ isForm, disableServerSideValidation, skipSchemaEmission, validateEachIteration, body, query, params, output, iteration, handle, toJSONSchema, validate, operationObject, }: {
|
|
8
8
|
isForm?: IS_FORM;
|
|
9
9
|
disableServerSideValidation?: boolean | VovkValidationType[];
|
|
10
10
|
skipSchemaEmission?: boolean | VovkValidationType[];
|
|
11
11
|
validateEachIteration?: boolean;
|
|
12
|
-
body?:
|
|
13
|
-
query?:
|
|
14
|
-
params?:
|
|
12
|
+
body?: TBody_MODEL;
|
|
13
|
+
query?: TQuery_MODEL;
|
|
14
|
+
params?: TParams_MODEL;
|
|
15
15
|
output?: OUTPUT_MODEL;
|
|
16
16
|
iteration?: ITERATION_MODEL;
|
|
17
17
|
handle: T;
|
|
@@ -19,7 +19,7 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
|
|
|
19
19
|
meta: {
|
|
20
20
|
type: VovkValidationType;
|
|
21
21
|
}) => KnownAny;
|
|
22
|
-
validate: (data: KnownAny, model: NonNullable<
|
|
22
|
+
validate: (data: KnownAny, model: NonNullable<TBody_MODEL | TQuery_MODEL | TParams_MODEL | OUTPUT_MODEL | ITERATION_MODEL>, meta: {
|
|
23
23
|
type: VovkValidationType | 'form';
|
|
24
24
|
req: VovkRequestAny;
|
|
25
25
|
status?: number;
|
|
@@ -31,34 +31,34 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
|
|
|
31
31
|
wrapper?: (req: VovkRequestAny, params: Parameters<T>[1]) => ReturnType<T>;
|
|
32
32
|
} & {
|
|
33
33
|
fn: {
|
|
34
|
-
<RETURN_TYPE = ReturnType<T>>(input?: (undefined extends
|
|
34
|
+
<RETURN_TYPE = ReturnType<T>>(input?: (undefined extends TBody_MODEL | undefined ? undefined extends TQuery_MODEL | undefined ? undefined extends TParams_MODEL | undefined ? true : false : false : false) extends true ? {
|
|
35
35
|
disableClientValidation?: boolean;
|
|
36
|
-
} & (undefined extends
|
|
36
|
+
} & (undefined extends TBody_MODEL | undefined ? {
|
|
37
37
|
body?: T["__types"]["body"];
|
|
38
38
|
} : {
|
|
39
39
|
body: T["__types"]["body"];
|
|
40
|
-
}) & (undefined extends
|
|
40
|
+
}) & (undefined extends TQuery_MODEL | undefined ? {
|
|
41
41
|
query?: T["__types"]["query"];
|
|
42
42
|
} : {
|
|
43
43
|
query: T["__types"]["query"];
|
|
44
|
-
}) & (undefined extends
|
|
44
|
+
}) & (undefined extends TParams_MODEL | undefined ? {
|
|
45
45
|
params?: T["__types"]["params"];
|
|
46
46
|
} : {
|
|
47
47
|
params: T["__types"]["params"];
|
|
48
48
|
}) & {
|
|
49
49
|
meta?: Meta;
|
|
50
|
-
} : never): (undefined extends
|
|
50
|
+
} : never): (undefined extends TBody_MODEL | undefined ? undefined extends TQuery_MODEL | undefined ? undefined extends TParams_MODEL | undefined ? true : false : false : false) extends true ? RETURN_TYPE : never;
|
|
51
51
|
<RETURN_TYPE = ReturnType<T>>(input: {
|
|
52
52
|
disableClientValidation?: boolean;
|
|
53
|
-
} & (undefined extends
|
|
53
|
+
} & (undefined extends TBody_MODEL | undefined ? {
|
|
54
54
|
body?: T["__types"]["body"];
|
|
55
55
|
} : {
|
|
56
56
|
body: T["__types"]["body"];
|
|
57
|
-
}) & (undefined extends
|
|
57
|
+
}) & (undefined extends TQuery_MODEL | undefined ? {
|
|
58
58
|
query?: T["__types"]["query"];
|
|
59
59
|
} : {
|
|
60
60
|
query: T["__types"]["query"];
|
|
61
|
-
}) & (undefined extends
|
|
61
|
+
}) & (undefined extends TParams_MODEL | undefined ? {
|
|
62
62
|
params?: T["__types"]["params"];
|
|
63
63
|
} : {
|
|
64
64
|
params: T["__types"]["params"];
|
|
@@ -69,9 +69,9 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
|
|
|
69
69
|
models: {
|
|
70
70
|
iteration?: (ITERATION_MODEL & ({} | null)) | undefined;
|
|
71
71
|
output?: (OUTPUT_MODEL & ({} | null)) | undefined;
|
|
72
|
-
params?: (
|
|
73
|
-
query?: (
|
|
74
|
-
body?: (
|
|
72
|
+
params?: (TParams_MODEL & ({} | null)) | undefined;
|
|
73
|
+
query?: (TQuery_MODEL & ({} | null)) | undefined;
|
|
74
|
+
body?: (TBody_MODEL & ({} | null)) | undefined;
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
77
|
export {};
|