@skmtc/core 0.0.796 → 0.0.798

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 (109) hide show
  1. package/esm/app/validate.d.ts +32 -0
  2. package/esm/app/validate.d.ts.map +1 -1
  3. package/esm/app/validate.js +32 -0
  4. package/esm/context/CoreContext.d.ts +147 -2
  5. package/esm/context/CoreContext.d.ts.map +1 -1
  6. package/esm/context/CoreContext.js +87 -0
  7. package/esm/context/GenerateContext.d.ts +180 -0
  8. package/esm/context/GenerateContext.d.ts.map +1 -1
  9. package/esm/context/GenerateContext.js +25 -0
  10. package/esm/context/ParseContext.d.ts +6 -0
  11. package/esm/context/ParseContext.d.ts.map +1 -1
  12. package/esm/context/ParseContext.js +6 -0
  13. package/esm/dsl/constants.d.ts +28 -0
  14. package/esm/dsl/constants.d.ts.map +1 -1
  15. package/esm/dsl/constants.js +28 -0
  16. package/esm/oas/_helpers/parseDefault.d.ts +148 -0
  17. package/esm/oas/_helpers/parseDefault.d.ts.map +1 -1
  18. package/esm/oas/_helpers/parseDefault.js +128 -0
  19. package/esm/oas/_helpers/parseEnum.d.ts +124 -0
  20. package/esm/oas/_helpers/parseEnum.d.ts.map +1 -1
  21. package/esm/oas/_helpers/parseEnum.js +104 -0
  22. package/esm/oas/_helpers/parseExample.d.ts +107 -0
  23. package/esm/oas/_helpers/parseExample.d.ts.map +1 -1
  24. package/esm/oas/_helpers/parseExample.js +87 -0
  25. package/esm/oas/_helpers/parseFormat.d.ts +154 -0
  26. package/esm/oas/_helpers/parseFormat.d.ts.map +1 -1
  27. package/esm/oas/_helpers/parseFormat.js +138 -0
  28. package/esm/oas/_helpers/parseNullable.d.ts +127 -0
  29. package/esm/oas/_helpers/parseNullable.d.ts.map +1 -1
  30. package/esm/oas/_helpers/parseNullable.js +113 -0
  31. package/esm/oas/example/toExamplesV3.d.ts +39 -0
  32. package/esm/oas/example/toExamplesV3.d.ts.map +1 -1
  33. package/esm/oas/example/toExamplesV3.js +29 -0
  34. package/esm/oas/object/Object.d.ts +6 -0
  35. package/esm/oas/object/Object.d.ts.map +1 -1
  36. package/esm/oas/object/Object.js +6 -0
  37. package/esm/oas/operation/Operation.d.ts +34 -0
  38. package/esm/oas/operation/Operation.d.ts.map +1 -1
  39. package/esm/oas/operation/Operation.js +14 -0
  40. package/esm/oas/parameter/Parameter.d.ts +3 -0
  41. package/esm/oas/parameter/Parameter.d.ts.map +1 -1
  42. package/esm/oas/parameter/Parameter.js +3 -0
  43. package/esm/oas/ref/ref-types.d.ts +42 -0
  44. package/esm/oas/ref/ref-types.d.ts.map +1 -1
  45. package/esm/oas/ref/ref-types.js +9 -0
  46. package/esm/oas/securitySchemes/security-scheme-types.d.ts +63 -0
  47. package/esm/oas/securitySchemes/security-scheme-types.d.ts.map +1 -1
  48. package/esm/oas/securitySchemes/security-scheme-types.js +15 -0
  49. package/esm/run/toV3JsonDocument.d.ts +90 -0
  50. package/esm/run/toV3JsonDocument.d.ts.map +1 -1
  51. package/esm/run/toV3JsonDocument.js +84 -0
  52. package/esm/types/Results.d.ts +32 -0
  53. package/esm/types/Results.d.ts.map +1 -1
  54. package/esm/types/Results.js +12 -0
  55. package/package.json +1 -1
  56. package/script/app/validate.d.ts +32 -0
  57. package/script/app/validate.d.ts.map +1 -1
  58. package/script/app/validate.js +32 -0
  59. package/script/context/CoreContext.d.ts +147 -2
  60. package/script/context/CoreContext.d.ts.map +1 -1
  61. package/script/context/CoreContext.js +87 -0
  62. package/script/context/GenerateContext.d.ts +180 -0
  63. package/script/context/GenerateContext.d.ts.map +1 -1
  64. package/script/context/GenerateContext.js +25 -0
  65. package/script/context/ParseContext.d.ts +6 -0
  66. package/script/context/ParseContext.d.ts.map +1 -1
  67. package/script/context/ParseContext.js +6 -0
  68. package/script/dsl/constants.d.ts +28 -0
  69. package/script/dsl/constants.d.ts.map +1 -1
  70. package/script/dsl/constants.js +28 -0
  71. package/script/oas/_helpers/parseDefault.d.ts +148 -0
  72. package/script/oas/_helpers/parseDefault.d.ts.map +1 -1
  73. package/script/oas/_helpers/parseDefault.js +128 -0
  74. package/script/oas/_helpers/parseEnum.d.ts +124 -0
  75. package/script/oas/_helpers/parseEnum.d.ts.map +1 -1
  76. package/script/oas/_helpers/parseEnum.js +104 -0
  77. package/script/oas/_helpers/parseExample.d.ts +107 -0
  78. package/script/oas/_helpers/parseExample.d.ts.map +1 -1
  79. package/script/oas/_helpers/parseExample.js +87 -0
  80. package/script/oas/_helpers/parseFormat.d.ts +154 -0
  81. package/script/oas/_helpers/parseFormat.d.ts.map +1 -1
  82. package/script/oas/_helpers/parseFormat.js +138 -0
  83. package/script/oas/_helpers/parseNullable.d.ts +127 -0
  84. package/script/oas/_helpers/parseNullable.d.ts.map +1 -1
  85. package/script/oas/_helpers/parseNullable.js +113 -0
  86. package/script/oas/example/toExamplesV3.d.ts +39 -0
  87. package/script/oas/example/toExamplesV3.d.ts.map +1 -1
  88. package/script/oas/example/toExamplesV3.js +29 -0
  89. package/script/oas/object/Object.d.ts +6 -0
  90. package/script/oas/object/Object.d.ts.map +1 -1
  91. package/script/oas/object/Object.js +6 -0
  92. package/script/oas/operation/Operation.d.ts +34 -0
  93. package/script/oas/operation/Operation.d.ts.map +1 -1
  94. package/script/oas/operation/Operation.js +14 -0
  95. package/script/oas/parameter/Parameter.d.ts +3 -0
  96. package/script/oas/parameter/Parameter.d.ts.map +1 -1
  97. package/script/oas/parameter/Parameter.js +3 -0
  98. package/script/oas/ref/ref-types.d.ts +42 -0
  99. package/script/oas/ref/ref-types.d.ts.map +1 -1
  100. package/script/oas/ref/ref-types.js +9 -0
  101. package/script/oas/securitySchemes/security-scheme-types.d.ts +63 -0
  102. package/script/oas/securitySchemes/security-scheme-types.d.ts.map +1 -1
  103. package/script/oas/securitySchemes/security-scheme-types.js +15 -0
  104. package/script/run/toV3JsonDocument.d.ts +90 -0
  105. package/script/run/toV3JsonDocument.d.ts.map +1 -1
  106. package/script/run/toV3JsonDocument.js +84 -0
  107. package/script/types/Results.d.ts +32 -0
  108. package/script/types/Results.d.ts.map +1 -1
  109. package/script/types/Results.js +12 -0
