vovk 3.0.0-draft.99 → 3.0.2

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.
Files changed (168) hide show
  1. package/README.md +23 -12
  2. package/bin/index.mjs +10 -0
  3. package/dist/client/createRPC.d.ts +13 -3
  4. package/dist/client/createRPC.js +112 -50
  5. package/dist/client/defaultHandler.d.ts +5 -1
  6. package/dist/client/defaultHandler.js +12 -9
  7. package/dist/client/defaultStreamHandler.d.ts +16 -4
  8. package/dist/client/defaultStreamHandler.js +262 -62
  9. package/dist/client/fetcher.d.ts +41 -3
  10. package/dist/client/fetcher.js +125 -60
  11. package/dist/client/progressive.d.ts +15 -0
  12. package/dist/client/progressive.js +56 -0
  13. package/dist/{utils → client}/serializeQuery.d.ts +2 -2
  14. package/dist/{utils → client}/serializeQuery.js +2 -5
  15. package/dist/core/HttpException.d.ts +16 -0
  16. package/dist/core/HttpException.js +26 -0
  17. package/dist/core/JSONLinesResponder.d.ts +42 -0
  18. package/dist/core/JSONLinesResponder.js +94 -0
  19. package/dist/core/controllersToStaticParams.d.ts +13 -0
  20. package/dist/core/controllersToStaticParams.js +32 -0
  21. package/dist/core/createDecorator.d.ts +18 -0
  22. package/dist/core/createDecorator.js +60 -0
  23. package/dist/core/decorators.d.ts +66 -0
  24. package/dist/core/decorators.js +155 -0
  25. package/dist/core/getSchema.d.ts +21 -0
  26. package/dist/core/getSchema.js +31 -0
  27. package/dist/core/initSegment.d.ts +33 -0
  28. package/dist/core/initSegment.js +35 -0
  29. package/dist/core/multitenant.d.ts +33 -0
  30. package/dist/core/multitenant.js +132 -0
  31. package/dist/core/resolveGeneratorConfigValues.d.ts +19 -0
  32. package/dist/core/resolveGeneratorConfigValues.js +59 -0
  33. package/dist/{utils → core}/setHandlerSchema.d.ts +2 -2
  34. package/dist/{utils → core}/setHandlerSchema.js +1 -4
  35. package/dist/core/toDownloadResponse.d.ts +11 -0
  36. package/dist/core/toDownloadResponse.js +25 -0
  37. package/dist/core/vovkApp.d.ts +36 -0
  38. package/dist/core/vovkApp.js +318 -0
  39. package/dist/index.d.ts +25 -59
  40. package/dist/index.js +23 -23
  41. package/dist/internal.d.ts +17 -0
  42. package/dist/internal.js +10 -0
  43. package/dist/openapi/error.d.ts +6 -0
  44. package/dist/openapi/error.js +97 -0
  45. package/dist/openapi/openAPIToVovkSchema/applyComponentsSchemas.d.ts +3 -0
  46. package/dist/openapi/openAPIToVovkSchema/applyComponentsSchemas.js +65 -0
  47. package/dist/openapi/openAPIToVovkSchema/index.d.ts +5 -0
  48. package/dist/openapi/openAPIToVovkSchema/index.js +153 -0
  49. package/dist/openapi/openAPIToVovkSchema/inlineRefs.d.ts +9 -0
  50. package/dist/openapi/openAPIToVovkSchema/inlineRefs.js +99 -0
  51. package/dist/openapi/operation.d.ts +26 -0
  52. package/dist/openapi/operation.js +19 -0
  53. package/dist/openapi/tool.d.ts +6 -0
  54. package/dist/openapi/tool.js +12 -0
  55. package/dist/openapi/vovkSchemaToOpenAPI.d.ts +21 -0
  56. package/dist/openapi/vovkSchemaToOpenAPI.js +250 -0
  57. package/dist/req/bufferBody.d.ts +1 -0
  58. package/dist/req/bufferBody.js +30 -0
  59. package/dist/req/parseBody.d.ts +4 -0
  60. package/dist/req/parseBody.js +49 -0
  61. package/dist/req/parseForm.d.ts +1 -0
  62. package/dist/req/parseForm.js +24 -0
  63. package/dist/{utils → req}/parseQuery.d.ts +1 -2
  64. package/dist/{utils → req}/parseQuery.js +12 -12
  65. package/dist/req/reqMeta.d.ts +2 -0
  66. package/dist/{utils → req}/reqMeta.js +1 -4
  67. package/dist/req/reqQuery.d.ts +2 -0
  68. package/dist/req/reqQuery.js +4 -0
  69. package/dist/req/validateContentType.d.ts +1 -0
  70. package/dist/req/validateContentType.js +32 -0
  71. package/dist/samples/createCodeSamples.d.ts +20 -0
  72. package/dist/samples/createCodeSamples.js +293 -0
  73. package/dist/samples/objectToCode.d.ts +8 -0
  74. package/dist/samples/objectToCode.js +38 -0
  75. package/dist/samples/schemaToCode.d.ts +11 -0
  76. package/dist/samples/schemaToCode.js +264 -0
  77. package/dist/samples/schemaToObject.d.ts +2 -0
  78. package/dist/samples/schemaToObject.js +164 -0
  79. package/dist/samples/schemaToTsType.d.ts +2 -0
  80. package/dist/samples/schemaToTsType.js +114 -0
  81. package/dist/tools/ToModelOutput.d.ts +8 -0
  82. package/dist/tools/ToModelOutput.js +10 -0
  83. package/dist/tools/createTool.d.ts +126 -0
  84. package/dist/tools/createTool.js +6 -0
  85. package/dist/tools/createToolFactory.d.ts +135 -0
  86. package/dist/tools/createToolFactory.js +62 -0
  87. package/dist/tools/deriveTools.d.ts +46 -0
  88. package/dist/tools/deriveTools.js +132 -0
  89. package/dist/tools/toModelOutputDefault.d.ts +7 -0
  90. package/dist/tools/toModelOutputDefault.js +7 -0
  91. package/dist/tools/toModelOutputMCP.d.ts +30 -0
  92. package/dist/tools/toModelOutputMCP.js +54 -0
  93. package/dist/tsconfig.tsbuildinfo +1 -0
  94. package/dist/types/client.d.ts +139 -0
  95. package/dist/types/client.js +1 -0
  96. package/dist/types/config.d.ts +151 -0
  97. package/dist/types/config.js +1 -0
  98. package/dist/types/core.d.ts +115 -0
  99. package/dist/types/core.js +1 -0
  100. package/dist/types/enums.d.ts +75 -0
  101. package/dist/{types.js → types/enums.js} +21 -9
  102. package/dist/types/inference.d.ts +117 -0
  103. package/dist/types/inference.js +1 -0
  104. package/dist/types/json-schema.d.ts +51 -0
  105. package/dist/types/json-schema.js +1 -0
  106. package/dist/types/operation.d.ts +5 -0
  107. package/dist/types/operation.js +1 -0
  108. package/dist/types/package.d.ts +544 -0
  109. package/dist/types/package.js +5 -0
  110. package/dist/types/request.d.ts +48 -0
  111. package/dist/types/request.js +1 -0
  112. package/dist/types/standard-schema.d.ts +117 -0
  113. package/dist/types/standard-schema.js +6 -0
  114. package/dist/types/tools.d.ts +43 -0
  115. package/dist/types/tools.js +1 -0
  116. package/dist/types/utils.d.ts +9 -0
  117. package/dist/types/utils.js +1 -0
  118. package/dist/types/validation.d.ts +48 -0
  119. package/dist/types/validation.js +1 -0
  120. package/dist/utils/camelCase.d.ts +6 -0
  121. package/dist/utils/camelCase.js +34 -0
  122. package/dist/utils/deepExtend.d.ts +54 -0
  123. package/dist/utils/deepExtend.js +127 -0
  124. package/dist/utils/fileNameToDisposition.d.ts +1 -0
  125. package/dist/utils/fileNameToDisposition.js +3 -0
  126. package/dist/utils/shim.d.ts +1 -0
  127. package/dist/utils/shim.js +1 -1
  128. package/dist/utils/toKebabCase.d.ts +1 -0
  129. package/dist/utils/toKebabCase.js +5 -0
  130. package/dist/utils/trimPath.d.ts +1 -0
  131. package/dist/utils/trimPath.js +1 -0
  132. package/dist/utils/upperFirst.d.ts +1 -0
  133. package/dist/utils/upperFirst.js +3 -0
  134. package/dist/validation/createStandardValidation.d.ts +268 -0
  135. package/dist/validation/createStandardValidation.js +45 -0
  136. package/dist/validation/createValidateOnClient.d.ts +14 -0
  137. package/dist/validation/createValidateOnClient.js +23 -0
  138. package/dist/validation/procedure.d.ts +261 -0
  139. package/dist/validation/procedure.js +8 -0
  140. package/dist/validation/withValidationLibrary.d.ts +119 -0
  141. package/dist/validation/withValidationLibrary.js +174 -0
  142. package/package.json +45 -11
  143. package/dist/HttpException.d.ts +0 -7
  144. package/dist/HttpException.js +0 -15
  145. package/dist/StreamJSONResponse.d.ts +0 -14
  146. package/dist/StreamJSONResponse.js +0 -57
  147. package/dist/VovkApp.d.ts +0 -29
  148. package/dist/VovkApp.js +0 -188
  149. package/dist/client/index.d.ts +0 -3
  150. package/dist/client/index.js +0 -7
  151. package/dist/client/types.d.ts +0 -104
  152. package/dist/client/types.js +0 -2
  153. package/dist/createDecorator.d.ts +0 -6
  154. package/dist/createDecorator.js +0 -43
  155. package/dist/createVovkApp.d.ts +0 -62
  156. package/dist/createVovkApp.js +0 -118
  157. package/dist/types.d.ts +0 -220
  158. package/dist/utils/generateStaticAPI.d.ts +0 -4
  159. package/dist/utils/generateStaticAPI.js +0 -18
  160. package/dist/utils/getSchema.d.ts +0 -20
  161. package/dist/utils/getSchema.js +0 -33
  162. package/dist/utils/reqForm.d.ts +0 -2
  163. package/dist/utils/reqForm.js +0 -13
  164. package/dist/utils/reqMeta.d.ts +0 -2
  165. package/dist/utils/reqQuery.d.ts +0 -2
  166. package/dist/utils/reqQuery.js +0 -10
  167. package/dist/utils/withValidation.d.ts +0 -20
  168. package/dist/utils/withValidation.js +0 -72
