@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
|
@@ -871,7 +871,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
871
871
|
}
|
|
872
872
|
}, _GenerateContext_runOasOperationGenerator = function _GenerateContext_runOasOperationGenerator(oasDocument, generatorConfig, include, skip, stackTrail) {
|
|
873
873
|
oasDocument.operations.forEach(operation => {
|
|
874
|
-
stackTrail.trace(
|
|
874
|
+
stackTrail.trace([operation.path, operation.method], opTrail => {
|
|
875
875
|
// Resolve the variant list to fan out over. The consumer's
|
|
876
876
|
// enrichments are keyed `[generatorId][path][method][variant]`;
|
|
877
877
|
// the block at `[path][method]` is therefore a record of
|
|
@@ -894,7 +894,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
894
894
|
operationLabel: `${operation.method.toUpperCase()} ${operation.path}`
|
|
895
895
|
});
|
|
896
896
|
variants.forEach(variant => {
|
|
897
|
-
opTrail.trace(
|
|
897
|
+
opTrail.trace(['variant', variant], st => {
|
|
898
898
|
try {
|
|
899
899
|
if (typeof generatorConfig?.isSupported === 'function' &&
|
|
900
900
|
!generatorConfig.isSupported({ operation, context: this, variant })) {
|
|
@@ -960,7 +960,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
960
960
|
});
|
|
961
961
|
}, _GenerateContext_runWebhookGenerator = function _GenerateContext_runWebhookGenerator(oasDocument, generatorConfig, include, skip, stackTrail) {
|
|
962
962
|
oasDocument.webhooks.forEach(webhook => {
|
|
963
|
-
stackTrail.trace(
|
|
963
|
+
stackTrail.trace(['webhook', webhook.name, webhook.method], webhookTrail => {
|
|
964
964
|
// Variant fan-out, keyed `[generatorId][name][method][variant]` —
|
|
965
965
|
// the webhook analogue of the operation routing. `toVariantList`
|
|
966
966
|
// handles absent / non-object / object enrichment blocks and
|
|
@@ -976,7 +976,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
976
976
|
operationLabel: `webhook '${webhook.name}' (${webhook.method.toUpperCase()})`
|
|
977
977
|
});
|
|
978
978
|
variants.forEach(variant => {
|
|
979
|
-
webhookTrail.trace(
|
|
979
|
+
webhookTrail.trace(['variant', variant], st => {
|
|
980
980
|
try {
|
|
981
981
|
if (typeof generatorConfig?.isSupported === 'function' &&
|
|
982
982
|
!generatorConfig.isSupported({ webhook, context: this, variant })) {
|
|
@@ -1041,7 +1041,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1041
1041
|
});
|
|
1042
1042
|
}, _GenerateContext_runGqlOperationGenerator = function _GenerateContext_runGqlOperationGenerator(gqlDocument, generatorConfig, stackTrail) {
|
|
1043
1043
|
gqlDocument.operations.forEach(operation => {
|
|
1044
|
-
stackTrail.trace(operation.
|
|
1044
|
+
stackTrail.trace([operation.rootKind, operation.fieldName], opTrail => {
|
|
1045
1045
|
// GraphQL enrichment routing key is
|
|
1046
1046
|
// `[generatorId][rootKind][fieldName][variant]`.
|
|
1047
1047
|
const opEnrichments = this.readEnrichment([
|
|
@@ -1055,7 +1055,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1055
1055
|
operationLabel: `${operation.rootKind} ${operation.fieldName}`
|
|
1056
1056
|
});
|
|
1057
1057
|
variants.forEach(variant => {
|
|
1058
|
-
opTrail.trace(
|
|
1058
|
+
opTrail.trace(['variant', variant], st => {
|
|
1059
1059
|
try {
|
|
1060
1060
|
if (typeof generatorConfig.isSupported === 'function' &&
|
|
1061
1061
|
!generatorConfig.isSupported({ operation, context: this, variant })) {
|
|
@@ -1107,7 +1107,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1107
1107
|
operationLabel: refName
|
|
1108
1108
|
});
|
|
1109
1109
|
variants.forEach(variant => {
|
|
1110
|
-
refTrail.trace(
|
|
1110
|
+
refTrail.trace(['variant', variant], st => {
|
|
1111
1111
|
try {
|
|
1112
1112
|
if (typeof generatorConfig.isSupported === 'function' &&
|
|
1113
1113
|
!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.
|
|
@@ -469,13 +469,13 @@ class ParseContext {
|
|
|
469
469
|
* For tree-position issues, prefer {@link logIssueNoKey} so the
|
|
470
470
|
* stack trail composes with the surrounding traces.
|
|
471
471
|
*
|
|
472
|
-
* Internally constructs a `StackTrail`
|
|
472
|
+
* Internally constructs a `StackTrail` with `StackTrail.fromString(location)`
|
|
473
473
|
* and delegates to {@link logIssueNoKey} — the underlying issue
|
|
474
474
|
* recording logic (protocol tagging, optional ref-error
|
|
475
475
|
* auto-registration, logger mirror with parent context) is shared.
|
|
476
476
|
*/
|
|
477
477
|
log({ location, parent, type, ...issue }) {
|
|
478
|
-
const stackTrail =
|
|
478
|
+
const stackTrail = StackTrail_js_1.StackTrail.fromString(location);
|
|
479
479
|
this.logIssueNoKey({ stackTrail, parent, type, ...issue });
|
|
480
480
|
}
|
|
481
481
|
/**
|
|
@@ -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
|
}
|
|
@@ -54,7 +54,8 @@ class StackTrail {
|
|
|
54
54
|
return new StackTrail([...__classPrivateFieldGet(this, _StackTrail_stack, "f")]);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* The live array of stack frames, not a copy: {@link trace} pops it after
|
|
58
|
+
* `fn` returns. Copy it (`[...trail.stackTrail]`) to keep the frames.
|
|
58
59
|
*
|
|
59
60
|
* @returns Array of stack frames in order
|
|
60
61
|
*
|
|
@@ -101,6 +102,10 @@ class StackTrail {
|
|
|
101
102
|
}
|
|
102
103
|
throw new Error(`Unexpected stack frame: ${frame}`);
|
|
103
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Runs `fn` on a copy of the trail with `key` appended: one frame for a
|
|
107
|
+
* string, one frame per element for an array.
|
|
108
|
+
*/
|
|
104
109
|
trace(key, fn) {
|
|
105
110
|
const stackTrail = this.clone();
|
|
106
111
|
stackTrail.append(key);
|
|
@@ -114,6 +119,7 @@ class StackTrail {
|
|
|
114
119
|
throw error;
|
|
115
120
|
}
|
|
116
121
|
}
|
|
122
|
+
/** Async form of {@link trace}. */
|
|
117
123
|
async traceAsync(key, fn) {
|
|
118
124
|
const stackTrail = this.clone();
|
|
119
125
|
stackTrail.append(key);
|
|
@@ -287,30 +293,46 @@ class StackTrail {
|
|
|
287
293
|
return this.toString();
|
|
288
294
|
}
|
|
289
295
|
/**
|
|
290
|
-
* Converts the trail to a colon-separated string
|
|
296
|
+
* Converts the trail to a colon-separated string.
|
|
291
297
|
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
* @returns String representation of the trail
|
|
298
|
+
* Inside a frame, `%` is escaped as `%25` and `:` as `%3A`, so
|
|
299
|
+
* {@link StackTrail.fromString} reads the same frames back.
|
|
296
300
|
*
|
|
297
301
|
* @example
|
|
298
302
|
* ```typescript
|
|
299
|
-
*
|
|
300
|
-
*
|
|
303
|
+
* new StackTrail(['components', 'schemas', 'User']).toString()
|
|
304
|
+
* // 'components:schemas:User'
|
|
301
305
|
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* console.log(trailWithColon.toString()); // 'components:schemas:User%3AType'
|
|
306
|
+
* new StackTrail(['paths', '/pets/{id}:archive', '100%']).toString()
|
|
307
|
+
* // 'paths:/pets/{id}%3Aarchive:100%25'
|
|
305
308
|
* ```
|
|
306
309
|
*/
|
|
307
310
|
toString() {
|
|
308
311
|
return __classPrivateFieldGet(this, _StackTrail_stack, "f")
|
|
309
|
-
.map(
|
|
310
|
-
return typeof item === 'string' ? item.replaceAll(':', '%3A') : item;
|
|
311
|
-
})
|
|
312
|
+
.map(frame => frame.replace(/[%:]/g, character => escapes[character]))
|
|
312
313
|
.join(':');
|
|
313
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Reads a string written by {@link StackTrail.toString} back into a trail.
|
|
317
|
+
*
|
|
318
|
+
* Splits on `:` and decodes `%25` and `%3A` in each frame. The empty
|
|
319
|
+
* string gives the empty trail, so a trail of one empty frame is the one
|
|
320
|
+
* trail that does not round-trip.
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* StackTrail.fromString('paths:/pets/{id}%3Aarchive:post').stackTrail
|
|
325
|
+
* // ['paths', '/pets/{id}:archive', 'post']
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
static fromString(value) {
|
|
329
|
+
if (value === '') {
|
|
330
|
+
return new StackTrail([]);
|
|
331
|
+
}
|
|
332
|
+
return new StackTrail(value.split(':').map(frame => frame.replace(/%(25|3A)/g, (_, code) => decodes[code])));
|
|
333
|
+
}
|
|
314
334
|
}
|
|
315
335
|
exports.StackTrail = StackTrail;
|
|
316
336
|
_StackTrail_stack = new WeakMap();
|
|
337
|
+
const escapes = { '%': '%25', ':': '%3A' };
|
|
338
|
+
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>;
|
|
@@ -49,6 +49,7 @@ exports.oasIssueType = v.union([
|
|
|
49
49
|
v.literal('MISSING_ARRAY_TYPE'),
|
|
50
50
|
v.literal('MISSING_BOOLEAN_TYPE'),
|
|
51
51
|
v.literal('MISSING_RESPONSES'),
|
|
52
|
+
v.literal('MISSING_INFO'),
|
|
52
53
|
v.literal('EMPTY_PARAMETER'),
|
|
53
54
|
v.literal('INVALID_EXAMPLE'),
|
|
54
55
|
v.literal('INVALID_ENUM'),
|
|
@@ -56,6 +57,8 @@ exports.oasIssueType = v.union([
|
|
|
56
57
|
v.literal('INVALID_NULLABLE'),
|
|
57
58
|
v.literal('UNEXPECTED_FORMAT'),
|
|
58
59
|
v.literal('INVALID_RESPONSE'),
|
|
60
|
+
v.literal('INVALID_REQUEST_BODY'),
|
|
61
|
+
v.literal('INVALID_HEADER'),
|
|
59
62
|
v.literal('INVALID_FORMAT'),
|
|
60
63
|
v.literal('INVALID_OPERATION'),
|
|
61
64
|
v.literal('INVALID_SCHEMA'),
|
|
@@ -64,6 +67,8 @@ exports.oasIssueType = v.union([
|
|
|
64
67
|
v.literal('INVALID_DEPENDENCY_REF'),
|
|
65
68
|
v.literal('EXAMPLE_AND_EXAMPLES_DEFINED'),
|
|
66
69
|
v.literal('INVALID_TAG_PARENT'),
|
|
70
|
+
v.literal('INVALID_TAG'),
|
|
71
|
+
v.literal('INVALID_EXTERNAL_DOCS'),
|
|
67
72
|
v.literal('UNSUPPORTED_OPERATION_METHOD'),
|
|
68
73
|
v.literal('WILDCARD_MEDIA_TYPE'),
|
|
69
74
|
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
|
}
|