@skmtc/core 0.0.939 → 0.0.941
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 +6 -32
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +15 -60
- package/esm/context/GenerateContext.d.ts +4 -15
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +16 -35
- package/esm/context/ParseContext.d.ts +5 -9
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +11 -18
- package/esm/context/RenderContext.d.ts +6 -209
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +8 -215
- package/esm/context/ResultsHandler.d.ts +0 -67
- package/esm/context/ResultsHandler.d.ts.map +1 -1
- package/esm/context/ResultsHandler.js +2 -68
- package/esm/context/StackTrail.d.ts +2 -0
- package/esm/context/StackTrail.d.ts.map +1 -1
- package/esm/context/StackTrail.js +26 -0
- package/esm/context/generateTypes.d.ts +2 -2
- package/esm/context/generateTypes.d.ts.map +1 -1
- package/esm/context/parseTypes.d.ts +7 -2
- package/esm/context/parseTypes.d.ts.map +1 -1
- package/esm/oas/_helpers/parseEnum.d.ts +3 -1
- package/esm/oas/_helpers/parseEnum.d.ts.map +1 -1
- package/esm/oas/_helpers/parseEnum.js +2 -1
- package/esm/oas/_helpers/parseNullable.d.ts +4 -1
- package/esm/oas/_helpers/parseNullable.d.ts.map +1 -1
- package/esm/oas/_helpers/parseNullable.js +2 -1
- package/esm/oas/array/toArray.d.ts +5 -2
- package/esm/oas/array/toArray.d.ts.map +1 -1
- package/esm/oas/array/toArray.js +16 -9
- package/esm/oas/boolean/toBoolean.d.ts +5 -2
- package/esm/oas/boolean/toBoolean.d.ts.map +1 -1
- package/esm/oas/boolean/toBoolean.js +16 -8
- package/esm/oas/components/toComponentsV3.d.ts +3 -1
- package/esm/oas/components/toComponentsV3.d.ts.map +1 -1
- package/esm/oas/components/toComponentsV3.js +9 -8
- package/esm/oas/contact/toContactV3.d.ts +2 -1
- package/esm/oas/contact/toContactV3.d.ts.map +1 -1
- package/esm/oas/contact/toContactV3.js +2 -1
- package/esm/oas/discriminator/toDiscriminatorV3.d.ts +3 -1
- package/esm/oas/discriminator/toDiscriminatorV3.d.ts.map +1 -1
- package/esm/oas/discriminator/toDiscriminatorV3.js +7 -2
- package/esm/oas/document/toDocumentFieldsV3.d.ts +3 -1
- package/esm/oas/document/toDocumentFieldsV3.d.ts.map +1 -1
- package/esm/oas/document/toDocumentFieldsV3.js +10 -9
- package/esm/oas/example/toExamplesV3.d.ts +10 -2
- package/esm/oas/example/toExamplesV3.d.ts.map +1 -1
- package/esm/oas/example/toExamplesV3.js +8 -7
- package/esm/oas/externalDocs/toExternalDocs.d.ts +3 -1
- package/esm/oas/externalDocs/toExternalDocs.d.ts.map +1 -1
- package/esm/oas/externalDocs/toExternalDocs.js +1 -1
- package/esm/oas/header/toHeadersV3.d.ts +3 -1
- package/esm/oas/header/toHeadersV3.d.ts.map +1 -1
- package/esm/oas/header/toHeadersV3.js +8 -7
- package/esm/oas/info/toInfoV3.d.ts +3 -1
- package/esm/oas/info/toInfoV3.d.ts.map +1 -1
- package/esm/oas/info/toInfoV3.js +4 -3
- package/esm/oas/integer/toInteger.d.ts +5 -2
- package/esm/oas/integer/toInteger.d.ts.map +1 -1
- package/esm/oas/integer/toInteger.js +17 -9
- package/esm/oas/license/toLicenseV3.d.ts +2 -1
- package/esm/oas/license/toLicenseV3.d.ts.map +1 -1
- package/esm/oas/license/toLicenseV3.js +2 -1
- package/esm/oas/mediaType/toMediaTypeItemV3.d.ts +10 -3
- package/esm/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
- package/esm/oas/mediaType/toMediaTypeItemV3.js +9 -8
- package/esm/oas/number/toNumber.d.ts +3 -1
- package/esm/oas/number/toNumber.d.ts.map +1 -1
- package/esm/oas/number/toNumber.js +15 -7
- package/esm/oas/object/toAdditionalPropertiesV3.d.ts +3 -1
- package/esm/oas/object/toAdditionalPropertiesV3.d.ts.map +1 -1
- package/esm/oas/object/toAdditionalPropertiesV3.js +2 -2
- package/esm/oas/object/toObject.d.ts +3 -1
- package/esm/oas/object/toObject.d.ts.map +1 -1
- package/esm/oas/object/toObject.js +15 -9
- package/esm/oas/operation/toOperationsV3.d.ts +5 -2
- package/esm/oas/operation/toOperationsV3.d.ts.map +1 -1
- package/esm/oas/operation/toOperationsV3.js +14 -12
- package/esm/oas/parameter/toParameterV3.d.ts +7 -3
- package/esm/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/esm/oas/parameter/toParameterV3.js +18 -16
- package/esm/oas/pathItem/toPathItemV3.d.ts +3 -1
- package/esm/oas/pathItem/toPathItemV3.d.ts.map +1 -1
- package/esm/oas/pathItem/toPathItemV3.js +3 -3
- package/esm/oas/ref/toRefV31.d.ts +3 -1
- package/esm/oas/ref/toRefV31.d.ts.map +1 -1
- package/esm/oas/ref/toRefV31.js +3 -3
- package/esm/oas/requestBody/toRequestBodiesV3.d.ts +5 -2
- package/esm/oas/requestBody/toRequestBodiesV3.d.ts.map +1 -1
- package/esm/oas/requestBody/toRequestBodiesV3.js +7 -7
- package/esm/oas/response/toResponseV3.d.ts +7 -3
- package/esm/oas/response/toResponseV3.d.ts.map +1 -1
- package/esm/oas/response/toResponseV3.js +10 -9
- package/esm/oas/schema/toSchemasV3.d.ts +9 -4
- package/esm/oas/schema/toSchemasV3.d.ts.map +1 -1
- package/esm/oas/schema/toSchemasV3.js +33 -25
- package/esm/oas/securityRequirement/toSecurityRequirement.d.ts +3 -1
- package/esm/oas/securityRequirement/toSecurityRequirement.d.ts.map +1 -1
- package/esm/oas/securityRequirement/toSecurityRequirement.js +1 -1
- package/esm/oas/securitySchemes/toSecuritySchemes.d.ts +3 -1
- package/esm/oas/securitySchemes/toSecuritySchemes.d.ts.map +1 -1
- package/esm/oas/securitySchemes/toSecuritySchemes.js +23 -8
- package/esm/oas/server/toServerV3.d.ts +7 -3
- package/esm/oas/server/toServerV3.d.ts.map +1 -1
- package/esm/oas/server/toServerV3.js +7 -7
- package/esm/oas/serverVariable/toServerVariableV3.d.ts +7 -3
- package/esm/oas/serverVariable/toServerVariableV3.d.ts.map +1 -1
- package/esm/oas/serverVariable/toServerVariableV3.js +6 -5
- package/esm/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts +3 -1
- package/esm/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts.map +1 -1
- package/esm/oas/specificationExtensions/toSpecificationExtensionsV3.js +2 -2
- package/esm/oas/string/toString.d.ts +6 -2
- package/esm/oas/string/toString.d.ts.map +1 -1
- package/esm/oas/string/toString.js +18 -9
- package/esm/oas/tag/toTagsV3.d.ts +5 -2
- package/esm/oas/tag/toTagsV3.d.ts.map +1 -1
- package/esm/oas/tag/toTagsV3.js +4 -3
- package/esm/oas/union/toUnion.d.ts +3 -1
- package/esm/oas/union/toUnion.d.ts.map +1 -1
- package/esm/oas/union/toUnion.js +4 -4
- package/esm/oas/unknown/toUnknown.d.ts +3 -1
- package/esm/oas/unknown/toUnknown.d.ts.map +1 -1
- package/esm/oas/unknown/toUnknown.js +2 -1
- package/esm/run/toArtifacts.d.ts +4 -1
- package/esm/run/toArtifacts.d.ts.map +1 -1
- package/esm/run/toArtifacts.js +2 -1
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +6 -32
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +15 -60
- package/script/context/GenerateContext.d.ts +4 -15
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +16 -35
- package/script/context/ParseContext.d.ts +5 -9
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +11 -18
- package/script/context/RenderContext.d.ts +6 -209
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +8 -215
- package/script/context/ResultsHandler.d.ts +0 -67
- package/script/context/ResultsHandler.d.ts.map +1 -1
- package/script/context/ResultsHandler.js +2 -68
- package/script/context/StackTrail.d.ts +2 -0
- package/script/context/StackTrail.d.ts.map +1 -1
- package/script/context/StackTrail.js +26 -0
- package/script/context/generateTypes.d.ts +2 -2
- package/script/context/generateTypes.d.ts.map +1 -1
- package/script/context/parseTypes.d.ts +7 -2
- package/script/context/parseTypes.d.ts.map +1 -1
- package/script/oas/_helpers/parseEnum.d.ts +3 -1
- package/script/oas/_helpers/parseEnum.d.ts.map +1 -1
- package/script/oas/_helpers/parseEnum.js +2 -1
- package/script/oas/_helpers/parseNullable.d.ts +4 -1
- package/script/oas/_helpers/parseNullable.d.ts.map +1 -1
- package/script/oas/_helpers/parseNullable.js +2 -1
- package/script/oas/array/toArray.d.ts +5 -2
- package/script/oas/array/toArray.d.ts.map +1 -1
- package/script/oas/array/toArray.js +16 -9
- package/script/oas/boolean/toBoolean.d.ts +5 -2
- package/script/oas/boolean/toBoolean.d.ts.map +1 -1
- package/script/oas/boolean/toBoolean.js +16 -8
- package/script/oas/components/toComponentsV3.d.ts +3 -1
- package/script/oas/components/toComponentsV3.d.ts.map +1 -1
- package/script/oas/components/toComponentsV3.js +9 -8
- package/script/oas/contact/toContactV3.d.ts +2 -1
- package/script/oas/contact/toContactV3.d.ts.map +1 -1
- package/script/oas/contact/toContactV3.js +2 -1
- package/script/oas/discriminator/toDiscriminatorV3.d.ts +3 -1
- package/script/oas/discriminator/toDiscriminatorV3.d.ts.map +1 -1
- package/script/oas/discriminator/toDiscriminatorV3.js +7 -2
- package/script/oas/document/toDocumentFieldsV3.d.ts +3 -1
- package/script/oas/document/toDocumentFieldsV3.d.ts.map +1 -1
- package/script/oas/document/toDocumentFieldsV3.js +10 -9
- package/script/oas/example/toExamplesV3.d.ts +10 -2
- package/script/oas/example/toExamplesV3.d.ts.map +1 -1
- package/script/oas/example/toExamplesV3.js +8 -7
- package/script/oas/externalDocs/toExternalDocs.d.ts +3 -1
- package/script/oas/externalDocs/toExternalDocs.d.ts.map +1 -1
- package/script/oas/externalDocs/toExternalDocs.js +1 -1
- package/script/oas/header/toHeadersV3.d.ts +3 -1
- package/script/oas/header/toHeadersV3.d.ts.map +1 -1
- package/script/oas/header/toHeadersV3.js +8 -7
- package/script/oas/info/toInfoV3.d.ts +3 -1
- package/script/oas/info/toInfoV3.d.ts.map +1 -1
- package/script/oas/info/toInfoV3.js +4 -3
- package/script/oas/integer/toInteger.d.ts +5 -2
- package/script/oas/integer/toInteger.d.ts.map +1 -1
- package/script/oas/integer/toInteger.js +17 -9
- package/script/oas/license/toLicenseV3.d.ts +2 -1
- package/script/oas/license/toLicenseV3.d.ts.map +1 -1
- package/script/oas/license/toLicenseV3.js +2 -1
- package/script/oas/mediaType/toMediaTypeItemV3.d.ts +10 -3
- package/script/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
- package/script/oas/mediaType/toMediaTypeItemV3.js +9 -8
- package/script/oas/number/toNumber.d.ts +3 -1
- package/script/oas/number/toNumber.d.ts.map +1 -1
- package/script/oas/number/toNumber.js +15 -7
- package/script/oas/object/toAdditionalPropertiesV3.d.ts +3 -1
- package/script/oas/object/toAdditionalPropertiesV3.d.ts.map +1 -1
- package/script/oas/object/toAdditionalPropertiesV3.js +2 -2
- package/script/oas/object/toObject.d.ts +3 -1
- package/script/oas/object/toObject.d.ts.map +1 -1
- package/script/oas/object/toObject.js +15 -9
- package/script/oas/operation/toOperationsV3.d.ts +5 -2
- package/script/oas/operation/toOperationsV3.d.ts.map +1 -1
- package/script/oas/operation/toOperationsV3.js +14 -12
- package/script/oas/parameter/toParameterV3.d.ts +7 -3
- package/script/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/script/oas/parameter/toParameterV3.js +18 -16
- package/script/oas/pathItem/toPathItemV3.d.ts +3 -1
- package/script/oas/pathItem/toPathItemV3.d.ts.map +1 -1
- package/script/oas/pathItem/toPathItemV3.js +3 -3
- package/script/oas/ref/toRefV31.d.ts +3 -1
- package/script/oas/ref/toRefV31.d.ts.map +1 -1
- package/script/oas/ref/toRefV31.js +3 -3
- package/script/oas/requestBody/toRequestBodiesV3.d.ts +5 -2
- package/script/oas/requestBody/toRequestBodiesV3.d.ts.map +1 -1
- package/script/oas/requestBody/toRequestBodiesV3.js +7 -7
- package/script/oas/response/toResponseV3.d.ts +7 -3
- package/script/oas/response/toResponseV3.d.ts.map +1 -1
- package/script/oas/response/toResponseV3.js +10 -9
- package/script/oas/schema/toSchemasV3.d.ts +9 -4
- package/script/oas/schema/toSchemasV3.d.ts.map +1 -1
- package/script/oas/schema/toSchemasV3.js +33 -25
- package/script/oas/securityRequirement/toSecurityRequirement.d.ts +3 -1
- package/script/oas/securityRequirement/toSecurityRequirement.d.ts.map +1 -1
- package/script/oas/securityRequirement/toSecurityRequirement.js +1 -1
- package/script/oas/securitySchemes/toSecuritySchemes.d.ts +3 -1
- package/script/oas/securitySchemes/toSecuritySchemes.d.ts.map +1 -1
- package/script/oas/securitySchemes/toSecuritySchemes.js +23 -8
- package/script/oas/server/toServerV3.d.ts +7 -3
- package/script/oas/server/toServerV3.d.ts.map +1 -1
- package/script/oas/server/toServerV3.js +7 -7
- package/script/oas/serverVariable/toServerVariableV3.d.ts +7 -3
- package/script/oas/serverVariable/toServerVariableV3.d.ts.map +1 -1
- package/script/oas/serverVariable/toServerVariableV3.js +6 -5
- package/script/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts +3 -1
- package/script/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts.map +1 -1
- package/script/oas/specificationExtensions/toSpecificationExtensionsV3.js +2 -2
- package/script/oas/string/toString.d.ts +6 -2
- package/script/oas/string/toString.d.ts.map +1 -1
- package/script/oas/string/toString.js +18 -9
- package/script/oas/tag/toTagsV3.d.ts +5 -2
- package/script/oas/tag/toTagsV3.d.ts.map +1 -1
- package/script/oas/tag/toTagsV3.js +4 -3
- package/script/oas/union/toUnion.d.ts +3 -1
- package/script/oas/union/toUnion.d.ts.map +1 -1
- package/script/oas/union/toUnion.js +4 -4
- package/script/oas/unknown/toUnknown.d.ts +3 -1
- package/script/oas/unknown/toUnknown.d.ts.map +1 -1
- package/script/oas/unknown/toUnknown.js +2 -1
- package/script/run/toArtifacts.d.ts +4 -1
- package/script/run/toArtifacts.d.ts.map +1 -1
- package/script/run/toArtifacts.js +2 -1
|
@@ -3,12 +3,12 @@ import type { FilesRenderResult, RenderResult } from './generateTypes.js';
|
|
|
3
3
|
import type { Definition } from '../dsl/Definition.js';
|
|
4
4
|
import type { PickArgs } from './generateTypes.js';
|
|
5
5
|
import type { ResultType } from '../types/Results.js';
|
|
6
|
-
import type { StackTrail } from './StackTrail.js';
|
|
7
6
|
import type * as log from '../deps/jsr.io/@std/log/0.224.14/mod.js';
|
|
8
7
|
import type { Logger } from '../types/Logger.js';
|
|
9
8
|
import { File } from '../dsl/File.js';
|
|
10
9
|
import type { Preview, Mapping } from '../types/Preview.js';
|
|
11
10
|
import type { JsonFile } from '../dsl/JsonFile.js';
|
|
11
|
+
import type { StackTrail } from './StackTrail.js';
|
|
12
12
|
/**
|
|
13
13
|
* Constructor arguments for {@link RenderContext}.
|
|
14
14
|
*/
|
|
@@ -23,189 +23,11 @@ type ConstructorArgs = {
|
|
|
23
23
|
prettierConfig?: PrettierConfigType;
|
|
24
24
|
/** Base path for resolving file paths */
|
|
25
25
|
basePath: string | undefined;
|
|
26
|
-
/** Stack trail for distributed tracing */
|
|
27
|
-
stackTrail: StackTrail;
|
|
28
26
|
/** Logger instance for debug information */
|
|
29
27
|
logger: log.Logger;
|
|
30
28
|
/** Function to capture result status */
|
|
31
|
-
captureCurrentResult: (result: ResultType) => void;
|
|
29
|
+
captureCurrentResult: (result: ResultType, stackTrail: StackTrail) => void;
|
|
32
30
|
};
|
|
33
|
-
/**
|
|
34
|
-
* The rendering context for the final phase of the SKMTC transformation pipeline.
|
|
35
|
-
*
|
|
36
|
-
* `RenderContext` is responsible for taking the generated artifacts from the generation
|
|
37
|
-
* phase and rendering them into their final form with proper formatting, path resolution,
|
|
38
|
-
* and file preparation. It handles code formatting via Biome, path normalization,
|
|
39
|
-
* and produces the final artifacts ready for writing to the filesystem.
|
|
40
|
-
*
|
|
41
|
-
* This context represents the culmination of the three-phase SKMTC pipeline, transforming
|
|
42
|
-
* generator outputs into production-ready code files with proper formatting and structure.
|
|
43
|
-
*
|
|
44
|
-
* ## Key Features
|
|
45
|
-
*
|
|
46
|
-
* - **Code Formatting**: Automatic Biome formatting for generated TypeScript/JavaScript code
|
|
47
|
-
* - **Path Resolution**: Intelligent path resolution with base path support
|
|
48
|
-
* - **Content Collation**: Combines all generated content into organized file structures
|
|
49
|
-
* - **Metadata Generation**: Tracks file statistics (lines, characters) and relationships
|
|
50
|
-
* - **Performance Monitoring**: Built-in tracing and performance measurement
|
|
51
|
-
*
|
|
52
|
-
* @example Basic rendering usage
|
|
53
|
-
* ```typescript
|
|
54
|
-
* import { RenderContext } from '@skmtc/core';
|
|
55
|
-
*
|
|
56
|
-
* const renderContext = new RenderContext({
|
|
57
|
-
* files: generatedFiles,
|
|
58
|
-
* previews: previewData,
|
|
59
|
-
* mappings: mappingData,
|
|
60
|
-
* prettierConfig: {
|
|
61
|
-
* semi: false,
|
|
62
|
-
* singleQuote: true,
|
|
63
|
-
* trailingComma: 'all'
|
|
64
|
-
* },
|
|
65
|
-
* basePath: './src/generated',
|
|
66
|
-
* stackTrail: traceStack,
|
|
67
|
-
* logger: myLogger,
|
|
68
|
-
* captureCurrentResult: (result) => console.log(result)
|
|
69
|
-
* });
|
|
70
|
-
*
|
|
71
|
-
* const rendered = await renderContext.render();
|
|
72
|
-
*
|
|
73
|
-
* // Access rendered files
|
|
74
|
-
* Object.entries(rendered.artifacts).forEach(([path, content]) => {
|
|
75
|
-
* console.log(`Rendered ${path}: ${rendered.files[path].lines} lines`);
|
|
76
|
-
* // Write to filesystem
|
|
77
|
-
* await Deno.writeTextFile(path, content);
|
|
78
|
-
* });
|
|
79
|
-
* ```
|
|
80
|
-
*
|
|
81
|
-
* @example With custom formatter configuration
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const renderContext = new RenderContext({
|
|
84
|
-
* files: generatedFiles,
|
|
85
|
-
* previews: {},
|
|
86
|
-
* mappings: {},
|
|
87
|
-
* prettierConfig: {
|
|
88
|
-
* printWidth: 120,
|
|
89
|
-
* tabWidth: 2,
|
|
90
|
-
* semi: true,
|
|
91
|
-
* singleQuote: true,
|
|
92
|
-
* trailingComma: 'es5',
|
|
93
|
-
* bracketSpacing: true,
|
|
94
|
-
* arrowParens: 'avoid'
|
|
95
|
-
* },
|
|
96
|
-
* basePath: './packages/api-client/src',
|
|
97
|
-
* stackTrail: stack,
|
|
98
|
-
* logger: logger,
|
|
99
|
-
* captureCurrentResult: resultHandler
|
|
100
|
-
* });
|
|
101
|
-
*
|
|
102
|
-
* const result = await renderContext.render();
|
|
103
|
-
*
|
|
104
|
-
* // All TypeScript files are automatically formatted
|
|
105
|
-
* console.log('Formatted files:', Object.keys(result.artifacts).length);
|
|
106
|
-
* ```
|
|
107
|
-
*
|
|
108
|
-
* @example Processing render results
|
|
109
|
-
* ```typescript
|
|
110
|
-
* const rendered = await renderContext.render();
|
|
111
|
-
*
|
|
112
|
-
* // Analyze file statistics
|
|
113
|
-
* const totalLines = Object.values(rendered.files)
|
|
114
|
-
* .reduce((sum, file) => sum + file.lines, 0);
|
|
115
|
-
* const totalChars = Object.values(rendered.files)
|
|
116
|
-
* .reduce((sum, file) => sum + file.characters, 0);
|
|
117
|
-
*
|
|
118
|
-
* console.log(`Generated ${Object.keys(rendered.artifacts).length} files`);
|
|
119
|
-
* console.log(`Total lines: ${totalLines}`);
|
|
120
|
-
* console.log(`Total characters: ${totalChars}`);
|
|
121
|
-
*
|
|
122
|
-
* // Check for large files
|
|
123
|
-
* const largeFiles = Object.entries(rendered.files)
|
|
124
|
-
* .filter(([_, metadata]) => metadata.lines > 1000)
|
|
125
|
-
* .map(([path, metadata]) => ({ path, lines: metadata.lines }));
|
|
126
|
-
*
|
|
127
|
-
* if (largeFiles.length > 0) {
|
|
128
|
-
* console.log('Large files detected:', largeFiles);
|
|
129
|
-
* }
|
|
130
|
-
*
|
|
131
|
-
* // Access preview and mapping data
|
|
132
|
-
* console.log('Previews available:', Object.keys(rendered.previews));
|
|
133
|
-
* console.log('Mappings available:', Object.keys(rendered.mappings));
|
|
134
|
-
* ```
|
|
135
|
-
*
|
|
136
|
-
* @example Integration with CoreContext
|
|
137
|
-
* ```typescript
|
|
138
|
-
* // Typically used within CoreContext.toArtifacts()
|
|
139
|
-
* class CustomCoreContext extends CoreContext {
|
|
140
|
-
* async renderWithPostProcessing(
|
|
141
|
-
* files: Map<string, File | JsonFile>,
|
|
142
|
-
* previews: Record<string, Record<string, Preview>>,
|
|
143
|
-
* mappings: Record<string, Record<string, Mapping>>
|
|
144
|
-
* ) {
|
|
145
|
-
* const renderContext = new RenderContext({
|
|
146
|
-
* files,
|
|
147
|
-
* previews,
|
|
148
|
-
* mappings,
|
|
149
|
-
* prettierConfig: this.prettierConfig,
|
|
150
|
-
* basePath: this.settings?.basePath,
|
|
151
|
-
* stackTrail: this.stackTrail,
|
|
152
|
-
* logger: this.logger,
|
|
153
|
-
* captureCurrentResult: this.captureCurrentResult.bind(this)
|
|
154
|
-
* });
|
|
155
|
-
*
|
|
156
|
-
* const rendered = await renderContext.render();
|
|
157
|
-
*
|
|
158
|
-
* // Post-process rendered files
|
|
159
|
-
* const processedArtifacts: Record<string, string> = {};
|
|
160
|
-
*
|
|
161
|
-
* for (const [path, content] of Object.entries(rendered.artifacts)) {
|
|
162
|
-
* // Add file headers, license notices, etc.
|
|
163
|
-
* const processedContent = this.addFileHeader(content, path);
|
|
164
|
-
* processedArtifacts[path] = processedContent;
|
|
165
|
-
* }
|
|
166
|
-
*
|
|
167
|
-
* return {
|
|
168
|
-
* ...rendered,
|
|
169
|
-
* artifacts: processedArtifacts
|
|
170
|
-
* };
|
|
171
|
-
* }
|
|
172
|
-
* }
|
|
173
|
-
* ```
|
|
174
|
-
*
|
|
175
|
-
* @example Error handling during rendering
|
|
176
|
-
* ```typescript
|
|
177
|
-
* try {
|
|
178
|
-
* const renderContext = new RenderContext({
|
|
179
|
-
* files: generatedFiles,
|
|
180
|
-
* previews: {},
|
|
181
|
-
* mappings: {},
|
|
182
|
-
* prettierConfig: prettierConfig,
|
|
183
|
-
* basePath: './invalid-path', // This might cause issues
|
|
184
|
-
* stackTrail: stack,
|
|
185
|
-
* logger: logger,
|
|
186
|
-
* captureCurrentResult: (result) => {
|
|
187
|
-
* if (result === 'error') {
|
|
188
|
-
* console.error('Render error detected');
|
|
189
|
-
* }
|
|
190
|
-
* }
|
|
191
|
-
* });
|
|
192
|
-
*
|
|
193
|
-
* const result = await renderContext.render();
|
|
194
|
-
*
|
|
195
|
-
* // Check if any files failed to render
|
|
196
|
-
* const failedFiles = Object.entries(result.files)
|
|
197
|
-
* .filter(([path, metadata]) => metadata.lines === 0)
|
|
198
|
-
* .map(([path]) => path);
|
|
199
|
-
*
|
|
200
|
-
* if (failedFiles.length > 0) {
|
|
201
|
-
* console.warn('Files with no content:', failedFiles);
|
|
202
|
-
* }
|
|
203
|
-
*
|
|
204
|
-
* } catch (error) {
|
|
205
|
-
* console.error('Render operation failed:', error);
|
|
206
|
-
* }
|
|
207
|
-
* ```
|
|
208
|
-
*/
|
|
209
31
|
export declare class RenderContext {
|
|
210
32
|
#private;
|
|
211
33
|
/** Map of generated files to render */
|
|
@@ -219,7 +41,7 @@ export declare class RenderContext {
|
|
|
219
41
|
/** Logger instance for debug information */
|
|
220
42
|
logger: Logger;
|
|
221
43
|
/** Function to capture result status */
|
|
222
|
-
captureCurrentResult: (result: ResultType) => void;
|
|
44
|
+
captureCurrentResult: (result: ResultType, stackTrail: StackTrail) => void;
|
|
223
45
|
/**
|
|
224
46
|
* Creates a new RenderContext instance with the specified configuration.
|
|
225
47
|
*
|
|
@@ -228,7 +50,7 @@ export declare class RenderContext {
|
|
|
228
50
|
*
|
|
229
51
|
* @param args - Constructor arguments containing all required configuration
|
|
230
52
|
*/
|
|
231
|
-
constructor({ files, previews, mappings, prettierConfig, basePath, logger,
|
|
53
|
+
constructor({ files, previews, mappings, prettierConfig, basePath, logger, captureCurrentResult }: ConstructorArgs);
|
|
232
54
|
/**
|
|
233
55
|
* Renders all files in the context to their final formatted form.
|
|
234
56
|
*
|
|
@@ -260,7 +82,7 @@ export declare class RenderContext {
|
|
|
260
82
|
* });
|
|
261
83
|
* ```
|
|
262
84
|
*/
|
|
263
|
-
render(): Omit<RenderResult, 'results'>;
|
|
85
|
+
render(stackTrail: StackTrail): Omit<RenderResult, 'results'>;
|
|
264
86
|
/**
|
|
265
87
|
* Collates all files in the context into a unified render result.
|
|
266
88
|
*
|
|
@@ -288,32 +110,7 @@ export declare class RenderContext {
|
|
|
288
110
|
* console.log(collated.files['/path/to/file.ts'].characters);
|
|
289
111
|
* ```
|
|
290
112
|
*/
|
|
291
|
-
collate(): FilesRenderResult;
|
|
292
|
-
/**
|
|
293
|
-
* Executes a function within a tracing context for performance monitoring.
|
|
294
|
-
*
|
|
295
|
-
* This method wraps function execution with distributed tracing capabilities,
|
|
296
|
-
* allowing performance monitoring and debugging of the rendering pipeline.
|
|
297
|
-
* It integrates with the stack trail to provide hierarchical tracing.
|
|
298
|
-
*
|
|
299
|
-
* @template T - The return type of the traced function
|
|
300
|
-
* @param token - Trace identifier (string or array of strings)
|
|
301
|
-
* @param fn - Function to execute within the trace context
|
|
302
|
-
* @returns The result of executing the traced function
|
|
303
|
-
*
|
|
304
|
-
* @example
|
|
305
|
-
* ```typescript
|
|
306
|
-
* const result = renderContext.trace('format-file', () => {
|
|
307
|
-
* return biome.formatContent(projectKey, content, { filePath: 'file.ts' });
|
|
308
|
-
* });
|
|
309
|
-
*
|
|
310
|
-
* // With hierarchical tracing
|
|
311
|
-
* const result = renderContext.trace(['render', 'format'], () => {
|
|
312
|
-
* return complexFormattingOperation();
|
|
313
|
-
* });
|
|
314
|
-
* ```
|
|
315
|
-
*/
|
|
316
|
-
trace<T>(token: string, fn: () => T): T;
|
|
113
|
+
collate(stackTrail: StackTrail): FilesRenderResult;
|
|
317
114
|
/**
|
|
318
115
|
* Retrieves a file from the context by its normalized path.
|
|
319
116
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"RenderContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderContext.ts"],"names":[],"mappings":"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"}
|
|
@@ -13,190 +13,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _RenderContext_prettierConfig
|
|
16
|
+
var _RenderContext_prettierConfig;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.RenderContext = void 0;
|
|
19
19
|
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
20
20
|
const normalize_js_1 = require("../deps/jsr.io/@std/path/1.1.2/normalize.js");
|
|
21
21
|
const toResolvedArtifactPath_js_1 = require("../helpers/toResolvedArtifactPath.js");
|
|
22
|
-
const tracer_js_1 = require("../helpers/tracer.js");
|
|
23
22
|
const File_js_1 = require("../dsl/File.js");
|
|
24
|
-
/**
|
|
25
|
-
* The rendering context for the final phase of the SKMTC transformation pipeline.
|
|
26
|
-
*
|
|
27
|
-
* `RenderContext` is responsible for taking the generated artifacts from the generation
|
|
28
|
-
* phase and rendering them into their final form with proper formatting, path resolution,
|
|
29
|
-
* and file preparation. It handles code formatting via Biome, path normalization,
|
|
30
|
-
* and produces the final artifacts ready for writing to the filesystem.
|
|
31
|
-
*
|
|
32
|
-
* This context represents the culmination of the three-phase SKMTC pipeline, transforming
|
|
33
|
-
* generator outputs into production-ready code files with proper formatting and structure.
|
|
34
|
-
*
|
|
35
|
-
* ## Key Features
|
|
36
|
-
*
|
|
37
|
-
* - **Code Formatting**: Automatic Biome formatting for generated TypeScript/JavaScript code
|
|
38
|
-
* - **Path Resolution**: Intelligent path resolution with base path support
|
|
39
|
-
* - **Content Collation**: Combines all generated content into organized file structures
|
|
40
|
-
* - **Metadata Generation**: Tracks file statistics (lines, characters) and relationships
|
|
41
|
-
* - **Performance Monitoring**: Built-in tracing and performance measurement
|
|
42
|
-
*
|
|
43
|
-
* @example Basic rendering usage
|
|
44
|
-
* ```typescript
|
|
45
|
-
* import { RenderContext } from '@skmtc/core';
|
|
46
|
-
*
|
|
47
|
-
* const renderContext = new RenderContext({
|
|
48
|
-
* files: generatedFiles,
|
|
49
|
-
* previews: previewData,
|
|
50
|
-
* mappings: mappingData,
|
|
51
|
-
* prettierConfig: {
|
|
52
|
-
* semi: false,
|
|
53
|
-
* singleQuote: true,
|
|
54
|
-
* trailingComma: 'all'
|
|
55
|
-
* },
|
|
56
|
-
* basePath: './src/generated',
|
|
57
|
-
* stackTrail: traceStack,
|
|
58
|
-
* logger: myLogger,
|
|
59
|
-
* captureCurrentResult: (result) => console.log(result)
|
|
60
|
-
* });
|
|
61
|
-
*
|
|
62
|
-
* const rendered = await renderContext.render();
|
|
63
|
-
*
|
|
64
|
-
* // Access rendered files
|
|
65
|
-
* Object.entries(rendered.artifacts).forEach(([path, content]) => {
|
|
66
|
-
* console.log(`Rendered ${path}: ${rendered.files[path].lines} lines`);
|
|
67
|
-
* // Write to filesystem
|
|
68
|
-
* await Deno.writeTextFile(path, content);
|
|
69
|
-
* });
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* @example With custom formatter configuration
|
|
73
|
-
* ```typescript
|
|
74
|
-
* const renderContext = new RenderContext({
|
|
75
|
-
* files: generatedFiles,
|
|
76
|
-
* previews: {},
|
|
77
|
-
* mappings: {},
|
|
78
|
-
* prettierConfig: {
|
|
79
|
-
* printWidth: 120,
|
|
80
|
-
* tabWidth: 2,
|
|
81
|
-
* semi: true,
|
|
82
|
-
* singleQuote: true,
|
|
83
|
-
* trailingComma: 'es5',
|
|
84
|
-
* bracketSpacing: true,
|
|
85
|
-
* arrowParens: 'avoid'
|
|
86
|
-
* },
|
|
87
|
-
* basePath: './packages/api-client/src',
|
|
88
|
-
* stackTrail: stack,
|
|
89
|
-
* logger: logger,
|
|
90
|
-
* captureCurrentResult: resultHandler
|
|
91
|
-
* });
|
|
92
|
-
*
|
|
93
|
-
* const result = await renderContext.render();
|
|
94
|
-
*
|
|
95
|
-
* // All TypeScript files are automatically formatted
|
|
96
|
-
* console.log('Formatted files:', Object.keys(result.artifacts).length);
|
|
97
|
-
* ```
|
|
98
|
-
*
|
|
99
|
-
* @example Processing render results
|
|
100
|
-
* ```typescript
|
|
101
|
-
* const rendered = await renderContext.render();
|
|
102
|
-
*
|
|
103
|
-
* // Analyze file statistics
|
|
104
|
-
* const totalLines = Object.values(rendered.files)
|
|
105
|
-
* .reduce((sum, file) => sum + file.lines, 0);
|
|
106
|
-
* const totalChars = Object.values(rendered.files)
|
|
107
|
-
* .reduce((sum, file) => sum + file.characters, 0);
|
|
108
|
-
*
|
|
109
|
-
* console.log(`Generated ${Object.keys(rendered.artifacts).length} files`);
|
|
110
|
-
* console.log(`Total lines: ${totalLines}`);
|
|
111
|
-
* console.log(`Total characters: ${totalChars}`);
|
|
112
|
-
*
|
|
113
|
-
* // Check for large files
|
|
114
|
-
* const largeFiles = Object.entries(rendered.files)
|
|
115
|
-
* .filter(([_, metadata]) => metadata.lines > 1000)
|
|
116
|
-
* .map(([path, metadata]) => ({ path, lines: metadata.lines }));
|
|
117
|
-
*
|
|
118
|
-
* if (largeFiles.length > 0) {
|
|
119
|
-
* console.log('Large files detected:', largeFiles);
|
|
120
|
-
* }
|
|
121
|
-
*
|
|
122
|
-
* // Access preview and mapping data
|
|
123
|
-
* console.log('Previews available:', Object.keys(rendered.previews));
|
|
124
|
-
* console.log('Mappings available:', Object.keys(rendered.mappings));
|
|
125
|
-
* ```
|
|
126
|
-
*
|
|
127
|
-
* @example Integration with CoreContext
|
|
128
|
-
* ```typescript
|
|
129
|
-
* // Typically used within CoreContext.toArtifacts()
|
|
130
|
-
* class CustomCoreContext extends CoreContext {
|
|
131
|
-
* async renderWithPostProcessing(
|
|
132
|
-
* files: Map<string, File | JsonFile>,
|
|
133
|
-
* previews: Record<string, Record<string, Preview>>,
|
|
134
|
-
* mappings: Record<string, Record<string, Mapping>>
|
|
135
|
-
* ) {
|
|
136
|
-
* const renderContext = new RenderContext({
|
|
137
|
-
* files,
|
|
138
|
-
* previews,
|
|
139
|
-
* mappings,
|
|
140
|
-
* prettierConfig: this.prettierConfig,
|
|
141
|
-
* basePath: this.settings?.basePath,
|
|
142
|
-
* stackTrail: this.stackTrail,
|
|
143
|
-
* logger: this.logger,
|
|
144
|
-
* captureCurrentResult: this.captureCurrentResult.bind(this)
|
|
145
|
-
* });
|
|
146
|
-
*
|
|
147
|
-
* const rendered = await renderContext.render();
|
|
148
|
-
*
|
|
149
|
-
* // Post-process rendered files
|
|
150
|
-
* const processedArtifacts: Record<string, string> = {};
|
|
151
|
-
*
|
|
152
|
-
* for (const [path, content] of Object.entries(rendered.artifacts)) {
|
|
153
|
-
* // Add file headers, license notices, etc.
|
|
154
|
-
* const processedContent = this.addFileHeader(content, path);
|
|
155
|
-
* processedArtifacts[path] = processedContent;
|
|
156
|
-
* }
|
|
157
|
-
*
|
|
158
|
-
* return {
|
|
159
|
-
* ...rendered,
|
|
160
|
-
* artifacts: processedArtifacts
|
|
161
|
-
* };
|
|
162
|
-
* }
|
|
163
|
-
* }
|
|
164
|
-
* ```
|
|
165
|
-
*
|
|
166
|
-
* @example Error handling during rendering
|
|
167
|
-
* ```typescript
|
|
168
|
-
* try {
|
|
169
|
-
* const renderContext = new RenderContext({
|
|
170
|
-
* files: generatedFiles,
|
|
171
|
-
* previews: {},
|
|
172
|
-
* mappings: {},
|
|
173
|
-
* prettierConfig: prettierConfig,
|
|
174
|
-
* basePath: './invalid-path', // This might cause issues
|
|
175
|
-
* stackTrail: stack,
|
|
176
|
-
* logger: logger,
|
|
177
|
-
* captureCurrentResult: (result) => {
|
|
178
|
-
* if (result === 'error') {
|
|
179
|
-
* console.error('Render error detected');
|
|
180
|
-
* }
|
|
181
|
-
* }
|
|
182
|
-
* });
|
|
183
|
-
*
|
|
184
|
-
* const result = await renderContext.render();
|
|
185
|
-
*
|
|
186
|
-
* // Check if any files failed to render
|
|
187
|
-
* const failedFiles = Object.entries(result.files)
|
|
188
|
-
* .filter(([path, metadata]) => metadata.lines === 0)
|
|
189
|
-
* .map(([path]) => path);
|
|
190
|
-
*
|
|
191
|
-
* if (failedFiles.length > 0) {
|
|
192
|
-
* console.warn('Files with no content:', failedFiles);
|
|
193
|
-
* }
|
|
194
|
-
*
|
|
195
|
-
* } catch (error) {
|
|
196
|
-
* console.error('Render operation failed:', error);
|
|
197
|
-
* }
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
23
|
class RenderContext {
|
|
201
24
|
/**
|
|
202
25
|
* Creates a new RenderContext instance with the specified configuration.
|
|
@@ -206,7 +29,7 @@ class RenderContext {
|
|
|
206
29
|
*
|
|
207
30
|
* @param args - Constructor arguments containing all required configuration
|
|
208
31
|
*/
|
|
209
|
-
constructor({ files, previews, mappings, prettierConfig, basePath, logger,
|
|
32
|
+
constructor({ files, previews, mappings, prettierConfig, basePath, logger, captureCurrentResult }) {
|
|
210
33
|
/** Map of generated files to render */
|
|
211
34
|
Object.defineProperty(this, "files", {
|
|
212
35
|
enumerable: true,
|
|
@@ -244,8 +67,6 @@ class RenderContext {
|
|
|
244
67
|
writable: true,
|
|
245
68
|
value: void 0
|
|
246
69
|
});
|
|
247
|
-
/** Stack trail for distributed tracing */
|
|
248
|
-
_RenderContext_stackTrail.set(this, void 0);
|
|
249
70
|
/** Function to capture result status */
|
|
250
71
|
Object.defineProperty(this, "captureCurrentResult", {
|
|
251
72
|
enumerable: true,
|
|
@@ -259,7 +80,6 @@ class RenderContext {
|
|
|
259
80
|
__classPrivateFieldSet(this, _RenderContext_prettierConfig, prettierConfig, "f");
|
|
260
81
|
this.basePath = basePath;
|
|
261
82
|
this.logger = logger;
|
|
262
|
-
__classPrivateFieldSet(this, _RenderContext_stackTrail, stackTrail, "f");
|
|
263
83
|
this.captureCurrentResult = captureCurrentResult;
|
|
264
84
|
}
|
|
265
85
|
/**
|
|
@@ -293,8 +113,8 @@ class RenderContext {
|
|
|
293
113
|
* });
|
|
294
114
|
* ```
|
|
295
115
|
*/
|
|
296
|
-
render() {
|
|
297
|
-
const result = this.collate();
|
|
116
|
+
render(stackTrail) {
|
|
117
|
+
const result = this.collate(stackTrail);
|
|
298
118
|
const rendered = {
|
|
299
119
|
artifacts: result.artifacts,
|
|
300
120
|
files: result.files,
|
|
@@ -330,18 +150,18 @@ class RenderContext {
|
|
|
330
150
|
* console.log(collated.files['/path/to/file.ts'].characters);
|
|
331
151
|
* ```
|
|
332
152
|
*/
|
|
333
|
-
collate() {
|
|
153
|
+
collate(stackTrail) {
|
|
334
154
|
const fileEntries = Array.from(this.files.entries());
|
|
335
155
|
const fileObjects = fileEntries
|
|
336
156
|
.map(([destinationPath, file]) => {
|
|
337
|
-
return
|
|
157
|
+
return stackTrail.trace(destinationPath, st => {
|
|
338
158
|
const renderedFile = renderFile({
|
|
339
159
|
content: file.toString(),
|
|
340
160
|
destinationPath,
|
|
341
161
|
basePath: this.basePath,
|
|
342
162
|
prettierConfig: __classPrivateFieldGet(this, _RenderContext_prettierConfig, "f")
|
|
343
163
|
});
|
|
344
|
-
this.captureCurrentResult('success');
|
|
164
|
+
this.captureCurrentResult('success', st);
|
|
345
165
|
return renderedFile;
|
|
346
166
|
});
|
|
347
167
|
})
|
|
@@ -360,33 +180,6 @@ class RenderContext {
|
|
|
360
180
|
}
|
|
361
181
|
return output;
|
|
362
182
|
}
|
|
363
|
-
/**
|
|
364
|
-
* Executes a function within a tracing context for performance monitoring.
|
|
365
|
-
*
|
|
366
|
-
* This method wraps function execution with distributed tracing capabilities,
|
|
367
|
-
* allowing performance monitoring and debugging of the rendering pipeline.
|
|
368
|
-
* It integrates with the stack trail to provide hierarchical tracing.
|
|
369
|
-
*
|
|
370
|
-
* @template T - The return type of the traced function
|
|
371
|
-
* @param token - Trace identifier (string or array of strings)
|
|
372
|
-
* @param fn - Function to execute within the trace context
|
|
373
|
-
* @returns The result of executing the traced function
|
|
374
|
-
*
|
|
375
|
-
* @example
|
|
376
|
-
* ```typescript
|
|
377
|
-
* const result = renderContext.trace('format-file', () => {
|
|
378
|
-
* return biome.formatContent(projectKey, content, { filePath: 'file.ts' });
|
|
379
|
-
* });
|
|
380
|
-
*
|
|
381
|
-
* // With hierarchical tracing
|
|
382
|
-
* const result = renderContext.trace(['render', 'format'], () => {
|
|
383
|
-
* return complexFormattingOperation();
|
|
384
|
-
* });
|
|
385
|
-
* ```
|
|
386
|
-
*/
|
|
387
|
-
trace(token, fn) {
|
|
388
|
-
return (0, tracer_js_1.tracer)(__classPrivateFieldGet(this, _RenderContext_stackTrail, "f"), token, fn);
|
|
389
|
-
}
|
|
390
183
|
/**
|
|
391
184
|
* Retrieves a file from the context by its normalized path.
|
|
392
185
|
*
|
|
@@ -452,7 +245,7 @@ class RenderContext {
|
|
|
452
245
|
}
|
|
453
246
|
}
|
|
454
247
|
exports.RenderContext = RenderContext;
|
|
455
|
-
_RenderContext_prettierConfig = new WeakMap()
|
|
248
|
+
_RenderContext_prettierConfig = new WeakMap();
|
|
456
249
|
/**
|
|
457
250
|
* Renders a single file with formatting and metadata calculation.
|
|
458
251
|
*
|
|
@@ -17,73 +17,6 @@ export interface ResultsHandlerOptions {
|
|
|
17
17
|
/** Formatter function for log messages */
|
|
18
18
|
formatter?: (logRecord: LogRecord) => string;
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Custom log handler that captures warning and error results for SKMTC processing.
|
|
22
|
-
*
|
|
23
|
-
* The `ResultsHandler` extends Deno's standard library BaseHandler to provide
|
|
24
|
-
* specialized logging behavior for the SKMTC pipeline. It integrates with the
|
|
25
|
-
* CoreContext to capture warnings and errors as structured results that can be
|
|
26
|
-
* analyzed and reported after processing completes.
|
|
27
|
-
*
|
|
28
|
-
* This handler ensures that important processing issues are captured and stored
|
|
29
|
-
* in the context's results system rather than just being logged to the console.
|
|
30
|
-
*
|
|
31
|
-
* ## Key Features
|
|
32
|
-
*
|
|
33
|
-
* - **Result Capture**: Automatically captures WARN and ERROR logs as results
|
|
34
|
-
* - **Immediate Flushing**: Critical errors trigger immediate flush
|
|
35
|
-
* - **Lifecycle Management**: Proper setup and cleanup with event handlers
|
|
36
|
-
* - **Context Integration**: Seamlessly integrates with CoreContext results system
|
|
37
|
-
*
|
|
38
|
-
* @example Setting up the handler
|
|
39
|
-
* ```typescript
|
|
40
|
-
* import { getLogger } from '@std/log';
|
|
41
|
-
* import { ResultsHandler, CoreContext } from '@skmtc/core';
|
|
42
|
-
*
|
|
43
|
-
* const context = new CoreContext({
|
|
44
|
-
* // ... context options
|
|
45
|
-
* });
|
|
46
|
-
*
|
|
47
|
-
* const handler = new ResultsHandler('WARN', {
|
|
48
|
-
* context: context,
|
|
49
|
-
* formatter: '[{levelName}] {msg}'
|
|
50
|
-
* });
|
|
51
|
-
*
|
|
52
|
-
* const logger = getLogger();
|
|
53
|
-
* logger.addHandler(handler);
|
|
54
|
-
*
|
|
55
|
-
* // Now warnings and errors will be captured as results
|
|
56
|
-
* logger.warning('Schema validation issue detected');
|
|
57
|
-
* logger.error('Failed to process operation');
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @example Integration in pipeline
|
|
61
|
-
* ```typescript
|
|
62
|
-
* class ProcessingPipeline {
|
|
63
|
-
* async process(document: OasDocument) {
|
|
64
|
-
* const context = new CoreContext(options);
|
|
65
|
-
*
|
|
66
|
-
* // Set up results handler
|
|
67
|
-
* const handler = new ResultsHandler('WARN', { context });
|
|
68
|
-
* const logger = getLogger();
|
|
69
|
-
* logger.addHandler(handler);
|
|
70
|
-
*
|
|
71
|
-
* try {
|
|
72
|
-
* const result = await this.processDocument(document, context);
|
|
73
|
-
*
|
|
74
|
-
* // Check captured results
|
|
75
|
-
* if (context.results.hasWarnings()) {
|
|
76
|
-
* console.log('Processing completed with warnings');
|
|
77
|
-
* }
|
|
78
|
-
*
|
|
79
|
-
* return result;
|
|
80
|
-
* } finally {
|
|
81
|
-
* handler.destroy();
|
|
82
|
-
* }
|
|
83
|
-
* }
|
|
84
|
-
* }
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
20
|
export declare class ResultsHandler extends BaseHandler implements LogHandlerBase {
|
|
88
21
|
#private;
|
|
89
22
|
/** The CoreContext instance for capturing results */
|
|
@@ -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,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
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;AAInD;;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;AACD,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;IAYrB;;;;;;;OAOG;IACH,KAAK;IAWL;;;;;;;;;;;;;;;;;;;;;OAqBG;IACM,OAAO;CAKjB"}
|