@skmtc/core 0.0.800 → 0.0.803

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 (291) hide show
  1. package/esm/context/CoreContext.d.ts +2 -2
  2. package/esm/context/CoreContext.d.ts.map +1 -1
  3. package/esm/context/GenerateContext.d.ts +16 -3
  4. package/esm/context/GenerateContext.d.ts.map +1 -1
  5. package/esm/context/ParseContext.d.ts +3 -3
  6. package/esm/context/ParseContext.d.ts.map +1 -1
  7. package/esm/context/RenderContext.d.ts +153 -1
  8. package/esm/context/RenderContext.d.ts.map +1 -1
  9. package/esm/context/RenderContext.js +179 -0
  10. package/esm/context/types.d.ts +30 -0
  11. package/esm/context/types.d.ts.map +1 -1
  12. package/esm/dsl/model/ModelBase.d.ts +1 -1
  13. package/esm/dsl/model/ModelBase.d.ts.map +1 -1
  14. package/esm/dsl/model/ModelDriver.d.ts +62 -0
  15. package/esm/dsl/model/ModelDriver.d.ts.map +1 -1
  16. package/esm/dsl/model/ModelDriver.js +63 -1
  17. package/esm/dsl/model/toModelBase.d.ts +66 -0
  18. package/esm/dsl/model/toModelBase.d.ts.map +1 -1
  19. package/esm/dsl/model/toModelBase.js +46 -0
  20. package/esm/dsl/model/toModelEntry.d.ts +63 -0
  21. package/esm/dsl/model/toModelEntry.d.ts.map +1 -1
  22. package/esm/dsl/model/toModelEntry.js +63 -0
  23. package/esm/dsl/operation/OperationBase.d.ts +3 -3
  24. package/esm/dsl/operation/OperationBase.d.ts.map +1 -1
  25. package/esm/dsl/operation/OperationDriver.d.ts +84 -0
  26. package/esm/dsl/operation/OperationDriver.d.ts.map +1 -1
  27. package/esm/dsl/operation/OperationDriver.js +85 -1
  28. package/esm/dsl/operation/toOperationBase.d.ts +58 -0
  29. package/esm/dsl/operation/toOperationBase.d.ts.map +1 -1
  30. package/esm/dsl/operation/toOperationBase.js +46 -0
  31. package/esm/dsl/operation/toOperationEntry.d.ts +37 -0
  32. package/esm/dsl/operation/toOperationEntry.d.ts.map +1 -1
  33. package/esm/dsl/operation/toOperationEntry.js +28 -0
  34. package/esm/helpers/isEmpty.d.ts +1 -1
  35. package/esm/helpers/isEmpty.d.ts.map +1 -1
  36. package/esm/helpers/tracer.d.ts +1 -1
  37. package/esm/helpers/tracer.d.ts.map +1 -1
  38. package/esm/helpers/tracer.js +1 -1
  39. package/esm/mod.d.ts +52 -0
  40. package/esm/mod.d.ts.map +1 -1
  41. package/esm/mod.js +52 -0
  42. package/esm/oas/array/Array.d.ts +26 -0
  43. package/esm/oas/array/Array.d.ts.map +1 -1
  44. package/esm/oas/array/Array.js +26 -0
  45. package/esm/oas/array/array-types.d.ts +32 -11
  46. package/esm/oas/array/array-types.d.ts.map +1 -1
  47. package/esm/oas/array/array-types.js +16 -0
  48. package/esm/oas/array/toArray.d.ts +111 -0
  49. package/esm/oas/array/toArray.d.ts.map +1 -1
  50. package/esm/oas/array/toArray.js +115 -3
  51. package/esm/oas/boolean/Boolean.d.ts +26 -0
  52. package/esm/oas/boolean/Boolean.d.ts.map +1 -1
  53. package/esm/oas/boolean/Boolean.js +26 -0
  54. package/esm/oas/boolean/boolean-types.d.ts +1 -7
  55. package/esm/oas/boolean/boolean-types.d.ts.map +1 -1
  56. package/esm/oas/boolean/toBoolean.d.ts +57 -0
  57. package/esm/oas/boolean/toBoolean.d.ts.map +1 -1
  58. package/esm/oas/boolean/toBoolean.js +57 -0
  59. package/esm/oas/components/components-types.d.ts +19 -0
  60. package/esm/oas/components/components-types.d.ts.map +1 -0
  61. package/esm/oas/components/components-types.js +21 -0
  62. package/esm/oas/contact/contact-types.d.ts +9 -0
  63. package/esm/oas/contact/contact-types.d.ts.map +1 -0
  64. package/esm/oas/contact/contact-types.js +7 -0
  65. package/esm/oas/discriminator/discriminator-types.d.ts +1 -5
  66. package/esm/oas/discriminator/discriminator-types.d.ts.map +1 -1
  67. package/esm/oas/document/document-types.d.ts +16 -0
  68. package/esm/oas/document/document-types.d.ts.map +1 -0
  69. package/esm/oas/document/document-types.js +18 -0
  70. package/esm/oas/example/example-types.d.ts +1 -6
  71. package/esm/oas/example/example-types.d.ts.map +1 -1
  72. package/esm/oas/header/header-types.d.ts +50 -0
  73. package/esm/oas/header/header-types.d.ts.map +1 -0
  74. package/esm/oas/header/header-types.js +30 -0
  75. package/esm/oas/info/info-types.d.ts +14 -0
  76. package/esm/oas/info/info-types.d.ts.map +1 -0
  77. package/esm/oas/info/info-types.js +13 -0
  78. package/esm/oas/integer/integer-types.d.ts +3 -17
  79. package/esm/oas/integer/integer-types.d.ts.map +1 -1
  80. package/esm/oas/license/license-types.d.ts +9 -0
  81. package/esm/oas/license/license-types.d.ts.map +1 -0
  82. package/esm/oas/license/license-types.js +7 -0
  83. package/esm/oas/mediaType/mediaType-types.d.ts +1 -11
  84. package/esm/oas/mediaType/mediaType-types.d.ts.map +1 -1
  85. package/esm/oas/number/number-types.d.ts +2 -16
  86. package/esm/oas/number/number-types.d.ts.map +1 -1
  87. package/esm/oas/number/toNumber.d.ts +62 -0
  88. package/esm/oas/number/toNumber.d.ts.map +1 -1
  89. package/esm/oas/number/toNumber.js +62 -0
  90. package/esm/oas/operation/operation-types.d.ts +22 -0
  91. package/esm/oas/operation/operation-types.d.ts.map +1 -0
  92. package/esm/oas/operation/operation-types.js +35 -0
  93. package/esm/oas/parameter/Parameter.d.ts +47 -0
  94. package/esm/oas/parameter/Parameter.d.ts.map +1 -1
  95. package/esm/oas/parameter/Parameter.js +47 -0
  96. package/esm/oas/parameter/parameter-types.d.ts +3 -58
  97. package/esm/oas/parameter/parameter-types.d.ts.map +1 -1
  98. package/esm/oas/pathItem/pathItem-types.d.ts +12 -0
  99. package/esm/oas/pathItem/pathItem-types.d.ts.map +1 -0
  100. package/esm/oas/pathItem/pathItem-types.js +12 -0
  101. package/esm/oas/requestBody/requestBody-types.d.ts +10 -0
  102. package/esm/oas/requestBody/requestBody-types.d.ts.map +1 -0
  103. package/esm/oas/requestBody/requestBody-types.js +9 -0
  104. package/esm/oas/response/response-types.d.ts +12 -0
  105. package/esm/oas/response/response-types.d.ts.map +1 -0
  106. package/esm/oas/response/response-types.js +11 -0
  107. package/esm/oas/schema/toSchemasV3.js +2 -2
  108. package/esm/oas/server/toServerV3.d.ts.map +1 -1
  109. package/esm/oas/string/string-types.d.ts +2 -29
  110. package/esm/oas/string/string-types.d.ts.map +1 -1
  111. package/esm/oas/string/toString.d.ts +125 -1
  112. package/esm/oas/string/toString.d.ts.map +1 -1
  113. package/esm/oas/string/toString.js +119 -0
  114. package/esm/oas/tag/tag-types.d.ts +8 -0
  115. package/esm/oas/tag/tag-types.d.ts.map +1 -0
  116. package/esm/oas/tag/tag-types.js +8 -0
  117. package/esm/oas/union/union-types.d.ts +1 -12
  118. package/esm/oas/union/union-types.d.ts.map +1 -1
  119. package/esm/oas/unknown/unknown-types.d.ts +1 -7
  120. package/esm/oas/unknown/unknown-types.d.ts.map +1 -1
  121. package/esm/types/CustomValue.d.ts +58 -0
  122. package/esm/types/CustomValue.d.ts.map +1 -1
  123. package/esm/types/CustomValue.js +58 -0
  124. package/esm/types/DenoJson.d.ts +24 -0
  125. package/esm/types/DenoJson.d.ts.map +1 -1
  126. package/esm/types/DenoJson.js +12 -0
  127. package/esm/types/Enrichments.d.ts +103 -0
  128. package/esm/types/Enrichments.d.ts.map +1 -1
  129. package/esm/types/Enrichments.js +52 -0
  130. package/esm/types/GeneratedValue.d.ts +17 -0
  131. package/esm/types/GeneratedValue.d.ts.map +1 -1
  132. package/esm/types/Logger.d.ts +9 -0
  133. package/esm/types/Logger.d.ts.map +1 -0
  134. package/esm/types/Logger.js +1 -0
  135. package/esm/types/Preview.d.ts +37 -0
  136. package/esm/types/Preview.d.ts.map +1 -1
  137. package/esm/types/Preview.js +37 -0
  138. package/esm/types/Settings.d.ts +35 -0
  139. package/esm/types/Settings.d.ts.map +1 -1
  140. package/esm/types/Settings.js +27 -0
  141. package/esm/typescript/FunctionParameter.d.ts +4 -4
  142. package/esm/typescript/FunctionParameter.d.ts.map +1 -1
  143. package/esm/typescript/List.d.ts +40 -2
  144. package/esm/typescript/List.d.ts.map +1 -1
  145. package/esm/typescript/List.js +32 -0
  146. package/package.json +1 -1
  147. package/script/context/CoreContext.d.ts +2 -2
  148. package/script/context/CoreContext.d.ts.map +1 -1
  149. package/script/context/GenerateContext.d.ts +16 -3
  150. package/script/context/GenerateContext.d.ts.map +1 -1
  151. package/script/context/ParseContext.d.ts +3 -3
  152. package/script/context/ParseContext.d.ts.map +1 -1
  153. package/script/context/RenderContext.d.ts +153 -1
  154. package/script/context/RenderContext.d.ts.map +1 -1
  155. package/script/context/RenderContext.js +179 -0
  156. package/script/context/types.d.ts +30 -0
  157. package/script/context/types.d.ts.map +1 -1
  158. package/script/dsl/model/ModelBase.d.ts +1 -1
  159. package/script/dsl/model/ModelBase.d.ts.map +1 -1
  160. package/script/dsl/model/ModelDriver.d.ts +62 -0
  161. package/script/dsl/model/ModelDriver.d.ts.map +1 -1
  162. package/script/dsl/model/ModelDriver.js +63 -1
  163. package/script/dsl/model/toModelBase.d.ts +66 -0
  164. package/script/dsl/model/toModelBase.d.ts.map +1 -1
  165. package/script/dsl/model/toModelBase.js +46 -0
  166. package/script/dsl/model/toModelEntry.d.ts +63 -0
  167. package/script/dsl/model/toModelEntry.d.ts.map +1 -1
  168. package/script/dsl/model/toModelEntry.js +63 -0
  169. package/script/dsl/operation/OperationBase.d.ts +3 -3
  170. package/script/dsl/operation/OperationBase.d.ts.map +1 -1
  171. package/script/dsl/operation/OperationDriver.d.ts +84 -0
  172. package/script/dsl/operation/OperationDriver.d.ts.map +1 -1
  173. package/script/dsl/operation/OperationDriver.js +85 -1
  174. package/script/dsl/operation/toOperationBase.d.ts +58 -0
  175. package/script/dsl/operation/toOperationBase.d.ts.map +1 -1
  176. package/script/dsl/operation/toOperationBase.js +46 -0
  177. package/script/dsl/operation/toOperationEntry.d.ts +37 -0
  178. package/script/dsl/operation/toOperationEntry.d.ts.map +1 -1
  179. package/script/dsl/operation/toOperationEntry.js +28 -0
  180. package/script/helpers/isEmpty.d.ts +1 -1
  181. package/script/helpers/isEmpty.d.ts.map +1 -1
  182. package/script/helpers/tracer.d.ts +1 -1
  183. package/script/helpers/tracer.d.ts.map +1 -1
  184. package/script/helpers/tracer.js +1 -1
  185. package/script/mod.d.ts +52 -0
  186. package/script/mod.d.ts.map +1 -1
  187. package/script/mod.js +52 -0
  188. package/script/oas/array/Array.d.ts +26 -0
  189. package/script/oas/array/Array.d.ts.map +1 -1
  190. package/script/oas/array/Array.js +26 -0
  191. package/script/oas/array/array-types.d.ts +32 -11
  192. package/script/oas/array/array-types.d.ts.map +1 -1
  193. package/script/oas/array/array-types.js +17 -1
  194. package/script/oas/array/toArray.d.ts +111 -0
  195. package/script/oas/array/toArray.d.ts.map +1 -1
  196. package/script/oas/array/toArray.js +114 -2
  197. package/script/oas/boolean/Boolean.d.ts +26 -0
  198. package/script/oas/boolean/Boolean.d.ts.map +1 -1
  199. package/script/oas/boolean/Boolean.js +26 -0
  200. package/script/oas/boolean/boolean-types.d.ts +1 -7
  201. package/script/oas/boolean/boolean-types.d.ts.map +1 -1
  202. package/script/oas/boolean/toBoolean.d.ts +57 -0
  203. package/script/oas/boolean/toBoolean.d.ts.map +1 -1
  204. package/script/oas/boolean/toBoolean.js +57 -0
  205. package/script/oas/components/components-types.d.ts +19 -0
  206. package/script/oas/components/components-types.d.ts.map +1 -0
  207. package/script/oas/components/components-types.js +57 -0
  208. package/script/oas/contact/contact-types.d.ts +9 -0
  209. package/script/oas/contact/contact-types.d.ts.map +1 -0
  210. package/script/oas/contact/contact-types.js +43 -0
  211. package/script/oas/discriminator/discriminator-types.d.ts +1 -5
  212. package/script/oas/discriminator/discriminator-types.d.ts.map +1 -1
  213. package/script/oas/document/document-types.d.ts +16 -0
  214. package/script/oas/document/document-types.d.ts.map +1 -0
  215. package/script/oas/document/document-types.js +54 -0
  216. package/script/oas/example/example-types.d.ts +1 -6
  217. package/script/oas/example/example-types.d.ts.map +1 -1
  218. package/script/oas/header/header-types.d.ts +50 -0
  219. package/script/oas/header/header-types.d.ts.map +1 -0
  220. package/script/oas/header/header-types.js +66 -0
  221. package/script/oas/info/info-types.d.ts +14 -0
  222. package/script/oas/info/info-types.d.ts.map +1 -0
  223. package/script/oas/info/info-types.js +49 -0
  224. package/script/oas/integer/integer-types.d.ts +3 -17
  225. package/script/oas/integer/integer-types.d.ts.map +1 -1
  226. package/script/oas/license/license-types.d.ts +9 -0
  227. package/script/oas/license/license-types.d.ts.map +1 -0
  228. package/script/oas/license/license-types.js +43 -0
  229. package/script/oas/mediaType/mediaType-types.d.ts +1 -11
  230. package/script/oas/mediaType/mediaType-types.d.ts.map +1 -1
  231. package/script/oas/number/number-types.d.ts +2 -16
  232. package/script/oas/number/number-types.d.ts.map +1 -1
  233. package/script/oas/number/toNumber.d.ts +62 -0
  234. package/script/oas/number/toNumber.d.ts.map +1 -1
  235. package/script/oas/number/toNumber.js +62 -0
  236. package/script/oas/operation/operation-types.d.ts +22 -0
  237. package/script/oas/operation/operation-types.d.ts.map +1 -0
  238. package/script/oas/operation/operation-types.js +71 -0
  239. package/script/oas/parameter/Parameter.d.ts +47 -0
  240. package/script/oas/parameter/Parameter.d.ts.map +1 -1
  241. package/script/oas/parameter/Parameter.js +47 -0
  242. package/script/oas/parameter/parameter-types.d.ts +3 -58
  243. package/script/oas/parameter/parameter-types.d.ts.map +1 -1
  244. package/script/oas/pathItem/pathItem-types.d.ts +12 -0
  245. package/script/oas/pathItem/pathItem-types.d.ts.map +1 -0
  246. package/script/oas/pathItem/pathItem-types.js +48 -0
  247. package/script/oas/requestBody/requestBody-types.d.ts +10 -0
  248. package/script/oas/requestBody/requestBody-types.d.ts.map +1 -0
  249. package/script/oas/requestBody/requestBody-types.js +45 -0
  250. package/script/oas/response/response-types.d.ts +12 -0
  251. package/script/oas/response/response-types.d.ts.map +1 -0
  252. package/script/oas/response/response-types.js +47 -0
  253. package/script/oas/schema/toSchemasV3.js +2 -2
  254. package/script/oas/server/toServerV3.d.ts.map +1 -1
  255. package/script/oas/string/string-types.d.ts +2 -29
  256. package/script/oas/string/string-types.d.ts.map +1 -1
  257. package/script/oas/string/toString.d.ts +125 -1
  258. package/script/oas/string/toString.d.ts.map +1 -1
  259. package/script/oas/string/toString.js +119 -0
  260. package/script/oas/tag/tag-types.d.ts +8 -0
  261. package/script/oas/tag/tag-types.d.ts.map +1 -0
  262. package/script/oas/tag/tag-types.js +44 -0
  263. package/script/oas/union/union-types.d.ts +1 -12
  264. package/script/oas/union/union-types.d.ts.map +1 -1
  265. package/script/oas/unknown/unknown-types.d.ts +1 -7
  266. package/script/oas/unknown/unknown-types.d.ts.map +1 -1
  267. package/script/types/CustomValue.d.ts +58 -0
  268. package/script/types/CustomValue.d.ts.map +1 -1
  269. package/script/types/CustomValue.js +58 -0
  270. package/script/types/DenoJson.d.ts +24 -0
  271. package/script/types/DenoJson.d.ts.map +1 -1
  272. package/script/types/DenoJson.js +12 -0
  273. package/script/types/Enrichments.d.ts +103 -0
  274. package/script/types/Enrichments.d.ts.map +1 -1
  275. package/script/types/Enrichments.js +52 -0
  276. package/script/types/GeneratedValue.d.ts +17 -0
  277. package/script/types/GeneratedValue.d.ts.map +1 -1
  278. package/script/types/Logger.d.ts +9 -0
  279. package/script/types/Logger.d.ts.map +1 -0
  280. package/script/types/Logger.js +2 -0
  281. package/script/types/Preview.d.ts +37 -0
  282. package/script/types/Preview.d.ts.map +1 -1
  283. package/script/types/Preview.js +37 -0
  284. package/script/types/Settings.d.ts +35 -0
  285. package/script/types/Settings.d.ts.map +1 -1
  286. package/script/types/Settings.js +27 -0
  287. package/script/typescript/FunctionParameter.d.ts +4 -4
  288. package/script/typescript/FunctionParameter.d.ts.map +1 -1
  289. package/script/typescript/List.d.ts +40 -2
  290. package/script/typescript/List.d.ts.map +1 -1
  291. package/script/typescript/List.js +32 -0
