@skmtc/core 0.0.800 → 0.0.802

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/esm/context/CoreContext.d.ts +0 -3
  2. package/esm/context/CoreContext.d.ts.map +1 -1
  3. package/esm/context/CoreContext.js +12 -17
  4. package/esm/context/GenerateContext.d.ts +14 -2
  5. package/esm/context/GenerateContext.d.ts.map +1 -1
  6. package/esm/context/RenderContext.d.ts +151 -2
  7. package/esm/context/RenderContext.d.ts.map +1 -1
  8. package/esm/context/RenderContext.js +185 -11
  9. package/esm/context/types.d.ts +30 -0
  10. package/esm/context/types.d.ts.map +1 -1
  11. package/esm/dsl/model/ModelBase.d.ts +1 -1
  12. package/esm/dsl/model/ModelBase.d.ts.map +1 -1
  13. package/esm/dsl/model/ModelDriver.d.ts +62 -0
  14. package/esm/dsl/model/ModelDriver.d.ts.map +1 -1
  15. package/esm/dsl/model/ModelDriver.js +63 -1
  16. package/esm/dsl/model/toModelBase.d.ts +66 -0
  17. package/esm/dsl/model/toModelBase.d.ts.map +1 -1
  18. package/esm/dsl/model/toModelBase.js +46 -0
  19. package/esm/dsl/model/toModelEntry.d.ts +63 -0
  20. package/esm/dsl/model/toModelEntry.d.ts.map +1 -1
  21. package/esm/dsl/model/toModelEntry.js +63 -0
  22. package/esm/dsl/operation/OperationBase.d.ts +3 -3
  23. package/esm/dsl/operation/OperationBase.d.ts.map +1 -1
  24. package/esm/dsl/operation/OperationDriver.d.ts +48 -0
  25. package/esm/dsl/operation/OperationDriver.d.ts.map +1 -1
  26. package/esm/dsl/operation/OperationDriver.js +49 -1
  27. package/esm/helpers/isEmpty.d.ts +1 -1
  28. package/esm/helpers/isEmpty.d.ts.map +1 -1
  29. package/esm/helpers/tracer.d.ts +1 -1
  30. package/esm/helpers/tracer.d.ts.map +1 -1
  31. package/esm/helpers/tracer.js +1 -1
  32. package/esm/mod.d.ts +51 -0
  33. package/esm/mod.d.ts.map +1 -1
  34. package/esm/mod.js +51 -0
  35. package/esm/oas/array/array-types.d.ts +20 -11
  36. package/esm/oas/array/array-types.d.ts.map +1 -1
  37. package/esm/oas/array/array-types.js +10 -0
  38. package/esm/oas/array/toArray.d.ts +111 -0
  39. package/esm/oas/array/toArray.d.ts.map +1 -1
  40. package/esm/oas/array/toArray.js +115 -3
  41. package/esm/oas/boolean/boolean-types.d.ts +1 -7
  42. package/esm/oas/boolean/boolean-types.d.ts.map +1 -1
  43. package/esm/oas/components/components-types.d.ts +19 -0
  44. package/esm/oas/components/components-types.d.ts.map +1 -0
  45. package/esm/oas/components/components-types.js +21 -0
  46. package/esm/oas/contact/contact-types.d.ts +9 -0
  47. package/esm/oas/contact/contact-types.d.ts.map +1 -0
  48. package/esm/oas/contact/contact-types.js +7 -0
  49. package/esm/oas/discriminator/discriminator-types.d.ts +1 -5
  50. package/esm/oas/discriminator/discriminator-types.d.ts.map +1 -1
  51. package/esm/oas/document/document-types.d.ts +16 -0
  52. package/esm/oas/document/document-types.d.ts.map +1 -0
  53. package/esm/oas/document/document-types.js +18 -0
  54. package/esm/oas/example/example-types.d.ts +1 -6
  55. package/esm/oas/example/example-types.d.ts.map +1 -1
  56. package/esm/oas/header/header-types.d.ts +50 -0
  57. package/esm/oas/header/header-types.d.ts.map +1 -0
  58. package/esm/oas/header/header-types.js +30 -0
  59. package/esm/oas/info/info-types.d.ts +14 -0
  60. package/esm/oas/info/info-types.d.ts.map +1 -0
  61. package/esm/oas/info/info-types.js +13 -0
  62. package/esm/oas/integer/integer-types.d.ts +3 -17
  63. package/esm/oas/integer/integer-types.d.ts.map +1 -1
  64. package/esm/oas/license/license-types.d.ts +9 -0
  65. package/esm/oas/license/license-types.d.ts.map +1 -0
  66. package/esm/oas/license/license-types.js +7 -0
  67. package/esm/oas/mediaType/mediaType-types.d.ts +1 -11
  68. package/esm/oas/mediaType/mediaType-types.d.ts.map +1 -1
  69. package/esm/oas/number/number-types.d.ts +2 -16
  70. package/esm/oas/number/number-types.d.ts.map +1 -1
  71. package/esm/oas/operation/operation-types.d.ts +22 -0
  72. package/esm/oas/operation/operation-types.d.ts.map +1 -0
  73. package/esm/oas/operation/operation-types.js +35 -0
  74. package/esm/oas/parameter/parameter-types.d.ts +3 -58
  75. package/esm/oas/parameter/parameter-types.d.ts.map +1 -1
  76. package/esm/oas/pathItem/pathItem-types.d.ts +12 -0
  77. package/esm/oas/pathItem/pathItem-types.d.ts.map +1 -0
  78. package/esm/oas/pathItem/pathItem-types.js +12 -0
  79. package/esm/oas/requestBody/requestBody-types.d.ts +10 -0
  80. package/esm/oas/requestBody/requestBody-types.d.ts.map +1 -0
  81. package/esm/oas/requestBody/requestBody-types.js +9 -0
  82. package/esm/oas/response/response-types.d.ts +12 -0
  83. package/esm/oas/response/response-types.d.ts.map +1 -0
  84. package/esm/oas/response/response-types.js +11 -0
  85. package/esm/oas/schema/toSchemasV3.js +2 -2
  86. package/esm/oas/server/toServerV3.d.ts.map +1 -1
  87. package/esm/oas/string/string-types.d.ts +2 -29
  88. package/esm/oas/string/string-types.d.ts.map +1 -1
  89. package/esm/oas/string/toString.d.ts +125 -1
  90. package/esm/oas/string/toString.d.ts.map +1 -1
  91. package/esm/oas/string/toString.js +119 -0
  92. package/esm/oas/tag/tag-types.d.ts +8 -0
  93. package/esm/oas/tag/tag-types.d.ts.map +1 -0
  94. package/esm/oas/tag/tag-types.js +8 -0
  95. package/esm/oas/union/union-types.d.ts +1 -12
  96. package/esm/oas/union/union-types.d.ts.map +1 -1
  97. package/esm/oas/unknown/unknown-types.d.ts +1 -7
  98. package/esm/oas/unknown/unknown-types.d.ts.map +1 -1
  99. package/esm/types/Preview.d.ts +37 -0
  100. package/esm/types/Preview.d.ts.map +1 -1
  101. package/esm/types/Preview.js +37 -0
  102. package/esm/types/Settings.d.ts +35 -0
  103. package/esm/types/Settings.d.ts.map +1 -1
  104. package/esm/types/Settings.js +27 -0
  105. package/esm/typescript/FunctionParameter.d.ts +4 -4
  106. package/esm/typescript/FunctionParameter.d.ts.map +1 -1
  107. package/esm/typescript/List.d.ts +40 -2
  108. package/esm/typescript/List.d.ts.map +1 -1
  109. package/esm/typescript/List.js +32 -0
  110. package/package.json +1 -1
  111. package/script/context/CoreContext.d.ts +0 -3
  112. package/script/context/CoreContext.d.ts.map +1 -1
  113. package/script/context/CoreContext.js +12 -17
  114. package/script/context/GenerateContext.d.ts +14 -2
  115. package/script/context/GenerateContext.d.ts.map +1 -1
  116. package/script/context/RenderContext.d.ts +151 -2
  117. package/script/context/RenderContext.d.ts.map +1 -1
  118. package/script/context/RenderContext.js +185 -11
  119. package/script/context/types.d.ts +30 -0
  120. package/script/context/types.d.ts.map +1 -1
  121. package/script/dsl/model/ModelBase.d.ts +1 -1
  122. package/script/dsl/model/ModelBase.d.ts.map +1 -1
  123. package/script/dsl/model/ModelDriver.d.ts +62 -0
  124. package/script/dsl/model/ModelDriver.d.ts.map +1 -1
  125. package/script/dsl/model/ModelDriver.js +63 -1
  126. package/script/dsl/model/toModelBase.d.ts +66 -0
  127. package/script/dsl/model/toModelBase.d.ts.map +1 -1
  128. package/script/dsl/model/toModelBase.js +46 -0
  129. package/script/dsl/model/toModelEntry.d.ts +63 -0
  130. package/script/dsl/model/toModelEntry.d.ts.map +1 -1
  131. package/script/dsl/model/toModelEntry.js +63 -0
  132. package/script/dsl/operation/OperationBase.d.ts +3 -3
  133. package/script/dsl/operation/OperationBase.d.ts.map +1 -1
  134. package/script/dsl/operation/OperationDriver.d.ts +48 -0
  135. package/script/dsl/operation/OperationDriver.d.ts.map +1 -1
  136. package/script/dsl/operation/OperationDriver.js +49 -1
  137. package/script/helpers/isEmpty.d.ts +1 -1
  138. package/script/helpers/isEmpty.d.ts.map +1 -1
  139. package/script/helpers/tracer.d.ts +1 -1
  140. package/script/helpers/tracer.d.ts.map +1 -1
  141. package/script/helpers/tracer.js +1 -1
  142. package/script/mod.d.ts +51 -0
  143. package/script/mod.d.ts.map +1 -1
  144. package/script/mod.js +51 -0
  145. package/script/oas/array/array-types.d.ts +20 -11
  146. package/script/oas/array/array-types.d.ts.map +1 -1
  147. package/script/oas/array/array-types.js +11 -1
  148. package/script/oas/array/toArray.d.ts +111 -0
  149. package/script/oas/array/toArray.d.ts.map +1 -1
  150. package/script/oas/array/toArray.js +114 -2
  151. package/script/oas/boolean/boolean-types.d.ts +1 -7
  152. package/script/oas/boolean/boolean-types.d.ts.map +1 -1
  153. package/script/oas/components/components-types.d.ts +19 -0
  154. package/script/oas/components/components-types.d.ts.map +1 -0
  155. package/script/oas/components/components-types.js +57 -0
  156. package/script/oas/contact/contact-types.d.ts +9 -0
  157. package/script/oas/contact/contact-types.d.ts.map +1 -0
  158. package/script/oas/contact/contact-types.js +43 -0
  159. package/script/oas/discriminator/discriminator-types.d.ts +1 -5
  160. package/script/oas/discriminator/discriminator-types.d.ts.map +1 -1
  161. package/script/oas/document/document-types.d.ts +16 -0
  162. package/script/oas/document/document-types.d.ts.map +1 -0
  163. package/script/oas/document/document-types.js +54 -0
  164. package/script/oas/example/example-types.d.ts +1 -6
  165. package/script/oas/example/example-types.d.ts.map +1 -1
  166. package/script/oas/header/header-types.d.ts +50 -0
  167. package/script/oas/header/header-types.d.ts.map +1 -0
  168. package/script/oas/header/header-types.js +66 -0
  169. package/script/oas/info/info-types.d.ts +14 -0
  170. package/script/oas/info/info-types.d.ts.map +1 -0
  171. package/script/oas/info/info-types.js +49 -0
  172. package/script/oas/integer/integer-types.d.ts +3 -17
  173. package/script/oas/integer/integer-types.d.ts.map +1 -1
  174. package/script/oas/license/license-types.d.ts +9 -0
  175. package/script/oas/license/license-types.d.ts.map +1 -0
  176. package/script/oas/license/license-types.js +43 -0
  177. package/script/oas/mediaType/mediaType-types.d.ts +1 -11
  178. package/script/oas/mediaType/mediaType-types.d.ts.map +1 -1
  179. package/script/oas/number/number-types.d.ts +2 -16
  180. package/script/oas/number/number-types.d.ts.map +1 -1
  181. package/script/oas/operation/operation-types.d.ts +22 -0
  182. package/script/oas/operation/operation-types.d.ts.map +1 -0
  183. package/script/oas/operation/operation-types.js +71 -0
  184. package/script/oas/parameter/parameter-types.d.ts +3 -58
  185. package/script/oas/parameter/parameter-types.d.ts.map +1 -1
  186. package/script/oas/pathItem/pathItem-types.d.ts +12 -0
  187. package/script/oas/pathItem/pathItem-types.d.ts.map +1 -0
  188. package/script/oas/pathItem/pathItem-types.js +48 -0
  189. package/script/oas/requestBody/requestBody-types.d.ts +10 -0
  190. package/script/oas/requestBody/requestBody-types.d.ts.map +1 -0
  191. package/script/oas/requestBody/requestBody-types.js +45 -0
  192. package/script/oas/response/response-types.d.ts +12 -0
  193. package/script/oas/response/response-types.d.ts.map +1 -0
  194. package/script/oas/response/response-types.js +47 -0
  195. package/script/oas/schema/toSchemasV3.js +2 -2
  196. package/script/oas/server/toServerV3.d.ts.map +1 -1
  197. package/script/oas/string/string-types.d.ts +2 -29
  198. package/script/oas/string/string-types.d.ts.map +1 -1
  199. package/script/oas/string/toString.d.ts +125 -1
  200. package/script/oas/string/toString.d.ts.map +1 -1
  201. package/script/oas/string/toString.js +119 -0
  202. package/script/oas/tag/tag-types.d.ts +8 -0
  203. package/script/oas/tag/tag-types.d.ts.map +1 -0
  204. package/script/oas/tag/tag-types.js +44 -0
  205. package/script/oas/union/union-types.d.ts +1 -12
  206. package/script/oas/union/union-types.d.ts.map +1 -1
  207. package/script/oas/unknown/unknown-types.d.ts +1 -7
  208. package/script/oas/unknown/unknown-types.d.ts.map +1 -1
  209. package/script/types/Preview.d.ts +37 -0
  210. package/script/types/Preview.d.ts.map +1 -1
  211. package/script/types/Preview.js +37 -0
  212. package/script/types/Settings.d.ts +35 -0
  213. package/script/types/Settings.d.ts.map +1 -1
  214. package/script/types/Settings.js +27 -0
  215. package/script/typescript/FunctionParameter.d.ts +4 -4
  216. package/script/typescript/FunctionParameter.d.ts.map +1 -1
  217. package/script/typescript/List.d.ts +40 -2
  218. package/script/typescript/List.d.ts.map +1 -1
  219. package/script/typescript/List.js +32 -0
