@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
|
@@ -114,6 +114,101 @@ type GenerateResult = {
|
|
|
114
114
|
previews: Record<string, Record<string, Preview>>;
|
|
115
115
|
mappings: Record<string, Record<string, Mapping>>;
|
|
116
116
|
};
|
|
117
|
+
/**
|
|
118
|
+
* The generation context for the second phase of the SKMTC transformation pipeline.
|
|
119
|
+
*
|
|
120
|
+
* `GenerateContext` manages the transformation of parsed OAS (OpenAPI Schema) objects
|
|
121
|
+
* into code artifacts using pluggable generators. It provides APIs for model and operation
|
|
122
|
+
* generation, file management, dependency tracking, and artifact registration.
|
|
123
|
+
*
|
|
124
|
+
* ## Key Responsibilities
|
|
125
|
+
*
|
|
126
|
+
* - **Generator Orchestration**: Executes pluggable model and operation generators
|
|
127
|
+
* - **Schema Processing**: Provides utilities for working with OAS schemas and references
|
|
128
|
+
* - **File Management**: Handles file creation, imports, exports, and dependencies
|
|
129
|
+
* - **Artifact Registration**: Collects generated definitions and files for rendering
|
|
130
|
+
* - **Type System Integration**: Bridges OAS types with generator-specific type systems
|
|
131
|
+
* - **Settings Management**: Handles skipping logic and client customizations
|
|
132
|
+
*
|
|
133
|
+
* ## Generator Integration
|
|
134
|
+
*
|
|
135
|
+
* The context works with two main types of generators:
|
|
136
|
+
* - **Model Generators**: Transform schema definitions into type definitions
|
|
137
|
+
* - **Operation Generators**: Transform API operations into client functions
|
|
138
|
+
*
|
|
139
|
+
* @example Basic usage in a model generator
|
|
140
|
+
* ```typescript
|
|
141
|
+
* import { ModelBase } from '@skmtc/core';
|
|
142
|
+
*
|
|
143
|
+
* class TypeScriptInterface extends ModelBase {
|
|
144
|
+
* generate(): Definition {
|
|
145
|
+
* const schema = this.context.getSchema(this.refName);
|
|
146
|
+
*
|
|
147
|
+
* return new Definition({
|
|
148
|
+
* context: this.context,
|
|
149
|
+
* identifier: Identifier.createType(this.refName),
|
|
150
|
+
* description: schema.description,
|
|
151
|
+
* value: {
|
|
152
|
+
* generatorKey: this.generatorKey,
|
|
153
|
+
* content: this.generateInterfaceBody(schema)
|
|
154
|
+
* }
|
|
155
|
+
* });
|
|
156
|
+
* }
|
|
157
|
+
* }
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @example Operation generator usage
|
|
161
|
+
* ```typescript
|
|
162
|
+
* class ApiClientGenerator extends OperationBase {
|
|
163
|
+
* generate(): Definition {
|
|
164
|
+
* const operation = this.context.getOperation(this.path, this.method);
|
|
165
|
+
*
|
|
166
|
+
* const functionName = this.context.createOperationName(this.path, this.method);
|
|
167
|
+
*
|
|
168
|
+
* return new Definition({
|
|
169
|
+
* context: this.context,
|
|
170
|
+
* identifier: Identifier.createVariable(functionName),
|
|
171
|
+
* value: {
|
|
172
|
+
* generatorKey: this.generatorKey,
|
|
173
|
+
* content: this.generateClientFunction(operation)
|
|
174
|
+
* }
|
|
175
|
+
* });
|
|
176
|
+
* }
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @example Schema and type system integration
|
|
181
|
+
* ```typescript
|
|
182
|
+
* class MyGenerator extends ModelBase {
|
|
183
|
+
* generate(): Definition {
|
|
184
|
+
* const schema = this.context.getSchema(this.refName);
|
|
185
|
+
*
|
|
186
|
+
* // Transform schema using type system
|
|
187
|
+
* const typeOutput = this.context.transformSchema(schema, {
|
|
188
|
+
* stringType: 'string',
|
|
189
|
+
* numberType: 'number',
|
|
190
|
+
* arrayType: (items) => `Array<${items}>`
|
|
191
|
+
* });
|
|
192
|
+
*
|
|
193
|
+
* // Register dependencies
|
|
194
|
+
* if (schema.hasReferences()) {
|
|
195
|
+
* this.context.addImportsToFile('./models/types.ts', {
|
|
196
|
+
* './common': ['BaseModel']
|
|
197
|
+
* });
|
|
198
|
+
* }
|
|
199
|
+
*
|
|
200
|
+
* return new Definition({
|
|
201
|
+
* context: this.context,
|
|
202
|
+
* identifier: Identifier.createType(this.refName),
|
|
203
|
+
* value: {
|
|
204
|
+
* generatorKey: this.generatorKey,
|
|
205
|
+
* content: typeOutput.content
|
|
206
|
+
* }
|
|
207
|
+
* });
|
|
208
|
+
* }
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
117
212
|
export declare class GenerateContext {
|
|
118
213
|
#private;
|
|
119
214
|
oasDocument: OasDocument;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateContext.d.ts","sourceRoot":"","sources":["../../src/context/GenerateContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD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A;AAEF,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,0BAA0B,iBAAiB,KAAG,WAI1E,CAAA"}
|
|
@@ -23,6 +23,101 @@ import { File } from '../dsl/File.js';
|
|
|
23
23
|
import { JsonFile } from '../dsl/JsonFile.js';
|
|
24
24
|
import invariant from 'tiny-invariant';
|
|
25
25
|
import { match } from 'ts-pattern';
|
|
26
|
+
/**
|
|
27
|
+
* The generation context for the second phase of the SKMTC transformation pipeline.
|
|
28
|
+
*
|
|
29
|
+
* `GenerateContext` manages the transformation of parsed OAS (OpenAPI Schema) objects
|
|
30
|
+
* into code artifacts using pluggable generators. It provides APIs for model and operation
|
|
31
|
+
* generation, file management, dependency tracking, and artifact registration.
|
|
32
|
+
*
|
|
33
|
+
* ## Key Responsibilities
|
|
34
|
+
*
|
|
35
|
+
* - **Generator Orchestration**: Executes pluggable model and operation generators
|
|
36
|
+
* - **Schema Processing**: Provides utilities for working with OAS schemas and references
|
|
37
|
+
* - **File Management**: Handles file creation, imports, exports, and dependencies
|
|
38
|
+
* - **Artifact Registration**: Collects generated definitions and files for rendering
|
|
39
|
+
* - **Type System Integration**: Bridges OAS types with generator-specific type systems
|
|
40
|
+
* - **Settings Management**: Handles skipping logic and client customizations
|
|
41
|
+
*
|
|
42
|
+
* ## Generator Integration
|
|
43
|
+
*
|
|
44
|
+
* The context works with two main types of generators:
|
|
45
|
+
* - **Model Generators**: Transform schema definitions into type definitions
|
|
46
|
+
* - **Operation Generators**: Transform API operations into client functions
|
|
47
|
+
*
|
|
48
|
+
* @example Basic usage in a model generator
|
|
49
|
+
* ```typescript
|
|
50
|
+
* import { ModelBase } from '@skmtc/core';
|
|
51
|
+
*
|
|
52
|
+
* class TypeScriptInterface extends ModelBase {
|
|
53
|
+
* generate(): Definition {
|
|
54
|
+
* const schema = this.context.getSchema(this.refName);
|
|
55
|
+
*
|
|
56
|
+
* return new Definition({
|
|
57
|
+
* context: this.context,
|
|
58
|
+
* identifier: Identifier.createType(this.refName),
|
|
59
|
+
* description: schema.description,
|
|
60
|
+
* value: {
|
|
61
|
+
* generatorKey: this.generatorKey,
|
|
62
|
+
* content: this.generateInterfaceBody(schema)
|
|
63
|
+
* }
|
|
64
|
+
* });
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example Operation generator usage
|
|
70
|
+
* ```typescript
|
|
71
|
+
* class ApiClientGenerator extends OperationBase {
|
|
72
|
+
* generate(): Definition {
|
|
73
|
+
* const operation = this.context.getOperation(this.path, this.method);
|
|
74
|
+
*
|
|
75
|
+
* const functionName = this.context.createOperationName(this.path, this.method);
|
|
76
|
+
*
|
|
77
|
+
* return new Definition({
|
|
78
|
+
* context: this.context,
|
|
79
|
+
* identifier: Identifier.createVariable(functionName),
|
|
80
|
+
* value: {
|
|
81
|
+
* generatorKey: this.generatorKey,
|
|
82
|
+
* content: this.generateClientFunction(operation)
|
|
83
|
+
* }
|
|
84
|
+
* });
|
|
85
|
+
* }
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @example Schema and type system integration
|
|
90
|
+
* ```typescript
|
|
91
|
+
* class MyGenerator extends ModelBase {
|
|
92
|
+
* generate(): Definition {
|
|
93
|
+
* const schema = this.context.getSchema(this.refName);
|
|
94
|
+
*
|
|
95
|
+
* // Transform schema using type system
|
|
96
|
+
* const typeOutput = this.context.transformSchema(schema, {
|
|
97
|
+
* stringType: 'string',
|
|
98
|
+
* numberType: 'number',
|
|
99
|
+
* arrayType: (items) => `Array<${items}>`
|
|
100
|
+
* });
|
|
101
|
+
*
|
|
102
|
+
* // Register dependencies
|
|
103
|
+
* if (schema.hasReferences()) {
|
|
104
|
+
* this.context.addImportsToFile('./models/types.ts', {
|
|
105
|
+
* './common': ['BaseModel']
|
|
106
|
+
* });
|
|
107
|
+
* }
|
|
108
|
+
*
|
|
109
|
+
* return new Definition({
|
|
110
|
+
* context: this.context,
|
|
111
|
+
* identifier: Identifier.createType(this.refName),
|
|
112
|
+
* value: {
|
|
113
|
+
* generatorKey: this.generatorKey,
|
|
114
|
+
* content: typeOutput.content
|
|
115
|
+
* }
|
|
116
|
+
* });
|
|
117
|
+
* }
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
26
121
|
export class GenerateContext {
|
|
27
122
|
constructor({ oasDocument, settings, logger, captureCurrentResult, stackTrail, toGeneratorConfigMap }) {
|
|
28
123
|
_GenerateContext_instances.add(this);
|
|
@@ -1,18 +1,182 @@
|
|
|
1
1
|
import type { Identifier } from './Identifier.js';
|
|
2
|
+
/**
|
|
3
|
+
* Arguments for creating empty ContentSettings without enrichments.
|
|
4
|
+
*/
|
|
2
5
|
type EmptyArgs = {
|
|
6
|
+
/** The path where generated content will be exported */
|
|
3
7
|
exportPath: string;
|
|
8
|
+
/** The identifier for the content being generated */
|
|
4
9
|
identifier: Identifier;
|
|
5
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Arguments for creating ContentSettings with enrichments.
|
|
13
|
+
*
|
|
14
|
+
* @template EnrichmentType - The type of enrichment data
|
|
15
|
+
*/
|
|
6
16
|
type CreateArgs<EnrichmentType = undefined> = {
|
|
17
|
+
/** The identifier for the content being generated */
|
|
7
18
|
identifier: Identifier;
|
|
19
|
+
/** The path where generated content will be exported */
|
|
8
20
|
exportPath: string;
|
|
21
|
+
/** Custom enrichment data for extending generation */
|
|
9
22
|
enrichments: EnrichmentType;
|
|
10
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Configuration settings for content generators in the SKMTC DSL system.
|
|
26
|
+
*
|
|
27
|
+
* `ContentSettings` encapsulates the configuration needed by generators to
|
|
28
|
+
* produce content, including where to export the generated files, how to
|
|
29
|
+
* identify the content, and any custom enrichment data for extending
|
|
30
|
+
* the generation process.
|
|
31
|
+
*
|
|
32
|
+
* This class is used by both {@link ModelBase} and {@link OperationBase}
|
|
33
|
+
* to configure their generation behavior, providing a consistent interface
|
|
34
|
+
* for generator settings across the system.
|
|
35
|
+
*
|
|
36
|
+
* ## Key Features
|
|
37
|
+
*
|
|
38
|
+
* - **Export Path Management**: Specifies where generated content should be written
|
|
39
|
+
* - **Identifier Integration**: Links content to specific identifiers for naming
|
|
40
|
+
* - **Enrichment Support**: Allows custom data to extend generation capabilities
|
|
41
|
+
* - **Type Safety**: Generic enrichment typing for compile-time validation
|
|
42
|
+
*
|
|
43
|
+
* @template EnrichmentType - The type of enrichment data (default: undefined)
|
|
44
|
+
*
|
|
45
|
+
* @example Basic settings without enrichments
|
|
46
|
+
* ```typescript
|
|
47
|
+
* import { ContentSettings, Identifier } from '@skmtc/core';
|
|
48
|
+
*
|
|
49
|
+
* const settings = ContentSettings.empty({
|
|
50
|
+
* exportPath: './src/generated/models.ts',
|
|
51
|
+
* identifier: Identifier.createType('UserModels')
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* console.log(settings.exportPath); // './src/generated/models.ts'
|
|
55
|
+
* console.log(settings.enrichments); // undefined
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example Settings with custom enrichments
|
|
59
|
+
* ```typescript
|
|
60
|
+
* type ValidationEnrichment = {
|
|
61
|
+
* validateRequired: boolean;
|
|
62
|
+
* generateComments: boolean;
|
|
63
|
+
* customValidators: string[];
|
|
64
|
+
* };
|
|
65
|
+
*
|
|
66
|
+
* const enrichedSettings = new ContentSettings({
|
|
67
|
+
* identifier: Identifier.createType('ValidatedModels'),
|
|
68
|
+
* exportPath: './src/models/validated.ts',
|
|
69
|
+
* enrichments: {
|
|
70
|
+
* validateRequired: true,
|
|
71
|
+
* generateComments: true,
|
|
72
|
+
* customValidators: ['email', 'phone']
|
|
73
|
+
* }
|
|
74
|
+
* });
|
|
75
|
+
*
|
|
76
|
+
* // Access enrichment data in generators
|
|
77
|
+
* if (enrichedSettings.enrichments?.validateRequired) {
|
|
78
|
+
* // Generate validation logic
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example Using with ModelBase
|
|
83
|
+
* ```typescript
|
|
84
|
+
* class ValidatedModelGenerator extends ModelBase<ValidationEnrichment> {
|
|
85
|
+
* constructor(args) {
|
|
86
|
+
* super({
|
|
87
|
+
* ...args,
|
|
88
|
+
* settings: new ContentSettings({
|
|
89
|
+
* identifier: Identifier.createType(args.refName),
|
|
90
|
+
* exportPath: './src/validated-models.ts',
|
|
91
|
+
* enrichments: {
|
|
92
|
+
* validateRequired: true,
|
|
93
|
+
* generateComments: false,
|
|
94
|
+
* customValidators: []
|
|
95
|
+
* }
|
|
96
|
+
* })
|
|
97
|
+
* });
|
|
98
|
+
* }
|
|
99
|
+
*
|
|
100
|
+
* toDefinition(): Definition {
|
|
101
|
+
* const validation = this.settings.enrichments?.validateRequired
|
|
102
|
+
* ? this.generateValidation()
|
|
103
|
+
* : '';
|
|
104
|
+
*
|
|
105
|
+
* return new Definition({
|
|
106
|
+
* context: this.context,
|
|
107
|
+
* identifier: this.settings.identifier,
|
|
108
|
+
* value: {
|
|
109
|
+
* generatorKey: this.generatorKey,
|
|
110
|
+
* content: `${this.generateInterface()}${validation}`
|
|
111
|
+
* }
|
|
112
|
+
* });
|
|
113
|
+
* }
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
11
117
|
export declare class ContentSettings<EnrichmentType = undefined> {
|
|
118
|
+
/** The identifier for the content being generated */
|
|
12
119
|
identifier: Identifier;
|
|
120
|
+
/** The path where generated content will be exported */
|
|
13
121
|
exportPath: string;
|
|
122
|
+
/** Custom enrichment data for extending generation */
|
|
14
123
|
enrichments: EnrichmentType;
|
|
124
|
+
/**
|
|
125
|
+
* Creates a new ContentSettings instance with enrichments.
|
|
126
|
+
*
|
|
127
|
+
* @param args - Settings configuration
|
|
128
|
+
* @param args.identifier - The identifier for the content being generated
|
|
129
|
+
* @param args.exportPath - The path where generated content will be exported
|
|
130
|
+
* @param args.enrichments - Custom enrichment data for extending generation
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* const settings = new ContentSettings({
|
|
135
|
+
* identifier: Identifier.createType('ApiModels'),
|
|
136
|
+
* exportPath: './src/api/models.ts',
|
|
137
|
+
* enrichments: {
|
|
138
|
+
* includeValidation: true,
|
|
139
|
+
* format: 'detailed'
|
|
140
|
+
* }
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
15
144
|
constructor({ identifier, exportPath, enrichments }: CreateArgs<EnrichmentType>);
|
|
145
|
+
/**
|
|
146
|
+
* Factory method to create ContentSettings without enrichments.
|
|
147
|
+
*
|
|
148
|
+
* This is a convenience method for creating ContentSettings when no
|
|
149
|
+
* custom enrichment data is needed. It explicitly sets enrichments
|
|
150
|
+
* to undefined and returns a properly typed instance.
|
|
151
|
+
*
|
|
152
|
+
* @param args - Basic settings arguments
|
|
153
|
+
* @param args.identifier - The identifier for the content being generated
|
|
154
|
+
* @param args.exportPath - The path where generated content will be exported
|
|
155
|
+
* @returns ContentSettings instance with undefined enrichments
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const basicSettings = ContentSettings.empty({
|
|
160
|
+
* identifier: Identifier.createType('SimpleModels'),
|
|
161
|
+
* exportPath: './src/models.ts'
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* console.log(basicSettings.enrichments); // undefined
|
|
165
|
+
*
|
|
166
|
+
* // Use in generator
|
|
167
|
+
* class SimpleGenerator extends ModelBase {
|
|
168
|
+
* constructor(args) {
|
|
169
|
+
* super({
|
|
170
|
+
* ...args,
|
|
171
|
+
* settings: ContentSettings.empty({
|
|
172
|
+
* identifier: Identifier.createType(args.refName),
|
|
173
|
+
* exportPath: './src/simple-models.ts'
|
|
174
|
+
* })
|
|
175
|
+
* });
|
|
176
|
+
* }
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
16
180
|
static empty({ identifier, exportPath }: EmptyArgs): ContentSettings<undefined>;
|
|
17
181
|
}
|
|
18
182
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSettings.d.ts","sourceRoot":"","sources":["../../src/dsl/ContentSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,KAAK,SAAS,GAAG;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,KAAK,UAAU,CAAC,cAAc,GAAG,SAAS,IAAI;IAC5C,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,cAAc,CAAA;CAC5B,CAAA;AAED,qBAAa,eAAe,CAAC,cAAc,GAAG,SAAS;IACrD,UAAU,EAAE,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"ContentSettings.d.ts","sourceRoot":"","sources":["../../src/dsl/ContentSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;GAEG;AACH,KAAK,SAAS,GAAG;IACf,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAA;IAClB,qDAAqD;IACrD,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED;;;;GAIG;AACH,KAAK,UAAU,CAAC,cAAc,GAAG,SAAS,IAAI;IAC5C,qDAAqD;IACrD,UAAU,EAAE,UAAU,CAAA;IACtB,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAA;IAClB,sDAAsD;IACtD,WAAW,EAAE,cAAc,CAAA;CAC5B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AACH,qBAAa,eAAe,CAAC,cAAc,GAAG,SAAS;IACrD,qDAAqD;IACrD,UAAU,EAAE,UAAU,CAAA;IAEtB,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAA;IAElB,sDAAsD;IACtD,WAAW,EAAE,cAAc,CAAA;IAE3B;;;;;;;;;;;;;;;;;;;OAmBG;gBACS,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,UAAU,CAAC,cAAc,CAAC;IAM/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,MAAM,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC;CAOhF"}
|
|
@@ -1,17 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration settings for content generators in the SKMTC DSL system.
|
|
3
|
+
*
|
|
4
|
+
* `ContentSettings` encapsulates the configuration needed by generators to
|
|
5
|
+
* produce content, including where to export the generated files, how to
|
|
6
|
+
* identify the content, and any custom enrichment data for extending
|
|
7
|
+
* the generation process.
|
|
8
|
+
*
|
|
9
|
+
* This class is used by both {@link ModelBase} and {@link OperationBase}
|
|
10
|
+
* to configure their generation behavior, providing a consistent interface
|
|
11
|
+
* for generator settings across the system.
|
|
12
|
+
*
|
|
13
|
+
* ## Key Features
|
|
14
|
+
*
|
|
15
|
+
* - **Export Path Management**: Specifies where generated content should be written
|
|
16
|
+
* - **Identifier Integration**: Links content to specific identifiers for naming
|
|
17
|
+
* - **Enrichment Support**: Allows custom data to extend generation capabilities
|
|
18
|
+
* - **Type Safety**: Generic enrichment typing for compile-time validation
|
|
19
|
+
*
|
|
20
|
+
* @template EnrichmentType - The type of enrichment data (default: undefined)
|
|
21
|
+
*
|
|
22
|
+
* @example Basic settings without enrichments
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { ContentSettings, Identifier } from '@skmtc/core';
|
|
25
|
+
*
|
|
26
|
+
* const settings = ContentSettings.empty({
|
|
27
|
+
* exportPath: './src/generated/models.ts',
|
|
28
|
+
* identifier: Identifier.createType('UserModels')
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* console.log(settings.exportPath); // './src/generated/models.ts'
|
|
32
|
+
* console.log(settings.enrichments); // undefined
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Settings with custom enrichments
|
|
36
|
+
* ```typescript
|
|
37
|
+
* type ValidationEnrichment = {
|
|
38
|
+
* validateRequired: boolean;
|
|
39
|
+
* generateComments: boolean;
|
|
40
|
+
* customValidators: string[];
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* const enrichedSettings = new ContentSettings({
|
|
44
|
+
* identifier: Identifier.createType('ValidatedModels'),
|
|
45
|
+
* exportPath: './src/models/validated.ts',
|
|
46
|
+
* enrichments: {
|
|
47
|
+
* validateRequired: true,
|
|
48
|
+
* generateComments: true,
|
|
49
|
+
* customValidators: ['email', 'phone']
|
|
50
|
+
* }
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // Access enrichment data in generators
|
|
54
|
+
* if (enrichedSettings.enrichments?.validateRequired) {
|
|
55
|
+
* // Generate validation logic
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example Using with ModelBase
|
|
60
|
+
* ```typescript
|
|
61
|
+
* class ValidatedModelGenerator extends ModelBase<ValidationEnrichment> {
|
|
62
|
+
* constructor(args) {
|
|
63
|
+
* super({
|
|
64
|
+
* ...args,
|
|
65
|
+
* settings: new ContentSettings({
|
|
66
|
+
* identifier: Identifier.createType(args.refName),
|
|
67
|
+
* exportPath: './src/validated-models.ts',
|
|
68
|
+
* enrichments: {
|
|
69
|
+
* validateRequired: true,
|
|
70
|
+
* generateComments: false,
|
|
71
|
+
* customValidators: []
|
|
72
|
+
* }
|
|
73
|
+
* })
|
|
74
|
+
* });
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* toDefinition(): Definition {
|
|
78
|
+
* const validation = this.settings.enrichments?.validateRequired
|
|
79
|
+
* ? this.generateValidation()
|
|
80
|
+
* : '';
|
|
81
|
+
*
|
|
82
|
+
* return new Definition({
|
|
83
|
+
* context: this.context,
|
|
84
|
+
* identifier: this.settings.identifier,
|
|
85
|
+
* value: {
|
|
86
|
+
* generatorKey: this.generatorKey,
|
|
87
|
+
* content: `${this.generateInterface()}${validation}`
|
|
88
|
+
* }
|
|
89
|
+
* });
|
|
90
|
+
* }
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
1
94
|
export class ContentSettings {
|
|
95
|
+
/**
|
|
96
|
+
* Creates a new ContentSettings instance with enrichments.
|
|
97
|
+
*
|
|
98
|
+
* @param args - Settings configuration
|
|
99
|
+
* @param args.identifier - The identifier for the content being generated
|
|
100
|
+
* @param args.exportPath - The path where generated content will be exported
|
|
101
|
+
* @param args.enrichments - Custom enrichment data for extending generation
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const settings = new ContentSettings({
|
|
106
|
+
* identifier: Identifier.createType('ApiModels'),
|
|
107
|
+
* exportPath: './src/api/models.ts',
|
|
108
|
+
* enrichments: {
|
|
109
|
+
* includeValidation: true,
|
|
110
|
+
* format: 'detailed'
|
|
111
|
+
* }
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
2
115
|
constructor({ identifier, exportPath, enrichments }) {
|
|
116
|
+
/** The identifier for the content being generated */
|
|
3
117
|
Object.defineProperty(this, "identifier", {
|
|
4
118
|
enumerable: true,
|
|
5
119
|
configurable: true,
|
|
6
120
|
writable: true,
|
|
7
121
|
value: void 0
|
|
8
122
|
});
|
|
123
|
+
/** The path where generated content will be exported */
|
|
9
124
|
Object.defineProperty(this, "exportPath", {
|
|
10
125
|
enumerable: true,
|
|
11
126
|
configurable: true,
|
|
12
127
|
writable: true,
|
|
13
128
|
value: void 0
|
|
14
129
|
});
|
|
130
|
+
/** Custom enrichment data for extending generation */
|
|
15
131
|
Object.defineProperty(this, "enrichments", {
|
|
16
132
|
enumerable: true,
|
|
17
133
|
configurable: true,
|
|
@@ -22,6 +138,41 @@ export class ContentSettings {
|
|
|
22
138
|
this.exportPath = exportPath;
|
|
23
139
|
this.enrichments = enrichments;
|
|
24
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Factory method to create ContentSettings without enrichments.
|
|
143
|
+
*
|
|
144
|
+
* This is a convenience method for creating ContentSettings when no
|
|
145
|
+
* custom enrichment data is needed. It explicitly sets enrichments
|
|
146
|
+
* to undefined and returns a properly typed instance.
|
|
147
|
+
*
|
|
148
|
+
* @param args - Basic settings arguments
|
|
149
|
+
* @param args.identifier - The identifier for the content being generated
|
|
150
|
+
* @param args.exportPath - The path where generated content will be exported
|
|
151
|
+
* @returns ContentSettings instance with undefined enrichments
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const basicSettings = ContentSettings.empty({
|
|
156
|
+
* identifier: Identifier.createType('SimpleModels'),
|
|
157
|
+
* exportPath: './src/models.ts'
|
|
158
|
+
* });
|
|
159
|
+
*
|
|
160
|
+
* console.log(basicSettings.enrichments); // undefined
|
|
161
|
+
*
|
|
162
|
+
* // Use in generator
|
|
163
|
+
* class SimpleGenerator extends ModelBase {
|
|
164
|
+
* constructor(args) {
|
|
165
|
+
* super({
|
|
166
|
+
* ...args,
|
|
167
|
+
* settings: ContentSettings.empty({
|
|
168
|
+
* identifier: Identifier.createType(args.refName),
|
|
169
|
+
* exportPath: './src/simple-models.ts'
|
|
170
|
+
* })
|
|
171
|
+
* });
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
25
176
|
static empty({ identifier, exportPath }) {
|
|
26
177
|
return new ContentSettings({
|
|
27
178
|
identifier,
|