@skmtc/core 0.32.3 → 0.34.0

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 (49) hide show
  1. package/esm/context/CoreContext.d.ts +8 -21
  2. package/esm/context/CoreContext.js +9 -22
  3. package/esm/context/GenerateContext.js +7 -7
  4. package/esm/context/ParseContext.d.ts +1 -1
  5. package/esm/context/ParseContext.js +2 -2
  6. package/esm/context/StackTrail.d.ts +30 -13
  7. package/esm/context/StackTrail.js +36 -14
  8. package/esm/context/generateTypes.d.ts +2 -2
  9. package/esm/context/generateTypes.js +2 -0
  10. package/esm/helpers/ResultsLog.d.ts +19 -181
  11. package/esm/helpers/ResultsLog.js +46 -205
  12. package/esm/parse/emptyParameter.d.ts +16 -0
  13. package/esm/parse/emptyParameter.js +19 -0
  14. package/esm/parse/toPresentResponses.d.ts +19 -0
  15. package/esm/parse/toPresentResponses.js +27 -0
  16. package/esm/parse/v3-0/parameter/toParameterV3.js +12 -3
  17. package/esm/parse/v3-0/response/toResponseV3.d.ts +5 -1
  18. package/esm/parse/v3-0/response/toResponseV3.js +12 -1
  19. package/esm/parse/v3-1/parameter/toParameterV3.js +12 -3
  20. package/esm/parse/v3-1/response/toResponseV3.d.ts +5 -1
  21. package/esm/parse/v3-1/response/toResponseV3.js +12 -1
  22. package/esm/parse/v3-2/parameter/toParameterV3.js +9 -0
  23. package/esm/parse/v3-2/response/toResponseV3.d.ts +5 -1
  24. package/esm/parse/v3-2/response/toResponseV3.js +12 -1
  25. package/package.json +1 -1
  26. package/script/context/CoreContext.d.ts +8 -21
  27. package/script/context/CoreContext.js +9 -22
  28. package/script/context/GenerateContext.js +7 -7
  29. package/script/context/ParseContext.d.ts +1 -1
  30. package/script/context/ParseContext.js +2 -2
  31. package/script/context/StackTrail.d.ts +30 -13
  32. package/script/context/StackTrail.js +36 -14
  33. package/script/context/generateTypes.d.ts +2 -2
  34. package/script/context/generateTypes.js +2 -0
  35. package/script/helpers/ResultsLog.d.ts +19 -181
  36. package/script/helpers/ResultsLog.js +46 -208
  37. package/script/parse/emptyParameter.d.ts +16 -0
  38. package/script/parse/emptyParameter.js +24 -0
  39. package/script/parse/toPresentResponses.d.ts +19 -0
  40. package/script/parse/toPresentResponses.js +31 -0
  41. package/script/parse/v3-0/parameter/toParameterV3.js +12 -3
  42. package/script/parse/v3-0/response/toResponseV3.d.ts +5 -1
  43. package/script/parse/v3-0/response/toResponseV3.js +13 -2
  44. package/script/parse/v3-1/parameter/toParameterV3.js +12 -3
  45. package/script/parse/v3-1/response/toResponseV3.d.ts +5 -1
  46. package/script/parse/v3-1/response/toResponseV3.js +13 -2
  47. package/script/parse/v3-2/parameter/toParameterV3.js +9 -0
  48. package/script/parse/v3-2/response/toResponseV3.d.ts +5 -1
  49. package/script/parse/v3-2/response/toResponseV3.js +13 -2
@@ -305,31 +305,18 @@ export declare class CoreContext {
305
305
  parseIssues: ParseIssue[];
306
306
  };
