@skmtc/core 0.0.792 → 0.0.794

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 (113) hide show
  1. package/esm/dsl/GeneratedValueList.d.ts +158 -0
  2. package/esm/dsl/GeneratedValueList.d.ts.map +1 -1
  3. package/esm/dsl/GeneratedValueList.js +158 -0
  4. package/esm/dsl/Stringable.d.ts +76 -0
  5. package/esm/dsl/Stringable.d.ts.map +1 -1
  6. package/esm/dsl/Stringable.js +75 -0
  7. package/esm/helpers/ResultsLog.d.ts +193 -0
  8. package/esm/helpers/ResultsLog.d.ts.map +1 -1
  9. package/esm/helpers/ResultsLog.js +213 -0
  10. package/esm/helpers/collateExamples.d.ts +150 -0
  11. package/esm/helpers/collateExamples.d.ts.map +1 -1
  12. package/esm/helpers/collateExamples.js +145 -0
  13. package/esm/helpers/formatNumber.d.ts +95 -0
  14. package/esm/helpers/formatNumber.d.ts.map +1 -1
  15. package/esm/helpers/formatNumber.js +95 -0
  16. package/esm/helpers/generationStats.d.ts +287 -1
  17. package/esm/helpers/generationStats.d.ts.map +1 -1
  18. package/esm/helpers/generationStats.js +266 -0
  19. package/esm/helpers/isEmpty.d.ts +62 -0
  20. package/esm/helpers/isEmpty.d.ts.map +1 -1
  21. package/esm/helpers/isEmpty.js +62 -0
  22. package/esm/helpers/isImported.d.ts +80 -0
  23. package/esm/helpers/isImported.d.ts.map +1 -1
  24. package/esm/helpers/isImported.js +80 -0
  25. package/esm/helpers/parseModuleName.d.ts +175 -0
  26. package/esm/helpers/parseModuleName.d.ts.map +1 -1
  27. package/esm/helpers/parseModuleName.js +153 -0
  28. package/esm/helpers/toResolvedArtifactPath.d.ts +145 -0
  29. package/esm/helpers/toResolvedArtifactPath.d.ts.map +1 -1
  30. package/esm/helpers/toResolvedArtifactPath.js +140 -0
  31. package/esm/helpers/tracer.d.ts +124 -0
  32. package/esm/helpers/tracer.d.ts.map +1 -1
  33. package/esm/helpers/tracer.js +124 -0
  34. package/esm/oas/schema/Schema.d.ts +117 -0
  35. package/esm/oas/schema/Schema.d.ts.map +1 -1
  36. package/esm/typescript/PathParams.d.ts +198 -0
  37. package/esm/typescript/PathParams.d.ts.map +1 -1
  38. package/esm/typescript/PathParams.js +190 -0
  39. package/esm/typescript/ReactRouterPathParams.d.ts +190 -0
  40. package/esm/typescript/ReactRouterPathParams.d.ts.map +1 -1
  41. package/esm/typescript/ReactRouterPathParams.js +183 -0
  42. package/esm/typescript/identifiers.d.ts +159 -0
  43. package/esm/typescript/identifiers.d.ts.map +1 -1
  44. package/esm/typescript/identifiers.js +159 -0
  45. package/esm/typescript/keyValues.d.ts +125 -0
  46. package/esm/typescript/keyValues.d.ts.map +1 -1
  47. package/esm/typescript/keyValues.js +125 -1
  48. package/esm/typescript/toPathParams.d.ts +179 -0
  49. package/esm/typescript/toPathParams.d.ts.map +1 -1
  50. package/esm/typescript/toPathParams.js +179 -0
  51. package/esm/typescript/toPathTemplate.d.ts +114 -0
  52. package/esm/typescript/toPathTemplate.d.ts.map +1 -1
  53. package/esm/typescript/toPathTemplate.js +114 -0
  54. package/esm/typescript/withDescription.d.ts +119 -0
  55. package/esm/typescript/withDescription.d.ts.map +1 -1
  56. package/esm/typescript/withDescription.js +119 -0
  57. package/package.json +1 -1
  58. package/script/dsl/GeneratedValueList.d.ts +158 -0
  59. package/script/dsl/GeneratedValueList.d.ts.map +1 -1
  60. package/script/dsl/GeneratedValueList.js +158 -0
  61. package/script/dsl/Stringable.d.ts +76 -0
  62. package/script/dsl/Stringable.d.ts.map +1 -1
  63. package/script/dsl/Stringable.js +75 -0
  64. package/script/helpers/ResultsLog.d.ts +193 -0
  65. package/script/helpers/ResultsLog.d.ts.map +1 -1
  66. package/script/helpers/ResultsLog.js +213 -0
  67. package/script/helpers/collateExamples.d.ts +150 -0
  68. package/script/helpers/collateExamples.d.ts.map +1 -1
  69. package/script/helpers/collateExamples.js +145 -0
  70. package/script/helpers/formatNumber.d.ts +95 -0
  71. package/script/helpers/formatNumber.d.ts.map +1 -1
  72. package/script/helpers/formatNumber.js +95 -0
  73. package/script/helpers/generationStats.d.ts +287 -1
  74. package/script/helpers/generationStats.d.ts.map +1 -1
  75. package/script/helpers/generationStats.js +266 -0
  76. package/script/helpers/isEmpty.d.ts +62 -0
  77. package/script/helpers/isEmpty.d.ts.map +1 -1
  78. package/script/helpers/isEmpty.js +62 -0
  79. package/script/helpers/isImported.d.ts +80 -0
  80. package/script/helpers/isImported.d.ts.map +1 -1
  81. package/script/helpers/isImported.js +80 -0
  82. package/script/helpers/parseModuleName.d.ts +175 -0
  83. package/script/helpers/parseModuleName.d.ts.map +1 -1
  84. package/script/helpers/parseModuleName.js +153 -0
  85. package/script/helpers/toResolvedArtifactPath.d.ts +145 -0
  86. package/script/helpers/toResolvedArtifactPath.d.ts.map +1 -1
  87. package/script/helpers/toResolvedArtifactPath.js +140 -0
  88. package/script/helpers/tracer.d.ts +124 -0
  89. package/script/helpers/tracer.d.ts.map +1 -1
  90. package/script/helpers/tracer.js +124 -0
  91. package/script/oas/schema/Schema.d.ts +117 -0
  92. package/script/oas/schema/Schema.d.ts.map +1 -1
  93. package/script/typescript/PathParams.d.ts +198 -0
  94. package/script/typescript/PathParams.d.ts.map +1 -1
  95. package/script/typescript/PathParams.js +190 -0
  96. package/script/typescript/ReactRouterPathParams.d.ts +190 -0
  97. package/script/typescript/ReactRouterPathParams.d.ts.map +1 -1
  98. package/script/typescript/ReactRouterPathParams.js +183 -0
  99. package/script/typescript/identifiers.d.ts +159 -0
  100. package/script/typescript/identifiers.d.ts.map +1 -1
  101. package/script/typescript/identifiers.js +159 -0
  102. package/script/typescript/keyValues.d.ts +125 -0
  103. package/script/typescript/keyValues.d.ts.map +1 -1
  104. package/script/typescript/keyValues.js +125 -1
  105. package/script/typescript/toPathParams.d.ts +179 -0
  106. package/script/typescript/toPathParams.d.ts.map +1 -1
  107. package/script/typescript/toPathParams.js +179 -0
  108. package/script/typescript/toPathTemplate.d.ts +114 -0
  109. package/script/typescript/toPathTemplate.d.ts.map +1 -1
  110. package/script/typescript/toPathTemplate.js +114 -0
  111. package/script/typescript/withDescription.d.ts +119 -0
  112. package/script/typescript/withDescription.d.ts.map +1 -1
  113. package/script/typescript/withDescription.js +119 -0
