@skmtc/core 0.36.0 → 0.37.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/_dnt.polyfills.d.ts +6 -6
- package/esm/context/CoreContext.d.ts +10 -2
- package/esm/context/CoreContext.js +158 -87
- package/esm/context/GenerateContext.d.ts +11 -0
- package/esm/context/GenerateContext.js +44 -16
- package/esm/context/LogLinesHandler.d.ts +28 -0
- package/esm/context/LogLinesHandler.js +65 -0
- package/esm/context/ParseContext.js +22 -3
- package/esm/context/ParseIssue.d.ts +12 -9
- package/esm/context/ParseIssue.js +7 -6
- package/esm/context/ResultsHandler.d.ts +5 -3
- package/esm/context/ResultsHandler.js +11 -5
- package/esm/context/generateTypes.d.ts +21 -2
- package/esm/context/generateTypes.js +2 -1
- package/esm/mod.d.ts +2 -0
- package/esm/mod.js +2 -0
- package/esm/parse/v3-0/server/toServerV3.js +11 -1
- package/esm/parse/v3-1/server/toServerV3.js +11 -1
- package/esm/parse/v3-2/server/toServerV3.js +11 -1
- package/esm/run/toArtifacts.d.ts +9 -1
- package/esm/run/toArtifacts.js +4 -4
- package/esm/types/LogLine.d.ts +36 -0
- package/esm/types/LogLine.js +26 -0
- package/esm/types/Manifest.d.ts +1 -1
- package/esm/types/Manifest.js +16 -4
- package/esm/types/SerializedError.d.ts +25 -0
- package/esm/types/SerializedError.js +50 -0
- package/package.json +1 -1
- package/script/_dnt.polyfills.d.ts +6 -6
- package/script/context/CoreContext.d.ts +10 -2
- package/script/context/CoreContext.js +158 -87
- package/script/context/GenerateContext.d.ts +11 -0
- package/script/context/GenerateContext.js +44 -16
- package/script/context/LogLinesHandler.d.ts +28 -0
- package/script/context/LogLinesHandler.js +69 -0
- package/script/context/ParseContext.js +22 -3
- package/script/context/ParseIssue.d.ts +12 -9
- package/script/context/ParseIssue.js +7 -6
- package/script/context/ResultsHandler.d.ts +5 -3
- package/script/context/ResultsHandler.js +11 -5
- package/script/context/generateTypes.d.ts +21 -2
- package/script/context/generateTypes.js +2 -1
- package/script/mod.d.ts +2 -0
- package/script/mod.js +2 -0
- package/script/parse/v3-0/server/toServerV3.js +11 -1
- package/script/parse/v3-1/server/toServerV3.js +11 -1
- package/script/parse/v3-2/server/toServerV3.js +11 -1
- package/script/run/toArtifacts.d.ts +9 -1
- package/script/run/toArtifacts.js +4 -4
- package/script/types/LogLine.d.ts +36 -0
- package/script/types/LogLine.js +62 -0
- package/script/types/Manifest.d.ts +1 -1
- package/script/types/Manifest.js +16 -4
- package/script/types/SerializedError.d.ts +25 -0
- package/script/types/SerializedError.js +87 -0
|
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_reportSkippedEnrichment, _GenerateContext_schemaRefNames, _GenerateContext_subjectDefaults, _GenerateContext_runOasOperationGenerator, _GenerateContext_runWebhookGenerator, _GenerateContext_runGqlOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_addPreview, _GenerateContext_toContentSettingsExportPath, _GenerateContext_ejectedBySuffixedPath_get, _GenerateContext_ejectedBySuffixedPathCache, _GenerateContext_findContainer, _GenerateContext_toContainer;
|
|
16
|
+
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_currentSubjectTrail, _GenerateContext_reportSkippedEnrichment, _GenerateContext_logError, _GenerateContext_schemaRefNames, _GenerateContext_subjectDefaults, _GenerateContext_runOasOperationGenerator, _GenerateContext_runWebhookGenerator, _GenerateContext_runGqlOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_addPreview, _GenerateContext_toContentSettingsExportPath, _GenerateContext_ejectedBySuffixedPath_get, _GenerateContext_ejectedBySuffixedPathCache, _GenerateContext_findContainer, _GenerateContext_toContainer;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.toModelSource = exports.toGqlOperationSource = exports.toWebhookSource = exports.toOasOperationSource = exports.GenerateContext = void 0;
|
|
19
19
|
const normalizeWorkspacePath_js_1 = require("../helpers/normalizeWorkspacePath.js");
|
|
@@ -35,6 +35,7 @@ const JsonFile_js_1 = require("../dsl/JsonFile.js");
|
|
|
35
35
|
const MarkdownFile_js_1 = require("../dsl/MarkdownFile.js");
|
|
36
36
|
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
37
37
|
const EnrichmentAudit_js_1 = require("../enrichments/EnrichmentAudit.js");
|
|
38
|
+
const SerializedError_js_1 = require("../types/SerializedError.js");
|
|
38
39
|
const EnrichmentWarning_js_1 = require("../enrichments/EnrichmentWarning.js");
|
|
39
40
|
/**
|
|
40
41
|
* The generation context for the second phase of the SKMTC transformation pipeline.
|
|
@@ -147,6 +148,8 @@ class GenerateContext {
|
|
|
147
148
|
* `enrichmentWarnings` at the end of {@link toArtifacts}.
|
|
148
149
|
*/
|
|
149
150
|
_GenerateContext_enrichmentAudit.set(this, void 0);
|
|
151
|
+
/** See {@link currentSubjectTrail}. */
|
|
152
|
+
_GenerateContext_currentSubjectTrail.set(this, void 0);
|
|
150
153
|
_GenerateContext_ejectedBySuffixedPathCache.set(this, void 0);
|
|
151
154
|
this.logger = logger;
|
|
152
155
|
__classPrivateFieldSet(this, _GenerateContext_files, new Map(), "f");
|
|
@@ -189,6 +192,28 @@ class GenerateContext {
|
|
|
189
192
|
get captureSink() {
|
|
190
193
|
return __classPrivateFieldGet(this, _GenerateContext_captureChannel, "f")?.sink;
|
|
191
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* The trail of the subject whose variant is being generated, or
|
|
197
|
+
* `undefined` outside one. Log lines and the results the logger
|
|
198
|
+
* records are addressed by it.
|
|
199
|
+
*/
|
|
200
|
+
get currentSubjectTrail() {
|
|
201
|
+
return __classPrivateFieldGet(this, _GenerateContext_currentSubjectTrail, "f");
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Runs `fn` with {@link currentSubjectTrail} set to `stackTrail`, and
|
|
205
|
+
* restores the previous value afterwards.
|
|
206
|
+
*/
|
|
207
|
+
withSubjectTrail(stackTrail, fn) {
|
|
208
|
+
const previous = __classPrivateFieldGet(this, _GenerateContext_currentSubjectTrail, "f");
|
|
209
|
+
__classPrivateFieldSet(this, _GenerateContext_currentSubjectTrail, stackTrail, "f");
|
|
210
|
+
try {
|
|
211
|
+
return fn();
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
__classPrivateFieldSet(this, _GenerateContext_currentSubjectTrail, previous, "f");
|
|
215
|
+
}
|
|
216
|
+
}
|
|
192
217
|
/**
|
|
193
218
|
* @internal
|
|
194
219
|
*/
|
|
@@ -835,7 +860,7 @@ class GenerateContext {
|
|
|
835
860
|
}
|
|
836
861
|
}
|
|
837
862
|
exports.GenerateContext = GenerateContext;
|
|
838
|
-
_GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_captureChannel = new WeakMap(), _GenerateContext_enrichmentAudit = new WeakMap(), _GenerateContext_ejectedBySuffixedPathCache = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_reportSkippedEnrichment = function _GenerateContext_reportSkippedEnrichment(block, variant, path) {
|
|
863
|
+
_GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_captureChannel = new WeakMap(), _GenerateContext_enrichmentAudit = new WeakMap(), _GenerateContext_currentSubjectTrail = new WeakMap(), _GenerateContext_ejectedBySuffixedPathCache = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_reportSkippedEnrichment = function _GenerateContext_reportSkippedEnrichment(block, variant, path) {
|
|
839
864
|
if (!(0, EnrichmentAudit_js_1.hasVariantEnrichment)(block, variant))
|
|
840
865
|
return;
|
|
841
866
|
__classPrivateFieldGet(this, _GenerateContext_enrichmentAudit, "f").report({
|
|
@@ -845,6 +870,8 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
845
870
|
message: `enrichment at '${(0, EnrichmentWarning_js_1.formatEnrichmentPath)(path)}' targets a skipped item — ` +
|
|
846
871
|
`it was not applied in this run`
|
|
847
872
|
});
|
|
873
|
+
}, _GenerateContext_logError = function _GenerateContext_logError(error) {
|
|
874
|
+
this.logger.error((0, SerializedError_js_1.toSerializedError)(error).message, error);
|
|
848
875
|
}, _GenerateContext_schemaRefNames = function _GenerateContext_schemaRefNames() {
|
|
849
876
|
switch (this.document.type) {
|
|
850
877
|
case 'oas':
|
|
@@ -866,7 +893,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
866
893
|
return isEnrichmentLeaf(subject) ? subject : undefined;
|
|
867
894
|
}
|
|
868
895
|
catch (error) {
|
|
869
|
-
this.
|
|
896
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logError).call(this, error);
|
|
870
897
|
return undefined;
|
|
871
898
|
}
|
|
872
899
|
}, _GenerateContext_runOasOperationGenerator = function _GenerateContext_runOasOperationGenerator(oasDocument, generatorConfig, include, skip, stackTrail) {
|
|
@@ -894,7 +921,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
894
921
|
operationLabel: `${operation.method.toUpperCase()} ${operation.path}`
|
|
895
922
|
});
|
|
896
923
|
variants.forEach(variant => {
|
|
897
|
-
opTrail.trace(['variant', variant], st => {
|
|
924
|
+
opTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
|
|
898
925
|
try {
|
|
899
926
|
if (typeof generatorConfig?.isSupported === 'function' &&
|
|
900
927
|
!generatorConfig.isSupported({ operation, context: this, variant })) {
|
|
@@ -951,10 +978,10 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
951
978
|
this.captureCurrentResult('success', st);
|
|
952
979
|
}
|
|
953
980
|
catch (error) {
|
|
954
|
-
this.
|
|
981
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logError).call(this, error);
|
|
955
982
|
this.captureCurrentResult('error', st);
|
|
956
983
|
}
|
|
957
|
-
});
|
|
984
|
+
}));
|
|
958
985
|
});
|
|
959
986
|
});
|
|
960
987
|
});
|
|
@@ -976,7 +1003,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
976
1003
|
operationLabel: `webhook '${webhook.name}' (${webhook.method.toUpperCase()})`
|
|
977
1004
|
});
|
|
978
1005
|
variants.forEach(variant => {
|
|
979
|
-
webhookTrail.trace(['variant', variant], st => {
|
|
1006
|
+
webhookTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
|
|
980
1007
|
try {
|
|
981
1008
|
if (typeof generatorConfig?.isSupported === 'function' &&
|
|
982
1009
|
!generatorConfig.isSupported({ webhook, context: this, variant })) {
|
|
@@ -1032,10 +1059,10 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1032
1059
|
this.captureCurrentResult('success', st);
|
|
1033
1060
|
}
|
|
1034
1061
|
catch (error) {
|
|
1035
|
-
this.
|
|
1062
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logError).call(this, error);
|
|
1036
1063
|
this.captureCurrentResult('error', st);
|
|
1037
1064
|
}
|
|
1038
|
-
});
|
|
1065
|
+
}));
|
|
1039
1066
|
});
|
|
1040
1067
|
});
|
|
1041
1068
|
});
|
|
@@ -1055,7 +1082,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1055
1082
|
operationLabel: `${operation.rootKind} ${operation.fieldName}`
|
|
1056
1083
|
});
|
|
1057
1084
|
variants.forEach(variant => {
|
|
1058
|
-
opTrail.trace(['variant', variant], st => {
|
|
1085
|
+
opTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
|
|
1059
1086
|
try {
|
|
1060
1087
|
if (typeof generatorConfig.isSupported === 'function' &&
|
|
1061
1088
|
!generatorConfig.isSupported({ operation, context: this, variant })) {
|
|
@@ -1076,10 +1103,10 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1076
1103
|
this.captureCurrentResult('success', st);
|
|
1077
1104
|
}
|
|
1078
1105
|
catch (error) {
|
|
1079
|
-
this.
|
|
1106
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logError).call(this, error);
|
|
1080
1107
|
this.captureCurrentResult('error', st);
|
|
1081
1108
|
}
|
|
1082
|
-
});
|
|
1109
|
+
}));
|
|
1083
1110
|
});
|
|
1084
1111
|
});
|
|
1085
1112
|
});
|
|
@@ -1107,7 +1134,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1107
1134
|
operationLabel: refName
|
|
1108
1135
|
});
|
|
1109
1136
|
variants.forEach(variant => {
|
|
1110
|
-
refTrail.trace(['variant', variant], st => {
|
|
1137
|
+
refTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
|
|
1111
1138
|
try {
|
|
1112
1139
|
if (typeof generatorConfig.isSupported === 'function' &&
|
|
1113
1140
|
!generatorConfig.isSupported({ refName, context: this, variant })) {
|
|
@@ -1118,7 +1145,8 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1118
1145
|
// (deny). Match is on `(refName, variant)`. An empty variant
|
|
1119
1146
|
// array on a refName means "every variant of this refName"; a
|
|
1120
1147
|
// populated array names the variants the entry applies to.
|
|
1121
|
-
if (include !== undefined &&
|
|
1148
|
+
if (include !== undefined &&
|
|
1149
|
+
!matchesRefFilter({ refs: include, refName, variant })) {
|
|
1122
1150
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_reportSkippedEnrichment).call(this, modelEnrichments, variant, [
|
|
1123
1151
|
generatorConfig.id,
|
|
1124
1152
|
refName,
|
|
@@ -1150,10 +1178,10 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1150
1178
|
this.captureCurrentResult('success', st);
|
|
1151
1179
|
}
|
|
1152
1180
|
catch (error) {
|
|
1153
|
-
this.
|
|
1181
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logError).call(this, error);
|
|
1154
1182
|
this.captureCurrentResult('error', st);
|
|
1155
1183
|
}
|
|
1156
|
-
});
|
|
1184
|
+
}));
|
|
1157
1185
|
});
|
|
1158
1186
|
});
|
|
1159
1187
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type LevelName } from '../deps/jsr.io/@std/log/0.224.14/levels.js';
|
|
2
|
+
import type { LogRecord } from '../deps/jsr.io/@std/log/0.224.14/logger.js';
|
|
3
|
+
import { BaseHandler } from '../deps/jsr.io/@std/log/0.224.14/base_handler.js';
|
|
4
|
+
import type { LogLine } from '../types/LogLine.js';
|
|
5
|
+
/** Configuration options for the {@link LogLinesHandler}. */
|
|
6
|
+
export type LogLinesHandlerOptions = {
|
|
7
|
+
/** The trail of the subject being generated, or `undefined` outside one. */
|
|
8
|
+
toTrail: () => string | undefined;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Keeps each log record at or above its level as a {@link LogLine}, in
|
|
12
|
+
* memory, for `toArtifacts` to return.
|
|
13
|
+
*/
|
|
14
|
+
export declare class LogLinesHandler extends BaseHandler {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(levelName: LevelName, { toTrail }: LogLinesHandlerOptions);
|
|
17
|
+
/** The lines kept so far, in the order they were logged. */
|
|
18
|
+
get lines(): LogLine[];
|
|
19
|
+
/**
|
|
20
|
+
* Records `logRecord` as a structured line. Overrides `handle` because
|
|
21
|
+
* `BaseHandler.handle` formats the record to a string before `log`.
|
|
22
|
+
*
|
|
23
|
+
* @override
|
|
24
|
+
*/
|
|
25
|
+
handle(logRecord: LogRecord): void;
|
|
26
|
+
/** Not used: {@link handle} records the structured line. */
|
|
27
|
+
log(_msg: string): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _LogLinesHandler_toTrail, _LogLinesHandler_lines;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.LogLinesHandler = void 0;
|
|
16
|
+
const levels_js_1 = require("../deps/jsr.io/@std/log/0.224.14/levels.js");
|
|
17
|
+
const base_handler_js_1 = require("../deps/jsr.io/@std/log/0.224.14/base_handler.js");
|
|
18
|
+
const SerializedError_js_1 = require("../types/SerializedError.js");
|
|
19
|
+
/**
|
|
20
|
+
* Keeps each log record at or above its level as a {@link LogLine}, in
|
|
21
|
+
* memory, for `toArtifacts` to return.
|
|
22
|
+
*/
|
|
23
|
+
class LogLinesHandler extends base_handler_js_1.BaseHandler {
|
|
24
|
+
constructor(levelName, { toTrail }) {
|
|
25
|
+
super(levelName);
|
|
26
|
+
_LogLinesHandler_toTrail.set(this, void 0);
|
|
27
|
+
_LogLinesHandler_lines.set(this, []);
|
|
28
|
+
__classPrivateFieldSet(this, _LogLinesHandler_toTrail, toTrail, "f");
|
|
29
|
+
}
|
|
30
|
+
/** The lines kept so far, in the order they were logged. */
|
|
31
|
+
get lines() {
|
|
32
|
+
return __classPrivateFieldGet(this, _LogLinesHandler_lines, "f");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Records `logRecord` as a structured line. Overrides `handle` because
|
|
36
|
+
* `BaseHandler.handle` formats the record to a string before `log`.
|
|
37
|
+
*
|
|
38
|
+
* @override
|
|
39
|
+
*/
|
|
40
|
+
handle(logRecord) {
|
|
41
|
+
if (this.level > logRecord.level) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Taken now: the trail object changes after the subject's callback returns.
|
|
45
|
+
const trail = __classPrivateFieldGet(this, _LogLinesHandler_toTrail, "f").call(this);
|
|
46
|
+
const error = logRecord.args.find(arg => arg instanceof Error);
|
|
47
|
+
__classPrivateFieldGet(this, _LogLinesHandler_lines, "f").push({
|
|
48
|
+
seq: __classPrivateFieldGet(this, _LogLinesHandler_lines, "f").length,
|
|
49
|
+
level: toLogLineLevel(logRecord.level),
|
|
50
|
+
...(trail === undefined ? {} : { trail }),
|
|
51
|
+
message: logRecord.msg,
|
|
52
|
+
...(error === undefined ? {} : { error: (0, SerializedError_js_1.toSerializedError)(error) }),
|
|
53
|
+
time: logRecord.datetime.getTime()
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/** Not used: {@link handle} records the structured line. */
|
|
57
|
+
log(_msg) { }
|
|
58
|
+
}
|
|
59
|
+
exports.LogLinesHandler = LogLinesHandler;
|
|
60
|
+
_LogLinesHandler_toTrail = new WeakMap(), _LogLinesHandler_lines = new WeakMap();
|
|
61
|
+
const toLogLineLevel = (level) => {
|
|
62
|
+
if (level >= levels_js_1.LogLevels.ERROR)
|
|
63
|
+
return 'ERROR';
|
|
64
|
+
if (level >= levels_js_1.LogLevels.WARN)
|
|
65
|
+
return 'WARN';
|
|
66
|
+
if (level >= levels_js_1.LogLevels.INFO)
|
|
67
|
+
return 'INFO';
|
|
68
|
+
return 'DEBUG';
|
|
69
|
+
};
|
|
@@ -43,6 +43,25 @@ const parseGqlDocument_js_1 = require("../gql/document/parseGqlDocument.js");
|
|
|
43
43
|
const StackTrail_js_1 = require("./StackTrail.js");
|
|
44
44
|
const isPlainObject_js_1 = require("../parse/isPlainObject.js");
|
|
45
45
|
const pathParameters_js_1 = require("../parse/pathParameters.js");
|
|
46
|
+
const SerializedError_js_1 = require("../types/SerializedError.js");
|
|
47
|
+
/** The stored form of an issue: an error's `cause` as a `SerializedError`. */
|
|
48
|
+
const toParseIssue = (issue) => {
|
|
49
|
+
if (issue.level !== 'error') {
|
|
50
|
+
return issue;
|
|
51
|
+
}
|
|
52
|
+
const { protocol, location, message } = issue;
|
|
53
|
+
const cause = issue.cause === undefined ? {} : { cause: (0, SerializedError_js_1.toSerializedError)(issue.cause) };
|
|
54
|
+
switch (protocol) {
|
|
55
|
+
case 'oas':
|
|
56
|
+
return { protocol, level: 'error', type: issue.type, location, message, ...cause };
|
|
57
|
+
case 'gql':
|
|
58
|
+
return { protocol, level: 'error', type: issue.type, location, message, ...cause };
|
|
59
|
+
default: {
|
|
60
|
+
const _exhaustive = protocol;
|
|
61
|
+
throw new Error(`Unhandled protocol type: ${JSON.stringify(_exhaustive)}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
46
65
|
class ParseContext {
|
|
47
66
|
constructor({ input, logger, silent = true, options }) {
|
|
48
67
|
_ParseContext_instances.add(this);
|
|
@@ -368,7 +387,7 @@ class ParseContext {
|
|
|
368
387
|
* manifest).
|
|
369
388
|
*/
|
|
370
389
|
logIssueAt(issue, parent) {
|
|
371
|
-
this.issues.push(issue);
|
|
390
|
+
this.issues.push(toParseIssue(issue));
|
|
372
391
|
if (!this.silent) {
|
|
373
392
|
this.logger.warn({
|
|
374
393
|
protocol: issue.protocol,
|
|
@@ -574,7 +593,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
574
593
|
type: 'INVALID_DEPENDENCY_REF',
|
|
575
594
|
location,
|
|
576
595
|
message,
|
|
577
|
-
cause: error
|
|
596
|
+
cause: (0, SerializedError_js_1.toSerializedError)(error)
|
|
578
597
|
});
|
|
579
598
|
break;
|
|
580
599
|
case 'gql':
|
|
@@ -584,7 +603,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
584
603
|
type: 'INVALID_DEPENDENCY_REF',
|
|
585
604
|
location,
|
|
586
605
|
message,
|
|
587
|
-
cause: error
|
|
606
|
+
cause: (0, SerializedError_js_1.toSerializedError)(error)
|
|
588
607
|
});
|
|
589
608
|
break;
|
|
590
609
|
default: {
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* GraphQL parsing. Each variant stands on its own — no shared base —
|
|
4
4
|
* so TypeScript narrows cleanly on `protocol` and `level`.
|
|
5
5
|
*
|
|
6
|
-
* `cause?:
|
|
7
|
-
* `debug` issues are synthesized by the parser with all the
|
|
8
|
-
* needed for the `message`; errors usually wrap a thrown
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* `cause?: SerializedError` is only present on the error variants.
|
|
7
|
+
* Warnings and `debug` issues are synthesized by the parser with all the
|
|
8
|
+
* information needed for the `message`; errors usually wrap a thrown
|
|
9
|
+
* `Error`, which is stored in `cause` as a {@link SerializedError} so its
|
|
10
|
+
* name, message and stack survive `JSON.stringify`.
|
|
11
11
|
*
|
|
12
12
|
* Three severities: `error` (broken — drives exit status), `warning` (a
|
|
13
13
|
* real deviation that was handled, e.g. a 3.0 schema missing `type`), and
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import * as v from 'valibot';
|
|
25
25
|
import type { OasIssueType } from './generateTypes.js';
|
|
26
|
+
import type { SerializedError } from '../types/SerializedError.js';
|
|
26
27
|
/**
|
|
27
28
|
* Categories of issues recorded during GraphQL → OAS mapping.
|
|
28
29
|
*
|
|
@@ -49,22 +50,24 @@ import type { OasIssueType } from './generateTypes.js';
|
|
|
49
50
|
* implementer references a type that failed to parse, and the
|
|
50
51
|
* consumer was pruned by `removeErroredItems`. Mirrors OAS's
|
|
51
52
|
* identically-named issue.
|
|
53
|
+
* - `RUN_FAILED` — the run itself failed outside the per-item catches.
|
|
54
|
+
* Mirrors OAS's identically-named issue.
|
|
52
55
|
*/
|
|
53
|
-
export type GqlIssueType = 'NESTED_LIST_LOSSY' | 'UNKNOWN_TYPE_KIND' | 'DROPPED_DIRECTIVE' | 'SKIPPED_FIELD_ARGUMENTS' | 'SKIPPED_FEATURE' | 'INVALID_TYPE_DEFINITION' | 'INVALID_DEPENDENCY_REF';
|
|
56
|
+
export type GqlIssueType = 'NESTED_LIST_LOSSY' | 'UNKNOWN_TYPE_KIND' | 'DROPPED_DIRECTIVE' | 'SKIPPED_FIELD_ARGUMENTS' | 'SKIPPED_FEATURE' | 'INVALID_TYPE_DEFINITION' | 'INVALID_DEPENDENCY_REF' | 'RUN_FAILED';
|
|
54
57
|
/**
|
|
55
58
|
* Valibot schema for {@link GqlIssueType}. Annotation deliberately
|
|
56
59
|
* omitted so the precise literal-union output type flows through to
|
|
57
60
|
* consumers; drift between this list and {@link GqlIssueType} is
|
|
58
61
|
* caught by the compile-time assertion below.
|
|
59
62
|
*/
|
|
60
|
-
export declare const gqlIssueType: v.UnionSchema<[v.LiteralSchema<"NESTED_LIST_LOSSY", undefined>, v.LiteralSchema<"UNKNOWN_TYPE_KIND", undefined>, v.LiteralSchema<"DROPPED_DIRECTIVE", undefined>, v.LiteralSchema<"SKIPPED_FIELD_ARGUMENTS", undefined>, v.LiteralSchema<"SKIPPED_FEATURE", undefined>, v.LiteralSchema<"INVALID_TYPE_DEFINITION", undefined>, v.LiteralSchema<"INVALID_DEPENDENCY_REF", undefined>], undefined>;
|
|
63
|
+
export declare const gqlIssueType: v.UnionSchema<[v.LiteralSchema<"NESTED_LIST_LOSSY", undefined>, v.LiteralSchema<"UNKNOWN_TYPE_KIND", undefined>, v.LiteralSchema<"DROPPED_DIRECTIVE", undefined>, v.LiteralSchema<"SKIPPED_FIELD_ARGUMENTS", undefined>, v.LiteralSchema<"SKIPPED_FEATURE", undefined>, v.LiteralSchema<"INVALID_TYPE_DEFINITION", undefined>, v.LiteralSchema<"INVALID_DEPENDENCY_REF", undefined>, v.LiteralSchema<"RUN_FAILED", undefined>], undefined>;
|
|
61
64
|
export type ParseIssue = {
|
|
62
65
|
protocol: 'oas';
|
|
63
66
|
level: 'error';
|
|
64
67
|
type: OasIssueType;
|
|
65
68
|
location: string;
|
|
66
69
|
message: string;
|
|
67
|
-
cause?:
|
|
70
|
+
cause?: SerializedError;
|
|
68
71
|
} | {
|
|
69
72
|
protocol: 'oas';
|
|
70
73
|
level: 'warning';
|
|
@@ -83,7 +86,7 @@ export type ParseIssue = {
|
|
|
83
86
|
type: GqlIssueType;
|
|
84
87
|
location: string;
|
|
85
88
|
message: string;
|
|
86
|
-
cause?:
|
|
89
|
+
cause?: SerializedError;
|
|
87
90
|
} | {
|
|
88
91
|
protocol: 'gql';
|
|
89
92
|
level: 'warning';
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* GraphQL parsing. Each variant stands on its own — no shared base —
|
|
5
5
|
* so TypeScript narrows cleanly on `protocol` and `level`.
|
|
6
6
|
*
|
|
7
|
-
* `cause?:
|
|
8
|
-
* `debug` issues are synthesized by the parser with all the
|
|
9
|
-
* needed for the `message`; errors usually wrap a thrown
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* `cause?: SerializedError` is only present on the error variants.
|
|
8
|
+
* Warnings and `debug` issues are synthesized by the parser with all the
|
|
9
|
+
* information needed for the `message`; errors usually wrap a thrown
|
|
10
|
+
* `Error`, which is stored in `cause` as a {@link SerializedError} so its
|
|
11
|
+
* name, message and stack survive `JSON.stringify`.
|
|
12
12
|
*
|
|
13
13
|
* Three severities: `error` (broken — drives exit status), `warning` (a
|
|
14
14
|
* real deviation that was handled, e.g. a 3.0 schema missing `type`), and
|
|
@@ -71,7 +71,8 @@ exports.gqlIssueType = v.union([
|
|
|
71
71
|
v.literal('SKIPPED_FIELD_ARGUMENTS'),
|
|
72
72
|
v.literal('SKIPPED_FEATURE'),
|
|
73
73
|
v.literal('INVALID_TYPE_DEFINITION'),
|
|
74
|
-
v.literal('INVALID_DEPENDENCY_REF')
|
|
74
|
+
v.literal('INVALID_DEPENDENCY_REF'),
|
|
75
|
+
v.literal('RUN_FAILED')
|
|
75
76
|
]);
|
|
76
77
|
const _gqlIssueTypeDriftCheck = exports.gqlIssueType;
|
|
77
78
|
void _gqlIssueTypeDriftCheck;
|
|
@@ -60,10 +60,11 @@ export declare class ResultsHandler extends BaseHandler implements LogHandlerBas
|
|
|
60
60
|
/**
|
|
61
61
|
* Captures log messages as results in the context.
|
|
62
62
|
*
|
|
63
|
-
* Converts log level names to result types and captures them
|
|
64
|
-
*
|
|
63
|
+
* Converts log level names to result types and captures them in the
|
|
64
|
+
* associated CoreContext at the trail of the subject being generated.
|
|
65
|
+
* A line logged outside a subject records nothing.
|
|
65
66
|
*
|
|
66
|
-
* @param levelName - The log level name ('WARN' or '
|
|
67
|
+
* @param levelName - The log level name ('WARN', 'ERROR' or 'CRITICAL')
|
|
67
68
|
*
|
|
68
69
|
* @throws {Error} When an unsupported log level is provided
|
|
69
70
|
*
|
|
@@ -72,6 +73,7 @@ export declare class ResultsHandler extends BaseHandler implements LogHandlerBas
|
|
|
72
73
|
* // This is called automatically by the logging system
|
|
73
74
|
* handler.log('WARN'); // Captures as 'warning' result
|
|
74
75
|
* handler.log('ERROR'); // Captures as 'error' result
|
|
76
|
+
* handler.log('CRITICAL'); // Captures as 'error' result
|
|
75
77
|
* ```
|
|
76
78
|
*/
|
|
77
79
|
log(levelName: string): void;
|
|
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.ResultsHandler = void 0;
|
|
10
10
|
const levels_js_1 = require("../deps/jsr.io/@std/log/0.224.14/levels.js");
|
|
11
11
|
const base_handler_js_1 = require("../deps/jsr.io/@std/log/0.224.14/base_handler.js");
|
|
12
|
-
const StackTrail_js_1 = require("./StackTrail.js");
|
|
13
12
|
class ResultsHandler extends base_handler_js_1.BaseHandler {
|
|
14
13
|
/**
|
|
15
14
|
* Creates a new ResultsHandler instance.
|
|
@@ -90,10 +89,11 @@ class ResultsHandler extends base_handler_js_1.BaseHandler {
|
|
|
90
89
|
/**
|
|
91
90
|
* Captures log messages as results in the context.
|
|
92
91
|
*
|
|
93
|
-
* Converts log level names to result types and captures them
|
|
94
|
-
*
|
|
92
|
+
* Converts log level names to result types and captures them in the
|
|
93
|
+
* associated CoreContext at the trail of the subject being generated.
|
|
94
|
+
* A line logged outside a subject records nothing.
|
|
95
95
|
*
|
|
96
|
-
* @param levelName - The log level name ('WARN' or '
|
|
96
|
+
* @param levelName - The log level name ('WARN', 'ERROR' or 'CRITICAL')
|
|
97
97
|
*
|
|
98
98
|
* @throws {Error} When an unsupported log level is provided
|
|
99
99
|
*
|
|
@@ -102,6 +102,7 @@ class ResultsHandler extends base_handler_js_1.BaseHandler {
|
|
|
102
102
|
* // This is called automatically by the logging system
|
|
103
103
|
* handler.log('WARN'); // Captures as 'warning' result
|
|
104
104
|
* handler.log('ERROR'); // Captures as 'error' result
|
|
105
|
+
* handler.log('CRITICAL'); // Captures as 'error' result
|
|
105
106
|
* ```
|
|
106
107
|
*/
|
|
107
108
|
log(levelName) {
|
|
@@ -111,12 +112,17 @@ class ResultsHandler extends base_handler_js_1.BaseHandler {
|
|
|
111
112
|
resultType = 'warning';
|
|
112
113
|
break;
|
|
113
114
|
case 'ERROR':
|
|
115
|
+
case 'CRITICAL':
|
|
114
116
|
resultType = 'error';
|
|
115
117
|
break;
|
|
116
118
|
default:
|
|
117
119
|
throw new Error(`Unexpected log level name: ${levelName}`);
|
|
118
120
|
}
|
|
119
|
-
|
|
121
|
+
// Outside a subject there is no result to record against.
|
|
122
|
+
const subjectTrail = this.context.currentSubjectTrail;
|
|
123
|
+
if (subjectTrail !== undefined) {
|
|
124
|
+
this.context.captureCurrentResult(resultType, subjectTrail);
|
|
125
|
+
}
|
|
120
126
|
}
|
|
121
127
|
/**
|
|
122
128
|
* Flushes any buffered content.
|
|
@@ -28,6 +28,8 @@ import type { GqlOperationProjection } from '../dsl/operation/gql/types.js';
|
|
|
28
28
|
import type { GqlOperation } from '../gql/operation/GqlOperation.js';
|
|
29
29
|
import type { SkmtcParsedDocument } from '../types/SkmtcDocument.js';
|
|
30
30
|
import type { AttributionState } from '../types/AttributionState.js';
|
|
31
|
+
import type { Logger } from '../types/Logger.js';
|
|
32
|
+
import type { LogLine } from '../types/LogLine.js';
|
|
31
33
|
import type { EnrichmentWarning } from '../enrichments/EnrichmentWarning.js';
|
|
32
34
|
import type { CaptureSink } from '../anchors/CaptureSink.js';
|
|
33
35
|
import type { Sidecar } from '../anchors/sidecar.js';
|
|
@@ -143,6 +145,13 @@ export type ToArtifactsResult = RenderResult & {
|
|
|
143
145
|
* the VS Code debugger views.
|
|
144
146
|
*/
|
|
145
147
|
inspection?: unknown;
|
|
148
|
+
/**
|
|
149
|
+
* The lines the run's logger received at or above the `logLevel`
|
|
150
|
+
* `toArtifacts` was called with (`'WARN'` by default), in order. A
|
|
151
|
+
* line logged while a subject was generated carries the subject's
|
|
152
|
+
* trail, which is also its key in `results`.
|
|
153
|
+
*/
|
|
154
|
+
logs: LogLine[];
|
|
146
155
|
};
|
|
147
156
|
/**
|
|
148
157
|
* Union type representing any supported OpenAPI document version.
|
|
@@ -166,8 +175,12 @@ export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3
|
|
|
166
175
|
* body, and its keys include a range: `application/*`, or `*\/*` with a
|
|
167
176
|
* scalar schema (a text body or a file). A body with only specific
|
|
168
177
|
* non-JSON types (`multipart/form-data`, `text/plain`) logs nothing.
|
|
178
|
+
*
|
|
179
|
+
* `RUN_FAILED` (`error`) — the run itself failed outside the per-item
|
|
180
|
+
* catches. Its `location` names the entry and phase, for example
|
|
181
|
+
* `toArtifacts:render`.
|
|
169
182
|
*/
|
|
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';
|
|
183
|
+
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' | 'RUN_FAILED';
|
|
171
184
|
/**
|
|
172
185
|
* Valibot schema for {@link OasIssueType}. Annotation deliberately omitted
|
|
173
186
|
* so the precise literal-union output type flows through to consumers
|
|
@@ -175,7 +188,7 @@ export type OasIssueType = 'UNEXPECTED_PROPERTY' | 'MISSING_OBJECT_TYPE' | 'MISS
|
|
|
175
188
|
* this list and {@link OasIssueType} is caught by `assertSchemaMatchesType`
|
|
176
189
|
* below.
|
|
177
190
|
*/
|
|
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>;
|
|
191
|
+
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>, v.LiteralSchema<"RUN_FAILED", undefined>], undefined>;
|
|
179
192
|
export type GenerateResult = {
|
|
180
193
|
files: Map<string, FileBase>;
|
|
181
194
|
previews: Record<string, Preview>;
|
|
@@ -396,6 +409,12 @@ export type ToWebhookSettingsArgs<V extends GeneratedValue, EnrichmentType = und
|
|
|
396
409
|
export type InsertNormalizedModelReturn<V extends GeneratedValue, Schema extends OasSchema | OasRef<'schema'> | OasVoid> = Schema extends OasRef<'schema'> ? DefinitionBase<V> : DefinitionBase<TypeSystemOutput<SchemaToNonRef<Schema>['type']>>;
|
|
397
410
|
export type GenerateContextType = {
|
|
398
411
|
settings: ClientSettings | undefined;
|
|
412
|
+
/**
|
|
413
|
+
* The run's logger. A line logged inside a transform carries the
|
|
414
|
+
* subject's stack trail, and a `warn` or `error` line sets the
|
|
415
|
+
* subject's result to `'warning'` or `'error'`.
|
|
416
|
+
*/
|
|
417
|
+
logger: Logger;
|
|
399
418
|
modelDepth: Record<string, number>;
|
|
400
419
|
document: SkmtcParsedDocument;
|
|
401
420
|
/**
|
|
@@ -71,7 +71,8 @@ exports.oasIssueType = v.union([
|
|
|
71
71
|
v.literal('INVALID_EXTERNAL_DOCS'),
|
|
72
72
|
v.literal('UNSUPPORTED_OPERATION_METHOD'),
|
|
73
73
|
v.literal('WILDCARD_MEDIA_TYPE'),
|
|
74
|
-
v.literal('NO_JSON_MEDIA_TYPE')
|
|
74
|
+
v.literal('NO_JSON_MEDIA_TYPE'),
|
|
75
|
+
v.literal('RUN_FAILED')
|
|
75
76
|
]);
|
|
76
77
|
// Compile-time drift detector: this binding fails to type-check if
|
|
77
78
|
// `OasIssueType` and the literal list above disagree in either
|
package/script/mod.d.ts
CHANGED
|
@@ -204,6 +204,8 @@ export * from './types/Modifiers.js';
|
|
|
204
204
|
export * from './types/ModuleExport.js';
|
|
205
205
|
export * from './types/ModuleSelect.js';
|
|
206
206
|
export * from './types/SchemaPath.js';
|
|
207
|
+
export * from './types/SerializedError.js';
|
|
208
|
+
export * from './types/LogLine.js';
|
|
207
209
|
export * from './enrichments/toEnrichmentDescriptor.js';
|
|
208
210
|
export * from './enrichments/validateConfig.js';
|
|
209
211
|
export * from './enrichments/readEnrichments.js';
|
package/script/mod.js
CHANGED
|
@@ -218,6 +218,8 @@ __exportStar(require("./types/Modifiers.js"), exports);
|
|
|
218
218
|
__exportStar(require("./types/ModuleExport.js"), exports);
|
|
219
219
|
__exportStar(require("./types/ModuleSelect.js"), exports);
|
|
220
220
|
__exportStar(require("./types/SchemaPath.js"), exports);
|
|
221
|
+
__exportStar(require("./types/SerializedError.js"), exports);
|
|
222
|
+
__exportStar(require("./types/LogLine.js"), exports);
|
|
221
223
|
__exportStar(require("./enrichments/toEnrichmentDescriptor.js"), exports);
|
|
222
224
|
__exportStar(require("./enrichments/validateConfig.js"), exports);
|
|
223
225
|
__exportStar(require("./enrichments/readEnrichments.js"), exports);
|
|
@@ -6,6 +6,16 @@ const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toS
|
|
|
6
6
|
const toServerVariableV3_js_1 = require("../serverVariable/toServerVariableV3.js");
|
|
7
7
|
const tryParseAt_js_1 = require("../../../context/tryParseAt.js");
|
|
8
8
|
const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
9
|
+
if (!Array.isArray(servers)) {
|
|
10
|
+
context.logIssueNoKey({
|
|
11
|
+
level: 'error',
|
|
12
|
+
stackTrail,
|
|
13
|
+
parent: servers,
|
|
14
|
+
message: '"servers" must be an array; left out',
|
|
15
|
+
type: 'INVALID_OPERATION'
|
|
16
|
+
});
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
9
19
|
return servers.flatMap((server, index) => {
|
|
10
20
|
const parsed = (0, tryParseAt_js_1.tryParseAt)({
|
|
11
21
|
stackTrail,
|
|
@@ -25,7 +35,7 @@ const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
|
25
35
|
};
|
|
26
36
|
exports.toServersV3 = toServersV3;
|
|
27
37
|
const toOptionalServersV3 = ({ servers, stackTrail, context }) => {
|
|
28
|
-
if (
|
|
38
|
+
if (servers === undefined || servers === null) {
|
|
29
39
|
return undefined;
|
|
30
40
|
}
|
|
31
41
|
return (0, exports.toServersV3)({ servers, stackTrail, context });
|
|
@@ -6,6 +6,16 @@ const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toS
|
|
|
6
6
|
const toServerVariableV3_js_1 = require("../serverVariable/toServerVariableV3.js");
|
|
7
7
|
const tryParseAt_js_1 = require("../../../context/tryParseAt.js");
|
|
8
8
|
const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
9
|
+
if (!Array.isArray(servers)) {
|
|
10
|
+
context.logIssueNoKey({
|
|
11
|
+
level: 'error',
|
|
12
|
+
stackTrail,
|
|
13
|
+
parent: servers,
|
|
14
|
+
message: '"servers" must be an array; left out',
|
|
15
|
+
type: 'INVALID_OPERATION'
|
|
16
|
+
});
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
9
19
|
return servers.flatMap((server, index) => {
|
|
10
20
|
const parsed = (0, tryParseAt_js_1.tryParseAt)({
|
|
11
21
|
stackTrail,
|
|
@@ -25,7 +35,7 @@ const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
|
25
35
|
};
|
|
26
36
|
exports.toServersV3 = toServersV3;
|
|
27
37
|
const toOptionalServersV3 = ({ servers, stackTrail, context }) => {
|
|
28
|
-
if (
|
|
38
|
+
if (servers === undefined || servers === null) {
|
|
29
39
|
return undefined;
|
|
30
40
|
}
|
|
31
41
|
return (0, exports.toServersV3)({ servers, stackTrail, context });
|