vovk 3.0.0-draft.46 → 3.0.0-draft.460

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 (207) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -96
  3. package/bin/index.mjs +8 -0
  4. package/cjs/JSONLinesResponse.d.ts +19 -0
  5. package/cjs/JSONLinesResponse.js +95 -0
  6. package/{VovkApp.d.ts → cjs/VovkApp.d.ts} +14 -8
  7. package/cjs/VovkApp.js +304 -0
  8. package/cjs/client/createRPC.d.ts +5 -0
  9. package/cjs/client/createRPC.js +116 -0
  10. package/cjs/client/defaultHandler.d.ts +6 -0
  11. package/{client → cjs/client}/defaultHandler.js +9 -2
  12. package/cjs/client/defaultStreamHandler.d.ts +9 -0
  13. package/{client → cjs/client}/defaultStreamHandler.js +49 -26
  14. package/cjs/client/fetcher.d.ts +18 -0
  15. package/cjs/client/fetcher.js +97 -0
  16. package/cjs/client/index.d.ts +4 -0
  17. package/cjs/client/index.js +10 -0
  18. package/cjs/client/progressive.d.ts +9 -0
  19. package/cjs/client/progressive.js +54 -0
  20. package/cjs/client/types.d.ts +120 -0
  21. package/{createVovkApp.d.ts → cjs/createVovkApp.d.ts} +19 -16
  22. package/cjs/createVovkApp.js +146 -0
  23. package/cjs/index.d.ts +69 -0
  24. package/cjs/index.js +42 -0
  25. package/cjs/openapi/error.d.ts +2 -0
  26. package/cjs/openapi/error.js +100 -0
  27. package/cjs/openapi/index.d.ts +8 -0
  28. package/cjs/openapi/index.js +21 -0
  29. package/cjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.d.ts +3 -0
  30. package/cjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.js +67 -0
  31. package/cjs/openapi/openAPIToVovkSchema/index.d.ts +4 -0
  32. package/cjs/openapi/openAPIToVovkSchema/index.js +141 -0
  33. package/cjs/openapi/openAPIToVovkSchema/inlineRefs.d.ts +10 -0
  34. package/cjs/openapi/openAPIToVovkSchema/inlineRefs.js +102 -0
  35. package/cjs/openapi/vovkSchemaToOpenAPI.d.ts +8 -0
  36. package/cjs/openapi/vovkSchemaToOpenAPI.js +238 -0
  37. package/cjs/types.d.ts +466 -0
  38. package/{types.js → cjs/types.js} +14 -2
  39. package/cjs/utils/camelCase.d.ts +6 -0
  40. package/cjs/utils/camelCase.js +37 -0
  41. package/cjs/utils/createCodeSamples.d.ts +20 -0
  42. package/cjs/utils/createCodeSamples.js +279 -0
  43. package/cjs/utils/createDecorator.d.ts +6 -0
  44. package/{createDecorator.js → cjs/utils/createDecorator.js} +24 -14
  45. package/cjs/utils/createLLMTools.d.ts +50 -0
  46. package/cjs/utils/createLLMTools.js +168 -0
  47. package/cjs/utils/createStandardValidation.d.ts +82 -0
  48. package/cjs/utils/createStandardValidation.js +34 -0
  49. package/cjs/utils/createValidateOnClient.d.ts +7 -0
  50. package/cjs/utils/createValidateOnClient.js +19 -0
  51. package/cjs/utils/deepExtend.d.ts +54 -0
  52. package/cjs/utils/deepExtend.js +134 -0
  53. package/{utils → cjs/utils}/generateStaticAPI.d.ts +2 -2
  54. package/cjs/utils/generateStaticAPI.js +30 -0
  55. package/cjs/utils/getJSONSchemaExample.d.ts +11 -0
  56. package/cjs/utils/getJSONSchemaExample.js +264 -0
  57. package/cjs/utils/getJSONSchemaSample.d.ts +2 -0
  58. package/cjs/utils/getJSONSchemaSample.js +167 -0
  59. package/cjs/utils/getSampleFromObject.d.ts +9 -0
  60. package/cjs/utils/getSampleFromObject.js +41 -0
  61. package/cjs/utils/getSchema.d.ts +21 -0
  62. package/cjs/utils/getSchema.js +38 -0
  63. package/cjs/utils/multitenant.d.ts +24 -0
  64. package/cjs/utils/multitenant.js +131 -0
  65. package/cjs/utils/parseQuery.d.ts +25 -0
  66. package/cjs/utils/parseQuery.js +156 -0
  67. package/cjs/utils/reqForm.d.ts +2 -0
  68. package/cjs/utils/reqForm.js +33 -0
  69. package/cjs/utils/reqMeta.d.ts +2 -0
  70. package/cjs/utils/reqQuery.d.ts +2 -0
  71. package/cjs/utils/reqQuery.js +10 -0
  72. package/cjs/utils/resolveGeneratorConfigValues.d.ts +18 -0
  73. package/cjs/utils/resolveGeneratorConfigValues.js +82 -0
  74. package/cjs/utils/serializeQuery.d.ts +13 -0
  75. package/cjs/utils/serializeQuery.js +65 -0
  76. package/cjs/utils/setHandlerSchema.d.ts +4 -0
  77. package/cjs/utils/setHandlerSchema.js +15 -0
  78. package/cjs/utils/upperFirst.d.ts +1 -0
  79. package/cjs/utils/upperFirst.js +6 -0
  80. package/cjs/utils/withValidationLibrary.d.ts +77 -0
  81. package/cjs/utils/withValidationLibrary.js +124 -0
  82. package/mjs/HttpException.d.ts +7 -0
  83. package/mjs/HttpException.js +15 -0
  84. package/mjs/JSONLinesResponse.d.ts +19 -0
  85. package/mjs/JSONLinesResponse.js +95 -0
  86. package/mjs/VovkApp.d.ts +34 -0
  87. package/mjs/VovkApp.js +304 -0
  88. package/mjs/client/createRPC.d.ts +5 -0
  89. package/mjs/client/createRPC.js +116 -0
  90. package/mjs/client/defaultHandler.d.ts +6 -0
  91. package/mjs/client/defaultHandler.js +29 -0
  92. package/mjs/client/defaultStreamHandler.d.ts +9 -0
  93. package/mjs/client/defaultStreamHandler.js +105 -0
  94. package/mjs/client/fetcher.d.ts +18 -0
  95. package/mjs/client/fetcher.js +97 -0
  96. package/mjs/client/index.d.ts +4 -0
  97. package/mjs/client/index.js +10 -0
  98. package/mjs/client/progressive.d.ts +9 -0
  99. package/mjs/client/progressive.js +54 -0
  100. package/mjs/client/types.d.ts +120 -0
  101. package/mjs/createVovkApp.d.ts +65 -0
  102. package/mjs/createVovkApp.js +146 -0
  103. package/mjs/index.d.ts +69 -0
  104. package/mjs/index.js +42 -0
  105. package/mjs/openapi/error.d.ts +2 -0
  106. package/mjs/openapi/error.js +100 -0
  107. package/mjs/openapi/index.d.ts +8 -0
  108. package/mjs/openapi/index.js +21 -0
  109. package/mjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.d.ts +3 -0
  110. package/mjs/openapi/openAPIToVovkSchema/applyComponentsSchemas.js +67 -0
  111. package/mjs/openapi/openAPIToVovkSchema/index.d.ts +4 -0
  112. package/mjs/openapi/openAPIToVovkSchema/index.js +141 -0
  113. package/mjs/openapi/openAPIToVovkSchema/inlineRefs.d.ts +10 -0
  114. package/mjs/openapi/openAPIToVovkSchema/inlineRefs.js +102 -0
  115. package/mjs/openapi/vovkSchemaToOpenAPI.d.ts +8 -0
  116. package/mjs/openapi/vovkSchemaToOpenAPI.js +238 -0
  117. package/mjs/types.d.ts +466 -0
  118. package/mjs/types.js +77 -0
  119. package/mjs/utils/camelCase.d.ts +6 -0
  120. package/mjs/utils/camelCase.js +37 -0
  121. package/mjs/utils/createCodeSamples.d.ts +20 -0
  122. package/mjs/utils/createCodeSamples.js +279 -0
  123. package/mjs/utils/createDecorator.d.ts +6 -0
  124. package/mjs/utils/createDecorator.js +48 -0
  125. package/mjs/utils/createLLMTools.d.ts +50 -0
  126. package/mjs/utils/createLLMTools.js +168 -0
  127. package/mjs/utils/createStandardValidation.d.ts +82 -0
  128. package/mjs/utils/createStandardValidation.js +34 -0
  129. package/mjs/utils/createValidateOnClient.d.ts +7 -0
  130. package/mjs/utils/createValidateOnClient.js +19 -0
  131. package/mjs/utils/deepExtend.d.ts +54 -0
  132. package/mjs/utils/deepExtend.js +134 -0
  133. package/mjs/utils/generateStaticAPI.d.ts +4 -0
  134. package/mjs/utils/generateStaticAPI.js +30 -0
  135. package/mjs/utils/getJSONSchemaExample.d.ts +11 -0
  136. package/mjs/utils/getJSONSchemaExample.js +264 -0
  137. package/mjs/utils/getJSONSchemaSample.d.ts +2 -0
  138. package/mjs/utils/getJSONSchemaSample.js +167 -0
  139. package/mjs/utils/getSampleFromObject.d.ts +9 -0
  140. package/mjs/utils/getSampleFromObject.js +41 -0
  141. package/mjs/utils/getSchema.d.ts +21 -0
  142. package/mjs/utils/getSchema.js +38 -0
  143. package/mjs/utils/multitenant.d.ts +24 -0
  144. package/mjs/utils/multitenant.js +131 -0
  145. package/mjs/utils/parseQuery.d.ts +25 -0
  146. package/mjs/utils/parseQuery.js +156 -0
  147. package/mjs/utils/reqForm.d.ts +2 -0
  148. package/mjs/utils/reqForm.js +33 -0
  149. package/mjs/utils/reqMeta.d.ts +2 -0
  150. package/mjs/utils/reqMeta.js +13 -0
  151. package/mjs/utils/reqQuery.d.ts +2 -0
  152. package/mjs/utils/reqQuery.js +10 -0
  153. package/mjs/utils/resolveGeneratorConfigValues.d.ts +18 -0
  154. package/mjs/utils/resolveGeneratorConfigValues.js +82 -0
  155. package/mjs/utils/serializeQuery.d.ts +13 -0
  156. package/mjs/utils/serializeQuery.js +65 -0
  157. package/mjs/utils/setHandlerSchema.d.ts +4 -0
  158. package/mjs/utils/setHandlerSchema.js +15 -0
  159. package/mjs/utils/shim.d.ts +1 -0
  160. package/mjs/utils/shim.js +18 -0
  161. package/mjs/utils/upperFirst.d.ts +1 -0
  162. package/mjs/utils/upperFirst.js +6 -0
  163. package/mjs/utils/withValidationLibrary.d.ts +77 -0
  164. package/mjs/utils/withValidationLibrary.js +124 -0
  165. package/package.json +28 -6
  166. package/.npmignore +0 -2
  167. package/StreamJSONResponse.d.ts +0 -17
  168. package/StreamJSONResponse.js +0 -54
  169. package/VovkApp.js +0 -185
  170. package/client/clientizeController.d.ts +0 -4
  171. package/client/clientizeController.js +0 -93
  172. package/client/defaultFetcher.d.ts +0 -4
  173. package/client/defaultFetcher.js +0 -49
  174. package/client/defaultHandler.d.ts +0 -2
  175. package/client/defaultStreamHandler.d.ts +0 -4
  176. package/client/index.d.ts +0 -4
  177. package/client/index.js +0 -5
  178. package/client/types.d.ts +0 -100
  179. package/createDecorator.d.ts +0 -4
  180. package/createVovkApp.js +0 -118
  181. package/index.d.ts +0 -60
  182. package/index.js +0 -20
  183. package/types.d.ts +0 -157
  184. package/utils/generateStaticAPI.js +0 -18
  185. package/utils/getSchema.d.ts +0 -8
  186. package/utils/getSchema.js +0 -38
  187. package/utils/reqForm.d.ts +0 -3
  188. package/utils/reqForm.js +0 -13
  189. package/utils/reqMeta.d.ts +0 -3
  190. package/utils/reqQuery.d.ts +0 -3
  191. package/utils/reqQuery.js +0 -25
  192. package/utils/setClientValidatorsForHandler.d.ts +0 -5
  193. package/utils/setClientValidatorsForHandler.js +0 -25
  194. package/worker/index.d.ts +0 -3
  195. package/worker/index.js +0 -7
  196. package/worker/promisifyWorker.d.ts +0 -2
  197. package/worker/promisifyWorker.js +0 -141
  198. package/worker/types.d.ts +0 -31
  199. package/worker/worker.d.ts +0 -1
  200. package/worker/worker.js +0 -43
  201. /package/{HttpException.d.ts → cjs/HttpException.d.ts} +0 -0
  202. /package/{HttpException.js → cjs/HttpException.js} +0 -0
  203. /package/{client → cjs/client}/types.js +0 -0
  204. /package/{utils → cjs/utils}/reqMeta.js +0 -0
  205. /package/{utils → cjs/utils}/shim.d.ts +0 -0
  206. /package/{utils → cjs/utils}/shim.js +0 -0
  207. /package/{worker → mjs/client}/types.js +0 -0
