@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
@@ -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,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,W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AW,EAAE,WAAW,CAAA;KAAE;IAUvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
@@ -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,
@@ -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 +1,29 @@
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 const EMPTY = '__EMPTY__';
@@ -1,16 +1,164 @@
1
1
  import type { OpenAPIV3 } from 'openapi-types';
2
2
  import type { ParseContext } from '../../context/ParseContext.js';
3
3
  import * as v from 'valibot';
4
+ /**
5
+ * Arguments for parsing OpenAPI schema default values.
6
+ *
7
+ * @template T - The expected type of the default value
8
+ * @template Nullable - Whether the schema allows null values
9
+ * @template Value - The OpenAPI schema object type
10
+ */
4
11
  type ParseDefaultArgs<T, Nullable extends boolean | undefined, Value extends OpenAPIV3.SchemaObject> = {
12
+ /** The OpenAPI schema object without nullable, example, and enum properties */
5
13
  value: Omit<Value, 'nullable' | 'example' | 'enum'>;
14
+ /** Whether the schema allows null values */
6
15
  nullable: Nullable;
16
+ /** Valibot schema for validating the default value */
7
17
  valibotSchema: v.GenericSchema<T>;
18
+ /** Parse context for error handling */
8
19
  context: ParseContext;
9
20
  };
21
+ /**
22
+ * Return type for parsed default value data.
23
+ *
24
+ * @template T - The expected type of the default value
25
+ * @template Nullable - Whether the schema allows null values
26
+ * @template Value - The OpenAPI schema object type
27
+ */
10
28
  type ParseDefaultReturn<T, Nullable extends boolean | undefined, Value extends OpenAPIV3.SchemaObject> = {
29
+ /** The parsed and validated default value */
11
30
  default: Nullable extends true ? T | null | undefined : T | undefined;
31
+ /** The schema object with all processed properties removed */
12
32
  value: Omit<Value, 'nullable' | 'example' | 'enum' | 'default'>;
13
33
  };
