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