@@ -1,4 +1,128 @@
1
1
  import type { Logger } from '../deps/jsr.io/@std/log/0.224.14/logger.js';
2
2
  import type { StackTrail } from '../context/StackTrail.js';
3
+ /**
4
+ * Executes a function with distributed tracing support and stack trail management.
5
+ *
6
+ * This utility function provides distributed tracing capabilities for the SKMTC
7
+ * generation pipeline. It manages stack trail tokens that help track execution
8
+ * context across complex nested operations, making debugging and performance
9
+ * analysis much easier.
10
+ *
11
+ * The tracer ensures proper cleanup of stack trail tokens even if the wrapped
12
+ * function throws an error, maintaining the integrity of the tracing system.
13
+ * This is essential for accurate debugging and performance monitoring in
14
+ * complex code generation scenarios.
15
+ *
16
+ * @template T - The return type of the traced function
17
+ * @param stackTrail - The stack trail instance for tracking execution context
18
+ * @param token - Token(s) to identify this execution step in traces
19
+ * @param fn - The function to execute with tracing
20
+ * @param log - Logger instance for error reporting
21
+ * @returns The result of the wrapped function execution
22
+ *
23
+ * @throws Re-throws any error from the wrapped function after cleanup
24
+ *
25
+ * @example Basic tracing usage
26
+ * ```typescript
27
+ * import { tracer } from '@skmtc/core';
28
+ *
29
+ * class ModelGenerator {
30
+ * generateModel(stackTrail: StackTrail, logger: Logger) {
31
+ * return tracer(stackTrail, 'generate-model', () => {
32
+ * // Complex model generation logic here
33
+ * return this.createModelDefinition();
34
+ * }, logger);
35
+ * }
36
+ * }
37
+ * ```
38
+ *
39
+ * @example Nested tracing
40
+ * ```typescript
41
+ * class ComplexProcessor {
42
+ * processSchema(stackTrail: StackTrail, logger: Logger) {
43
+ * return tracer(stackTrail, 'process-schema', () => {
44
+ * const parsed = tracer(stackTrail, 'parse', () => {
45
+ * return this.parseSchema();
46
+ * }, logger);
47
+ *
48
+ * const validated = tracer(stackTrail, 'validate', () => {
49
+ * return this.validateSchema(parsed);
50
+ * }, logger);
51
+ *
52
+ * return tracer(stackTrail, 'transform', () => {
53
+ * return this.transformSchema(validated);
54
+ * }, logger);
55
+ * }, logger);
56
+ * }
57
+ * }
58
+ *
59
+ * // Stack trail will show: ['process-schema', 'parse'] -> ['process-schema', 'validate'] -> ['process-schema', 'transform']
60
+ * ```
61
+ *
62
+ * @example Multiple token tracing
63
+ * ```typescript
64
+ * const result = tracer(
65
+ * stackTrail,
66
+ * ['file-generation', 'models.ts'], // Multiple tokens for detailed context
67
+ * () => {
68
+ * return generateModelsFile();
69
+ * },
70
+ * logger
71
+ * );
72
+ * ```
73
+ *
74
+ * @example Error handling with tracing
75
+ * ```typescript
76
+ * class SafeGenerator {
77
+ * generateWithTracing(stackTrail: StackTrail, logger: Logger) {
78
+ * try {
79
+ * return tracer(stackTrail, 'risky-operation', () => {
80
+ * // This might throw an error
81
+ * return this.complexGeneration();
82
+ * }, logger);
83
+ * } catch (error) {
84
+ * // Stack trail is automatically cleaned up
85
+ * logger.error(`Generation failed: ${error.message}`);
86
+ * return this.fallbackGeneration();
87
+ * }
88
+ * }
89
+ * }
90
+ * ```
91
+ *
92
+ * @example Performance monitoring
93
+ * ```typescript
94
+ * class PerformanceAwareGenerator {
95
+ * timedGeneration(stackTrail: StackTrail, logger: Logger) {
96
+ * const startTime = Date.now();
97
+ *
98
+ * const result = tracer(stackTrail, 'timed-generation', () => {
99
+ * return this.heavyComputation();
100
+ * }, logger);
101
+ *
102
+ * const duration = Date.now() - startTime;
103
+ * logger.info(`Generation completed in ${duration}ms`);
104
+ *
105
+ * return result;
106
+ * }
107
+ * }
108
+ * ```
109
+ *
110
+ * @example Integration with context classes
111
+ * ```typescript
112
+ * // Typically used within context classes like this:
113
+ * class GenerateContext {
114
+ * trace<T>(token: string | string[], fn: () => T): T {
115
+ * return tracer(this.stackTrail, token, fn, this.logger);
116
+ * }
117
+ *
118
+ * processModel(schema: OasSchema) {
119
+ * return this.trace(['model', schema.type], () => {
120
+ * // Model processing logic
121
+ * return this.createModel(schema);
122
+ * });
123
+ * }
124
+ * }
125
+ * ```
126
+ */
3
127
  export declare const tracer: <T>(stackTrail: StackTrail, token: string | string[], fn: () => T, log: Logger) => T;
