@skmtc/core 0.33.0 → 0.35.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.
- package/esm/context/CoreContext.d.ts +8 -21
- package/esm/context/CoreContext.js +9 -22
- package/esm/context/GenerateContext.js +7 -7
- package/esm/context/ParseContext.d.ts +1 -1
- package/esm/context/ParseContext.js +2 -2
- package/esm/context/StackTrail.d.ts +30 -13
- package/esm/context/StackTrail.js +36 -14
- package/esm/context/generateTypes.d.ts +2 -2
- package/esm/context/generateTypes.js +5 -0
- package/esm/helpers/ResultsLog.d.ts +19 -181
- package/esm/helpers/ResultsLog.js +46 -205
- package/esm/parse/descriptiveFields.d.ts +36 -0
- package/esm/parse/descriptiveFields.js +56 -0
- package/esm/parse/isPlainObject.d.ts +2 -0
- package/esm/parse/isPlainObject.js +2 -0
- package/esm/parse/toComponentEntries.d.ts +29 -0
- package/esm/parse/toComponentEntries.js +31 -0
- package/esm/parse/toPresentInfo.d.ts +30 -0
- package/esm/parse/toPresentInfo.js +40 -0
- package/esm/parse/v3-0/components/toComponentsV3.js +2 -2
- package/esm/parse/v3-0/externalDocs/toExternalDocs.d.ts +3 -1
- package/esm/parse/v3-0/externalDocs/toExternalDocs.js +9 -8
- package/esm/parse/v3-0/header/toHeadersV3.d.ts +12 -0
- package/esm/parse/v3-0/header/toHeadersV3.js +20 -0
- package/esm/parse/v3-0/info/toInfoV3.d.ts +2 -1
- package/esm/parse/v3-0/info/toInfoV3.js +15 -4
- package/esm/parse/v3-0/requestBody/toRequestBodiesV3.js +9 -9
- package/esm/parse/v3-0/tag/toTagsV3.js +7 -2
- package/esm/parse/v3-1/components/toComponentsV3.js +2 -2
- package/esm/parse/v3-1/externalDocs/toExternalDocs.d.ts +3 -1
- package/esm/parse/v3-1/externalDocs/toExternalDocs.js +9 -8
- package/esm/parse/v3-1/header/toHeadersV3.d.ts +12 -0
- package/esm/parse/v3-1/header/toHeadersV3.js +20 -0
- package/esm/parse/v3-1/info/toInfoV3.d.ts +2 -1
- package/esm/parse/v3-1/info/toInfoV3.js +15 -4
- package/esm/parse/v3-1/requestBody/toRequestBodiesV3.js +9 -9
- package/esm/parse/v3-1/tag/toTagsV3.js +7 -2
- package/esm/parse/v3-2/components/toComponentsV3.js +2 -2
- package/esm/parse/v3-2/externalDocs/toExternalDocs.d.ts +3 -1
- package/esm/parse/v3-2/externalDocs/toExternalDocs.js +9 -8
- package/esm/parse/v3-2/header/toHeadersV3.d.ts +12 -0
- package/esm/parse/v3-2/header/toHeadersV3.js +20 -0
- package/esm/parse/v3-2/info/toInfoV3.d.ts +2 -1
- package/esm/parse/v3-2/info/toInfoV3.js +15 -4
- package/esm/parse/v3-2/requestBody/toRequestBodiesV3.js +9 -9
- package/esm/parse/v3-2/tag/toTagsV3.js +14 -7
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +8 -21
- package/script/context/CoreContext.js +9 -22
- package/script/context/GenerateContext.js +7 -7
- package/script/context/ParseContext.d.ts +1 -1
- package/script/context/ParseContext.js +2 -2
- package/script/context/StackTrail.d.ts +30 -13
- package/script/context/StackTrail.js +36 -14
- package/script/context/generateTypes.d.ts +2 -2
- package/script/context/generateTypes.js +5 -0
- package/script/helpers/ResultsLog.d.ts +19 -181
- package/script/helpers/ResultsLog.js +46 -208
- package/script/parse/descriptiveFields.d.ts +36 -0
- package/script/parse/descriptiveFields.js +95 -0
- package/script/parse/isPlainObject.d.ts +2 -0
- package/script/parse/isPlainObject.js +6 -0
- package/script/parse/toComponentEntries.d.ts +29 -0
- package/script/parse/toComponentEntries.js +35 -0
- package/script/parse/toPresentInfo.d.ts +30 -0
- package/script/parse/toPresentInfo.js +45 -0
- package/script/parse/v3-0/components/toComponentsV3.js +1 -1
- package/script/parse/v3-0/externalDocs/toExternalDocs.d.ts +3 -1
- package/script/parse/v3-0/externalDocs/toExternalDocs.js +9 -41
- package/script/parse/v3-0/header/toHeadersV3.d.ts +12 -0
- package/script/parse/v3-0/header/toHeadersV3.js +22 -1
- package/script/parse/v3-0/info/toInfoV3.d.ts +2 -1
- package/script/parse/v3-0/info/toInfoV3.js +15 -4
- package/script/parse/v3-0/requestBody/toRequestBodiesV3.js +9 -9
- package/script/parse/v3-0/tag/toTagsV3.js +7 -2
- package/script/parse/v3-1/components/toComponentsV3.js +1 -1
- package/script/parse/v3-1/externalDocs/toExternalDocs.d.ts +3 -1
- package/script/parse/v3-1/externalDocs/toExternalDocs.js +9 -41
- package/script/parse/v3-1/header/toHeadersV3.d.ts +12 -0
- package/script/parse/v3-1/header/toHeadersV3.js +22 -1
- package/script/parse/v3-1/info/toInfoV3.d.ts +2 -1
- package/script/parse/v3-1/info/toInfoV3.js +15 -4
- package/script/parse/v3-1/requestBody/toRequestBodiesV3.js +9 -9
- package/script/parse/v3-1/tag/toTagsV3.js +7 -2
- package/script/parse/v3-2/components/toComponentsV3.js +1 -1
- package/script/parse/v3-2/externalDocs/toExternalDocs.d.ts +3 -1
- package/script/parse/v3-2/externalDocs/toExternalDocs.js +9 -41
- package/script/parse/v3-2/header/toHeadersV3.d.ts +12 -0
- package/script/parse/v3-2/header/toHeadersV3.js +22 -1
- package/script/parse/v3-2/info/toInfoV3.d.ts +2 -1
- package/script/parse/v3-2/info/toInfoV3.js +15 -4
- package/script/parse/v3-2/requestBody/toRequestBodiesV3.js +9 -9
- package/script/parse/v3-2/tag/toTagsV3.js +14 -7
|
@@ -305,31 +305,18 @@ export declare class CoreContext {
|
|
|
305
305
|
parseIssues: ParseIssue[];
|
|
306
306
|
};
|
|
307
307
|
/**
|
|
308
|
-
* Captures a result at
|
|
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
|
|
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
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
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
|
|
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
|
|
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
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
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
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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.
|
|
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(
|
|
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(
|
|
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`
|
|
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`
|
|
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 =
|
|
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
|
-
*
|
|
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
|
-
|
|
68
|
-
|
|
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
|
|
196
|
+
* Converts the trail to a colon-separated string.
|
|
191
197
|
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
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
|
-
*
|
|
200
|
-
*
|
|
203
|
+
* new StackTrail(['components', 'schemas', 'User']).toString()
|
|
204
|
+
* // 'components:schemas:User'
|
|
201
205
|
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
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
|
-
*
|
|
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
|
|
293
|
+
* Converts the trail to a colon-separated string.
|
|
288
294
|
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
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
|
-
*
|
|
297
|
-
*
|
|
300
|
+
* new StackTrail(['components', 'schemas', 'User']).toString()
|
|
301
|
+
* // 'components:schemas:User'
|
|
298
302
|
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
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(
|
|
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' | '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';
|
|
170
|
+
export type OasIssueType = 'UNEXPECTED_PROPERTY' | 'MISSING_OBJECT_TYPE' | 'MISSING_STRING_TYPE' | 'MISSING_ARRAY_TYPE' | 'MISSING_BOOLEAN_TYPE' | 'MISSING_RESPONSES' | 'MISSING_INFO' | 'EMPTY_PARAMETER' | 'INVALID_EXAMPLE' | 'INVALID_ENUM' | 'INVALID_DEFAULT' | 'INVALID_NULLABLE' | 'UNEXPECTED_FORMAT' | 'INVALID_RESPONSE' | 'INVALID_REQUEST_BODY' | 'INVALID_HEADER' | 'INVALID_FORMAT' | 'INVALID_OPERATION' | 'INVALID_SCHEMA' | 'INVALID_PARAMETER' | 'INVALID_SECURITY_SCHEME' | 'INVALID_DEPENDENCY_REF' | 'EXAMPLE_AND_EXAMPLES_DEFINED' | 'INVALID_TAG_PARENT' | 'INVALID_TAG' | 'INVALID_EXTERNAL_DOCS' | '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<"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>;
|
|
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<"MISSING_INFO", 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_REQUEST_BODY", undefined>, v.LiteralSchema<"INVALID_HEADER", 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<"INVALID_TAG", undefined>, v.LiteralSchema<"INVALID_EXTERNAL_DOCS", 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>;
|
|
@@ -13,6 +13,7 @@ export const oasIssueType = v.union([
|
|
|
13
13
|
v.literal('MISSING_ARRAY_TYPE'),
|
|
14
14
|
v.literal('MISSING_BOOLEAN_TYPE'),
|
|
15
15
|
v.literal('MISSING_RESPONSES'),
|
|
16
|
+
v.literal('MISSING_INFO'),
|
|
16
17
|
v.literal('EMPTY_PARAMETER'),
|
|
17
18
|
v.literal('INVALID_EXAMPLE'),
|
|
18
19
|
v.literal('INVALID_ENUM'),
|
|
@@ -20,6 +21,8 @@ export const oasIssueType = v.union([
|
|
|
20
21
|
v.literal('INVALID_NULLABLE'),
|
|
21
22
|
v.literal('UNEXPECTED_FORMAT'),
|
|
22
23
|
v.literal('INVALID_RESPONSE'),
|
|
24
|
+
v.literal('INVALID_REQUEST_BODY'),
|
|
25
|
+
v.literal('INVALID_HEADER'),
|
|
23
26
|
v.literal('INVALID_FORMAT'),
|
|
24
27
|
v.literal('INVALID_OPERATION'),
|
|
25
28
|
v.literal('INVALID_SCHEMA'),
|
|
@@ -28,6 +31,8 @@ export const oasIssueType = v.union([
|
|
|
28
31
|
v.literal('INVALID_DEPENDENCY_REF'),
|
|
29
32
|
v.literal('EXAMPLE_AND_EXAMPLES_DEFINED'),
|
|
30
33
|
v.literal('INVALID_TAG_PARENT'),
|
|
34
|
+
v.literal('INVALID_TAG'),
|
|
35
|
+
v.literal('INVALID_EXTERNAL_DOCS'),
|
|
31
36
|
v.literal('UNSUPPORTED_OPERATION_METHOD'),
|
|
32
37
|
v.literal('WILDCARD_MEDIA_TYPE'),
|
|
33
38
|
v.literal('NO_JSON_MEDIA_TYPE')
|
|
@@ -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
|
-
*
|
|
4
|
+
* Records one result per stack trail and builds the `manifest.results` tree.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
52
|
-
* resultsLog.capture('
|
|
13
|
+
* resultsLog.capture(new StackTrail(['generate', '/pets', 'get']), 'success')
|
|
14
|
+
* resultsLog.capture(new StackTrail(['generate', '/pets/{id}:archive', 'post']), 'error')
|
|
53
15
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
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
|
|
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
|
-
*
|
|
159
|
-
*
|
|
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:
|
|
30
|
+
capture(stackTrail: StackTrail, result: ResultType): void;
|
|
165
31
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
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
|
}
|