@@ -1,3 +1,35 @@
1
+ /**
2
+ * Validates a project name against SKMTC naming conventions.
3
+ *
4
+ * Ensures project names follow standard naming patterns suitable for package
5
+ * managers and file systems. Names must be lowercase, contain only letters,
6
+ * numbers, and hyphens, with specific length and format requirements.
7
+ *
8
+ * @param name - The project name to validate
9
+ * @returns An error message string if validation fails, undefined if valid
10
+ *
11
+ * @example Valid project names
12
+ * ```typescript
13
+ * checkProjectName('my-api-client'); // undefined (valid)
14
+ * checkProjectName('user-service'); // undefined (valid)
15
+ * checkProjectName('api2'); // undefined (valid)
16
+ * ```
17
+ *
18
+ * @example Invalid project names
19
+ * ```typescript
20
+ * checkProjectName('A'); // 'Name must be at least 2 characters long'
21
+ * checkProjectName('My-API-Client'); // 'Name must only contain lowercase letters, numbers and hyphens'
22
+ * checkProjectName('-api-client'); // 'Name cannot start with a hyphen'
23
+ * checkProjectName('api-client-'); // 'Name cannot end with a hyphen'
24
+ * ```
25
+ *
26
+ * @example Validation rules
27
+ * - Minimum length: 2 characters
28
+ * - Maximum length: 20 characters
29
+ * - Allowed characters: a-z, 0-9, hyphens (-)
30
+ * - Cannot start or end with hyphen
31
+ * - Must be lowercase only
32
+ */
1
33
  import "../_dnt.polyfills.js";
