@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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"}
|
|
@@ -9,188 +9,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
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
|
|
12
|
+
var _RenderContext_prettierConfig;
|
|
13
13
|
import invariant from 'tiny-invariant';
|
|
14
14
|
import { normalize } from '../deps/jsr.io/@std/path/1.1.2/normalize.js';
|
|
15
15
|
import { toResolvedArtifactPath } from '../helpers/toResolvedArtifactPath.js';
|
|
16
|
-
import { tracer } from '../helpers/tracer.js';
|
|
17
16
|
import { File } from '../dsl/File.js';
|
|
18
|
-
/**
|
|
19
|
-
* The rendering context for the final phase of the SKMTC transformation pipeline.
|
|
20
|
-
*
|
|
21
|
-
* `RenderContext` is responsible for taking the generated artifacts from the generation
|
|
22
|
-
* phase and rendering them into their final form with proper formatting, path resolution,
|
|
23
|
-
* and file preparation. It handles code formatting via Biome, path normalization,
|
|
24
|
-
* and produces the final artifacts ready for writing to the filesystem.
|
|
25
|
-
*
|
|
26
|
-
* This context represents the culmination of the three-phase SKMTC pipeline, transforming
|
|
27
|
-
* generator outputs into production-ready code files with proper formatting and structure.
|
|
28
|
-
*
|
|
29
|
-
* ## Key Features
|
|
30
|
-
*
|
|
31
|
-
* - **Code Formatting**: Automatic Biome formatting for generated TypeScript/JavaScript code
|
|
32
|
-
* - **Path Resolution**: Intelligent path resolution with base path support
|
|
33
|
-
* - **Content Collation**: Combines all generated content into organized file structures
|
|
34
|
-
* - **Metadata Generation**: Tracks file statistics (lines, characters) and relationships
|
|
35
|
-
* - **Performance Monitoring**: Built-in tracing and performance measurement
|
|
36
|
-
*
|
|
37
|
-
* @example Basic rendering usage
|
|
38
|
-
* ```typescript
|
|
39
|
-
* import { RenderContext } from '@skmtc/core';
|
|
40
|
-
*
|
|
41
|
-
* const renderContext = new RenderContext({
|
|
42
|
-
* files: generatedFiles,
|
|
43
|
-
* previews: previewData,
|
|
44
|
-
* mappings: mappingData,
|
|
45
|
-
* prettierConfig: {
|
|
46
|
-
* semi: false,
|
|
47
|
-
* singleQuote: true,
|
|
48
|
-
* trailingComma: 'all'
|
|
49
|
-
* },
|
|
50
|
-
* basePath: './src/generated',
|
|
51
|
-
* stackTrail: traceStack,
|
|
52
|
-
* logger: myLogger,
|
|
53
|
-
* captureCurrentResult: (result) => console.log(result)
|
|
54
|
-
* });
|
|
55
|
-
*
|
|
56
|
-
* const rendered = await renderContext.render();
|
|
57
|
-
*
|
|
58
|
-
* // Access rendered files
|
|
59
|
-
* Object.entries(rendered.artifacts).forEach(([path, content]) => {
|
|
60
|
-
* console.log(`Rendered ${path}: ${rendered.files[path].lines} lines`);
|
|
61
|
-
* // Write to filesystem
|
|
62
|
-
* await Deno.writeTextFile(path, content);
|
|
63
|
-
* });
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* @example With custom formatter configuration
|
|
67
|
-
* ```typescript
|
|
68
|
-
* const renderContext = new RenderContext({
|
|
69
|
-
* files: generatedFiles,
|
|
70
|
-
* previews: {},
|
|
71
|
-
* mappings: {},
|
|
72
|
-
* prettierConfig: {
|
|
73
|
-
* printWidth: 120,
|
|
74
|
-
* tabWidth: 2,
|
|
75
|
-
* semi: true,
|
|
76
|
-
* singleQuote: true,
|
|
77
|
-
* trailingComma: 'es5',
|
|
78
|
-
* bracketSpacing: true,
|
|
79
|
-
* arrowParens: 'avoid'
|
|
80
|
-
* },
|
|
81
|
-
* basePath: './packages/api-client/src',
|
|
82
|
-
* stackTrail: stack,
|
|
83
|
-
* logger: logger,
|
|
84
|
-
* captureCurrentResult: resultHandler
|
|
85
|
-
* });
|
|
86
|
-
*
|
|
87
|
-
* const result = await renderContext.render();
|
|
88
|
-
*
|
|
89
|
-
* // All TypeScript files are automatically formatted
|
|
90
|
-
* console.log('Formatted files:', Object.keys(result.artifacts).length);
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* @example Processing render results
|
|
94
|
-
* ```typescript
|
|
95
|
-
* const rendered = await renderContext.render();
|
|
96
|
-
*
|
|
97
|
-
* // Analyze file statistics
|
|
98
|
-
* const totalLines = Object.values(rendered.files)
|
|
99
|
-
* .reduce((sum, file) => sum + file.lines, 0);
|
|
100
|
-
* const totalChars = Object.values(rendered.files)
|
|
101
|
-
* .reduce((sum, file) => sum + file.characters, 0);
|
|
102
|
-
*
|
|
103
|
-
* console.log(`Generated ${Object.keys(rendered.artifacts).length} files`);
|
|
104
|
-
* console.log(`Total lines: ${totalLines}`);
|
|
105
|
-
* console.log(`Total characters: ${totalChars}`);
|
|
106
|
-
*
|
|
107
|
-
* // Check for large files
|
|
108
|
-
* const largeFiles = Object.entries(rendered.files)
|
|
109
|
-
* .filter(([_, metadata]) => metadata.lines > 1000)
|
|
110
|
-
* .map(([path, metadata]) => ({ path, lines: metadata.lines }));
|
|
111
|
-
*
|
|
112
|
-
* if (largeFiles.length > 0) {
|
|
113
|
-
* console.log('Large files detected:', largeFiles);
|
|
114
|
-
* }
|
|
115
|
-
*
|
|
116
|
-
* // Access preview and mapping data
|
|
117
|
-
* console.log('Previews available:', Object.keys(rendered.previews));
|
|
118
|
-
* console.log('Mappings available:', Object.keys(rendered.mappings));
|
|
119
|
-
* ```
|
|
120
|
-
*
|
|
121
|
-
* @example Integration with CoreContext
|
|
122
|
-
* ```typescript
|
|
123
|
-
* // Typically used within CoreContext.toArtifacts()
|
|
124
|
-
* class CustomCoreContext extends CoreContext {
|
|
125
|
-
* async renderWithPostProcessing(
|
|
126
|
-
* files: Map<string, File | JsonFile>,
|
|
127
|
-
* previews: Record<string, Record<string, Preview>>,
|
|
128
|
-
* mappings: Record<string, Record<string, Mapping>>
|
|
129
|
-
* ) {
|
|
130
|
-
* const renderContext = new RenderContext({
|
|
131
|
-
* files,
|
|
132
|
-
* previews,
|
|
133
|
-
* mappings,
|
|
134
|
-
* prettierConfig: this.prettierConfig,
|
|
135
|
-
* basePath: this.settings?.basePath,
|
|
136
|
-
* stackTrail: this.stackTrail,
|
|
137
|
-
* logger: this.logger,
|
|
138
|
-
* captureCurrentResult: this.captureCurrentResult.bind(this)
|
|
139
|
-
* });
|
|
140
|
-
*
|
|
141
|
-
* const rendered = await renderContext.render();
|
|
142
|
-
*
|
|
143
|
-
* // Post-process rendered files
|
|
144
|
-
* const processedArtifacts: Record<string, string> = {};
|
|
145
|
-
*
|
|
146
|
-
* for (const [path, content] of Object.entries(rendered.artifacts)) {
|
|
147
|
-
* // Add file headers, license notices, etc.
|
|
148
|
-
* const processedContent = this.addFileHeader(content, path);
|
|
149
|
-
* processedArtifacts[path] = processedContent;
|
|
150
|
-
* }
|
|
151
|
-
*
|
|
152
|
-
* return {
|
|
153
|
-
* ...rendered,
|
|
154
|
-
* artifacts: processedArtifacts
|
|
155
|
-
* };
|
|
156
|
-
* }
|
|
157
|
-
* }
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* @example Error handling during rendering
|
|
161
|
-
* ```typescript
|
|
162
|
-
* try {
|
|
163
|
-
* const renderContext = new RenderContext({
|
|
164
|
-
* files: generatedFiles,
|
|
165
|
-
* previews: {},
|
|
166
|
-
* mappings: {},
|
|
167
|
-
* prettierConfig: prettierConfig,
|
|
168
|
-
* basePath: './invalid-path', // This might cause issues
|
|
169
|
-
* stackTrail: stack,
|
|
170
|
-
* logger: logger,
|
|
171
|
-
* captureCurrentResult: (result) => {
|
|
172
|
-
* if (result === 'error') {
|
|
173
|
-
* console.error('Render error detected');
|
|
174
|
-
* }
|
|
175
|
-
* }
|
|
176
|
-
* });
|
|
177
|
-
*
|
|
178
|
-
* const result = await renderContext.render();
|
|
179
|
-
*
|
|
180
|
-
* // Check if any files failed to render
|
|
181
|
-
* const failedFiles = Object.entries(result.files)
|
|
182
|
-
* .filter(([path, metadata]) => metadata.lines === 0)
|
|
183
|
-
* .map(([path]) => path);
|
|
184
|
-
*
|
|
185
|
-
* if (failedFiles.length > 0) {
|
|
186
|
-
* console.warn('Files with no content:', failedFiles);
|
|
187
|
-
* }
|
|
188
|
-
*
|
|
189
|
-
* } catch (error) {
|
|
190
|
-
* console.error('Render operation failed:', error);
|
|
191
|
-
* }
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
17
|
export class RenderContext {
|
|
195
18
|
/**
|
|
196
19
|
* Creates a new RenderContext instance with the specified configuration.
|
|
@@ -200,7 +23,7 @@ export class RenderContext {
|
|
|
200
23
|
*
|
|
201
24
|
* @param args - Constructor arguments containing all required configuration
|
|
202
25
|
*/
|
|
203
|
-
constructor({ files, previews, mappings, prettierConfig, basePath, logger,
|
|
26
|
+
constructor({ files, previews, mappings, prettierConfig, basePath, logger, captureCurrentResult }) {
|
|
204
27
|
/** Map of generated files to render */
|
|
205
28
|
Object.defineProperty(this, "files", {
|
|
206
29
|
enumerable: true,
|
|
@@ -238,8 +61,6 @@ export class RenderContext {
|
|
|
238
61
|
writable: true,
|
|
239
62
|
value: void 0
|
|
240
63
|
});
|
|
241
|
-
/** Stack trail for distributed tracing */
|
|
242
|
-
_RenderContext_stackTrail.set(this, void 0);
|
|
243
64
|
/** Function to capture result status */
|
|
244
65
|
Object.defineProperty(this, "captureCurrentResult", {
|
|
245
66
|
enumerable: true,
|
|
@@ -253,7 +74,6 @@ export class RenderContext {
|
|
|
253
74
|
__classPrivateFieldSet(this, _RenderContext_prettierConfig, prettierConfig, "f");
|
|
254
75
|
this.basePath = basePath;
|
|
255
76
|
this.logger = logger;
|
|
256
|
-
__classPrivateFieldSet(this, _RenderContext_stackTrail, stackTrail, "f");
|
|
257
77
|
this.captureCurrentResult = captureCurrentResult;
|
|
258
78
|
}
|
|
259
79
|
/**
|
|
@@ -287,8 +107,8 @@ export class RenderContext {
|
|
|
287
107
|
* });
|
|
288
108
|
* ```
|
|
289
109
|
*/
|
|
290
|
-
render() {
|
|
291
|
-
const result = this.collate();
|
|
110
|
+
render(stackTrail) {
|
|
111
|
+
const result = this.collate(stackTrail);
|
|
292
112
|
const rendered = {
|
|
293
113
|
artifacts: result.artifacts,
|
|
294
114
|
files: result.files,
|
|
@@ -324,18 +144,18 @@ export class RenderContext {
|
|
|
324
144
|
* console.log(collated.files['/path/to/file.ts'].characters);
|
|
325
145
|
* ```
|
|
326
146
|
*/
|
|
327
|
-
collate() {
|
|
147
|
+
collate(stackTrail) {
|
|
328
148
|
const fileEntries = Array.from(this.files.entries());
|
|
329
149
|
const fileObjects = fileEntries
|
|
330
150
|
.map(([destinationPath, file]) => {
|
|
331
|
-
return
|
|
151
|
+
return stackTrail.trace(destinationPath, st => {
|
|
332
152
|
const renderedFile = renderFile({
|
|
333
153
|
content: file.toString(),
|
|
334
154
|
destinationPath,
|
|
335
155
|
basePath: this.basePath,
|
|
336
156
|
prettierConfig: __classPrivateFieldGet(this, _RenderContext_prettierConfig, "f")
|
|
337
157
|
});
|
|
338
|
-
this.captureCurrentResult('success');
|
|
158
|
+
this.captureCurrentResult('success', st);
|
|
339
159
|
return renderedFile;
|
|
340
160
|
});
|
|
341
161
|
})
|
|
@@ -354,33 +174,6 @@ export class RenderContext {
|
|
|
354
174
|
}
|
|
355
175
|
return output;
|
|
356
176
|
}
|
|
357
|
-
/**
|
|
358
|
-
* Executes a function within a tracing context for performance monitoring.
|
|
359
|
-
*
|
|
360
|
-
* This method wraps function execution with distributed tracing capabilities,
|
|
361
|
-
* allowing performance monitoring and debugging of the rendering pipeline.
|
|
362
|
-
* It integrates with the stack trail to provide hierarchical tracing.
|
|
363
|
-
*
|
|
364
|
-
* @template T - The return type of the traced function
|
|
365
|
-
* @param token - Trace identifier (string or array of strings)
|
|
366
|
-
* @param fn - Function to execute within the trace context
|
|
367
|
-
* @returns The result of executing the traced function
|
|
368
|
-
*
|
|
369
|
-
* @example
|
|
370
|
-
* ```typescript
|
|
371
|
-
* const result = renderContext.trace('format-file', () => {
|
|
372
|
-
* return biome.formatContent(projectKey, content, { filePath: 'file.ts' });
|
|
373
|
-
* });
|
|
374
|
-
*
|
|
375
|
-
* // With hierarchical tracing
|
|
376
|
-
* const result = renderContext.trace(['render', 'format'], () => {
|
|
377
|
-
* return complexFormattingOperation();
|
|
378
|
-
* });
|
|
379
|
-
* ```
|
|
380
|
-
*/
|
|
381
|
-
trace(token, fn) {
|
|
382
|
-
return tracer(__classPrivateFieldGet(this, _RenderContext_stackTrail, "f"), token, fn);
|
|
383
|
-
}
|
|
384
177
|
/**
|
|
385
178
|
* Retrieves a file from the context by its normalized path.
|
|
386
179
|
*
|
|
@@ -445,7 +238,7 @@ export class RenderContext {
|
|
|
445
238
|
return file.definitions.get(name);
|
|
446
239
|
}
|
|
447
240
|
}
|
|
448
|
-
_RenderContext_prettierConfig = new WeakMap()
|
|
241
|
+
_RenderContext_prettierConfig = new WeakMap();
|
|
449
242
|
/**
|
|
450
243
|
* Renders a single file with formatting and metadata calculation.
|
|
451
244
|
*
|
|
@@ -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"}
|