@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,8 +1,201 @@
1
1
  import type { ResultsItem, ResultType } from '../types/Results.js';
2
+ /**
3
+ * Manages and organizes generation results with intelligent prioritization.
4
+ *
5
+ * `ResultsLog` tracks the outcomes of code generation operations, maintaining
6
+ * a hierarchical structure of results organized by stack trail paths. It implements
7
+ * intelligent result prioritization, ensuring that more severe results (errors)
8
+ * take precedence over less severe ones (success, warnings) when multiple results
9
+ * exist for the same path.
10
+ *
11
+ * The class is designed to work with the SKMTC tracing system, using stack trail
12
+ * identifiers to organize results in a meaningful hierarchical structure that
13
+ * reflects the execution flow of the generation process.
14
+ *
15
+ * ## Key Features
16
+ *
17
+ * - **Result Prioritization**: Automatically prioritizes more severe results
18
+ * - **Hierarchical Organization**: Organizes results by stack trail paths
19
+ * - **Tree Structure**: Converts flat result logs into nested tree structures
20
+ * - **Duplicate Handling**: Prevents less severe results from overwriting more severe ones
21
+ *
22
+ * @example Basic usage
23
+ * ```typescript
24
+ * import { ResultsLog } from '@skmtc/core';
25
+ *
26
+ * const resultsLog = new ResultsLog();
27
+ *
28
+ * // Capture results from different parts of generation
29
+ * resultsLog.capture('models:User', 'success');
30
+ * resultsLog.capture('models:Product', 'error');
31
+ * resultsLog.capture('types:Status', 'success');
32
+ *
33
+ * // Convert to hierarchical structure
34
+ * const tree = resultsLog.toTree();
35
+ * console.log(tree);
36
+ * // {
37
+ * // models: {
38
+ * // User: 'success',
39
+ * // Product: 'error'
40
+ * // },
41
+ * // types: {
42
+ * // Status: 'success'
43
+ * // }
44
+ * // }
45
+ * ```
46
+ *
47
+ * @example Result prioritization
48
+ * ```typescript
49
+ * const resultsLog = new ResultsLog();
50
+ *
51
+ * // First capture a success
52
+ * resultsLog.capture('api:createUser', 'success');
53
+ *
54
+ * // Later encounter an error at the same path
55
+ * resultsLog.capture('api:createUser', 'error');
56
+ *
57
+ * // Error takes precedence
58
+ * const tree = resultsLog.toTree();
59
+ * console.log(tree.api.createUser); // 'error'
60
+ *
61
+ * // But success won't overwrite error
62
+ * resultsLog.capture('api:createUser', 'success');
63
+ * console.log(resultsLog.toTree().api.createUser); // Still 'error'
64
+ * ```
65
+ *
66
+ * @example Complex nested paths
67
+ * ```typescript
68
+ * const resultsLog = new ResultsLog();
69
+ *
70
+ * resultsLog.capture('generation:models:User:properties:name', 'success');
71
+ * resultsLog.capture('generation:models:User:properties:email', 'warning');
72
+ * resultsLog.capture('generation:models:Product:validation', 'error');
73
+ * resultsLog.capture('generation:operations:createUser', 'success');
74
+ *
75
+ * const tree = resultsLog.toTree();
76
+ * console.log(tree);
77
+ * // {
78
+ * // generation: {
79
+ * // models: {
80
+ * // User: {
81
+ * // properties: {
82
+ * // name: 'success',
83
+ * // email: 'warning'
84
+ * // }
85
+ * // },
86
+ * // Product: {
87
+ * // validation: 'error'
88
+ * // }
89
+ * // },
90
+ * // operations: {
91
+ * // createUser: 'success'
92
+ * // }
93
+ * // }
94
+ * // }
95
+ * ```
96
+ *
97
+ * @example Integration with tracing
98
+ * ```typescript
99
+ * class TrackedGenerator {
100
+ * private resultsLog = new ResultsLog();
101
+ *
102
+ * generateModel(name: string, schema: OasSchema) {
103
+ * const stackPath = `models:${name}`;
104
+ *
105
+ * try {
106
+ * const model = this.processSchema(schema);
107
+ * this.resultsLog.capture(stackPath, 'success');
108
+ * return model;
109
+ * } catch (error) {
110
+ * this.resultsLog.capture(stackPath, 'error');
111
+ * throw error;
112
+ * }
113
+ * }
114
+ *
115
+ * generateOperation(operationId: string, operation: OasOperation) {
116
+ * const stackPath = `operations:${operationId}`;
117
+ *
118
+ * if (!this.supportsOperation(operation)) {
119
+ * this.resultsLog.capture(stackPath, 'notSupported');
120
+ * return null;
121
+ * }
122
+ *
123
+ * const result = this.processOperation(operation);
124
+ * this.resultsLog.capture(stackPath, 'success');
125
+ * return result;
126
+ * }
127
+ *
128
+ * getResults(): ResultsItem {
129
+ * return this.resultsLog.toTree();
130
+ * }
131
+ * }
132
+ * ```
133
+ */
2
134
  export declare class ResultsLog {
3
135
  #private;
136
+ /**
137
+ * Creates a new ResultsLog instance.
138
+ *
139
+ * Initializes an empty results tracking system ready to capture
140
+ * generation outcomes from various parts of the pipeline.
141
+ */
4
142
  constructor();
143
+ /**
144
+ * Captures a generation result for a specific stack trail path.
145
+ *
146
+ * This method records the outcome of a generation operation, using intelligent
147
+ * prioritization to ensure that more severe results take precedence over less
148
+ * severe ones. For example, an error result will not be overwritten by a
149
+ * success result, but a success can be overwritten by an error.
150
+ *
151
+ * @param stackTrail - Colon-separated path identifying the operation location
152
+ * @param result - The result type to capture (error, warning, success, etc.)
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const resultsLog = new ResultsLog();
157
+ *
158
+ * // Capture various results
159
+ * resultsLog.capture('models:User:properties:email', 'success');
160
+ * resultsLog.capture('models:User:validation', 'warning');
161
+ * resultsLog.capture('operations:createUser', 'error');
162
+ * ```
163
+ */
5
164
  capture(stackTrail: string, result: ResultType): void;
165
+ /**
166
+ * Converts the flat results structure into a hierarchical tree.
167
+ *
168
+ * This method transforms the internal flat storage (using colon-separated paths)
169
+ * into a nested object structure that reflects the hierarchy of generation
170
+ * operations. This makes it easier to understand and process results in
171
+ * a structured way.
172
+ *
173
+ * @returns Nested object structure representing the results hierarchy
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * const resultsLog = new ResultsLog();
178
+ * resultsLog.capture('api:models:User', 'success');
179
+ * resultsLog.capture('api:operations:getUser', 'error');
180
+ * resultsLog.capture('types:Status', 'success');
181
+ *
182
+ * const tree = resultsLog.toTree();
183
+ * console.log(tree);
184
+ * // {
185
+ * // api: {
186
+ * // models: {
187
+ * // User: 'success'
188
+ * // },
189
+ * // operations: {
190
+ * // getUser: 'error'
191
+ * // }
192
+ * // },
193
+ * // types: {
194
+ * // Status: 'success'
195
+ * // }
196
+ * // }
197
+ * ```
198
+ */
6
199
  toTree(): ResultsItem;
7
200
  }