@@ -0,0 +1,151 @@
1
+ import type { OpenAPIObject } from 'openapi3-ts/oas31';
2
+ import type { PackageJson } from './package.js';
3
+ import type { HttpMethod, VovkSchemaIdEnum } from './enums.js';
4
+ import type { VovkOperationObject } from './operation.js';
5
+ import type { KnownAny, RequireFields } from './utils.js';
6
+ export type VovkPackageJson = PackageJson & {
7
+ rs_name?: string;
8
+ py_name?: string;
9
+ };
10
+ export type VovkReadmeConfig = {
11
+ banner?: string;
12
+ installCommand?: string;
13
+ description?: string;
14
+ };
15
+ export type VovkSamplesConfig = {
16
+ apiRoot?: string;
17
+ headers?: Record<string, string>;
18
+ };
19
+ type IncludeExcludeSegments = {
20
+ excludeSegments?: never;
21
+ includeSegments?: string[];
22
+ } | {
23
+ excludeSegments?: string[];
24
+ includeSegments?: never;
25
+ };
26
+ type ClientConfigCommon = {
27
+ enabled?: boolean;
28
+ outDir?: string;
29
+ fromTemplates?: string[];
30
+ prettifyClient?: boolean;
31
+ outputConfig?: VovkOutputConfig<GeneratorConfigImports>;
32
+ } & IncludeExcludeSegments;
33
+ type ClientConfigComposed = ClientConfigCommon;
34
+ type ClientConfigSegmented = ClientConfigCommon;
35
+ export type VovkBundleConfig = {
36
+ requires?: Record<string, string>;
37
+ prebundleOutDir?: string;
38
+ keepPrebundleDir?: boolean;
39
+ outDir?: string;
40
+ build: (options: {
41
+ outDir: string;
42
+ prebundleDir: string;
43
+ entry: string;
44
+ }) => Promise<void>;
45
+ outputConfig?: VovkOutputConfig<GeneratorConfigImports>;
46
+ } & IncludeExcludeSegments;
47
+ type GeneratorConfigImports = {
48
+ fetcher?: string;
49
+ validateOnClient?: string | null;
50
+ createRPC?: string;
51
+ };
52
+ type SegmentConfigImports = {
53
+ fetcher?: string;
54
+ validateOnClient?: string | null;
55
+ };
56
+ export interface VovkOutputConfig<TImports extends GeneratorConfigImports = GeneratorConfigImports> {
57
+ origin?: string | null;
58
+ package?: VovkPackageJson;
59
+ readme?: VovkReadmeConfig;
60
+ samples?: VovkSamplesConfig;
61
+ openAPIObject?: Partial<OpenAPIObject>;
62
+ reExports?: Record<string, string>;
63
+ imports?: TImports;
64
+ }
65
+ export type ClientTemplateDef = {
66
+ extends?: string;
67
+ templatePath?: string | null;
68
+ composedClient?: Omit<ClientConfigComposed, 'fromTemplates' | 'enabled'>;
69
+ segmentedClient?: Omit<ClientConfigSegmented, 'fromTemplates' | 'enabled'>;
70
+ requires?: Record<string, string>;
71
+ outputConfig?: VovkOutputConfig<GeneratorConfigImports>;
72
+ };
73
+ export type GetOpenAPINameFn = (config: {
74
+ operationObject: VovkOperationObject;
75
+ method: HttpMethod;
76
+ path: string;
77
+ openAPIObject: OpenAPIObject;
78
+ }) => string;
79
+ export interface VovkOpenAPIMixin {
80
+ source: {
81
+ file: string;
82
+ } | {
83
+ url: string;
84
+ fallback?: string;
85
+ } | {
86
+ object: OpenAPIObject;
87
+ };
88
+ apiRoot?: string;
89
+ getModuleName?: 'nestjs-operation-id' | (string & {}) | 'api' | GetOpenAPINameFn;
90
+ getMethodName?: 'nestjs-operation-id' | 'camel-case-operation-id' | 'auto' | GetOpenAPINameFn;
91
+ errorMessageKey?: string;
92
+ mixinName?: string;
93
+ }
94
+ export interface VovkOpenAPIMixinNormalized extends Omit<VovkOpenAPIMixin, 'source' | 'getMethodName' | 'getModuleName'> {
95
+ source: Exclude<NonNullable<VovkOpenAPIMixin['source']>, {
96
+ file: string;
97
+ } | {
98
+ url: string;
99
+ }>;
100
+ getMethodName: GetOpenAPINameFn;
101
+ getModuleName: GetOpenAPINameFn;
102
+ }
103
+ export interface VovkSegmentConfig extends VovkOutputConfig<SegmentConfigImports> {
104
+ rootEntry?: string;
105
+ segmentNameOverride?: string;
106
+ openAPIMixin?: VovkOpenAPIMixin;
107
+ }
108
+ type VovkUserConfig = {
109
+ $schema?: typeof VovkSchemaIdEnum.CONFIG | (string & {});
110
+ exposeConfigKeys?: boolean | (keyof VovkStrictConfig | (string & {}))[];
111
+ schemaOutDir?: string;
112
+ modulesDir?: string;
113
+ rootEntry?: string;
114
+ logLevel?: 'error' | 'trace' | 'debug' | 'info' | 'warn';
115
+ libs?: {
116
+ ajv?: KnownAny;
117
+ [key: string]: KnownAny;
118
+ };
119
+ devHttps?: boolean;
120
+ composedClient?: ClientConfigComposed;
121
+ segmentedClient?: ClientConfigSegmented;
122
+ bundle?: VovkBundleConfig;
123
+ clientTemplateDefs?: Record<string, ClientTemplateDef>;
124
+ rootSegmentModulesDirName?: string;
125
+ moduleTemplates?: {
126
+ service?: string;
127
+ controller?: string;
128
+ [key: string]: string | undefined;
129
+ };
130
+ outputConfig?: VovkOutputConfig<GeneratorConfigImports> & {
131
+ segments?: Record<string, VovkSegmentConfig>;
132
+ };
133
+ };
134
+ /**
135
+ * The user configuration for Vovk.ts
136
+ * @see https://vovk.dev/config
137
+ */
138
+ export type VovkConfig = VovkUserConfig;
139
+ export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'exposeConfigKeys' | 'libs' | 'composedClient' | 'segmentedClient' | 'bundle'>> & {
140
+ exposeConfigKeys: (keyof VovkStrictConfig | string)[];
141
+ bundle: Required<Omit<NonNullable<VovkUserConfig['bundle']>, 'includeSegments' | 'excludeSegments'>> & IncludeExcludeSegments;
142
+ libs: Record<string, KnownAny>;
143
+ composedClient: RequireFields<ClientConfigComposed, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
144
+ segmentedClient: RequireFields<ClientConfigSegmented, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
145
+ outputConfig: VovkOutputConfig<GeneratorConfigImports> & {
146
+ segments?: Record<string, Omit<VovkSegmentConfig, 'openAPIMixin'> & {
147
+ openAPIMixin?: VovkOpenAPIMixinNormalized;
148
+ }>;
149
+ };
150
+ };
151
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,115 @@
1
+ import type { OpenAPIObject } from 'openapi3-ts/oas31';
2
+ import type { VovkPackageJson, VovkStrictConfig } from './config.js';
3
+ import type { HttpStatus, VovkSchemaIdEnum } from './enums.js';
4
+ import type { VovkJSONSchemaBase } from './json-schema.js';
5
+ import type { VovkOperationObject } from './operation.js';
6
+ import type { VovkRequest } from './request.js';
7
+ import type { KnownAny, RequireFields, StaticClass } from './utils.js';
8
+ import type { Responder } from '../core/JSONLinesResponder.js';
9
+ /**
10
+ * Schema for an individual handler, available as MyRPC.myHandler.schema and MyController.myHandler.schema
11
+ */
12
+ export type VovkHandlerSchema = {
13
+ path: string;
14
+ httpMethod: string;
15
+ validation?: {
16
+ query?: VovkJSONSchemaBase;
17
+ body?: VovkJSONSchemaBase;
18
+ params?: VovkJSONSchemaBase;
19
+ output?: VovkJSONSchemaBase;
20
+ iteration?: VovkJSONSchemaBase;
21
+ };
22
+ operationObject?: VovkOperationObject;
23
+ misc?: Record<string, unknown>;
24
+ };
25
+ /**
26
+ * Represents the schema of a controller
27
+ */
28
+ export type VovkControllerSchema = {
29
+ rpcModuleName: string;
30
+ originalControllerName?: string;
31
+ prefix?: string;
32
+ forceApiRoot?: string;
33
+ handlers: {
34
+ [key: string]: VovkHandlerSchema;
35
+ };
36
+ };
37
+ /**
38
+ * Represents the schema of a segment
39
+ */
40
+ export type VovkSegmentSchema = {
41
+ $schema: typeof VovkSchemaIdEnum.SEGMENT | (string & {});
42
+ emitSchema: boolean;
43
+ segmentName: string;
44
+ segmentType: 'segment' | 'mixin' | (string & {});
45
+ forceApiRoot?: string;
46
+ controllers: {
47
+ [key: string]: VovkControllerSchema;
48
+ };
49
+ meta?: {
50
+ openAPIObject?: Partial<Omit<OpenAPIObject, 'paths'>>;
51
+ package?: VovkPackageJson;
52
+ };
53
+ };
54
+ /**
55
+ * Represents the meta schema
56
+ */
57
+ export type VovkMetaSchema = {
58
+ $schema: typeof VovkSchemaIdEnum.META | (string & {});
59
+ config: RequireFields<Partial<VovkStrictConfig>, '$schema'>;
60
+ openAPIObject?: Partial<OpenAPIObject>;
61
+ };
62
+ /**
63
+ * Represents the full schema of composed client or a segment in segmented client.
64
+ * @see https://vovk.dev/schema
65
+ */
66
+ export type VovkSchema = {
67
+ $schema: typeof VovkSchemaIdEnum.SCHEMA | (string & {});
68
+ segments: {
69
+ [key: string]: VovkSegmentSchema;
70
+ };
71
+ meta?: VovkMetaSchema;
72
+ };
73
+ /**
74
+ * The shape of error responses
75
+ */
76
+ export type VovkErrorResponse = {
77
+ cause?: unknown;
78
+ statusCode: HttpStatus;
79
+ message: string;
80
+ isError: true;
81
+ };
82
+ export type StreamAbortMessage = {
83
+ isError: true;
84
+ reason: KnownAny;
85
+ };
86
+ export type VovkControllerInternal = {
87
+ _segmentName: string;
88
+ _rpcModuleName?: VovkControllerSchema['rpcModuleName'];
89
+ _prefix?: VovkControllerSchema['prefix'];
90
+ _handlers: VovkControllerSchema['handlers'];
91
+ _handlersMetadata?: Record<string, {
92
+ staticParams?: Record<string, string>[];
93
+ }>;
94
+ _onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
95
+ _onSuccess?: (resp: unknown, req: VovkRequest) => void | Promise<void>;
96
+ _onBefore?: (req: VovkRequest) => void | Promise<void>;
97
+ };
98
+ export type VovkController = StaticClass & VovkControllerInternal & {
99
+ [key: string]: unknown;
100
+ };
101
+ export type DecoratorOptions = {
102
+ cors?: boolean;
103
+ headers?: Record<string, string>;
104
+ staticParams?: Record<string, string>[];
105
+ before?: (this: VovkController, req: VovkRequest) => unknown;
106
+ };
107
+ export type RouteHandler = ((req: VovkRequest, params: Record<string, string>) => Response | Promise<Response> | Responder | Promise<Responder> | Iterable<unknown> | AsyncIterable<unknown>) & {
108
+ _options?: DecoratorOptions;
109
+ };
110
+ export type ControllerStaticMethod<REQ extends VovkRequest = VovkRequest, TParams extends {
111
+ [key: string]: string;
112
+ } = KnownAny> = ((req: REQ, params: TParams) => unknown) & {
113
+ _controller?: VovkController;
114
+ };
115
+ export type VovkValidationType = 'body' | 'query' | 'params' | 'output' | 'iteration' | 'tool-input';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,75 @@
1
+ /**
2
+ * HTTP methods enum
3
+ */
4
+ export declare enum HttpMethod {
5
+ GET = "GET",
6
+ POST = "POST",
7
+ PUT = "PUT",
8
+ PATCH = "PATCH",
9
+ DELETE = "DELETE",
10
+ HEAD = "HEAD",
11
+ OPTIONS = "OPTIONS"
12
+ }
13
+ /**
14
+ * HTTP status codes enum
15
+ */
16
+ export declare enum HttpStatus {
17
+ NULL = 0,
18
+ CONTINUE = 100,
19
+ SWITCHING_PROTOCOLS = 101,
20
+ PROCESSING = 102,
21
+ EARLYHINTS = 103,
22
+ OK = 200,
23
+ CREATED = 201,
24
+ ACCEPTED = 202,
25
+ NON_AUTHORITATIVE_INFORMATION = 203,
26
+ NO_CONTENT = 204,
27
+ RESET_CONTENT = 205,
28
+ PARTIAL_CONTENT = 206,
29
+ AMBIGUOUS = 300,
30
+ MOVED_PERMANENTLY = 301,
31
+ FOUND = 302,
32
+ SEE_OTHER = 303,
33
+ NOT_MODIFIED = 304,
34
+ TEMPORARY_REDIRECT = 307,
35
+ PERMANENT_REDIRECT = 308,
36
+ BAD_REQUEST = 400,
37
+ UNAUTHORIZED = 401,
38
+ PAYMENT_REQUIRED = 402,
39
+ FORBIDDEN = 403,
40
+ NOT_FOUND = 404,
41
+ METHOD_NOT_ALLOWED = 405,
42
+ NOT_ACCEPTABLE = 406,
43
+ PROXY_AUTHENTICATION_REQUIRED = 407,
44
+ REQUEST_TIMEOUT = 408,
45
+ CONFLICT = 409,
46
+ GONE = 410,
47
+ LENGTH_REQUIRED = 411,
48
+ PRECONDITION_FAILED = 412,
49
+ PAYLOAD_TOO_LARGE = 413,
50
+ URI_TOO_LONG = 414,
51
+ UNSUPPORTED_MEDIA_TYPE = 415,
52
+ REQUESTED_RANGE_NOT_SATISFIABLE = 416,
53
+ EXPECTATION_FAILED = 417,
54
+ I_AM_A_TEAPOT = 418,
55
+ MISDIRECTED = 421,
56
+ UNPROCESSABLE_ENTITY = 422,
57
+ FAILED_DEPENDENCY = 424,
58
+ PRECONDITION_REQUIRED = 428,
59
+ TOO_MANY_TRequestS = 429,
60
+ INTERNAL_SERVER_ERROR = 500,
61
+ NOT_IMPLEMENTED = 501,
62
+ BAD_GATEWAY = 502,
63
+ SERVICE_UNAVAILABLE = 503,
64
+ GATEWAY_TIMEOUT = 504,
65
+ HTTP_VERSION_NOT_SUPPORTED = 505
66
+ }
67
+ /**
68
+ * IDs of the JSON Schema files that can be generated by Vovk.ts
69
+ */
70
+ export declare enum VovkSchemaIdEnum {
71
+ META = "https://vovk.dev/api/schema/v3/meta.json",
72
+ CONFIG = "https://vovk.dev/api/schema/v3/config.json",
73
+ SEGMENT = "https://vovk.dev/api/schema/v3/segment.json",
74
+ SCHEMA = "https://vovk.dev/api/schema/v3/schema.json"
75
+ }
@@ -1,8 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpStatus = exports.HttpMethod = void 0;
4
- // Enums
5
- var HttpMethod;
1
+ /**
2
+ * HTTP methods enum
3
+ */
4
+ export var HttpMethod;
6
5
  (function (HttpMethod) {
7
6
  HttpMethod["GET"] = "GET";
8
7
  HttpMethod["POST"] = "POST";
@@ -11,8 +10,11 @@ var HttpMethod;
11
10
  HttpMethod["DELETE"] = "DELETE";
12
11
  HttpMethod["HEAD"] = "HEAD";
13
12
  HttpMethod["OPTIONS"] = "OPTIONS";
14
- })(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
15
- var HttpStatus;
13
+ })(HttpMethod || (HttpMethod = {}));
14
+ /**
15
+ * HTTP status codes enum
16
+ */
17
+ export var HttpStatus;
16
18
  (function (HttpStatus) {
17
19
  HttpStatus[HttpStatus["NULL"] = 0] = "NULL";
18
20
  HttpStatus[HttpStatus["CONTINUE"] = 100] = "CONTINUE";
@@ -56,11 +58,21 @@ var HttpStatus;
56
58
  HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
57
59
  HttpStatus[HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
58
60
  HttpStatus[HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
59
- HttpStatus[HttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
61
+ HttpStatus[HttpStatus["TOO_MANY_TRequestS"] = 429] = "TOO_MANY_TRequestS";
60
62
  HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
61
63
  HttpStatus[HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
62
64
  HttpStatus[HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
63
65
  HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
64
66
  HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
65
67
  HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
66
- })(HttpStatus || (exports.HttpStatus = HttpStatus = {}));
68
+ })(HttpStatus || (HttpStatus = {}));
69
+ /**
70
+ * IDs of the JSON Schema files that can be generated by Vovk.ts
71
+ */
72
+ export var VovkSchemaIdEnum;
73
+ (function (VovkSchemaIdEnum) {
74
+ VovkSchemaIdEnum["META"] = "https://vovk.dev/api/schema/v3/meta.json";
75
+ VovkSchemaIdEnum["CONFIG"] = "https://vovk.dev/api/schema/v3/config.json";
76
+ VovkSchemaIdEnum["SEGMENT"] = "https://vovk.dev/api/schema/v3/segment.json";
77
+ VovkSchemaIdEnum["SCHEMA"] = "https://vovk.dev/api/schema/v3/schema.json";
78
+ })(VovkSchemaIdEnum || (VovkSchemaIdEnum = {}));
@@ -0,0 +1,117 @@
1
+ import type { JSONLinesResponder } from '../core/JSONLinesResponder.js';
2
+ import type { VovkStreamAsyncIterable } from './client.js';
3
+ import type { VovkRequest } from './request.js';
4
+ import type { KnownAny } from './utils.js';
5
+ export type VovkControllerBody<T extends (...args: KnownAny[]) => unknown> = Awaited<ReturnType<Parameters<T>[0]['vovk']['body']>>;
6
+ export type VovkControllerQuery<T extends (...args: KnownAny[]) => unknown> = ReturnType<Parameters<T>[0]['vovk']['query']>;
7
+ export type VovkControllerParams<T extends (...args: KnownAny[]) => unknown> = Parameters<T>[1] extends object ? Parameters<T>[1] : ReturnType<Parameters<T>[0]['vovk']['params']>;
8
+ export type VovkControllerYieldType<T extends (req: VovkRequest<KnownAny, KnownAny>) => unknown> = T extends {
9
+ __types: {
10
+ iteration: infer U;
11
+ };
12
+ } ? unknown extends U ? never : U : T extends {
13
+ __handleFn: (...args: KnownAny[]) => infer R;
14
+ } ? R extends AsyncGenerator<infer Y, unknown, unknown> ? Y : R extends Generator<infer Y, unknown, unknown> ? Y : R extends Promise<JSONLinesResponder<infer Y>> | JSONLinesResponder<infer Y> ? Y : never : T extends (...args: KnownAny[]) => AsyncGenerator<infer Y, unknown, unknown> ? Y : T extends (...args: KnownAny[]) => Generator<infer Y, unknown, unknown> ? Y : T extends (...args: KnownAny[]) => Promise<JSONLinesResponder<infer Y>> | JSONLinesResponder<infer Y> ? Y : never;
15
+ /**
16
+ * Utility type to extract output from controller methods
17
+ * @see https://vovk.dev/inference
18
+ * @example
19
+ * ```ts
20
+ * type MyControllerOutput = VovkOutput<typeof MyController.myMethod>;
21
+ * ```
22
+ */
23
+ export type VovkOutput<T> = T extends {
24
+ __types?: {
25
+ output?: infer O;
26
+ };
27
+ } ? O : unknown;
28
+ /**
29
+ * Utility type to extract iteration (JSONLines output) from controller methods
30
+ * @see https://vovk.dev/inference
31
+ * @example
32
+ * ```ts
33
+ * type MyControllerIteration = VovkIteration<typeof MyController.myMethod>;
34
+ * ```
35
+ */
36
+ export type VovkIteration<T> = T extends {
37
+ __types?: {
38
+ iteration?: infer I;
39
+ };
40
+ } ? I : unknown;
41
+ export type VovkClientBody<T extends (opts: unknown) => unknown> = Parameters<T>[0] extends {
42
+ body: infer B;
43
+ } ? Exclude<B, Blob> : undefined;
44
+ export type VovkClientQuery<T extends (opts: unknown) => unknown> = Parameters<T>[0] extends {
45
+ query: infer Q;
46
+ } ? Q : undefined;
47
+ export type VovkClientParams<T extends (opts: unknown) => unknown> = Parameters<T>[0] extends {
48
+ params: infer P;
49
+ } ? P : undefined;
50
+ export type VovkClientYieldType<T extends (...args: KnownAny[]) => unknown> = T extends (...args: KnownAny[]) => Promise<VovkStreamAsyncIterable<infer Y>> ? Y : never;
51
+ /**
52
+ * Utility type to extract body from both controller and client methods
53
+ * @see https://vovk.dev/inference
54
+ * @example
55
+ * ```ts
56
+ * type MyControllerBody = VovkBody<typeof MyController.myMethod>;
57
+ * ```
58
+ */
59
+ export type VovkBody<T extends (...args: KnownAny[]) => unknown> = T extends {
60
+ isRPC: true;
61
+ } ? VovkClientBody<T> : T extends {
62
+ __types: {
63
+ body: infer B;
64
+ };
65
+ } ? B : VovkControllerBody<T>;
66
+ /**
67
+ * Utility type to extract query from both controller and client methods
68
+ * @see https://vovk.dev/inference
69
+ * @example
70
+ * ```ts
71
+ * type MyControllerQuery = VovkQuery<typeof MyController.myMethod>;
72
+ * ```
73
+ */
74
+ export type VovkQuery<T extends (...args: KnownAny[]) => unknown> = T extends {
75
+ isRPC: true;
76
+ } ? VovkClientQuery<T> : T extends {
77
+ __types: {
78
+ query: infer Q;
79
+ };
80
+ } ? Q : VovkControllerQuery<T>;
81
+ /**
82
+ * Utility type to extract params from both controller and client methods
83
+ * @see https://vovk.dev/inference
84
+ * @example
85
+ * ```ts
86
+ * type MyControllerParams = VovkParams<typeof MyController.myMethod>;
87
+ * ```
88
+ */
89
+ export type VovkParams<T extends (...args: KnownAny[]) => unknown> = T extends {
90
+ isRPC: true;
91
+ } ? VovkClientParams<T> : T extends {
92
+ __types: {
93
+ params: infer P;
94
+ };
95
+ } ? P : VovkControllerParams<T>;
96
+ /**
97
+ * Utility type to extract yield type from both controller and client methods
98
+ * @see https://vovk.dev/inference
99
+ * @example
100
+ * ```ts
101
+ * type MyControllerYieldType = VovkYieldType<typeof MyController.myMethod>;
102
+ * ```
103
+ */
104
+ export type VovkYieldType<T extends (...args: KnownAny[]) => unknown> = T extends {
105
+ isRPC: true;
106
+ } ? VovkClientYieldType<T> : VovkControllerYieldType<T>;
107
+ /**
108
+ * Utility type to extract return type from both controller and client methods
109
+ * @see https://vovk.dev/inference
110
+ * @example
111
+ * ```ts
112
+ * type MyControllerReturnType = VovkReturnType<typeof MyController.myMethod>;
113
+ * ```
114
+ */
115
+ export type VovkReturnType<T extends (...args: KnownAny) => unknown> = T extends {
116
+ __handleFn: (...args: KnownAny[]) => infer R;
117
+ } ? Awaited<R> : Awaited<ReturnType<T>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,51 @@
1
+ import type { KnownAny } from './utils.js';
2
+ import type { ContentType } from './validation.js';
3
+ type Type = 'object' | 'array' | 'string' | 'number' | 'boolean' | 'null' | 'integer';
4
+ /**
5
+ * Base JSON Schema type used in Vovk.ts for validation and code generation.
6
+ * @see https://vovk.dev/schema
7
+ */
8
+ export type VovkJSONSchemaBase = {
9
+ $schema?: 'https://json-schema.org/draft/2020-12/schema' | 'http://json-schema.org/draft-07/schema#';
10
+ type?: Type | Type[];
11
+ format?: string;
12
+ pattern?: string;
13
+ $ref?: string;
14
+ items?: boolean | VovkJSONSchemaBase;
15
+ prefixItems?: VovkJSONSchemaBase[];
16
+ additionalItems?: boolean | VovkJSONSchemaBase;
17
+ enum?: KnownAny[];
18
+ minimum?: number;
19
+ maximum?: number;
20
+ exclusiveMinimum?: number;
21
+ exclusiveMaximum?: number;
22
+ minItems?: number;
23
+ maxItems?: number;
24
+ title?: string;
25
+ description?: string;
26
+ properties?: {
27
+ [key: string]: VovkJSONSchemaBase;
28
+ };
29
+ required?: string[];
30
+ examples?: KnownAny[];
31
+ not?: VovkJSONSchemaBase;
32
+ $defs?: {
33
+ [key: string]: VovkJSONSchemaBase;
34
+ };
35
+ definitions?: {
36
+ [key: string]: VovkJSONSchemaBase;
37
+ };
38
+ additionalProperties?: boolean | VovkJSONSchemaBase;
39
+ anyOf?: VovkJSONSchemaBase[];
40
+ oneOf?: VovkJSONSchemaBase[];
41
+ allOf?: VovkJSONSchemaBase[];
42
+ const?: KnownAny;
43
+ example?: KnownAny;
44
+ contentEncoding?: string;
45
+ contentMediaType?: string;
46
+ minLength?: number;
47
+ maxLength?: number;
48
+ 'x-contentType'?: ContentType[];
49
+ 'x-tsType'?: string;
50
+ };
51
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { OperationObject } from 'openapi3-ts/oas31';
2
+ import type { VovkToolOptions } from './tools.js';
3
+ export type VovkOperationObject = OperationObject & {
4
+ 'x-tool'?: VovkToolOptions;
5
+ };
@@ -0,0 +1 @@
1
+ export {};