@skmtc/core 0.0.796 → 0.0.797

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 (55) 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 +137 -1
  5. package/esm/context/CoreContext.d.ts.map +1 -1
  6. package/esm/context/CoreContext.js +87 -0
  7. package/esm/dsl/constants.d.ts +28 -0
  8. package/esm/dsl/constants.d.ts.map +1 -1
  9. package/esm/dsl/constants.js +28 -0
  10. package/esm/oas/_helpers/parseDefault.d.ts +148 -0
  11. package/esm/oas/_helpers/parseDefault.d.ts.map +1 -1
  12. package/esm/oas/_helpers/parseDefault.js +128 -0
  13. package/esm/oas/_helpers/parseEnum.d.ts +124 -0
  14. package/esm/oas/_helpers/parseEnum.d.ts.map +1 -1
  15. package/esm/oas/_helpers/parseEnum.js +104 -0
  16. package/esm/oas/_helpers/parseExample.d.ts +107 -0
  17. package/esm/oas/_helpers/parseExample.d.ts.map +1 -1
  18. package/esm/oas/_helpers/parseExample.js +87 -0
  19. package/esm/oas/_helpers/parseFormat.d.ts +154 -0
  20. package/esm/oas/_helpers/parseFormat.d.ts.map +1 -1
  21. package/esm/oas/_helpers/parseFormat.js +138 -0
  22. package/esm/oas/_helpers/parseNullable.d.ts +127 -0
  23. package/esm/oas/_helpers/parseNullable.d.ts.map +1 -1
  24. package/esm/oas/_helpers/parseNullable.js +113 -0
  25. package/esm/run/toV3JsonDocument.d.ts +90 -0
  26. package/esm/run/toV3JsonDocument.d.ts.map +1 -1
  27. package/esm/run/toV3JsonDocument.js +84 -0
  28. package/package.json +1 -1
  29. package/script/app/validate.d.ts +32 -0
  30. package/script/app/validate.d.ts.map +1 -1
  31. package/script/app/validate.js +32 -0
  32. package/script/context/CoreContext.d.ts +137 -1
  33. package/script/context/CoreContext.d.ts.map +1 -1
  34. package/script/context/CoreContext.js +87 -0
  35. package/script/dsl/constants.d.ts +28 -0
  36. package/script/dsl/constants.d.ts.map +1 -1
  37. package/script/dsl/constants.js +28 -0
  38. package/script/oas/_helpers/parseDefault.d.ts +148 -0
  39. package/script/oas/_helpers/parseDefault.d.ts.map +1 -1
  40. package/script/oas/_helpers/parseDefault.js +128 -0
  41. package/script/oas/_helpers/parseEnum.d.ts +124 -0
  42. package/script/oas/_helpers/parseEnum.d.ts.map +1 -1
  43. package/script/oas/_helpers/parseEnum.js +104 -0
  44. package/script/oas/_helpers/parseExample.d.ts +107 -0
  45. package/script/oas/_helpers/parseExample.d.ts.map +1 -1
  46. package/script/oas/_helpers/parseExample.js +87 -0
  47. package/script/oas/_helpers/parseFormat.d.ts +154 -0
  48. package/script/oas/_helpers/parseFormat.d.ts.map +1 -1
  49. package/script/oas/_helpers/parseFormat.js +138 -0
  50. package/script/oas/_helpers/parseNullable.d.ts +127 -0
  51. package/script/oas/_helpers/parseNullable.d.ts.map +1 -1
  52. package/script/oas/_helpers/parseNullable.js +113 -0
  53. package/script/run/toV3JsonDocument.d.ts +90 -0
  54. package/script/run/toV3JsonDocument.d.ts.map +1 -1
  55. package/script/run/toV3JsonDocument.js +84 -0
@@ -3,6 +3,43 @@ import { parse as parseYaml } from '../deps/jsr.io/@std/yaml/1.0.9/parse.js';
3
3
  import { Converter as ThreeOneToThreeZeroConverter } from '@apiture/openapi-down-convert';
4
4
  import { match, P } from 'ts-pattern';
5
5
  import converter from 'swagger2openapi';
