@skmtc/core 0.0.799 → 0.0.802
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/CoreContext.d.ts +0 -3
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +12 -17
- package/esm/context/GenerateContext.d.ts +35 -3
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +21 -1
- package/esm/context/ParseContext.d.ts +64 -3
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +61 -0
- package/esm/context/RenderContext.d.ts +151 -2
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +185 -11
- package/esm/context/ResultsHandler.d.ts +10 -3
- package/esm/context/ResultsHandler.d.ts.map +1 -1
- package/esm/context/types.d.ts +30 -0
- package/esm/context/types.d.ts.map +1 -1
- package/esm/dsl/model/ModelBase.d.ts +1 -1
- package/esm/dsl/model/ModelBase.d.ts.map +1 -1
- package/esm/dsl/model/ModelDriver.d.ts +62 -0
- package/esm/dsl/model/ModelDriver.d.ts.map +1 -1
- package/esm/dsl/model/ModelDriver.js +63 -1
- package/esm/dsl/model/toModelBase.d.ts +66 -0
- package/esm/dsl/model/toModelBase.d.ts.map +1 -1
- package/esm/dsl/model/toModelBase.js +46 -0
- package/esm/dsl/model/toModelEntry.d.ts +63 -0
- package/esm/dsl/model/toModelEntry.d.ts.map +1 -1
- package/esm/dsl/model/toModelEntry.js +63 -0
- package/esm/dsl/model/types.d.ts +51 -4
- package/esm/dsl/model/types.d.ts.map +1 -1
- package/esm/dsl/operation/OperationBase.d.ts +3 -3
- package/esm/dsl/operation/OperationBase.d.ts.map +1 -1
- package/esm/dsl/operation/OperationDriver.d.ts +48 -0
- package/esm/dsl/operation/OperationDriver.d.ts.map +1 -1
- package/esm/dsl/operation/OperationDriver.js +49 -1
- package/esm/dsl/operation/types.d.ts +61 -3
- package/esm/dsl/operation/types.d.ts.map +1 -1
- package/esm/helpers/isEmpty.d.ts +1 -1
- package/esm/helpers/isEmpty.d.ts.map +1 -1
- package/esm/helpers/tracer.d.ts +1 -1
- package/esm/helpers/tracer.d.ts.map +1 -1
- package/esm/helpers/tracer.js +1 -1
- package/esm/mod.d.ts +51 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +51 -0
- package/esm/oas/array/array-types.d.ts +20 -11
- package/esm/oas/array/array-types.d.ts.map +1 -1
- package/esm/oas/array/array-types.js +10 -0
- package/esm/oas/array/toArray.d.ts +111 -0
- package/esm/oas/array/toArray.d.ts.map +1 -1
- package/esm/oas/array/toArray.js +115 -3
- package/esm/oas/boolean/boolean-types.d.ts +1 -7
- package/esm/oas/boolean/boolean-types.d.ts.map +1 -1
- package/esm/oas/components/components-types.d.ts +19 -0
- package/esm/oas/components/components-types.d.ts.map +1 -0
- package/esm/oas/components/components-types.js +21 -0
- package/esm/oas/contact/contact-types.d.ts +9 -0
- package/esm/oas/contact/contact-types.d.ts.map +1 -0
- package/esm/oas/contact/contact-types.js +7 -0
- package/esm/oas/discriminator/discriminator-types.d.ts +1 -5
- package/esm/oas/discriminator/discriminator-types.d.ts.map +1 -1
- package/esm/oas/document/document-types.d.ts +16 -0
- package/esm/oas/document/document-types.d.ts.map +1 -0
- package/esm/oas/document/document-types.js +18 -0
- package/esm/oas/example/example-types.d.ts +1 -6
- package/esm/oas/example/example-types.d.ts.map +1 -1
- package/esm/oas/header/header-types.d.ts +50 -0
- package/esm/oas/header/header-types.d.ts.map +1 -0
- package/esm/oas/header/header-types.js +30 -0
- package/esm/oas/info/info-types.d.ts +14 -0
- package/esm/oas/info/info-types.d.ts.map +1 -0
- package/esm/oas/info/info-types.js +13 -0
- package/esm/oas/integer/integer-types.d.ts +3 -17
- package/esm/oas/integer/integer-types.d.ts.map +1 -1
- package/esm/oas/license/license-types.d.ts +9 -0
- package/esm/oas/license/license-types.d.ts.map +1 -0
- package/esm/oas/license/license-types.js +7 -0
- package/esm/oas/mediaType/mediaType-types.d.ts +1 -11
- package/esm/oas/mediaType/mediaType-types.d.ts.map +1 -1
- package/esm/oas/number/number-types.d.ts +2 -16
- package/esm/oas/number/number-types.d.ts.map +1 -1
- package/esm/oas/operation/Operation.d.ts +47 -2
- package/esm/oas/operation/Operation.d.ts.map +1 -1
- package/esm/oas/operation/Operation.js +43 -0
- package/esm/oas/operation/operation-types.d.ts +22 -0
- package/esm/oas/operation/operation-types.d.ts.map +1 -0
- package/esm/oas/operation/operation-types.js +35 -0
- package/esm/oas/parameter/parameter-types.d.ts +3 -58
- package/esm/oas/parameter/parameter-types.d.ts.map +1 -1
- package/esm/oas/pathItem/pathItem-types.d.ts +12 -0
- package/esm/oas/pathItem/pathItem-types.d.ts.map +1 -0
- package/esm/oas/pathItem/pathItem-types.js +12 -0
- package/esm/oas/ref/Ref.d.ts +49 -2
- package/esm/oas/ref/Ref.d.ts.map +1 -1
- package/esm/oas/ref/Ref.js +28 -0
- package/esm/oas/requestBody/requestBody-types.d.ts +10 -0
- package/esm/oas/requestBody/requestBody-types.d.ts.map +1 -0
- package/esm/oas/requestBody/requestBody-types.js +9 -0
- package/esm/oas/response/response-types.d.ts +12 -0
- package/esm/oas/response/response-types.d.ts.map +1 -0
- package/esm/oas/response/response-types.js +11 -0
- package/esm/oas/schema/toSchemasV3.js +2 -2
- package/esm/oas/server/toServerV3.d.ts.map +1 -1
- package/esm/oas/string/string-types.d.ts +2 -29
- package/esm/oas/string/string-types.d.ts.map +1 -1
- package/esm/oas/string/toString.d.ts +125 -1
- package/esm/oas/string/toString.d.ts.map +1 -1
- package/esm/oas/string/toString.js +119 -0
- package/esm/oas/tag/tag-types.d.ts +8 -0
- package/esm/oas/tag/tag-types.d.ts.map +1 -0
- package/esm/oas/tag/tag-types.js +8 -0
- package/esm/oas/union/union-types.d.ts +1 -12
- package/esm/oas/union/union-types.d.ts.map +1 -1
- package/esm/oas/unknown/unknown-types.d.ts +1 -7
- package/esm/oas/unknown/unknown-types.d.ts.map +1 -1
- package/esm/types/Preview.d.ts +37 -0
- package/esm/types/Preview.d.ts.map +1 -1
- package/esm/types/Preview.js +37 -0
- package/esm/types/Settings.d.ts +35 -0
- package/esm/types/Settings.d.ts.map +1 -1
- package/esm/types/Settings.js +27 -0
- package/esm/typescript/FunctionParameter.d.ts +4 -4
- package/esm/typescript/FunctionParameter.d.ts.map +1 -1
- package/esm/typescript/List.d.ts +104 -5
- package/esm/typescript/List.d.ts.map +1 -1
- package/esm/typescript/List.js +75 -0
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +0 -3
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +12 -17
- package/script/context/GenerateContext.d.ts +35 -3
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +21 -1
- package/script/context/ParseContext.d.ts +64 -3
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +61 -0
- package/script/context/RenderContext.d.ts +151 -2
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +185 -11
- package/script/context/ResultsHandler.d.ts +10 -3
- package/script/context/ResultsHandler.d.ts.map +1 -1
- package/script/context/types.d.ts +30 -0
- package/script/context/types.d.ts.map +1 -1
- package/script/dsl/model/ModelBase.d.ts +1 -1
- package/script/dsl/model/ModelBase.d.ts.map +1 -1
- package/script/dsl/model/ModelDriver.d.ts +62 -0
- package/script/dsl/model/ModelDriver.d.ts.map +1 -1
- package/script/dsl/model/ModelDriver.js +63 -1
- package/script/dsl/model/toModelBase.d.ts +66 -0
- package/script/dsl/model/toModelBase.d.ts.map +1 -1
- package/script/dsl/model/toModelBase.js +46 -0
- package/script/dsl/model/toModelEntry.d.ts +63 -0
- package/script/dsl/model/toModelEntry.d.ts.map +1 -1
- package/script/dsl/model/toModelEntry.js +63 -0
- package/script/dsl/model/types.d.ts +51 -4
- package/script/dsl/model/types.d.ts.map +1 -1
- package/script/dsl/operation/OperationBase.d.ts +3 -3
- package/script/dsl/operation/OperationBase.d.ts.map +1 -1
- package/script/dsl/operation/OperationDriver.d.ts +48 -0
- package/script/dsl/operation/OperationDriver.d.ts.map +1 -1
- package/script/dsl/operation/OperationDriver.js +49 -1
- package/script/dsl/operation/types.d.ts +61 -3
- package/script/dsl/operation/types.d.ts.map +1 -1
- package/script/helpers/isEmpty.d.ts +1 -1
- package/script/helpers/isEmpty.d.ts.map +1 -1
- package/script/helpers/tracer.d.ts +1 -1
- package/script/helpers/tracer.d.ts.map +1 -1
- package/script/helpers/tracer.js +1 -1
- package/script/mod.d.ts +51 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +51 -0
- package/script/oas/array/array-types.d.ts +20 -11
- package/script/oas/array/array-types.d.ts.map +1 -1
- package/script/oas/array/array-types.js +11 -1
- package/script/oas/array/toArray.d.ts +111 -0
- package/script/oas/array/toArray.d.ts.map +1 -1
- package/script/oas/array/toArray.js +114 -2
- package/script/oas/boolean/boolean-types.d.ts +1 -7
- package/script/oas/boolean/boolean-types.d.ts.map +1 -1
- package/script/oas/components/components-types.d.ts +19 -0
- package/script/oas/components/components-types.d.ts.map +1 -0
- package/script/oas/components/components-types.js +57 -0
- package/script/oas/contact/contact-types.d.ts +9 -0
- package/script/oas/contact/contact-types.d.ts.map +1 -0
- package/script/oas/contact/contact-types.js +43 -0
- package/script/oas/discriminator/discriminator-types.d.ts +1 -5
- package/script/oas/discriminator/discriminator-types.d.ts.map +1 -1
- package/script/oas/document/document-types.d.ts +16 -0
- package/script/oas/document/document-types.d.ts.map +1 -0
- package/script/oas/document/document-types.js +54 -0
- package/script/oas/example/example-types.d.ts +1 -6
- package/script/oas/example/example-types.d.ts.map +1 -1
- package/script/oas/header/header-types.d.ts +50 -0
- package/script/oas/header/header-types.d.ts.map +1 -0
- package/script/oas/header/header-types.js +66 -0
- package/script/oas/info/info-types.d.ts +14 -0
- package/script/oas/info/info-types.d.ts.map +1 -0
- package/script/oas/info/info-types.js +49 -0
- package/script/oas/integer/integer-types.d.ts +3 -17
- package/script/oas/integer/integer-types.d.ts.map +1 -1
- package/script/oas/license/license-types.d.ts +9 -0
- package/script/oas/license/license-types.d.ts.map +1 -0
- package/script/oas/license/license-types.js +43 -0
- package/script/oas/mediaType/mediaType-types.d.ts +1 -11
- package/script/oas/mediaType/mediaType-types.d.ts.map +1 -1
- package/script/oas/number/number-types.d.ts +2 -16
- package/script/oas/number/number-types.d.ts.map +1 -1
- package/script/oas/operation/Operation.d.ts +47 -2
- package/script/oas/operation/Operation.d.ts.map +1 -1
- package/script/oas/operation/Operation.js +43 -0
- package/script/oas/operation/operation-types.d.ts +22 -0
- package/script/oas/operation/operation-types.d.ts.map +1 -0
- package/script/oas/operation/operation-types.js +71 -0
- package/script/oas/parameter/parameter-types.d.ts +3 -58
- package/script/oas/parameter/parameter-types.d.ts.map +1 -1
- package/script/oas/pathItem/pathItem-types.d.ts +12 -0
- package/script/oas/pathItem/pathItem-types.d.ts.map +1 -0
- package/script/oas/pathItem/pathItem-types.js +48 -0
- package/script/oas/ref/Ref.d.ts +49 -2
- package/script/oas/ref/Ref.d.ts.map +1 -1
- package/script/oas/ref/Ref.js +28 -0
- package/script/oas/requestBody/requestBody-types.d.ts +10 -0
- package/script/oas/requestBody/requestBody-types.d.ts.map +1 -0
- package/script/oas/requestBody/requestBody-types.js +45 -0
- package/script/oas/response/response-types.d.ts +12 -0
- package/script/oas/response/response-types.d.ts.map +1 -0
- package/script/oas/response/response-types.js +47 -0
- package/script/oas/schema/toSchemasV3.js +2 -2
- package/script/oas/server/toServerV3.d.ts.map +1 -1
- package/script/oas/string/string-types.d.ts +2 -29
- package/script/oas/string/string-types.d.ts.map +1 -1
- package/script/oas/string/toString.d.ts +125 -1
- package/script/oas/string/toString.d.ts.map +1 -1
- package/script/oas/string/toString.js +119 -0
- package/script/oas/tag/tag-types.d.ts +8 -0
- package/script/oas/tag/tag-types.d.ts.map +1 -0
- package/script/oas/tag/tag-types.js +44 -0
- package/script/oas/union/union-types.d.ts +1 -12
- package/script/oas/union/union-types.d.ts.map +1 -1
- package/script/oas/unknown/unknown-types.d.ts +1 -7
- package/script/oas/unknown/unknown-types.d.ts.map +1 -1
- package/script/types/Preview.d.ts +37 -0
- package/script/types/Preview.d.ts.map +1 -1
- package/script/types/Preview.js +37 -0
- package/script/types/Settings.d.ts +35 -0
- package/script/types/Settings.d.ts.map +1 -1
- package/script/types/Settings.js +27 -0
- package/script/typescript/FunctionParameter.d.ts +4 -4
- package/script/typescript/FunctionParameter.d.ts.map +1 -1
- package/script/typescript/List.d.ts +104 -5
- package/script/typescript/List.d.ts.map +1 -1
- package/script/typescript/List.js +75 -0
|
@@ -150,7 +150,7 @@ type ConstructorArgs = {
|
|
|
150
150
|
* prettierConfig: this.prettierConfig,
|
|
151
151
|
* basePath: this.settings?.basePath,
|
|
152
152
|
* stackTrail: this.stackTrail,
|
|
153
|
-
* logger: this
|
|
153
|
+
* logger: this.#logger,
|
|
154
154
|
* captureCurrentResult: this.captureCurrentResult.bind(this)
|
|
155
155
|
* });
|
|
156
156
|
*
|
|
@@ -210,17 +210,166 @@ type ConstructorArgs = {
|
|
|
210
210
|
*/
|
|
211
211
|
export declare class RenderContext {
|
|
212
212
|
#private;
|
|
213
|
+
/** Map of generated files to render */
|
|
213
214
|
files: Map<string, File | JsonFile>;
|
|
215
|
+
/** Preview data for generated content */
|
|
214
216
|
previews: Record<string, Record<string, Preview>>;
|
|
217
|
+
/** Mapping data for file relationships */
|
|
215
218
|
mappings: Record<string, Record<string, Mapping>>;
|
|
219
|
+
/** Base path for resolving file paths */
|
|
216
220
|
basePath: string | undefined;
|
|
217
|
-
|
|
221
|
+
/** Function to capture result status */
|
|
218
222
|
captureCurrentResult: (result: ResultType) => void;
|
|
223
|
+
/**
|
|
224
|
+
* Creates a new RenderContext instance with the specified configuration.
|
|
225
|
+
*
|
|
226
|
+
* Initializes the rendering context with files to render, preview data,
|
|
227
|
+
* formatting configuration, and logging/tracing infrastructure.
|
|
228
|
+
*
|
|
229
|
+
* @param args - Constructor arguments containing all required configuration
|
|
230
|
+
*/
|
|
219
231
|
constructor({ files, previews, mappings, prettierConfig, basePath, logger, stackTrail, captureCurrentResult }: ConstructorArgs);
|
|
232
|
+
/**
|
|
233
|
+
* Renders all files in the context to their final formatted form.
|
|
234
|
+
*
|
|
235
|
+
* This is the main rendering method that orchestrates the collation and
|
|
236
|
+
* formatting of all generated files. It processes files through Prettier
|
|
237
|
+
* formatting (if configured), resolves paths, and produces the final
|
|
238
|
+
* artifacts ready for writing to the filesystem.
|
|
239
|
+
*
|
|
240
|
+
* The method is wrapped in Sentry tracing spans for performance monitoring
|
|
241
|
+
* and includes both collation and artifact preparation phases.
|
|
242
|
+
*
|
|
243
|
+
* @returns Promise resolving to render result containing artifacts, file metadata, previews, and mappings
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const renderContext = new RenderContext({
|
|
248
|
+
* files: generatedFiles,
|
|
249
|
+
* previews: previewData,
|
|
250
|
+
* mappings: mappingData,
|
|
251
|
+
* prettierConfig: { semi: false, singleQuote: true },
|
|
252
|
+
* basePath: './src/generated',
|
|
253
|
+
* stackTrail: traceStack,
|
|
254
|
+
* logger: logger,
|
|
255
|
+
* captureCurrentResult: resultHandler
|
|
256
|
+
* });
|
|
257
|
+
*
|
|
258
|
+
* const result = await renderContext.render();
|
|
259
|
+
*
|
|
260
|
+
* // Access rendered files
|
|
261
|
+
* Object.entries(result.artifacts).forEach(([path, content]) => {
|
|
262
|
+
* console.log(`Rendered ${path}: ${result.files[path].lines} lines`);
|
|
263
|
+
* });
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
220
266
|
render(): Promise<Omit<RenderResult, 'results'>>;
|
|
267
|
+
/**
|
|
268
|
+
* Collates all files in the context into a unified render result.
|
|
269
|
+
*
|
|
270
|
+
* This method processes each file in the context through the rendering pipeline,
|
|
271
|
+
* applying Prettier formatting and path resolution. It coordinates the parallel
|
|
272
|
+
* processing of all files and aggregates the results into a single output structure.
|
|
273
|
+
*
|
|
274
|
+
* The collation process includes:
|
|
275
|
+
* - File content rendering with optional Prettier formatting
|
|
276
|
+
* - Path resolution using base path configuration
|
|
277
|
+
* - Metadata calculation (line count, character count)
|
|
278
|
+
* - Result aggregation into artifacts and file metadata maps
|
|
279
|
+
*
|
|
280
|
+
* @returns Promise resolving to collated files with artifacts and metadata
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* const collated = await renderContext.collate();
|
|
285
|
+
*
|
|
286
|
+
* // Access rendered file content
|
|
287
|
+
* console.log(collated.artifacts['/path/to/file.ts']);
|
|
288
|
+
*
|
|
289
|
+
* // Access file metadata
|
|
290
|
+
* console.log(collated.files['/path/to/file.ts'].lines);
|
|
291
|
+
* console.log(collated.files['/path/to/file.ts'].characters);
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
221
294
|
collate(): Promise<FilesRenderResult>;
|
|
295
|
+
/**
|
|
296
|
+
* Executes a function within a tracing context for performance monitoring.
|
|
297
|
+
*
|
|
298
|
+
* This method wraps function execution with distributed tracing capabilities,
|
|
299
|
+
* allowing performance monitoring and debugging of the rendering pipeline.
|
|
300
|
+
* It integrates with the stack trail to provide hierarchical tracing.
|
|
301
|
+
*
|
|
302
|
+
* @template T - The return type of the traced function
|
|
303
|
+
* @param token - Trace identifier (string or array of strings)
|
|
304
|
+
* @param fn - Function to execute within the trace context
|
|
305
|
+
* @returns The result of executing the traced function
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* const result = renderContext.trace('format-file', () => {
|
|
310
|
+
* return prettier.format(content, prettierConfig);
|
|
311
|
+
* });
|
|
312
|
+
*
|
|
313
|
+
* // With hierarchical tracing
|
|
314
|
+
* const result = renderContext.trace(['render', 'format'], () => {
|
|
315
|
+
* return complexFormattingOperation();
|
|
316
|
+
* });
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
222
319
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
320
|
+
/**
|
|
321
|
+
* Retrieves a file from the context by its normalized path.
|
|
322
|
+
*
|
|
323
|
+
* This method looks up a file in the context's file map using path normalization
|
|
324
|
+
* to ensure consistent path resolution. It validates that the requested file
|
|
325
|
+
* exists and throws an error if not found.
|
|
326
|
+
*
|
|
327
|
+
* @param filePath - The file path to retrieve (will be normalized)
|
|
328
|
+
* @returns The File or JsonFile instance
|
|
329
|
+
* @throws {Error} When the file is not found in the context
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```typescript
|
|
333
|
+
* const file = renderContext.getFile('./src/models/User.ts');
|
|
334
|
+
* console.log(file.toString()); // Access file content
|
|
335
|
+
*
|
|
336
|
+
* // Works with various path formats
|
|
337
|
+
* const sameFile = renderContext.getFile('src/models/User.ts');
|
|
338
|
+
* const alsoSameFile = renderContext.getFile('/absolute/path/src/models/User.ts');
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
223
341
|
getFile(filePath: string): File | JsonFile;
|
|
342
|
+
/**
|
|
343
|
+
* Picks a specific definition from a file in the context.
|
|
344
|
+
*
|
|
345
|
+
* This method retrieves a named definition (type, interface, etc.) from
|
|
346
|
+
* a specific file in the context. It validates that the target file is
|
|
347
|
+
* a File type (not JsonFile) and returns the requested definition if found.
|
|
348
|
+
*
|
|
349
|
+
* @param args - Object containing the definition name and export path
|
|
350
|
+
* @param args.name - The name of the definition to retrieve
|
|
351
|
+
* @param args.exportPath - The path to the file containing the definition
|
|
352
|
+
* @returns The Definition instance if found, undefined otherwise
|
|
353
|
+
* @throws {Error} When the file is not found or is not a File type
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```typescript
|
|
357
|
+
* const userDefinition = renderContext.pick({
|
|
358
|
+
* name: 'User',
|
|
359
|
+
* exportPath: './src/models/User.ts'
|
|
360
|
+
* });
|
|
361
|
+
*
|
|
362
|
+
* if (userDefinition) {
|
|
363
|
+
* console.log(userDefinition.identifier); // Access definition details
|
|
364
|
+
* }
|
|
365
|
+
*
|
|
366
|
+
* // Pick interface definition
|
|
367
|
+
* const apiInterface = renderContext.pick({
|
|
368
|
+
* name: 'ApiResponse',
|
|
369
|
+
* exportPath: './src/types/api.ts'
|
|
370
|
+
* });
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
224
373
|
pick({ name, exportPath }: PickArgs): Definition | undefined;
|
|
225
374
|
}
|
|
226
375
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAElD;;GAEG;AACH,KAAK,eAAe,GAAG;IACrB,uCAAuC;IACvC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,CAAC,CAAA;IACnC,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,0CAA0C;IAC1C,QA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|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _RenderContext_prettierConfig, _RenderContext_stackTrail;
|
|
12
|
+
var _RenderContext_prettierConfig, _RenderContext_logger, _RenderContext_stackTrail;
|
|
13
13
|
import * as Sentry from '@sentry/node';
|
|
14
14
|
import invariant from 'tiny-invariant';
|
|
15
15
|
import { normalize } from '../deps/jsr.io/@std/path/1.1.2/normalize.js';
|
|
@@ -138,7 +138,7 @@ import * as prettier from 'prettier';
|
|
|
138
138
|
* prettierConfig: this.prettierConfig,
|
|
139
139
|
* basePath: this.settings?.basePath,
|
|
140
140
|
* stackTrail: this.stackTrail,
|
|
141
|
-
* logger: this
|
|
141
|
+
* logger: this.#logger,
|
|
142
142
|
* captureCurrentResult: this.captureCurrentResult.bind(this)
|
|
143
143
|
* });
|
|
144
144
|
*
|
|
@@ -197,39 +197,50 @@ import * as prettier from 'prettier';
|
|
|
197
197
|
* ```
|
|
198
198
|
*/
|
|
199
199
|
export class RenderContext {
|
|
200
|
+
/**
|
|
201
|
+
* Creates a new RenderContext instance with the specified configuration.
|
|
202
|
+
*
|
|
203
|
+
* Initializes the rendering context with files to render, preview data,
|
|
204
|
+
* formatting configuration, and logging/tracing infrastructure.
|
|
205
|
+
*
|
|
206
|
+
* @param args - Constructor arguments containing all required configuration
|
|
207
|
+
*/
|
|
200
208
|
constructor({ files, previews, mappings, prettierConfig, basePath, logger, stackTrail, captureCurrentResult }) {
|
|
209
|
+
/** Map of generated files to render */
|
|
201
210
|
Object.defineProperty(this, "files", {
|
|
202
211
|
enumerable: true,
|
|
203
212
|
configurable: true,
|
|
204
213
|
writable: true,
|
|
205
214
|
value: void 0
|
|
206
215
|
});
|
|
216
|
+
/** Preview data for generated content */
|
|
207
217
|
Object.defineProperty(this, "previews", {
|
|
208
218
|
enumerable: true,
|
|
209
219
|
configurable: true,
|
|
210
220
|
writable: true,
|
|
211
221
|
value: void 0
|
|
212
222
|
});
|
|
223
|
+
/** Mapping data for file relationships */
|
|
213
224
|
Object.defineProperty(this, "mappings", {
|
|
214
225
|
enumerable: true,
|
|
215
226
|
configurable: true,
|
|
216
227
|
writable: true,
|
|
217
228
|
value: void 0
|
|
218
229
|
});
|
|
230
|
+
/** Optional Prettier configuration for code formatting */
|
|
219
231
|
_RenderContext_prettierConfig.set(this, void 0);
|
|
232
|
+
/** Base path for resolving file paths */
|
|
220
233
|
Object.defineProperty(this, "basePath", {
|
|
221
234
|
enumerable: true,
|
|
222
235
|
configurable: true,
|
|
223
236
|
writable: true,
|
|
224
237
|
value: void 0
|
|
225
238
|
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
writable: true,
|
|
230
|
-
value: void 0
|
|
231
|
-
});
|
|
239
|
+
/** Logger instance for debug information */
|
|
240
|
+
_RenderContext_logger.set(this, void 0);
|
|
241
|
+
/** Stack trail for distributed tracing */
|
|
232
242
|
_RenderContext_stackTrail.set(this, void 0);
|
|
243
|
+
/** Function to capture result status */
|
|
233
244
|
Object.defineProperty(this, "captureCurrentResult", {
|
|
234
245
|
enumerable: true,
|
|
235
246
|
configurable: true,
|
|
@@ -241,10 +252,44 @@ export class RenderContext {
|
|
|
241
252
|
this.mappings = mappings;
|
|
242
253
|
__classPrivateFieldSet(this, _RenderContext_prettierConfig, prettierConfig, "f");
|
|
243
254
|
this.basePath = basePath;
|
|
244
|
-
this
|
|
255
|
+
__classPrivateFieldSet(this, _RenderContext_logger, logger, "f");
|
|
245
256
|
__classPrivateFieldSet(this, _RenderContext_stackTrail, stackTrail, "f");
|
|
246
257
|
this.captureCurrentResult = captureCurrentResult;
|
|
247
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Renders all files in the context to their final formatted form.
|
|
261
|
+
*
|
|
262
|
+
* This is the main rendering method that orchestrates the collation and
|
|
263
|
+
* formatting of all generated files. It processes files through Prettier
|
|
264
|
+
* formatting (if configured), resolves paths, and produces the final
|
|
265
|
+
* artifacts ready for writing to the filesystem.
|
|
266
|
+
*
|
|
267
|
+
* The method is wrapped in Sentry tracing spans for performance monitoring
|
|
268
|
+
* and includes both collation and artifact preparation phases.
|
|
269
|
+
*
|
|
270
|
+
* @returns Promise resolving to render result containing artifacts, file metadata, previews, and mappings
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* const renderContext = new RenderContext({
|
|
275
|
+
* files: generatedFiles,
|
|
276
|
+
* previews: previewData,
|
|
277
|
+
* mappings: mappingData,
|
|
278
|
+
* prettierConfig: { semi: false, singleQuote: true },
|
|
279
|
+
* basePath: './src/generated',
|
|
280
|
+
* stackTrail: traceStack,
|
|
281
|
+
* logger: logger,
|
|
282
|
+
* captureCurrentResult: resultHandler
|
|
283
|
+
* });
|
|
284
|
+
*
|
|
285
|
+
* const result = await renderContext.render();
|
|
286
|
+
*
|
|
287
|
+
* // Access rendered files
|
|
288
|
+
* Object.entries(result.artifacts).forEach(([path, content]) => {
|
|
289
|
+
* console.log(`Rendered ${path}: ${result.files[path].lines} lines`);
|
|
290
|
+
* });
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
248
293
|
async render() {
|
|
249
294
|
return await Sentry.startSpan({ name: 'Render artifacts' }, async () => {
|
|
250
295
|
const result = await Sentry.startSpan({ name: 'Collate content' }, async () => {
|
|
@@ -259,6 +304,33 @@ export class RenderContext {
|
|
|
259
304
|
return rendered;
|
|
260
305
|
});
|
|
261
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* Collates all files in the context into a unified render result.
|
|
309
|
+
*
|
|
310
|
+
* This method processes each file in the context through the rendering pipeline,
|
|
311
|
+
* applying Prettier formatting and path resolution. It coordinates the parallel
|
|
312
|
+
* processing of all files and aggregates the results into a single output structure.
|
|
313
|
+
*
|
|
314
|
+
* The collation process includes:
|
|
315
|
+
* - File content rendering with optional Prettier formatting
|
|
316
|
+
* - Path resolution using base path configuration
|
|
317
|
+
* - Metadata calculation (line count, character count)
|
|
318
|
+
* - Result aggregation into artifacts and file metadata maps
|
|
319
|
+
*
|
|
320
|
+
* @returns Promise resolving to collated files with artifacts and metadata
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* const collated = await renderContext.collate();
|
|
325
|
+
*
|
|
326
|
+
* // Access rendered file content
|
|
327
|
+
* console.log(collated.artifacts['/path/to/file.ts']);
|
|
328
|
+
*
|
|
329
|
+
* // Access file metadata
|
|
330
|
+
* console.log(collated.files['/path/to/file.ts'].lines);
|
|
331
|
+
* console.log(collated.files['/path/to/file.ts'].characters);
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
262
334
|
async collate() {
|
|
263
335
|
const fileEntries = Array.from(this.files.entries());
|
|
264
336
|
const fileObjectPromises = fileEntries
|
|
@@ -290,22 +362,124 @@ export class RenderContext {
|
|
|
290
362
|
}
|
|
291
363
|
return output;
|
|
292
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* Executes a function within a tracing context for performance monitoring.
|
|
367
|
+
*
|
|
368
|
+
* This method wraps function execution with distributed tracing capabilities,
|
|
369
|
+
* allowing performance monitoring and debugging of the rendering pipeline.
|
|
370
|
+
* It integrates with the stack trail to provide hierarchical tracing.
|
|
371
|
+
*
|
|
372
|
+
* @template T - The return type of the traced function
|
|
373
|
+
* @param token - Trace identifier (string or array of strings)
|
|
374
|
+
* @param fn - Function to execute within the trace context
|
|
375
|
+
* @returns The result of executing the traced function
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```typescript
|
|
379
|
+
* const result = renderContext.trace('format-file', () => {
|
|
380
|
+
* return prettier.format(content, prettierConfig);
|
|
381
|
+
* });
|
|
382
|
+
*
|
|
383
|
+
* // With hierarchical tracing
|
|
384
|
+
* const result = renderContext.trace(['render', 'format'], () => {
|
|
385
|
+
* return complexFormattingOperation();
|
|
386
|
+
* });
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
293
389
|
trace(token, fn) {
|
|
294
|
-
return tracer(__classPrivateFieldGet(this, _RenderContext_stackTrail, "f"), token, fn, this
|
|
390
|
+
return tracer(__classPrivateFieldGet(this, _RenderContext_stackTrail, "f"), token, fn, __classPrivateFieldGet(this, _RenderContext_logger, "f"));
|
|
295
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Retrieves a file from the context by its normalized path.
|
|
394
|
+
*
|
|
395
|
+
* This method looks up a file in the context's file map using path normalization
|
|
396
|
+
* to ensure consistent path resolution. It validates that the requested file
|
|
397
|
+
* exists and throws an error if not found.
|
|
398
|
+
*
|
|
399
|
+
* @param filePath - The file path to retrieve (will be normalized)
|
|
400
|
+
* @returns The File or JsonFile instance
|
|
401
|
+
* @throws {Error} When the file is not found in the context
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* ```typescript
|
|
405
|
+
* const file = renderContext.getFile('./src/models/User.ts');
|
|
406
|
+
* console.log(file.toString()); // Access file content
|
|
407
|
+
*
|
|
408
|
+
* // Works with various path formats
|
|
409
|
+
* const sameFile = renderContext.getFile('src/models/User.ts');
|
|
410
|
+
* const alsoSameFile = renderContext.getFile('/absolute/path/src/models/User.ts');
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
296
413
|
getFile(filePath) {
|
|
297
414
|
const normalisedPath = normalize(filePath);
|
|
298
415
|
const currentFile = this.files.get(normalisedPath);
|
|
299
416
|
invariant(currentFile, `File not found during render phase: ${normalisedPath}`);
|
|
300
417
|
return currentFile;
|
|
301
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* Picks a specific definition from a file in the context.
|
|
421
|
+
*
|
|
422
|
+
* This method retrieves a named definition (type, interface, etc.) from
|
|
423
|
+
* a specific file in the context. It validates that the target file is
|
|
424
|
+
* a File type (not JsonFile) and returns the requested definition if found.
|
|
425
|
+
*
|
|
426
|
+
* @param args - Object containing the definition name and export path
|
|
427
|
+
* @param args.name - The name of the definition to retrieve
|
|
428
|
+
* @param args.exportPath - The path to the file containing the definition
|
|
429
|
+
* @returns The Definition instance if found, undefined otherwise
|
|
430
|
+
* @throws {Error} When the file is not found or is not a File type
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```typescript
|
|
434
|
+
* const userDefinition = renderContext.pick({
|
|
435
|
+
* name: 'User',
|
|
436
|
+
* exportPath: './src/models/User.ts'
|
|
437
|
+
* });
|
|
438
|
+
*
|
|
439
|
+
* if (userDefinition) {
|
|
440
|
+
* console.log(userDefinition.identifier); // Access definition details
|
|
441
|
+
* }
|
|
442
|
+
*
|
|
443
|
+
* // Pick interface definition
|
|
444
|
+
* const apiInterface = renderContext.pick({
|
|
445
|
+
* name: 'ApiResponse',
|
|
446
|
+
* exportPath: './src/types/api.ts'
|
|
447
|
+
* });
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
302
450
|
pick({ name, exportPath }) {
|
|
303
451
|
const file = this.getFile(exportPath);
|
|
304
452
|
invariant(file instanceof File, `File at "${exportPath}" is not a "File" type`);
|
|
305
453
|
return file.definitions.get(name);
|
|
306
454
|
}
|
|
307
455
|
}
|
|
308
|
-
_RenderContext_prettierConfig = new WeakMap(), _RenderContext_stackTrail = new WeakMap();
|
|
456
|
+
_RenderContext_prettierConfig = new WeakMap(), _RenderContext_logger = new WeakMap(), _RenderContext_stackTrail = new WeakMap();
|
|
457
|
+
/**
|
|
458
|
+
* Renders a single file with formatting and metadata calculation.
|
|
459
|
+
*
|
|
460
|
+
* This function processes a single file through the rendering pipeline,
|
|
461
|
+
* applying Prettier formatting if configured and calculating file metadata
|
|
462
|
+
* such as line count and character count. It resolves the final path using
|
|
463
|
+
* the base path configuration.
|
|
464
|
+
*
|
|
465
|
+
* @param args - File rendering arguments
|
|
466
|
+
* @returns Promise resolving to a FileObject with content and metadata
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```typescript
|
|
470
|
+
* const fileObject = await renderFile({
|
|
471
|
+
* content: 'const x = 1;',
|
|
472
|
+
* destinationPath: 'utils.ts',
|
|
473
|
+
* basePath: './src',
|
|
474
|
+
* prettierConfig: { semi: false }
|
|
475
|
+
* });
|
|
476
|
+
*
|
|
477
|
+
* console.log(fileObject.path); // './src/utils.ts'
|
|
478
|
+
* console.log(fileObject.content); // 'const x = 1' (formatted)
|
|
479
|
+
* console.log(fileObject.lines); // 1
|
|
480
|
+
* console.log(fileObject.characters); // 11
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
309
483
|
const renderFile = async ({ content, destinationPath, basePath, prettierConfig }) => {
|
|
310
484
|
const path = toResolvedArtifactPath({ basePath, destinationPath });
|
|
311
485
|
const formatted = prettierConfig
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { type LevelName } from '../deps/jsr.io/@std/log/0.224.14/levels.js';
|
|
2
2
|
import type { LogRecord } from '../deps/jsr.io/@std/log/0.224.14/logger.js';
|
|
3
3
|
import { BaseHandler } from '../deps/jsr.io/@std/log/0.224.14/base_handler.js';
|
|
4
|
-
import type { BaseHandlerOptions } from '../deps/jsr.io/@std/log/0.224.14/base_handler.js';
|
|
5
4
|
import type { CoreContext } from './CoreContext.js';
|
|
5
|
+
/**
|
|
6
|
+
* Base log handler interface for extending Deno standard library handlers.
|
|
7
|
+
*/
|
|
8
|
+
export interface LogHandlerBase {
|
|
9
|
+
handle(logRecord: LogRecord): void;
|
|
10
|
+
}
|
|
6
11
|
/**
|
|
7
12
|
* Configuration options for the {@link ResultsHandler}.
|
|
8
13
|
*/
|
|
9
|
-
export interface ResultsHandlerOptions
|
|
14
|
+
export interface ResultsHandlerOptions {
|
|
10
15
|
/** The CoreContext instance to capture results to */
|
|
11
16
|
context: CoreContext;
|
|
17
|
+
/** Formatter function for log messages */
|
|
18
|
+
formatter?: (logRecord: LogRecord) => string;
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* Custom log handler that captures warning and error results for SKMTC processing.
|
|
@@ -77,7 +84,7 @@ export interface ResultsHandlerOptions extends BaseHandlerOptions {
|
|
|
77
84
|
* }
|
|
78
85
|
* ```
|
|
79
86
|
*/
|
|
80
|
-
export declare class ResultsHandler extends BaseHandler {
|
|
87
|
+
export declare class ResultsHandler extends BaseHandler implements LogHandlerBase {
|
|
81
88
|
#private;
|
|
82
89
|
/** The CoreContext instance for capturing results */
|
|
83
90
|
context: CoreContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultsHandler.d.ts","sourceRoot":"","sources":["../../src/context/ResultsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,4CAA4C,CAAA;AACtF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAA;AAC9E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ResultsHandler.d.ts","sourceRoot":"","sources":["../../src/context/ResultsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,4CAA4C,CAAA;AACtF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAA;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGnD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAA;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,qDAAqD;IACrD,OAAO,EAAE,WAAW,CAAA;IACpB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,MAAM,CAAA;CAC7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,qBAAa,cAAe,SAAQ,WAAY,YAAW,cAAc;;IACvE,qDAAqD;IACrD,OAAO,EAAE,WAAW,CAAA;IAOpB;;;;;;;;;;;;;;OAcG;gBACS,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,qBAAqB;IAMhE;;;;;;;OAOG;IACM,KAAK;IAMd;;;;;;;;;OASG;IACM,MAAM,CAAC,SAAS,EAAE,SAAS;IASpC;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM;IAWrB;;;;;;;OAOG;IACH,KAAK;IAWL;;;;;;;;;;;;;;;;;;;;;OAqBG;IACM,OAAO;CAKjB"}
|
package/esm/context/types.d.ts
CHANGED
|
@@ -3,24 +3,54 @@ import type { ManifestEntry } from '../types/Manifest.js';
|
|
|
3
3
|
import type { Mapping, Preview } from '../types/Preview.js';
|
|
4
4
|
import type { ResultsItem } from '../types/Results.js';
|
|
5
5
|
import type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
6
|
+
/**
|
|
7
|
+
* Type representing the three phases of the SKMTC pipeline.
|
|
8
|
+
*/
|
|
6
9
|
export type PhaseType = 'parse' | 'generate' | 'render';
|
|
10
|
+
/**
|
|
11
|
+
* Options for retrieving files from the context.
|
|
12
|
+
*/
|
|
7
13
|
export type GetFileOptions = {
|
|
14
|
+
/** Whether to throw an error if the file is not found */
|
|
8
15
|
throwIfNotFound?: boolean;
|
|
9
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Arguments for adding a generator key to the context.
|
|
19
|
+
*/
|
|
10
20
|
export type AddGeneratorKeyArgs = {
|
|
21
|
+
/** The generator key to add */
|
|
11
22
|
generatorKey: GeneratorKey;
|
|
12
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Result of rendering files in the context.
|
|
26
|
+
*/
|
|
13
27
|
export type FilesRenderResult = {
|
|
28
|
+
/** Map of file paths to rendered content */
|
|
14
29
|
artifacts: Record<string, string>;
|
|
30
|
+
/** Map of file paths to metadata */
|
|
15
31
|
files: Record<string, ManifestEntry>;
|
|
16
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Complete result of the rendering phase including all generated content and metadata.
|
|
35
|
+
*/
|
|
17
36
|
export type RenderResult = {
|
|
37
|
+
/** Map of file paths to rendered content */
|
|
18
38
|
artifacts: Record<string, string>;
|
|
39
|
+
/** Map of file paths to metadata */
|
|
19
40
|
files: Record<string, ManifestEntry>;
|
|
41
|
+
/** Preview data for generated content */
|
|
20
42
|
previews: Record<string, Record<string, Preview>>;
|
|
43
|
+
/** Mapping data for file relationships */
|
|
21
44
|
mappings: Record<string, Record<string, Mapping>>;
|
|
45
|
+
/** Hierarchical results tracking */
|
|
22
46
|
results: ResultsItem;
|
|
23
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Union type representing any supported OpenAPI document version.
|
|
50
|
+
*/
|
|
24
51
|
export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
52
|
+
/**
|
|
53
|
+
* Types of issues that can be encountered during OpenAPI schema parsing.
|
|
54
|
+
*/
|
|
25
55
|
export type IssueType = 'UNEXPECTED_PROPERTY' | 'MISSING_OBJECT_TYPE' | 'MISSING_STRING_TYPE' | 'MISSING_ARRAY_TYPE' | 'MISSING_BOOLEAN_TYPE' | 'INVALID_EXAMPLE' | 'INVALID_ENUM' | 'INVALID_DEFAULT' | 'INVALID_NULLABLE' | 'UNEXPECTED_FORMAT' | 'INVALID_RESPONSE' | 'INVALID_FORMAT' | 'INVALID_OPERATION' | 'INVALID_SCHEMA' | 'INVALID_PARAMETER' | 'INVALID_DEPENDENCY_REF';
|
|
26
56
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,C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AA;IACpC,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,oCAAoC;IACpC,OAAO,EAAE,WAAW,CAAA;CACrB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAA;AAE3F;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,qBAAqB,GACrB,qBAAqB,GACrB,qBAAqB,GACrB,oBAAoB,GACpB,sBAAsB,GACtB,iBAAiB,GACjB,cAAc,GACd,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,kBAAkB,GAClB,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,mBAAmB,GACnB,wBAAwB,CAAA"}
|
|
@@ -8,7 +8,7 @@ import { ContentBase } from '../ContentBase.js';
|
|
|
8
8
|
import type { Inserted } from '../Inserted.js';
|
|
9
9
|
import type { OasSchema } from '../../oas/schema/Schema.js';
|
|
10
10
|
import type { OasRef } from '../../oas/ref/Ref.js';
|
|
11
|
-
import { OasVoid } from '../../oas/void/Void.js';
|
|
11
|
+
import type { OasVoid } from '../../oas/void/Void.js';
|
|
12
12
|
/**
|
|
13
13
|
* Constructor arguments for {@link ModelBase}.
|
|
14
14
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelBase.d.ts","sourceRoot":"","sources":["../../../src/dsl/model/ModelBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,c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