@skmtc/core 0.0.807 → 0.0.809
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/esm/oas/array/array-types.d.ts +238 -25
- package/esm/oas/array/array-types.d.ts.map +1 -1
- package/esm/oas/array/array-types.js +97 -5
- package/esm/oas/boolean/boolean-types.d.ts +81 -9
- package/esm/oas/boolean/boolean-types.d.ts.map +1 -1
- package/esm/oas/boolean/boolean-types.js +32 -2
- package/esm/oas/contact/contact-types.d.ts +176 -0
- package/esm/oas/contact/contact-types.d.ts.map +1 -1
- package/esm/oas/contact/contact-types.js +102 -0
- package/esm/oas/mediaType/toMediaTypeItemV3.d.ts +288 -0
- package/esm/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
- package/esm/oas/mediaType/toMediaTypeItemV3.js +272 -0
- package/esm/oas/operation/operation-types.d.ts +251 -0
- package/esm/oas/operation/operation-types.d.ts.map +1 -1
- package/esm/oas/operation/operation-types.js +98 -0
- package/esm/oas/string/string-types.d.ts +192 -18
- package/esm/oas/string/string-types.d.ts.map +1 -1
- package/esm/oas/string/string-types.js +76 -4
- package/esm/types/ModuleExport.d.ts +130 -0
- package/esm/types/ModuleExport.d.ts.map +1 -1
- package/esm/types/ModuleExport.js +36 -0
- package/esm/types/PrettierConfig.d.ts +74 -0
- package/esm/types/PrettierConfig.d.ts.map +1 -1
- package/esm/types/PrettierConfig.js +74 -0
- package/esm/types/Results.d.ts +97 -0
- package/esm/types/Results.d.ts.map +1 -1
- package/esm/types/Results.js +97 -0
- package/package.json +1 -1
- package/script/oas/array/array-types.d.ts +238 -25
- package/script/oas/array/array-types.d.ts.map +1 -1
- package/script/oas/array/array-types.js +97 -5
- package/script/oas/boolean/boolean-types.d.ts +81 -9
- package/script/oas/boolean/boolean-types.d.ts.map +1 -1
- package/script/oas/boolean/boolean-types.js +32 -2
- package/script/oas/contact/contact-types.d.ts +176 -0
- package/script/oas/contact/contact-types.d.ts.map +1 -1
- package/script/oas/contact/contact-types.js +102 -0
- package/script/oas/mediaType/toMediaTypeItemV3.d.ts +288 -0
- package/script/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
- package/script/oas/mediaType/toMediaTypeItemV3.js +272 -0
- package/script/oas/operation/operation-types.d.ts +251 -0
- package/script/oas/operation/operation-types.d.ts.map +1 -1
- package/script/oas/operation/operation-types.js +98 -0
- package/script/oas/string/string-types.d.ts +192 -18
- package/script/oas/string/string-types.d.ts.map +1 -1
- package/script/oas/string/string-types.js +76 -4
- package/script/types/ModuleExport.d.ts +130 -0
- package/script/types/ModuleExport.d.ts.map +1 -1
- package/script/types/ModuleExport.js +36 -0
- package/script/types/PrettierConfig.d.ts +74 -0
- package/script/types/PrettierConfig.d.ts.map +1 -1
- package/script/types/PrettierConfig.js +74 -0
- package/script/types/Results.d.ts +97 -0
- package/script/types/Results.d.ts.map +1 -1
- package/script/types/Results.js +97 -0
|
@@ -4,19 +4,270 @@ import { type OasParameterRefData, type OasRequestBodyRefData, type OasResponseR
|
|
|
4
4
|
import { type OasRequestBodyData } from '../requestBody/requestBody-types.js';
|
|
5
5
|
import { type OasResponseData } from '../response/response-types.js';
|
|
6
6
|
import * as v from 'valibot';
|
|
7
|
+
/**
|
|
8
|
+
* Data type for OpenAPI operation objects processed by the SKMTC pipeline.
|
|
9
|
+
*
|
|
10
|
+
* This type represents a complete OpenAPI operation (API endpoint) including all
|
|
11
|
+
* associated metadata, parameters, request body, responses, and path information.
|
|
12
|
+
* It serves as the internal representation of OpenAPI operations during the
|
|
13
|
+
* code generation process, combining operation data with its parent path item context.
|
|
14
|
+
*
|
|
15
|
+
* ## Usage in SKMTC Pipeline
|
|
16
|
+
*
|
|
17
|
+
* This type is used by:
|
|
18
|
+
* - Operation parsers to validate and structure incoming OpenAPI operations
|
|
19
|
+
* - Code generators to access operation metadata and generate client code
|
|
20
|
+
* - Response processors to understand expected API responses
|
|
21
|
+
* - Parameter handlers to generate request validation and typing
|
|
22
|
+
*
|
|
23
|
+
* @example Basic GET operation
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import type { OasOperationData } from '@skmtc/core/oas/operation';
|
|
26
|
+
*
|
|
27
|
+
* const getUserOperation: OasOperationData = {
|
|
28
|
+
* oasType: 'operation',
|
|
29
|
+
* path: '/users/{id}',
|
|
30
|
+
* method: 'get',
|
|
31
|
+
* operationId: 'getUserById',
|
|
32
|
+
* summary: 'Get user by ID',
|
|
33
|
+
* description: 'Retrieves a specific user by their unique identifier',
|
|
34
|
+
* tags: ['users'],
|
|
35
|
+
* parameters: [
|
|
36
|
+
* {
|
|
37
|
+
* name: 'id',
|
|
38
|
+
* in: 'path',
|
|
39
|
+
* required: true,
|
|
40
|
+
* schema: { type: 'string' }
|
|
41
|
+
* }
|
|
42
|
+
* ],
|
|
43
|
+
* responses: {
|
|
44
|
+
* '200': {
|
|
45
|
+
* description: 'User found',
|
|
46
|
+
* content: {
|
|
47
|
+
* 'application/json': {
|
|
48
|
+
* schema: { $ref: '#/components/schemas/User' }
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
* },
|
|
52
|
+
* '404': {
|
|
53
|
+
* description: 'User not found'
|
|
54
|
+
* }
|
|
55
|
+
* },
|
|
56
|
+
* pathItem: pathItemData
|
|
57
|
+
* };
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example POST operation with request body
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const createUserOperation: OasOperationData = {
|
|
63
|
+
* oasType: 'operation',
|
|
64
|
+
* path: '/users',
|
|
65
|
+
* method: 'post',
|
|
66
|
+
* operationId: 'createUser',
|
|
67
|
+
* summary: 'Create new user',
|
|
68
|
+
* description: 'Creates a new user account',
|
|
69
|
+
* tags: ['users'],
|
|
70
|
+
* requestBody: {
|
|
71
|
+
* description: 'User data',
|
|
72
|
+
* required: true,
|
|
73
|
+
* content: {
|
|
74
|
+
* 'application/json': {
|
|
75
|
+
* schema: { $ref: '#/components/schemas/CreateUserRequest' }
|
|
76
|
+
* }
|
|
77
|
+
* }
|
|
78
|
+
* },
|
|
79
|
+
* responses: {
|
|
80
|
+
* '201': {
|
|
81
|
+
* description: 'User created successfully',
|
|
82
|
+
* content: {
|
|
83
|
+
* 'application/json': {
|
|
84
|
+
* schema: { $ref: '#/components/schemas/User' }
|
|
85
|
+
* }
|
|
86
|
+
* }
|
|
87
|
+
* },
|
|
88
|
+
* '400': {
|
|
89
|
+
* description: 'Invalid request data'
|
|
90
|
+
* }
|
|
91
|
+
* },
|
|
92
|
+
* pathItem: pathItemData
|
|
93
|
+
* };
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @example Operation with query parameters
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const listUsersOperation: OasOperationData = {
|
|
99
|
+
* oasType: 'operation',
|
|
100
|
+
* path: '/users',
|
|
101
|
+
* method: 'get',
|
|
102
|
+
* operationId: 'listUsers',
|
|
103
|
+
* summary: 'List users',
|
|
104
|
+
* description: 'Get paginated list of users',
|
|
105
|
+
* tags: ['users'],
|
|
106
|
+
* parameters: [
|
|
107
|
+
* {
|
|
108
|
+
* name: 'page',
|
|
109
|
+
* in: 'query',
|
|
110
|
+
* schema: { type: 'integer', minimum: 1, default: 1 }
|
|
111
|
+
* },
|
|
112
|
+
* {
|
|
113
|
+
* name: 'limit',
|
|
114
|
+
* in: 'query',
|
|
115
|
+
* schema: { type: 'integer', minimum: 1, maximum: 100, default: 20 }
|
|
116
|
+
* },
|
|
117
|
+
* {
|
|
118
|
+
* name: 'status',
|
|
119
|
+
* in: 'query',
|
|
120
|
+
* schema: { type: 'string', enum: ['active', 'inactive'] }
|
|
121
|
+
* }
|
|
122
|
+
* ],
|
|
123
|
+
* responses: {
|
|
124
|
+
* '200': {
|
|
125
|
+
* description: 'List of users',
|
|
126
|
+
* content: {
|
|
127
|
+
* 'application/json': {
|
|
128
|
+
* schema: {
|
|
129
|
+
* type: 'object',
|
|
130
|
+
* properties: {
|
|
131
|
+
* users: {
|
|
132
|
+
* type: 'array',
|
|
133
|
+
* items: { $ref: '#/components/schemas/User' }
|
|
134
|
+
* },
|
|
135
|
+
* totalCount: { type: 'integer' },
|
|
136
|
+
* page: { type: 'integer' },
|
|
137
|
+
* limit: { type: 'integer' }
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
* }
|
|
141
|
+
* }
|
|
142
|
+
* }
|
|
143
|
+
* },
|
|
144
|
+
* pathItem: pathItemData
|
|
145
|
+
* };
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
7
148
|
export type OasOperationData = {
|
|
149
|
+
/** Type identifier for SKMTC internal processing */
|
|
8
150
|
oasType: 'operation';
|
|
151
|
+
/** Parent path item containing this operation */
|
|
9
152
|
pathItem: OasPathItemData;
|
|
153
|
+
/** The API path template (e.g., '/users/{id}') */
|
|
10
154
|
path: string;
|
|
155
|
+
/** HTTP method for this operation */
|
|
11
156
|
method: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace';
|
|
157
|
+
/** Unique identifier for this operation (used for client method names) */
|
|
12
158
|
operationId?: string;
|
|
159
|
+
/** Tags for grouping operations (used for code organization) */
|
|
13
160
|
tags?: string[];
|
|
161
|
+
/** Brief summary of what the operation does */
|
|
14
162
|
summary?: string;
|
|
163
|
+
/** Detailed description of the operation behavior */
|
|
15
164
|
description?: string;
|
|
165
|
+
/** List of parameters (path, query, header, cookie) */
|
|
16
166
|
parameters?: (OasParameterData | OasParameterRefData)[];
|
|
167
|
+
/** Request body specification for operations that accept data */
|
|
17
168
|
requestBody?: OasRequestBodyData | OasRequestBodyRefData;
|
|
169
|
+
/** Map of status codes to response specifications */
|
|
18
170
|
responses: Record<string, OasResponseData | OasResponseRefData>;
|
|
171
|
+
/** Whether this operation is deprecated */
|
|
19
172
|
deprecated?: boolean;
|
|
20
173
|
};
|
|
174
|
+
/**
|
|
175
|
+
* Valibot schema for validating OpenAPI operation data objects.
|
|
176
|
+
*
|
|
177
|
+
* This comprehensive schema validates OpenAPI operations according to the OpenAPI v3
|
|
178
|
+
* specification, including all standard properties like HTTP methods, parameters,
|
|
179
|
+
* request bodies, responses, and metadata. It uses lazy evaluation and unions to
|
|
180
|
+
* handle complex nested structures and reference objects.
|
|
181
|
+
*
|
|
182
|
+
* The schema ensures that operation data conforms to OpenAPI standards while also
|
|
183
|
+
* including SKMTC-specific metadata (like `oasType` and `pathItem`) needed for
|
|
184
|
+
* the code generation pipeline.
|
|
185
|
+
*
|
|
186
|
+
* @example Validating a GET operation
|
|
187
|
+
* ```typescript
|
|
188
|
+
* import { oasOperationData } from '@skmtc/core/oas/operation';
|
|
189
|
+
* import * as v from 'valibot';
|
|
190
|
+
*
|
|
191
|
+
* const operation = {
|
|
192
|
+
* oasType: 'operation',
|
|
193
|
+
* path: '/api/users/{id}',
|
|
194
|
+
* method: 'get',
|
|
195
|
+
* operationId: 'getUserById',
|
|
196
|
+
* summary: 'Get user by ID',
|
|
197
|
+
* parameters: [
|
|
198
|
+
* {
|
|
199
|
+
* name: 'id',
|
|
200
|
+
* in: 'path',
|
|
201
|
+
* required: true,
|
|
202
|
+
* schema: { type: 'string' }
|
|
203
|
+
* }
|
|
204
|
+
* ],
|
|
205
|
+
* responses: {
|
|
206
|
+
* '200': {
|
|
207
|
+
* description: 'Success',
|
|
208
|
+
* content: {
|
|
209
|
+
* 'application/json': {
|
|
210
|
+
* schema: { $ref: '#/components/schemas/User' }
|
|
211
|
+
* }
|
|
212
|
+
* }
|
|
213
|
+
* }
|
|
214
|
+
* },
|
|
215
|
+
* pathItem: validPathItem
|
|
216
|
+
* };
|
|
217
|
+
*
|
|
218
|
+
* const validated = v.parse(oasOperationData, operation);
|
|
219
|
+
* console.log(validated.operationId); // 'getUserById'
|
|
220
|
+
* ```
|
|
221
|
+
*
|
|
222
|
+
* @example Validating a POST operation with request body
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const postOperation = {
|
|
225
|
+
* oasType: 'operation',
|
|
226
|
+
* path: '/api/users',
|
|
227
|
+
* method: 'post',
|
|
228
|
+
* operationId: 'createUser',
|
|
229
|
+
* requestBody: {
|
|
230
|
+
* description: 'User data',
|
|
231
|
+
* required: true,
|
|
232
|
+
* content: {
|
|
233
|
+
* 'application/json': {
|
|
234
|
+
* schema: { $ref: '#/components/schemas/CreateUserRequest' }
|
|
235
|
+
* }
|
|
236
|
+
* }
|
|
237
|
+
* },
|
|
238
|
+
* responses: {
|
|
239
|
+
* '201': {
|
|
240
|
+
* description: 'User created',
|
|
241
|
+
* content: {
|
|
242
|
+
* 'application/json': {
|
|
243
|
+
* schema: { $ref: '#/components/schemas/User' }
|
|
244
|
+
* }
|
|
245
|
+
* }
|
|
246
|
+
* }
|
|
247
|
+
* },
|
|
248
|
+
* pathItem: validPathItem
|
|
249
|
+
* };
|
|
250
|
+
*
|
|
251
|
+
* const validated = v.parse(oasOperationData, postOperation);
|
|
252
|
+
* console.log(validated.method); // 'post'
|
|
253
|
+
* ```
|
|
254
|
+
*
|
|
255
|
+
* @example Validation error handling
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const invalidOperation = {
|
|
258
|
+
* oasType: 'operation',
|
|
259
|
+
* path: '/api/users',
|
|
260
|
+
* method: 'invalid', // Invalid HTTP method
|
|
261
|
+
* responses: {} // Missing required responses
|
|
262
|
+
* };
|
|
263
|
+
*
|
|
264
|
+
* try {
|
|
265
|
+
* v.parse(oasOperationData, invalidOperation);
|
|
266
|
+
* } catch (error) {
|
|
267
|
+
* console.error('Validation failed:', error.message);
|
|
268
|
+
* // Handle validation errors
|
|
269
|
+
* }
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
21
272
|
export declare const oasOperationData: v.GenericSchema<OasOperationData>;
|
|
22
273
|
//# sourceMappingURL=operation-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-types.d.ts","sourceRoot":"","sources":["../../../src/oas/operation/operation-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAoB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AE/D,2CAA2C;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAA;CAGrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,aAAa,CAAC,gBAAgB,CA2B7D,CAAA"}
|
|
@@ -41,6 +41,104 @@ const ref_types_js_1 = require("../ref/ref-types.js");
|
|
|
41
41
|
const requestBody_types_js_1 = require("../requestBody/requestBody-types.js");
|
|
42
42
|
const response_types_js_1 = require("../response/response-types.js");
|
|
43
43
|
const v = __importStar(require("valibot"));
|
|
44
|
+
/**
|
|
45
|
+
* Valibot schema for validating OpenAPI operation data objects.
|
|
46
|
+
*
|
|
47
|
+
* This comprehensive schema validates OpenAPI operations according to the OpenAPI v3
|
|
48
|
+
* specification, including all standard properties like HTTP methods, parameters,
|
|
49
|
+
* request bodies, responses, and metadata. It uses lazy evaluation and unions to
|
|
50
|
+
* handle complex nested structures and reference objects.
|
|
51
|
+
*
|
|
52
|
+
* The schema ensures that operation data conforms to OpenAPI standards while also
|
|
53
|
+
* including SKMTC-specific metadata (like `oasType` and `pathItem`) needed for
|
|
54
|
+
* the code generation pipeline.
|
|
55
|
+
*
|
|
56
|
+
* @example Validating a GET operation
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { oasOperationData } from '@skmtc/core/oas/operation';
|
|
59
|
+
* import * as v from 'valibot';
|
|
60
|
+
*
|
|
61
|
+
* const operation = {
|
|
62
|
+
* oasType: 'operation',
|
|
63
|
+
* path: '/api/users/{id}',
|
|
64
|
+
* method: 'get',
|
|
65
|
+
* operationId: 'getUserById',
|
|
66
|
+
* summary: 'Get user by ID',
|
|
67
|
+
* parameters: [
|
|
68
|
+
* {
|
|
69
|
+
* name: 'id',
|
|
70
|
+
* in: 'path',
|
|
71
|
+
* required: true,
|
|
72
|
+
* schema: { type: 'string' }
|
|
73
|
+
* }
|
|
74
|
+
* ],
|
|
75
|
+
* responses: {
|
|
76
|
+
* '200': {
|
|
77
|
+
* description: 'Success',
|
|
78
|
+
* content: {
|
|
79
|
+
* 'application/json': {
|
|
80
|
+
* schema: { $ref: '#/components/schemas/User' }
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* },
|
|
85
|
+
* pathItem: validPathItem
|
|
86
|
+
* };
|
|
87
|
+
*
|
|
88
|
+
* const validated = v.parse(oasOperationData, operation);
|
|
89
|
+
* console.log(validated.operationId); // 'getUserById'
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @example Validating a POST operation with request body
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const postOperation = {
|
|
95
|
+
* oasType: 'operation',
|
|
96
|
+
* path: '/api/users',
|
|
97
|
+
* method: 'post',
|
|
98
|
+
* operationId: 'createUser',
|
|
99
|
+
* requestBody: {
|
|
100
|
+
* description: 'User data',
|
|
101
|
+
* required: true,
|
|
102
|
+
* content: {
|
|
103
|
+
* 'application/json': {
|
|
104
|
+
* schema: { $ref: '#/components/schemas/CreateUserRequest' }
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
107
|
+
* },
|
|
108
|
+
* responses: {
|
|
109
|
+
* '201': {
|
|
110
|
+
* description: 'User created',
|
|
111
|
+
* content: {
|
|
112
|
+
* 'application/json': {
|
|
113
|
+
* schema: { $ref: '#/components/schemas/User' }
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
* }
|
|
117
|
+
* },
|
|
118
|
+
* pathItem: validPathItem
|
|
119
|
+
* };
|
|
120
|
+
*
|
|
121
|
+
* const validated = v.parse(oasOperationData, postOperation);
|
|
122
|
+
* console.log(validated.method); // 'post'
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @example Validation error handling
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const invalidOperation = {
|
|
128
|
+
* oasType: 'operation',
|
|
129
|
+
* path: '/api/users',
|
|
130
|
+
* method: 'invalid', // Invalid HTTP method
|
|
131
|
+
* responses: {} // Missing required responses
|
|
132
|
+
* };
|
|
133
|
+
*
|
|
134
|
+
* try {
|
|
135
|
+
* v.parse(oasOperationData, invalidOperation);
|
|
136
|
+
* } catch (error) {
|
|
137
|
+
* console.error('Validation failed:', error.message);
|
|
138
|
+
* // Handle validation errors
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
44
142
|
exports.oasOperationData = v.object({
|
|
45
143
|
oasType: v.literal('operation'),
|
|
46
144
|
pathItem: pathItem_types_js_1.oasPathItemData,
|
|
@@ -2,54 +2,228 @@ import * as v from 'valibot';
|
|
|
2
2
|
/**
|
|
3
3
|
* Union type for OpenAPI string format specifiers.
|
|
4
4
|
*
|
|
5
|
-
* Represents the standard string formats defined in OpenAPI v3,
|
|
6
|
-
* providing semantic meaning for string validation and processing.
|
|
7
|
-
*
|
|
5
|
+
* Represents the standard string formats defined in the OpenAPI v3 specification,
|
|
6
|
+
* providing semantic meaning for string validation and processing. These formats
|
|
7
|
+
* are used by generators to produce appropriate validation rules, UI components,
|
|
8
|
+
* and type annotations in target languages.
|
|
9
|
+
*
|
|
10
|
+
* ## Format Categories
|
|
11
|
+
*
|
|
12
|
+
* **Date/Time Formats:**
|
|
13
|
+
* - `date-time`: Full RFC3339 date-time (e.g., "2018-03-20T09:12:28Z")
|
|
14
|
+
* - `time`: RFC3339 time only (e.g., "09:12:28")
|
|
15
|
+
* - `date`: RFC3339 full-date (e.g., "2018-03-20")
|
|
16
|
+
* - `duration`: RFC3339 duration (e.g., "P3Y6M4DT12H30M5S")
|
|
17
|
+
*
|
|
18
|
+
* **Network Formats:**
|
|
19
|
+
* - `email`: RFC5322 email address
|
|
20
|
+
* - `hostname`: RFC1123 hostname
|
|
21
|
+
* - `ipv4`: IPv4 address
|
|
22
|
+
* - `ipv6`: IPv6 address
|
|
23
|
+
* - `uri`: RFC3986 URI
|
|
24
|
+
* - `uuid`: RFC4122 UUID
|
|
25
|
+
*
|
|
26
|
+
* **Encoding/Pattern Formats:**
|
|
27
|
+
* - `regex`: Regular expression pattern
|
|
28
|
+
* - `password`: Password field hint for UI components
|
|
29
|
+
* - `byte`: Base64 encoded data
|
|
30
|
+
* - `binary`: Binary data
|
|
31
|
+
*
|
|
32
|
+
* @example Using string formats in schema definitions
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import type { StringFormat } from '@skmtc/core/oas/string';
|
|
35
|
+
*
|
|
36
|
+
* const emailFormat: StringFormat = 'email';
|
|
37
|
+
* const timestampFormat: StringFormat = 'date-time';
|
|
38
|
+
* ```
|
|
8
39
|
*/
|
|
9
40
|
export type StringFormat = 'date-time' | 'time' | 'date' | 'duration' | 'email' | 'hostname' | 'ipv4' | 'ipv6' | 'uuid' | 'uri' | 'regex' | 'password' | 'byte' | 'binary';
|
|
10
41
|
/**
|
|
11
42
|
* Valibot enum schema for valid OpenAPI string format values.
|
|
12
43
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
44
|
+
* This schema validates that string format values conform to the OpenAPI v3
|
|
45
|
+
* specification's standard format identifiers. It includes date/time formats,
|
|
46
|
+
* network address formats, and encoding formats that provide semantic meaning
|
|
47
|
+
* for string validation and UI generation.
|
|
48
|
+
*
|
|
49
|
+
* @example Validating string formats
|
|
50
|
+
* ```typescript
|
|
51
|
+
* import { stringFormat } from '@skmtc/core/oas/string';
|
|
52
|
+
* import * as v from 'valibot';
|
|
53
|
+
*
|
|
54
|
+
* const validFormat = v.parse(stringFormat, 'email'); // 'email'
|
|
55
|
+
* const invalidFormat = v.parse(stringFormat, 'invalid'); // Throws ValiError
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example Using in schema validation
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const schema = {
|
|
61
|
+
* type: 'string',
|
|
62
|
+
* format: 'email',
|
|
63
|
+
* description: 'User email address'
|
|
64
|
+
* };
|
|
65
|
+
*
|
|
66
|
+
* // Validate the format field
|
|
67
|
+
* if (schema.format) {
|
|
68
|
+
* const validatedFormat = v.parse(stringFormat, schema.format);
|
|
69
|
+
* console.log(`Valid format: ${validatedFormat}`);
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
15
72
|
*/
|
|
16
73
|
export declare const stringFormat: v.GenericSchema<StringFormat>;
|
|
17
74
|
/**
|
|
18
75
|
* Valibot schema for validating OpenAPI string data objects.
|
|
19
76
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
77
|
+
* This comprehensive schema validates OpenAPI string schemas according to the
|
|
78
|
+
* OpenAPI v3 specification, including all standard properties like length
|
|
79
|
+
* constraints, pattern validation, format specifiers, enumeration values,
|
|
80
|
+
* and metadata fields. Used throughout the SKMTC pipeline for runtime
|
|
81
|
+
* validation of string schema definitions.
|
|
82
|
+
*
|
|
83
|
+
* @example Validating a basic string schema
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { oasStringData } from '@skmtc/core/oas/string';
|
|
86
|
+
* import * as v from 'valibot';
|
|
87
|
+
*
|
|
88
|
+
* const schema = {
|
|
89
|
+
* type: 'string',
|
|
90
|
+
* description: 'User name',
|
|
91
|
+
* minLength: 1,
|
|
92
|
+
* maxLength: 100,
|
|
93
|
+
* pattern: '^[a-zA-Z\\s]+$'
|
|
94
|
+
* };
|
|
95
|
+
*
|
|
96
|
+
* const validated = v.parse(oasStringData, schema);
|
|
97
|
+
* console.log(validated.minLength); // 1
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @example Validating formatted strings
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const emailSchema = {
|
|
103
|
+
* type: 'string',
|
|
104
|
+
* format: 'email',
|
|
105
|
+
* title: 'Email Address',
|
|
106
|
+
* example: 'user@example.com'
|
|
107
|
+
* };
|
|
108
|
+
*
|
|
109
|
+
* const result = v.parse(oasStringData, emailSchema);
|
|
110
|
+
* console.log(result.format); // 'email'
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @example Validating enumerated strings
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const statusSchema = {
|
|
116
|
+
* type: 'string',
|
|
117
|
+
* enum: ['pending', 'approved', 'rejected'],
|
|
118
|
+
* default: 'pending',
|
|
119
|
+
* description: 'Application status'
|
|
120
|
+
* };
|
|
121
|
+
*
|
|
122
|
+
* const validated = v.parse(oasStringData, statusSchema);
|
|
123
|
+
* console.log(validated.enum); // ['pending', 'approved', 'rejected']
|
|
124
|
+
* ```
|
|
22
125
|
*/
|
|
23
126
|
export declare const oasStringData: v.GenericSchema<OasStringData>;
|
|
24
127
|
/**
|
|
25
128
|
* Data type for OpenAPI string schema objects.
|
|
26
129
|
*
|
|
27
|
-
* Represents string schemas
|
|
28
|
-
*
|
|
29
|
-
*
|
|
130
|
+
* Represents the complete structure of OpenAPI string schemas as processed by the
|
|
131
|
+
* SKMTC pipeline. This type includes all standard OpenAPI string schema properties
|
|
132
|
+
* including validation constraints (length, pattern), format specifiers, enumeration
|
|
133
|
+
* values, and metadata fields. It's used throughout the string processing pipeline
|
|
134
|
+
* for type-safe handling of string schema definitions.
|
|
135
|
+
*
|
|
136
|
+
* ## Usage in SKMTC Pipeline
|
|
137
|
+
*
|
|
138
|
+
* This type is used by:
|
|
139
|
+
* - Schema parsers to validate incoming string schema data
|
|
140
|
+
* - String processors to transform OpenAPI schemas into OAS objects
|
|
141
|
+
* - Code generators to access string constraints and generate validation code
|
|
142
|
+
* - UI generators to create appropriate form controls based on formats and constraints
|
|
143
|
+
*
|
|
144
|
+
* @example Basic string schema
|
|
145
|
+
* ```typescript
|
|
146
|
+
* import type { OasStringData } from '@skmtc/core/oas/string';
|
|
147
|
+
*
|
|
148
|
+
* const nameSchema: OasStringData = {
|
|
149
|
+
* type: 'string',
|
|
150
|
+
* title: 'Full Name',
|
|
151
|
+
* description: 'User full name',
|
|
152
|
+
* minLength: 1,
|
|
153
|
+
* maxLength: 200,
|
|
154
|
+
* example: 'John Doe'
|
|
155
|
+
* };
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example Email string with format
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const emailSchema: OasStringData = {
|
|
161
|
+
* type: 'string',
|
|
162
|
+
* format: 'email',
|
|
163
|
+
* title: 'Email Address',
|
|
164
|
+
* description: 'User email for notifications',
|
|
165
|
+
* example: 'john.doe@example.com'
|
|
166
|
+
* };
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @example Enumerated string values
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const roleSchema: OasStringData = {
|
|
172
|
+
* type: 'string',
|
|
173
|
+
* title: 'User Role',
|
|
174
|
+
* description: 'User access level',
|
|
175
|
+
* enum: ['admin', 'moderator', 'user', 'guest'],
|
|
176
|
+
* default: 'user'
|
|
177
|
+
* };
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @example Pattern-constrained string
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const phoneSchema: OasStringData = {
|
|
183
|
+
* type: 'string',
|
|
184
|
+
* title: 'Phone Number',
|
|
185
|
+
* description: 'US phone number',
|
|
186
|
+
* pattern: '^\\+?1?[2-9]\\d{9}$',
|
|
187
|
+
* example: '+1234567890',
|
|
188
|
+
* minLength: 10,
|
|
189
|
+
* maxLength: 15
|
|
190
|
+
* };
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @example Nullable string with constraints
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const commentSchema: OasStringData = {
|
|
196
|
+
* type: 'string',
|
|
197
|
+
* title: 'Comment',
|
|
198
|
+
* description: 'Optional user comment',
|
|
199
|
+
* maxLength: 500,
|
|
200
|
+
* nullable: true,
|
|
201
|
+
* default: null
|
|
202
|
+
* };
|
|
203
|
+
* ```
|
|
30
204
|
*/
|
|
31
205
|
export type OasStringData = {
|
|
32
|
-
/** Human-readable title for the string */
|
|
206
|
+
/** Human-readable title for the string schema */
|
|
33
207
|
title?: string;
|
|
34
|
-
/** Detailed description
|
|
208
|
+
/** Detailed description explaining the string's purpose and usage */
|
|
35
209
|
description?: string;
|
|
36
|
-
/** Default value
|
|
210
|
+
/** Default value used when no explicit value is provided */
|
|
37
211
|
default?: string;
|
|
38
212
|
/** Type identifier (always 'string') */
|
|
39
213
|
type: 'string';
|
|
40
|
-
/** Maximum allowed length */
|
|
214
|
+
/** Maximum allowed length in characters */
|
|
41
215
|
maxLength?: number;
|
|
42
|
-
/** Minimum required length */
|
|
216
|
+
/** Minimum required length in characters */
|
|
43
217
|
minLength?: number;
|
|
44
218
|
/** Regular expression pattern for validation */
|
|
45
219
|
pattern?: string;
|
|
46
220
|
/** Array of valid enumeration values */
|
|
47
221
|
enum?: string[];
|
|
48
|
-
/** Format specifier (date-time,
|
|
222
|
+
/** Format specifier (email, date-time, uuid, etc.) */
|
|
49
223
|
format?: string;
|
|
50
|
-
/** Whether null values are allowed */
|
|
224
|
+
/** Whether null values are allowed in addition to string values */
|
|
51
225
|
nullable?: boolean;
|
|
52
|
-
/** Example value for documentation */
|
|
226
|
+
/** Example value for documentation and testing */
|
|
53
227
|
example?: string;
|
|
54
228
|
};
|
|
55
229
|
//# sourceMappingURL=string-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-types.d.ts","sourceRoot":"","sources":["../../../src/oas/string/string-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B
|
|
1
|
+
{"version":3,"file":"string-types.d.ts","sourceRoot":"","sources":["../../../src/oas/string/string-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,MAAM,GACN,MAAM,GACN,UAAU,GACV,OAAO,GACP,UAAU,GACV,MAAM,GACN,MAAM,GACN,MAAM,GAC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