2
34
  export declare const checkProjectName: (name: string) => string | undefined;
3
35
  //# sourceMappingURL=validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/app/validate.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,SAoBxD,CAAA"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/app/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,sBAAsB,CAAC;AAE9B,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,SAoBxD,CAAA"}
@@ -1,3 +1,35 @@
1
+ /**
2
+ * Validates a project name against SKMTC naming conventions.
3
+ *
4
+ * Ensures project names follow standard naming patterns suitable for package
5
+ * managers and file systems. Names must be lowercase, contain only letters,
6
+ * numbers, and hyphens, with specific length and format requirements.
7
+ *
8
+ * @param name - The project name to validate
9
+ * @returns An error message string if validation fails, undefined if valid
10
+ *
11
+ * @example Valid project names
12
+ * ```typescript
13
+ * checkProjectName('my-api-client'); // undefined (valid)
14
+ * checkProjectName('user-service'); // undefined (valid)
15
+ * checkProjectName('api2'); // undefined (valid)
16
+ * ```
17
+ *
18
+ * @example Invalid project names
19
+ * ```typescript
20
+ * checkProjectName('A'); // 'Name must be at least 2 characters long'
21
+ * checkProjectName('My-API-Client'); // 'Name must only contain lowercase letters, numbers and hyphens'
22
+ * checkProjectName('-api-client'); // 'Name cannot start with a hyphen'
23
+ * checkProjectName('api-client-'); // 'Name cannot end with a hyphen'
24
+ * ```
25
+ *
26
+ * @example Validation rules
27
+ * - Minimum length: 2 characters
28
+ * - Maximum length: 20 characters
29
+ * - Allowed characters: a-z, 0-9, hyphens (-)
30
+ * - Cannot start or end with hyphen
31
+ * - Must be lowercase only
32
+ */
1
33
  import "../_dnt.polyfills.js";
