@veloxts/router 0.6.57 → 0.6.58

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.
@@ -0,0 +1,437 @@
1
+ /**
2
+ * OpenAPI 3.0.3 Type Definitions
3
+ *
4
+ * Type-safe definitions for generating OpenAPI specifications from VeloxTS procedures.
5
+ *
6
+ * @module @veloxts/router/openapi/types
7
+ */
8
+ import type { ProcedureCollection } from '../types.js';
9
+ /**
10
+ * JSON Schema representation for OpenAPI
11
+ */
12
+ export type JSONSchema = {
13
+ type?: string | string[];
14
+ format?: string;
15
+ title?: string;
16
+ description?: string;
17
+ default?: unknown;
18
+ enum?: unknown[];
19
+ const?: unknown;
20
+ nullable?: boolean;
21
+ properties?: Record<string, JSONSchema>;
22
+ required?: string[];
23
+ additionalProperties?: boolean | JSONSchema;
24
+ patternProperties?: Record<string, JSONSchema>;
25
+ minProperties?: number;
26
+ maxProperties?: number;
27
+ items?: JSONSchema | JSONSchema[];
28
+ minItems?: number;
29
+ maxItems?: number;
30
+ uniqueItems?: boolean;
31
+ minLength?: number;
32
+ maxLength?: number;
33
+ pattern?: string;
34
+ minimum?: number;
35
+ maximum?: number;
36
+ exclusiveMinimum?: number;
37
+ exclusiveMaximum?: number;
38
+ multipleOf?: number;
39
+ allOf?: JSONSchema[];
40
+ anyOf?: JSONSchema[];
41
+ oneOf?: JSONSchema[];
42
+ not?: JSONSchema;
43
+ $ref?: string;
44
+ example?: unknown;
45
+ deprecated?: boolean;
46
+ readOnly?: boolean;
47
+ writeOnly?: boolean;
48
+ [key: string]: unknown;
49
+ };
50
+ /**
51
+ * Contact information for the API
52
+ */
53
+ export interface OpenAPIContact {
54
+ name?: string;
55
+ url?: string;
56
+ email?: string;
57
+ }
58
+ /**
59
+ * License information for the API
60
+ */
61
+ export interface OpenAPILicense {
62
+ name: string;
63
+ url?: string;
64
+ }
65
+ /**
66
+ * API metadata
67
+ */
68
+ export interface OpenAPIInfo {
69
+ title: string;
70
+ version: string;
71
+ description?: string;
72
+ termsOfService?: string;
73
+ contact?: OpenAPIContact;
74
+ license?: OpenAPILicense;
75
+ }
76
+ /**
77
+ * Server information
78
+ */
79
+ export interface OpenAPIServer {
80
+ url: string;
81
+ description?: string;
82
+ variables?: Record<string, {
83
+ default: string;
84
+ enum?: string[];
85
+ description?: string;
86
+ }>;
87
+ }
88
+ /**
89
+ * Parameter location
90
+ */
91
+ export type ParameterIn = 'path' | 'query' | 'header' | 'cookie';
92
+ /**
93
+ * Parameter definition
94
+ */
95
+ export interface OpenAPIParameter {
96
+ name: string;
97
+ in: ParameterIn;
98
+ description?: string;
99
+ required?: boolean;
100
+ deprecated?: boolean;
101
+ allowEmptyValue?: boolean;
102
+ schema: JSONSchema;
103
+ example?: unknown;
104
+ examples?: Record<string, OpenAPIExample>;
105
+ }
106
+ /**
107
+ * Example object
108
+ */
109
+ export interface OpenAPIExample {
110
+ summary?: string;
111
+ description?: string;
112
+ value?: unknown;
113
+ externalValue?: string;
114
+ }
115
+ /**
116
+ * Media type object
117
+ */
118
+ export interface OpenAPIMediaType {
119
+ schema?: JSONSchema;
120
+ example?: unknown;
121
+ examples?: Record<string, OpenAPIExample>;
122
+ encoding?: Record<string, OpenAPIEncoding>;
123
+ }
124
+ /**
125
+ * Encoding object for multipart requests
126
+ */
127
+ export interface OpenAPIEncoding {
128
+ contentType?: string;
129
+ headers?: Record<string, OpenAPIHeader>;
130
+ style?: string;
131
+ explode?: boolean;
132
+ allowReserved?: boolean;
133
+ }
134
+ /**
135
+ * Header object
136
+ */
137
+ export interface OpenAPIHeader {
138
+ description?: string;
139
+ required?: boolean;
140
+ deprecated?: boolean;
141
+ schema?: JSONSchema;
142
+ example?: unknown;
143
+ }
144
+ /**
145
+ * Request body definition
146
+ */
147
+ export interface OpenAPIRequestBody {
148
+ description?: string;
149
+ required?: boolean;
150
+ content: Record<string, OpenAPIMediaType>;
151
+ }
152
+ /**
153
+ * Response definition
154
+ */
155
+ export interface OpenAPIResponse {
156
+ description: string;
157
+ headers?: Record<string, OpenAPIHeader>;
158
+ content?: Record<string, OpenAPIMediaType>;
159
+ links?: Record<string, OpenAPILink>;
160
+ }
161
+ /**
162
+ * Link object for response linking
163
+ */
164
+ export interface OpenAPILink {
165
+ operationRef?: string;
166
+ operationId?: string;
167
+ parameters?: Record<string, unknown>;
168
+ requestBody?: unknown;
169
+ description?: string;
170
+ server?: OpenAPIServer;
171
+ }
172
+ /**
173
+ * Security scheme types
174
+ */
175
+ export type SecuritySchemeType = 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
176
+ /**
177
+ * OAuth2 flow object
178
+ */
179
+ export interface OpenAPIOAuthFlow {
180
+ authorizationUrl?: string;
181
+ tokenUrl?: string;
182
+ refreshUrl?: string;
183
+ scopes: Record<string, string>;
184
+ }
185
+ /**
186
+ * OAuth2 flows object
187
+ */
188
+ export interface OpenAPIOAuthFlows {
189
+ implicit?: OpenAPIOAuthFlow;
190
+ password?: OpenAPIOAuthFlow;
191
+ clientCredentials?: OpenAPIOAuthFlow;
192
+ authorizationCode?: OpenAPIOAuthFlow;
193
+ }
194
+ /**
195
+ * Security scheme definition
196
+ */
197
+ export interface OpenAPISecurityScheme {
198
+ type: SecuritySchemeType;
199
+ description?: string;
200
+ name?: string;
201
+ in?: 'query' | 'header' | 'cookie';
202
+ scheme?: string;
203
+ bearerFormat?: string;
204
+ flows?: OpenAPIOAuthFlows;
205
+ openIdConnectUrl?: string;
206
+ }
207
+ /**
208
+ * Security requirement object
209
+ */
210
+ export type OpenAPISecurityRequirement = Record<string, string[]>;
211
+ /**
212
+ * External documentation object
213
+ */
214
+ export interface OpenAPIExternalDocs {
215
+ url: string;
216
+ description?: string;
217
+ }
218
+ /**
219
+ * Operation object (endpoint definition)
220
+ */
221
+ export interface OpenAPIOperation {
222
+ operationId?: string;
223
+ summary?: string;
224
+ description?: string;
225
+ tags?: string[];
226
+ externalDocs?: OpenAPIExternalDocs;
227
+ parameters?: OpenAPIParameter[];
228
+ requestBody?: OpenAPIRequestBody;
229
+ responses: Record<string, OpenAPIResponse>;
230
+ callbacks?: Record<string, Record<string, OpenAPIPathItem>>;
231
+ deprecated?: boolean;
232
+ security?: OpenAPISecurityRequirement[];
233
+ servers?: OpenAPIServer[];
234
+ }
235
+ /**
236
+ * Path item object (all operations for a path)
237
+ */
238
+ export interface OpenAPIPathItem {
239
+ $ref?: string;
240
+ summary?: string;
241
+ description?: string;
242
+ get?: OpenAPIOperation;
243
+ put?: OpenAPIOperation;
244
+ post?: OpenAPIOperation;
245
+ delete?: OpenAPIOperation;
246
+ options?: OpenAPIOperation;
247
+ head?: OpenAPIOperation;
248
+ patch?: OpenAPIOperation;
249
+ trace?: OpenAPIOperation;
250
+ servers?: OpenAPIServer[];
251
+ parameters?: OpenAPIParameter[];
252
+ }
253
+ /**
254
+ * Components object for reusable definitions
255
+ */
256
+ export interface OpenAPIComponents {
257
+ schemas?: Record<string, JSONSchema>;
258
+ responses?: Record<string, OpenAPIResponse>;
259
+ parameters?: Record<string, OpenAPIParameter>;
260
+ examples?: Record<string, OpenAPIExample>;
261
+ requestBodies?: Record<string, OpenAPIRequestBody>;
262
+ headers?: Record<string, OpenAPIHeader>;
263
+ securitySchemes?: Record<string, OpenAPISecurityScheme>;
264
+ links?: Record<string, OpenAPILink>;
265
+ callbacks?: Record<string, Record<string, OpenAPIPathItem>>;
266
+ }
267
+ /**
268
+ * Tag object for grouping operations
269
+ */
270
+ export interface OpenAPITag {
271
+ name: string;
272
+ description?: string;
273
+ externalDocs?: OpenAPIExternalDocs;
274
+ }
275
+ /**
276
+ * Complete OpenAPI 3.0.3 specification
277
+ */
278
+ export interface OpenAPISpec {
279
+ openapi: '3.0.3';
280
+ info: OpenAPIInfo;
281
+ servers?: OpenAPIServer[];
282
+ paths: Record<string, OpenAPIPathItem>;
283
+ components?: OpenAPIComponents;
284
+ security?: OpenAPISecurityRequirement[];
285
+ tags?: OpenAPITag[];
286
+ externalDocs?: OpenAPIExternalDocs;
287
+ }
288
+ /**
289
+ * Options for OpenAPI specification generation
290
+ */
291
+ export interface OpenAPIGeneratorOptions {
292
+ /**
293
+ * API info metadata (required)
294
+ */
295
+ info: OpenAPIInfo;
296
+ /**
297
+ * Server URLs for the API
298
+ */
299
+ servers?: OpenAPIServer[];
300
+ /**
301
+ * API prefix prepended to all paths
302
+ * @default '/api'
303
+ */
304
+ prefix?: string;
305
+ /**
306
+ * Security scheme definitions
307
+ * Merged with default schemes (bearerAuth)
308
+ */
309
+ securitySchemes?: Record<string, OpenAPISecurityScheme>;
310
+ /**
311
+ * Default security for all endpoints
312
+ * Applied when no guards are present
313
+ */
314
+ defaultSecurity?: OpenAPISecurityRequirement[];
315
+ /**
316
+ * Custom guard name to security scheme mapping
317
+ * @example { 'authenticated': 'bearerAuth', 'apiKey': 'apiKeyAuth' }
318
+ */
319
+ guardToSecurityMap?: Record<string, string>;
320
+ /**
321
+ * Tag descriptions for namespaces
322
+ * @example { 'users': 'User management endpoints' }
323
+ */
324
+ tagDescriptions?: Record<string, string>;
325
+ /**
326
+ * External documentation link
327
+ */
328
+ externalDocs?: OpenAPIExternalDocs;
329
+ /**
330
+ * Additional OpenAPI extensions (x-* properties)
331
+ */
332
+ extensions?: Record<string, unknown>;
333
+ }
334
+ /**
335
+ * Swagger UI configuration options
336
+ */
337
+ export interface SwaggerUIConfig {
338
+ /**
339
+ * Enable deep linking for tags and operations
340
+ * @default true
341
+ */
342
+ deepLinking?: boolean;
343
+ /**
344
+ * Display operationId in the UI
345
+ * @default false
346
+ */
347
+ displayOperationId?: boolean;
348
+ /**
349
+ * Default expand depth for models section
350
+ * @default 1
351
+ */
352
+ defaultModelsExpandDepth?: number;
353
+ /**
354
+ * Default expand depth for model properties
355
+ * @default 1
356
+ */
357
+ defaultModelExpandDepth?: number;
358
+ /**
359
+ * Controls expansion of operations and tags
360
+ * @default 'list'
361
+ */
362
+ docExpansion?: 'list' | 'full' | 'none';
363
+ /**
364
+ * Enable filter/search box
365
+ * @default false
366
+ */
367
+ filter?: boolean | string;
368
+ /**
369
+ * Show extensions (x-* fields)
370
+ * @default false
371
+ */
372
+ showExtensions?: boolean;
373
+ /**
374
+ * Enable "Try it out" by default
375
+ * @default true
376
+ */
377
+ tryItOutEnabled?: boolean;
378
+ /**
379
+ * Persist authorization data across browser sessions
380
+ * @default false
381
+ */
382
+ persistAuthorization?: boolean;
383
+ }
384
+ /**
385
+ * Options for the Swagger UI Fastify plugin
386
+ */
387
+ export interface SwaggerUIPluginOptions {
388
+ /**
389
+ * Route prefix for Swagger UI
390
+ * @default '/docs'
391
+ */
392
+ routePrefix?: string;
393
+ /**
394
+ * Route for raw OpenAPI JSON
395
+ * @default '/docs/openapi.json'
396
+ */
397
+ specRoute?: string;
398
+ /**
399
+ * Swagger UI configuration
400
+ */
401
+ uiConfig?: SwaggerUIConfig;
402
+ /**
403
+ * OpenAPI generator options
404
+ */
405
+ openapi: OpenAPIGeneratorOptions;
406
+ /**
407
+ * Procedure collections to document
408
+ */
409
+ collections: ProcedureCollection[];
410
+ /**
411
+ * Custom page title
412
+ * @default 'API Documentation'
413
+ */
414
+ title?: string;
415
+ /**
416
+ * Custom favicon URL
417
+ */
418
+ favicon?: string;
419
+ }
420
+ /**
421
+ * HTTP methods supported by OpenAPI
422
+ */
423
+ export type OpenAPIHttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'head';
424
+ /**
425
+ * Route information for generation
426
+ */
427
+ export interface RouteInfo {
428
+ method: OpenAPIHttpMethod;
429
+ path: string;
430
+ operationId: string;
431
+ namespace: string;
432
+ procedureName: string;
433
+ inputSchema?: JSONSchema;
434
+ outputSchema?: JSONSchema;
435
+ guards: string[];
436
+ deprecated?: boolean;
437
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * OpenAPI 3.0.3 Type Definitions
3
+ *
4
+ * Type-safe definitions for generating OpenAPI specifications from VeloxTS procedures.
5
+ *
6
+ * @module @veloxts/router/openapi/types
7
+ */
8
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/router",
3
- "version": "0.6.57",
3
+ "version": "0.6.58",
4
4
  "description": "Procedure definitions with tRPC and REST routing for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,6 +17,10 @@
17
17
  "./trpc": {
18
18
  "types": "./dist/trpc/index.d.ts",
19
19
  "import": "./dist/trpc/index.js"
20
+ },
21
+ "./openapi": {
22
+ "types": "./dist/openapi/index.d.ts",
23
+ "import": "./dist/openapi/index.js"
20
24
  }
21
25
  },
22
26
  "tsd": {
@@ -35,8 +39,9 @@
35
39
  "dependencies": {
36
40
  "@trpc/server": "11.8.0",
37
41
  "fastify": "5.6.2",
38
- "@veloxts/core": "0.6.57",
39
- "@veloxts/validation": "0.6.57"
42
+ "zod-to-json-schema": "3.24.5",
43
+ "@veloxts/validation": "0.6.58",
44
+ "@veloxts/core": "0.6.58"
40
45
  },
41
46
  "devDependencies": {
42
47
  "@vitest/coverage-v8": "4.0.16",