307
307
  /**
308
- * Captures a result at the current execution position in the stack trail.
309
- *
310
- * This method records processing results (success, warning, error, etc.) at the
311
- * current location in the document traversal stack. Results are associated with
312
- * the current stack trail position, enabling detailed error reporting and
313
- * debugging of OpenAPI processing issues.
308
+ * Captures a result at `stackTrail`. Each frame of the trail becomes one
309
+ * level of the `manifest.results` tree.
314
310
  *
315
311
  * @param result - The type of result to capture (success, warning, error, etc.)
312
+ * @param stackTrail - The trail the result belongs to
316
313
  *
317
- * @example Capturing a warning result
318
- * ```typescript
319
- * context.captureCurrentResult('warning');
320
- * // Result captured at current stack position like: "components.schemas.User.properties.email"
321
- * ```
322
- *
323
- * @example Usage during schema processing
314
+ * @example
324
315
  * ```typescript
325
- * context.trace(['components', 'schemas', 'User'], () => {
326
- * try {
327
- * processUserSchema();
328
- * context.captureCurrentResult('success');
329
- * } catch (error) {
330
- * context.captureCurrentResult('error');
331
- * }
332
- * });
316
+ * stackTrail.trace(['/pets', 'get'], opTrail => {
317
+ * context.captureCurrentResult('success', opTrail)
318
+ * })
319
+ * // manifest.results: { …, '/pets': { get: 'success' } }
333
320
  * ```
334
321
  */
335
322
  captureCurrentResult(result: ResultType, stackTrail: StackTrail): void;
@@ -410,35 +410,22 @@ export class CoreContext {
410
410
  }
411
411
  }
412
412
  /**
413
- * Captures a result at the current execution position in the stack trail.
414
- *
415
- * This method records processing results (success, warning, error, etc.) at the
416
- * current location in the document traversal stack. Results are associated with
417
- * the current stack trail position, enabling detailed error reporting and
418
- * debugging of OpenAPI processing issues.
413
+ * Captures a result at `stackTrail`. Each frame of the trail becomes one
414
+ * level of the `manifest.results` tree.
419
415
  *
420
416
  * @param result - The type of result to capture (success, warning, error, etc.)
417
+ * @param stackTrail - The trail the result belongs to
421
418
  *
422
- * @example Capturing a warning result
423
- * ```typescript
424
- * context.captureCurrentResult('warning');
425
- * // Result captured at current stack position like: "components.schemas.User.properties.email"
426
- * ```
427
- *
428
- * @example Usage during schema processing
419
+ * @example
429
420
  * ```typescript
430
- * context.trace(['components', 'schemas', 'User'], () => {
431
- * try {
432
- * processUserSchema();
433
- * context.captureCurrentResult('success');
434
- * } catch (error) {
435
- * context.captureCurrentResult('error');
436
- * }
437
- * });
421
+ * stackTrail.trace(['/pets', 'get'], opTrail => {
422
+ * context.captureCurrentResult('success', opTrail)
423
+ * })
424
+ * // manifest.results: { …, '/pets': { get: 'success' } }
438
425
  * ```
439
426
  */
440
427
  captureCurrentResult(result, stackTrail) {
441
- __classPrivateFieldGet(this, _CoreContext_results, "f").capture(stackTrail.toString(), result);
428
+ __classPrivateFieldGet(this, _CoreContext_results, "f").capture(stackTrail, result);
442
429
  }
443
430
  }
444
431
  _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreContext_instances = new WeakSet(), _CoreContext_setupLogger = function _CoreContext_setupLogger({ spanId, logsPath }) {
@@ -864,7 +864,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
864
864
  }