8
201
  //# sourceMappingURL=ResultsLog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ResultsLog.d.ts","sourceRoot":"","sources":["../../src/helpers/ResultsLog.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAElE,qBAAa,UAAU;;;IAOrB,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAc9C,MAAM,IAAI,WAAW;CAWtB"}
1
+ {"version":3,"file":"ResultsLog.d.ts","sourceRoot":"","sources":["../../src/helpers/ResultsLog.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmIG;AACH,qBAAa,UAAU;;IAGrB;;;;;OAKG;;IAKH;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IA8B9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,MAAM,IAAI,WAAW;CAWtB"}
@@ -11,17 +11,210 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
11
11
  };
12
12
  var _ResultsLog_instances, _ResultsLog_results, _ResultsLog_incomingResultIsWorse;
13
13
  import { set } from 'lodash-es';
14
+ /**
15
+ * Manages and organizes generation results with intelligent prioritization.
16
+ *
17
+ * `ResultsLog` tracks the outcomes of code generation operations, maintaining
18
+ * a hierarchical structure of results organized by stack trail paths. It implements
19
+ * intelligent result prioritization, ensuring that more severe results (errors)
20
+ * take precedence over less severe ones (success, warnings) when multiple results
21
+ * exist for the same path.
22
+ *
23
+ * The class is designed to work with the SKMTC tracing system, using stack trail
24
+ * identifiers to organize results in a meaningful hierarchical structure that
25
+ * reflects the execution flow of the generation process.
26
+ *
27
+ * ## Key Features
28
+ *
29
+ * - **Result Prioritization**: Automatically prioritizes more severe results
30
+ * - **Hierarchical Organization**: Organizes results by stack trail paths
31
+ * - **Tree Structure**: Converts flat result logs into nested tree structures
32
+ * - **Duplicate Handling**: Prevents less severe results from overwriting more severe ones
33
+ *
34
+ * @example Basic usage
35
+ * ```typescript
36
+ * import { ResultsLog } from '@skmtc/core';
37
+ *
38
+ * const resultsLog = new ResultsLog();
39
+ *
40
+ * // Capture results from different parts of generation
41
+ * resultsLog.capture('models:User', 'success');
42
+ * resultsLog.capture('models:Product', 'error');
43
+ * resultsLog.capture('types:Status', 'success');
44
+ *
45
+ * // Convert to hierarchical structure
46
+ * const tree = resultsLog.toTree();
47
+ * console.log(tree);
48
+ * // {
49
+ * // models: {
50
+ * // User: 'success',
51
+ * // Product: 'error'
52
+ * // },
53
+ * // types: {
54
+ * // Status: 'success'
55
+ * // }
56
+ * // }
57
+ * ```
58
+ *
59
+ * @example Result prioritization
60
+ * ```typescript
61
+ * const resultsLog = new ResultsLog();
62
+ *
63
+ * // First capture a success
64
+ * resultsLog.capture('api:createUser', 'success');
65
+ *
66
+ * // Later encounter an error at the same path
67
+ * resultsLog.capture('api:createUser', 'error');
68
+ *
69
+ * // Error takes precedence
70
+ * const tree = resultsLog.toTree();
71
+ * console.log(tree.api.createUser); // 'error'
72
+ *
73
+ * // But success won't overwrite error
74
+ * resultsLog.capture('api:createUser', 'success');
75
+ * console.log(resultsLog.toTree().api.createUser); // Still 'error'
76
+ * ```
77
+ *
78
+ * @example Complex nested paths
79
+ * ```typescript
80
+ * const resultsLog = new ResultsLog();
81
+ *
82
+ * resultsLog.capture('generation:models:User:properties:name', 'success');
83
+ * resultsLog.capture('generation:models:User:properties:email', 'warning');
84
+ * resultsLog.capture('generation:models:Product:validation', 'error');
85
+ * resultsLog.capture('generation:operations:createUser', 'success');
86
+ *
87
+ * const tree = resultsLog.toTree();
88
+ * console.log(tree);
89
+ * // {
90
+ * // generation: {
91
+ * // models: {
92
+ * // User: {
93
+ * // properties: {
94
+ * // name: 'success',
95
+ * // email: 'warning'
96
+ * // }
97
+ * // },
98
+ * // Product: {
99
+ * // validation: 'error'
100
+ * // }
101
+ * // },
102
+ * // operations: {
103
+ * // createUser: 'success'
104
+ * // }
105
+ * // }
106
+ * // }
107
+ * ```
108
+ *
109
+ * @example Integration with tracing
110
+ * ```typescript
111
+ * class TrackedGenerator {
112
+ * private resultsLog = new ResultsLog();
113
+ *
114
+ * generateModel(name: string, schema: OasSchema) {
115
+ * const stackPath = `models:${name}`;
116
+ *
117
+ * try {
118
+ * const model = this.processSchema(schema);
119
+ * this.resultsLog.capture(stackPath, 'success');
120
+ * return model;
121
+ * } catch (error) {
122
+ * this.resultsLog.capture(stackPath, 'error');
123
+ * throw error;
124
+ * }
125
+ * }
126
+ *
127
+ * generateOperation(operationId: string, operation: OasOperation) {
128
+ * const stackPath = `operations:${operationId}`;
129
+ *
130
+ * if (!this.supportsOperation(operation)) {
131
+ * this.resultsLog.capture(stackPath, 'notSupported');
132
+ * return null;
133
+ * }
134
+ *
135
+ * const result = this.processOperation(operation);
136
+ * this.resultsLog.capture(stackPath, 'success');
137
+ * return result;
138
+ * }
139
+ *
140
+ * getResults(): ResultsItem {
141
+ * return this.resultsLog.toTree();
142
+ * }
143
+ * }
144
+ * ```
145
+ */
14
146
  export class ResultsLog {
147
+ /**
148
+ * Creates a new ResultsLog instance.
149
+ *
150
+ * Initializes an empty results tracking system ready to capture
151
+ * generation outcomes from various parts of the pipeline.
152
+ */
15
153
  constructor() {
16
154
  _ResultsLog_instances.add(this);
17
155
  _ResultsLog_results.set(this, void 0);
18
156
  __classPrivateFieldSet(this, _ResultsLog_results, {}, "f");
19
157
  }
158
+ /**
159
+ * Captures a generation result for a specific stack trail path.
160
+ *
161
+ * This method records the outcome of a generation operation, using intelligent
162
+ * prioritization to ensure that more severe results take precedence over less
163
+ * severe ones. For example, an error result will not be overwritten by a
164
+ * success result, but a success can be overwritten by an error.
165
+ *
166
+ * @param stackTrail - Colon-separated path identifying the operation location
167
+ * @param result - The result type to capture (error, warning, success, etc.)
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const resultsLog = new ResultsLog();
172
+ *
173
+ * // Capture various results
174
+ * resultsLog.capture('models:User:properties:email', 'success');
175
+ * resultsLog.capture('models:User:validation', 'warning');
176
+ * resultsLog.capture('operations:createUser', 'error');
177
+ * ```
178
+ */
20
179
  capture(stackTrail, result) {
21
180
  if (__classPrivateFieldGet(this, _ResultsLog_instances, "m", _ResultsLog_incomingResultIsWorse).call(this, __classPrivateFieldGet(this, _ResultsLog_results, "f")[stackTrail], result)) {
22
181
  __classPrivateFieldGet(this, _ResultsLog_results, "f")[stackTrail] = result;
23
182
  }
24
183
  }
184
+ /**
185
+ * Converts the flat results structure into a hierarchical tree.
186
+ *
187
+ * This method transforms the internal flat storage (using colon-separated paths)
188
+ * into a nested object structure that reflects the hierarchy of generation
189
+ * operations. This makes it easier to understand and process results in
190
+ * a structured way.
191
+ *
192
+ * @returns Nested object structure representing the results hierarchy
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * const resultsLog = new ResultsLog();
197
+ * resultsLog.capture('api:models:User', 'success');
198
+ * resultsLog.capture('api:operations:getUser', 'error');
199
+ * resultsLog.capture('types:Status', 'success');
200
+ *
201
+ * const tree = resultsLog.toTree();
202
+ * console.log(tree);
203
+ * // {
204
+ * // api: {
205
+ * // models: {
206
+ * // User: 'success'
207
+ * // },
208
+ * // operations: {
209
+ * // getUser: 'error'
210
+ * // }
211
+ * // },
212
+ * // types: {
213
+ * // Status: 'success'
214
+ * // }
215
+ * // }
216
+ * ```
217
+ */
25
218
  toTree() {
26
219
  const tree = {};
27
220
  Object.entries(__classPrivateFieldGet(this, _ResultsLog_results, "f")).forEach(([key, value]) => {
@@ -37,6 +230,26 @@ _ResultsLog_results = new WeakMap(), _ResultsLog_instances = new WeakSet(), _Res
37
230
  }
38
231
  return resultRankings[current] < resultRankings[incoming];
39
232
  };
233
+ /**
234
+ * Priority rankings for different result types.
235
+ *
236
+ * This mapping defines the severity hierarchy used by the ResultsLog to determine
237
+ * which results should take precedence when multiple results are captured for the
238
+ * same path. Higher numbers indicate higher severity/priority.
239
+ *
240
+ * The ranking system ensures that critical issues (errors) are never masked by
241
+ * less important results (success), while still allowing for proper escalation
242
+ * when more severe conditions are encountered.
243
+ *
244
+ * @example Ranking hierarchy (high to low priority)
245
+ * ```
246
+ * error (50) - Critical failures that prevent generation
247
+ * warning (40) - Issues that allow generation but need attention
248
+ * success (30) - Normal successful completion
249
+ * skipped (20) - Operations that were intentionally bypassed
250
+ * notSupported (10) - Features not yet implemented
251
+ * ```
252
+ */
40
253
  const resultRankings = {
41
254
  error: 50,
42
255
  warning: 40,
@@ -1,10 +1,160 @@
1
1
  import "../_dnt.polyfills.js";
2
2
  import type { OasRef } from '../oas/ref/Ref.js';
3
3
  import type { OasSchema } from '../oas/schema/Schema.js';
4
+ /**
5
+ * Arguments for collating examples from OpenAPI schemas.
6
+ */
4
7
  type CollatedExampleArgs = {
8
+ /** The OpenAPI schema or reference to extract examples from */
5
9
  objectSchema: OasSchema | OasRef<'schema'> | undefined;
10
+ /** Current recursion depth (used to prevent infinite loops) */
6
11
  depth: number;
7
12
  };
13
+ /**
14
+ * Recursively collates and builds example values from OpenAPI schemas.
15
+ *
16
+ * This function traverses OpenAPI schema structures and generates comprehensive
17
+ * example values based on the schema definitions and any explicit examples provided.
18
+ * It handles complex nested structures including objects, arrays, unions, and
19
+ * references while preventing infinite recursion through depth limiting.
20
+ *
21
+ * The function prioritizes explicit examples when available and falls back to
22
+ * generating examples from nested schemas. It's particularly useful for creating
23
+ * realistic test data, API documentation examples, and mock responses.
24
+ *
25
+ * @param args - Configuration for example collation
26
+ * @param args.objectSchema - The schema to extract examples from
27
+ * @param args.depth - Current recursion depth (prevents infinite loops)
28
+ * @returns Collated example value matching the schema structure, or undefined if no examples
29
+ *
30
+ * @throws {Error} When recursion depth exceeds 15 levels (prevents stack overflow)
31
+ *
32
+ * @example Basic schema examples
33
+ * ```typescript
34
+ * import { collateExamples } from '@skmtc/core';
35
+ *
36
+ * // String schema with example
37
+ * const stringSchema = new OasString({ example: 'john.doe@example.com' });
38
+ * const example = collateExamples({ objectSchema: stringSchema, depth: 0 });
39
+ * console.log(example); // 'john.doe@example.com'
40
+ *
41
+ * // Number schema with example
42
+ * const numberSchema = new OasNumber({ example: 42 });
43
+ * const numExample = collateExamples({ objectSchema: numberSchema, depth: 0 });
44
+ * console.log(numExample); // 42
45
+ * ```
46
+ *
47
+ * @example Object schema examples
48
+ * ```typescript
49
+ * // Object schema with nested properties
50
+ * const userSchema = new OasObject({
51
+ * properties: {
52
+ * id: new OasInteger({ example: 123 }),
53
+ * name: new OasString({ example: 'John Doe' }),
54
+ * email: new OasString({ example: 'john@example.com' }),
55
+ * age: new OasInteger({ example: 30 })
56
+ * }
57
+ * });
58
+ *
59
+ * const userExample = collateExamples({ objectSchema: userSchema, depth: 0 });
60
+ * console.log(userExample);
61
+ * // {
62
+ * // id: 123,
63
+ * // name: 'John Doe',
64
+ * // email: 'john@example.com',
65
+ * // age: 30
66
+ * // }
67
+ * ```
68
+ *
69
+ * @example Array schema examples
70
+ * ```typescript
71
+ * // Array of objects
72
+ * const usersArraySchema = new OasArray({
73
+ * items: new OasObject({
74
+ * properties: {
75
+ * id: new OasInteger({ example: 1 }),
76
+ * name: new OasString({ example: 'Jane Smith' })
77
+ * }
78
+ * })
79
+ * });
80
+ *
81
+ * const arrayExample = collateExamples({ objectSchema: usersArraySchema, depth: 0 });
82
+ * console.log(arrayExample);
83
+ * // [
84
+ * // {
85
+ * // id: 1,
86
+ * // name: 'Jane Smith'
87
+ * // }
88
+ * // ]
89
+ * ```
90
+ *
91
+ * @example Union schema examples
92
+ * ```typescript
93
+ * // Union of string and number
94
+ * const unionSchema = new OasUnion({
95
+ * members: [
96
+ * new OasString({ example: 'text-value' }),
97
+ * new OasNumber({ example: 99 })
98
+ * ]
99
+ * });
100
+ *
101
+ * const unionExample = collateExamples({ objectSchema: unionSchema, depth: 0 });
102
+ * console.log(unionExample); // 'text-value' (first member with example)
103
+ * ```
104
+ *
105
+ * @example Reference resolution
106
+ * ```typescript
107
+ * // Schema with reference to another schema
108
+ * const addressRef = new OasRef({
109
+ * $ref: '#/components/schemas/Address',
110
+ * resolve: () => new OasObject({
111
+ * properties: {
112
+ * street: new OasString({ example: '123 Main St' }),
113
+ * city: new OasString({ example: 'Springfield' })
114
+ * }
115
+ * })
116
+ * });
117
+ *
118
+ * const refExample = collateExamples({ objectSchema: addressRef, depth: 0 });
119
+ * console.log(refExample);
120
+ * // {
121
+ * // street: '123 Main St',
122
+ * // city: 'Springfield'
123
+ * // }
124
+ * ```
125
+ *
126
+ * @example Depth limiting and error handling
127
+ * ```typescript
128
+ * // Deep nesting detection
129
+ * try {
130
+ * const deepExample = collateExamples({ objectSchema: someSchema, depth: 16 });
131
+ * } catch (error) {
132
+ * console.error('Depth limit exceeded:', error.message); // 'Depth limit reached'
133
+ * }
134
+ *
135
+ * // Handling missing schemas
136
+ * const emptyExample = collateExamples({ objectSchema: undefined, depth: 0 });
137
+ * console.log(emptyExample); // undefined
138
+ * ```
139
+ *
140
+ * @example Using in API documentation generation
141
+ * ```typescript
142
+ * class ApiDocGenerator {
143
+ * generateExampleResponse(responseSchema: OasSchema) {
144
+ * const example = collateExamples({ objectSchema: responseSchema, depth: 0 });
145
+ *
146
+ * if (example) {
147
+ * return {
148
+ * description: 'Example response',
149
+ * value: example
150
+ * };
151
+ * }
152
+ *
153
+ * return { description: 'No example available' };
154
+ * }
155
+ * }
156
+ * ```
157
+ */
8
158
  export declare const collateExamples: ({ objectSchema, depth }: CollatedExampleArgs) => unknown;
9
159
  export {};
10
160
  //# sourceMappingURL=collateExamples.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collateExamples.d.ts","sourceRoot":"","sources":["../../src/helpers/collateExamples.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAIxD,KAAK,mBAAmB,GAAG;IACzB,YAAY,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAA;IACtD,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,yBAAyB,mBAAmB,KAAG,OAwE9E,CAAA"}
1
+ {"version":3,"file":"collateExamples.d.ts","sourceRoot":"","sources":["../../src/helpers/collateExamples.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAIxD;;GAEG;AACH,KAAK,mBAAmB,GAAG;IACzB,+DAA+D;IAC/D,YAAY,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAA;IACtD,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgJG;AACH,eAAO,MAAM,eAAe,GAAI,yBAAyB,mBAAmB,KAAG,OAwE9E,CAAA"}