34
+ /**
35
+ * Parses and validates OpenAPI schema default values with type safety.
36
+ *
37
+ * This function extracts and validates default values from OpenAPI schema objects,
38
+ * ensuring they conform to the expected type and handling nullable schemas correctly.
39
+ * Invalid default values are removed and logged as warnings through the parse context.
40
+ *
41
+ * The function provides full type safety, with the return type reflecting whether
42
+ * null values are allowed based on the nullable parameter. This ensures that
43
+ * generated code maintains proper type constraints for default values.
44
+ *
45
+ * @template T - The expected type of the default value
46
+ * @template Nullable - Whether the schema allows null as a default
47
+ * @template Value - The OpenAPI schema object type
48
+ *
49
+ * @param args - Parsing configuration
50
+ * @returns Parsed default data with the validated default value and cleaned schema
51
+ *
52
+ * @example Basic string default parsing
53
+ * ```typescript
54
+ * import { parseDefault } from '@skmtc/core/oas/_helpers';
55
+ * import * as v from 'valibot';
56
+ *
57
+ * const result = parseDefault({
58
+ * value: {
59
+ * type: 'string',
60
+ * default: 'hello world',
61
+ * minLength: 5
62
+ * },
63
+ * nullable: false,
64
+ * valibotSchema: v.string(),
65
+ * context: parseContext
66
+ * });
67
+ *
68
+ * console.log(result.default); // 'hello world'
69
+ * console.log(result.value); // { type: 'string', minLength: 5 }
70
+ * ```
71
+ *
72
+ * @example Nullable default value
73
+ * ```typescript
74
+ * const result = parseDefault({
75
+ * value: {
76
+ * type: 'string',
77
+ * default: null,
78
+ * format: 'email'
79
+ * },
80
+ * nullable: true,
81
+ * valibotSchema: v.string(),
82
+ * context: parseContext
83
+ * });
84
+ *
85
+ * console.log(result.default); // null (valid for nullable schema)
86
+ * // Type: string | null | undefined
87
+ * ```
88
+ *
89
+ * @example Number default with constraints
90
+ * ```typescript
91
+ * const result = parseDefault({
92
+ * value: {
93
+ * type: 'number',
94
+ * default: 42,
95
+ * minimum: 0,
96
+ * maximum: 100
97
+ * },
98
+ * nullable: false,
99
+ * valibotSchema: v.number(),
100
+ * context: parseContext
101
+ * });
102
+ *
103
+ * console.log(result.default); // 42
104
+ * console.log(result.value); // { type: 'number', minimum: 0, maximum: 100 }
105
+ * ```
106
+ *
107
+ * @example Invalid default handling
108
+ * ```typescript
109
+ * const result = parseDefault({
110
+ * value: {
111
+ * type: 'boolean',
112
+ * default: 'not a boolean', // Invalid default
113
+ * description: 'A boolean flag'
114
+ * },
115
+ * nullable: false,
116
+ * valibotSchema: v.boolean(),
117
+ * context: parseContext
118
+ * });
119
+ *
120
+ * console.log(result.default); // undefined (invalid default removed)
121
+ * // Context will log a warning about the invalid default
122
+ * ```
123
+ *
124
+ * @example Array default value
125
+ * ```typescript
126
+ * const result = parseDefault({
127
+ * value: {
128
+ * type: 'array',
129
+ * items: { type: 'string' },
130
+ * default: ['item1', 'item2']
131
+ * },
132
+ * nullable: false,
133
+ * valibotSchema: v.array(v.string()),
134
+ * context: parseContext
135
+ * });
136
+ *
137
+ * console.log(result.default); // ['item1', 'item2']
138
+ * ```
139
+ *
140
+ * @example Object default value
141
+ * ```typescript
142
+ * const result = parseDefault({
143
+ * value: {
144
+ * type: 'object',
145
+ * properties: {
146
+ * name: { type: 'string' },
147
+ * age: { type: 'number' }
148
+ * },
149
+ * default: { name: 'John', age: 30 }
150
+ * },
151
+ * nullable: false,
152
+ * valibotSchema: v.object({
153
+ * name: v.string(),
154
+ * age: v.number()
155
+ * }),
156
+ * context: parseContext
157
+ * });
158
+ *
159
+ * console.log(result.default); // { name: 'John', age: 30 }
160
+ * ```
161
+ */
14
162
  export declare const parseDefault: <T, Nullable extends boolean | undefined, Value extends OpenAPIV3.SchemaObject>({ value, nullable, valibotSchema, context }: ParseDefaultArgs<T, Nullable, Value>) => ParseDefaultReturn<T, Nullable, Value>;
15
163
  export {};
16
164
  //# sourceMappingURL=parseDefault.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseDefault.d.ts","sourceRoot":"","sources":["../../../src/oas/_helpers/parseDefault.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,KAAK,gBAAgB,CACnB,CAAC,EACD,QAAQ,SAAS,OAAO,GAAG,SAAS,EACpC,KAAK,SAAS,SAAS,CAAC,YAAY,IAClC;IACF,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC,CAAA;IACnD,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;IACjC,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,KAAK,kBAAkB,CACrB,CAAC,EACD,QAAQ,SAAS,OAAO,GAAG,SAAS,EACpC,KAAK,SAAS,SAAS,CAAC,YAAY,IAClC;IACF,OAAO,EAAE,QAAQ,SAAS,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,CAAA;IACrE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC,CAAA;CAChE,CAAA;AAED,eAAO,MAAM,YAAY,GACvB,CAAC,EACD,QAAQ,SAAS,OAAO,GAAG,SAAS,EACpC,KAAK,SAAS,SAAS,CAAC,YAAY,EACpC,6CAKC,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,KAAG,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAgB9E,CAAA"}
1
+ {"version":3,"file":"parseDefault.d.ts","sourceRoot":"","sources":["../../../src/oas/_helpers/parseDefault.ts"],"names":[],"mappings":"AAAA,OAA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