865
865
  }, _GenerateContext_runOasOperationGenerator = function _GenerateContext_runOasOperationGenerator(oasDocument, generatorConfig, include, skip, stackTrail) {
866
866
  oasDocument.operations.forEach(operation => {
867
- stackTrail.trace(`${operation.path}:${operation.method}`, opTrail => {
867
+ stackTrail.trace([operation.path, operation.method], opTrail => {
868
868
  // Resolve the variant list to fan out over. The consumer's
869
869
  // enrichments are keyed `[generatorId][path][method][variant]`;
870
870
  // the block at `[path][method]` is therefore a record of
@@ -887,7 +887,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
887
887
  operationLabel: `${operation.method.toUpperCase()} ${operation.path}`
888
888
  });
889
889
  variants.forEach(variant => {
890
- opTrail.trace(`variant: ${variant}`, st => {
890
+ opTrail.trace(['variant', variant], st => {
891
891
  try {
892
892
  if (typeof generatorConfig?.isSupported === 'function' &&
893
893
  !generatorConfig.isSupported({ operation, context: this, variant })) {
@@ -953,7 +953,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
953
953
  });
954
954
  }, _GenerateContext_runWebhookGenerator = function _GenerateContext_runWebhookGenerator(oasDocument, generatorConfig, include, skip, stackTrail) {
955
955
  oasDocument.webhooks.forEach(webhook => {
956
- stackTrail.trace(`webhook:${webhook.name}:${webhook.method}`, webhookTrail => {
956
+ stackTrail.trace(['webhook', webhook.name, webhook.method], webhookTrail => {
957
957
  // Variant fan-out, keyed `[generatorId][name][method][variant]` —
958
958
  // the webhook analogue of the operation routing. `toVariantList`
959
959
  // handles absent / non-object / object enrichment blocks and
@@ -969,7 +969,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
969
969
  operationLabel: `webhook '${webhook.name}' (${webhook.method.toUpperCase()})`
970
970
  });
971
971
  variants.forEach(variant => {
972
- webhookTrail.trace(`variant: ${variant}`, st => {
972
+ webhookTrail.trace(['variant', variant], st => {
973
973
  try {
974
974
  if (typeof generatorConfig?.isSupported === 'function' &&
975
975
  !generatorConfig.isSupported({ webhook, context: this, variant })) {
@@ -1034,7 +1034,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
1034
1034
  });
1035
1035
  }, _GenerateContext_runGqlOperationGenerator = function _GenerateContext_runGqlOperationGenerator(gqlDocument, generatorConfig, stackTrail) {
1036
1036
  gqlDocument.operations.forEach(operation => {
1037
- stackTrail.trace(operation.identifier, opTrail => {
1037
+ stackTrail.trace([operation.rootKind, operation.fieldName], opTrail => {
1038
1038
  // GraphQL enrichment routing key is
1039
1039
  // `[generatorId][rootKind][fieldName][variant]`.
1040
1040
  const opEnrichments = this.readEnrichment([
@@ -1048,7 +1048,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
1048
1048
  operationLabel: `${operation.rootKind} ${operation.fieldName}`
1049
1049
  });
1050
1050
  variants.forEach(variant => {
1051
- opTrail.trace(`variant: ${variant}`, st => {
1051
+ opTrail.trace(['variant', variant], st => {
1052
1052
  try {
1053
1053
  if (typeof generatorConfig.isSupported === 'function' &&
1054
1054
  !generatorConfig.isSupported({ operation, context: this, variant })) {
@@ -1100,7 +1100,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
1100
1100
  operationLabel: refName
1101
1101
  });
1102
1102
  variants.forEach(variant => {
1103
- refTrail.trace(`variant: ${variant}`, st => {
1103
+ refTrail.trace(['variant', variant], st => {
1104
1104
  try {
1105
1105
  if (typeof generatorConfig.isSupported === 'function' &&
1106
1106
  !generatorConfig.isSupported({ refName, context: this, variant })) {
@@ -194,7 +194,7 @@ export declare class ParseContext {
194
194
  * For tree-position issues, prefer {@link logIssueNoKey} so the
195
195
  * stack trail composes with the surrounding traces.
196
196
  *
197
- * Internally constructs a `StackTrail` from `location.split(':')`
197
+ * Internally constructs a `StackTrail` with `StackTrail.fromString(location)`
198
198
  * and delegates to {@link logIssueNoKey} — the underlying issue
199
199
  * recording logic (protocol tagging, optional ref-error
200
200
  * auto-registration, logger mirror with parent context) is shared.
@@ -466,13 +466,13 @@ export class ParseContext {
466
466
  * For tree-position issues, prefer {@link logIssueNoKey} so the
467
467
  * stack trail composes with the surrounding traces.
468
468
  *
469
- * Internally constructs a `StackTrail` from `location.split(':')`
469
+ * Internally constructs a `StackTrail` with `StackTrail.fromString(location)`
470
470
  * and delegates to {@link logIssueNoKey} — the underlying issue
471
471
  * recording logic (protocol tagging, optional ref-error
472
472
  * auto-registration, logger mirror with parent context) is shared.
473
473
  */
474
474
  log({ location, parent, type, ...issue }) {
475
- const stackTrail = new StackTrail(location.split(':'));
475
+ const stackTrail = StackTrail.fromString(location);
476
476
  this.logIssueNoKey({ stackTrail, parent, type, ...issue });
477
477
  }
478
478
  /**
@@ -29,7 +29,8 @@ export declare class StackTrail {
29
29
  */
30
30
  clone(): StackTrail;
31
31
  /**
32
- * Gets a copy of the current stack frames.
32
+ * The live array of stack frames, not a copy: {@link trace} pops it after
33
+ * `fn` returns. Copy it (`[...trail.stackTrail]`) to keep the frames.
33
34
  *
34
35
  * @returns Array of stack frames in order
35
36
  *
@@ -64,8 +65,13 @@ export declare class StackTrail {
64
65
  * ```
65
66
  */
66
67
  append(frame: string | string[]): StackTrail;
67
- trace<T>(key: string, fn: (st: StackTrail) => T): T;
68
- traceAsync<T>(key: string, fn: (st: StackTrail) => Promise<T>): Promise<T>;
68
+ /**
69
+ * Runs `fn` on a copy of the trail with `key` appended: one frame for a
70
+ * string, one frame per element for an array.
71
+ */
72
+ trace<T>(key: string | string[], fn: (st: StackTrail) => T): T;
73
+ /** Async form of {@link trace}. */
74
+ traceAsync<T>(key: string | string[], fn: (st: StackTrail) => Promise<T>): Promise<T>;
69
75
  /**
70
76
  * Converts the trail to an OpenAPI reference string if applicable.
71
77
  *
@@ -187,22 +193,33 @@ export declare class StackTrail {
187
193
  */
188
194
  toJSON(): string;
189
195
  /**
190
- * Converts the trail to a colon-separated string representation.
196
+ * Converts the trail to a colon-separated string.
191
197
  *
192
- * Colons within frame names are escaped as '%3A' to avoid conflicts
193
- * with the separator character.
194
- *
195
- * @returns String representation of the trail
198
+ * Inside a frame, `%` is escaped as `%25` and `:` as `%3A`, so
199
+ * {@link StackTrail.fromString} reads the same frames back.
196
200
  *
197
201
  * @example
198
202
  * ```typescript
199
- * const trail = new StackTrail(['components', 'schemas', 'User']);
200
- * console.log(trail.toString()); // 'components:schemas:User'
203
+ * new StackTrail(['components', 'schemas', 'User']).toString()
204
+ * // 'components:schemas:User'
201
205
  *
202
- * // With colon in frame name
203
- * const trailWithColon = new StackTrail(['components', 'schemas', 'User:Type']);
204
- * console.log(trailWithColon.toString()); // 'components:schemas:User%3AType'
206
+ * new StackTrail(['paths', '/pets/{id}:archive', '100%']).toString()
207
+ * // 'paths:/pets/{id}%3Aarchive:100%25'
205
208
  * ```
206
209
  */
207
210
  toString(): string;
211
+ /**
212
+ * Reads a string written by {@link StackTrail.toString} back into a trail.
213
+ *
214
+ * Splits on `:` and decodes `%25` and `%3A` in each frame. The empty
215
+ * string gives the empty trail, so a trail of one empty frame is the one
216
+ * trail that does not round-trip.
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * StackTrail.fromString('paths:/pets/{id}%3Aarchive:post').stackTrail
221
+ * // ['paths', '/pets/{id}:archive', 'post']
222
+ * ```
223
+ */
224
+ static fromString(value: string): StackTrail;
208
225
  }
@@ -51,7 +51,8 @@ export class StackTrail {
51
51
  return new StackTrail([...__classPrivateFieldGet(this, _StackTrail_stack, "f")]);
52
52
  }
53
53
  /**
54
- * Gets a copy of the current stack frames.
54
+ * The live array of stack frames, not a copy: {@link trace} pops it after
55
+ * `fn` returns. Copy it (`[...trail.stackTrail]`) to keep the frames.
55
56
  *
56
57
  * @returns Array of stack frames in order
57
58
  *
@@ -98,6 +99,10 @@ export class StackTrail {
98
99
  }
99
100
  throw new Error(`Unexpected stack frame: ${frame}`);
100
101
  }
102
+ /**
103
+ * Runs `fn` on a copy of the trail with `key` appended: one frame for a
104
+ * string, one frame per element for an array.
105
+ */
101
106
  trace(key, fn) {
102
107
  const stackTrail = this.clone();
103
108
  stackTrail.append(key);
@@ -111,6 +116,7 @@ export class StackTrail {
111
116
  throw error;
112
117
  }
113
118
  }
119
+ /** Async form of {@link trace}. */
114
120
  async traceAsync(key, fn) {
115
121
  const stackTrail = this.clone();
116
122
  stackTrail.append(key);
@@ -284,29 +290,45 @@ export class StackTrail {
284
290
  return this.toString();
285
291
  }
286
292
  /**
287
- * Converts the trail to a colon-separated string representation.
293
+ * Converts the trail to a colon-separated string.
288
294
  *
289
- * Colons within frame names are escaped as '%3A' to avoid conflicts
290
- * with the separator character.
291
- *
292
- * @returns String representation of the trail
295
+ * Inside a frame, `%` is escaped as `%25` and `:` as `%3A`, so
296
+ * {@link StackTrail.fromString} reads the same frames back.
293
297
  *
294
298
  * @example
295
299
  * ```typescript
296
- * const trail = new StackTrail(['components', 'schemas', 'User']);
297
- * console.log(trail.toString()); // 'components:schemas:User'
300
+ * new StackTrail(['components', 'schemas', 'User']).toString()
301
+ * // 'components:schemas:User'
298
302
  *
299
- * // With colon in frame name
300
- * const trailWithColon = new StackTrail(['components', 'schemas', 'User:Type']);
301
- * console.log(trailWithColon.toString()); // 'components:schemas:User%3AType'
303
+ * new StackTrail(['paths', '/pets/{id}:archive', '100%']).toString()
304
+ * // 'paths:/pets/{id}%3Aarchive:100%25'
302
305
  * ```
303
306
  */
304
307
  toString() {
305
308
  return __classPrivateFieldGet(this, _StackTrail_stack, "f")
306
- .map(item => {
307
- return typeof item === 'string' ? item.replaceAll(':', '%3A') : item;
308
- })
309
+ .map(frame => frame.replace(/[%:]/g, character => escapes[character]))
309
310
  .join(':');
310
311
  }
312
+ /**
313
+ * Reads a string written by {@link StackTrail.toString} back into a trail.
314
+ *
315
+ * Splits on `:` and decodes `%25` and `%3A` in each frame. The empty
316
+ * string gives the empty trail, so a trail of one empty frame is the one
317
+ * trail that does not round-trip.
318
+ *
319
+ * @example
320
+ * ```typescript
321
+ * StackTrail.fromString('paths:/pets/{id}%3Aarchive:post').stackTrail
322
+ * // ['paths', '/pets/{id}:archive', 'post']
323
+ * ```
324
+ */
325
+ static fromString(value) {
326
+ if (value === '') {
327
+ return new StackTrail([]);
328
+ }
329
+ return new StackTrail(value.split(':').map(frame => frame.replace(/%(25|3A)/g, (_, code) => decodes[code])));
330
+ }
311
331
  }
312
332
  _StackTrail_stack = new WeakMap();
333
+ const escapes = { '%': '%25', ':': '%3A' };
334
+ const decodes = { '25': '%', '3A': ':' };
@@ -167,7 +167,7 @@ export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3
167
167
  * scalar schema (a text body or a file). A body with only specific
168
168
  * non-JSON types (`multipart/form-data`, `text/plain`) logs nothing.
169
169
  */
170
- export type OasIssueType = 'UNEXPECTED_PROPERTY' | 'MISSING_OBJECT_TYPE' | 'MISSING_STRING_TYPE' | 'MISSING_ARRAY_TYPE' | 'MISSING_BOOLEAN_TYPE' | 'INVALID_EXAMPLE' | 'INVALID_ENUM' | 'INVALID_DEFAULT' | 'INVALID_NULLABLE' | 'UNEXPECTED_FORMAT' | 'INVALID_RESPONSE' | 'INVALID_FORMAT' | 'INVALID_OPERATION' | 'INVALID_SCHEMA' | 'INVALID_PARAMETER' | 'INVALID_SECURITY_SCHEME' | 'INVALID_DEPENDENCY_REF' | 'EXAMPLE_AND_EXAMPLES_DEFINED' | 'INVALID_TAG_PARENT' | 'UNSUPPORTED_OPERATION_METHOD' | 'WILDCARD_MEDIA_TYPE' | 'NO_JSON_MEDIA_TYPE';
170
+ export type OasIssueType = 'UNEXPECTED_PROPERTY' | 'MISSING_OBJECT_TYPE' | 'MISSING_STRING_TYPE' | 'MISSING_ARRAY_TYPE' | 'MISSING_BOOLEAN_TYPE' | 'MISSING_RESPONSES' | 'EMPTY_PARAMETER' | 'INVALID_EXAMPLE' | 'INVALID_ENUM' | 'INVALID_DEFAULT' | 'INVALID_NULLABLE' | 'UNEXPECTED_FORMAT' | 'INVALID_RESPONSE' | 'INVALID_FORMAT' | 'INVALID_OPERATION' | 'INVALID_SCHEMA' | 'INVALID_PARAMETER' | 'INVALID_SECURITY_SCHEME' | 'INVALID_DEPENDENCY_REF' | 'EXAMPLE_AND_EXAMPLES_DEFINED' | 'INVALID_TAG_PARENT' | 'UNSUPPORTED_OPERATION_METHOD' | 'WILDCARD_MEDIA_TYPE' | 'NO_JSON_MEDIA_TYPE';
171
171
  /**
172
172
  * Valibot schema for {@link OasIssueType}. Annotation deliberately omitted
173
173
  * so the precise literal-union output type flows through to consumers
@@ -175,7 +175,7 @@ export type OasIssueType = 'UNEXPECTED_PROPERTY' | 'MISSING_OBJECT_TYPE' | 'MISS
175
175
  * this list and {@link OasIssueType} is caught by `assertSchemaMatchesType`
176
176
  * below.
177
177
  */
178
- export declare const oasIssueType: v.UnionSchema<[v.LiteralSchema<"UNEXPECTED_PROPERTY", undefined>, v.LiteralSchema<"MISSING_OBJECT_TYPE", undefined>, v.LiteralSchema<"MISSING_STRING_TYPE", undefined>, v.LiteralSchema<"MISSING_ARRAY_TYPE", undefined>, v.LiteralSchema<"MISSING_BOOLEAN_TYPE", undefined>, v.LiteralSchema<"INVALID_EXAMPLE", undefined>, v.LiteralSchema<"INVALID_ENUM", undefined>, v.LiteralSchema<"INVALID_DEFAULT", undefined>, v.LiteralSchema<"INVALID_NULLABLE", undefined>, v.LiteralSchema<"UNEXPECTED_FORMAT", undefined>, v.LiteralSchema<"INVALID_RESPONSE", undefined>, v.LiteralSchema<"INVALID_FORMAT", undefined>, v.LiteralSchema<"INVALID_OPERATION", undefined>, v.LiteralSchema<"INVALID_SCHEMA", undefined>, v.LiteralSchema<"INVALID_PARAMETER", undefined>, v.LiteralSchema<"INVALID_SECURITY_SCHEME", undefined>, v.LiteralSchema<"INVALID_DEPENDENCY_REF", undefined>, v.LiteralSchema<"EXAMPLE_AND_EXAMPLES_DEFINED", undefined>, v.LiteralSchema<"INVALID_TAG_PARENT", undefined>, v.LiteralSchema<"UNSUPPORTED_OPERATION_METHOD", undefined>, v.LiteralSchema<"WILDCARD_MEDIA_TYPE", undefined>, v.LiteralSchema<"NO_JSON_MEDIA_TYPE", undefined>], undefined>;
178
+ export declare const oasIssueType: v.UnionSchema<[v.LiteralSchema<"UNEXPECTED_PROPERTY", undefined>, v.LiteralSchema<"MISSING_OBJECT_TYPE", undefined>, v.LiteralSchema<"MISSING_STRING_TYPE", undefined>, v.LiteralSchema<"MISSING_ARRAY_TYPE", undefined>, v.LiteralSchema<"MISSING_BOOLEAN_TYPE", undefined>, v.LiteralSchema<"MISSING_RESPONSES", undefined>, v.LiteralSchema<"EMPTY_PARAMETER", undefined>, v.LiteralSchema<"INVALID_EXAMPLE", undefined>, v.LiteralSchema<"INVALID_ENUM", undefined>, v.LiteralSchema<"INVALID_DEFAULT", undefined>, v.LiteralSchema<"INVALID_NULLABLE", undefined>, v.LiteralSchema<"UNEXPECTED_FORMAT", undefined>, v.LiteralSchema<"INVALID_RESPONSE", undefined>, v.LiteralSchema<"INVALID_FORMAT", undefined>, v.LiteralSchema<"INVALID_OPERATION", undefined>, v.LiteralSchema<"INVALID_SCHEMA", undefined>, v.LiteralSchema<"INVALID_PARAMETER", undefined>, v.LiteralSchema<"INVALID_SECURITY_SCHEME", undefined>, v.LiteralSchema<"INVALID_DEPENDENCY_REF", undefined>, v.LiteralSchema<"EXAMPLE_AND_EXAMPLES_DEFINED", undefined>, v.LiteralSchema<"INVALID_TAG_PARENT", undefined>, v.LiteralSchema<"UNSUPPORTED_OPERATION_METHOD", undefined>, v.LiteralSchema<"WILDCARD_MEDIA_TYPE", undefined>, v.LiteralSchema<"NO_JSON_MEDIA_TYPE", undefined>], undefined>;
179
179
  export type GenerateResult = {
180
180
  files: Map<string, FileBase>;
181
181
  previews: Record<string, Preview>;
@@ -12,6 +12,8 @@ export const oasIssueType = v.union([
12
12
  v.literal('MISSING_STRING_TYPE'),
13
13
  v.literal('MISSING_ARRAY_TYPE'),
14
14
  v.literal('MISSING_BOOLEAN_TYPE'),
15
+ v.literal('MISSING_RESPONSES'),
16
+ v.literal('EMPTY_PARAMETER'),
15
17
  v.literal('INVALID_EXAMPLE'),
16
18
  v.literal('INVALID_ENUM'),
17
19
  v.literal('INVALID_DEFAULT'),
@@ -1,200 +1,38 @@
1
+ import type { StackTrail } from '../context/StackTrail.js';
1
2
  import type { ResultsItem, ResultType } from '../types/Results.js';
2
3
  /**
3
- * Manages and organizes generation results with intelligent prioritization.
4
+ * Records one result per stack trail and builds the `manifest.results` tree.
4
5
  *
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.
6
+ * When several results are captured at the same trail, the most severe one
7
+ * wins (see `resultRankings`).
10
8
  *
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
9
+ * @example
48
10
  * ```typescript
49
- * const resultsLog = new ResultsLog();
11
+ * const resultsLog = new ResultsLog()
50
12
  *
51
- * // First capture a success
52
- * resultsLog.capture('api:createUser', 'success');
13
+ * resultsLog.capture(new StackTrail(['generate', '/pets', 'get']), 'success')
14
+ * resultsLog.capture(new StackTrail(['generate', '/pets/{id}:archive', 'post']), 'error')
53
15
  *
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
- * }
16
+ * resultsLog.toTree()
17
+ * // { generate: { '/pets': { get: 'success' }, '/pets/{id}:archive': { post: 'error' } } }
132
18
  * ```
133
19
  */
134
20
  export declare class ResultsLog {
135
21
  #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
- */
142
22
  constructor();
143
23
  /**
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();
24
+ * Captures `result` at `stackTrail`, unless a more severe result is
25
+ * already recorded there.
157
26
  *
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
- * ```
27
+ * Stores a copy of the frames: `StackTrail.trace` pops the live array
28
+ * after its callback returns.
163
29
  */
164
- capture(stackTrail: string, result: ResultType): void;
30
+ capture(stackTrail: StackTrail, result: ResultType): void;
165
31
  /**
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
- * ```
32
+ * Nests the captured results by their frames, one object level per frame.
33
+ * Frames are used as own-property keys verbatim, so a frame such as
34
+ * `constructor`, `toString` or `0` is a key like any other. A result
35
+ * captured at the empty trail has no key and is left out.
198
36
  */
199
37
  toTree(): ResultsItem;
200
38
  }