@skmtc/core 0.0.786 → 0.0.788
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/GenerateContext.d.ts +95 -0
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +95 -0
- 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/dsl/JsonFile.d.ts +162 -0
- package/esm/dsl/JsonFile.d.ts.map +1 -1
- package/esm/dsl/JsonFile.js +157 -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/operation/Operation.d.ts +107 -1
- package/esm/oas/operation/Operation.d.ts.map +1 -1
- package/esm/oas/operation/Operation.js +107 -1
- package/esm/oas/ref/Ref.d.ts +86 -0
- package/esm/oas/ref/Ref.d.ts.map +1 -1
- package/esm/oas/ref/Ref.js +86 -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/context/GenerateContext.d.ts +95 -0
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +95 -0
- 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/dsl/JsonFile.d.ts +162 -0
- package/script/dsl/JsonFile.d.ts.map +1 -1
- package/script/dsl/JsonFile.js +157 -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/operation/Operation.d.ts +107 -1
- package/script/oas/operation/Operation.d.ts.map +1 -1
- package/script/oas/operation/Operation.js +107 -1
- package/script/oas/ref/Ref.d.ts +86 -0
- package/script/oas/ref/Ref.d.ts.map +1 -1
- package/script/oas/ref/Ref.js +86 -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
package/script/dsl/JsonFile.js
CHANGED
|
@@ -1,20 +1,154 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JsonFile = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a JSON file in the SKMTC DSL system.
|
|
6
|
+
*
|
|
7
|
+
* The `JsonFile` class is used to generate JSON files as part of the code generation
|
|
8
|
+
* process. It provides a simple interface for creating configuration files, manifests,
|
|
9
|
+
* package.json files, and other JSON-based artifacts with proper formatting.
|
|
10
|
+
*
|
|
11
|
+
* ## Key Features
|
|
12
|
+
*
|
|
13
|
+
* - **JSON Formatting**: Automatically formats JSON with 2-space indentation
|
|
14
|
+
* - **Type Safety**: Accepts any valid JSON-serializable content structure
|
|
15
|
+
* - **Path Management**: Associates content with specific file paths
|
|
16
|
+
* - **String Conversion**: Easy integration with file writing systems
|
|
17
|
+
*
|
|
18
|
+
* @example Basic JSON file creation
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { JsonFile } from '@skmtc/core';
|
|
21
|
+
*
|
|
22
|
+
* const packageJson = new JsonFile({
|
|
23
|
+
* path: './package.json',
|
|
24
|
+
* content: {
|
|
25
|
+
* name: 'my-api-client',
|
|
26
|
+
* version: '1.0.0',
|
|
27
|
+
* type: 'module',
|
|
28
|
+
* main: './index.js',
|
|
29
|
+
* dependencies: {
|
|
30
|
+
* 'axios': '^1.0.0'
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* const jsonContent = packageJson.toString();
|
|
36
|
+
* console.log(jsonContent);
|
|
37
|
+
* // {
|
|
38
|
+
* // "name": "my-api-client",
|
|
39
|
+
* // "version": "1.0.0",
|
|
40
|
+
* // "type": "module",
|
|
41
|
+
* // "main": "./index.js",
|
|
42
|
+
* // "dependencies": {
|
|
43
|
+
* // "axios": "^1.0.0"
|
|
44
|
+
* // }
|
|
45
|
+
* // }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example Configuration file generation
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const configFile = new JsonFile({
|
|
51
|
+
* path: './src/config/api.json',
|
|
52
|
+
* content: {
|
|
53
|
+
* baseUrl: 'https://api.example.com',
|
|
54
|
+
* timeout: 5000,
|
|
55
|
+
* retryAttempts: 3,
|
|
56
|
+
* endpoints: {
|
|
57
|
+
* users: '/users',
|
|
58
|
+
* products: '/products',
|
|
59
|
+
* orders: '/orders'
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* // Write to file system
|
|
65
|
+
* await Deno.writeTextFile(configFile.path, configFile.toString());
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example OpenAPI specification output
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const openApiFile = new JsonFile({
|
|
71
|
+
* path: './dist/openapi.json',
|
|
72
|
+
* content: {
|
|
73
|
+
* openapi: '3.0.0',
|
|
74
|
+
* info: {
|
|
75
|
+
* title: 'My API',
|
|
76
|
+
* version: '1.0.0'
|
|
77
|
+
* },
|
|
78
|
+
* paths: {
|
|
79
|
+
* '/users': {
|
|
80
|
+
* get: {
|
|
81
|
+
* summary: 'List users',
|
|
82
|
+
* responses: {
|
|
83
|
+
* '200': {
|
|
84
|
+
* description: 'Success'
|
|
85
|
+
* }
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
* }
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @example Using with generator registration
|
|
95
|
+
* ```typescript
|
|
96
|
+
* class MyGenerator extends ContentBase {
|
|
97
|
+
* generate() {
|
|
98
|
+
* const manifestFile = new JsonFile({
|
|
99
|
+
* path: './generated/manifest.json',
|
|
100
|
+
* content: {
|
|
101
|
+
* generatedAt: new Date().toISOString(),
|
|
102
|
+
* version: '1.0.0',
|
|
103
|
+
* files: [
|
|
104
|
+
* './models/User.ts',
|
|
105
|
+
* './models/Product.ts'
|
|
106
|
+
* ]
|
|
107
|
+
* }
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* // Register with the generation context
|
|
111
|
+
* this.register({ jsonFile: manifestFile });
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
4
116
|
class JsonFile {
|
|
117
|
+
/**
|
|
118
|
+
* Creates a new JsonFile instance.
|
|
119
|
+
*
|
|
120
|
+
* @param args - JSON file configuration
|
|
121
|
+
* @param args.path - The output path for this JSON file
|
|
122
|
+
* @param args.content - The JSON content to write
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const configFile = new JsonFile({
|
|
127
|
+
* path: './config/settings.json',
|
|
128
|
+
* content: {
|
|
129
|
+
* theme: 'dark',
|
|
130
|
+
* language: 'en',
|
|
131
|
+
* features: ['auth', 'notifications']
|
|
132
|
+
* }
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
5
136
|
constructor({ path, content }) {
|
|
137
|
+
/** The file type, always 'json' for JSON files */
|
|
6
138
|
Object.defineProperty(this, "fileType", {
|
|
7
139
|
enumerable: true,
|
|
8
140
|
configurable: true,
|
|
9
141
|
writable: true,
|
|
10
142
|
value: 'json'
|
|
11
143
|
});
|
|
144
|
+
/** The file path for this generated JSON file */
|
|
12
145
|
Object.defineProperty(this, "path", {
|
|
13
146
|
enumerable: true,
|
|
14
147
|
configurable: true,
|
|
15
148
|
writable: true,
|
|
16
149
|
value: void 0
|
|
17
150
|
});
|
|
151
|
+
/** The JSON content to write to the file */
|
|
18
152
|
Object.defineProperty(this, "content", {
|
|
19
153
|
enumerable: true,
|
|
20
154
|
configurable: true,
|
|
@@ -24,6 +158,29 @@ class JsonFile {
|
|
|
24
158
|
this.path = path;
|
|
25
159
|
this.content = content;
|
|
26
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Converts the JSON content to a formatted string.
|
|
163
|
+
*
|
|
164
|
+
* This method serializes the content object to JSON with 2-space indentation
|
|
165
|
+
* for readable output. The resulting string is suitable for writing directly
|
|
166
|
+
* to a file or including in the generation pipeline.
|
|
167
|
+
*
|
|
168
|
+
* @returns The formatted JSON content as a string
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* const file = new JsonFile({
|
|
173
|
+
* path: './data.json',
|
|
174
|
+
* content: { name: 'test', value: 42 }
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* console.log(file.toString());
|
|
178
|
+
* // {
|
|
179
|
+
* // "name": "test",
|
|
180
|
+
* // "value": 42
|
|
181
|
+
* // }
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
27
184
|
toString() {
|
|
28
185
|
return JSON.stringify(this.content, null, 2);
|
|
29
186
|
}
|
|
@@ -2,21 +2,129 @@ import "../../_dnt.polyfills.js";
|
|
|
2
2
|
import type { OasSchema, ToJsonSchemaOptions } from '../schema/Schema.js';
|
|
3
3
|
import type { OasRef } from '../ref/Ref.js';
|
|
4
4
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
5
|
+
/**
|
|
6
|
+
* Constructor fields for {@link OasArray}.
|
|
7
|
+
*
|
|
8
|
+
* @template Nullable - Whether the array value can be null
|
|
9
|
+
*/
|
|
5
10
|
export type ArrayFields<Nullable extends boolean | undefined> = {
|
|
11
|
+
/** Schema definition for array items */
|
|
6
12
|
items: OasSchema | OasRef<'schema'>;
|
|
13
|
+
/** A short summary of the array schema */
|
|
7
14
|
title?: string;
|
|
15
|
+
/** A description of the array schema */
|
|
8
16
|
description?: string;
|
|
17
|
+
/** Whether the array value can be null */
|
|
9
18
|
nullable?: Nullable;
|
|
19
|
+
/** Whether array items must be unique */
|
|
10
20
|
uniqueItems?: boolean;
|
|
21
|
+
/** Custom extension fields (x-* properties) */
|
|
11
22
|
extensionFields?: Record<string, unknown>;
|
|
23
|
+
/** Example array value */
|
|
12
24
|
example?: Nullable extends true ? unknown[] | null | undefined : unknown[] | undefined;
|
|
25
|
+
/** Maximum number of items allowed */
|
|
13
26
|
maxItems?: number;
|
|
27
|
+
/** Minimum number of items required */
|
|
14
28
|
minItems?: number;
|
|
29
|
+
/** Array of allowed enum values for the entire array */
|
|
15
30
|
enums?: Nullable extends true ? (unknown | null)[] | undefined : unknown[] | undefined;
|
|
31
|
+
/** Default value for the array */
|
|
16
32
|
defaultValue?: Nullable extends true ? unknown[] | null | undefined : unknown[] | undefined;
|
|
17
33
|
};
|
|
18
34
|
/**
|
|
19
|
-
*
|
|
35
|
+
* Represents an array schema in the OpenAPI Specification.
|
|
36
|
+
*
|
|
37
|
+
* `OasArray` handles array type definitions with comprehensive validation
|
|
38
|
+
* constraints including item count limits, uniqueness requirements, and
|
|
39
|
+
* item type specifications. It supports nested schemas and references
|
|
40
|
+
* for complex array structures.
|
|
41
|
+
*
|
|
42
|
+
* This class is used throughout the OAS processing pipeline to represent
|
|
43
|
+
* array fields in API schemas, including lists of objects, primitive arrays,
|
|
44
|
+
* and complex nested array structures.
|
|
45
|
+
*
|
|
46
|
+
* ## Key Features
|
|
47
|
+
*
|
|
48
|
+
* - **Item Type Definition**: Support for any schema type as array items
|
|
49
|
+
* - **Size Constraints**: Minimum and maximum item count validation
|
|
50
|
+
* - **Uniqueness Validation**: Ensure array items are unique (like Set behavior)
|
|
51
|
+
* - **Nested Schemas**: Support for complex nested array structures
|
|
52
|
+
* - **Reference Handling**: Seamless integration with schema references
|
|
53
|
+
* - **Nullable Support**: Type-safe nullable array handling
|
|
54
|
+
* - **JSON Schema**: Conversion to standard JSON Schema format
|
|
55
|
+
*
|
|
56
|
+
* @template Nullable - Whether the array value can be null
|
|
57
|
+
*
|
|
58
|
+
* @example String array
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { OasArray, OasString } from '@skmtc/core';
|
|
61
|
+
*
|
|
62
|
+
* const tagsArray = new OasArray({
|
|
63
|
+
* title: 'Tags',
|
|
64
|
+
* description: 'List of tags associated with the item',
|
|
65
|
+
* items: new OasString({ minLength: 1 }),
|
|
66
|
+
* minItems: 1,
|
|
67
|
+
* uniqueItems: true,
|
|
68
|
+
* example: ['javascript', 'typescript', 'react']
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example Object array with references
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import { OasArray, OasRef } from '@skmtc/core';
|
|
75
|
+
*
|
|
76
|
+
* const usersArray = new OasArray({
|
|
77
|
+
* title: 'Users',
|
|
78
|
+
* description: 'List of user objects',
|
|
79
|
+
* items: new OasRef({ refName: 'User' }),
|
|
80
|
+
* maxItems: 100,
|
|
81
|
+
* example: [
|
|
82
|
+
* { id: 1, name: 'John' },
|
|
83
|
+
* { id: 2, name: 'Jane' }
|
|
84
|
+
* ]
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @example Nested array (array of arrays)
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const matrixArray = new OasArray({
|
|
91
|
+
* title: 'Matrix',
|
|
92
|
+
* description: '2D array of numbers',
|
|
93
|
+
* items: new OasArray({
|
|
94
|
+
* items: new OasInteger({ minimum: 0 })
|
|
95
|
+
* }),
|
|
96
|
+
* example: [
|
|
97
|
+
* [1, 2, 3],
|
|
98
|
+
* [4, 5, 6],
|
|
99
|
+
* [7, 8, 9]
|
|
100
|
+
* ]
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @example Nullable array with constraints
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const optionalIdsArray = new OasArray<true>({
|
|
107
|
+
* title: 'Optional IDs',
|
|
108
|
+
* description: 'Optional list of IDs',
|
|
109
|
+
* items: new OasInteger({ format: 'int64', minimum: 1 }),
|
|
110
|
+
* nullable: true,
|
|
111
|
+
* minItems: 0,
|
|
112
|
+
* maxItems: 10,
|
|
113
|
+
* defaultValue: null
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @example Unique items validation
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const uniqueEmailsArray = new OasArray({
|
|
120
|
+
* title: 'Email Recipients',
|
|
121
|
+
* description: 'List of unique email addresses',
|
|
122
|
+
* items: new OasString({ format: 'email' }),
|
|
123
|
+
* uniqueItems: true, // Ensures no duplicate emails
|
|
124
|
+
* minItems: 1,
|
|
125
|
+
* example: ['user1@example.com', 'user2@example.com']
|
|
126
|
+
* });
|
|
127
|
+
* ```
|
|
20
128
|
*/
|
|
21
129
|
export declare class OasArray<Nullable extends boolean | undefined = boolean | undefined> {
|
|
22
130
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Array.d.ts","sourceRoot":"","sources":["../../../src/oas/array/Array.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,MAAM,MAAM,WAAW,CAAC,QAAQ,SAAS,OAAO,GAAG,SAAS,IAAI;IAC9D,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC,OAAO,CAAC,EAAE,QAAQ,SAAS,IAAI,GAAG,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,EAAE,GAAG,SAAS,CAAA;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,QAAQ,SAAS,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,GAAG,OAAO,EAAE,GAAG,SAAS,CAAA;IACtF,YAAY,CAAC,EAAE,QAAQ,SAAS,IAAI,GAAG,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,EAAE,GAAG,SAA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AAE,GAAG,SAAS,CAAA;gBAE9E,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC;IAczC,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC;IAI7B,WAAW,IAAI,QAAQ,CAAC,QAAQ,CAAC;IAIjC,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAC,iBAAiB;CAexE"}
|
|
@@ -3,7 +3,99 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OasArray = void 0;
|
|
4
4
|
require("../../_dnt.polyfills.js");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Represents an array schema in the OpenAPI Specification.
|
|
7
|
+
*
|
|
8
|
+
* `OasArray` handles array type definitions with comprehensive validation
|
|
9
|
+
* constraints including item count limits, uniqueness requirements, and
|
|
10
|
+
* item type specifications. It supports nested schemas and references
|
|
11
|
+
* for complex array structures.
|
|
12
|
+
*
|
|
13
|
+
* This class is used throughout the OAS processing pipeline to represent
|
|
14
|
+
* array fields in API schemas, including lists of objects, primitive arrays,
|
|
15
|
+
* and complex nested array structures.
|
|
16
|
+
*
|
|
17
|
+
* ## Key Features
|
|
18
|
+
*
|
|
19
|
+
* - **Item Type Definition**: Support for any schema type as array items
|
|
20
|
+
* - **Size Constraints**: Minimum and maximum item count validation
|
|
21
|
+
* - **Uniqueness Validation**: Ensure array items are unique (like Set behavior)
|
|
22
|
+
* - **Nested Schemas**: Support for complex nested array structures
|
|
23
|
+
* - **Reference Handling**: Seamless integration with schema references
|
|
24
|
+
* - **Nullable Support**: Type-safe nullable array handling
|
|
25
|
+
* - **JSON Schema**: Conversion to standard JSON Schema format
|
|
26
|
+
*
|
|
27
|
+
* @template Nullable - Whether the array value can be null
|
|
28
|
+
*
|
|
29
|
+
* @example String array
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { OasArray, OasString } from '@skmtc/core';
|
|
32
|
+
*
|
|
33
|
+
* const tagsArray = new OasArray({
|
|
34
|
+
* title: 'Tags',
|
|
35
|
+
* description: 'List of tags associated with the item',
|
|
36
|
+
* items: new OasString({ minLength: 1 }),
|
|
37
|
+
* minItems: 1,
|
|
38
|
+
* uniqueItems: true,
|
|
39
|
+
* example: ['javascript', 'typescript', 'react']
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example Object array with references
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { OasArray, OasRef } from '@skmtc/core';
|
|
46
|
+
*
|
|
47
|
+
* const usersArray = new OasArray({
|
|
48
|
+
* title: 'Users',
|
|
49
|
+
* description: 'List of user objects',
|
|
50
|
+
* items: new OasRef({ refName: 'User' }),
|
|
51
|
+
* maxItems: 100,
|
|
52
|
+
* example: [
|
|
53
|
+
* { id: 1, name: 'John' },
|
|
54
|
+
* { id: 2, name: 'Jane' }
|
|
55
|
+
* ]
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example Nested array (array of arrays)
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const matrixArray = new OasArray({
|
|
62
|
+
* title: 'Matrix',
|
|
63
|
+
* description: '2D array of numbers',
|
|
64
|
+
* items: new OasArray({
|
|
65
|
+
* items: new OasInteger({ minimum: 0 })
|
|
66
|
+
* }),
|
|
67
|
+
* example: [
|
|
68
|
+
* [1, 2, 3],
|
|
69
|
+
* [4, 5, 6],
|
|
70
|
+
* [7, 8, 9]
|
|
71
|
+
* ]
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example Nullable array with constraints
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const optionalIdsArray = new OasArray<true>({
|
|
78
|
+
* title: 'Optional IDs',
|
|
79
|
+
* description: 'Optional list of IDs',
|
|
80
|
+
* items: new OasInteger({ format: 'int64', minimum: 1 }),
|
|
81
|
+
* nullable: true,
|
|
82
|
+
* minItems: 0,
|
|
83
|
+
* maxItems: 10,
|
|
84
|
+
* defaultValue: null
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @example Unique items validation
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const uniqueEmailsArray = new OasArray({
|
|
91
|
+
* title: 'Email Recipients',
|
|
92
|
+
* description: 'List of unique email addresses',
|
|
93
|
+
* items: new OasString({ format: 'email' }),
|
|
94
|
+
* uniqueItems: true, // Ensures no duplicate emails
|
|
95
|
+
* minItems: 1,
|
|
96
|
+
* example: ['user1@example.com', 'user2@example.com']
|
|
97
|
+
* });
|
|
98
|
+
* ```
|
|
7
99
|
*/
|
|
8
100
|
class OasArray {
|
|
9
101
|
constructor(fields) {
|
|
@@ -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;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,MAAM,MAAM,aAAa,CAAC,QAAQ,SAAS,OAAO,GAAG,SAAS,IAAI;IAChE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAC1B,OAAO,CAAC,EAAE,QAAQ,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;IAChF,KAAK,CAAC,EAAE,QAAQ,SAAS,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC,OAAO,CAAC,EAAE,QAAQ,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;IAChF,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,qBAAa,UAAU,CAAC,QAAQ,SAAS,OAAO,GAAG,S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,GAAG,SAAS,CAAA;IACrC;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B;;OAEG;IACH,gBAAgB,EAAE,OAAO,GAAG,SAAS,CAAA;IACrC;;OAEG;IACH,OAAO,EAAE,QAAQ,SAAS,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;gBACnE,MAAM,GAAE,aAAa,CAAC,QAAQ,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
|
/**
|