2
34
  export const checkProjectName = (name) => {
3
35
  if (name.length < 2) {
@@ -9,29 +9,70 @@ import * as log from '../deps/jsr.io/@std/log/0.224.14/mod.js';
9
9
  import type { GeneratorsMapContainer } from '../types/GeneratorType.js';
10
10
  import type { OpenAPIV3 } from 'openapi-types';
11
11
  import type { RenderResult } from './types.js';
12
+ /**
13
+ * Represents the parse phase of the SKMTC pipeline.
14
+ *
15
+ * The parse phase converts OpenAPI v3 JSON documents into internal OAS objects,
16
+ * handling schema validation, reference resolution, and data transformation.
17
+ */
12
18
  export type ParsePhase = {
19
+ /** Identifies this as the parse phase */
13
20
  type: 'parse';
21
+ /** The parse context containing parsed document and utilities */
14
22
  context: ParseContext;
15
23
  };
24
+ /**
25
+ * Represents the generate phase of the SKMTC pipeline.
26
+ *
27
+ * The generate phase transforms parsed OAS objects into generator-specific artifacts,
28
+ * applying templates, handling references, and preparing output files.
29
+ */
16
30
  export type GeneratePhase = {
31
+ /** Identifies this as the generate phase */
17
32
  type: 'generate';
33
+ /** The generate context for artifact creation and processing */
18
34
  context: GenerateContext;
19
35
  };
36
+ /**
37
+ * Represents the render phase of the SKMTC pipeline.
38
+ *
39
+ * The render phase takes generator artifacts and renders them to formatted files,
40
+ * applying code formatting, file system operations, and final output generation.
41
+ */
20
42
  export type RenderPhase = {
43
+ /** Identifies this as the render phase */
21
44
  type: 'render';
45
+ /** The render context for file output and formatting */
22
46
  context: RenderContext;
23
47
  };
48
+ /**
49
+ * Union type representing any phase of the SKMTC pipeline execution.
50
+ *
51
+ * Each execution phase contains its type identifier and associated context,
52
+ * allowing for type-safe phase handling and context access throughout the pipeline.
53
+ */
24
54
  export type ExecutionPhase = ParsePhase | GeneratePhase | RenderPhase;
25
55
  type CoreContextArgs = {
26
56
  spanId: string;
27
57
  logsPath?: string;
28
58
  silent: boolean;
29
59
  };
30
- type ToArtifactsArgs = {
60
+ /**
61
+ * Arguments for the `toArtifacts` method of CoreContext.
62
+ *
63
+ * Contains all the necessary configuration for transforming an OpenAPI document
64
+ * into code artifacts through the SKMTC pipeline.
65
+ */
66
+ export type ToArtifactsArgs = {
67
+ /** The OpenAPI v3 document to process */
31
68
  documentObject: OpenAPIV3.Document;
69
+ /** Client settings for customization (optional) */
32
70
  settings: ClientSettings | undefined;
71
+ /** Function that returns the generator configuration map */
33
72
  toGeneratorConfigMap: <EnrichmentType = undefined>() => GeneratorsMapContainer<EnrichmentType>;
73
+ /** Prettier configuration for code formatting (optional) */
34
74
  prettier?: PrettierConfigType;
75
+ /** Whether to suppress console output */
35
76
  silent: boolean;
36
77
  };
37
78
  /**
@@ -218,13 +259,117 @@ export declare class CoreContext {
218
259
  * @throws Will throw an error if any phase of the pipeline fails
219
260
  */
220
261
  toArtifacts({ documentObject, settings, toGeneratorConfigMap, prettier }: ToArtifactsArgs): Promise<RenderResult>;
262
+ /**
263
+ * Executes a function with distributed tracing and logging.
264
+ *
265
+ * This method wraps function execution with tracing capabilities, updating the
266
+ * stack trail for context tracking and logging execution details. It's used
267
+ * throughout the SKMTC pipeline to maintain execution context and debugging information.
268
+ *
269
+ * @template T - The return type of the traced function
270
+ * @param token - Single token or array of tokens to add to the trace stack
271
+ * @param fn - The function to execute within the trace context
272
+ * @returns The result of executing the traced function
273
+ *
274
+ * @example Single token tracing
275
+ * ```typescript
276
+ * const result = context.trace('parse-schema', () => {
277
+ * // Schema parsing logic here
278
+ * return parsedSchema;
279
+ * });
280
+ * ```
281
+ *
282
+ * @example Multiple token tracing (nested context)
283
+ * ```typescript
284
+ * const result = context.trace(['components', 'schemas', 'User'], () => {
285
+ * // Process User schema
286
+ * return processedUserSchema;
287
+ * });
288
+ * ```
289
+ */
221
290
  trace<T>(token: string | string[], fn: () => T): T;
291
+ /**
292
+ * Captures a result at the current execution position in the stack trail.
293
+ *
294
+ * This method records processing results (success, warning, error, etc.) at the
295
+ * current location in the document traversal stack. Results are associated with
296
+ * the current stack trail position, enabling detailed error reporting and
297
+ * debugging of OpenAPI processing issues.
298
+ *
299
+ * @param result - The type of result to capture (success, warning, error, etc.)
300
+ *
301
+ * @example Capturing a warning result
302
+ * ```typescript
303
+ * context.captureCurrentResult('warning');
304
+ * // Result captured at current stack position like: "components.schemas.User.properties.email"
305
+ * ```
306
+ *
307
+ * @example Usage during schema processing
308
+ * ```typescript
309
+ * context.trace(['components', 'schemas', 'User'], () => {
310
+ * try {
311
+ * processUserSchema();
312
+ * context.captureCurrentResult('success');
313
+ * } catch (error) {
314
+ * context.captureCurrentResult('error');
315
+ * }
316
+ * });
317
+ * ```
318
+ */
222
319
  captureCurrentResult(result: ResultType): void;
223
320
  }
321
+ /**
322
+ * Arguments for the SKMTC JSON log formatter.
323
+ *
324
+ * Contains the log record and stack trail information needed to format
325
+ * structured JSON log entries for the SKMTC processing pipeline.
326
+ */
224
327
  export type JsonFormatterArgs = {
225
- logRecord: log.LogRecord;
328
+ /** The Deno log record containing log level, message, and metadata */
329
+ logRecord: {
330
+ /** The log level name */
331
+ levelName: string;
332
+ /** The timestamp when the log was created */
333
+ datetime: Date;
334
+ /** The log message */
335
+ msg: string;
336
+ /** Additional log arguments */
337
+ args: unknown[];
338
+ };
339
+ /** String representation of the current stack trail position */
226
340
  stackTrail: string;
227
341
  };
342
+ /**
343
+ * Custom JSON formatter for SKMTC log entries.
344
+ *
345
+ * Formats log records into structured JSON that includes stack trail context,
346
+ * making it easier to trace execution and debug issues in the SKMTC pipeline.
347
+ * The formatter flattens log arguments and includes execution context.
348
+ *
349
+ * @param args - Formatter arguments containing log record and stack trail
350
+ * @returns Formatted JSON string for the log entry
351
+ *
352
+ * @example Usage in logger setup
353
+ * ```typescript
354
+ * const handler = new ConsoleHandler("DEBUG", {
355
+ * formatter: (logRecord) => skmtcFormatter({
356
+ * logRecord,
357
+ * stackTrail: context.stackTrail.toString()
358
+ * })
359
+ * });
360
+ * ```
361
+ *
362
+ * @example Output format
363
+ * ```json
364
+ * {
365
+ * "stackTrail": "components.schemas.User.properties.email",
366
+ * "level": "INFO",
367
+ * "datetime": 1645123456789,
368
+ * "message": "Processing email property",
369
+ * "args": { "format": "email", "required": true }
370
+ * }
371
+ * ```
372
+ */
228
373
  export declare function skmtcFormatter({ logRecord, stackTrail }: JsonFormatterArgs): string;
229
374
  export {};
230
375
  //# sourceMappingURL=CoreContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CoreContext.d.ts","sourceRoot":"","sources":["../../src/context/CoreContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,Y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M,iBAAiB,GAAG;IAC9B,sEAAsE;IACtE,SAAS,EAAE;QACT,yBAAyB;QACzB,SAAS,EAAE,MAAM,CAAA;QACjB,6CAA6C;QAC7C,QAAQ,EAAE,IAAI,CAAA;QACd,sBAAsB;QACtB,GAAG,EAAE,MAAM,CAAA;QACX,+BAA+B;QAC/B,IAAI,EAAE,OAAO,EAAE,CAAA;KAChB,CAAA;IACD,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAQnF"}
@@ -278,11 +278,67 @@ export class CoreContext {
278
278
  });
279
279
  }
