@skmtc/core 0.0.808 → 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/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
|
@@ -4,67 +4,280 @@ import { type OasSchemaRefData } from '../ref/ref-types.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Valibot schema for validating OpenAPI array data objects.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* to handle recursive schema references
|
|
7
|
+
* This comprehensive schema validates OpenAPI array schemas according to the OpenAPI v3
|
|
8
|
+
* specification, including item type definitions, length constraints, uniqueness requirements,
|
|
9
|
+
* and enumeration values. It uses lazy evaluation to handle recursive schema references,
|
|
10
|
+
* allowing for complex nested array structures and self-referential schemas.
|
|
11
|
+
*
|
|
12
|
+
* The schema supports both direct schema definitions and reference objects for the items
|
|
13
|
+
* property, enabling flexible array type definitions that can reference other schemas
|
|
14
|
+
* in the document or define inline item types.
|
|
15
|
+
*
|
|
16
|
+
* @example Validating a simple array schema
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { oasArrayData } from '@skmtc/core/oas/array';
|
|
19
|
+
* import * as v from 'valibot';
|
|
20
|
+
*
|
|
21
|
+
* const schema = {
|
|
22
|
+
* type: 'array',
|
|
23
|
+
* items: {
|
|
24
|
+
* type: 'string'
|
|
25
|
+
* },
|
|
26
|
+
* description: 'List of user names',
|
|
27
|
+
* minItems: 1,
|
|
28
|
+
* maxItems: 100
|
|
29
|
+
* };
|
|
30
|
+
*
|
|
31
|
+
* const validated = v.parse(oasArrayData, schema);
|
|
32
|
+
* console.log(validated.minItems); // 1
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Validating array with reference items
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const refArraySchema = {
|
|
38
|
+
* type: 'array',
|
|
39
|
+
* items: {
|
|
40
|
+
* $ref: '#/components/schemas/User'
|
|
41
|
+
* },
|
|
42
|
+
* title: 'User List',
|
|
43
|
+
* uniqueItems: true,
|
|
44
|
+
* default: []
|
|
45
|
+
* };
|
|
46
|
+
*
|
|
47
|
+
* const result = v.parse(oasArrayData, refArraySchema);
|
|
48
|
+
* console.log(result.uniqueItems); // true
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @example Validating constrained arrays
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const constrainedArray = {
|
|
54
|
+
* type: 'array',
|
|
55
|
+
* items: { type: 'number' },
|
|
56
|
+
* minItems: 2,
|
|
57
|
+
* maxItems: 10,
|
|
58
|
+
* uniqueItems: true,
|
|
59
|
+
* enums: [[1, 2, 3], [4, 5, 6]]
|
|
60
|
+
* };
|
|
61
|
+
*
|
|
62
|
+
* const validated = v.parse(oasArrayData, constrainedArray);
|
|
63
|
+
* console.log(validated.maxItems); // 10
|
|
64
|
+
* ```
|
|
10
65
|
*/
|
|
11
66
|
export declare const oasArrayData: v.GenericSchema<OasArrayData>;
|
|
12
67
|
/**
|
|
13
68
|
* Valibot schema for array data without the items property.
|
|
14
69
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
70
|
+
* This specialized schema validates array schemas when the items property is processed
|
|
71
|
+
* separately from the main array constraints. It's commonly used during schema parsing
|
|
72
|
+
* and transformation processes where items need special handling, such as when resolving
|
|
73
|
+
* references or applying schema merging operations.
|
|
74
|
+
*
|
|
75
|
+
* This pattern is useful in multi-phase parsing where array constraints (like min/max
|
|
76
|
+
* items, uniqueness) are validated independently from the item type definitions,
|
|
77
|
+
* allowing for more flexible processing pipelines.
|
|
78
|
+
*
|
|
79
|
+
* @example Validating array constraints without items
|
|
80
|
+
* ```typescript
|
|
81
|
+
* import { oasArrayDataWithoutItems } from '@skmtc/core/oas/array';
|
|
82
|
+
* import * as v from 'valibot';
|
|
83
|
+
*
|
|
84
|
+
* const constraintsOnly = {
|
|
85
|
+
* type: 'array',
|
|
86
|
+
* title: 'Validation Rules',
|
|
87
|
+
* minItems: 1,
|
|
88
|
+
* maxItems: 50,
|
|
89
|
+
* uniqueItems: true,
|
|
90
|
+
* default: []
|
|
91
|
+
* };
|
|
92
|
+
*
|
|
93
|
+
* const validated = v.parse(oasArrayDataWithoutItems, constraintsOnly);
|
|
94
|
+
* console.log(validated.uniqueItems); // true
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @example Usage in two-phase parsing
|
|
98
|
+
* ```typescript
|
|
99
|
+
* function parseArraySchema(schema: unknown) {
|
|
100
|
+
* // Phase 1: Validate basic array structure
|
|
101
|
+
* const arrayConstraints = v.parse(oasArrayDataWithoutItems, schema);
|
|
102
|
+
*
|
|
103
|
+
* // Phase 2: Process items separately (not shown)
|
|
104
|
+
* const items = processItemsSchema((schema as any).items);
|
|
105
|
+
*
|
|
106
|
+
* return { ...arrayConstraints, items };
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
17
109
|
*/
|
|
18
110
|
export declare const oasArrayDataWithoutItems: v.GenericSchema<OasArrayDataWithoutItems>;
|
|
19
111
|
/**
|
|
20
112
|
* Data type for OpenAPI array schema objects.
|
|
21
113
|
*
|
|
22
|
-
* Represents array schemas
|
|
23
|
-
*
|
|
24
|
-
*
|
|
114
|
+
* Represents the complete structure of OpenAPI array schemas as processed by the SKMTC
|
|
115
|
+
* pipeline. This type includes all standard OpenAPI array schema properties including
|
|
116
|
+
* item type specifications, length constraints, uniqueness requirements, and metadata
|
|
117
|
+
* fields. It's used throughout the array processing pipeline for type-safe handling
|
|
118
|
+
* of array schema definitions.
|
|
119
|
+
*
|
|
120
|
+
* ## Usage in SKMTC Pipeline
|
|
121
|
+
*
|
|
122
|
+
* This type is used by:
|
|
123
|
+
* - Schema parsers to validate incoming array schema data
|
|
124
|
+
* - Array processors to transform OpenAPI schemas into OAS objects
|
|
125
|
+
* - Code generators to access array constraints and generate validation code
|
|
126
|
+
* - Type generators to create appropriate array type definitions
|
|
127
|
+
*
|
|
128
|
+
* @example Basic string array schema
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import type { OasArrayData } from '@skmtc/core/oas/array';
|
|
131
|
+
*
|
|
132
|
+
* const tagListSchema: OasArrayData = {
|
|
133
|
+
* type: 'array',
|
|
134
|
+
* items: {
|
|
135
|
+
* type: 'string',
|
|
136
|
+
* minLength: 1,
|
|
137
|
+
* maxLength: 50
|
|
138
|
+
* },
|
|
139
|
+
* title: 'Tag List',
|
|
140
|
+
* description: 'Collection of tags for categorization',
|
|
141
|
+
* minItems: 0,
|
|
142
|
+
* maxItems: 20,
|
|
143
|
+
* uniqueItems: true,
|
|
144
|
+
* default: []
|
|
145
|
+
* };
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @example Array of referenced objects
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const userListSchema: OasArrayData = {
|
|
151
|
+
* type: 'array',
|
|
152
|
+
* items: {
|
|
153
|
+
* $ref: '#/components/schemas/User'
|
|
154
|
+
* },
|
|
155
|
+
* title: 'User Collection',
|
|
156
|
+
* description: 'List of user objects',
|
|
157
|
+
* minItems: 1,
|
|
158
|
+
* default: []
|
|
159
|
+
* };
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* @example Complex nested array schema
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const matrixSchema: OasArrayData = {
|
|
165
|
+
* type: 'array',
|
|
166
|
+
* items: {
|
|
167
|
+
* type: 'array',
|
|
168
|
+
* items: {
|
|
169
|
+
* type: 'number'
|
|
170
|
+
* },
|
|
171
|
+
* minItems: 3,
|
|
172
|
+
* maxItems: 3
|
|
173
|
+
* },
|
|
174
|
+
* title: '3x3 Matrix',
|
|
175
|
+
* description: 'Two-dimensional number array representing a 3x3 matrix',
|
|
176
|
+
* minItems: 3,
|
|
177
|
+
* maxItems: 3
|
|
178
|
+
* };
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @example Enum array with constraints
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const statusListSchema: OasArrayData = {
|
|
184
|
+
* type: 'array',
|
|
185
|
+
* items: {
|
|
186
|
+
* type: 'string',
|
|
187
|
+
* enum: ['active', 'inactive', 'pending']
|
|
188
|
+
* },
|
|
189
|
+
* title: 'Status List',
|
|
190
|
+
* description: 'Multiple status values',
|
|
191
|
+
* uniqueItems: true,
|
|
192
|
+
* enums: [
|
|
193
|
+
* ['active'],
|
|
194
|
+
* ['active', 'pending'],
|
|
195
|
+
* ['inactive', 'pending']
|
|
196
|
+
* ]
|
|
197
|
+
* };
|
|
198
|
+
* ```
|
|
25
199
|
*/
|
|
26
200
|
export type OasArrayData = {
|
|
27
201
|
/** Type identifier (always 'array') */
|
|
28
202
|
type: 'array';
|
|
29
|
-
/** Schema definition for array items */
|
|
203
|
+
/** Schema definition for array items (can be direct schema or reference) */
|
|
30
204
|
items: OasSchemaData | OasSchemaRefData;
|
|
31
|
-
/** Human-readable title for the array */
|
|
205
|
+
/** Human-readable title for the array schema */
|
|
32
206
|
title?: string;
|
|
33
|
-
/** Detailed description
|
|
207
|
+
/** Detailed description explaining the array's purpose and contents */
|
|
34
208
|
description?: string;
|
|
35
|
-
/** Default value
|
|
209
|
+
/** Default value used when no explicit array is provided */
|
|
36
210
|
default?: unknown[];
|
|
37
|
-
/** Maximum number of items allowed */
|
|
211
|
+
/** Maximum number of items allowed in the array */
|
|
38
212
|
maxItems?: number;
|
|
39
|
-
/** Minimum number of items required */
|
|
213
|
+
/** Minimum number of items required in the array */
|
|
40
214
|
minItems?: number;
|
|
41
|
-
/** Whether all items must be unique */
|
|
215
|
+
/** Whether all items in the array must be unique */
|
|
42
216
|
uniqueItems?: boolean;
|
|
43
|
-
/** Array of valid enumeration values */
|
|
217
|
+
/** Array of valid enumeration values for the entire array */
|
|
44
218
|
enums?: unknown[];
|
|
45
219
|
};
|
|
46
220
|
/**
|
|
47
221
|
* Array schema data without the items property.
|
|
48
222
|
*
|
|
49
|
-
* Represents an array schema with all properties except the items definition.
|
|
50
|
-
*
|
|
223
|
+
* Represents an array schema with all standard properties except the items definition.
|
|
224
|
+
* This type is used during parsing phases where item schemas are processed separately
|
|
225
|
+
* from array constraints, enabling more flexible processing pipelines and better
|
|
226
|
+
* separation of concerns in complex schema transformation operations.
|
|
227
|
+
*
|
|
228
|
+
* ## Common Use Cases
|
|
229
|
+
*
|
|
230
|
+
* - **Two-phase parsing**: Validate array structure first, then process items
|
|
231
|
+
* - **Schema merging**: Combine array constraints from multiple sources
|
|
232
|
+
* - **Constraint extraction**: Extract array rules for validation generation
|
|
233
|
+
* - **Reference resolution**: Process items after resolving schema references
|
|
234
|
+
*
|
|
235
|
+
* @example Array constraints for validation
|
|
236
|
+
* ```typescript
|
|
237
|
+
* import type { OasArrayDataWithoutItems } from '@skmtc/core/oas/array';
|
|
238
|
+
*
|
|
239
|
+
* const constraintsSchema: OasArrayDataWithoutItems = {
|
|
240
|
+
* type: 'array',
|
|
241
|
+
* title: 'Validation Rules',
|
|
242
|
+
* description: 'Array with length and uniqueness constraints',
|
|
243
|
+
* minItems: 1,
|
|
244
|
+
* maxItems: 100,
|
|
245
|
+
* uniqueItems: true,
|
|
246
|
+
* default: []
|
|
247
|
+
* };
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @example Enum constraints without item types
|
|
251
|
+
* ```typescript
|
|
252
|
+
* const enumArrayConstraints: OasArrayDataWithoutItems = {
|
|
253
|
+
* type: 'array',
|
|
254
|
+
* title: 'Option Groups',
|
|
255
|
+
* description: 'Predefined option combinations',
|
|
256
|
+
* enums: [
|
|
257
|
+
* ['option1', 'option2'],
|
|
258
|
+
* ['option3', 'option4'],
|
|
259
|
+
* ['option1', 'option3', 'option4']
|
|
260
|
+
* ],
|
|
261
|
+
* uniqueItems: true
|
|
262
|
+
* };
|
|
263
|
+
* ```
|
|
51
264
|
*/
|
|
52
265
|
export type OasArrayDataWithoutItems = {
|
|
53
266
|
/** Type identifier (always 'array') */
|
|
54
267
|
type: 'array';
|
|
55
|
-
/** Human-readable title for the array */
|
|
268
|
+
/** Human-readable title for the array schema */
|
|
56
269
|
title?: string;
|
|
57
|
-
/** Detailed description
|
|
270
|
+
/** Detailed description explaining the array's purpose and contents */
|
|
58
271
|
description?: string;
|
|
59
|
-
/** Default value
|
|
272
|
+
/** Default value used when no explicit array is provided */
|
|
60
273
|
default?: unknown[];
|
|
61
|
-
/** Maximum number of items allowed */
|
|
274
|
+
/** Maximum number of items allowed in the array */
|
|
62
275
|
maxItems?: number;
|
|
63
|
-
/** Minimum number of items required */
|
|
276
|
+
/** Minimum number of items required in the array */
|
|
64
277
|
minItems?: number;
|
|
65
|
-
/** Whether all items must be unique */
|
|
278
|
+
/** Whether all items in the array must be unique */
|
|
66
279
|
uniqueItems?: boolean;
|
|
67
|
-
/** Array of valid enumeration values */
|
|
280
|
+
/** Array of valid enumeration values for the entire array */
|
|
68
281
|
enums?: unknown[];
|
|
69
282
|
};
|
|
70
283
|
//# sourceMappingURL=array-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-types.d.ts","sourceRoot":"","sources":["../../../src/oas/array/array-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EAAE,KAAK,gBAAgB,EAAoB,MAAM,qBAAqB,CAAA;AAE7E
|
|
1
|
+
{"version":3,"file":"array-types.d.ts","sourceRoot":"","sources":["../../../src/oas/array/array-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EAAE,KAAK,gBAAgB,EAAoB,MAAM,qBAAqB,CAAA;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,aAAa,CAAC,YAAY,CAUrD,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,wBAAwB,EAAE,CAAC,CAAC,aAAa,CAAC,wBAAwB,CAS7E,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,uCAAuC;IACvC,IAAI,EAAE,OAAO,CAAA;IACb,4EAA4E;IAC5E,KAAK,EAAE,aAAa,GAAG,gBAAgB,CAAA;IACvC,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,EAAE,CAAA;IACnB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,OAAO,EAAE,CAAA;CAClB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,uCAAuC;IACvC,IAAI,EAAE,OAAO,CAAA;IACb,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,EAAE,CAAA;IACnB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,OAAO,EAAE,CAAA;CAClB,CAAA"}
|
|
@@ -4,9 +4,64 @@ import { oasSchemaRefData } from '../ref/ref-types.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Valibot schema for validating OpenAPI array data objects.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* to handle recursive schema references
|
|
7
|
+
* This comprehensive schema validates OpenAPI array schemas according to the OpenAPI v3
|
|
8
|
+
* specification, including item type definitions, length constraints, uniqueness requirements,
|
|
9
|
+
* and enumeration values. It uses lazy evaluation to handle recursive schema references,
|
|
10
|
+
* allowing for complex nested array structures and self-referential schemas.
|
|
11
|
+
*
|
|
12
|
+
* The schema supports both direct schema definitions and reference objects for the items
|
|
13
|
+
* property, enabling flexible array type definitions that can reference other schemas
|
|
14
|
+
* in the document or define inline item types.
|
|
15
|
+
*
|
|
16
|
+
* @example Validating a simple array schema
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { oasArrayData } from '@skmtc/core/oas/array';
|
|
19
|
+
* import * as v from 'valibot';
|
|
20
|
+
*
|
|
21
|
+
* const schema = {
|
|
22
|
+
* type: 'array',
|
|
23
|
+
* items: {
|
|
24
|
+
* type: 'string'
|
|
25
|
+
* },
|
|
26
|
+
* description: 'List of user names',
|
|
27
|
+
* minItems: 1,
|
|
28
|
+
* maxItems: 100
|
|
29
|
+
* };
|
|
30
|
+
*
|
|
31
|
+
* const validated = v.parse(oasArrayData, schema);
|
|
32
|
+
* console.log(validated.minItems); // 1
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Validating array with reference items
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const refArraySchema = {
|
|
38
|
+
* type: 'array',
|
|
39
|
+
* items: {
|
|
40
|
+
* $ref: '#/components/schemas/User'
|
|
41
|
+
* },
|
|
42
|
+
* title: 'User List',
|
|
43
|
+
* uniqueItems: true,
|
|
44
|
+
* default: []
|
|
45
|
+
* };
|
|
46
|
+
*
|
|
47
|
+
* const result = v.parse(oasArrayData, refArraySchema);
|
|
48
|
+
* console.log(result.uniqueItems); // true
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @example Validating constrained arrays
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const constrainedArray = {
|
|
54
|
+
* type: 'array',
|
|
55
|
+
* items: { type: 'number' },
|
|
56
|
+
* minItems: 2,
|
|
57
|
+
* maxItems: 10,
|
|
58
|
+
* uniqueItems: true,
|
|
59
|
+
* enums: [[1, 2, 3], [4, 5, 6]]
|
|
60
|
+
* };
|
|
61
|
+
*
|
|
62
|
+
* const validated = v.parse(oasArrayData, constrainedArray);
|
|
63
|
+
* console.log(validated.maxItems); // 10
|
|
64
|
+
* ```
|
|
10
65
|
*/
|
|
11
66
|
export const oasArrayData = v.object({
|
|
12
67
|
type: v.literal('array'),
|
|
@@ -22,8 +77,45 @@ export const oasArrayData = v.object({
|
|
|
22
77
|
/**
|
|
23
78
|
* Valibot schema for array data without the items property.
|
|
24
79
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
80
|
+
* This specialized schema validates array schemas when the items property is processed
|
|
81
|
+
* separately from the main array constraints. It's commonly used during schema parsing
|
|
82
|
+
* and transformation processes where items need special handling, such as when resolving
|
|
83
|
+
* references or applying schema merging operations.
|
|
84
|
+
*
|
|
85
|
+
* This pattern is useful in multi-phase parsing where array constraints (like min/max
|
|
86
|
+
* items, uniqueness) are validated independently from the item type definitions,
|
|
87
|
+
* allowing for more flexible processing pipelines.
|
|
88
|
+
*
|
|
89
|
+
* @example Validating array constraints without items
|
|
90
|
+
* ```typescript
|
|
91
|
+
* import { oasArrayDataWithoutItems } from '@skmtc/core/oas/array';
|
|
92
|
+
* import * as v from 'valibot';
|
|
93
|
+
*
|
|
94
|
+
* const constraintsOnly = {
|
|
95
|
+
* type: 'array',
|
|
96
|
+
* title: 'Validation Rules',
|
|
97
|
+
* minItems: 1,
|
|
98
|
+
* maxItems: 50,
|
|
99
|
+
* uniqueItems: true,
|
|
100
|
+
* default: []
|
|
101
|
+
* };
|
|
102
|
+
*
|
|
103
|
+
* const validated = v.parse(oasArrayDataWithoutItems, constraintsOnly);
|
|
104
|
+
* console.log(validated.uniqueItems); // true
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @example Usage in two-phase parsing
|
|
108
|
+
* ```typescript
|
|
109
|
+
* function parseArraySchema(schema: unknown) {
|
|
110
|
+
* // Phase 1: Validate basic array structure
|
|
111
|
+
* const arrayConstraints = v.parse(oasArrayDataWithoutItems, schema);
|
|
112
|
+
*
|
|
113
|
+
* // Phase 2: Process items separately (not shown)
|
|
114
|
+
* const items = processItemsSchema((schema as any).items);
|
|
115
|
+
*
|
|
116
|
+
* return { ...arrayConstraints, items };
|
|
117
|
+
* }
|
|
118
|
+
* ```
|
|
27
119
|
*/
|
|
28
120
|
export const oasArrayDataWithoutItems = v.object({
|
|
29
121
|
type: v.literal('array'),
|
|
@@ -2,27 +2,99 @@ import * as v from 'valibot';
|
|
|
2
2
|
/**
|
|
3
3
|
* Valibot schema for validating OpenAPI boolean data objects.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* This schema validates OpenAPI boolean schemas according to the OpenAPI v3 specification,
|
|
6
|
+
* including optional properties like default values, enumeration constraints, title,
|
|
7
|
+
* and description metadata. Boolean enums are commonly used to restrict values to
|
|
8
|
+
* specific boolean constants (e.g., [true] for always-true flags).
|
|
9
|
+
*
|
|
10
|
+
* @example Validating a basic boolean schema
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { oasBooleanData } from '@skmtc/core/oas/boolean';
|
|
13
|
+
* import * as v from 'valibot';
|
|
14
|
+
*
|
|
15
|
+
* const schema = {
|
|
16
|
+
* type: 'boolean',
|
|
17
|
+
* description: 'Whether the feature is enabled',
|
|
18
|
+
* default: false
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* const validated = v.parse(oasBooleanData, schema);
|
|
22
|
+
* console.log(validated.default); // false
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example Validating boolean with enumeration
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const constrainedBoolean = {
|
|
28
|
+
* type: 'boolean',
|
|
29
|
+
* title: 'Admin Flag',
|
|
30
|
+
* description: 'User admin status',
|
|
31
|
+
* enum: [true] // Only true values allowed
|
|
32
|
+
* };
|
|
33
|
+
*
|
|
34
|
+
* const result = v.parse(oasBooleanData, constrainedBoolean);
|
|
35
|
+
* console.log(result.enum); // [true]
|
|
36
|
+
* ```
|
|
7
37
|
*/
|
|
8
38
|
export declare const oasBooleanData: v.GenericSchema<OasBooleanData>;
|
|
9
39
|
/**
|
|
10
40
|
* Data type for OpenAPI boolean schema objects.
|
|
11
41
|
*
|
|
12
|
-
* Represents boolean schemas
|
|
13
|
-
*
|
|
14
|
-
*
|
|
42
|
+
* Represents the structure of OpenAPI boolean schemas as processed by the SKMTC pipeline.
|
|
43
|
+
* This type includes all standard OpenAPI boolean schema properties including metadata,
|
|
44
|
+
* default values, and enumeration constraints. It's used throughout the boolean
|
|
45
|
+
* processing pipeline for type-safe handling of boolean schema definitions.
|
|
46
|
+
*
|
|
47
|
+
* ## Usage in SKMTC Pipeline
|
|
48
|
+
*
|
|
49
|
+
* This type is used by:
|
|
50
|
+
* - Schema parsers to validate incoming boolean schema data
|
|
51
|
+
* - Boolean processors to transform OpenAPI schemas into OAS objects
|
|
52
|
+
* - Code generators to access boolean schema metadata and constraints
|
|
53
|
+
* - Validation systems to ensure schema compliance
|
|
54
|
+
*
|
|
55
|
+
* @example Basic boolean schema
|
|
56
|
+
* ```typescript
|
|
57
|
+
* import type { OasBooleanData } from '@skmtc/core/oas/boolean';
|
|
58
|
+
*
|
|
59
|
+
* const isActiveSchema: OasBooleanData = {
|
|
60
|
+
* type: 'boolean',
|
|
61
|
+
* title: 'Active Status',
|
|
62
|
+
* description: 'Whether the record is active',
|
|
63
|
+
* default: true
|
|
64
|
+
* };
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @example Boolean with enumeration constraints
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const adminFlagSchema: OasBooleanData = {
|
|
70
|
+
* type: 'boolean',
|
|
71
|
+
* description: 'Administrative privileges flag',
|
|
72
|
+
* enum: [false, true], // Allow both values
|
|
73
|
+
* default: false
|
|
74
|
+
* };
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @example Read-only boolean flag
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const systemFlagSchema: OasBooleanData = {
|
|
80
|
+
* type: 'boolean',
|
|
81
|
+
* title: 'System Generated',
|
|
82
|
+
* description: 'Indicates if the record was system-generated',
|
|
83
|
+
* enum: [true], // Always true
|
|
84
|
+
* default: true
|
|
85
|
+
* };
|
|
86
|
+
* ```
|
|
15
87
|
*/
|
|
16
88
|
export type OasBooleanData = {
|
|
17
89
|
/** Type identifier (always 'boolean') */
|
|
18
90
|
type: 'boolean';
|
|
19
|
-
/** Human-readable title for the boolean */
|
|
91
|
+
/** Human-readable title for the boolean schema */
|
|
20
92
|
title?: string;
|
|
21
|
-
/** Detailed description
|
|
93
|
+
/** Detailed description explaining the boolean's purpose and usage */
|
|
22
94
|
description?: string;
|
|
23
|
-
/** Default value
|
|
95
|
+
/** Default value used when no explicit value is provided */
|
|
24
96
|
default?: boolean;
|
|
25
|
-
/** Array of valid boolean values
|
|
97
|
+
/** Array of valid boolean values for enumeration constraints */
|
|
26
98
|
enum?: boolean[];
|
|
27
99
|
};
|
|
28
100
|
//# sourceMappingURL=boolean-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean-types.d.ts","sourceRoot":"","sources":["../../../src/oas/boolean/boolean-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B
|
|
1
|
+
{"version":3,"file":"boolean-types.d.ts","sourceRoot":"","sources":["../../../src/oas/boolean/boolean-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,aAAa,CAAC,cAAc,CAMzD,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,yCAAyC;IACzC,IAAI,EAAE,SAAS,CAAA;IACf,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,gEAAgE;IAChE,IAAI,CAAC,EAAE,OAAO,EAAE,CAAA;CACjB,CAAA"}
|
|
@@ -2,8 +2,38 @@ import * as v from 'valibot';
|
|
|
2
2
|
/**
|
|
3
3
|
* Valibot schema for validating OpenAPI boolean data objects.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* This schema validates OpenAPI boolean schemas according to the OpenAPI v3 specification,
|
|
6
|
+
* including optional properties like default values, enumeration constraints, title,
|
|
7
|
+
* and description metadata. Boolean enums are commonly used to restrict values to
|
|
8
|
+
* specific boolean constants (e.g., [true] for always-true flags).
|
|
9
|
+
*
|
|
10
|
+
* @example Validating a basic boolean schema
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { oasBooleanData } from '@skmtc/core/oas/boolean';
|
|
13
|
+
* import * as v from 'valibot';
|
|
14
|
+
*
|
|
15
|
+
* const schema = {
|
|
16
|
+
* type: 'boolean',
|
|
17
|
+
* description: 'Whether the feature is enabled',
|
|
18
|
+
* default: false
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* const validated = v.parse(oasBooleanData, schema);
|
|
22
|
+
* console.log(validated.default); // false
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example Validating boolean with enumeration
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const constrainedBoolean = {
|
|
28
|
+
* type: 'boolean',
|
|
29
|
+
* title: 'Admin Flag',
|
|
30
|
+
* description: 'User admin status',
|
|
31
|
+
* enum: [true] // Only true values allowed
|
|
32
|
+
* };
|
|
33
|
+
*
|
|
34
|
+
* const result = v.parse(oasBooleanData, constrainedBoolean);
|
|
35
|
+
* console.log(result.enum); // [true]
|
|
36
|
+
* ```
|
|
7
37
|
*/
|
|
8
38
|
export const oasBooleanData = v.object({
|
|
9
39
|
type: v.literal('boolean'),
|