4
128
  //# sourceMappingURL=tracer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../src/helpers/tracer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4CAA4C,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,eAAO,MAAM,MAAM,GAAI,CAAC,EACtB,YAAY,UAAU,EACtB,OAAO,MAAM,GAAG,MAAM,EAAE,EACxB,IAAI,MAAM,CAAC,EACX,KAAK,MAAM,MAgBZ,CAAA"}
1
+ {"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../src/helpers/tracer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4CAA4C,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2HG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EACtB,YAAY,UAAU,EACtB,OAAO,MAAM,GAAG,MAAM,EAAE,EACxB,IAAI,MAAM,CAAC,EACX,KAAK,MAAM,MAgBZ,CAAA"}
@@ -1,6 +1,130 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tracer = void 0;
4
+ /**
5
+ * Executes a function with distributed tracing support and stack trail management.
6
+ *
7
+ * This utility function provides distributed tracing capabilities for the SKMTC
8
+ * generation pipeline. It manages stack trail tokens that help track execution
9
+ * context across complex nested operations, making debugging and performance
10
+ * analysis much easier.
11
+ *
12
+ * The tracer ensures proper cleanup of stack trail tokens even if the wrapped
13
+ * function throws an error, maintaining the integrity of the tracing system.
14
+ * This is essential for accurate debugging and performance monitoring in
15
+ * complex code generation scenarios.
16
+ *
17
+ * @template T - The return type of the traced function
18
+ * @param stackTrail - The stack trail instance for tracking execution context
19
+ * @param token - Token(s) to identify this execution step in traces
20
+ * @param fn - The function to execute with tracing
21
+ * @param log - Logger instance for error reporting
22
+ * @returns The result of the wrapped function execution
23
+ *
24
+ * @throws Re-throws any error from the wrapped function after cleanup
25
+ *
26
+ * @example Basic tracing usage
27
+ * ```typescript
28
+ * import { tracer } from '@skmtc/core';
29
+ *
30
+ * class ModelGenerator {
31
+ * generateModel(stackTrail: StackTrail, logger: Logger) {
32
+ * return tracer(stackTrail, 'generate-model', () => {
33
+ * // Complex model generation logic here
34
+ * return this.createModelDefinition();
35
+ * }, logger);
36
+ * }
37
+ * }
38
+ * ```
39
+ *
40
+ * @example Nested tracing
41
+ * ```typescript
42
+ * class ComplexProcessor {
43
+ * processSchema(stackTrail: StackTrail, logger: Logger) {
44
+ * return tracer(stackTrail, 'process-schema', () => {
45
+ * const parsed = tracer(stackTrail, 'parse', () => {
46
+ * return this.parseSchema();
47
+ * }, logger);
48
+ *
49
+ * const validated = tracer(stackTrail, 'validate', () => {
50
+ * return this.validateSchema(parsed);
51
+ * }, logger);
52
+ *
53
+ * return tracer(stackTrail, 'transform', () => {
54
+ * return this.transformSchema(validated);
55
+ * }, logger);
56
+ * }, logger);
57
+ * }
58
+ * }
59
+ *
60
+ * // Stack trail will show: ['process-schema', 'parse'] -> ['process-schema', 'validate'] -> ['process-schema', 'transform']
61
+ * ```
62
+ *
63
+ * @example Multiple token tracing
64
+ * ```typescript
65
+ * const result = tracer(
66
+ * stackTrail,
67
+ * ['file-generation', 'models.ts'], // Multiple tokens for detailed context
68
+ * () => {
69
+ * return generateModelsFile();
70
+ * },
71
+ * logger
72
+ * );
73
+ * ```
74
+ *
75
+ * @example Error handling with tracing
76
+ * ```typescript
77
+ * class SafeGenerator {
78
+ * generateWithTracing(stackTrail: StackTrail, logger: Logger) {
79
+ * try {
80
+ * return tracer(stackTrail, 'risky-operation', () => {
81
+ * // This might throw an error
82
+ * return this.complexGeneration();
83
+ * }, logger);
84
+ * } catch (error) {
85
+ * // Stack trail is automatically cleaned up
86
+ * logger.error(`Generation failed: ${error.message}`);
87
+ * return this.fallbackGeneration();
88
+ * }
89
+ * }
90
+ * }
91
+ * ```
92
+ *
93
+ * @example Performance monitoring
94
+ * ```typescript
95
+ * class PerformanceAwareGenerator {
96
+ * timedGeneration(stackTrail: StackTrail, logger: Logger) {
97
+ * const startTime = Date.now();
98
+ *
99
+ * const result = tracer(stackTrail, 'timed-generation', () => {
100
+ * return this.heavyComputation();
101
+ * }, logger);
102
+ *
103
+ * const duration = Date.now() - startTime;
104
+ * logger.info(`Generation completed in ${duration}ms`);
105
+ *
106
+ * return result;
107
+ * }
108
+ * }
109
+ * ```
110
+ *
111
+ * @example Integration with context classes
112
+ * ```typescript
113
+ * // Typically used within context classes like this:
114
+ * class GenerateContext {
115
+ * trace<T>(token: string | string[], fn: () => T): T {
116
+ * return tracer(this.stackTrail, token, fn, this.logger);
117
+ * }
118
+ *
119
+ * processModel(schema: OasSchema) {
120
+ * return this.trace(['model', schema.type], () => {
121
+ * // Model processing logic
122
+ * return this.createModel(schema);
123
+ * });
124
+ * }
125
+ * }
126
+ * ```
127
+ */
4
128
  const tracer = (stackTrail, token, fn, log) => {
5
129
  stackTrail.append(token);
6
130
  try {
@@ -7,8 +7,125 @@ import type { OasObject } from '../object/Object.js';
7
7
  import type { OasString } from '../string/String.js';
8
8
  import type { OasUnknown } from '../unknown/Unknown.js';
9
9
  import type { OasUnion } from '../union/Union.js';
10
+ /**
11
+ * Union type representing all possible OpenAPI Schema objects in the SKMTC system.
12
+ *
13
+ * `OasSchema` is the fundamental type for representing any OpenAPI schema definition
14
+ * after it has been parsed and processed by the SKMTC pipeline. It encompasses all
15
+ * JSON Schema types supported by OpenAPI 3.x specifications, providing type-safe
16
+ * access to schema properties and validation constraints.
17
+ *
18
+ * This union type is used throughout the system for schema processing, type generation,
19
+ * and validation. Each variant corresponds to a specific JSON Schema type with its
20
+ * own set of properties and validation rules.
21
+ *
22
+ * ## Supported Schema Types
23
+ *
24
+ * - **{@link OasArray}**: Array schemas with item type definitions and constraints
25
+ * - **{@link OasBoolean}**: Boolean schemas with optional default values
26
+ * - **{@link OasInteger}**: Integer schemas with numeric constraints and formats
27
+ * - **{@link OasNumber}**: Number schemas with numeric constraints and formats
28
+ * - **{@link OasObject}**: Object schemas with properties, required fields, and constraints
29
+ * - **{@link OasString}**: String schemas with length constraints, patterns, and formats
30
+ * - **{@link OasUnknown}**: Schemas with unknown or mixed types
31
+ * - **{@link OasUnion}**: Union schemas representing oneOf/anyOf/allOf constructs
32
+ *
33
+ * @example Type checking and processing
34
+ * ```typescript
35
+ * import type { OasSchema } from '@skmtc/core';
36
+ *
37
+ * function processSchema(schema: OasSchema): string {
38
+ * if (schema.type === 'object') {
39
+ * // TypeScript knows this is OasObject
40
+ * return `Object with ${Object.keys(schema.properties || {}).length} properties`;
41
+ * } else if (schema.type === 'array') {
42
+ * // TypeScript knows this is OasArray
43
+ * return `Array of ${schema.items.type} items`;
44
+ * } else if (schema.type === 'string') {
45
+ * // TypeScript knows this is OasString
46
+ * return `String${schema.format ? ` (${schema.format})` : ''}`;
47
+ * }
48
+ * // Handle other types...
49
+ * return `${schema.type} type`;
50
+ * }
51
+ * ```
52
+ *
53
+ * @example Schema validation and constraints
54
+ * ```typescript
55
+ * function validateSchemaConstraints(schema: OasSchema, value: unknown): boolean {
56
+ * switch (schema.type) {
57
+ * case 'string':
58
+ * if (typeof value !== 'string') return false;
59
+ * if (schema.minLength && value.length < schema.minLength) return false;
60
+ * if (schema.maxLength && value.length > schema.maxLength) return false;
61
+ * if (schema.pattern && !new RegExp(schema.pattern).test(value)) return false;
62
+ * return true;
63
+ *
64
+ * case 'integer':
65
+ * case 'number':
66
+ * if (typeof value !== 'number') return false;
67
+ * if (schema.minimum && value < schema.minimum) return false;
68
+ * if (schema.maximum && value > schema.maximum) return false;
69
+ * return true;
70
+ *
71
+ * case 'array':
72
+ * if (!Array.isArray(value)) return false;
73
+ * if (schema.minItems && value.length < schema.minItems) return false;
74
+ * if (schema.maxItems && value.length > schema.maxItems) return false;
75
+ * return true;
76
+ *
77
+ * default:
78
+ * return true;
79
+ * }
80
+ * }
81
+ * ```
82
+ *
83
+ * @example Code generation based on schema type
84
+ * ```typescript
85
+ * class TypeScriptGenerator {
86
+ * generateType(schema: OasSchema): string {
87
+ * switch (schema.type) {
88
+ * case 'object':
89
+ * return this.generateInterface(schema);
90
+ * case 'array':
91
+ * return `Array<${this.generateType(schema.items)}>`;
92
+ * case 'string':
93
+ * if (schema.enums) {
94
+ * return schema.enums.map(e => `'${e}'`).join(' | ');
95
+ * }
96
+ * return 'string';
97
+ * case 'integer':
98
+ * case 'number':
99
+ * return 'number';
100
+ * case 'boolean':
101
+ * return 'boolean';
102
+ * case 'union':
103
+ * return schema.variants.map(v => this.generateType(v)).join(' | ');
104
+ * default:
105
+ * return 'unknown';
106
+ * }
107
+ * }
108
+ * }
109
+ * ```
110
+ */
10
111
  export type OasSchema = OasArray | OasBoolean | OasInteger | OasNumber | OasObject | OasString | OasUnknown | OasUnion;
112
+ /**
113
+ * Configuration options for JSON Schema conversion operations.
114
+ *
115
+ * These options control how OAS schemas are converted back to JSON Schema format,
116
+ * particularly around reference resolution and schema inlining behavior.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const options: ToJsonSchemaOptions = {
121
+ * resolve: true // Resolve $ref references during conversion
122
+ * };
123
+ *
124
+ * const jsonSchema = schema.toJsonSchema(options);
125
+ * ```
126
+ */
11
127
  export type ToJsonSchemaOptions = {
128
+ /** Whether to resolve $ref references during conversion (default: false) */
12
129
  resolve: boolean;
13
130
  };
14
131
  //# sourceMappingURL=Schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../../src/oas/schema/Schema.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,UAAU,GACV,UAAU,GACV,SAAS,GACT,SAAS,GACT,SAAS,GACT,UAAU,GACV,QAAQ,CAAA;AAEZ,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA"}
1
+ {"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../../src/oas/schema/Schema.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoGG;AACH,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,UAAU,GACV,UAAU,GACV,SAAS,GACT,SAAS,GACT,SAAS,GACT,UAAU,GACV,QAAQ,CAAA;AAEZ;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,4EAA4E;IAC5E,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA"}
@@ -2,18 +2,216 @@ import type { GenerateContext } from '../context/GenerateContext.js';
2
2
  import { Definition } from '../dsl/Definition.js';
3
3
  import type { TypeSystemObject } from '../types/TypeSystem.js';
4
4
  import { FunctionParameter } from './FunctionParameter.js';
5
+ /**
6
+ * Constructor arguments for {@link PathParams}.
7
+ */
5
8
  type ConstructorArgs = {
9
+ /** The generation context for registering types and handling imports */
6
10
  context: GenerateContext;
11
+ /** Optional argument name for the parameter (if undefined, uses destructuring) */
7
12
  argName?: string;
13
+ /** Name of the TypeScript type to generate */
8
14
  typeName: string;
15
+ /** The type system object defining the parameter structure */
9
16
  typeValue: TypeSystemObject;
17
+ /** OpenAPI path template with parameter placeholders */
10
18
  pathTemplate: string;
11
19
  };
20
+ /**
21
+ * Manages path parameter type definitions and function parameters for API endpoints.
22
+ *
23
+ * `PathParams` is a utility class that combines type generation, function parameter
24
+ * handling, and path templating for OpenAPI path parameters. It creates TypeScript
25
+ * type definitions for path parameters and generates the corresponding function
26
+ * parameters that can be used in API client methods.
27
+ *
28
+ * This class is essential for generating type-safe API clients where path parameters
29
+ * are properly typed and validated at compile time. It handles both destructured
30
+ * parameters (when no argument name is provided) and named parameters.
31
+ *
32
+ * ## Key Features
33
+ *
34
+ * - **Type Definition Generation**: Creates TypeScript types for path parameters
35
+ * - **Function Parameter Integration**: Generates properly typed function parameters
36
+ * - **Path Template Processing**: Converts OpenAPI paths to template literals
37
+ * - **Destructuring Support**: Handles both named and destructured parameter patterns
38
+ * - **Context Integration**: Fully integrated with the SKMTC generation pipeline
39
+ *
40
+ * @example Basic path parameters with destructuring
41
+ * ```typescript
42
+ * import { PathParams } from '@skmtc/core';
43
+ *
44
+ * const pathParams = new PathParams({
45
+ * context: generateContext,
46
+ * typeName: 'GetUserParams',
47
+ * typeValue: {
48
+ * type: 'object',
49
+ * objectProperties: {
50
+ * properties: {
51
+ * id: { type: 'string' },
52
+ * format: { type: 'string' }
53
+ * }
54
+ * }
55
+ * },
56
+ * pathTemplate: '/users/{id}'
57
+ * });
58
+ *
59
+ * console.log(pathParams.path); // '/users/${id}'
60
+ * ```
61
+ *
62
+ * @example Named parameter usage
63
+ * ```typescript
64
+ * const namedPathParams = new PathParams({
65
+ * context: generateContext,
66
+ * argName: 'params',
67
+ * typeName: 'UserPathParams',
68
+ * typeValue: {
69
+ * type: 'object',
70
+ * objectProperties: {
71
+ * properties: {
72
+ * userId: { type: 'string' },
73
+ * projectId: { type: 'string' }
74
+ * }
75
+ * }
76
+ * },
77
+ * pathTemplate: '/users/{userId}/projects/{projectId}'
78
+ * });
79
+ *
80
+ * console.log(pathParams.path); // '/users/${params.userId}/projects/${params.projectId}'
81
+ * ```
82
+ *
83
+ * @example API client method generation
84
+ * ```typescript
85
+ * class ApiMethodGenerator {
86
+ * generateGetMethod(operationPath: string, parameters: any) {
87
+ * const pathParams = new PathParams({
88
+ * context: this.context,
89
+ * argName: 'pathParams',
90
+ * typeName: 'PathParameters',
91
+ * typeValue: parameters,
92
+ * pathTemplate: operationPath
93
+ * });
94
+ *
95
+ * return `
96
+ * async getData(${pathParams.parameter.toString()}) {
97
+ * const url = \`${pathParams.path}\`;
98
+ * return this.client.get(url);
99
+ * }`;
100
+ * }
101
+ * }
102
+ *
103
+ * // Generates:
104
+ * // async getData(pathParams: PathParameters) {
105
+ * // const url = `/users/${pathParams.userId}/projects/${pathParams.projectId}`;
106
+ * // return this.client.get(url);
107
+ * // }
108
+ * ```
109
+ *
110
+ * @example With destructured parameters
111
+ * ```typescript
112
+ * const destructuredParams = new PathParams({
113
+ * context: generateContext,
114
+ * // No argName provided, so uses destructuring
115
+ * typeName: 'OrderParams',
116
+ * typeValue: {
117
+ * type: 'object',
118
+ * objectProperties: {
119
+ * properties: {
120
+ * orderId: { type: 'string' },
121
+ * customerId: { type: 'string' }
122
+ * }
123
+ * }
124
+ * },
125
+ * pathTemplate: '/customers/{customerId}/orders/{orderId}'
126
+ * });
127
+ *
128
+ * // Function parameter will be: { orderId, customerId }: OrderParams
129
+ * // Path template will be: '/customers/${customerId}/orders/${orderId}'
130
+ * ```
131
+ *
132
+ * @example Complex nested path parameters
133
+ * ```typescript
134
+ * const complexPathParams = new PathParams({
135
+ * context: generateContext,
136
+ * argName: 'pathData',
137
+ * typeName: 'ComplexPathParams',
138
+ * typeValue: {
139
+ * type: 'object',
140
+ * objectProperties: {
141
+ * properties: {
142
+ * orgId: { type: 'string' },
143
+ * projectId: { type: 'string' },
144
+ * issueId: { type: 'number' },
145
+ * commentId: { type: 'string' }
146
+ * }
147
+ * }
148
+ * },
149
+ * pathTemplate: '/orgs/{orgId}/projects/{projectId}/issues/{issueId}/comments/{commentId}'
150
+ * });
151
+ *
152
+ * // Generates path: '/orgs/${pathData.orgId}/projects/${pathData.projectId}/issues/${pathData.issueId}/comments/${pathData.commentId}'
153
+ * ```
154
+ *
155
+ * @example Integration with operation generation
156
+ * ```typescript
157
+ * class OperationGenerator {
158
+ * generateOperation(operation: OasOperation) {
159
+ * const pathParameters = this.extractPathParameters(operation);
160
+ *
161
+ * if (pathParameters.length > 0) {
162
+ * const pathParams = new PathParams({
163
+ * context: this.context,
164
+ * typeName: `${operation.operationId}PathParams`,
165
+ * typeValue: this.buildParametersType(pathParameters),
166
+ * pathTemplate: operation.path
167
+ * });
168
+ *
169
+ * return this.generateMethodWithPathParams(operation, pathParams);
170
+ * }
171
+ *
172
+ * return this.generateSimpleMethod(operation);
173
+ * }
174
+ * }
175
+ * ```
176
+ */
12
177
  export declare class PathParams {
178
+ /** The generation context used for type registration and imports */
13
179
  context: GenerateContext;
180
+ /** The TypeScript type definition for the path parameters */
14
181
  typeDefinition: Definition<TypeSystemObject>;
182
+ /** The function parameter representation for method signatures */
15
183
  parameter: FunctionParameter;
184
+ /** The processed path template with parameter substitutions */
16
185
  path: string;
186
+ /**
187
+ * Creates a new PathParams instance with type definitions and path processing.
188
+ *
189
+ * The constructor sets up the complete parameter handling pipeline:
190
+ * 1. Creates a TypeScript type definition for the parameters
191
+ * 2. Generates a function parameter (either named or destructured)
192
+ * 3. Processes the path template for runtime interpolation
193
+ *
194
+ * @param args - Configuration for path parameter generation
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * const pathParams = new PathParams({
199
+ * context: generateContext,
200
+ * argName: 'params',
201
+ * typeName: 'UserPathParams',
202
+ * typeValue: {
203
+ * type: 'object',
204
+ * objectProperties: {
205
+ * properties: {
206
+ * id: { type: 'string' },
207
+ * format: { type: 'string' }
208
+ * }
209
+ * }
210
+ * },
211
+ * pathTemplate: '/users/{id}/profile'
212
+ * });
213
+ * ```
214
+ */
17
215
  constructor({ context, argName, typeName, typeValue, pathTemplate }: ConstructorArgs);
18
216
  }
19
217
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"PathParams.d.ts","sourceRoot":"","sources":["../../src/typescript/PathParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAG1D,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,eAAe,CAAA;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,gBAAgB,CAAA;IAC3B,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,qBAAa,UAAU;IACrB,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAC5C,SAAS,EAAE,iBAAiB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;gBAEA,EACV,OAAO,EACP,OAAO,EACP,QAAQ,EACR,SAAS,EACT,YAAY,EACb,EAAE,eAAe;CAwBnB"}
1
+ {"version":3,"file":"PathParams.d.ts","sourceRoot":"","sources":["../../src/typescript/PathParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAG1D;;GAEG;AACH,KAAK,eAAe,GAAG;IACrB,wEAAwE;IACxE,OAAO,EAAE,eAAe,CAAA;IACxB,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAA;IAChB,8DAA8D;IAC9D,SAAS,EAAE,gBAAgB,CAAA;IAC3B,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4JG;AACH,qBAAa,UAAU;IACrB,oEAAoE;IACpE,OAAO,EAAE,eAAe,CAAA;IAExB,6DAA6D;IAC7D,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAE5C,kEAAkE;IAClE,SAAS,EAAE,iBAAiB,CAAA;IAE5B,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAA;IAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;gBACS,EACV,OAAO,EACP,OAAO,EACP,QAAQ,EACR,SAAS,EACT,YAAY,EACb,EAAE,eAAe;CAwBnB"}