@skmtc/core 0.0.786 → 0.0.787
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/dsl/ContentSettings.d.ts +164 -0
- package/esm/dsl/ContentSettings.d.ts.map +1 -1
- package/esm/dsl/ContentSettings.js +151 -0
- package/esm/dsl/Definition.d.ts +199 -0
- package/esm/dsl/Definition.d.ts.map +1 -1
- package/esm/dsl/Definition.js +189 -0
- package/esm/dsl/EntityType.d.ts +83 -0
- package/esm/dsl/EntityType.d.ts.map +1 -1
- package/esm/dsl/EntityType.js +83 -0
- package/esm/oas/array/Array.d.ts +109 -1
- package/esm/oas/array/Array.d.ts.map +1 -1
- package/esm/oas/array/Array.js +93 -1
- package/esm/oas/integer/Integer.d.ts +98 -0
- package/esm/oas/integer/Integer.d.ts.map +1 -1
- package/esm/oas/integer/Integer.js +80 -0
- package/esm/oas/string/String.d.ts +103 -1
- package/esm/oas/string/String.d.ts.map +1 -1
- package/esm/oas/string/String.js +87 -1
- package/esm/types/Brand.d.ts +74 -0
- package/esm/types/Brand.d.ts.map +1 -1
- package/esm/types/Brand.js +9 -0
- package/esm/types/RefName.d.ts +61 -0
- package/esm/types/RefName.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/dsl/ContentSettings.d.ts +164 -0
- package/script/dsl/ContentSettings.d.ts.map +1 -1
- package/script/dsl/ContentSettings.js +151 -0
- package/script/dsl/Definition.d.ts +199 -0
- package/script/dsl/Definition.d.ts.map +1 -1
- package/script/dsl/Definition.js +189 -0
- package/script/dsl/EntityType.d.ts +83 -0
- package/script/dsl/EntityType.d.ts.map +1 -1
- package/script/dsl/EntityType.js +83 -0
- package/script/oas/array/Array.d.ts +109 -1
- package/script/oas/array/Array.d.ts.map +1 -1
- package/script/oas/array/Array.js +93 -1
- package/script/oas/integer/Integer.d.ts +98 -0
- package/script/oas/integer/Integer.d.ts.map +1 -1
- package/script/oas/integer/Integer.js +80 -0
- package/script/oas/string/String.d.ts +103 -1
- package/script/oas/string/String.d.ts.map +1 -1
- package/script/oas/string/String.js +87 -1
- package/script/types/Brand.d.ts +74 -0
- package/script/types/Brand.d.ts.map +1 -1
- package/script/types/Brand.js +9 -0
- package/script/types/RefName.d.ts +61 -0
- package/script/types/RefName.d.ts.map +1 -1
|
@@ -2,21 +2,119 @@ import "../../_dnt.polyfills.js";
|
|
|
2
2
|
import type { OasRef } from '../ref/Ref.js';
|
|
3
3
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
4
4
|
import type { ToJsonSchemaOptions } from '../schema/Schema.js';
|
|
5
|
+
/**
|
|
6
|
+
* Constructor fields for {@link OasInteger}.
|
|
7
|
+
*
|
|
8
|
+
* @template Nullable - Whether the integer value can be null
|
|
9
|
+
*/
|
|
5
10
|
export type IntegerFields<Nullable extends boolean | undefined> = {
|
|
11
|
+
/** A short summary of the integer schema */
|
|
6
12
|
title?: string;
|
|
13
|
+
/** A description of the integer schema */
|
|
7
14
|
description?: string;
|
|
15
|
+
/** Whether the integer value can be null */
|
|
8
16
|
nullable?: Nullable;
|
|
17
|
+
/** Integer format specification (int32 or int64) */
|
|
9
18
|
format?: 'int32' | 'int64';
|
|
19
|
+
/** Default value for the integer */
|
|
10
20
|
default?: Nullable extends true ? number | null | undefined : number | undefined;
|
|
21
|
+
/** Array of allowed enum values */
|
|
11
22
|
enums?: Nullable extends true ? (number | null)[] | undefined : number[] | undefined;
|
|
23
|
+
/** Custom extension fields (x-* properties) */
|
|
12
24
|
extensionFields?: Record<string, unknown>;
|
|
25
|
+
/** Example value for the integer */
|
|
13
26
|
example?: Nullable extends true ? number | null | undefined : number | undefined;
|
|
27
|
+
/** Number must be a multiple of this value */
|
|
14
28
|
multipleOf?: number;
|
|
29
|
+
/** Maximum value (inclusive) */
|
|
15
30
|
maximum?: number;
|
|
31
|
+
/** Whether maximum is exclusive */
|
|
16
32
|
exclusiveMaximum?: boolean;
|
|
33
|
+
/** Minimum value (inclusive) */
|
|
17
34
|
minimum?: number;
|
|
35
|
+
/** Whether minimum is exclusive */
|
|
18
36
|
exclusiveMinimum?: boolean;
|
|
19
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Represents an integer schema in the OpenAPI Specification.
|
|
40
|
+
*
|
|
41
|
+
* `OasInteger` handles integer type definitions with comprehensive validation
|
|
42
|
+
* constraints including range limits, multiple-of validation, format specifications,
|
|
43
|
+
* and enum restrictions. It supports both 32-bit and 64-bit integer formats
|
|
44
|
+
* and provides nullable type support.
|
|
45
|
+
*
|
|
46
|
+
* This class is used throughout the OAS processing pipeline to represent
|
|
47
|
+
* integer fields in API schemas, including IDs, counts, timestamps, and
|
|
48
|
+
* other numeric values that must be whole numbers.
|
|
49
|
+
*
|
|
50
|
+
* ## Key Features
|
|
51
|
+
*
|
|
52
|
+
* - **Format Support**: int32 and int64 format specifications
|
|
53
|
+
* - **Range Validation**: Minimum and maximum value constraints
|
|
54
|
+
* - **Multiple Validation**: Ensure values are multiples of specified numbers
|
|
55
|
+
* - **Enum Values**: Restricted sets of allowed integer values
|
|
56
|
+
* - **Nullable Support**: Type-safe nullable integer handling
|
|
57
|
+
* - **JSON Schema**: Conversion to standard JSON Schema format
|
|
58
|
+
*
|
|
59
|
+
* @template Nullable - Whether the integer value can be null
|
|
60
|
+
*
|
|
61
|
+
* @example Basic integer schema
|
|
62
|
+
* ```typescript
|
|
63
|
+
* import { OasInteger } from '@skmtc/core';
|
|
64
|
+
*
|
|
65
|
+
* const ageInteger = new OasInteger({
|
|
66
|
+
* title: 'Age',
|
|
67
|
+
* description: 'Person age in years',
|
|
68
|
+
* minimum: 0,
|
|
69
|
+
* maximum: 150,
|
|
70
|
+
* example: 25
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @example ID with int64 format
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const userIdInteger = new OasInteger({
|
|
77
|
+
* title: 'User ID',
|
|
78
|
+
* description: 'Unique user identifier',
|
|
79
|
+
* format: 'int64',
|
|
80
|
+
* minimum: 1,
|
|
81
|
+
* example: 1234567890123
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @example Count with multiple-of validation
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const batchSizeInteger = new OasInteger({
|
|
88
|
+
* title: 'Batch Size',
|
|
89
|
+
* description: 'Number of items to process',
|
|
90
|
+
* minimum: 10,
|
|
91
|
+
* maximum: 1000,
|
|
92
|
+
* multipleOf: 10, // Must be multiple of 10
|
|
93
|
+
* default: 50
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @example Status code enum
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const statusCodeInteger = new OasInteger({
|
|
100
|
+
* title: 'HTTP Status Code',
|
|
101
|
+
* description: 'Valid HTTP response status codes',
|
|
102
|
+
* enums: [200, 201, 400, 401, 404, 500],
|
|
103
|
+
* example: 200
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @example Nullable integer
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const optionalCountInteger = new OasInteger<true>({
|
|
110
|
+
* title: 'Optional Count',
|
|
111
|
+
* description: 'Count value that can be null',
|
|
112
|
+
* nullable: true,
|
|
113
|
+
* minimum: 0,
|
|
114
|
+
* default: null
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
20
118
|
export declare class OasInteger<Nullable extends boolean | undefined = boolean | undefined> {
|
|
21
119
|
/**
|
|
22
120
|
* Object is part the 'schema' set which is used
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Integer.d.ts","sourceRoot":"","sources":["../../../src/oas/integer/Integer.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC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AAQ,CAAM;IAgBhD,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,UAAU,CAAC,QAAQ,CAAC;IAI/B,WAAW,IAAI,UAAU,CAAC,QAAQ,CAAC;IAKnC,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC,oBAAoB;CAiB5E"}
|
|
@@ -2,6 +2,86 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OasInteger = void 0;
|
|
4
4
|
require("../../_dnt.polyfills.js");
|
|
5
|
+
/**
|
|
6
|
+
* Represents an integer schema in the OpenAPI Specification.
|
|
7
|
+
*
|
|
8
|
+
* `OasInteger` handles integer type definitions with comprehensive validation
|
|
9
|
+
* constraints including range limits, multiple-of validation, format specifications,
|
|
10
|
+
* and enum restrictions. It supports both 32-bit and 64-bit integer formats
|
|
11
|
+
* and provides nullable type support.
|
|
12
|
+
*
|
|
13
|
+
* This class is used throughout the OAS processing pipeline to represent
|
|
14
|
+
* integer fields in API schemas, including IDs, counts, timestamps, and
|
|
15
|
+
* other numeric values that must be whole numbers.
|
|
16
|
+
*
|
|
17
|
+
* ## Key Features
|
|
18
|
+
*
|
|
19
|
+
* - **Format Support**: int32 and int64 format specifications
|
|
20
|
+
* - **Range Validation**: Minimum and maximum value constraints
|
|
21
|
+
* - **Multiple Validation**: Ensure values are multiples of specified numbers
|
|
22
|
+
* - **Enum Values**: Restricted sets of allowed integer values
|
|
23
|
+
* - **Nullable Support**: Type-safe nullable integer handling
|
|
24
|
+
* - **JSON Schema**: Conversion to standard JSON Schema format
|
|
25
|
+
*
|
|
26
|
+
* @template Nullable - Whether the integer value can be null
|
|
27
|
+
*
|
|
28
|
+
* @example Basic integer schema
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { OasInteger } from '@skmtc/core';
|
|
31
|
+
*
|
|
32
|
+
* const ageInteger = new OasInteger({
|
|
33
|
+
* title: 'Age',
|
|
34
|
+
* description: 'Person age in years',
|
|
35
|
+
* minimum: 0,
|
|
36
|
+
* maximum: 150,
|
|
37
|
+
* example: 25
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example ID with int64 format
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const userIdInteger = new OasInteger({
|
|
44
|
+
* title: 'User ID',
|
|
45
|
+
* description: 'Unique user identifier',
|
|
46
|
+
* format: 'int64',
|
|
47
|
+
* minimum: 1,
|
|
48
|
+
* example: 1234567890123
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example Count with multiple-of validation
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const batchSizeInteger = new OasInteger({
|
|
55
|
+
* title: 'Batch Size',
|
|
56
|
+
* description: 'Number of items to process',
|
|
57
|
+
* minimum: 10,
|
|
58
|
+
* maximum: 1000,
|
|
59
|
+
* multipleOf: 10, // Must be multiple of 10
|
|
60
|
+
* default: 50
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example Status code enum
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const statusCodeInteger = new OasInteger({
|
|
67
|
+
* title: 'HTTP Status Code',
|
|
68
|
+
* description: 'Valid HTTP response status codes',
|
|
69
|
+
* enums: [200, 201, 400, 401, 404, 500],
|
|
70
|
+
* example: 200
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @example Nullable integer
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const optionalCountInteger = new OasInteger<true>({
|
|
77
|
+
* title: 'Optional Count',
|
|
78
|
+
* description: 'Count value that can be null',
|
|
79
|
+
* nullable: true,
|
|
80
|
+
* minimum: 0,
|
|
81
|
+
* default: null
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
5
85
|
class OasInteger {
|
|
6
86
|
constructor(fields = {}) {
|
|
7
87
|
/**
|
|
@@ -2,21 +2,108 @@ import "../../_dnt.polyfills.js";
|
|
|
2
2
|
import type { OasRef } from '../ref/Ref.js';
|
|
3
3
|
import type { ToJsonSchemaOptions } from '../schema/Schema.js';
|
|
4
4
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
5
|
+
/**
|
|
6
|
+
* Constructor fields for {@link OasString}.
|
|
7
|
+
*
|
|
8
|
+
* @template Nullable - Whether the string value can be null
|
|
9
|
+
*/
|
|
5
10
|
export type StringFields<Nullable extends boolean | undefined> = {
|
|
11
|
+
/** A short summary of the string schema */
|
|
6
12
|
title?: string;
|
|
13
|
+
/** A description of the string schema */
|
|
7
14
|
description?: string;
|
|
15
|
+
/** String format (e.g., 'email', 'date-time', 'uri') */
|
|
8
16
|
format?: string;
|
|
17
|
+
/** Default value for the string */
|
|
9
18
|
default?: Nullable extends true ? string | null | undefined : string | undefined;
|
|
19
|
+
/** Regular expression pattern for validation */
|
|
10
20
|
pattern?: string;
|
|
21
|
+
/** Array of allowed enum values */
|
|
11
22
|
enums?: Nullable extends true ? (string | null)[] | undefined : string[] | undefined;
|
|
23
|
+
/** Maximum length constraint */
|
|
12
24
|
maxLength?: number;
|
|
25
|
+
/** Minimum length constraint */
|
|
13
26
|
minLength?: number;
|
|
27
|
+
/** Whether the string value can be null */
|
|
14
28
|
nullable?: Nullable;
|
|
29
|
+
/** Custom extension fields (x-* properties) */
|
|
15
30
|
extensionFields?: Record<string, unknown>;
|
|
31
|
+
/** Example value for the string */
|
|
16
32
|
example?: Nullable extends true ? string | null | undefined : string | undefined;
|
|
17
33
|
};
|
|
18
34
|
/**
|
|
19
|
-
*
|
|
35
|
+
* Represents a string schema in the OpenAPI Specification.
|
|
36
|
+
*
|
|
37
|
+
* `OasString` handles string type definitions with comprehensive validation
|
|
38
|
+
* constraints including format validation, length limits, pattern matching,
|
|
39
|
+
* and enum restrictions. It supports nullable types and provides JSON Schema
|
|
40
|
+
* conversion for validation purposes.
|
|
41
|
+
*
|
|
42
|
+
* This class is used throughout the OAS processing pipeline to represent
|
|
43
|
+
* string fields in API schemas, parameters, and request/response bodies.
|
|
44
|
+
*
|
|
45
|
+
* ## Key Features
|
|
46
|
+
*
|
|
47
|
+
* - **Format Validation**: Support for standard formats (email, date-time, uri, etc.)
|
|
48
|
+
* - **Length Constraints**: Minimum and maximum length validation
|
|
49
|
+
* - **Pattern Matching**: Regular expression validation
|
|
50
|
+
* - **Enum Values**: Restricted sets of allowed values
|
|
51
|
+
* - **Nullable Support**: Type-safe nullable string handling
|
|
52
|
+
* - **JSON Schema**: Conversion to standard JSON Schema format
|
|
53
|
+
*
|
|
54
|
+
* @template Nullable - Whether the string value can be null
|
|
55
|
+
*
|
|
56
|
+
* @example Basic string schema
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { OasString } from '@skmtc/core';
|
|
59
|
+
*
|
|
60
|
+
* const basicString = new OasString({
|
|
61
|
+
* title: 'User Name',
|
|
62
|
+
* description: 'The full name of the user',
|
|
63
|
+
* minLength: 1,
|
|
64
|
+
* maxLength: 100
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example Email format validation
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const emailString = new OasString({
|
|
71
|
+
* title: 'Email Address',
|
|
72
|
+
* description: 'Valid email address',
|
|
73
|
+
* format: 'email',
|
|
74
|
+
* example: 'user@example.com'
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @example Enum with allowed values
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const statusString = new OasString({
|
|
81
|
+
* title: 'Status',
|
|
82
|
+
* description: 'Current status of the item',
|
|
83
|
+
* enums: ['pending', 'approved', 'rejected'],
|
|
84
|
+
* default: 'pending'
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @example Pattern validation
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const phoneString = new OasString({
|
|
91
|
+
* title: 'Phone Number',
|
|
92
|
+
* description: 'US phone number format',
|
|
93
|
+
* pattern: '^\\+?1?[2-9]\\d{2}[2-9]\\d{2}\\d{4}$',
|
|
94
|
+
* example: '+15551234567'
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @example Nullable string
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const nullableString = new OasString<true>({
|
|
101
|
+
* title: 'Optional Note',
|
|
102
|
+
* description: 'Optional note that can be null',
|
|
103
|
+
* nullable: true,
|
|
104
|
+
* default: null
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
20
107
|
*/
|
|
21
108
|
export declare class OasString<Nullable extends boolean | undefined = boolean | undefined> {
|
|
22
109
|
/**
|
|
@@ -68,6 +155,21 @@ export declare class OasString<Nullable extends boolean | undefined = boolean |
|
|
|
68
155
|
* The default value of the string.
|
|
69
156
|
*/
|
|
70
157
|
default: Nullable extends true ? string | null | undefined : string | undefined;
|
|
158
|
+
/**
|
|
159
|
+
* Creates a new OasString instance.
|
|
160
|
+
*
|
|
161
|
+
* @param fields - String schema configuration fields
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const userIdString = new OasString({
|
|
166
|
+
* title: 'User ID',
|
|
167
|
+
* description: 'Unique identifier for user',
|
|
168
|
+
* format: 'uuid',
|
|
169
|
+
* example: '123e4567-e89b-12d3-a456-426614174000'
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
71
173
|
constructor(fields?: StringFields<Nullable>);
|
|
72
174
|
isRef(): this is OasRef<'schema'>;
|
|
73
175
|
resolve(): OasString<Nullable>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"String.d.ts","sourceRoot":"","sources":["../../../src/oas/string/String.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OA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H,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B;;OAEG;IACH,KAAK,EAAE,QAAQ,SAAS,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;IACnF;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B;;OAEG;IACH,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC9B,qCAAqC;IACrC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IACpD,gCAAgC;IAChC,OAAO,EAAE,QAAQ,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;IAC/E;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B;;OAEG;IACH,OAAO,EAAE,QAAQ,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;IAE/E;;;;;;;;;;;;;;OAcG;gBACS,MAAM,GAAE,YAAY,CAAC,QAAQ,CAAM;IAc/C,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,SAAS,CAAC,QAAQ,CAAC;IAI9B,WAAW,IAAI,SAAS,CAAC,QAAQ,CAAC;IAKlC,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC,oBAAoB;CAe5E"}
|
|
@@ -3,9 +3,95 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OasString = void 0;
|
|
4
4
|
require("../../_dnt.polyfills.js");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Represents a string schema in the OpenAPI Specification.
|
|
7
|
+
*
|
|
8
|
+
* `OasString` handles string type definitions with comprehensive validation
|
|
9
|
+
* constraints including format validation, length limits, pattern matching,
|
|
10
|
+
* and enum restrictions. It supports nullable types and provides JSON Schema
|
|
11
|
+
* conversion for validation purposes.
|
|
12
|
+
*
|
|
13
|
+
* This class is used throughout the OAS processing pipeline to represent
|
|
14
|
+
* string fields in API schemas, parameters, and request/response bodies.
|
|
15
|
+
*
|
|
16
|
+
* ## Key Features
|
|
17
|
+
*
|
|
18
|
+
* - **Format Validation**: Support for standard formats (email, date-time, uri, etc.)
|
|
19
|
+
* - **Length Constraints**: Minimum and maximum length validation
|
|
20
|
+
* - **Pattern Matching**: Regular expression validation
|
|
21
|
+
* - **Enum Values**: Restricted sets of allowed values
|
|
22
|
+
* - **Nullable Support**: Type-safe nullable string handling
|
|
23
|
+
* - **JSON Schema**: Conversion to standard JSON Schema format
|
|
24
|
+
*
|
|
25
|
+
* @template Nullable - Whether the string value can be null
|
|
26
|
+
*
|
|
27
|
+
* @example Basic string schema
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { OasString } from '@skmtc/core';
|
|
30
|
+
*
|
|
31
|
+
* const basicString = new OasString({
|
|
32
|
+
* title: 'User Name',
|
|
33
|
+
* description: 'The full name of the user',
|
|
34
|
+
* minLength: 1,
|
|
35
|
+
* maxLength: 100
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example Email format validation
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const emailString = new OasString({
|
|
42
|
+
* title: 'Email Address',
|
|
43
|
+
* description: 'Valid email address',
|
|
44
|
+
* format: 'email',
|
|
45
|
+
* example: 'user@example.com'
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example Enum with allowed values
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const statusString = new OasString({
|
|
52
|
+
* title: 'Status',
|
|
53
|
+
* description: 'Current status of the item',
|
|
54
|
+
* enums: ['pending', 'approved', 'rejected'],
|
|
55
|
+
* default: 'pending'
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example Pattern validation
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const phoneString = new OasString({
|
|
62
|
+
* title: 'Phone Number',
|
|
63
|
+
* description: 'US phone number format',
|
|
64
|
+
* pattern: '^\\+?1?[2-9]\\d{2}[2-9]\\d{2}\\d{4}$',
|
|
65
|
+
* example: '+15551234567'
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example Nullable string
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const nullableString = new OasString<true>({
|
|
72
|
+
* title: 'Optional Note',
|
|
73
|
+
* description: 'Optional note that can be null',
|
|
74
|
+
* nullable: true,
|
|
75
|
+
* default: null
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
7
78
|
*/
|
|
8
79
|
class OasString {
|
|
80
|
+
/**
|
|
81
|
+
* Creates a new OasString instance.
|
|
82
|
+
*
|
|
83
|
+
* @param fields - String schema configuration fields
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const userIdString = new OasString({
|
|
88
|
+
* title: 'User ID',
|
|
89
|
+
* description: 'Unique identifier for user',
|
|
90
|
+
* format: 'uuid',
|
|
91
|
+
* example: '123e4567-e89b-12d3-a456-426614174000'
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
9
95
|
constructor(fields = {}) {
|
|
10
96
|
/**
|
|
11
97
|
* Object is part the 'schema' set which is used
|
package/script/types/Brand.d.ts
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unique symbol used for branding types.
|
|
3
|
+
*
|
|
4
|
+
* This symbol is used internally by the {@link Brand} type to create
|
|
5
|
+
* unique branded types that are structurally identical but nominally
|
|
6
|
+
* distinct from their base types.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
1
10
|
import "../_dnt.polyfills.js";
|
|
2
11
|
declare const brand: unique symbol;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a branded type from a base type.
|
|
14
|
+
*
|
|
15
|
+
* Brand types (also known as nominal types or opaque types) are TypeScript
|
|
16
|
+
* types that are structurally identical to their base type but are treated
|
|
17
|
+
* as distinct types by the type system. This prevents accidental mixing of
|
|
18
|
+
* values that should be kept separate.
|
|
19
|
+
*
|
|
20
|
+
* The SKMTC system uses branded types extensively to ensure type safety
|
|
21
|
+
* when working with identifiers, keys, and other string-based values that
|
|
22
|
+
* have specific semantic meaning.
|
|
23
|
+
*
|
|
24
|
+
* @template T - The base type to brand
|
|
25
|
+
* @template TBrand - The brand identifier (usually a string literal)
|
|
26
|
+
*
|
|
27
|
+
* @example Basic branded type usage
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { Brand } from '@skmtc/core';
|
|
30
|
+
*
|
|
31
|
+
* type UserId = Brand<string, 'UserId'>;
|
|
32
|
+
* type ProductId = Brand<string, 'ProductId'>;
|
|
33
|
+
*
|
|
34
|
+
* const userId: UserId = 'user-123' as UserId;
|
|
35
|
+
* const productId: ProductId = 'prod-456' as ProductId;
|
|
36
|
+
*
|
|
37
|
+
* function getUser(id: UserId) {
|
|
38
|
+
* // Function expects a UserId, not just any string
|
|
39
|
+
* return `User with ID: ${id}`;
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* getUser(userId); // ✅ Works - correct type
|
|
43
|
+
* getUser(productId); // ❌ TypeScript error - ProductId is not UserId
|
|
44
|
+
* getUser('user-789'); // ❌ TypeScript error - string is not UserId
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example SKMTC branded types
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // RefName ensures schema reference safety
|
|
50
|
+
* type RefName = Brand<string, 'RefName'>;
|
|
51
|
+
* const schemaRef: RefName = 'User' as RefName;
|
|
52
|
+
*
|
|
53
|
+
* // GeneratorKey ensures generator identification safety
|
|
54
|
+
* type OperationGeneratorKey = Brand<string, 'OperationGeneratorKey'>;
|
|
55
|
+
* const opKey: OperationGeneratorKey = 'api-client|/users|get' as OperationGeneratorKey;
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example Runtime behavior
|
|
59
|
+
* ```typescript
|
|
60
|
+
* type EmailAddress = Brand<string, 'EmailAddress'>;
|
|
61
|
+
*
|
|
62
|
+
* const email: EmailAddress = 'user@example.com' as EmailAddress;
|
|
63
|
+
*
|
|
64
|
+
* // At runtime, branded types are just their base type
|
|
65
|
+
* console.log(typeof email); // 'string'
|
|
66
|
+
* console.log(email); // 'user@example.com'
|
|
67
|
+
*
|
|
68
|
+
* // But TypeScript enforces the brand at compile time
|
|
69
|
+
* function sendEmail(to: EmailAddress) {
|
|
70
|
+
* // Implementation
|
|
71
|
+
* }
|
|
72
|
+
*
|
|
73
|
+
* sendEmail(email); // ✅ Works
|
|
74
|
+
* sendEmail('test@example.com'); // ❌ Error - needs EmailAddress brand
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
3
77
|
export type Brand<T, TBrand> = T & {
|
|
4
78
|
[brand]: TBrand;
|
|
5
79
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Brand.d.ts","sourceRoot":"","sources":["../../src/types/Brand.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Brand.d.ts","sourceRoot":"","sources":["../../src/types/Brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,sBAAsB,CAAC;AAE9B,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAA;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,GAAG;IAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
|
package/script/types/Brand.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Unique symbol used for branding types.
|
|
5
|
+
*
|
|
6
|
+
* This symbol is used internally by the {@link Brand} type to create
|
|
7
|
+
* unique branded types that are structurally identical but nominally
|
|
8
|
+
* distinct from their base types.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
3
12
|
require("../_dnt.polyfills.js");
|
|
@@ -1,4 +1,65 @@
|
|
|
1
1
|
import "../_dnt.polyfills.js";
|
|
2
2
|
import type { Brand } from './Brand.js';
|
|
3
|
+
/**
|
|
4
|
+
* Branded type representing a reference name for OpenAPI schemas.
|
|
5
|
+
*
|
|
6
|
+
* `RefName` is a branded string type that ensures type safety when working
|
|
7
|
+
* with schema reference names throughout the SKMTC system. It prevents
|
|
8
|
+
* accidental mixing of regular strings with schema reference identifiers.
|
|
9
|
+
*
|
|
10
|
+
* Reference names typically correspond to keys in the OpenAPI `components.schemas`
|
|
11
|
+
* section and are used to create cross-references between different parts
|
|
12
|
+
* of the schema definition.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { RefName } from '@skmtc/core';
|
|
17
|
+
*
|
|
18
|
+
* // RefName is extracted from OpenAPI schema references
|
|
19
|
+
* const userRefName: RefName = 'User' as RefName;
|
|
20
|
+
* const productRefName: RefName = 'Product' as RefName;
|
|
21
|
+
*
|
|
22
|
+
* // Used in schema references
|
|
23
|
+
* const userRef = new OasRef({
|
|
24
|
+
* refName: userRefName, // Type-safe reference name
|
|
25
|
+
* ref: '#/components/schemas/User'
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example In generator contexts
|
|
30
|
+
* ```typescript
|
|
31
|
+
* class ModelGenerator extends ModelBase {
|
|
32
|
+
* constructor(args: { refName: RefName; ... }) {
|
|
33
|
+
* super(args);
|
|
34
|
+
* // this.refName is guaranteed to be a valid schema reference
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* toDefinition(): Definition {
|
|
38
|
+
* // RefName ensures we're working with valid schema identifiers
|
|
39
|
+
* const schemaName = this.refName; // Type: RefName
|
|
40
|
+
* return new Definition({
|
|
41
|
+
* identifier: Identifier.createType(schemaName),
|
|
42
|
+
* // ...
|
|
43
|
+
* });
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example Type safety benefits
|
|
49
|
+
* ```typescript
|
|
50
|
+
* function processSchema(refName: RefName) {
|
|
51
|
+
* // RefName brand ensures this is a valid schema reference
|
|
52
|
+
* console.log(`Processing schema: ${refName}`);
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* const validRef: RefName = 'User' as RefName;
|
|
56
|
+
* const regularString = 'just a string';
|
|
57
|
+
*
|
|
58
|
+
* processSchema(validRef); // ✅ Works - RefName type
|
|
59
|
+
* processSchema(regularString); // ❌ TypeScript error - string is not RefName
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @see {@link Brand} for the underlying branding mechanism
|
|
63
|
+
*/
|
|
3
64
|
export type RefName = Brand<string, 'RefName'>;
|
|
4
65
|
//# sourceMappingURL=RefName.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefName.d.ts","sourceRoot":"","sources":["../../src/types/RefName.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"RefName.d.ts","sourceRoot":"","sources":["../../src/types/RefName.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA"}
|