280
280
  }
281
+ /**
282
+ * Executes a function with distributed tracing and logging.
283
+ *
284
+ * This method wraps function execution with tracing capabilities, updating the
285
+ * stack trail for context tracking and logging execution details. It's used
286
+ * throughout the SKMTC pipeline to maintain execution context and debugging information.
287
+ *
288
+ * @template T - The return type of the traced function
289
+ * @param token - Single token or array of tokens to add to the trace stack
290
+ * @param fn - The function to execute within the trace context
291
+ * @returns The result of executing the traced function
292
+ *
293
+ * @example Single token tracing
294
+ * ```typescript
295
+ * const result = context.trace('parse-schema', () => {
296
+ * // Schema parsing logic here
297
+ * return parsedSchema;
298
+ * });
299
+ * ```
300
+ *
301
+ * @example Multiple token tracing (nested context)
302
+ * ```typescript
303
+ * const result = context.trace(['components', 'schemas', 'User'], () => {
304
+ * // Process User schema
305
+ * return processedUserSchema;
306
+ * });
307
+ * ```
308
+ */
281
309
  trace(token, fn) {
282
310
  console.log('trace', token);
283
311
  this.logger.info('trace', token);
284
312
  return tracer(__classPrivateFieldGet(this, _CoreContext_stackTrail, "f"), token, fn, this.logger);
285
313
  }
314
+ /**
315
+ * Captures a result at the current execution position in the stack trail.
316
+ *
317
+ * This method records processing results (success, warning, error, etc.) at the
318
+ * current location in the document traversal stack. Results are associated with
319
+ * the current stack trail position, enabling detailed error reporting and
320
+ * debugging of OpenAPI processing issues.
321
+ *
322
+ * @param result - The type of result to capture (success, warning, error, etc.)
323
+ *
324
+ * @example Capturing a warning result
325
+ * ```typescript
326
+ * context.captureCurrentResult('warning');
327
+ * // Result captured at current stack position like: "components.schemas.User.properties.email"
328
+ * ```
329
+ *
330
+ * @example Usage during schema processing
331
+ * ```typescript
332
+ * context.trace(['components', 'schemas', 'User'], () => {
333
+ * try {
334
+ * processUserSchema();
335
+ * context.captureCurrentResult('success');
336
+ * } catch (error) {
337
+ * context.captureCurrentResult('error');
338
+ * }
339
+ * });
340
+ * ```
341
+ */
286
342
  captureCurrentResult(result) {
287
343
  __classPrivateFieldGet(this, _CoreContext_results, "f").capture(__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").toString(), result);
288
344
  }
@@ -354,6 +410,37 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
354
410
  });
