@skmtc/core 0.0.789 → 0.0.791
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/context/RenderContext.d.ts +190 -0
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +179 -0
- package/esm/oas/boolean/Boolean.d.ts +142 -1
- package/esm/oas/boolean/Boolean.d.ts.map +1 -1
- package/esm/oas/boolean/Boolean.js +130 -1
- package/esm/oas/number/Number.d.ts +179 -1
- package/esm/oas/number/Number.d.ts.map +1 -1
- package/esm/oas/number/Number.js +161 -1
- package/esm/oas/parameter/Parameter.d.ts +160 -0
- package/esm/oas/parameter/Parameter.d.ts.map +1 -1
- package/esm/oas/parameter/Parameter.js +144 -0
- package/esm/oas/response/Response.d.ts +190 -0
- package/esm/oas/response/Response.d.ts.map +1 -1
- package/esm/oas/response/Response.js +183 -0
- package/esm/oas/void/Void.d.ts +130 -3
- package/esm/oas/void/Void.d.ts.map +1 -1
- package/esm/oas/void/Void.js +125 -3
- package/package.json +1 -1
- package/script/context/RenderContext.d.ts +190 -0
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +179 -0
- package/script/oas/boolean/Boolean.d.ts +142 -1
- package/script/oas/boolean/Boolean.d.ts.map +1 -1
- package/script/oas/boolean/Boolean.js +130 -1
- package/script/oas/number/Number.d.ts +179 -1
- package/script/oas/number/Number.d.ts.map +1 -1
- package/script/oas/number/Number.js +161 -1
- package/script/oas/parameter/Parameter.d.ts +160 -0
- package/script/oas/parameter/Parameter.d.ts.map +1 -1
- package/script/oas/parameter/Parameter.js +144 -0
- package/script/oas/response/Response.d.ts +190 -0
- package/script/oas/response/Response.d.ts.map +1 -1
- package/script/oas/response/Response.js +183 -0
- package/script/oas/void/Void.d.ts +130 -3
- package/script/oas/void/Void.d.ts.map +1 -1
- package/script/oas/void/Void.js +125 -3
|
@@ -2,17 +2,158 @@ import "../../_dnt.polyfills.js";
|
|
|
2
2
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
3
3
|
import type { OasRef } from '../ref/Ref.js';
|
|
4
4
|
import type { ToJsonSchemaOptions } from '../schema/Schema.js';
|
|
5
|
+
/**
|
|
6
|
+
* Constructor fields for {@link OasBoolean}.
|
|
7
|
+
*
|
|
8
|
+
* @template Nullable - Whether the boolean can be null (affects type unions)
|
|
9
|
+
*/
|
|
5
10
|
export type BooleanFields<Nullable extends boolean | undefined> = {
|
|
11
|
+
/** A short summary of the boolean schema */
|
|
6
12
|
title?: string;
|
|
13
|
+
/** A description of the boolean schema */
|
|
7
14
|
description?: string;
|
|
15
|
+
/** Whether the boolean value can be null */
|
|
8
16
|
nullable?: Nullable;
|
|
17
|
+
/** Custom extension fields (x-* properties) */
|
|
9
18
|
extensionFields?: Record<string, unknown>;
|
|
19
|
+
/** Example value for the boolean (null allowed if Nullable is true) */
|
|
10
20
|
example?: Nullable extends true ? boolean | null | undefined : boolean | undefined;
|
|
21
|
+
/** Array of valid enum values for the boolean (null allowed if Nullable is true) */
|
|
11
22
|
enums?: Nullable extends true ? (boolean | null)[] | undefined : boolean[] | undefined;
|
|
23
|
+
/** Default value for the boolean (null allowed if Nullable is true) */
|
|
12
24
|
default?: Nullable extends true ? boolean | null | undefined : boolean | undefined;
|
|
13
25
|
};
|
|
14
26
|
/**
|
|
15
|
-
*
|
|
27
|
+
* Represents a boolean schema in the OpenAPI Specification.
|
|
28
|
+
*
|
|
29
|
+
* The `OasBoolean` class handles boolean data types in OpenAPI schemas, supporting
|
|
30
|
+
* both simple true/false values and more complex boolean schemas with constraints,
|
|
31
|
+
* enumerations, and nullable types. This class provides type-safe boolean handling
|
|
32
|
+
* with optional null value support through generic typing.
|
|
33
|
+
*
|
|
34
|
+
* ## Key Features
|
|
35
|
+
*
|
|
36
|
+
* - **Type Safety**: Generic nullable type support with proper TypeScript inference
|
|
37
|
+
* - **Enum Support**: Constrain boolean values to specific true/false combinations
|
|
38
|
+
* - **Null Handling**: Optional null value support for nullable boolean types
|
|
39
|
+
* - **Validation**: Default values and example validation
|
|
40
|
+
* - **JSON Schema**: Converts to standard JSON Schema format for validation
|
|
41
|
+
* - **Documentation**: Rich metadata support for API documentation
|
|
42
|
+
*
|
|
43
|
+
* @template Nullable - Whether the boolean value itself can be null
|
|
44
|
+
*
|
|
45
|
+
* @example Basic boolean schema
|
|
46
|
+
* ```typescript
|
|
47
|
+
* import { OasBoolean } from '@skmtc/core';
|
|
48
|
+
*
|
|
49
|
+
* const isActiveSchema = new OasBoolean({
|
|
50
|
+
* title: 'Active Status',
|
|
51
|
+
* description: 'Whether the user account is active',
|
|
52
|
+
* default: true,
|
|
53
|
+
* example: true
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // This represents: boolean with default true
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example Nullable boolean schema
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const nullableFlag = new OasBoolean<true>({
|
|
62
|
+
* title: 'Optional Flag',
|
|
63
|
+
* description: 'An optional boolean flag that can be null',
|
|
64
|
+
* nullable: true,
|
|
65
|
+
* default: null,
|
|
66
|
+
* example: true
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* // This represents: boolean | null
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example Boolean with enum constraints
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const strictBoolean = new OasBoolean({
|
|
75
|
+
* title: 'Confirmation',
|
|
76
|
+
* description: 'Must explicitly be true to confirm action',
|
|
77
|
+
* enums: [true], // Only true is allowed
|
|
78
|
+
* example: true
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* // This only accepts true, effectively making it required
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @example Boolean with null in enum
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const triStateBoolean = new OasBoolean<true>({
|
|
87
|
+
* title: 'Approval Status',
|
|
88
|
+
* description: 'Approval can be true (approved), false (denied), or null (pending)',
|
|
89
|
+
* nullable: true,
|
|
90
|
+
* enums: [true, false, null],
|
|
91
|
+
* default: null,
|
|
92
|
+
* example: null
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* // This represents: true | false | null (tri-state logic)
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @example Feature flag schema
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const featureFlag = new OasBoolean({
|
|
101
|
+
* title: 'Feature Enabled',
|
|
102
|
+
* description: 'Whether the new feature is enabled for this user',
|
|
103
|
+
* default: false,
|
|
104
|
+
* example: false
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* // Used in configuration objects
|
|
108
|
+
* const userConfig = new OasObject({
|
|
109
|
+
* properties: {
|
|
110
|
+
* darkMode: featureFlag,
|
|
111
|
+
* notifications: featureFlag,
|
|
112
|
+
* betaFeatures: featureFlag
|
|
113
|
+
* }
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @example Consent and agreement booleans
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const consentSchema = new OasBoolean({
|
|
120
|
+
* title: 'Terms Accepted',
|
|
121
|
+
* description: 'User has accepted the terms and conditions',
|
|
122
|
+
* enums: [true], // Must be true to be valid
|
|
123
|
+
* example: true
|
|
124
|
+
* });
|
|
125
|
+
*
|
|
126
|
+
* const privacyConsent = new OasBoolean({
|
|
127
|
+
* title: 'Privacy Policy Accepted',
|
|
128
|
+
* description: 'User has accepted the privacy policy',
|
|
129
|
+
* default: false,
|
|
130
|
+
* example: true
|
|
131
|
+
* });
|
|
132
|
+
*
|
|
133
|
+
* // Used in registration forms where consent is required
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @example Optional settings with nullable booleans
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const userPreferences = new OasObject({
|
|
139
|
+
* properties: {
|
|
140
|
+
* emailNotifications: new OasBoolean<true>({
|
|
141
|
+
* title: 'Email Notifications',
|
|
142
|
+
* description: 'Enable email notifications (null means use default)',
|
|
143
|
+
* nullable: true,
|
|
144
|
+
* default: null
|
|
145
|
+
* }),
|
|
146
|
+
* smsNotifications: new OasBoolean<true>({
|
|
147
|
+
* title: 'SMS Notifications',
|
|
148
|
+
* description: 'Enable SMS notifications (null means not set)',
|
|
149
|
+
* nullable: true,
|
|
150
|
+
* default: null
|
|
151
|
+
* })
|
|
152
|
+
* }
|
|
153
|
+
* });
|
|
154
|
+
*
|
|
155
|
+
* // Allows: { emailNotifications: true, smsNotifications: null }
|
|
156
|
+
* ```
|
|
16
157
|
*/
|
|
17
158
|
export declare class OasBoolean<Nullable extends boolean | undefined = boolean | undefined> {
|
|
18
159
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Boolean.d.ts","sourceRoot":"","sources":["../../../src/oas/boolean/Boolean.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"Boolean.d.ts","sourceRoot":"","sources":["../../../src/oas/boolean/Boolean.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE9D;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,QAAQ,SAAS,OAAO,GAAG,SAAS,IAAI;IAChE,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0CAA0C;IAC1C,WAAW,CAAC,EA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S,GAAG,OAAO,GAAG,SAAS,CAAA;IAEjF;;OAEG;IACH,KAAK,EAAE,QAAQ,SAAS,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,GAAG,OAAO,EAAE,GAAG,SAAS,CAAA;IACrF;;OAEG;IACH,OAAO,EAAE,QAAQ,SAAS,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;gBAErE,MAAM,GAAE,aAAa,CAAC,QAAQ,CAAM;IAUhD,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;CAW5E"}
|
|
@@ -3,7 +3,136 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OasBoolean = void 0;
|
|
4
4
|
require("../../_dnt.polyfills.js");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Represents a boolean schema in the OpenAPI Specification.
|
|
7
|
+
*
|
|
8
|
+
* The `OasBoolean` class handles boolean data types in OpenAPI schemas, supporting
|
|
9
|
+
* both simple true/false values and more complex boolean schemas with constraints,
|
|
10
|
+
* enumerations, and nullable types. This class provides type-safe boolean handling
|
|
11
|
+
* with optional null value support through generic typing.
|
|
12
|
+
*
|
|
13
|
+
* ## Key Features
|
|
14
|
+
*
|
|
15
|
+
* - **Type Safety**: Generic nullable type support with proper TypeScript inference
|
|
16
|
+
* - **Enum Support**: Constrain boolean values to specific true/false combinations
|
|
17
|
+
* - **Null Handling**: Optional null value support for nullable boolean types
|
|
18
|
+
* - **Validation**: Default values and example validation
|
|
19
|
+
* - **JSON Schema**: Converts to standard JSON Schema format for validation
|
|
20
|
+
* - **Documentation**: Rich metadata support for API documentation
|
|
21
|
+
*
|
|
22
|
+
* @template Nullable - Whether the boolean value itself can be null
|
|
23
|
+
*
|
|
24
|
+
* @example Basic boolean schema
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { OasBoolean } from '@skmtc/core';
|
|
27
|
+
*
|
|
28
|
+
* const isActiveSchema = new OasBoolean({
|
|
29
|
+
* title: 'Active Status',
|
|
30
|
+
* description: 'Whether the user account is active',
|
|
31
|
+
* default: true,
|
|
32
|
+
* example: true
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // This represents: boolean with default true
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example Nullable boolean schema
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const nullableFlag = new OasBoolean<true>({
|
|
41
|
+
* title: 'Optional Flag',
|
|
42
|
+
* description: 'An optional boolean flag that can be null',
|
|
43
|
+
* nullable: true,
|
|
44
|
+
* default: null,
|
|
45
|
+
* example: true
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // This represents: boolean | null
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @example Boolean with enum constraints
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const strictBoolean = new OasBoolean({
|
|
54
|
+
* title: 'Confirmation',
|
|
55
|
+
* description: 'Must explicitly be true to confirm action',
|
|
56
|
+
* enums: [true], // Only true is allowed
|
|
57
|
+
* example: true
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* // This only accepts true, effectively making it required
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Boolean with null in enum
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const triStateBoolean = new OasBoolean<true>({
|
|
66
|
+
* title: 'Approval Status',
|
|
67
|
+
* description: 'Approval can be true (approved), false (denied), or null (pending)',
|
|
68
|
+
* nullable: true,
|
|
69
|
+
* enums: [true, false, null],
|
|
70
|
+
* default: null,
|
|
71
|
+
* example: null
|
|
72
|
+
* });
|
|
73
|
+
*
|
|
74
|
+
* // This represents: true | false | null (tri-state logic)
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @example Feature flag schema
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const featureFlag = new OasBoolean({
|
|
80
|
+
* title: 'Feature Enabled',
|
|
81
|
+
* description: 'Whether the new feature is enabled for this user',
|
|
82
|
+
* default: false,
|
|
83
|
+
* example: false
|
|
84
|
+
* });
|
|
85
|
+
*
|
|
86
|
+
* // Used in configuration objects
|
|
87
|
+
* const userConfig = new OasObject({
|
|
88
|
+
* properties: {
|
|
89
|
+
* darkMode: featureFlag,
|
|
90
|
+
* notifications: featureFlag,
|
|
91
|
+
* betaFeatures: featureFlag
|
|
92
|
+
* }
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @example Consent and agreement booleans
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const consentSchema = new OasBoolean({
|
|
99
|
+
* title: 'Terms Accepted',
|
|
100
|
+
* description: 'User has accepted the terms and conditions',
|
|
101
|
+
* enums: [true], // Must be true to be valid
|
|
102
|
+
* example: true
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* const privacyConsent = new OasBoolean({
|
|
106
|
+
* title: 'Privacy Policy Accepted',
|
|
107
|
+
* description: 'User has accepted the privacy policy',
|
|
108
|
+
* default: false,
|
|
109
|
+
* example: true
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* // Used in registration forms where consent is required
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @example Optional settings with nullable booleans
|
|
116
|
+
* ```typescript
|
|
117
|
+
* const userPreferences = new OasObject({
|
|
118
|
+
* properties: {
|
|
119
|
+
* emailNotifications: new OasBoolean<true>({
|
|
120
|
+
* title: 'Email Notifications',
|
|
121
|
+
* description: 'Enable email notifications (null means use default)',
|
|
122
|
+
* nullable: true,
|
|
123
|
+
* default: null
|
|
124
|
+
* }),
|
|
125
|
+
* smsNotifications: new OasBoolean<true>({
|
|
126
|
+
* title: 'SMS Notifications',
|
|
127
|
+
* description: 'Enable SMS notifications (null means not set)',
|
|
128
|
+
* nullable: true,
|
|
129
|
+
* default: null
|
|
130
|
+
* })
|
|
131
|
+
* }
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* // Allows: { emailNotifications: true, smsNotifications: null }
|
|
135
|
+
* ```
|
|
7
136
|
*/
|
|
8
137
|
class OasBoolean {
|
|
9
138
|
constructor(fields = {}) {
|
|
@@ -2,23 +2,201 @@ 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 OasNumber}.
|
|
7
|
+
*
|
|
8
|
+
* @template Nullable - Whether the number can be null (affects type unions)
|
|
9
|
+
*/
|
|
5
10
|
export type NumberFields<Nullable extends boolean | undefined> = {
|
|
11
|
+
/** A short summary of the number schema */
|
|
6
12
|
title?: string;
|
|
13
|
+
/** A description of the number schema */
|
|
7
14
|
description?: string;
|
|
15
|
+
/** Whether the number value can be null */
|
|
8
16
|
nullable?: Nullable;
|
|
17
|
+
/** Default value for the number (null allowed if Nullable is true) */
|
|
9
18
|
default?: Nullable extends true ? number | null | undefined : number | undefined;
|
|
19
|
+
/** Custom extension fields (x-* properties) */
|
|
10
20
|
extensionFields?: Record<string, unknown>;
|
|
21
|
+
/** Example value for the number (null allowed if Nullable is true) */
|
|
11
22
|
example?: Nullable extends true ? number | null | undefined : number | undefined;
|
|
23
|
+
/** Array of valid enum values for the number (null allowed if Nullable is true) */
|
|
12
24
|
enums?: Nullable extends true ? (number | null)[] | undefined : number[] | undefined;
|
|
25
|
+
/** The format of the number (float or double precision) */
|
|
13
26
|
format?: 'float' | 'double';
|
|
27
|
+
/** Value must be a multiple of this number */
|
|
14
28
|
multipleOf?: number;
|
|
29
|
+
/** Maximum value allowed (inclusive by default) */
|
|
15
30
|
maximum?: number;
|
|
31
|
+
/** Whether the maximum value is exclusive */
|
|
16
32
|
exclusiveMaximum?: boolean;
|
|
33
|
+
/** Minimum value allowed (inclusive by default) */
|
|
17
34
|
minimum?: number;
|
|
35
|
+
/** Whether the minimum value is exclusive */
|
|
18
36
|
exclusiveMinimum?: boolean;
|
|
19
37
|
};
|
|
20
38
|
/**
|
|
21
|
-
*
|
|
39
|
+
* Represents a number schema in the OpenAPI Specification.
|
|
40
|
+
*
|
|
41
|
+
* The `OasNumber` class handles floating-point numeric data types in OpenAPI schemas,
|
|
42
|
+
* supporting comprehensive validation constraints including ranges, precision formats,
|
|
43
|
+
* and mathematical constraints. This class provides type-safe number handling with
|
|
44
|
+
* optional null value support and extensive validation capabilities.
|
|
45
|
+
*
|
|
46
|
+
* ## Key Features
|
|
47
|
+
*
|
|
48
|
+
* - **Range Validation**: Minimum and maximum constraints with exclusive/inclusive options
|
|
49
|
+
* - **Precision Control**: Float and double format support for different precision needs
|
|
50
|
+
* - **Mathematical Constraints**: Multiple-of validation for specific numeric patterns
|
|
51
|
+
* - **Type Safety**: Generic nullable type support with proper TypeScript inference
|
|
52
|
+
* - **Enum Support**: Constrain numbers to specific allowed values
|
|
53
|
+
* - **Null Handling**: Optional null value support for nullable number types
|
|
54
|
+
*
|
|
55
|
+
* @template Nullable - Whether the number value itself can be null
|
|
56
|
+
*
|
|
57
|
+
* @example Basic number schema with range
|
|
58
|
+
* ```typescript
|
|
59
|
+
* import { OasNumber } from '@skmtc/core';
|
|
60
|
+
*
|
|
61
|
+
* const ageSchema = new OasNumber({
|
|
62
|
+
* title: 'Age',
|
|
63
|
+
* description: 'Person age in years',
|
|
64
|
+
* minimum: 0,
|
|
65
|
+
* maximum: 150,
|
|
66
|
+
* example: 25,
|
|
67
|
+
* default: 18
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // This represents: number (0 <= value <= 150)
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example Price with precision and constraints
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const priceSchema = new OasNumber({
|
|
76
|
+
* title: 'Product Price',
|
|
77
|
+
* description: 'Price in USD with cent precision',
|
|
78
|
+
* format: 'double',
|
|
79
|
+
* minimum: 0,
|
|
80
|
+
* exclusiveMinimum: true, // Must be > 0, not >= 0
|
|
81
|
+
* multipleOf: 0.01, // Must be in cents (e.g., 19.99, 10.50)
|
|
82
|
+
* example: 29.99
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* // This represents: number > 0, in multiples of 0.01
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @example Percentage with strict bounds
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const percentageSchema = new OasNumber({
|
|
91
|
+
* title: 'Completion Percentage',
|
|
92
|
+
* description: 'Task completion as a percentage',
|
|
93
|
+
* minimum: 0,
|
|
94
|
+
* maximum: 100,
|
|
95
|
+
* multipleOf: 0.1, // One decimal place precision
|
|
96
|
+
* example: 75.5,
|
|
97
|
+
* default: 0
|
|
98
|
+
* });
|
|
99
|
+
*
|
|
100
|
+
* // This represents: 0 <= value <= 100, in increments of 0.1
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @example Nullable rating system
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const ratingSchema = new OasNumber<true>({
|
|
106
|
+
* title: 'User Rating',
|
|
107
|
+
* description: 'Product rating from 1-5 stars, null if not rated',
|
|
108
|
+
* nullable: true,
|
|
109
|
+
* minimum: 1,
|
|
110
|
+
* maximum: 5,
|
|
111
|
+
* multipleOf: 0.5, // Allow half-star ratings
|
|
112
|
+
* enums: [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, null],
|
|
113
|
+
* example: 4.5,
|
|
114
|
+
* default: null
|
|
115
|
+
* });
|
|
116
|
+
*
|
|
117
|
+
* // This represents: (1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 4.5 | 5) | null
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @example Scientific measurement with high precision
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const temperatureSchema = new OasNumber({
|
|
123
|
+
* title: 'Temperature',
|
|
124
|
+
* description: 'Temperature in Celsius with high precision',
|
|
125
|
+
* format: 'double',
|
|
126
|
+
* minimum: -273.15, // Absolute zero
|
|
127
|
+
* maximum: 1000,
|
|
128
|
+
* multipleOf: 0.001, // Millikelvin precision
|
|
129
|
+
* example: 23.456
|
|
130
|
+
* });
|
|
131
|
+
*
|
|
132
|
+
* // For scientific applications requiring high precision
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @example Currency with regional constraints
|
|
136
|
+
* ```typescript
|
|
137
|
+
* const currencySchema = new OasNumber({
|
|
138
|
+
* title: 'Amount',
|
|
139
|
+
* description: 'Transaction amount in major currency units',
|
|
140
|
+
* format: 'double',
|
|
141
|
+
* minimum: 0,
|
|
142
|
+
* maximum: 999999.99,
|
|
143
|
+
* multipleOf: 0.01,
|
|
144
|
+
* example: 1234.56
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* // Used in financial applications
|
|
148
|
+
* const transaction = new OasObject({
|
|
149
|
+
* properties: {
|
|
150
|
+
* amount: currencySchema,
|
|
151
|
+
* currency: new OasString({ enum: ['USD', 'EUR', 'GBP'] })
|
|
152
|
+
* }
|
|
153
|
+
* });
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @example Coordinate system
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const latitudeSchema = new OasNumber({
|
|
159
|
+
* title: 'Latitude',
|
|
160
|
+
* description: 'Geographic latitude coordinate',
|
|
161
|
+
* format: 'double',
|
|
162
|
+
* minimum: -90,
|
|
163
|
+
* maximum: 90,
|
|
164
|
+
* example: 40.7128
|
|
165
|
+
* });
|
|
166
|
+
*
|
|
167
|
+
* const longitudeSchema = new OasNumber({
|
|
168
|
+
* title: 'Longitude',
|
|
169
|
+
* description: 'Geographic longitude coordinate',
|
|
170
|
+
* format: 'double',
|
|
171
|
+
* minimum: -180,
|
|
172
|
+
* maximum: 180,
|
|
173
|
+
* example: -74.0060
|
|
174
|
+
* });
|
|
175
|
+
*
|
|
176
|
+
* // Used for location data
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* @example Probability and statistics
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const probabilitySchema = new OasNumber({
|
|
182
|
+
* title: 'Probability',
|
|
183
|
+
* description: 'Statistical probability value',
|
|
184
|
+
* minimum: 0,
|
|
185
|
+
* maximum: 1,
|
|
186
|
+
* exclusiveMaximum: false, // Can be exactly 1
|
|
187
|
+
* example: 0.75,
|
|
188
|
+
* default: 0.5
|
|
189
|
+
* });
|
|
190
|
+
*
|
|
191
|
+
* const confidenceSchema = new OasNumber({
|
|
192
|
+
* title: 'Confidence Level',
|
|
193
|
+
* description: 'Statistical confidence level as percentage',
|
|
194
|
+
* minimum: 0,
|
|
195
|
+
* maximum: 100,
|
|
196
|
+
* enums: [90, 95, 99], // Common confidence levels
|
|
197
|
+
* example: 95
|
|
198
|
+
* });
|
|
199
|
+
* ```
|
|
22
200
|
*/
|
|
23
201
|
export declare class OasNumber<Nullable extends boolean | undefined = boolean | undefined> {
|
|
24
202
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Number.d.ts","sourceRoot":"","sources":["../../../src/oas/number/Number.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;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"Number.d.ts","sourceRoot":"","sources":["../../../src/oas/number/Number.ts"],"names":[],"mappings":"AAAA,O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O,GAAG,SAAS,CAAA;IACrC;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B;;OAEG;IACH,gBAAgB,EAAE,OAAO,GAAG,SAAS,CAAA;gBACzB,MAAM,GAAE,YAAY,CAAC,QAAQ,CAAM;IAgB/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;CAgB5E"}
|
|
@@ -3,7 +3,167 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OasNumber = void 0;
|
|
4
4
|
require("../../_dnt.polyfills.js");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Represents a number schema in the OpenAPI Specification.
|
|
7
|
+
*
|
|
8
|
+
* The `OasNumber` class handles floating-point numeric data types in OpenAPI schemas,
|
|
9
|
+
* supporting comprehensive validation constraints including ranges, precision formats,
|
|
10
|
+
* and mathematical constraints. This class provides type-safe number handling with
|
|
11
|
+
* optional null value support and extensive validation capabilities.
|
|
12
|
+
*
|
|
13
|
+
* ## Key Features
|
|
14
|
+
*
|
|
15
|
+
* - **Range Validation**: Minimum and maximum constraints with exclusive/inclusive options
|
|
16
|
+
* - **Precision Control**: Float and double format support for different precision needs
|
|
17
|
+
* - **Mathematical Constraints**: Multiple-of validation for specific numeric patterns
|
|
18
|
+
* - **Type Safety**: Generic nullable type support with proper TypeScript inference
|
|
19
|
+
* - **Enum Support**: Constrain numbers to specific allowed values
|
|
20
|
+
* - **Null Handling**: Optional null value support for nullable number types
|
|
21
|
+
*
|
|
22
|
+
* @template Nullable - Whether the number value itself can be null
|
|
23
|
+
*
|
|
24
|
+
* @example Basic number schema with range
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { OasNumber } from '@skmtc/core';
|
|
27
|
+
*
|
|
28
|
+
* const ageSchema = new OasNumber({
|
|
29
|
+
* title: 'Age',
|
|
30
|
+
* description: 'Person age in years',
|
|
31
|
+
* minimum: 0,
|
|
32
|
+
* maximum: 150,
|
|
33
|
+
* example: 25,
|
|
34
|
+
* default: 18
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // This represents: number (0 <= value <= 150)
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example Price with precision and constraints
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const priceSchema = new OasNumber({
|
|
43
|
+
* title: 'Product Price',
|
|
44
|
+
* description: 'Price in USD with cent precision',
|
|
45
|
+
* format: 'double',
|
|
46
|
+
* minimum: 0,
|
|
47
|
+
* exclusiveMinimum: true, // Must be > 0, not >= 0
|
|
48
|
+
* multipleOf: 0.01, // Must be in cents (e.g., 19.99, 10.50)
|
|
49
|
+
* example: 29.99
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // This represents: number > 0, in multiples of 0.01
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example Percentage with strict bounds
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const percentageSchema = new OasNumber({
|
|
58
|
+
* title: 'Completion Percentage',
|
|
59
|
+
* description: 'Task completion as a percentage',
|
|
60
|
+
* minimum: 0,
|
|
61
|
+
* maximum: 100,
|
|
62
|
+
* multipleOf: 0.1, // One decimal place precision
|
|
63
|
+
* example: 75.5,
|
|
64
|
+
* default: 0
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* // This represents: 0 <= value <= 100, in increments of 0.1
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example Nullable rating system
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const ratingSchema = new OasNumber<true>({
|
|
73
|
+
* title: 'User Rating',
|
|
74
|
+
* description: 'Product rating from 1-5 stars, null if not rated',
|
|
75
|
+
* nullable: true,
|
|
76
|
+
* minimum: 1,
|
|
77
|
+
* maximum: 5,
|
|
78
|
+
* multipleOf: 0.5, // Allow half-star ratings
|
|
79
|
+
* enums: [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, null],
|
|
80
|
+
* example: 4.5,
|
|
81
|
+
* default: null
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* // This represents: (1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 4.5 | 5) | null
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example Scientific measurement with high precision
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const temperatureSchema = new OasNumber({
|
|
90
|
+
* title: 'Temperature',
|
|
91
|
+
* description: 'Temperature in Celsius with high precision',
|
|
92
|
+
* format: 'double',
|
|
93
|
+
* minimum: -273.15, // Absolute zero
|
|
94
|
+
* maximum: 1000,
|
|
95
|
+
* multipleOf: 0.001, // Millikelvin precision
|
|
96
|
+
* example: 23.456
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* // For scientific applications requiring high precision
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @example Currency with regional constraints
|
|
103
|
+
* ```typescript
|
|
104
|
+
* const currencySchema = new OasNumber({
|
|
105
|
+
* title: 'Amount',
|
|
106
|
+
* description: 'Transaction amount in major currency units',
|
|
107
|
+
* format: 'double',
|
|
108
|
+
* minimum: 0,
|
|
109
|
+
* maximum: 999999.99,
|
|
110
|
+
* multipleOf: 0.01,
|
|
111
|
+
* example: 1234.56
|
|
112
|
+
* });
|
|
113
|
+
*
|
|
114
|
+
* // Used in financial applications
|
|
115
|
+
* const transaction = new OasObject({
|
|
116
|
+
* properties: {
|
|
117
|
+
* amount: currencySchema,
|
|
118
|
+
* currency: new OasString({ enum: ['USD', 'EUR', 'GBP'] })
|
|
119
|
+
* }
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @example Coordinate system
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const latitudeSchema = new OasNumber({
|
|
126
|
+
* title: 'Latitude',
|
|
127
|
+
* description: 'Geographic latitude coordinate',
|
|
128
|
+
* format: 'double',
|
|
129
|
+
* minimum: -90,
|
|
130
|
+
* maximum: 90,
|
|
131
|
+
* example: 40.7128
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* const longitudeSchema = new OasNumber({
|
|
135
|
+
* title: 'Longitude',
|
|
136
|
+
* description: 'Geographic longitude coordinate',
|
|
137
|
+
* format: 'double',
|
|
138
|
+
* minimum: -180,
|
|
139
|
+
* maximum: 180,
|
|
140
|
+
* example: -74.0060
|
|
141
|
+
* });
|
|
142
|
+
*
|
|
143
|
+
* // Used for location data
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @example Probability and statistics
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const probabilitySchema = new OasNumber({
|
|
149
|
+
* title: 'Probability',
|
|
150
|
+
* description: 'Statistical probability value',
|
|
151
|
+
* minimum: 0,
|
|
152
|
+
* maximum: 1,
|
|
153
|
+
* exclusiveMaximum: false, // Can be exactly 1
|
|
154
|
+
* example: 0.75,
|
|
155
|
+
* default: 0.5
|
|
156
|
+
* });
|
|
157
|
+
*
|
|
158
|
+
* const confidenceSchema = new OasNumber({
|
|
159
|
+
* title: 'Confidence Level',
|
|
160
|
+
* description: 'Statistical confidence level as percentage',
|
|
161
|
+
* minimum: 0,
|
|
162
|
+
* maximum: 100,
|
|
163
|
+
* enums: [90, 95, 99], // Common confidence levels
|
|
164
|
+
* example: 95
|
|
165
|
+
* });
|
|
166
|
+
* ```
|
|
7
167
|
*/
|
|
8
168
|
class OasNumber {
|
|
9
169
|
constructor(fields = {}) {
|