6
+ /**
7
+ * Parses a string into an OpenAPI document object.
8
+ *
9
+ * Automatically detects whether the input string is JSON or YAML format based on
10
+ * the content, then parses it into an OpenAPI document object. Supports all
11
+ * OpenAPI versions (2.0, 3.0.x, 3.1.x).
12
+ *
13
+ * @param schema - The OpenAPI document as a JSON or YAML string
14
+ * @returns Parsed OpenAPI document object
15
+ *
16
+ * @example Parsing JSON OpenAPI document
17
+ * ```typescript
18
+ * const jsonSchema = `{
19
+ * "openapi": "3.0.0",
20
+ * "info": { "title": "My API", "version": "1.0.0" },
21
+ * "paths": {}
22
+ * }`;
23
+ * const document = stringToSchema(jsonSchema);
24
+ * console.log(document.info.title); // "My API"
25
+ * ```
26
+ *
27
+ * @example Parsing YAML OpenAPI document
28
+ * ```typescript
29
+ * const yamlSchema = `
30
+ * openapi: 3.0.0
31
+ * info:
32
+ * title: My API
33
+ * version: 1.0.0
34
+ * paths: {}
35
+ * `;
36
+ * const document = stringToSchema(yamlSchema);
37
+ * console.log(document.info.title); // "My API"
38
+ * ```
39
+ *
40
+ * @throws {SyntaxError} If the JSON is malformed
41
+ * @throws {Error} If the YAML is malformed
42
+ */
6
43
  export const stringToSchema = (schema) => {
7
44
  if (schema.trimStart().startsWith('{')) {
8
45
  return JSON.parse(schema);
@@ -11,6 +48,53 @@ export const stringToSchema = (schema) => {
11
48
  return parseYaml(schema);
12
49
  }
13
50
  };
51
+ /**
52
+ * Converts any OpenAPI document version to OpenAPI 3.0 format.
53
+ *
54
+ * SKMTC processes all documents using OpenAPI 3.0 as the internal format.
55
+ * This function handles version detection and conversion from:
56
+ * - OpenAPI 3.0.x (returned as-is)
57
+ * - OpenAPI 3.1.x (downgraded to 3.0 with allOf transformations)
58
+ * - Swagger 2.0 (upgraded to OpenAPI 3.0)
59
+ *
60
+ * @param schema - The OpenAPI document to convert
61
+ * @returns Promise resolving to an OpenAPI 3.0 document
62
+ *
63
+ * @example Converting OpenAPI 3.1 to 3.0
64
+ * ```typescript
65
+ * const openapi31Doc = {
66
+ * openapi: "3.1.0",
67
+ * info: { title: "My API", version: "1.0.0" },
68
+ * paths: {}
69
+ * };
70
+ * const v3Doc = await toV3Document(openapi31Doc);
71
+ * console.log(v3Doc.openapi); // "3.0.3" (converted)
72
+ * ```
73
+ *
74
+ * @example Converting Swagger 2.0 to OpenAPI 3.0
75
+ * ```typescript
76
+ * const swagger2Doc = {
77
+ * swagger: "2.0",
78
+ * info: { title: "My API", version: "1.0.0" },
79
+ * paths: {}
80
+ * };
81
+ * const v3Doc = await toV3Document(swagger2Doc);
82
+ * console.log(v3Doc.openapi); // "3.0.0" (converted)
83
+ * ```
84
+ *
85
+ * @example OpenAPI 3.0 passthrough
86
+ * ```typescript
87
+ * const openapi30Doc = {
88
+ * openapi: "3.0.2",
89
+ * info: { title: "My API", version: "1.0.0" },
90
+ * paths: {}
91
+ * };
92
+ * const v3Doc = await toV3Document(openapi30Doc);
93
+ * console.log(v3Doc === openapi30Doc); // true (same object)
94
+ * ```
95
+ *
96
+ * @throws {Error} If the document version is not recognized or supported
97
+ */
14
98
  export const toV3Document = async (schema) => {
15
99
  return await match(schema)
16
100
  .with({ openapi: P.string.startsWith('3.0') }, doc => doc)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.796",
3
+ "version": "0.0.797",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/skmtc/skmtc.git"
@@ -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,6 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkProjectName = void 0;
4
+ /**
5
+ * Validates a project name against SKMTC naming conventions.
6
+ *
7
+ * Ensures project names follow standard naming patterns suitable for package
8
+ * managers and file systems. Names must be lowercase, contain only letters,
9
+ * numbers, and hyphens, with specific length and format requirements.
10
+ *
11
+ * @param name - The project name to validate
12
+ * @returns An error message string if validation fails, undefined if valid
13
+ *
14
+ * @example Valid project names
15
+ * ```typescript
16
+ * checkProjectName('my-api-client'); // undefined (valid)
17
+ * checkProjectName('user-service'); // undefined (valid)
18
+ * checkProjectName('api2'); // undefined (valid)
19
+ * ```
20
+ *
21
+ * @example Invalid project names
22
+ * ```typescript
23
+ * checkProjectName('A'); // 'Name must be at least 2 characters long'
24
+ * checkProjectName('My-API-Client'); // 'Name must only contain lowercase letters, numbers and hyphens'
25
+ * checkProjectName('-api-client'); // 'Name cannot start with a hyphen'
26
+ * checkProjectName('api-client-'); // 'Name cannot end with a hyphen'
27
+ * ```
28
+ *
29
+ * @example Validation rules
30
+ * - Minimum length: 2 characters
31
+ * - Maximum length: 20 characters
32
+ * - Allowed characters: a-z, 0-9, hyphens (-)
33
+ * - Cannot start or end with hyphen
34
+ * - Must be lowercase only
35
+ */
4
36
  require("../_dnt.polyfills.js");
5
37
  const checkProjectName = (name) => {
6
38
  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,108 @@ 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 = {
328
+ /** The Deno log record containing log level, message, and metadata */
225
329
  logRecord: log.LogRecord;
330
+ /** String representation of the current stack trail position */
226
331
  stackTrail: string;
227
332
  };
333
+ /**
334
+ * Custom JSON formatter for SKMTC log entries.
335
+ *
336
+ * Formats log records into structured JSON that includes stack trail context,
337
+ * making it easier to trace execution and debug issues in the SKMTC pipeline.
338
+ * The formatter flattens log arguments and includes execution context.
339
+ *
340
+ * @param args - Formatter arguments containing log record and stack trail
341
+ * @returns Formatted JSON string for the log entry
342
+ *
343
+ * @example Usage in logger setup
344
+ * ```typescript
345
+ * const handler = new ConsoleHandler("DEBUG", {
346
+ * formatter: (logRecord) => skmtcFormatter({
347
+ * logRecord,
348
+ * stackTrail: context.stackTrail.toString()
349
+ * })
350
+ * });
351
+ * ```
352
+ *
353
+ * @example Output format
354
+ * ```json
355
+ * {
356
+ * "stackTrail": "components.schemas.User.properties.email",
357
+ * "level": "INFO",
358
+ * "datetime": 1645123456789,
359
+ * "message": "Processing email property",
360
+ * "args": { "format": "email", "required": true }
361
+ * }
362
+ * ```
363
+ */
228
364
  export declare function skmtcFormatter({ logRecord, stackTrail }: JsonFormatterArgs): string;
229
365
  export {};
230
366
  //# 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,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,GAAG,MAAM,yCAAyC,CAAA;AAQ9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAEvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,eAAe,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,QAAQ,CAAA;IACd,OAAO,EAAE,aAAa,CAAA;CACvB,CAAA;AAED,MAAM,MAAM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;;;;;;;;;;;;;;;;OAsEG;IACG,WAAW,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,oBAAoB,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;IA2DvH;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAkClD;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;CAkB/C;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,sEAAsE;IACtE,SAAS,EAAE,GAAG,CAAC,SAAS,CAAA;IACxB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAQnF"}
@@ -315,11 +315,67 @@ class CoreContext {
315
315
  });
316
316
  }
317
317
  }