package/cjs/types.d.ts ADDED
@@ -0,0 +1,466 @@
1
+ import type { NextRequest } from 'next/server';
2
+ import type { OpenAPIObject, OperationObject } from 'openapi3-ts/oas31';
3
+ import type { JSONLinesResponse } from './JSONLinesResponse';
4
+ import type { VovkStreamAsyncIterable } from './client/types';
5
+ import type { PackageJson } from 'type-fest';
6
+ export type KnownAny = any;
7
+ export type StaticClass = Function;
8
+ export type VovkPackageJson = PackageJson & {
9
+ rs_name?: string;
10
+ py_name?: string;
11
+ };
12
+ /**
13
+ * Schema for an individual handler, available as MyRPC.myHandler.schema and MyController.myHandler.schema
14
+ */
15
+ export type VovkHandlerSchema = {
16
+ path: string;
17
+ httpMethod: string;
18
+ validation?: {
19
+ query?: VovkBasicJSONSchema;
20
+ body?: VovkBasicJSONSchema;
21
+ params?: VovkBasicJSONSchema;
22
+ output?: VovkBasicJSONSchema;
23
+ iteration?: VovkBasicJSONSchema;
24
+ };
25
+ operationObject?: VovkOperationObject;
26
+ misc?: Record<string, KnownAny>;
27
+ };
28
+ /**
29
+ * Represents the schema of a controller
30
+ */
31
+ export type VovkControllerSchema = {
32
+ rpcModuleName: string;
33
+ originalControllerName?: string;
34
+ prefix?: string;
35
+ forceApiRoot?: string;
36
+ handlers: {
37
+ [key: string]: VovkHandlerSchema;
38
+ };
39
+ };
40
+ /**
41
+ * Represents the schema of a segment
42
+ */
43
+ export type VovkSegmentSchema = {
44
+ $schema: typeof VovkSchemaIdEnum.SEGMENT | (string & {});
45
+ emitSchema: boolean;
46
+ segmentName: string;
47
+ segmentType: 'segment' | 'mixin' | (string & {});
48
+ forceApiRoot?: string;
49
+ controllers: {
50
+ [key: string]: VovkControllerSchema;
51
+ };
52
+ meta?: {
53
+ openAPIObject?: Partial<Omit<OpenAPIObject, 'paths'>>;
54
+ package?: VovkPackageJson;
55
+ };
56
+ };
57
+ /**
58
+ * Represents the meta schema
59
+ */
60
+ export type VovkMetaSchema = {
61
+ $schema: typeof VovkSchemaIdEnum.META | (string & {});
62
+ config: RequireFields<Partial<VovkStrictConfig>, '$schema'>;
63
+ openAPIObject?: Partial<OpenAPIObject>;
64
+ };
65
+ /**
66
+ * Represents the full schema of composed client or a segment in segmented client.
67
+ */
68
+ export type VovkSchema = {
69
+ $schema: typeof VovkSchemaIdEnum.SCHEMA | (string & {});
70
+ segments: {
71
+ [key: string]: VovkSegmentSchema;
72
+ };
73
+ meta?: VovkMetaSchema;
74
+ };
75
+ /**
76
+ * The shape of error responses
77
+ */
78
+ export type VovkErrorResponse = {
79
+ cause?: unknown;
80
+ statusCode: HttpStatus;
81
+ message: string;
82
+ isError: true;
83
+ };
84
+ export type VovkControllerInternal = {
85
+ _rpcModuleName?: VovkControllerSchema['rpcModuleName'];
86
+ _prefix?: VovkControllerSchema['prefix'];
87
+ _handlers: VovkControllerSchema['handlers'];
88
+ _handlersMetadata?: Record<string, {
89
+ staticParams?: Record<string, string>[];
90
+ }>;
91
+ _onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
92
+ _onSuccess?: (resp: unknown, req: VovkRequest) => void | Promise<void>;
93
+ _onBefore?: (req: VovkRequest) => void | Promise<void>;
94
+ };
95
+ export type VovkController = StaticClass & VovkControllerInternal & {
96
+ [key: string]: unknown;
97
+ };
98
+ export type DecoratorOptions = {
99
+ cors?: boolean;
100
+ headers?: Record<string, string>;
101
+ staticParams?: Record<string, string>[];
102
+ before?: (this: VovkController, req: VovkRequest) => unknown;
103
+ };
104
+ export type RouteHandler = ((req: VovkRequest, params: Record<string, string>) => Response | Promise<Response> | Iterable<unknown> | AsyncIterable<unknown>) & {
105
+ _options?: DecoratorOptions;
106
+ };
107
+ export interface VovkRequest<TBody extends KnownAny = unknown, TQuery extends KnownAny = unknown, TParams extends KnownAny = unknown> extends Omit<NextRequest, 'json' | 'nextUrl'> {
108
+ json: () => Promise<TBody>;
109
+ nextUrl: Omit<NextRequest['nextUrl'], 'searchParams'> & {
110
+ searchParams: Omit<NextRequest['nextUrl']['searchParams'], 'get' | 'getAll' | 'entries' | 'forEach' | 'keys' | 'values'> & {
111
+ get: <KEY extends keyof TQuery>(key: KEY) => TQuery[KEY] extends readonly (infer ITEM)[] ? ITEM : TQuery[KEY];
112
+ getAll: <KEY extends keyof TQuery>(key: KEY) => TQuery[KEY] extends KnownAny[] ? TQuery[KEY] : TQuery[KEY][];
113
+ entries: () => IterableIterator<[keyof TQuery, TQuery[keyof TQuery]]>;
114
+ forEach: (callbackfn: (value: TQuery[keyof TQuery], key: keyof TQuery, searchParams: NextRequest['nextUrl']['searchParams']) => void) => void;
115
+ keys: () => IterableIterator<keyof TQuery>;
116
+ values: () => IterableIterator<TQuery[keyof TQuery]>;
117
+ };
118
+ };
119
+ vovk: {
120
+ body: () => Promise<TBody>;
121
+ query: () => TQuery;
122
+ meta: <T = Record<KnownAny, KnownAny>>(meta?: T | null) => T;
123
+ form: <T = TBody>() => Promise<T>;
124
+ params: () => TParams;
125
+ };
126
+ }
127
+ export type ControllerStaticMethod<REQ extends VovkRequest<KnownAny, KnownAny, KnownAny> = VovkRequest, TParams extends {
128
+ [key: string]: string;
129
+ } = KnownAny> = ((req: REQ, params: TParams) => unknown) & {
130
+ _controller?: VovkController;
131
+ };
132
+ export type VovkTypedMethod<T extends (...args: KnownAny[]) => KnownAny, B = KnownAny, Q = KnownAny, P = KnownAny, O = KnownAny, I = KnownAny, IS_FORM extends boolean = false> = T & {
133
+ __types: {
134
+ body: B;
135
+ query: Q;
136
+ params: P;
137
+ output: O;
138
+ iteration: I;
139
+ isForm: IS_FORM;
140
+ };
141
+ isRPC?: boolean;
142
+ };
143
+ export type VovkControllerBody<T extends (...args: KnownAny) => KnownAny> = Awaited<ReturnType<Parameters<T>[0]['vovk']['body']>>;
144
+ export type VovkControllerQuery<T extends (...args: KnownAny) => KnownAny> = ReturnType<Parameters<T>[0]['vovk']['query']>;
145
+ export type VovkControllerParams<T extends (...args: KnownAny) => KnownAny> = Parameters<T>[1] extends object ? Parameters<T>[1] : ReturnType<Parameters<T>[0]['vovk']['params']>;
146
+ export type VovkControllerYieldType<T extends (req: VovkRequest<KnownAny, KnownAny>) => KnownAny> = T extends (...args: KnownAny[]) => AsyncGenerator<infer Y, KnownAny, KnownAny> ? Y : T extends (...args: KnownAny[]) => Generator<infer Y, KnownAny, KnownAny> ? Y : T extends (...args: KnownAny[]) => Promise<JSONLinesResponse<infer Y>> | JSONLinesResponse<infer Y> ? Y : never;
147
+ export type VovkOutput<T> = T extends {
148
+ __types?: {
149
+ output?: infer O;
150
+ };
151
+ } ? O : KnownAny;
152
+ export type VovkIteration<T> = T extends {
153
+ __types?: {
154
+ iteration?: infer I;
155
+ };
156
+ } ? I : KnownAny;
157
+ export type VovkClientBody<T extends (opts: KnownAny) => KnownAny> = Parameters<T>[0] extends {
158
+ body: infer B;
159
+ } ? B : undefined;
160
+ export type VovkClientQuery<T extends (opts: KnownAny) => KnownAny> = Parameters<T>[0] extends {
161
+ query: infer Q;
162
+ } ? Q : undefined;
163
+ export type VovkClientParams<T extends (opts: KnownAny) => KnownAny> = Parameters<T>[0] extends {
164
+ params: infer P;
165
+ } ? P : undefined;
166
+ export type VovkClientYieldType<T extends (...args: KnownAny[]) => unknown> = T extends (...args: KnownAny[]) => Promise<VovkStreamAsyncIterable<infer Y>> ? Y : never;
167
+ export type VovkBody<T extends (...args: KnownAny[]) => unknown> = T extends {
168
+ isRPC: true;
169
+ } ? VovkClientBody<T> : VovkControllerBody<T>;
170
+ export type VovkQuery<T extends (...args: KnownAny[]) => unknown> = T extends {
171
+ isRPC: true;
172
+ } ? VovkClientQuery<T> : VovkControllerQuery<T>;
173
+ export type VovkParams<T extends (...args: KnownAny[]) => unknown> = T extends {
174
+ isRPC: true;
175
+ } ? VovkClientParams<T> : VovkControllerParams<T>;
176
+ export type VovkYieldType<T extends (...args: KnownAny[]) => unknown> = T extends {
177
+ isRPC: true;
178
+ } ? VovkClientYieldType<T> : VovkControllerYieldType<T>;
179
+ export type VovkReturnType<T extends (...args: KnownAny) => unknown> = Awaited<ReturnType<T>>;
180
+ export type StreamAbortMessage = {
181
+ isError: true;
182
+ reason: KnownAny;
183
+ };
184
+ export type VovkValidationType = 'body' | 'query' | 'params' | 'output' | 'iteration';
185
+ export declare enum HttpMethod {
186
+ GET = "GET",
187
+ POST = "POST",
188
+ PUT = "PUT",
189
+ PATCH = "PATCH",
190
+ DELETE = "DELETE",
191
+ HEAD = "HEAD",
192
+ OPTIONS = "OPTIONS"
193
+ }
194
+ export declare enum HttpStatus {
195
+ NULL = 0,
196
+ CONTINUE = 100,
197
+ SWITCHING_PROTOCOLS = 101,
198
+ PROCESSING = 102,
199
+ EARLYHINTS = 103,
200
+ OK = 200,
201
+ CREATED = 201,
202
+ ACCEPTED = 202,
203
+ NON_AUTHORITATIVE_INFORMATION = 203,
204
+ NO_CONTENT = 204,
205
+ RESET_CONTENT = 205,
206
+ PARTIAL_CONTENT = 206,
207
+ AMBIGUOUS = 300,
208
+ MOVED_PERMANENTLY = 301,
209
+ FOUND = 302,
210
+ SEE_OTHER = 303,
211
+ NOT_MODIFIED = 304,
212
+ TEMPORARY_REDIRECT = 307,
213
+ PERMANENT_REDIRECT = 308,
214
+ BAD_REQUEST = 400,
215
+ UNAUTHORIZED = 401,
216
+ PAYMENT_REQUIRED = 402,
217
+ FORBIDDEN = 403,
218
+ NOT_FOUND = 404,
219
+ METHOD_NOT_ALLOWED = 405,
220
+ NOT_ACCEPTABLE = 406,
221
+ PROXY_AUTHENTICATION_REQUIRED = 407,
222
+ REQUEST_TIMEOUT = 408,
223
+ CONFLICT = 409,
224
+ GONE = 410,
225
+ LENGTH_REQUIRED = 411,
226
+ PRECONDITION_FAILED = 412,
227
+ PAYLOAD_TOO_LARGE = 413,
228
+ URI_TOO_LONG = 414,
229
+ UNSUPPORTED_MEDIA_TYPE = 415,
230
+ REQUESTED_RANGE_NOT_SATISFIABLE = 416,
231
+ EXPECTATION_FAILED = 417,
232
+ I_AM_A_TEAPOT = 418,
233
+ MISDIRECTED = 421,
234
+ UNPROCESSABLE_ENTITY = 422,
235
+ FAILED_DEPENDENCY = 424,
236
+ PRECONDITION_REQUIRED = 428,
237
+ TOO_MANY_TRequestS = 429,
238
+ INTERNAL_SERVER_ERROR = 500,
239
+ NOT_IMPLEMENTED = 501,
240
+ BAD_GATEWAY = 502,
241
+ SERVICE_UNAVAILABLE = 503,
242
+ GATEWAY_TIMEOUT = 504,
243
+ HTTP_VERSION_NOT_SUPPORTED = 505
244
+ }
245
+ export interface VovkLLMTool {
246
+ execute: (input: {
247
+ body?: KnownAny;
248
+ query?: KnownAny;
249
+ params?: KnownAny;
250
+ }, options?: KnownAny) => Promise<KnownAny>;
251
+ name: string;
252
+ description: string;
253
+ parameters?: {
254
+ type: 'object';
255
+ properties?: {
256
+ body?: VovkBasicJSONSchema;
257
+ query?: VovkBasicJSONSchema;
258
+ params?: VovkBasicJSONSchema;
259
+ };
260
+ required?: ('body' | 'query' | 'params')[];
261
+ additionalProperties?: boolean;
262
+ };
263
+ models: {
264
+ body?: KnownAny;
265
+ query?: KnownAny;
266
+ params?: KnownAny;
267
+ output?: KnownAny;
268
+ iteration?: KnownAny;
269
+ } | undefined;
270
+ type: 'function';
271
+ }
272
+ export type VovkBasicJSONSchema = {
273
+ $schema?: string;
274
+ type?: string | string[];
275
+ format?: string;
276
+ $ref?: string;
277
+ items?: VovkBasicJSONSchema;
278
+ enum?: KnownAny[];
279
+ minimum?: number;
280
+ maximum?: number;
281
+ title?: string;
282
+ description?: string;
283
+ properties?: {
284
+ [key: string]: VovkBasicJSONSchema;
285
+ };
286
+ required?: string[];
287
+ examples?: KnownAny[];
288
+ $defs?: {
289
+ [key: string]: VovkBasicJSONSchema;
290
+ };
291
+ definitions?: {
292
+ [key: string]: VovkBasicJSONSchema;
293
+ };
294
+ additionalProperties?: boolean;
295
+ anyOf?: VovkBasicJSONSchema[];
296
+ oneOf?: VovkBasicJSONSchema[];
297
+ allOf?: VovkBasicJSONSchema[];
298
+ const?: KnownAny;
299
+ example?: KnownAny;
300
+ contentEncoding?: string;
301
+ contentMediaType?: string;
302
+ minLength?: number;
303
+ maxLength?: number;
304
+ [key: `x-${string}`]: KnownAny;
305
+ };
306
+ export type VovkOperationObject = OperationObject & {
307
+ 'x-tool-disable'?: boolean;
308
+ 'x-tool-description'?: string;
309
+ 'x-tool-successMessage'?: string;
310
+ 'x-tool-errorMessage'?: string;
311
+ 'x-tool-includeResponse'?: boolean;
312
+ };
313
+ /**
314
+ * IDs of the JSON Schema files that can be generated by Vovk.ts
315
+ */
316
+ export declare enum VovkSchemaIdEnum {
317
+ META = "https://vovk.dev/api/schema/v3/meta.json",
318
+ CONFIG = "https://vovk.dev/api/schema/v3/config.json",
319
+ SEGMENT = "https://vovk.dev/api/schema/v3/segment.json",
320
+ SCHEMA = "https://vovk.dev/api/schema/v3/schema.json"
321
+ }
322
+ export type VovkReadmeConfig = {
323
+ banner?: string;
324
+ installCommand?: string;
325
+ description?: string;
326
+ };
327
+ export type VovkSamplesConfig = {
328
+ apiRoot?: string;
329
+ headers?: Record<string, string>;
330
+ };
331
+ type ClientConfigCommon = {
332
+ enabled?: boolean;
333
+ outDir?: string;
334
+ fromTemplates?: string[];
335
+ prettifyClient?: boolean;
336
+ } & ({
337
+ excludeSegments?: never;
338
+ includeSegments?: string[];
339
+ } | {
340
+ excludeSegments?: string[];
341
+ includeSegments?: never;
342
+ });
343
+ type ClientConfigComposed = ClientConfigCommon;
344
+ type ClientConfigSegmented = ClientConfigCommon;
345
+ type BundleConfig = {
346
+ requires?: Record<string, string>;
347
+ prebundleOutDir?: string;
348
+ keepPrebundleDir?: boolean;
349
+ tsdownBuildOptions?: Parameters<typeof import('tsdown') extends {
350
+ build: infer T;
351
+ } ? T : never>[0];
352
+ generatorConfig?: VovkGeneratorConfig<GeneratorConfigImports>;
353
+ } & ({
354
+ excludeSegments?: never;
355
+ includeSegments?: string[];
356
+ } | {
357
+ excludeSegments?: string[];
358
+ includeSegments?: never;
359
+ });
360
+ type GeneratorConfigImports = {
361
+ fetcher?: string | [string, string] | [string];
362
+ validateOnClient?: string | [string, string] | [string] | null;
363
+ createRPC?: string | [string, string] | [string];
364
+ };
365
+ type SegmentConfigImports = {
366
+ fetcher?: string | [string, string] | [string];
367
+ validateOnClient?: string | [string, string] | [string] | null;
368
+ };
369
+ export interface VovkGeneratorConfig<TImports extends GeneratorConfigImports = GeneratorConfigImports> {
370
+ origin?: string | null;
371
+ package?: VovkPackageJson;
372
+ readme?: VovkReadmeConfig;
373
+ samples?: VovkSamplesConfig;
374
+ openAPIObject?: Partial<OpenAPIObject>;
375
+ reExports?: Record<string, string>;
376
+ imports?: TImports;
377
+ }
378
+ export type ClientTemplateDef = {
379
+ extends?: string;
380
+ templatePath?: string | null;
381
+ composedClient?: Omit<ClientConfigComposed, 'fromTemplates' | 'enabled'>;
382
+ segmentedClient?: Omit<ClientConfigSegmented, 'fromTemplates' | 'enabled'>;
383
+ requires?: Record<string, string>;
384
+ generatorConfig?: VovkGeneratorConfig<GeneratorConfigImports>;
385
+ };
386
+ export type GetOpenAPINameFn = (config: {
387
+ operationObject: VovkOperationObject;
388
+ method: HttpMethod;
389
+ path: string;
390
+ openAPIObject: OpenAPIObject;
391
+ }) => string;
392
+ export interface VovkOpenAPIMixin {
393
+ source: {
394
+ file: string;
395
+ } | {
396
+ url: string;
397
+ fallback?: string;
398
+ } | {
399
+ object: OpenAPIObject;
400
+ };
401
+ apiRoot?: string;
402
+ getModuleName?: 'nestjs-operation-id' | (string & {}) | 'api' | GetOpenAPINameFn;
403
+ getMethodName?: 'nestjs-operation-id' | 'camel-case-operation-id' | 'auto' | GetOpenAPINameFn;
404
+ errorMessageKey?: string;
405
+ mixinName?: string;
406
+ }
407
+ export interface VovkOpenAPIMixinNormalized extends Omit<VovkOpenAPIMixin, 'source' | 'getMethodName' | 'getModuleName'> {
408
+ source: Exclude<NonNullable<VovkOpenAPIMixin['source']>, {
409
+ file: string;
410
+ } | {
411
+ url: string;
412
+ }>;
413
+ getMethodName: GetOpenAPINameFn;
414
+ getModuleName: GetOpenAPINameFn;
415
+ }
416
+ export interface VovkSegmentConfig extends VovkGeneratorConfig<SegmentConfigImports> {
417
+ rootEntry?: string;
418
+ segmentNameOverride?: string;
419
+ openAPIMixin?: VovkOpenAPIMixin;
420
+ }
421
+ type VovkUserConfig = {
422
+ $schema?: typeof VovkSchemaIdEnum.CONFIG | (string & {});
423
+ emitConfig?: boolean | (keyof VovkStrictConfig | (string & {}))[];
424
+ schemaOutDir?: string;
425
+ modulesDir?: string;
426
+ rootEntry?: string;
427
+ logLevel?: 'error' | 'trace' | 'debug' | 'info' | 'warn' | (string & {});
428
+ libs?: {
429
+ ajv: KnownAny;
430
+ [key: string]: KnownAny;
431
+ };
432
+ devHttps?: boolean;
433
+ composedClient?: ClientConfigComposed;
434
+ segmentedClient?: ClientConfigSegmented;
435
+ bundle?: BundleConfig;
436
+ clientTemplateDefs?: Record<string, ClientTemplateDef>;
437
+ rootSegmentModulesDirName?: string;
438
+ moduleTemplates?: {
439
+ service?: string;
440
+ controller?: string;
441
+ [key: string]: string | undefined;
442
+ };
443
+ generatorConfig?: VovkGeneratorConfig<GeneratorConfigImports> & {
444
+ segments?: Record<string, VovkSegmentConfig>;
445
+ };
446
+ };
447
+ export type VovkConfig = VovkUserConfig;
448
+ export type VovkStrictConfig = Required<Omit<VovkUserConfig, 'emitConfig' | 'libs' | 'composedClient' | 'segmentedClient' | 'bundle'>> & {
449
+ emitConfig: (keyof VovkStrictConfig | string)[];
450
+ bundle: RequireAllExcept<NonNullable<VovkUserConfig['bundle']>, 'includeSegments' | 'excludeSegments'>;
451
+ libs: Record<string, KnownAny>;
452
+ composedClient: RequireFields<ClientConfigComposed, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
453
+ segmentedClient: RequireFields<ClientConfigSegmented, 'enabled' | 'fromTemplates' | 'outDir' | 'prettifyClient'>;
454
+ generatorConfig: VovkGeneratorConfig<GeneratorConfigImports> & {
455
+ segments?: Record<string, Omit<VovkSegmentConfig, 'openAPIMixin'> & {
456
+ openAPIMixin?: VovkOpenAPIMixinNormalized;
457
+ }>;
458
+ };
459
+ };
460
+ export type RequireFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
461
+ export type RequireAllExcept<T, K extends keyof T> = Required<Omit<T, K>> & Pick<T, K>;
462
+ export type IsEmptyObject<T> = T extends object ? keyof T extends never ? true : T extends Partial<T> ? Partial<T> extends T ? true : false : false : false;
463
+ export type Prettify<T> = {
464
+ [K in keyof T]: T[K];
465
+ } & {};
466
+ export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpStatus = exports.HttpMethod = void 0;
3
+ exports.VovkSchemaIdEnum = exports.HttpStatus = exports.HttpMethod = void 0;
4
+ // Enums
4
5
  var HttpMethod;
