@skmtc/core 0.0.789 → 0.0.791

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.
Files changed (37) hide show
  1. package/esm/context/RenderContext.d.ts +190 -0
  2. package/esm/context/RenderContext.d.ts.map +1 -1
  3. package/esm/context/RenderContext.js +179 -0
  4. package/esm/oas/boolean/Boolean.d.ts +142 -1
  5. package/esm/oas/boolean/Boolean.d.ts.map +1 -1
  6. package/esm/oas/boolean/Boolean.js +130 -1
  7. package/esm/oas/number/Number.d.ts +179 -1
  8. package/esm/oas/number/Number.d.ts.map +1 -1
  9. package/esm/oas/number/Number.js +161 -1
  10. package/esm/oas/parameter/Parameter.d.ts +160 -0
  11. package/esm/oas/parameter/Parameter.d.ts.map +1 -1
  12. package/esm/oas/parameter/Parameter.js +144 -0
  13. package/esm/oas/response/Response.d.ts +190 -0
  14. package/esm/oas/response/Response.d.ts.map +1 -1
  15. package/esm/oas/response/Response.js +183 -0
  16. package/esm/oas/void/Void.d.ts +130 -3
  17. package/esm/oas/void/Void.d.ts.map +1 -1
  18. package/esm/oas/void/Void.js +125 -3
  19. package/package.json +1 -1
  20. package/script/context/RenderContext.d.ts +190 -0
  21. package/script/context/RenderContext.d.ts.map +1 -1
  22. package/script/context/RenderContext.js +179 -0
  23. package/script/oas/boolean/Boolean.d.ts +142 -1
  24. package/script/oas/boolean/Boolean.d.ts.map +1 -1
  25. package/script/oas/boolean/Boolean.js +130 -1
  26. package/script/oas/number/Number.d.ts +179 -1
  27. package/script/oas/number/Number.d.ts.map +1 -1
  28. package/script/oas/number/Number.js +161 -1
  29. package/script/oas/parameter/Parameter.d.ts +160 -0
  30. package/script/oas/parameter/Parameter.d.ts.map +1 -1
  31. package/script/oas/parameter/Parameter.js +144 -0
  32. package/script/oas/response/Response.d.ts +190 -0
  33. package/script/oas/response/Response.d.ts.map +1 -1
  34. package/script/oas/response/Response.js +183 -0
  35. package/script/oas/void/Void.d.ts +130 -3
  36. package/script/oas/void/Void.d.ts.map +1 -1
  37. package/script/oas/void/Void.js +125 -3
