@skmtc/core 0.0.808 → 0.0.810

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 (73) hide show
  1. package/esm/context/types.d.ts +0 -8
  2. package/esm/context/types.d.ts.map +1 -1
  3. package/esm/dsl/model/toModelBase.d.ts +24 -2
  4. package/esm/dsl/model/toModelBase.d.ts.map +1 -1
  5. package/esm/dsl/model/types.d.ts +2 -2
  6. package/esm/dsl/operation/toOperationBase.d.ts +26 -3
  7. package/esm/dsl/operation/toOperationBase.d.ts.map +1 -1
  8. package/esm/dsl/operation/types.d.ts +2 -2
  9. package/esm/oas/array/array-types.d.ts +238 -25
  10. package/esm/oas/array/array-types.d.ts.map +1 -1
  11. package/esm/oas/array/array-types.js +97 -5
  12. package/esm/oas/boolean/boolean-types.d.ts +81 -9
  13. package/esm/oas/boolean/boolean-types.d.ts.map +1 -1
  14. package/esm/oas/boolean/boolean-types.js +32 -2
  15. package/esm/oas/contact/contact-types.d.ts +176 -0
  16. package/esm/oas/contact/contact-types.d.ts.map +1 -1
  17. package/esm/oas/contact/contact-types.js +102 -0
  18. package/esm/oas/header/Header.d.ts +8 -185
  19. package/esm/oas/header/Header.d.ts.map +1 -1
  20. package/esm/oas/header/Header.js +57 -220
  21. package/esm/oas/mediaType/toMediaTypeItemV3.d.ts +288 -0
  22. package/esm/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
  23. package/esm/oas/mediaType/toMediaTypeItemV3.js +272 -0
  24. package/esm/oas/operation/operation-types.d.ts +251 -0
  25. package/esm/oas/operation/operation-types.d.ts.map +1 -1
  26. package/esm/oas/operation/operation-types.js +98 -0
  27. package/esm/oas/string/string-types.d.ts +192 -18
  28. package/esm/oas/string/string-types.d.ts.map +1 -1
  29. package/esm/oas/string/string-types.js +76 -4
  30. package/esm/types/ModuleExport.d.ts +130 -0
  31. package/esm/types/ModuleExport.d.ts.map +1 -1
  32. package/esm/types/ModuleExport.js +36 -0
  33. package/esm/typescript/List.d.ts +2 -2
  34. package/esm/typescript/List.d.ts.map +1 -1
  35. package/esm/typescript/List.js +4 -4
  36. package/esm/typescript/toPathTemplate.d.ts.map +1 -1
  37. package/package.json +1 -1
  38. package/script/context/types.d.ts +0 -8
  39. package/script/context/types.d.ts.map +1 -1
  40. package/script/dsl/model/toModelBase.d.ts +24 -2
  41. package/script/dsl/model/toModelBase.d.ts.map +1 -1
  42. package/script/dsl/model/types.d.ts +2 -2
  43. package/script/dsl/operation/toOperationBase.d.ts +26 -3
  44. package/script/dsl/operation/toOperationBase.d.ts.map +1 -1
  45. package/script/dsl/operation/types.d.ts +2 -2
  46. package/script/oas/array/array-types.d.ts +238 -25
  47. package/script/oas/array/array-types.d.ts.map +1 -1
  48. package/script/oas/array/array-types.js +97 -5
  49. package/script/oas/boolean/boolean-types.d.ts +81 -9
  50. package/script/oas/boolean/boolean-types.d.ts.map +1 -1
  51. package/script/oas/boolean/boolean-types.js +32 -2
  52. package/script/oas/contact/contact-types.d.ts +176 -0
  53. package/script/oas/contact/contact-types.d.ts.map +1 -1
  54. package/script/oas/contact/contact-types.js +102 -0
  55. package/script/oas/header/Header.d.ts +8 -185
  56. package/script/oas/header/Header.d.ts.map +1 -1
  57. package/script/oas/header/Header.js +57 -220
  58. package/script/oas/mediaType/toMediaTypeItemV3.d.ts +288 -0
  59. package/script/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
  60. package/script/oas/mediaType/toMediaTypeItemV3.js +272 -0
  61. package/script/oas/operation/operation-types.d.ts +251 -0
  62. package/script/oas/operation/operation-types.d.ts.map +1 -1
  63. package/script/oas/operation/operation-types.js +98 -0
  64. package/script/oas/string/string-types.d.ts +192 -18
  65. package/script/oas/string/string-types.d.ts.map +1 -1
  66. package/script/oas/string/string-types.js +76 -4
  67. package/script/types/ModuleExport.d.ts +130 -0
  68. package/script/types/ModuleExport.d.ts.map +1 -1
  69. package/script/types/ModuleExport.js +36 -0
  70. package/script/typescript/List.d.ts +2 -2
  71. package/script/typescript/List.d.ts.map +1 -1
  72. package/script/typescript/List.js +4 -4
  73. package/script/typescript/toPathTemplate.d.ts.map +1 -1