@@ -9,7 +9,7 @@ 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, _RenderContext_stackTrail;
12
+ var _RenderContext_prettierConfig, _RenderContext_logger, _RenderContext_stackTrail;
13
13
  import * as Sentry from '@sentry/node';
14
14
  import invariant from 'tiny-invariant';
15
15
  import { normalize } from '../deps/jsr.io/@std/path/1.1.2/normalize.js';
@@ -138,7 +138,7 @@ import * as prettier from 'prettier';
138
138
  * prettierConfig: this.prettierConfig,
139
139
  * basePath: this.settings?.basePath,
140
140
  * stackTrail: this.stackTrail,
141
- * logger: this.logger,
141
+ * logger: this.#logger,
142
142
  * captureCurrentResult: this.captureCurrentResult.bind(this)
143
143
  * });
144
144
  *
@@ -197,39 +197,50 @@ import * as prettier from 'prettier';
197
197
  * ```
198
198
  */
199
199
  export class RenderContext {
200
+ /**
201
+ * Creates a new RenderContext instance with the specified configuration.
202
+ *
203
+ * Initializes the rendering context with files to render, preview data,
204
+ * formatting configuration, and logging/tracing infrastructure.
205
+ *
206
+ * @param args - Constructor arguments containing all required configuration
207
+ */
200
208
  constructor({ files, previews, mappings, prettierConfig, basePath, logger, stackTrail, captureCurrentResult }) {
209
+ /** Map of generated files to render */
201
210
  Object.defineProperty(this, "files", {
202
211
  enumerable: true,
203
212
  configurable: true,
204
213
  writable: true,
205
214
  value: void 0
206
215
  });
216
+ /** Preview data for generated content */
207
217
  Object.defineProperty(this, "previews", {
208
218
  enumerable: true,
209
219
  configurable: true,
210
220
  writable: true,
211
221
  value: void 0
212
222
  });
223
+ /** Mapping data for file relationships */
213
224
  Object.defineProperty(this, "mappings", {
214
225
  enumerable: true,
215
226
  configurable: true,
216
227
  writable: true,
217
228
  value: void 0
218
229
  });
230
+ /** Optional Prettier configuration for code formatting */
219
231
  _RenderContext_prettierConfig.set(this, void 0);
232
+ /** Base path for resolving file paths */
220
233
  Object.defineProperty(this, "basePath", {
221
234
  enumerable: true,
222
235
  configurable: true,
223
236
  writable: true,
224
237
  value: void 0
225
238
  });
226
- Object.defineProperty(this, "logger", {
227
- enumerable: true,
228
- configurable: true,
229
- writable: true,
230
- value: void 0
231
- });
239
+ /** Logger instance for debug information */
240
+ _RenderContext_logger.set(this, void 0);
241
+ /** Stack trail for distributed tracing */
232
242
  _RenderContext_stackTrail.set(this, void 0);
243
+ /** Function to capture result status */
233
244
  Object.defineProperty(this, "captureCurrentResult", {
234
245
  enumerable: true,
235
246
  configurable: true,
@@ -241,10 +252,44 @@ export class RenderContext {
241
252
  this.mappings = mappings;
242
253
  __classPrivateFieldSet(this, _RenderContext_prettierConfig, prettierConfig, "f");
243
254
  this.basePath = basePath;
244
- this.logger = logger;
255
+ __classPrivateFieldSet(this, _RenderContext_logger, logger, "f");
245
256
  __classPrivateFieldSet(this, _RenderContext_stackTrail, stackTrail, "f");
246
257
  this.captureCurrentResult = captureCurrentResult;
247
258
  }
259
+ /**
260
+ * Renders all files in the context to their final formatted form.
261
+ *
262
+ * This is the main rendering method that orchestrates the collation and
263
+ * formatting of all generated files. It processes files through Prettier
264
+ * formatting (if configured), resolves paths, and produces the final
265
+ * artifacts ready for writing to the filesystem.
266
+ *
267
+ * The method is wrapped in Sentry tracing spans for performance monitoring
268
+ * and includes both collation and artifact preparation phases.
269
+ *
270
+ * @returns Promise resolving to render result containing artifacts, file metadata, previews, and mappings
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * const renderContext = new RenderContext({
275
+ * files: generatedFiles,
276
+ * previews: previewData,
277
+ * mappings: mappingData,
278
+ * prettierConfig: { semi: false, singleQuote: true },
279
+ * basePath: './src/generated',
280
+ * stackTrail: traceStack,
281
+ * logger: logger,
282
+ * captureCurrentResult: resultHandler
283
+ * });
284
+ *
285
+ * const result = await renderContext.render();
286
+ *
287
+ * // Access rendered files
288
+ * Object.entries(result.artifacts).forEach(([path, content]) => {
289
+ * console.log(`Rendered ${path}: ${result.files[path].lines} lines`);
290
+ * });
291
+ * ```
292
+ */
248
293
  async render() {
249
294
  return await Sentry.startSpan({ name: 'Render artifacts' }, async () => {
250
295
  const result = await Sentry.startSpan({ name: 'Collate content' }, async () => {
@@ -259,6 +304,33 @@ export class RenderContext {
259
304
  return rendered;
260
305
  });
261
306
  }
307
+ /**
308
+ * Collates all files in the context into a unified render result.
309
+ *
310
+ * This method processes each file in the context through the rendering pipeline,
311
+ * applying Prettier formatting and path resolution. It coordinates the parallel
312
+ * processing of all files and aggregates the results into a single output structure.
313
+ *
314
+ * The collation process includes:
315
+ * - File content rendering with optional Prettier formatting
316
+ * - Path resolution using base path configuration
317
+ * - Metadata calculation (line count, character count)
318
+ * - Result aggregation into artifacts and file metadata maps
319
+ *
320
+ * @returns Promise resolving to collated files with artifacts and metadata
321
+ *
322
+ * @example
323
+ * ```typescript
324
+ * const collated = await renderContext.collate();
325
+ *
326
+ * // Access rendered file content
327
+ * console.log(collated.artifacts['/path/to/file.ts']);
328
+ *
329
+ * // Access file metadata
330
+ * console.log(collated.files['/path/to/file.ts'].lines);
331
+ * console.log(collated.files['/path/to/file.ts'].characters);
332
+ * ```
333
+ */
262
334
  async collate() {
263
335
  const fileEntries = Array.from(this.files.entries());
264
336
  const fileObjectPromises = fileEntries
@@ -290,22 +362,124 @@ export class RenderContext {
290
362
  }
291
363
  return output;
292
364
  }
365
+ /**
366
+ * Executes a function within a tracing context for performance monitoring.
367
+ *
368
+ * This method wraps function execution with distributed tracing capabilities,
369
+ * allowing performance monitoring and debugging of the rendering pipeline.
370
+ * It integrates with the stack trail to provide hierarchical tracing.
371
+ *
372
+ * @template T - The return type of the traced function
373
+ * @param token - Trace identifier (string or array of strings)
374
+ * @param fn - Function to execute within the trace context
375
+ * @returns The result of executing the traced function
376
+ *
377
+ * @example
378
+ * ```typescript
379
+ * const result = renderContext.trace('format-file', () => {
380
+ * return prettier.format(content, prettierConfig);
381
+ * });
382
+ *
383
+ * // With hierarchical tracing
384
+ * const result = renderContext.trace(['render', 'format'], () => {
385
+ * return complexFormattingOperation();
386
+ * });
387
+ * ```
388
+ */
293
389
  trace(token, fn) {
294
- return tracer(__classPrivateFieldGet(this, _RenderContext_stackTrail, "f"), token, fn, this.logger);
390
+ return tracer(__classPrivateFieldGet(this, _RenderContext_stackTrail, "f"), token, fn, __classPrivateFieldGet(this, _RenderContext_logger, "f"));
295
391
  }
392
+ /**
393
+ * Retrieves a file from the context by its normalized path.
394
+ *
395
+ * This method looks up a file in the context's file map using path normalization
396
+ * to ensure consistent path resolution. It validates that the requested file
397
+ * exists and throws an error if not found.
398
+ *
399
+ * @param filePath - The file path to retrieve (will be normalized)
400
+ * @returns The File or JsonFile instance
401
+ * @throws {Error} When the file is not found in the context
402
+ *
403
+ * @example
404
+ * ```typescript
405
+ * const file = renderContext.getFile('./src/models/User.ts');
406
+ * console.log(file.toString()); // Access file content
407
+ *
408
+ * // Works with various path formats
409
+ * const sameFile = renderContext.getFile('src/models/User.ts');
410
+ * const alsoSameFile = renderContext.getFile('/absolute/path/src/models/User.ts');
411
+ * ```
412
+ */
296
413
  getFile(filePath) {
297
414
  const normalisedPath = normalize(filePath);
298
415
  const currentFile = this.files.get(normalisedPath);
299
416
  invariant(currentFile, `File not found during render phase: ${normalisedPath}`);
300
417
  return currentFile;
301
418
  }
419
+ /**
420
+ * Picks a specific definition from a file in the context.
421
+ *
422
+ * This method retrieves a named definition (type, interface, etc.) from
423
+ * a specific file in the context. It validates that the target file is
424
+ * a File type (not JsonFile) and returns the requested definition if found.
425
+ *
426
+ * @param args - Object containing the definition name and export path
427
+ * @param args.name - The name of the definition to retrieve
428
+ * @param args.exportPath - The path to the file containing the definition
429
+ * @returns The Definition instance if found, undefined otherwise
430
+ * @throws {Error} When the file is not found or is not a File type
431
+ *
432
+ * @example
433
+ * ```typescript
434
+ * const userDefinition = renderContext.pick({
435
+ * name: 'User',
436
+ * exportPath: './src/models/User.ts'
437
+ * });
438
+ *
439
+ * if (userDefinition) {
440
+ * console.log(userDefinition.identifier); // Access definition details
441
+ * }
442
+ *
443
+ * // Pick interface definition
444
+ * const apiInterface = renderContext.pick({
445
+ * name: 'ApiResponse',
446
+ * exportPath: './src/types/api.ts'
447
+ * });
448
+ * ```
449
+ */
302
450
  pick({ name, exportPath }) {
303
451
  const file = this.getFile(exportPath);
304
452
  invariant(file instanceof File, `File at "${exportPath}" is not a "File" type`);
305
453
  return file.definitions.get(name);
306
454
  }
307
455
  }
308
- _RenderContext_prettierConfig = new WeakMap(), _RenderContext_stackTrail = new WeakMap();
456
+ _RenderContext_prettierConfig = new WeakMap(), _RenderContext_logger = new WeakMap(), _RenderContext_stackTrail = new WeakMap();
457
+ /**
458
+ * Renders a single file with formatting and metadata calculation.
459
+ *
460
+ * This function processes a single file through the rendering pipeline,
461
+ * applying Prettier formatting if configured and calculating file metadata
462
+ * such as line count and character count. It resolves the final path using
463
+ * the base path configuration.
464
+ *
465
+ * @param args - File rendering arguments
466
+ * @returns Promise resolving to a FileObject with content and metadata
467
+ *
468
+ * @example
469
+ * ```typescript
470
+ * const fileObject = await renderFile({
471
+ * content: 'const x = 1;',
472
+ * destinationPath: 'utils.ts',
473
+ * basePath: './src',
474
+ * prettierConfig: { semi: false }
475
+ * });
476
+ *
477
+ * console.log(fileObject.path); // './src/utils.ts'
478
+ * console.log(fileObject.content); // 'const x = 1' (formatted)
479
+ * console.log(fileObject.lines); // 1
480
+ * console.log(fileObject.characters); // 11
481
+ * ```
482
+ */
309
483
  const renderFile = async ({ content, destinationPath, basePath, prettierConfig }) => {
310
484
  const path = toResolvedArtifactPath({ basePath, destinationPath });
311
485
  const formatted = prettierConfig
@@ -3,24 +3,54 @@ import type { ManifestEntry } from '../types/Manifest.js';
3
3
  import type { Mapping, Preview } from '../types/Preview.js';
4
4
  import type { ResultsItem } from '../types/Results.js';
5
5
  import type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
6
+ /**
7
+ * Type representing the three phases of the SKMTC pipeline.
8
+ */
6
9
  export type PhaseType = 'parse' | 'generate' | 'render';
10
+ /**
11
+ * Options for retrieving files from the context.
12
+ */
7
13
  export type GetFileOptions = {
14
+ /** Whether to throw an error if the file is not found */
8
15
  throwIfNotFound?: boolean;
9
16
  };
17
+ /**
18
+ * Arguments for adding a generator key to the context.
19
+ */
10
20
  export type AddGeneratorKeyArgs = {
21
+ /** The generator key to add */
11
22
  generatorKey: GeneratorKey;
12
23
  };
24
+ /**
25
+ * Result of rendering files in the context.
26
+ */
13
27
  export type FilesRenderResult = {
28
+ /** Map of file paths to rendered content */
14
29
  artifacts: Record<string, string>;
30
+ /** Map of file paths to metadata */
15
31
  files: Record<string, ManifestEntry>;
16
32
  };
33
+ /**
34
+ * Complete result of the rendering phase including all generated content and metadata.
35
+ */
17
36
  export type RenderResult = {
37
+ /** Map of file paths to rendered content */
18
38
  artifacts: Record<string, string>;
39
+ /** Map of file paths to metadata */
19
40
  files: Record<string, ManifestEntry>;
41
+ /** Preview data for generated content */
20
42
  previews: Record<string, Record<string, Preview>>;
43
+ /** Mapping data for file relationships */
21
44
  mappings: Record<string, Record<string, Mapping>>;
45
+ /** Hierarchical results tracking */
22
46
  results: ResultsItem;
23
47
  };
48
+ /**
49
+ * Union type representing any supported OpenAPI document version.
50
+ */
24
51
  export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3_1.Document;
52
+ /**
53
+ * Types of issues that can be encountered during OpenAPI schema parsing.
54
+ */
25
55
  export type IssueType = 'UNEXPECTED_PROPERTY' | 'MISSING_OBJECT_TYPE' | 'MISSING_STRING_TYPE' | 'MISSING_ARRAY_TYPE' | 'MISSING_BOOLEAN_TYPE' | 'INVALID_EXAMPLE' | 'INVALID_ENUM' | 'INVALID_DEFAULT' | 'INVALID_NULLABLE' | 'UNEXPECTED_FORMAT' | 'INVALID_RESPONSE' | 'INVALID_FORMAT' | 'INVALID_OPERATION' | 'INVALID_SCHEMA' | 'INVALID_PARAMETER' | 'INVALID_DEPENDENCY_REF';
26
56
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEtE,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACpC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACj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AE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;CACrC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACpC,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,oCAAoC;IACpC,OAAO,EAAE,WAAW,CAAA;CACrB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAA;AAE3F;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,qBAAqB,GACrB,qBAAqB,GACrB,qBAAqB,GACrB,oBAAoB,GACpB,sBAAsB,GACtB,iBAAiB,GACjB,cAAc,GACd,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,kBAAkB,GAClB,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,mBAAmB,GACnB,wBAAwB,CAAA"}
@@ -8,7 +8,7 @@ import { ContentBase } from '../ContentBase.js';
8
8
  import type { Inserted } from '../Inserted.js';
9
9
  import type { OasSchema } from '../../oas/schema/Schema.js';
10
10
  import type { OasRef } from '../../oas/ref/Ref.js';
11
- import { OasVoid } from '../../oas/void/Void.js';
11
+ import type { OasVoid } from '../../oas/void/Void.js';
12
12
  /**
13
13
  * Constructor arguments for {@link ModelBase}.
14
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ModelBase.d.ts","sourceRoot":"","sources":["../../../src/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
15
  };
16
+ /**
17
+ * Driver class responsible for managing model generation lifecycle.
18
+ *
19
+ * @template V - The generated value type
20
+ * @template T - The generation type
21
+ * @template EnrichmentType - Optional enrichment type
22
+ */
16
23
  export declare class ModelDriver<V extends GeneratedValue, T extends GenerationType, EnrichmentType> {
24
+ /** The generation context */
17
25
  context: GenerateContext;
26
+ /** The insertable model configuration */
18
27
  insertable: ModelInsertable<V, EnrichmentType>;
28
+ /** Reference name for the model */
19
29
  refName: RefName;
30
+ /** Content settings for the model */
20
31
  settings: ContentSettings<EnrichmentType>;
32
+ /** Optional destination path for the generated file */
21
33
  destinationPath?: string;
34
+ /** The generated definition */
22
35
  definition: GeneratedDefinition<V, T>;
36
+ /** Optional root reference name */
23
37
  rootRef?: RefName;
38
+ /** Whether to skip export declaration */
24
39
  noExport?: boolean;
40
+ /**
41
+ * Creates a new ModelDriver instance.
42
+ *
43
+ * @param args - Constructor arguments
44
+ * @param args.context - Generation context
45
+ * @param args.insertable - Model insertable configuration
46
+ * @param args.refName - Reference name for the model
47
+ * @param args.generation - Optional generation type
48
+ * @param args.destinationPath - Optional destination path
49
+ * @param args.rootRef - Optional root reference name
50
+ * @param args.noExport - Whether to skip export declaration
51
+ */
25
52
  constructor({ context, insertable, refName, generation, destinationPath, rootRef, noExport }: CreateModelArgs<V, T, EnrichmentType>);
53
+ /**
54
+ * Applies generation configuration to create the model definition.
55
+ *
56
+ * This method handles the core generation logic, including identifier resolution,
57
+ * export path management, and import registration for cross-file dependencies.
58
+ *
59
+ * @template T - The generation type
60
+ * @param args - Apply configuration arguments
61
+ * @param args.generation - Optional generation type (unused currently)
62
+ * @param args.destinationPath - Optional destination path for imports
63
+ * @returns Generated definition for the model
64
+ */
26
65
  private apply;
66
+ /**
67
+ * Retrieves or creates a definition for the model.
68
+ *
69
+ * This method first checks for cached definitions to avoid duplicate generation,
70
+ * then creates a new definition if none exists. It handles the complete model
71
+ * transformation process including schema resolution and value generation.
72
+ *
73
+ * @param args - Definition retrieval arguments
74
+ * @param args.identifier - The identifier for the definition
75
+ * @param args.exportPath - The export path for the definition
76
+ * @returns Model definition instance
77
+ */
27
78
  private getDefinition;
79
+ /**
80
+ * Type guard to verify a definition matches the expected generated value type.
81
+ *
82
+ * This method performs type narrowing to ensure a cached definition is compatible
83
+ * with the current generation requirements, including export path validation.
84
+ *
85
+ * @template V - The expected generated value type
86
+ * @param definition - The definition to verify (may be undefined)
87
+ * @param exportPath - Expected export path for validation
88
+ * @returns True if definition matches expected type and constraints
89
+ */
28
90
  private affirmDefinition;
29
91
  }
30
92
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ModelDriver.d.ts","sourceRoot":"","sources":["../../../src/dsl/model/ModelDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAI5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGrD,KAAK,eAAe,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,cAAc,EAAE,cAAc,IAAI;IACzF,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,EAAE,eAAe,CAAC,CAAC,EAAE,cAAc,CAAC,CAAA;IAC9C,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,CAAC,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAYD,qBAAa,WAAW,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,c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,CAAA;IAChB,UAAU,CAAC,EAAE,CAAC,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAYD;;;;;;GAMG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,cAAc,EAAE,cAAc;IACzF,6BAA6B;IAC7B,OAAO,EAAE,eAAe,CAAA;IACxB,yCAAyC;IACzC,UAAU,EAAE,eAAe,CAAC,CAAC,EAAE,cAAc,CAAC,CAAA;IAC9C,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,qCAAqC;IACrC,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,CAAA;IACzC,uDAAuD;IACvD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,+BAA+B;IAC/B,UAAU,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACrC,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;;;;;;;;OAWG;gBACS,EACV,OAAO,EACP,UAAU,EACV,OAAO,EACP,UAAU,EACV,eAAe,EACf,OAAO,EACP,QAAQ,EACT,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC;IAgBxC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,KAAK;IAuBb;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,aAAa;IA2CrB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB;CAqBzB"}
@@ -1,50 +1,77 @@
1
1
  import { normalize } from '../../deps/jsr.io/@std/path/1.1.2/normalize.js';
2
2
  import { Definition } from '../Definition.js';
3
3
  import { toModelGeneratorKey } from '../../types/GeneratorKeys.js';
4
+ /**
5
+ * Driver class responsible for managing model generation lifecycle.
6
+ *
7
+ * @template V - The generated value type
8
+ * @template T - The generation type
9
+ * @template EnrichmentType - Optional enrichment type
10
+ */
4
11
  export class ModelDriver {
12
+ /**
13
+ * Creates a new ModelDriver instance.
14
+ *
15
+ * @param args - Constructor arguments
16
+ * @param args.context - Generation context
17
+ * @param args.insertable - Model insertable configuration
18
+ * @param args.refName - Reference name for the model
19
+ * @param args.generation - Optional generation type
20
+ * @param args.destinationPath - Optional destination path
21
+ * @param args.rootRef - Optional root reference name
22
+ * @param args.noExport - Whether to skip export declaration
23
+ */
5
24
  constructor({ context, insertable, refName, generation, destinationPath, rootRef, noExport }) {
25
+ /** The generation context */
6
26
  Object.defineProperty(this, "context", {
7
27
  enumerable: true,
8
28
  configurable: true,
9
29
  writable: true,
10
30
  value: void 0
11
31
  });
32
+ /** The insertable model configuration */
12
33
  Object.defineProperty(this, "insertable", {
13
34
  enumerable: true,
14
35
  configurable: true,
15
36
  writable: true,
16
37
  value: void 0
17
38
  });
39
+ /** Reference name for the model */
18
40
  Object.defineProperty(this, "refName", {
19
41
  enumerable: true,
20
42
  configurable: true,
21
43
  writable: true,
22
44
  value: void 0
23
45
  });
46
+ /** Content settings for the model */
24
47
  Object.defineProperty(this, "settings", {
25
48
  enumerable: true,
26
49
  configurable: true,
27
50
  writable: true,
28
51
  value: void 0
29
52
  });
53
+ /** Optional destination path for the generated file */
30
54
  Object.defineProperty(this, "destinationPath", {
31
55
  enumerable: true,
32
56
  configurable: true,
33
57
  writable: true,
34
58
  value: void 0
35
59
  });
60
+ /** The generated definition */
36
61
  Object.defineProperty(this, "definition", {
37
62
  enumerable: true,
38
63
  configurable: true,
39
64
  writable: true,
40
65
  value: void 0
41
66
  });
67
+ /** Optional root reference name */
42
68
  Object.defineProperty(this, "rootRef", {
43
69
  enumerable: true,
44
70
  configurable: true,
45
71
  writable: true,
46
72
  value: void 0
47
73
  });
74
+ /** Whether to skip export declaration */
48
75
  Object.defineProperty(this, "noExport", {
49
76
  enumerable: true,
50
77
  configurable: true,
@@ -62,7 +89,19 @@ export class ModelDriver {
62
89
  this.definition = this.apply({ generation, destinationPath });
63
90
  this.context.modelDepth[`${insertable.id}:${refName}`] = 0;
64
91
  }
65
- apply({ generation, destinationPath } = {}) {
92
+ /**
93
+ * Applies generation configuration to create the model definition.
94
+ *
95
+ * This method handles the core generation logic, including identifier resolution,
96
+ * export path management, and import registration for cross-file dependencies.
97
+ *
98
+ * @template T - The generation type
99
+ * @param args - Apply configuration arguments
100
+ * @param args.generation - Optional generation type (unused currently)
101
+ * @param args.destinationPath - Optional destination path for imports
102
+ * @returns Generated definition for the model
103
+ */
104
+ apply({ generation: _generation, destinationPath } = {}) {
66
105
  const { identifier, exportPath } = this.settings;
67
106
  // Everything is selected (for now)
68
107
  // if (/*!selected && */ generation !== 'force') {
@@ -77,6 +116,18 @@ export class ModelDriver {
77
116
  }
78
117
  return definition;
79
118
  }
119
+ /**
120
+ * Retrieves or creates a definition for the model.
121
+ *
122
+ * This method first checks for cached definitions to avoid duplicate generation,
123
+ * then creates a new definition if none exists. It handles the complete model
124
+ * transformation process including schema resolution and value generation.
125
+ *
126
+ * @param args - Definition retrieval arguments
127
+ * @param args.identifier - The identifier for the definition
128
+ * @param args.exportPath - The export path for the definition
129
+ * @returns Model definition instance
130
+ */
80
131
  getDefinition({ identifier, exportPath }) {
81
132
  const cachedDefinition = this.context.findDefinition({
82
133
  name: identifier.name,
@@ -112,6 +163,17 @@ export class ModelDriver {
112
163
  });
113
164
  return definition;
114
165
  }
166
+ /**
167
+ * Type guard to verify a definition matches the expected generated value type.
168
+ *
169
+ * This method performs type narrowing to ensure a cached definition is compatible
170
+ * with the current generation requirements, including export path validation.
171
+ *
172
+ * @template V - The expected generated value type
173
+ * @param definition - The definition to verify (may be undefined)
174
+ * @param exportPath - Expected export path for validation
175
+ * @returns True if definition matches expected type and constraints
176
+ */
115
177
  affirmDefinition(definition, exportPath) {
116
178
  if (!definition) {
117
179
  return false;