318
+ /**
319
+ * Executes a function with distributed tracing and logging.
320
+ *
321
+ * This method wraps function execution with tracing capabilities, updating the
322
+ * stack trail for context tracking and logging execution details. It's used
323
+ * throughout the SKMTC pipeline to maintain execution context and debugging information.
324
+ *
325
+ * @template T - The return type of the traced function
326
+ * @param token - Single token or array of tokens to add to the trace stack
327
+ * @param fn - The function to execute within the trace context
328
+ * @returns The result of executing the traced function
329
+ *
330
+ * @example Single token tracing
331
+ * ```typescript
332
+ * const result = context.trace('parse-schema', () => {
333
+ * // Schema parsing logic here
334
+ * return parsedSchema;
335
+ * });
336
+ * ```
337
+ *
338
+ * @example Multiple token tracing (nested context)
339
+ * ```typescript
340
+ * const result = context.trace(['components', 'schemas', 'User'], () => {
341
+ * // Process User schema
342
+ * return processedUserSchema;
343
+ * });
344
+ * ```
345
+ */
318
346
  trace(token, fn) {
319
347
  console.log('trace', token);
320
348
  this.logger.info('trace', token);
321
349
  return (0, tracer_js_1.tracer)(__classPrivateFieldGet(this, _CoreContext_stackTrail, "f"), token, fn, this.logger);
322
350
  }