@@ -2,6 +2,108 @@ import { toOptionalSchemaV3 } from '../schema/toSchemasV3.js';
2
2
  import { toExamplesV3 } from '../example/toExamplesV3.js';
3
3
  import { OasMediaType } from './MediaType.js';
4
4
  import { toSpecificationExtensionsV3 } from '../specificationExtensions/toSpecificationExtensionsV3.js';
5
+ /**
6
+ * Transforms an OpenAPI v3 media type object into an internal OAS media type representation.
7
+ *
8
+ * This function processes OpenAPI v3 MediaType objects, extracting schema definitions,
9
+ * examples, encoding information, and specification extensions. It creates a structured
10
+ * internal representation that can be used by the SKMTC pipeline for code generation
11
+ * and validation.
12
+ *
13
+ * The transformation handles all standard OpenAPI v3 MediaType properties including
14
+ * schema references, inline schemas, examples, encoding specifications, and custom
15
+ * extension fields that begin with 'x-'.
16
+ *
17
+ * @param args - Transformation arguments
18
+ * @param args.mediaTypeItem - The OpenAPI v3 media type object to process
19
+ * @param args.mediaType - The media type identifier (MIME type)
20
+ * @param args.context - Parsing context for tracing and error handling
21
+ * @returns Structured OAS media type object for internal processing
22
+ *
23
+ * @example Transforming JSON media type
24
+ * ```typescript
25
+ * import { toMediaTypeItemV3 } from '@skmtc/core/oas/mediaType';
26
+ *
27
+ * const jsonMediaType = {
28
+ * schema: {
29
+ * type: 'object',
30
+ * properties: {
31
+ * name: { type: 'string' },
32
+ * email: { type: 'string', format: 'email' }
33
+ * }
34
+ * },
35
+ * example: {
36
+ * name: 'John Doe',
37
+ * email: 'john@example.com'
38
+ * }
39
+ * };
40
+ *
41
+ * const result = toMediaTypeItemV3({
42
+ * mediaTypeItem: jsonMediaType,
43
+ * mediaType: 'application/json',
44
+ * context: parseContext
45
+ * });
46
+ *
47
+ * console.log(result.mediaType); // 'application/json'
48
+ * console.log(result.schema); // Processed schema object
49
+ * ```
50
+ *
51
+ * @example Processing form data with encoding
52
+ * ```typescript
53
+ * const formMediaType = {
54
+ * schema: {
55
+ * type: 'object',
56
+ * properties: {
57
+ * file: { type: 'string', format: 'binary' },
58
+ * metadata: { type: 'string' }
59
+ * }
60
+ * },
61
+ * encoding: {
62
+ * file: {
63
+ * contentType: 'image/png',
64
+ * headers: {
65
+ * 'X-Rate-Limit': {
66
+ * schema: { type: 'integer' }
67
+ * }
68
+ * }
69
+ * }
70
+ * }
71
+ * };
72
+ *
73
+ * const result = toMediaTypeItemV3({
74
+ * mediaTypeItem: formMediaType,
75
+ * mediaType: 'multipart/form-data',
76
+ * context: parseContext
77
+ * });
78
+ *
79
+ * console.log(result.encoding); // Processed encoding configuration
80
+ * ```
81
+ *
82
+ * @example Handling multiple examples
83
+ * ```typescript
84
+ * const mediaTypeWithExamples = {
85
+ * schema: { type: 'string' },
86
+ * examples: {
87
+ * success: {
88
+ * summary: 'Successful response',
89
+ * value: 'Operation completed'
90
+ * },
91
+ * error: {
92
+ * summary: 'Error response',
93
+ * value: 'Operation failed'
94
+ * }
95
+ * }
96
+ * };
97
+ *
98
+ * const result = toMediaTypeItemV3({
99
+ * mediaTypeItem: mediaTypeWithExamples,
100
+ * mediaType: 'text/plain',
101
+ * context: parseContext
102
+ * });
103
+ *
104
+ * console.log(Object.keys(result.examples)); // ['success', 'error']
105
+ * ```
106
+ */
5
107
  export const toMediaTypeItemV3 = ({ mediaTypeItem, mediaType, context }) => {
6
108
  const { schema, example, examples, encoding, ...skipped } = mediaTypeItem;
7
109
  const extensionFields = toSpecificationExtensionsV3({
@@ -24,6 +126,89 @@ export const toMediaTypeItemV3 = ({ mediaTypeItem, mediaType, context }) => {
24
126
  };
25
127
  return new OasMediaType(fields);
26
128
  };
129
+ /**
130
+ * Transforms multiple OpenAPI v3 media type objects into internal OAS representations.
131
+ *
132
+ * This function processes a complete content map from OpenAPI v3, transforming each
133
+ * media type entry into its internal OAS representation. It's commonly used to process
134
+ * the `content` property of request bodies, responses, and parameters that support
135
+ * multiple media types.
136
+ *
137
+ * The function maintains the original media type keys while transforming the values
138
+ * into structured OAS media type objects. Each transformation is traced for debugging
139
+ * and error tracking purposes.
140
+ *
141
+ * @param args - Transformation arguments
142
+ * @param args.content - Map of media types to OpenAPI MediaType objects
143
+ * @param args.context - Parsing context for tracing and error handling
144
+ * @returns Map of media type strings to processed OAS media type objects
145
+ *
146
+ * @example Processing multiple content types
147
+ * ```typescript
148
+ * import { toMediaTypeItemsV3 } from '@skmtc/core/oas/mediaType';
149
+ *
150
+ * const content = {
151
+ * 'application/json': {
152
+ * schema: {
153
+ * type: 'object',
154
+ * properties: { message: { type: 'string' } }
155
+ * }
156
+ * },
157
+ * 'application/xml': {
158
+ * schema: {
159
+ * type: 'string'
160
+ * }
161
+ * },
162
+ * 'text/plain': {
163
+ * schema: {
164
+ * type: 'string'
165
+ * },
166
+ * example: 'Plain text response'
167
+ * }
168
+ * };
169
+ *
170
+ * const result = toMediaTypeItemsV3({
171
+ * content,
172
+ * context: parseContext
173
+ * });
174
+ *
175
+ * console.log(Object.keys(result)); // ['application/json', 'application/xml', 'text/plain']
176
+ * console.log(result['application/json'].mediaType); // 'application/json'
177
+ * ```
178
+ *
179
+ * @example Processing request body content types
180
+ * ```typescript
181
+ * const requestBodyContent = {
182
+ * 'application/json': {
183
+ * schema: { $ref: '#/components/schemas/CreateUserRequest' }
184
+ * },
185
+ * 'application/x-www-form-urlencoded': {
186
+ * schema: {
187
+ * type: 'object',
188
+ * properties: {
189
+ * name: { type: 'string' },
190
+ * email: { type: 'string' }
191
+ * }
192
+ * },
193
+ * encoding: {
194
+ * email: {
195
+ * style: 'form',
196
+ * explode: false
197
+ * }
198
+ * }
199
+ * }
200
+ * };
201
+ *
202
+ * const processed = toMediaTypeItemsV3({
203
+ * content: requestBodyContent,
204
+ * context: parseContext
205
+ * });
206
+ *
207
+ * // Each media type is processed with its specific configuration
208
+ * console.log(processed['application/json'].schema); // Reference object
209
+ * console.log(processed['application/x-www-form-urlencoded'].encoding); // Form encoding config
210
+ * ```
211
+ */
27
212
  export const toMediaTypeItemsV3 = ({ content, context }) => {
28
213
  return Object.fromEntries(Object.entries(content).map(([mediaType, value]) => [
29
214
  mediaType,
@@ -34,6 +219,93 @@ export const toMediaTypeItemsV3 = ({ content, context }) => {
34
219
  }))
35
220
  ]));
36
221
  };