5
6
  (function (HttpMethod) {
6
7
  HttpMethod["GET"] = "GET";
@@ -55,7 +56,7 @@ var HttpStatus;
55
56
  HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
56
57
  HttpStatus[HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
57
58
  HttpStatus[HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
58
- HttpStatus[HttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
59
+ HttpStatus[HttpStatus["TOO_MANY_TRequestS"] = 429] = "TOO_MANY_TRequestS";
59
60
  HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
60
61
  HttpStatus[HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
61
62
  HttpStatus[HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
@@ -63,3 +64,14 @@ var HttpStatus;
63
64
  HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
64
65
  HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
65
66
  })(HttpStatus || (exports.HttpStatus = HttpStatus = {}));
67
+ // -----
68
+ /**
69
+ * IDs of the JSON Schema files that can be generated by Vovk.ts
70
+ */
71
+ var VovkSchemaIdEnum;
72
+ (function (VovkSchemaIdEnum) {
73
+ VovkSchemaIdEnum["META"] = "https://vovk.dev/api/schema/v3/meta.json";
74
+ VovkSchemaIdEnum["CONFIG"] = "https://vovk.dev/api/schema/v3/config.json";
75
+ VovkSchemaIdEnum["SEGMENT"] = "https://vovk.dev/api/schema/v3/segment.json";
76
+ VovkSchemaIdEnum["SCHEMA"] = "https://vovk.dev/api/schema/v3/schema.json";
77
+ })(VovkSchemaIdEnum || (exports.VovkSchemaIdEnum = VovkSchemaIdEnum = {}));
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Converts string to camel case.
3
+ * @param {*} input - The value to convert to camel case.
4
+ * @returns {string}
5
+ */
6
+ export declare function camelCase(input: string): string;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.camelCase = camelCase;
4
+ // Convert any value to string
5
+ function toString(value) {
6
+ return value == null ? '' : String(value);
7
+ }
8
+ // Regex to match words (including Unicode letters & digits)
9
+ const reUnicodeWord = /[\p{Lu}]{2,}(?=[\p{Lu}][\p{Ll}]+[0-9]*|\b)|[\p{Lu}]?[\p{Ll}]+[0-9]*|[\p{Lu}]|[0-9]+/gu;
10
+ /**
11
+ * Splits string into an array of words based on Unicode word boundaries
12
+ * @param {string} str
13
+ * @returns {string[]}
14
+ */
15
+ function unicodeWords(str) {
16
+ return str.match(reUnicodeWord) || [];
17
+ }
18
+ /**
19
+ * Converts string to camel case.
20
+ * @param {*} input - The value to convert to camel case.
21
+ * @returns {string}
22
+ */
23
+ function camelCase(input) {
24
+ const str = toString(input);
25
+ // replace separators with space
26
+ const sanitized = str.replace(/[\s_-]+/g, ' ').trim();
27
+ const words = unicodeWords(sanitized);
28
+ return words
29
+ .map((word, index) => {
30
+ const lower = word.toLowerCase();
31
+ if (index === 0) {
32
+ return lower;
33
+ }
34
+ return lower.charAt(0).toUpperCase() + lower.slice(1);
35
+ })
36
+ .join('');
37
+ }
@@ -0,0 +1,20 @@
1
+ import type { KnownAny, VovkControllerSchema, VovkHandlerSchema, VovkSamplesConfig } from '../types';
2
+ export type CodeSamplePackageJson = {
3
+ name?: string;
4
+ version?: string;
5
+ description?: string;
6
+ rs_name?: string;
7
+ py_name?: string;
8
+ [key: string]: KnownAny;
9
+ };
10
+ export declare function createCodeSamples({ handlerName, handlerSchema, controllerSchema, package: packageJson, config, }: {
11
+ handlerName: string;
12
+ handlerSchema: VovkHandlerSchema;
13
+ controllerSchema: VovkControllerSchema;
14
+ package?: CodeSamplePackageJson;
15
+ config: VovkSamplesConfig;
16
+ }): {
17
+ ts: string;
18
+ py: string;
19
+ rs: string;
20
+ };