@@ -236,39 +236,55 @@ const prettier = __importStar(require("prettier"));
236
236
  * ```
237
237
  */
238
238
  class RenderContext {
239
+ /**
240
+ * Creates a new RenderContext instance with the specified configuration.
241
+ *
242
+ * Initializes the rendering context with files to render, preview data,
243
+ * formatting configuration, and logging/tracing infrastructure.
244
+ *
245
+ * @param args - Constructor arguments containing all required configuration
246
+ */
239
247
  constructor({ files, previews, mappings, prettierConfig, basePath, logger, stackTrail, captureCurrentResult }) {
248
+ /** Map of generated files to render */
240
249
  Object.defineProperty(this, "files", {
241
250
  enumerable: true,
242
251
  configurable: true,
243
252
  writable: true,
244
253
  value: void 0
245
254
  });
255
+ /** Preview data for generated content */
246
256
  Object.defineProperty(this, "previews", {
247
257
  enumerable: true,
248
258
  configurable: true,
249
259
  writable: true,
250
260
  value: void 0
251
261
  });
262
+ /** Mapping data for file relationships */
252
263
  Object.defineProperty(this, "mappings", {
253
264
  enumerable: true,
254
265
  configurable: true,
255
266
  writable: true,
256
267
  value: void 0
257
268
  });
269
+ /** Optional Prettier configuration for code formatting */
258
270
  _RenderContext_prettierConfig.set(this, void 0);
271
+ /** Base path for resolving file paths */
259
272
  Object.defineProperty(this, "basePath", {
260
273
  enumerable: true,
261
274
  configurable: true,
262
275
  writable: true,
263
276
  value: void 0
264
277
  });
278
+ /** Logger instance for debug information */
265
279
  Object.defineProperty(this, "logger", {
266
280
  enumerable: true,
267
281
  configurable: true,
268
282
  writable: true,
269
283
  value: void 0
270
284
  });
285
+ /** Stack trail for distributed tracing */
271
286
  _RenderContext_stackTrail.set(this, void 0);
287
+ /** Function to capture result status */
272
288
  Object.defineProperty(this, "captureCurrentResult", {
273
289
  enumerable: true,
274
290
  configurable: true,
@@ -284,6 +300,40 @@ class RenderContext {
284
300
  __classPrivateFieldSet(this, _RenderContext_stackTrail, stackTrail, "f");
285
301
  this.captureCurrentResult = captureCurrentResult;
286
302
  }
303
+ /**
304
+ * Renders all files in the context to their final formatted form.
305
+ *
306
+ * This is the main rendering method that orchestrates the collation and
307
+ * formatting of all generated files. It processes files through Prettier
308
+ * formatting (if configured), resolves paths, and produces the final
309
+ * artifacts ready for writing to the filesystem.
310
+ *
311
+ * The method is wrapped in Sentry tracing spans for performance monitoring
312
+ * and includes both collation and artifact preparation phases.
313
+ *
314
+ * @returns Promise resolving to render result containing artifacts, file metadata, previews, and mappings
315
+ *
316
+ * @example
317
+ * ```typescript
318
+ * const renderContext = new RenderContext({
319
+ * files: generatedFiles,
320
+ * previews: previewData,
321
+ * mappings: mappingData,
322
+ * prettierConfig: { semi: false, singleQuote: true },
323
+ * basePath: './src/generated',
324
+ * stackTrail: traceStack,
325
+ * logger: logger,
326
+ * captureCurrentResult: resultHandler
327
+ * });
328
+ *
329
+ * const result = await renderContext.render();
330
+ *
331
+ * // Access rendered files
332
+ * Object.entries(result.artifacts).forEach(([path, content]) => {
333
+ * console.log(`Rendered ${path}: ${result.files[path].lines} lines`);
334
+ * });
335
+ * ```
336
+ */
287
337
  async render() {
288
338
  return await Sentry.startSpan({ name: 'Render artifacts' }, async () => {
289
339
  const result = await Sentry.startSpan({ name: 'Collate content' }, async () => {
@@ -298,6 +348,33 @@ class RenderContext {
298
348
  return rendered;
299
349
  });
300
350
  }
351
+ /**
352
+ * Collates all files in the context into a unified render result.
353
+ *
354
+ * This method processes each file in the context through the rendering pipeline,
355
+ * applying Prettier formatting and path resolution. It coordinates the parallel
356
+ * processing of all files and aggregates the results into a single output structure.
357
+ *
358
+ * The collation process includes:
359
+ * - File content rendering with optional Prettier formatting
360
+ * - Path resolution using base path configuration
361
+ * - Metadata calculation (line count, character count)
362
+ * - Result aggregation into artifacts and file metadata maps
363
+ *
364
+ * @returns Promise resolving to collated files with artifacts and metadata
365
+ *
366
+ * @example
367
+ * ```typescript
368
+ * const collated = await renderContext.collate();
369
+ *
370
+ * // Access rendered file content
371
+ * console.log(collated.artifacts['/path/to/file.ts']);
372
+ *
373
+ * // Access file metadata
374
+ * console.log(collated.files['/path/to/file.ts'].lines);
375
+ * console.log(collated.files['/path/to/file.ts'].characters);
376
+ * ```
377
+ */
301
378
  async collate() {
302
379
  const fileEntries = Array.from(this.files.entries());
303
380
  const fileObjectPromises = fileEntries
@@ -329,15 +406,91 @@ class RenderContext {
329
406
  }
330
407
  return output;
331
408
  }
409
+ /**
410
+ * Executes a function within a tracing context for performance monitoring.
411
+ *
412
+ * This method wraps function execution with distributed tracing capabilities,
413
+ * allowing performance monitoring and debugging of the rendering pipeline.
414
+ * It integrates with the stack trail to provide hierarchical tracing.
415
+ *
416
+ * @template T - The return type of the traced function
417
+ * @param token - Trace identifier (string or array of strings)
418
+ * @param fn - Function to execute within the trace context
419
+ * @returns The result of executing the traced function
420
+ *
421
+ * @example
422
+ * ```typescript
423
+ * const result = renderContext.trace('format-file', () => {
424
+ * return prettier.format(content, prettierConfig);
425
+ * });
426
+ *
427
+ * // With hierarchical tracing
428
+ * const result = renderContext.trace(['render', 'format'], () => {
429
+ * return complexFormattingOperation();
430
+ * });
431
+ * ```
432
+ */
332
433
  trace(token, fn) {
333
434
  return (0, tracer_js_1.tracer)(__classPrivateFieldGet(this, _RenderContext_stackTrail, "f"), token, fn, this.logger);
334
435
  }
436
+ /**
437
+ * Retrieves a file from the context by its normalized path.
438
+ *
439
+ * This method looks up a file in the context's file map using path normalization
440
+ * to ensure consistent path resolution. It validates that the requested file
441
+ * exists and throws an error if not found.
442
+ *
443
+ * @param filePath - The file path to retrieve (will be normalized)
444
+ * @returns The File or JsonFile instance
445
+ * @throws {Error} When the file is not found in the context
446
+ *
447
+ * @example
448
+ * ```typescript
449
+ * const file = renderContext.getFile('./src/models/User.ts');
450
+ * console.log(file.toString()); // Access file content
451
+ *
452
+ * // Works with various path formats
453
+ * const sameFile = renderContext.getFile('src/models/User.ts');
454
+ * const alsoSameFile = renderContext.getFile('/absolute/path/src/models/User.ts');
455
+ * ```
456
+ */
335
457
  getFile(filePath) {
336
458
  const normalisedPath = (0, normalize_js_1.normalize)(filePath);
337
459
  const currentFile = this.files.get(normalisedPath);
338
460
  (0, tiny_invariant_1.default)(currentFile, `File not found during render phase: ${normalisedPath}`);
339
461
  return currentFile;
340
462
  }
463
+ /**
464
+ * Picks a specific definition from a file in the context.
465
+ *
466
+ * This method retrieves a named definition (type, interface, etc.) from
467
+ * a specific file in the context. It validates that the target file is
468
+ * a File type (not JsonFile) and returns the requested definition if found.
469
+ *
470
+ * @param args - Object containing the definition name and export path
471
+ * @param args.name - The name of the definition to retrieve
472
+ * @param args.exportPath - The path to the file containing the definition
473
+ * @returns The Definition instance if found, undefined otherwise
474
+ * @throws {Error} When the file is not found or is not a File type
475
+ *
476
+ * @example
477
+ * ```typescript
478
+ * const userDefinition = renderContext.pick({
479
+ * name: 'User',
480
+ * exportPath: './src/models/User.ts'
481
+ * });
482
+ *
483
+ * if (userDefinition) {
484
+ * console.log(userDefinition.identifier); // Access definition details
485
+ * }
486
+ *
487
+ * // Pick interface definition
488
+ * const apiInterface = renderContext.pick({
489
+ * name: 'ApiResponse',
490
+ * exportPath: './src/types/api.ts'
491
+ * });
492
+ * ```
493
+ */
341
494
  pick({ name, exportPath }) {
342
495
  const file = this.getFile(exportPath);
343
496
  (0, tiny_invariant_1.default)(file instanceof File_js_1.File, `File at "${exportPath}" is not a "File" type`);
@@ -346,6 +499,32 @@ class RenderContext {
346
499
  }
347
500
  exports.RenderContext = RenderContext;
348
501
  _RenderContext_prettierConfig = new WeakMap(), _RenderContext_stackTrail = new WeakMap();
502
+ /**
503
+ * Renders a single file with formatting and metadata calculation.
504
+ *
505
+ * This function processes a single file through the rendering pipeline,
506
+ * applying Prettier formatting if configured and calculating file metadata
507
+ * such as line count and character count. It resolves the final path using
508
+ * the base path configuration.
509
+ *
510
+ * @param args - File rendering arguments
511
+ * @returns Promise resolving to a FileObject with content and metadata
512
+ *
513
+ * @example
514
+ * ```typescript
515
+ * const fileObject = await renderFile({
516
+ * content: 'const x = 1;',
517
+ * destinationPath: 'utils.ts',
518
+ * basePath: './src',
519
+ * prettierConfig: { semi: false }
520
+ * });
521
+ *
522
+ * console.log(fileObject.path); // './src/utils.ts'
523
+ * console.log(fileObject.content); // 'const x = 1' (formatted)
524
+ * console.log(fileObject.lines); // 1
525
+ * console.log(fileObject.characters); // 11
526
+ * ```
527
+ */
349
528
  const renderFile = async ({ content, destinationPath, basePath, prettierConfig }) => {
350
529
  const path = (0, toResolvedArtifactPath_js_1.toResolvedArtifactPath)({ basePath, destinationPath });
351
530
  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,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BAAmB,GACnB,wBAAwB,CAAA"}
@@ -8,7 +8,7 @@ import { ContentBase } from '../ContentBase.js';
8
8
  import type { Inserted } from '../Inserted.js';
9
9
  import type { OasSchema } from '../../oas/schema/Schema.js';
10
10
  import type { OasRef } from '../../oas/ref/Ref.js';
11
- import { OasVoid } from '../../oas/void/Void.js';
11
+ import type { OasVoid } from '../../oas/void/Void.js';
12
12
  /**
13
13
  * Constructor arguments for {@link ModelBase}.
14
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ModelBase.d.ts","sourceRoot":"","sources":["../../../src/dsl/model/ModelBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAGlD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAEhD;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,cAAc,GAAG,SAAS,IAAI;IACtD,yEAAyE;IACzE,OAAO,EAAE,eAAe,CAAA;IACxB,0EAA0E;IAC1E,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,C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AiB,CAAC,EACpF,OAAO,GAAE,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,UAAU,CAAM,GAC1D,2BAA2B,CAAC,CAAC,EAAE,MAAM,CAAC;IAYzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACM,QAAQ,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;CAMhD"}
@@ -13,18 +13,80 @@ type CreateModelArgs<V extends GeneratedValue, T extends GenerationType, Enrichm
13
13
  rootRef?: RefName;
14
14
  noExport?: boolean;
15
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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c,CAAC;IAgBxC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,KAAK;IAuBb;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,aAAa;IA2CrB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB;CAqBzB"}
@@ -4,50 +4,77 @@ exports.ModelDriver = void 0;
4
4
  const normalize_js_1 = require("../../deps/jsr.io/@std/path/1.1.2/normalize.js");
5
5
  const Definition_js_1 = require("../Definition.js");
6
6
  const GeneratorKeys_js_1 = require("../../types/GeneratorKeys.js");
7
+ /**
8
+ * Driver class responsible for managing model generation lifecycle.
9
+ *
10
+ * @template V - The generated value type
11
+ * @template T - The generation type
12
+ * @template EnrichmentType - Optional enrichment type
13
+ */
7
14
  class ModelDriver {
15
+ /**
16
+ * Creates a new ModelDriver instance.
17
+ *
18
+ * @param args - Constructor arguments
19
+ * @param args.context - Generation context
20
+ * @param args.insertable - Model insertable configuration
21
+ * @param args.refName - Reference name for the model
22
+ * @param args.generation - Optional generation type
23
+ * @param args.destinationPath - Optional destination path
24
+ * @param args.rootRef - Optional root reference name
25
+ * @param args.noExport - Whether to skip export declaration
26
+ */
8
27
  constructor({ context, insertable, refName, generation, destinationPath, rootRef, noExport }) {
28
+ /** The generation context */
9
29
  Object.defineProperty(this, "context", {
10
30
  enumerable: true,
11
31
  configurable: true,
12
32
  writable: true,
13
33
  value: void 0
14
34
  });
35
+ /** The insertable model configuration */
15
36
  Object.defineProperty(this, "insertable", {
16
37
  enumerable: true,
17
38
  configurable: true,
18
39
  writable: true,
19
40
  value: void 0
20
41
  });
42
+ /** Reference name for the model */
21
43
  Object.defineProperty(this, "refName", {
22
44
  enumerable: true,
23
45
  configurable: true,
24
46
  writable: true,
25
47
  value: void 0
26
48
  });
49
+ /** Content settings for the model */
27
50
  Object.defineProperty(this, "settings", {
28
51
  enumerable: true,
29
52
  configurable: true,
30
53
  writable: true,
31
54
  value: void 0
32
55
  });
56
+ /** Optional destination path for the generated file */
33
57
  Object.defineProperty(this, "destinationPath", {
34
58
  enumerable: true,
35
59
  configurable: true,
36
60
  writable: true,
37
61
  value: void 0
38
62
  });
63
+ /** The generated definition */
39
64
  Object.defineProperty(this, "definition", {
40
65
  enumerable: true,
41
66
  configurable: true,
42
67
  writable: true,
43
68
  value: void 0
44
69
  });
70
+ /** Optional root reference name */
45
71
  Object.defineProperty(this, "rootRef", {
46
72
  enumerable: true,
47
73
  configurable: true,
48
74
  writable: true,
49
75
  value: void 0
50
76
  });
77
+ /** Whether to skip export declaration */
51
78
  Object.defineProperty(this, "noExport", {
52
79
  enumerable: true,
53
80
  configurable: true,
@@ -65,7 +92,19 @@ class ModelDriver {
65
92
  this.definition = this.apply({ generation, destinationPath });
66
93
  this.context.modelDepth[`${insertable.id}:${refName}`] = 0;
67
94
  }
68
- apply({ generation, destinationPath } = {}) {
95
+ /**
96
+ * Applies generation configuration to create the model definition.
97
+ *
98
+ * This method handles the core generation logic, including identifier resolution,
99
+ * export path management, and import registration for cross-file dependencies.
100
+ *
101
+ * @template T - The generation type
102
+ * @param args - Apply configuration arguments
103
+ * @param args.generation - Optional generation type (unused currently)
104
+ * @param args.destinationPath - Optional destination path for imports
105
+ * @returns Generated definition for the model
106
+ */
107
+ apply({ generation: _generation, destinationPath } = {}) {
69
108
  const { identifier, exportPath } = this.settings;
70
109
  // Everything is selected (for now)
71
110
  // if (/*!selected && */ generation !== 'force') {
@@ -80,6 +119,18 @@ class ModelDriver {
80
119
  }
81
120
  return definition;
82
121
  }
122
+ /**
123
+ * Retrieves or creates a definition for the model.
124
+ *
125
+ * This method first checks for cached definitions to avoid duplicate generation,
126
+ * then creates a new definition if none exists. It handles the complete model
127
+ * transformation process including schema resolution and value generation.
128
+ *
129
+ * @param args - Definition retrieval arguments
130
+ * @param args.identifier - The identifier for the definition
131
+ * @param args.exportPath - The export path for the definition
132
+ * @returns Model definition instance
133
+ */
83
134
  getDefinition({ identifier, exportPath }) {
84
135
  const cachedDefinition = this.context.findDefinition({
85
136
  name: identifier.name,
@@ -115,6 +166,17 @@ class ModelDriver {
115
166
  });
116
167
  return definition;
117
168
  }
169
+ /**
170
+ * Type guard to verify a definition matches the expected generated value type.
171
+ *
172
+ * This method performs type narrowing to ensure a cached definition is compatible
173
+ * with the current generation requirements, including export path validation.
174
+ *
175
+ * @template V - The expected generated value type
176
+ * @param definition - The definition to verify (may be undefined)
177
+ * @param exportPath - Expected export path for validation
178
+ * @returns True if definition matches expected type and constraints
179
+ */
118
180
  affirmDefinition(definition, exportPath) {
119
181
  if (!definition) {
120
182
  return false;
@@ -4,16 +4,82 @@ import type { ContentSettings } from '../ContentSettings.js';
4
4
  import { ModelBase } from './ModelBase.js';
5
5
  import type { Identifier } from '../Identifier.js';
6
6
  import * as v from 'valibot';
7
+ /**
8
+ * Arguments for creating a model insertable instance.
9
+ *
10
+ * @template EnrichmentType - Type of enrichments to apply to the model
11
+ */
7
12
  export type ModelInsertableArgs<EnrichmentType = undefined> = {
13
+ /** The generation context providing access to OAS objects and utilities */
8
14
  context: GenerateContext;
15
+ /** Content settings for customizing model generation behavior */
9
16
  settings: ContentSettings<EnrichmentType>;
17
+ /** Reference name identifying the model schema */
10
18
  refName: RefName;
11
19
  };
20
+ /**
21
+ * Configuration for creating a base model class.
22
+ *
23
+ * Defines the structure and behavior for model generators, including
24
+ * identifier generation, export path resolution, and enrichment schemas.
25
+ *
26
+ * @template EnrichmentType - Type of enrichments to apply to generated models
27
+ */
12
28
  export type BaseModelConfig<EnrichmentType = undefined> = {
29
+ /** Unique identifier for the model generator */
13
30
  id: string;
31
+ /** Function to generate identifiers from reference names */
14
32
  toIdentifier: (refName: RefName) => Identifier;
33
+ /** Function to generate export paths from reference names */
15
34
  toExportPath: (refName: RefName) => string;
35
+ /** Optional function to provide enrichment validation schema */
16
36
  toEnrichmentSchema?: () => v.BaseSchema<EnrichmentType, EnrichmentType, v.BaseIssue<unknown>>;
17
37
  };
38
+ /**
39
+ * Creates a base model class constructor for generating type-safe model artifacts.
40
+ *
41
+ * This factory function creates a specialized ModelBase class that implements
42
+ * the provided configuration for identifier generation, export paths, and
43
+ * enrichment handling. The resulting class can be instantiated to generate
44
+ * model artifacts from OpenAPI schemas.
45
+ *
46
+ * @template EnrichmentType - Type of enrichments to apply to generated models
47
+ * @param config - Configuration defining the model generation behavior
48
+ * @returns Constructor function for creating model instances
49
+ *
50
+ * @example Creating a TypeScript interface generator
51
+ * ```typescript
52
+ * import { toModelBase } from '@skmtc/core';
53
+ *
54
+ * const TypeScriptModelBase = toModelBase({
55
+ * id: 'typescript-interfaces',
56
+ * toIdentifier: (refName) => new Identifier(pascalCase(refName)),
57
+ * toExportPath: (refName) => `./models/${kebabCase(refName)}.ts`,
58
+ * toEnrichmentSchema: () => v.object({
59
+ * includeValidation: v.optional(v.boolean()),
60
+ * readonly: v.optional(v.boolean())
61
+ * })
62
+ * });
63
+ *
64
+ * class TypeScriptModelGenerator extends TypeScriptModelBase {
65
+ * generate() {
66
+ * const enrichments = this.enrichments;
67
+ * const interface = generateInterface(this.schema, {
68
+ * readonly: enrichments?.readonly ?? false
69
+ * });
70
+ * this.register({ file: this.createFile(interface) });
71
+ * }
72
+ * }
73
+ * ```
74
+ *
75
+ * @example Creating a validation schema generator
76
+ * ```typescript
77
+ * const ValidationModelBase = toModelBase({
78
+ * id: 'zod-schemas',
79
+ * toIdentifier: (refName) => new Identifier(`${pascalCase(refName)}Schema`),
80
+ * toExportPath: (refName) => `./schemas/${kebabCase(refName)}.schema.ts`
81
+ * });
82
+ * ```
83
+ */
18
84
  export declare const toModelBase: <EnrichmentType = undefined>(config: BaseModelConfig<EnrichmentType>) => new (args: ModelInsertableArgs<EnrichmentType>) => ModelBase<EnrichmentType>;
19
85
  //# sourceMappingURL=toModelBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toModelBase.d.ts","sourceRoot":"","sources":["../../../src/dsl/model/toModelBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAA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