355
411
  return { type: 'render', context: renderContext };
356
412
  };
413
+ /**
414
+ * Custom JSON formatter for SKMTC log entries.
415
+ *
416
+ * Formats log records into structured JSON that includes stack trail context,
417
+ * making it easier to trace execution and debug issues in the SKMTC pipeline.
418
+ * The formatter flattens log arguments and includes execution context.
419
+ *
420
+ * @param args - Formatter arguments containing log record and stack trail
421
+ * @returns Formatted JSON string for the log entry
422
+ *
423
+ * @example Usage in logger setup
424
+ * ```typescript
425
+ * const handler = new ConsoleHandler("DEBUG", {
426
+ * formatter: (logRecord) => skmtcFormatter({
427
+ * logRecord,
428
+ * stackTrail: context.stackTrail.toString()
429
+ * })
430
+ * });
431
+ * ```
432
+ *
433
+ * @example Output format
434
+ * ```json
435
+ * {
436
+ * "stackTrail": "components.schemas.User.properties.email",
437
+ * "level": "INFO",
438
+ * "datetime": 1645123456789,
439
+ * "message": "Processing email property",
440
+ * "args": { "format": "email", "required": true }
441
+ * }
442
+ * ```
443
+ */
357
444
  export function skmtcFormatter({ logRecord, stackTrail }) {
358
445
  return JSON.stringify({
359
446
  stackTrail,
@@ -30,76 +30,231 @@ type ConstructorArgs = {
30
30
  captureCurrentResult: (result: ResultType) => void;
31
31
  toGeneratorConfigMap: <EnrichmentType = undefined>() => GeneratorsMapContainer<EnrichmentType>;
32
32
  };
33
+ /**
34
+ * Arguments for picking a specific export from a generator module.
35
+ *
36
+ * Used to select and configure specific exports from generator modules
37
+ * during the artifact generation process.
38
+ */
33
39
  export type PickArgs = {
40
+ /** The name of the export to pick from the generator module */
34
41
  name: string;
42
+ /** The file path where the export should be made available */
35
43
  exportPath: string;
36
44
  };
45
+ /**
46
+ * Arguments for registering a JSON file in the generation context.
47
+ *
48
+ * Used to register JSON configuration files, manifests, or other JSON
49
+ * data that should be included in the generated output artifacts.
50
+ */
37
51
  export type RegisterJsonArgs = {
52
+ /** The destination file path where the JSON should be written */
38
53
  destinationPath: string;
54
+ /** The JSON object to write to the file */
39
55
  json: Record<string, unknown>;
40
56
  };
57
+ /**
58
+ * Arguments for applying package imports to a generated file.
59
+ *
60
+ * Used to configure import statements and dependencies when generating
61
+ * code files that need to reference external packages or modules.
62
+ */
41
63
  export type ApplyPackageImportsArgs = {
64
+ /** The destination file path where imports should be applied */
42
65
  destinationPath: string;
66
+ /** The export path for the module being imported */
43
67
  exportPath: string;
44
68
  };
69
+ /**
70
+ * Base arguments for registering generated content in the generation context.
71
+ *
72
+ * Provides the fundamental configuration options for registering imports,
73
+ * re-exports, and definitions that will be included in generated files.
74
+ */
45
75
  export type BaseRegisterArgs = {
76
+ /** Import statements to include, organized by module path */
46
77
  imports?: Record<string, ImportNameArg[]>;
78
+ /** Re-export statements to include, organized by module path */
47
79
  reExports?: Record<string, Identifier[]>;
80
+ /** Definition objects to include in the generated content */
48
81
  definitions?: (Definition | undefined)[];
49
82
  };
83
+ /**
84
+ * Arguments for registering generated content with a specific destination.
85
+ *
86
+ * Extends BaseRegisterArgs to include a destination path, allowing content
87
+ * to be registered and associated with a specific output file location.
88
+ */
50
89
  export type RegisterArgs = {
90
+ /** Import statements to include, organized by module path */
51
91
  imports?: Record<string, ImportNameArg[]>;
92
+ /** Re-export statements to include, organized by module path */
52
93
  reExports?: Record<string, Identifier[]>;
94
+ /** Definition objects to include in the generated content */
53
95
  definitions?: (Definition | undefined)[];
96
+ /** The destination file path where the content should be registered */
54
97
  destinationPath: string;
55
98
  };
99
+ /**
100
+ * Arguments for creating and registering a definition from a schema.
101
+ *
102
+ * Used to transform OpenAPI schema objects into code definitions and
103
+ * register them in the generation context for output file creation.
104
+ *
105
+ * @template Schema - The schema type extending SchemaType
106
+ */
56
107
  export type CreateAndRegisterDefinition<Schema extends SchemaType> = {
108
+ /** The OpenAPI schema to transform into a definition */
57
109
  schema: Schema;
110
+ /** The identifier for the generated definition */
58
111
  identifier: Identifier;
112
+ /** The destination file path where the definition should be registered */
59
113
  destinationPath: string;
114
+ /** Function to transform the schema into a generated value */
60
115
  schemaToValueFn: SchemaToValueFn;
116
+ /** Optional root reference name for the schema */
61
117
  rootRef?: RefName;
118
+ /** Whether to exclude this definition from exports */
62
119
  noExport?: boolean;
63
120
  };
121
+ /**
122
+ * Arguments for defining and registering a value in the generation context.
123
+ *
124
+ * Used to create definitions from pre-generated values and register them
125
+ * in the generation context for inclusion in output files.
126
+ *
127
+ * @template V - The generated value type extending GeneratedValue
128
+ */
64
129
  export type DefineAndRegisterArgs<V extends GeneratedValue> = {
130
+ /** The identifier for the definition */
65
131
  identifier: Identifier;
132
+ /** The generated value to define */
66
133
  value: V;
134
+ /** The destination file path where the definition should be registered */
67
135
  destinationPath: string;
136
+ /** Whether to exclude this definition from exports */
68
137
  noExport?: boolean;
69
138
  };
139
+ /**
140
+ * Arguments for retrieving operation-specific settings.
141
+ *
142
+ * Used to get generator-specific configuration for a particular
143
+ * OpenAPI operation based on its path and HTTP method.
144
+ */
70
145
  export type GetOperationSettingsArgs = {
146
+ /** The ID of the generator requesting settings */
71
147
  generatorId: string;
148
+ /** The API path for the operation */
72
149
  path: string;
150
+ /** The HTTP method for the operation */
73
151
  method: Method;
74
152
  };
153
+ /**
154
+ * Arguments for adding render dependencies for an operation.
155
+ *
156
+ * Used to specify additional dependencies that should be included
157
+ * when rendering code for a specific OpenAPI operation.
158
+ */
75
159
  export type AddRenderDependencyArgs = {
160
+ /** The ID of the generator adding dependencies */
76
161
  generatorId: string;
162
+ /** The OpenAPI operation requiring dependencies */
77
163
  operation: OasOperation;
164
+ /** Array of dependency names or paths to include */
78
165
  dependencies: string[];
79
166
  };
167
+ /**
168
+ * Arguments for retrieving model-specific settings.
169
+ *
170
+ * Used to get generator-specific configuration for a particular
171
+ * OpenAPI model based on its reference name.
172
+ */
80
173
  export type ToModelSettingsArgs = {
174
+ /** The ID of the generator requesting model settings */
81
175
  generatorId: string;
176
+ /** The reference name of the model */
82
177
  refName: RefName;
83
178
  };
179
+ /**
180
+ * Options for inserting an operation into the generation context.
181
+ *
182
+ * Configures how an OpenAPI operation should be processed and
183
+ * included in the generated code output.
184
+ *
185
+ * @template T - The generation type extending GenerationType
186
+ */
84
187
  export type InsertOperationOptions<T extends GenerationType> = {
188
+ /** Whether to exclude this operation from exports */
85
189
  noExport?: boolean;
190
+ /** The type of generation to apply */
86
191
  generation?: T;
192
+ /** Custom destination path for the operation */
87
193
  destinationPath?: string;
88
194
  };
195
+ /**
196
+ * Arguments for inserting a normalized model into the generation context.
197
+ *
198
+ * Used to process and register OpenAPI schema objects as normalized
199
+ * model definitions with fallback naming when schema names are unavailable.
200
+ *
201
+ * @template Schema - The schema type (OasSchema, OasRef, or OasVoid)
202
+ */
89
203
  export type InsertNormalisedModelArgs<Schema extends OasSchema | OasRef<'schema'> | OasVoid> = {
204
+ /** Fallback name to use if the schema doesn't have a name */
90
205
  fallbackName: string;
206
+ /** The OpenAPI schema to normalize and insert */
91
207
  schema: Schema;
208
+ /** The destination file path for the model */
92
209
  destinationPath: string;
93
210
  };
211
+ /**
212
+ * Options for inserting a normalized model.
213
+ *
214
+ * Configures how a normalized model should be processed and
215
+ * included in the generated code output.
216
+ */
94
217
  export type InsertNormalisedModelOptions = {
218
+ /** Whether to exclude this model from exports */
95
219
  noExport?: boolean;
96
220
  };
221
+ /**
222
+ * Return type for inserting a normalized model.
223
+ *
224
+ * Provides type-safe return values based on the schema type being processed.
225
+ * Returns different Definition types depending on whether the schema is a
226
+ * reference or a concrete schema.
227
+ *
228
+ * @template V - The generated value type
229
+ * @template Schema - The schema type being processed
230
+ */
97
231
  export type InsertNormalisedModelReturn<V extends GeneratedValue, Schema extends OasSchema | OasRef<'schema'> | OasVoid> = Schema extends OasRef<'schema'> ? Definition<V> : Definition<TypeSystemOutput<SchemaToNonRef<Schema>['type']>>;
232
+ /**
233
+ * Options for inserting a model into the generation context.
234
+ *
235
+ * Configures how a model should be processed and included in
236
+ * the generated code output.
237
+ *
238
+ * @template T - The generation type extending GenerationType
239
+ */
98
240
  export type InsertModelOptions<T extends GenerationType> = {
241
+ /** Whether to exclude this model from exports */
99
242
  noExport?: boolean;
243
+ /** The type of generation to apply */
100
244
  generation?: T;
245
+ /** Custom destination path for the model */
101
246
  destinationPath?: string;
102
247
  };
248
+ /**
249
+ * Return type for insert operations in the generation context.
250
+ *
251
+ * Represents the result of inserting content into the generation
252
+ * context, providing type-safe access to the inserted content.
253
+ *
254
+ * @template V - The generated value type
255
+ * @template T - The generation type
256
+ * @template EnrichmentType - The enrichment data type
257
+ */
103
258
  export type InsertReturn<V extends GeneratedValue, T extends GenerationType, EnrichmentType> = Inserted<V, T, EnrichmentType>;
104
259
  type ToOperationSettingsArgs<V, EnrichmentType = undefined> = {
105
260
  operation: OasOperation;
@@ -211,12 +366,19 @@ type GenerateResult = {
211
366
  */
212
367
  export declare class GenerateContext {
213
368
  #private;
369
+ /** The parsed OpenAPI document being processed */
214
370
  oasDocument: OasDocument;
371
+ /** Client settings for customization (optional) */
215
372
  settings: ClientSettings | undefined;
373
+ /** Logger instance for tracking generation progress */
216
374
  logger: log.Logger;
375
+ /** Function to capture processing results at current stack position */
217
376
  captureCurrentResult: (result: ResultType) => void;
377
+ /** Function that returns the generator configuration map */
218
378
  toGeneratorConfigMap: <EnrichmentType = undefined>() => GeneratorsMapContainer<EnrichmentType>;
379
+ /** Stack trail for tracking current processing context */
219
380
  stackTrail: StackTrail;
381
+ /** Tracking model nesting depth to prevent infinite recursion */
220
382
  modelDepth: Record<string, number>;
221
383
  constructor({ oasDocument, settings, logger, captureCurrentResult, stackTrail, toGeneratorConfigMap }: ConstructorArgs);
222
384
  /**
@@ -316,11 +478,29 @@ type ToOperationSourceArgs = {
316
478
  operation: OasOperation;
317
479
  generatorId: string;
318
480
  };
481
+ /**
482
+ * Creates an OperationSource from an operation and generator ID.
483
+ *
484
+ * Transforms operation and generator information into a source descriptor
485
+ * that can be used for tracking operation origins in the generation pipeline.
486
+ *
487
+ * @param args - Arguments containing operation and generator ID
488
+ * @returns OperationSource descriptor for the operation
489
+ */
319
490
  export declare const toOperationSource: ({ operation, generatorId }: ToOperationSourceArgs) => OperationSource;
320
491
  type ToModelSourceArgs = {
321
492
  refName: RefName;
322
493
  generatorId: string;
323
494
  };
495
+ /**
496
+ * Creates a ModelSource from a reference name and generator ID.
497
+ *
498
+ * Transforms model reference and generator information into a source descriptor
499
+ * that can be used for tracking model origins in the generation pipeline.
500
+ *
501
+ * @param args - Arguments containing reference name and generator ID
502
+ * @returns ModelSource descriptor for the model
503
+ */
324
504
  export declare const toModelSource: ({ refName, generatorId }: ToModelSourceArgs) => ModelSource;
325
505
  export {};
326
506
  //# sourceMappingURL=GenerateContext.d.ts.map