@@ -1 +1 @@
1
- {"version":3,"file":"Void.d.ts","sourceRoot":"","sources":["../../../src/oas/void/Void.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;GAIG;AACH,qBAAa,OAAO;IAClB;;;OAGG;IACH,OAAO,EAAG,QAAQ,CAAS;IAC3B;;OAEG;IACH,IAAI,EAAG,MAAM,CAAS;IACtB;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;gBAEnB,MAAM,GAAE,UAAe;IAKnC,MAAM,CAAC,KAAK,IAAI,OAAO;IAIvB,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,OAAO;IAIlB,WAAW,IAAI,OAAO;CAGvB"}
1
+ {"version":3,"file":"Void.d.ts","sourceRoot":"","sources":["../../../src/oas/void/Void.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8HG;AACH,qBAAa,OAAO;IAClB;;;OAGG;IACH,OAAO,EAAG,QAAQ,CAAS;IAC3B;;OAEG;IACH,IAAI,EAAG,MAAM,CAAS;IACtB;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;gBAEnB,MAAM,GAAE,UAAe;IAKnC,MAAM,CAAC,KAAK,IAAI,OAAO;IAIvB,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,OAAO;IAIlB,WAAW,IAAI,OAAO;CAGvB"}
@@ -1,8 +1,130 @@
1
1
  import "../../_dnt.polyfills.js";
2
2
  /**
3
- * Object representing a void type in the OpenAPI Specification.
4
- * It is used to describe an absence of a value such as when no
5
- * content is returned by an operation.
3
+ * Represents a void (empty) schema in the OpenAPI Specification.
4
+ *
5
+ * The `OasVoid` class represents the absence of a value or content, commonly used
6
+ * in scenarios where operations don't return any content (like HTTP 204 No Content
7
+ * responses), optional properties that might not be present, or fallback cases
8
+ * in schema processing where no specific type is defined.
9
+ *
10
+ * This class serves as a type-safe representation of "nothing" in the OpenAPI
11
+ * type system, enabling proper handling of void responses and empty schemas
12
+ * throughout the SKMTC pipeline.
13
+ *
14
+ * ## Key Features
15
+ *
16
+ * - **Empty Content Representation**: Models operations that return no content
17
+ * - **Type Safety**: Provides a concrete type for void/empty scenarios
18
+ * - **Schema Processing**: Handles missing or undefined schema definitions
19
+ * - **Factory Pattern**: Convenient `empty()` static method for common usage
20
+ * - **Pipeline Integration**: Works seamlessly with the SKMTC processing pipeline
21
+ *
22
+ * @example Basic void schema for empty responses
23
+ * ```typescript
24
+ * import { OasVoid } from '@skmtc/core';
25
+ *
26
+ * const emptyResponse = new OasVoid({
27
+ * title: 'No Content',
28
+ * description: 'Operation completed successfully with no response body'
29
+ * });
30
+ *
31
+ * // Used for HTTP 204 No Content responses
32
+ * ```
33
+ *
34
+ * @example Using the empty factory method
35
+ * ```typescript
36
+ * const voidSchema = OasVoid.empty();
37
+ *
38
+ * // Equivalent to new OasVoid({})
39
+ * // Commonly used as a fallback or placeholder
40
+ * ```
41
+ *
42
+ * @example In operation responses
43
+ * ```typescript
44
+ * const deleteOperation = new OasOperation({
45
+ * path: '/users/{id}',
46
+ * method: 'delete',
47
+ * responses: {
48
+ * '204': new OasResponse({
49
+ * description: 'User deleted successfully',
50
+ * content: {
51
+ * // No content for successful deletion
52
+ * }
53
+ * }),
54
+ * '404': new OasResponse({
55
+ * description: 'User not found'
56
+ * })
57
+ * }
58
+ * });
59
+ *
60
+ * // The void response indicates successful deletion with no return value
61
+ * ```
62
+ *
63
+ * @example As a schema fallback
64
+ * ```typescript
65
+ * function processSchema(schema: OasSchema | undefined): OasSchema {
66
+ * if (!schema) {
67
+ * return OasVoid.empty(); // Fallback for missing schemas
68
+ * }
69
+ * return schema;
70
+ * }
71
+ *
72
+ * // Ensures type safety even when schemas are missing
73
+ * ```
74
+ *
75
+ * @example In optional object properties
76
+ * ```typescript
77
+ * const userProfile = new OasObject({
78
+ * properties: {
79
+ * name: new OasString({ description: 'User name' }),
80
+ * avatar: new OasString({
81
+ * description: 'Avatar URL',
82
+ * nullable: true
83
+ * }),
84
+ * // Some properties might be processed as void if not defined
85
+ * metadata: processOptionalSchema(rawSchema.metadata) // might return OasVoid
86
+ * }
87
+ * });
88
+ * ```
89
+ *
90
+ * @example HTTP operations with void responses
91
+ * ```typescript
92
+ * // Common HTTP operations that return void/empty content:
93
+ *
94
+ * // DELETE - Resource removal
95
+ * const deleteResponse = new OasVoid({
96
+ * title: 'Deletion Successful',
97
+ * description: 'Resource was successfully deleted'
98
+ * });
99
+ *
100
+ * // PUT - Update with no response body
101
+ * const updateResponse = new OasVoid({
102
+ * title: 'Update Successful',
103
+ * description: 'Resource was successfully updated'
104
+ * });
105
+ *
106
+ * // POST - Action with no return value
107
+ * const actionResponse = new OasVoid({
108
+ * title: 'Action Completed',
109
+ * description: 'Action was successfully performed'
110
+ * });
111
+ * ```
112
+ *
113
+ * @example In code generation
114
+ * ```typescript
115
+ * class TypeScriptGenerator extends ModelBase {
116
+ * generateType(schema: OasSchema): string {
117
+ * if (schema.type === 'void') {
118
+ * return 'void'; // TypeScript void type
119
+ * }
120
+ * // Handle other types...
121
+ * return 'unknown';
122
+ * }
123
+ * }
124
+ *
125
+ * // Generates:
126
+ * // async function deleteUser(id: string): Promise<void>
127
+ * ```
6
128
  */
7
129
  export class OasVoid {
8
130
  constructor(fields = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.789",
3
+ "version": "0.0.791",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/skmtc/skmtc.git"
@@ -8,16 +8,206 @@ import type * as log from '../deps/jsr.io/@std/log/0.224.14/mod.js';
8
8
  import { File } from '../dsl/File.js';
9
9
  import type { Preview, Mapping } from '../types/Preview.js';
10
10
  import type { JsonFile } from '../dsl/JsonFile.js';
11
+ /**
12
+ * Constructor arguments for {@link RenderContext}.
13
+ */
11
14
  type ConstructorArgs = {
15
+ /** Map of generated files to render */
12
16
  files: Map<string, File | JsonFile>;
17
+ /** Preview data for generated content */
13
18
  previews: Record<string, Record<string, Preview>>;
19
+ /** Mapping data for file relationships */
14
20
  mappings: Record<string, Record<string, Mapping>>;
21
+ /** Optional Prettier configuration for code formatting */
15
22
  prettierConfig?: PrettierConfigType;
23
+ /** Base path for resolving file paths */
16
24
  basePath: string | undefined;
25
+ /** Stack trail for distributed tracing */
17
26
  stackTrail: StackTrail;
27
+ /** Logger instance for debug information */
18
28
  logger: log.Logger;
29
+ /** Function to capture result status */
19
30
  captureCurrentResult: (result: ResultType) => void;
20
31
  };
32
+ /**
33
+ * The rendering context for the final phase of the SKMTC transformation pipeline.
34
+ *
35
+ * `RenderContext` is responsible for taking the generated artifacts from the generation
36
+ * phase and rendering them into their final form with proper formatting, path resolution,
37
+ * and file preparation. It handles code formatting via Prettier, path normalization,
38
+ * and produces the final artifacts ready for writing to the filesystem.
39
+ *
40
+ * This context represents the culmination of the three-phase SKMTC pipeline, transforming
41
+ * generator outputs into production-ready code files with proper formatting and structure.
42
+ *
43
+ * ## Key Features
44
+ *
45
+ * - **Code Formatting**: Automatic Prettier formatting for generated TypeScript/JavaScript code
46
+ * - **Path Resolution**: Intelligent path resolution with base path support
47
+ * - **Content Collation**: Combines all generated content into organized file structures
48
+ * - **Metadata Generation**: Tracks file statistics (lines, characters) and relationships
49
+ * - **Error Tracking**: Comprehensive error handling with Sentry integration
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 Prettier configuration
82
+ * ```typescript
83
+ * const renderContext = new RenderContext({
84
+ * files: generatedFiles,
85
+ * previews: {},
86
+ * mappings: {},
87
+ * prettierConfig: {
88
+ * parser: 'typescript',
89
+ * printWidth: 120,
90
+ * tabWidth: 2,
91
+ * semi: true,
92
+ * singleQuote: true,
93
+ * trailingComma: 'es5',
94
+ * bracketSpacing: true,
95
+ * arrowParens: 'avoid'
96
+ * },
97
+ * basePath: './packages/api-client/src',
98
+ * stackTrail: stack,
99
+ * logger: logger,
100
+ * captureCurrentResult: resultHandler
101
+ * });
102
+ *
103
+ * const result = await renderContext.render();
104
+ *
105
+ * // All TypeScript files are automatically formatted
106
+ * console.log('Formatted files:', Object.keys(result.artifacts).length);
107
+ * ```
108
+ *
109
+ * @example Processing render results
110
+ * ```typescript
111
+ * const rendered = await renderContext.render();
112
+ *
113
+ * // Analyze file statistics
114
+ * const totalLines = Object.values(rendered.files)
115
+ * .reduce((sum, file) => sum + file.lines, 0);
116
+ * const totalChars = Object.values(rendered.files)
117
+ * .reduce((sum, file) => sum + file.characters, 0);
118
+ *
119
+ * console.log(`Generated ${Object.keys(rendered.artifacts).length} files`);
120
+ * console.log(`Total lines: ${totalLines}`);
121
+ * console.log(`Total characters: ${totalChars}`);
122
+ *
123
+ * // Check for large files
124
+ * const largeFiles = Object.entries(rendered.files)
125
+ * .filter(([_, metadata]) => metadata.lines > 1000)
126
+ * .map(([path, metadata]) => ({ path, lines: metadata.lines }));
127
+ *
128
+ * if (largeFiles.length > 0) {
129
+ * console.log('Large files detected:', largeFiles);
130
+ * }
131
+ *
132
+ * // Access preview and mapping data
133
+ * console.log('Previews available:', Object.keys(rendered.previews));
134
+ * console.log('Mappings available:', Object.keys(rendered.mappings));
135
+ * ```
136
+ *
137
+ * @example Integration with CoreContext
138
+ * ```typescript
139
+ * // Typically used within CoreContext.toArtifacts()
140
+ * class CustomCoreContext extends CoreContext {
141
+ * async renderWithPostProcessing(
142
+ * files: Map<string, File | JsonFile>,
143
+ * previews: Record<string, Record<string, Preview>>,
144
+ * mappings: Record<string, Record<string, Mapping>>
145
+ * ) {
146
+ * const renderContext = new RenderContext({
147
+ * files,
148
+ * previews,
149
+ * mappings,
150
+ * prettierConfig: this.prettierConfig,
151
+ * basePath: this.settings?.basePath,
152
+ * stackTrail: this.stackTrail,
153
+ * logger: this.logger,
154
+ * captureCurrentResult: this.captureCurrentResult.bind(this)
155
+ * });
156
+ *
157
+ * const rendered = await renderContext.render();
158
+ *
159
+ * // Post-process rendered files
160
+ * const processedArtifacts: Record<string, string> = {};
161
+ *
162
+ * for (const [path, content] of Object.entries(rendered.artifacts)) {
163
+ * // Add file headers, license notices, etc.
164
+ * const processedContent = this.addFileHeader(content, path);
165
+ * processedArtifacts[path] = processedContent;
166
+ * }
167
+ *
168
+ * return {
169
+ * ...rendered,
170
+ * artifacts: processedArtifacts
171
+ * };
172
+ * }
173
+ * }
174
+ * ```
175
+ *
176
+ * @example Error handling during rendering
177
+ * ```typescript
178
+ * try {
179
+ * const renderContext = new RenderContext({
180
+ * files: generatedFiles,
181
+ * previews: {},
182
+ * mappings: {},
183
+ * prettierConfig: prettierConfig,
184
+ * basePath: './invalid-path', // This might cause issues
185
+ * stackTrail: stack,
186
+ * logger: logger,
187
+ * captureCurrentResult: (result) => {
188
+ * if (result === 'error') {
189
+ * console.error('Render error detected');
190
+ * }
191
+ * }
192
+ * });
193
+ *
194
+ * const result = await renderContext.render();
195
+ *
196
+ * // Check if any files failed to render
197
+ * const failedFiles = Object.entries(result.files)
198
+ * .filter(([path, metadata]) => metadata.lines === 0)
199
+ * .map(([path]) => path);
200
+ *
201
+ * if (failedFiles.length > 0) {
202
+ * console.warn('Files with no content:', failedFiles);
203
+ * }
204
+ *
205
+ * } catch (error) {
206
+ * console.error('Render operation failed:', error);
207
+ * // Sentry automatically captures the error
208
+ * }
209
+ * ```
210
+ */
21
211
  export declare class RenderContext {
22
212
  #private;
23
213
  files: Map<string, File | JsonFile>;
@@ -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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,CAAA;IAElB,oBAAoB,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;gBACtC,EACV,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,MAAM,EACN,UAAU,EACV,oBAAoB,EACrB,EAAE,eAAe;IAWZ,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAiBhD,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAuC3C,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAIlD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ;IAU1C,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAO7D"}
@@ -56,6 +56,185 @@ const toResolvedArtifactPath_js_1 = require("../helpers/toResolvedArtifactPath.j
56
56
  const tracer_js_1 = require("../helpers/tracer.js");
57
57
  const File_js_1 = require("../dsl/File.js");
58
58
  const prettier = __importStar(require("prettier"));
59
+ /**
60
+ * The rendering context for the final phase of the SKMTC transformation pipeline.
61
+ *
62
+ * `RenderContext` is responsible for taking the generated artifacts from the generation
63
+ * phase and rendering them into their final form with proper formatting, path resolution,
64
+ * and file preparation. It handles code formatting via Prettier, path normalization,
65
+ * and produces the final artifacts ready for writing to the filesystem.
66
+ *
67
+ * This context represents the culmination of the three-phase SKMTC pipeline, transforming
68
+ * generator outputs into production-ready code files with proper formatting and structure.
69
+ *
70
+ * ## Key Features
71
+ *
72
+ * - **Code Formatting**: Automatic Prettier formatting for generated TypeScript/JavaScript code
73
+ * - **Path Resolution**: Intelligent path resolution with base path support
74
+ * - **Content Collation**: Combines all generated content into organized file structures
75
+ * - **Metadata Generation**: Tracks file statistics (lines, characters) and relationships
76
+ * - **Error Tracking**: Comprehensive error handling with Sentry integration
77
+ * - **Performance Monitoring**: Built-in tracing and performance measurement
78
+ *
79
+ * @example Basic rendering usage
80
+ * ```typescript
81
+ * import { RenderContext } from '@skmtc/core';
82
+ *
83
+ * const renderContext = new RenderContext({
84
+ * files: generatedFiles,
85
+ * previews: previewData,
86
+ * mappings: mappingData,
87
+ * prettierConfig: {
88
+ * semi: false,
89
+ * singleQuote: true,
90
+ * trailingComma: 'all'
91
+ * },
92
+ * basePath: './src/generated',
93
+ * stackTrail: traceStack,
94
+ * logger: myLogger,
95
+ * captureCurrentResult: (result) => console.log(result)
96
+ * });
97
+ *
98
+ * const rendered = await renderContext.render();
99
+ *
100
+ * // Access rendered files
101
+ * Object.entries(rendered.artifacts).forEach(([path, content]) => {
102
+ * console.log(`Rendered ${path}: ${rendered.files[path].lines} lines`);
103
+ * // Write to filesystem
104
+ * await Deno.writeTextFile(path, content);
105
+ * });
106
+ * ```
107
+ *
108
+ * @example With custom Prettier configuration
109
+ * ```typescript
110
+ * const renderContext = new RenderContext({
111
+ * files: generatedFiles,
112
+ * previews: {},
113
+ * mappings: {},
114
+ * prettierConfig: {
115
+ * parser: 'typescript',
116
+ * printWidth: 120,
117
+ * tabWidth: 2,
118
+ * semi: true,
119
+ * singleQuote: true,
120
+ * trailingComma: 'es5',
121
+ * bracketSpacing: true,
122
+ * arrowParens: 'avoid'
123
+ * },
124
+ * basePath: './packages/api-client/src',
125
+ * stackTrail: stack,
126
+ * logger: logger,
127
+ * captureCurrentResult: resultHandler
128
+ * });
129
+ *
130
+ * const result = await renderContext.render();
131
+ *
132
+ * // All TypeScript files are automatically formatted
133
+ * console.log('Formatted files:', Object.keys(result.artifacts).length);
134
+ * ```
135
+ *
136
+ * @example Processing render results
137
+ * ```typescript
138
+ * const rendered = await renderContext.render();
139
+ *
140
+ * // Analyze file statistics
141
+ * const totalLines = Object.values(rendered.files)
142
+ * .reduce((sum, file) => sum + file.lines, 0);
143
+ * const totalChars = Object.values(rendered.files)
144
+ * .reduce((sum, file) => sum + file.characters, 0);
145
+ *
146
+ * console.log(`Generated ${Object.keys(rendered.artifacts).length} files`);
147
+ * console.log(`Total lines: ${totalLines}`);
148
+ * console.log(`Total characters: ${totalChars}`);
149
+ *
150
+ * // Check for large files
151
+ * const largeFiles = Object.entries(rendered.files)
152
+ * .filter(([_, metadata]) => metadata.lines > 1000)
153
+ * .map(([path, metadata]) => ({ path, lines: metadata.lines }));
154
+ *
155
+ * if (largeFiles.length > 0) {
156
+ * console.log('Large files detected:', largeFiles);
157
+ * }
158
+ *
159
+ * // Access preview and mapping data
160
+ * console.log('Previews available:', Object.keys(rendered.previews));
161
+ * console.log('Mappings available:', Object.keys(rendered.mappings));
162
+ * ```
163
+ *
164
+ * @example Integration with CoreContext
165
+ * ```typescript
166
+ * // Typically used within CoreContext.toArtifacts()
167
+ * class CustomCoreContext extends CoreContext {
168
+ * async renderWithPostProcessing(
169
+ * files: Map<string, File | JsonFile>,
170
+ * previews: Record<string, Record<string, Preview>>,
171
+ * mappings: Record<string, Record<string, Mapping>>
172
+ * ) {
173
+ * const renderContext = new RenderContext({
174
+ * files,
175
+ * previews,
176
+ * mappings,
177
+ * prettierConfig: this.prettierConfig,
178
+ * basePath: this.settings?.basePath,
179
+ * stackTrail: this.stackTrail,
180
+ * logger: this.logger,
181
+ * captureCurrentResult: this.captureCurrentResult.bind(this)
182
+ * });
183
+ *
184
+ * const rendered = await renderContext.render();
185
+ *
186
+ * // Post-process rendered files
187
+ * const processedArtifacts: Record<string, string> = {};
188
+ *
189
+ * for (const [path, content] of Object.entries(rendered.artifacts)) {
190
+ * // Add file headers, license notices, etc.
191
+ * const processedContent = this.addFileHeader(content, path);
192
+ * processedArtifacts[path] = processedContent;
193
+ * }
194
+ *
195
+ * return {
196
+ * ...rendered,
197
+ * artifacts: processedArtifacts
198
+ * };
199
+ * }
200
+ * }
201
+ * ```
202
+ *
203
+ * @example Error handling during rendering
204
+ * ```typescript
205
+ * try {
206
+ * const renderContext = new RenderContext({
207
+ * files: generatedFiles,
208
+ * previews: {},
209
+ * mappings: {},
210
+ * prettierConfig: prettierConfig,
211
+ * basePath: './invalid-path', // This might cause issues
212
+ * stackTrail: stack,
213
+ * logger: logger,
214
+ * captureCurrentResult: (result) => {
215
+ * if (result === 'error') {
216
+ * console.error('Render error detected');
217
+ * }
218
+ * }
219
+ * });
220
+ *
221
+ * const result = await renderContext.render();
222
+ *
223
+ * // Check if any files failed to render
224
+ * const failedFiles = Object.entries(result.files)
225
+ * .filter(([path, metadata]) => metadata.lines === 0)
226
+ * .map(([path]) => path);
227
+ *
228
+ * if (failedFiles.length > 0) {
229
+ * console.warn('Files with no content:', failedFiles);
230
+ * }
231
+ *
232
+ * } catch (error) {
233
+ * console.error('Render operation failed:', error);
234
+ * // Sentry automatically captures the error
235
+ * }
236
+ * ```
237
+ */
59
238
  class RenderContext {
60
239
  constructor({ files, previews, mappings, prettierConfig, basePath, logger, stackTrail, captureCurrentResult }) {
61
240
  Object.defineProperty(this, "files", {