351
+ /**
352
+ * Captures a result at the current execution position in the stack trail.
353
+ *
354
+ * This method records processing results (success, warning, error, etc.) at the
355
+ * current location in the document traversal stack. Results are associated with
356
+ * the current stack trail position, enabling detailed error reporting and
357
+ * debugging of OpenAPI processing issues.
358
+ *
359
+ * @param result - The type of result to capture (success, warning, error, etc.)
360
+ *
361
+ * @example Capturing a warning result
362
+ * ```typescript
363
+ * context.captureCurrentResult('warning');
364
+ * // Result captured at current stack position like: "components.schemas.User.properties.email"
365
+ * ```
366
+ *
367
+ * @example Usage during schema processing
368
+ * ```typescript
369
+ * context.trace(['components', 'schemas', 'User'], () => {
370
+ * try {
371
+ * processUserSchema();
372
+ * context.captureCurrentResult('success');
373
+ * } catch (error) {
374
+ * context.captureCurrentResult('error');
375
+ * }
376
+ * });
377
+ * ```
378
+ */
323
379
  captureCurrentResult(result) {
324
380
  __classPrivateFieldGet(this, _CoreContext_results, "f").capture(__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").toString(), result);
325
381
  }
@@ -392,6 +448,37 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
392
448
  });
393
449
  return { type: 'render', context: renderContext };
394
450
  };
451
+ /**
452
+ * Custom JSON formatter for SKMTC log entries.
453
+ *
454
+ * Formats log records into structured JSON that includes stack trail context,
455
+ * making it easier to trace execution and debug issues in the SKMTC pipeline.
456
+ * The formatter flattens log arguments and includes execution context.
457
+ *
458
+ * @param args - Formatter arguments containing log record and stack trail
459
+ * @returns Formatted JSON string for the log entry
460
+ *
461
+ * @example Usage in logger setup
462
+ * ```typescript
463
+ * const handler = new ConsoleHandler("DEBUG", {
464
+ * formatter: (logRecord) => skmtcFormatter({
465
+ * logRecord,
466
+ * stackTrail: context.stackTrail.toString()
467
+ * })
468
+ * });
469
+ * ```
470
+ *
471
+ * @example Output format
472
+ * ```json
473
+ * {
474
+ * "stackTrail": "components.schemas.User.properties.email",
475
+ * "level": "INFO",
476
+ * "datetime": 1645123456789,
477
+ * "message": "Processing email property",
478
+ * "args": { "format": "email", "required": true }
479
+ * }
480
+ * ```
481
+ */
395
482
  function skmtcFormatter({ logRecord, stackTrail }) {
396
483
  return JSON.stringify({
397
484
  stackTrail,
@@ -1,2 +1,30 @@
1
+ /**
2
+ * Marker constant representing an empty or unset value in the SKMTC DSL system.
3
+ *
4
+ * This constant is used throughout the DSL to represent placeholders, empty
5
+ * templates, or uninitialized content. It provides a consistent way to identify
6
+ * empty states that need to be handled during code generation.
7
+ *
8
+ * @example Usage in templates
9
+ * ```typescript
10
+ * import { EMPTY } from '@skmtc/core';
11
+ *
12
+ * const template = someCondition ? 'actual content' : EMPTY;
13
+ *
14
+ * if (template === EMPTY) {
15
+ * // Handle empty state
16
+ * console.log('No content to generate');
17
+ * }
18
+ * ```
19
+ *
20
+ * @example DSL content generation
21
+ * ```typescript
22
+ * const content = new List([
23
+ * 'import { User } from "./types";',
24
+ * someFeature ? 'import { Admin } from "./admin";' : EMPTY,
25
+ * 'export { User };'
26
+ * ]).filter(line => line !== EMPTY);
27
+ * ```
28
+ */
1
29
  export declare const EMPTY = "__EMPTY__";
2
30
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/dsl/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,cAAc,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/dsl/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,KAAK,cAAc,CAAA"}
@@ -1,4 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EMPTY = void 0;
4
+ /**
5
+ * Marker constant representing an empty or unset value in the SKMTC DSL system.
6
+ *
7
+ * This constant is used throughout the DSL to represent placeholders, empty
8
+ * templates, or uninitialized content. It provides a consistent way to identify
9
+ * empty states that need to be handled during code generation.
10
+ *
11
+ * @example Usage in templates
12
+ * ```typescript
13
+ * import { EMPTY } from '@skmtc/core';
14
+ *
15
+ * const template = someCondition ? 'actual content' : EMPTY;
16
+ *
17
+ * if (template === EMPTY) {
18
+ * // Handle empty state
19
+ * console.log('No content to generate');
20
+ * }
21
+ * ```
22
+ *
23
+ * @example DSL content generation
24
+ * ```typescript
25
+ * const content = new List([
26
+ * 'import { User } from "./types";',
27
+ * someFeature ? 'import { Admin } from "./admin";' : EMPTY,
28
+ * 'export { User };'
29
+ * ]).filter(line => line !== EMPTY);
30
+ * ```
31
+ */
4
32
  exports.EMPTY = '__EMPTY__';