222
+ /**
223
+ * Optionally transforms OpenAPI v3 media type objects when content is provided.
224
+ *
225
+ * This function provides a safe way to process media type content that may or may not
226
+ * be present in the OpenAPI specification. It handles the common pattern where content
227
+ * properties are optional in OpenAPI objects (like responses without bodies or
228
+ * operations without request bodies).
229
+ *
230
+ * When content is undefined, the function returns undefined without processing.
231
+ * When content is provided, it delegates to `toMediaTypeItemsV3` for full processing.
232
+ *
233
+ * @param args - Transformation arguments
234
+ * @param args.content - Optional map of media types to OpenAPI MediaType objects
235
+ * @param args.context - Parsing context for tracing and error handling
236
+ * @returns Map of processed media types if content exists, undefined otherwise
237
+ *
238
+ * @example Handling optional response content
239
+ * ```typescript
240
+ * import { toOptionalMediaTypeItemsV3 } from '@skmtc/core/oas/mediaType';
241
+ *
242
+ * // Response with content
243
+ * const responseWithContent = {
244
+ * description: 'Successful response',
245
+ * content: {
246
+ * 'application/json': {
247
+ * schema: { type: 'object' }
248
+ * }
249
+ * }
250
+ * };
251
+ *
252
+ * const withContent = toOptionalMediaTypeItemsV3({
253
+ * content: responseWithContent.content,
254
+ * context: parseContext
255
+ * });
256
+ * console.log(withContent); // { 'application/json': OasMediaType }
257
+ *
258
+ * // Response without content (like 204 No Content)
259
+ * const responseNoContent = {
260
+ * description: 'No content response'
261
+ * };
262
+ *
263
+ * const noContent = toOptionalMediaTypeItemsV3({
264
+ * content: responseNoContent.content, // undefined
265
+ * context: parseContext
266
+ * });
267
+ * console.log(noContent); // undefined
268
+ * ```
269
+ *
270
+ * @example Processing operations with optional request bodies
271
+ * ```typescript
272
+ * function processOperation(operation: OpenAPIV3.OperationObject) {
273
+ * const requestBodyContent = toOptionalMediaTypeItemsV3({
274
+ * content: operation.requestBody?.content,
275
+ * context: parseContext
276
+ * });
277
+ *
278
+ * if (requestBodyContent) {
279
+ * console.log('Operation has request body with media types:');
280
+ * console.log(Object.keys(requestBodyContent));
281
+ * } else {
282
+ * console.log('Operation has no request body');
283
+ * }
284
+ * }
285
+ * ```
286
+ *
287
+ * @example Safe processing in response handlers
288
+ * ```typescript
289
+ * class ResponseProcessor {
290
+ * processResponse(response: OpenAPIV3.ResponseObject) {
291
+ * const mediaTypes = toOptionalMediaTypeItemsV3({
292
+ * content: response.content,
293
+ * context: this.context
294
+ * });
295
+ *
296
+ * // Safe to check without worrying about undefined content
297
+ * const hasJsonResponse = mediaTypes && 'application/json' in mediaTypes;
298
+ *
299
+ * if (hasJsonResponse) {
300
+ * const jsonMediaType = mediaTypes['application/json'];
301
+ * return this.generateJsonResponseHandler(jsonMediaType);
302
+ * }
303
+ *
304
+ * return this.generateEmptyResponseHandler();
305
+ * }
306
+ * }
307
+ * ```
308
+ */
37
309
  export const toOptionalMediaTypeItemsV3 = ({ content, context }) => {
38
310
  if (!content) {
39
311
  return;
@@ -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,MAAM,iCAAiC,CAAA;AACzF,OAAO,EAAE,KAAK,eAAe,EAAmB,MAAM,+BAA+B,CAAA;AACrF,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EAIxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,qCAAqC,CAAA;AACjG,OAAO,EAAE,KAAK,eAAe,EAAmB,MAAM,+BAA+B,CAAA;AACrF,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,WAAW,CAAA;IACpB,QAAQ,EAAE,eAAe,CAAA;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA;IAClF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IAGpB,UAAU,CAAC,EAAE,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,EAAE,CAAA;IACvD,WAAW,CAAC,EAAE,kBAAkB,GAAG,qBAAqB,CAAA;IACxD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,kBAAkB,CAAC,CAAA;IAE/D,UAAU,CAAC,EAAE,OAAO,CAAA;CAGrB,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,aAAa,CAAC,gBAAgB,CA2B7D,CAAA"}
1
+ {"version":3,"file":"operation-types.d.ts","sourceRoot":"","sources":["../../../src/oas/operation/operation-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAoB,MAAM,iCAAiC,CAAA;AACzF,OAAO,EAAE,KAAK,eAAe,EAAmB,MAAM,+BAA+B,CAAA;AACrF,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EAIxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,qCAAqC,CAAA;AACjG,OAAO,EAAE,KAAK,eAAe,EAAmB,MAAM,+BAA+B,CAAA;AACrF,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4IG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,oDAAoD;IACpD,OAAO,EAAE,WAAW,CAAA;IACpB,iDAAiD;IACjD,QAAQ,EAAE,eAAe,CAAA;IACzB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,qCAAqC;IACrC,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA;IAClF,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAA;IAGpB,uDAAuD;IACvD,UAAU,CAAC,EAAE,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,EAAE,CAAA;IACvD,iEAAiE;IACjE,WAAW,CAAC,EAAE,kBAAkB,GAAG,qBAAqB,CAAA;IACxD,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,kBAAkB,CAAC,CAAA;IAE/D,2CAA2C;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAA;CAGrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,aAAa,CAAC,gBAAgB,CA2B7D,CAAA"}
@@ -5,6 +5,104 @@ import { oasParameterRefData, oasRequestBodyRefData, oasResponseRefData } from '
5
5
  import { oasRequestBodyData } from '../requestBody/requestBody-types.js';
6
6
  import { oasResponseData } from '../response/response-types.js';
7
7
  import * as v from 'valibot';
8
+ /**
9
+ * Valibot schema for validating OpenAPI operation data objects.
10
+ *
11
+ * This comprehensive schema validates OpenAPI operations according to the OpenAPI v3
12
+ * specification, including all standard properties like HTTP methods, parameters,
13
+ * request bodies, responses, and metadata. It uses lazy evaluation and unions to
14
+ * handle complex nested structures and reference objects.
15
+ *
16
+ * The schema ensures that operation data conforms to OpenAPI standards while also
17
+ * including SKMTC-specific metadata (like `oasType` and `pathItem`) needed for
18
+ * the code generation pipeline.
19
+ *
20
+ * @example Validating a GET operation
21
+ * ```typescript
22
+ * import { oasOperationData } from '@skmtc/core/oas/operation';
23
+ * import * as v from 'valibot';
24
+ *
25
+ * const operation = {
26
+ * oasType: 'operation',
27
+ * path: '/api/users/{id}',
28
+ * method: 'get',
29
+ * operationId: 'getUserById',
30
+ * summary: 'Get user by ID',
31
+ * parameters: [
32
+ * {
33
+ * name: 'id',
34
+ * in: 'path',
35
+ * required: true,
36
+ * schema: { type: 'string' }
37
+ * }
38
+ * ],
39
+ * responses: {
40
+ * '200': {
41
+ * description: 'Success',
42
+ * content: {
43
+ * 'application/json': {
44
+ * schema: { $ref: '#/components/schemas/User' }
45
+ * }
46
+ * }
47
+ * }
48
+ * },
49
+ * pathItem: validPathItem
50
+ * };
51
+ *
52
+ * const validated = v.parse(oasOperationData, operation);
53
+ * console.log(validated.operationId); // 'getUserById'
54
+ * ```
55
+ *
56
+ * @example Validating a POST operation with request body
57
+ * ```typescript
58
+ * const postOperation = {
59
+ * oasType: 'operation',
60
+ * path: '/api/users',
61
+ * method: 'post',
62
+ * operationId: 'createUser',
63
+ * requestBody: {
64
+ * description: 'User data',
65
+ * required: true,
66
+ * content: {
67
+ * 'application/json': {
68
+ * schema: { $ref: '#/components/schemas/CreateUserRequest' }
69
+ * }
70
+ * }
71
+ * },
72
+ * responses: {
73
+ * '201': {
74
+ * description: 'User created',
75
+ * content: {
76
+ * 'application/json': {
77
+ * schema: { $ref: '#/components/schemas/User' }
78
+ * }
79
+ * }
80
+ * }
81
+ * },
82
+ * pathItem: validPathItem
83
+ * };
84
+ *
85
+ * const validated = v.parse(oasOperationData, postOperation);
86
+ * console.log(validated.method); // 'post'
87
+ * ```
88
+ *
89
+ * @example Validation error handling
90
+ * ```typescript
91
+ * const invalidOperation = {
92
+ * oasType: 'operation',
93
+ * path: '/api/users',
94
+ * method: 'invalid', // Invalid HTTP method
95
+ * responses: {} // Missing required responses
96
+ * };
97
+ *
98
+ * try {
99
+ * v.parse(oasOperationData, invalidOperation);
100
+ * } catch (error) {
101
+ * console.error('Validation failed:', error.message);
102
+ * // Handle validation errors
103
+ * }
104
+ * ```
105
+ */
8
106
  export const oasOperationData = v.object({
9
107
  oasType: v.literal('operation'),
10
108
  pathItem: oasPathItemData,