@skmtc/core 0.49.0 → 0.50.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.js +80 -3
- package/esm/context/GenerateContext.d.ts +6 -1
- package/esm/context/GenerateContext.js +149 -81
- package/esm/context/LogLinesHandler.d.ts +1 -1
- package/esm/context/LogLinesHandler.js +3 -0
- package/esm/context/ParseContext.d.ts +3 -0
- package/esm/context/ParseContext.js +36 -14
- package/esm/helpers/ResultsLog.js +7 -1
- package/esm/helpers/refFns.js +11 -0
- package/esm/helpers/toCountPhrase.d.ts +11 -0
- package/esm/helpers/toCountPhrase.js +11 -0
- package/esm/parse/toCyclicRefs.js +27 -16
- package/esm/types/JsonPointer.js +2 -2
- package/esm/types/LogLine.d.ts +40 -1
- package/esm/types/LogLine.js +25 -0
- package/package.json +1 -1
- package/script/context/CoreContext.js +80 -3
- package/script/context/GenerateContext.d.ts +6 -1
- package/script/context/GenerateContext.js +149 -81
- package/script/context/LogLinesHandler.d.ts +1 -1
- package/script/context/LogLinesHandler.js +3 -0
- package/script/context/ParseContext.d.ts +3 -0
- package/script/context/ParseContext.js +36 -14
- package/script/helpers/ResultsLog.js +7 -1
- package/script/helpers/refFns.js +11 -0
- package/script/helpers/toCountPhrase.d.ts +11 -0
- package/script/helpers/toCountPhrase.js +15 -0
- package/script/parse/toCyclicRefs.js +27 -16
- package/script/types/JsonPointer.js +2 -2
- package/script/types/LogLine.d.ts +40 -1
- package/script/types/LogLine.js +27 -1
|
@@ -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_failedItems, _GenerateContext_foldedPaths, _GenerateContext_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_currentSubjectTrail, _GenerateContext_reportSkippedEnrichment, _GenerateContext_logError, _GenerateContext_failItem, _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_failedItems, _GenerateContext_foldedPaths, _GenerateContext_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_currentSubjectTrail, _GenerateContext_logsGeneratorLines, _GenerateContext_subjectCounts, _GenerateContext_reportSkippedEnrichment, _GenerateContext_logError, _GenerateContext_failItem, _GenerateContext_captureSubjectResult, _GenerateContext_logGeneratorLine, _GenerateContext_runGenerator, _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");
|
|
@@ -38,10 +38,27 @@ const DefinitionContainer_js_1 = require("../dsl/DefinitionContainer.js");
|
|
|
38
38
|
const JsonFile_js_1 = require("../dsl/JsonFile.js");
|
|
39
39
|
const MarkdownFile_js_1 = require("../dsl/MarkdownFile.js");
|
|
40
40
|
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
41
|
+
const toCountPhrase_js_1 = require("../helpers/toCountPhrase.js");
|
|
41
42
|
const EnrichmentAudit_js_1 = require("../enrichments/EnrichmentAudit.js");
|
|
42
43
|
const SerializedError_js_1 = require("../types/SerializedError.js");
|
|
43
44
|
const toGenerationFailure_js_1 = require("./toGenerationFailure.js");
|
|
44
45
|
const EnrichmentWarning_js_1 = require("../enrichments/EnrichmentWarning.js");
|
|
46
|
+
/** What one of a generator's subjects is called on its log line. */
|
|
47
|
+
const toSubjectNoun = ({ type }) => {
|
|
48
|
+
switch (type) {
|
|
49
|
+
case 'oasOperation':
|
|
50
|
+
case 'gqlOperation':
|
|
51
|
+
return 'operation';
|
|
52
|
+
case 'webhook':
|
|
53
|
+
return 'webhook';
|
|
54
|
+
case 'model':
|
|
55
|
+
return 'model';
|
|
56
|
+
default: {
|
|
57
|
+
const _exhaustive = type;
|
|
58
|
+
throw new Error(`Invalid generator type: ${JSON.stringify(_exhaustive)}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
45
62
|
/**
|
|
46
63
|
* The generation context for the second phase of the SKMTC transformation pipeline.
|
|
47
64
|
*
|
|
@@ -91,7 +108,7 @@ const isGqlToOperationSettingsFields = (args) => args.operation.oasType === 'gql
|
|
|
91
108
|
* (`{ fields, title, … }`). Narrows `unknown` without an `as` cast. */
|
|
92
109
|
const isEnrichmentLeaf = (value) => typeof value === 'object' && value !== null;
|
|
93
110
|
class GenerateContext {
|
|
94
|
-
constructor({ document, settings, logger, captureCurrentResult, toGeneratorConfigMap, captureChannel }) {
|
|
111
|
+
constructor({ document, settings, logger, captureCurrentResult, toGeneratorConfigMap, captureChannel, logsGeneratorLines = false }) {
|
|
95
112
|
_GenerateContext_instances.add(this);
|
|
96
113
|
_GenerateContext_files.set(this, void 0);
|
|
97
114
|
/** Each subject whose generation threw: its trail and the error message. */
|
|
@@ -161,8 +178,13 @@ class GenerateContext {
|
|
|
161
178
|
_GenerateContext_enrichmentAudit.set(this, void 0);
|
|
162
179
|
/** See {@link currentSubjectTrail}. */
|
|
163
180
|
_GenerateContext_currentSubjectTrail.set(this, void 0);
|
|
181
|
+
/** Whether each generator logs a line after it ran. */
|
|
182
|
+
_GenerateContext_logsGeneratorLines.set(this, void 0);
|
|
183
|
+
/** The counts of the generator {@link toArtifacts} is running. */
|
|
184
|
+
_GenerateContext_subjectCounts.set(this, { offered: 0, transformed: 0, failed: 0 });
|
|
164
185
|
_GenerateContext_ejectedBySuffixedPathCache.set(this, void 0);
|
|
165
186
|
this.logger = logger;
|
|
187
|
+
__classPrivateFieldSet(this, _GenerateContext_logsGeneratorLines, logsGeneratorLines, "f");
|
|
166
188
|
__classPrivateFieldSet(this, _GenerateContext_files, new Map(), "f");
|
|
167
189
|
__classPrivateFieldSet(this, _GenerateContext_previews, {}, "f");
|
|
168
190
|
this.document = document;
|
|
@@ -231,66 +253,21 @@ class GenerateContext {
|
|
|
231
253
|
const generators = Object.values(this.toGeneratorConfigMap());
|
|
232
254
|
generators.forEach(generatorConfig => {
|
|
233
255
|
stackTrail.trace(generatorConfig.id, st => {
|
|
234
|
-
// Whole-generator skip (string entry in `skip`).
|
|
235
|
-
//
|
|
256
|
+
// Whole-generator skip (string entry in `skip`). No per-operation
|
|
257
|
+
// `skipped` results emitted.
|
|
236
258
|
if (this.settings?.skip?.includes(generatorConfig.id)) {
|
|
259
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logGeneratorLine).call(this, st, `${generatorConfig.id}: skipped by settings.skip`);
|
|
237
260
|
return;
|
|
238
261
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const skip = toGeneratorFilter(this.settings?.skip, generatorConfig.id);
|
|
249
|
-
// Extract the per-generator include slice (if any). Same
|
|
250
|
-
// dispatch shape as skip: object entries get matched by key,
|
|
251
|
-
// string entries don't produce a per-op filter (they mean
|
|
252
|
-
// "everything from this generator is included", which is
|
|
253
|
-
// semantically equivalent to "no per-op filter" once the
|
|
254
|
-
// whole-generator gate above has admitted us).
|
|
255
|
-
const include = toGeneratorFilter(this.settings?.include, generatorConfig.id);
|
|
256
|
-
switch (generatorConfig.type) {
|
|
257
|
-
case 'oasOperation':
|
|
258
|
-
if (this.document.type !== 'oas') {
|
|
259
|
-
// Generator targets OAS; current document is GraphQL — skip silently.
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOasOperationGenerator).call(this, this.document.value, generatorConfig, toIncludePaths(include, generatorConfig.id), toSkipPaths(skip, generatorConfig.id), st);
|
|
263
|
-
break;
|
|
264
|
-
case 'webhook':
|
|
265
|
-
if (this.document.type !== 'oas') {
|
|
266
|
-
// Webhooks are an OAS 3.1 feature; current document is GraphQL —
|
|
267
|
-
// skip silently.
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runWebhookGenerator).call(this, this.document.value, generatorConfig, toIncludePaths(include, generatorConfig.id), toSkipPaths(skip, generatorConfig.id), st);
|
|
271
|
-
break;
|
|
272
|
-
case 'gqlOperation':
|
|
273
|
-
if (this.document.type !== 'gql') {
|
|
274
|
-
// Generator targets GraphQL; current document is OAS — skip silently.
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
// GraphQL operations don't yet have skip/include support
|
|
278
|
-
// at the per-operation level. The whole-generator gate
|
|
279
|
-
// above does apply (so `include: ['my-gql-gen']` works as
|
|
280
|
-
// expected), but per-(rootKind, fieldName) filtering is a
|
|
281
|
-
// follow-up that needs the same dispatch shape added for
|
|
282
|
-
// GqlOperation. Tracked alongside the existing GQL-skip
|
|
283
|
-
// gap.
|
|
284
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runGqlOperationGenerator).call(this, this.document.value, generatorConfig, st);
|
|
285
|
-
break;
|
|
286
|
-
case 'model':
|
|
287
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, this.document, generatorConfig, toIncludeModels(include, generatorConfig.id), toSkipModels(skip, generatorConfig.id), st);
|
|
288
|
-
break;
|
|
289
|
-
default: {
|
|
290
|
-
const _exhaustive = generatorConfig;
|
|
291
|
-
throw new Error(`Invalid generator type: ${JSON.stringify(_exhaustive)}`);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
262
|
+
const startedAt = performance.now();
|
|
263
|
+
const fileCountBefore = __classPrivateFieldGet(this, _GenerateContext_files, "f").size;
|
|
264
|
+
__classPrivateFieldSet(this, _GenerateContext_subjectCounts, { offered: 0, transformed: 0, failed: 0 }, "f");
|
|
265
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runGenerator).call(this, generatorConfig, st);
|
|
266
|
+
const { offered, transformed, failed } = __classPrivateFieldGet(this, _GenerateContext_subjectCounts, "f");
|
|
267
|
+
const fileCount = __classPrivateFieldGet(this, _GenerateContext_files, "f").size - fileCountBefore;
|
|
268
|
+
const milliseconds = Math.round(performance.now() - startedAt);
|
|
269
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logGeneratorLine).call(this, st, `${generatorConfig.id}: ${transformed} of ${(0, toCountPhrase_js_1.toCountPhrase)(offered, toSubjectNoun(generatorConfig))}, ` +
|
|
270
|
+
`${failed} failed, ${(0, toCountPhrase_js_1.toCountPhrase)(fileCount, 'file')}, ${milliseconds} ms`);
|
|
294
271
|
});
|
|
295
272
|
});
|
|
296
273
|
// Post-walk consumption audit: every enrichment lookup above was
|
|
@@ -371,7 +348,11 @@ class GenerateContext {
|
|
|
371
348
|
break;
|
|
372
349
|
}
|
|
373
350
|
case 'model': {
|
|
374
|
-
const models = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this).filter(refName => generatorConfig.isSupported({
|
|
351
|
+
const models = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this).filter(refName => generatorConfig.isSupported({
|
|
352
|
+
ref: (0, refFns_js_1.toSchemaComponentRef)(refName),
|
|
353
|
+
context: this,
|
|
354
|
+
variant: Variant_js_1.DEFAULT_VARIANT
|
|
355
|
+
}));
|
|
375
356
|
out[generatorConfig.id] = { type: 'model', models };
|
|
376
357
|
break;
|
|
377
358
|
}
|
|
@@ -452,10 +433,18 @@ class GenerateContext {
|
|
|
452
433
|
// `undefined` for schemas it doesn't seed.
|
|
453
434
|
const models = {};
|
|
454
435
|
for (const refName of __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this)) {
|
|
455
|
-
if (!generatorConfig.isSupported({
|
|
436
|
+
if (!generatorConfig.isSupported({
|
|
437
|
+
ref: (0, refFns_js_1.toSchemaComponentRef)(refName),
|
|
438
|
+
context: this,
|
|
439
|
+
variant: Variant_js_1.DEFAULT_VARIANT
|
|
440
|
+
})) {
|
|
456
441
|
continue;
|
|
457
442
|
}
|
|
458
|
-
const leaf = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_subjectDefaults).call(this, () => toDefaults({
|
|
443
|
+
const leaf = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_subjectDefaults).call(this, () => toDefaults({
|
|
444
|
+
ref: (0, refFns_js_1.toSchemaComponentRef)(refName),
|
|
445
|
+
context: this,
|
|
446
|
+
variant: Variant_js_1.DEFAULT_VARIANT
|
|
447
|
+
}));
|
|
459
448
|
if (leaf === undefined)
|
|
460
449
|
continue;
|
|
461
450
|
models[refName] = { [Variant_js_1.DEFAULT_VARIANT]: leaf };
|
|
@@ -667,7 +656,10 @@ class GenerateContext {
|
|
|
667
656
|
// @TODO Using mapped types would help avoid generics casting
|
|
668
657
|
return definition;
|
|
669
658
|
}
|
|
670
|
-
const cachedDefinition = this.findDefinition({
|
|
659
|
+
const cachedDefinition = this.findDefinition({
|
|
660
|
+
name: fallbackName,
|
|
661
|
+
exportPath: destinationPath
|
|
662
|
+
});
|
|
671
663
|
// @TODO add check to make sure retrieved definition
|
|
672
664
|
// used same generator and same schema #SKM-47
|
|
673
665
|
if (cachedDefinition) {
|
|
@@ -906,7 +898,7 @@ class GenerateContext {
|
|
|
906
898
|
}
|
|
907
899
|
}
|
|
908
900
|
exports.GenerateContext = GenerateContext;
|
|
909
|
-
_GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakMap(), _GenerateContext_foldedPaths = 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) {
|
|
901
|
+
_GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakMap(), _GenerateContext_foldedPaths = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_captureChannel = new WeakMap(), _GenerateContext_enrichmentAudit = new WeakMap(), _GenerateContext_currentSubjectTrail = new WeakMap(), _GenerateContext_logsGeneratorLines = new WeakMap(), _GenerateContext_subjectCounts = new WeakMap(), _GenerateContext_ejectedBySuffixedPathCache = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_reportSkippedEnrichment = function _GenerateContext_reportSkippedEnrichment(block, variant, path) {
|
|
910
902
|
if (!(0, EnrichmentAudit_js_1.hasVariantEnrichment)(block, variant))
|
|
911
903
|
return;
|
|
912
904
|
__classPrivateFieldGet(this, _GenerateContext_enrichmentAudit, "f").report({
|
|
@@ -920,8 +912,78 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
920
912
|
this.logger.error((0, SerializedError_js_1.toSerializedError)(error).message, error);
|
|
921
913
|
}, _GenerateContext_failItem = function _GenerateContext_failItem(error, stackTrail) {
|
|
922
914
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logError).call(this, error);
|
|
923
|
-
this.
|
|
915
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'error', stackTrail);
|
|
924
916
|
__classPrivateFieldGet(this, _GenerateContext_failedItems, "f").push({ trail: `${stackTrail}`, message: (0, SerializedError_js_1.toSerializedError)(error).message });
|
|
917
|
+
}, _GenerateContext_captureSubjectResult = function _GenerateContext_captureSubjectResult(result, stackTrail) {
|
|
918
|
+
this.captureCurrentResult(result, stackTrail);
|
|
919
|
+
__classPrivateFieldGet(this, _GenerateContext_subjectCounts, "f").offered += 1;
|
|
920
|
+
if (result === 'success' || result === 'error') {
|
|
921
|
+
__classPrivateFieldGet(this, _GenerateContext_subjectCounts, "f").transformed += 1;
|
|
922
|
+
}
|
|
923
|
+
if (result === 'error') {
|
|
924
|
+
__classPrivateFieldGet(this, _GenerateContext_subjectCounts, "f").failed += 1;
|
|
925
|
+
}
|
|
926
|
+
}, _GenerateContext_logGeneratorLine = function _GenerateContext_logGeneratorLine(generatorTrail, message) {
|
|
927
|
+
if (!__classPrivateFieldGet(this, _GenerateContext_logsGeneratorLines, "f")) {
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
this.withSubjectTrail(generatorTrail, () => this.logger.info(message));
|
|
931
|
+
}, _GenerateContext_runGenerator = function _GenerateContext_runGenerator(generatorConfig, st) {
|
|
932
|
+
// `include` is per-generator, not document-global. A generator
|
|
933
|
+
// with a per-operation include slice runs in allow-list mode
|
|
934
|
+
// (only the listed operations); a generator absent from
|
|
935
|
+
// `include` is unaffected and runs default-on. There is
|
|
936
|
+
// therefore no whole-generator include gate here — the slice
|
|
937
|
+
// extracted below is applied per-operation in the run* arms.
|
|
938
|
+
// (Whole-generator opt-out is `skip`. A bare-string `include`
|
|
939
|
+
// entry carries no per-operation filter and is a no-op.)
|
|
940
|
+
// skmtc#330: every object entry for this generator, merged, not only the first one.
|
|
941
|
+
const skip = toGeneratorFilter(this.settings?.skip, generatorConfig.id);
|
|
942
|
+
// Extract the per-generator include slice (if any). Same
|
|
943
|
+
// dispatch shape as skip: object entries get matched by key,
|
|
944
|
+
// string entries don't produce a per-op filter (they mean
|
|
945
|
+
// "everything from this generator is included", which is
|
|
946
|
+
// semantically equivalent to "no per-op filter" once the
|
|
947
|
+
// whole-generator gate above has admitted us).
|
|
948
|
+
const include = toGeneratorFilter(this.settings?.include, generatorConfig.id);
|
|
949
|
+
switch (generatorConfig.type) {
|
|
950
|
+
case 'oasOperation':
|
|
951
|
+
if (this.document.type !== 'oas') {
|
|
952
|
+
// Generator targets OAS; current document is GraphQL — skip silently.
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOasOperationGenerator).call(this, this.document.value, generatorConfig, toIncludePaths(include, generatorConfig.id), toSkipPaths(skip, generatorConfig.id), st);
|
|
956
|
+
break;
|
|
957
|
+
case 'webhook':
|
|
958
|
+
if (this.document.type !== 'oas') {
|
|
959
|
+
// Webhooks are an OAS 3.1 feature; current document is GraphQL —
|
|
960
|
+
// skip silently.
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runWebhookGenerator).call(this, this.document.value, generatorConfig, toIncludePaths(include, generatorConfig.id), toSkipPaths(skip, generatorConfig.id), st);
|
|
964
|
+
break;
|
|
965
|
+
case 'gqlOperation':
|
|
966
|
+
if (this.document.type !== 'gql') {
|
|
967
|
+
// Generator targets GraphQL; current document is OAS — skip silently.
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
// GraphQL operations don't yet have skip/include support
|
|
971
|
+
// at the per-operation level. The whole-generator gate
|
|
972
|
+
// above does apply (so `include: ['my-gql-gen']` works as
|
|
973
|
+
// expected), but per-(rootKind, fieldName) filtering is a
|
|
974
|
+
// follow-up that needs the same dispatch shape added for
|
|
975
|
+
// GqlOperation. Tracked alongside the existing GQL-skip
|
|
976
|
+
// gap.
|
|
977
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runGqlOperationGenerator).call(this, this.document.value, generatorConfig, st);
|
|
978
|
+
break;
|
|
979
|
+
case 'model':
|
|
980
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, this.document, generatorConfig, toIncludeModels(include, generatorConfig.id), toSkipModels(skip, generatorConfig.id), st);
|
|
981
|
+
break;
|
|
982
|
+
default: {
|
|
983
|
+
const _exhaustive = generatorConfig;
|
|
984
|
+
throw new Error(`Invalid generator type: ${JSON.stringify(_exhaustive)}`);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
925
987
|
}, _GenerateContext_schemaRefNames = function _GenerateContext_schemaRefNames() {
|
|
926
988
|
switch (this.document.type) {
|
|
927
989
|
case 'oas':
|
|
@@ -975,7 +1037,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
975
1037
|
try {
|
|
976
1038
|
if (typeof generatorConfig?.isSupported === 'function' &&
|
|
977
1039
|
!generatorConfig.isSupported({ operation, context: this, variant })) {
|
|
978
|
-
this.
|
|
1040
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
|
|
979
1041
|
return;
|
|
980
1042
|
}
|
|
981
1043
|
// Order: isSupported (capability) → include (allow) → skip
|
|
@@ -996,7 +1058,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
996
1058
|
operation.method,
|
|
997
1059
|
variant
|
|
998
1060
|
]);
|
|
999
|
-
this.
|
|
1061
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
|
|
1000
1062
|
return;
|
|
1001
1063
|
}
|
|
1002
1064
|
if (matchesPathFilter({
|
|
@@ -1011,7 +1073,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1011
1073
|
operation.method,
|
|
1012
1074
|
variant
|
|
1013
1075
|
]);
|
|
1014
|
-
this.
|
|
1076
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
|
|
1015
1077
|
return;
|
|
1016
1078
|
}
|
|
1017
1079
|
generatorConfig.transform({
|
|
@@ -1025,7 +1087,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1025
1087
|
variant
|
|
1026
1088
|
});
|
|
1027
1089
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, operation, variant }));
|
|
1028
|
-
this.
|
|
1090
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
|
|
1029
1091
|
}
|
|
1030
1092
|
catch (error) {
|
|
1031
1093
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
|
|
@@ -1056,7 +1118,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1056
1118
|
try {
|
|
1057
1119
|
if (typeof generatorConfig?.isSupported === 'function' &&
|
|
1058
1120
|
!generatorConfig.isSupported({ webhook, context: this, variant })) {
|
|
1059
|
-
this.
|
|
1121
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
|
|
1060
1122
|
return;
|
|
1061
1123
|
}
|
|
1062
1124
|
// Order: isSupported (capability) → include (allow) → skip
|
|
@@ -1076,7 +1138,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1076
1138
|
webhook.method,
|
|
1077
1139
|
variant
|
|
1078
1140
|
]);
|
|
1079
|
-
this.
|
|
1141
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
|
|
1080
1142
|
return;
|
|
1081
1143
|
}
|
|
1082
1144
|
if (matchesPathFilter({
|
|
@@ -1091,7 +1153,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1091
1153
|
webhook.method,
|
|
1092
1154
|
variant
|
|
1093
1155
|
]);
|
|
1094
|
-
this.
|
|
1156
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
|
|
1095
1157
|
return;
|
|
1096
1158
|
}
|
|
1097
1159
|
generatorConfig.transform({
|
|
@@ -1105,7 +1167,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1105
1167
|
variant
|
|
1106
1168
|
});
|
|
1107
1169
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, webhook, variant }));
|
|
1108
|
-
this.
|
|
1170
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
|
|
1109
1171
|
}
|
|
1110
1172
|
catch (error) {
|
|
1111
1173
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
|
|
@@ -1134,7 +1196,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1134
1196
|
try {
|
|
1135
1197
|
if (typeof generatorConfig.isSupported === 'function' &&
|
|
1136
1198
|
!generatorConfig.isSupported({ operation, context: this, variant })) {
|
|
1137
|
-
this.
|
|
1199
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
|
|
1138
1200
|
return;
|
|
1139
1201
|
}
|
|
1140
1202
|
generatorConfig.transform({
|
|
@@ -1148,7 +1210,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1148
1210
|
variant
|
|
1149
1211
|
});
|
|
1150
1212
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, operation, variant }));
|
|
1151
|
-
this.
|
|
1213
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
|
|
1152
1214
|
}
|
|
1153
1215
|
catch (error) {
|
|
1154
1216
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
|
|
@@ -1186,7 +1248,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1186
1248
|
try {
|
|
1187
1249
|
if (typeof generatorConfig.isSupported === 'function' &&
|
|
1188
1250
|
!generatorConfig.isSupported({ ref, context: this, variant })) {
|
|
1189
|
-
this.
|
|
1251
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
|
|
1190
1252
|
return;
|
|
1191
1253
|
}
|
|
1192
1254
|
// Order: isSupported (capability) → include (allow) → skip
|
|
@@ -1200,7 +1262,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1200
1262
|
refName,
|
|
1201
1263
|
variant
|
|
1202
1264
|
]);
|
|
1203
|
-
this.
|
|
1265
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
|
|
1204
1266
|
return;
|
|
1205
1267
|
}
|
|
1206
1268
|
if (matchesRefFilter({ refs: skip, refName, variant })) {
|
|
@@ -1209,7 +1271,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1209
1271
|
refName,
|
|
1210
1272
|
variant
|
|
1211
1273
|
]);
|
|
1212
|
-
this.
|
|
1274
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
|
|
1213
1275
|
return;
|
|
1214
1276
|
}
|
|
1215
1277
|
generatorConfig.transform({
|
|
@@ -1223,7 +1285,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1223
1285
|
variant
|
|
1224
1286
|
});
|
|
1225
1287
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, ref, variant }));
|
|
1226
|
-
this.
|
|
1288
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
|
|
1227
1289
|
}
|
|
1228
1290
|
catch (error) {
|
|
1229
1291
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
|
|
@@ -1399,13 +1461,19 @@ const mergePathsFilters = (a, b) => Object.entries(b).reduce((merged, [path, met
|
|
|
1399
1461
|
return acc;
|
|
1400
1462
|
}
|
|
1401
1463
|
const current = acc[method];
|
|
1402
|
-
return {
|
|
1464
|
+
return {
|
|
1465
|
+
...acc,
|
|
1466
|
+
[method]: current === undefined ? variants : mergeVariants(current, variants)
|
|
1467
|
+
};
|
|
1403
1468
|
}, { ...existing });
|
|
1404
1469
|
return { ...merged, [path]: combined };
|
|
1405
1470
|
}, { ...a });
|
|
1406
1471
|
const mergeModelsFilters = (a, b) => Object.entries(b).reduce((merged, [refName, variants]) => {
|
|
1407
1472
|
const current = merged[refName];
|
|
1408
|
-
return {
|
|
1473
|
+
return {
|
|
1474
|
+
...merged,
|
|
1475
|
+
[refName]: current === undefined ? variants : mergeVariants(current, variants)
|
|
1476
|
+
};
|
|
1409
1477
|
}, { ...a });
|
|
1410
1478
|
/** Two filters of one generator, merged. Filters of two shapes cannot merge: the first stays. */
|
|
1411
1479
|
const mergeFilters = (a, b) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type LevelName } from '../deps/jsr.io/@std/log/0.224.14/levels.js';
|
|
2
2
|
import type { LogRecord } from '../deps/jsr.io/@std/log/0.224.14/logger.js';
|
|
3
3
|
import { BaseHandler } from '../deps/jsr.io/@std/log/0.224.14/base_handler.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type LogLine } from '../types/LogLine.js';
|
|
5
5
|
/** Configuration options for the {@link LogLinesHandler}. */
|
|
6
6
|
export type LogLinesHandlerOptions = {
|
|
7
7
|
/** The trail of the subject being generated, or `undefined` outside one. */
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.LogLinesHandler = void 0;
|
|
16
16
|
const levels_js_1 = require("../deps/jsr.io/@std/log/0.224.14/levels.js");
|
|
17
17
|
const base_handler_js_1 = require("../deps/jsr.io/@std/log/0.224.14/base_handler.js");
|
|
18
|
+
const LogLine_js_1 = require("../types/LogLine.js");
|
|
18
19
|
const SerializedError_js_1 = require("../types/SerializedError.js");
|
|
19
20
|
/**
|
|
20
21
|
* Keeps each log record at or above its level as a {@link LogLine}, in
|
|
@@ -44,12 +45,14 @@ class LogLinesHandler extends base_handler_js_1.BaseHandler {
|
|
|
44
45
|
// Taken now: the trail object changes after the subject's callback returns.
|
|
45
46
|
const trail = __classPrivateFieldGet(this, _LogLinesHandler_toTrail, "f").call(this);
|
|
46
47
|
const error = logRecord.args.find(arg => arg instanceof Error);
|
|
48
|
+
const issueArg = logRecord.args.find(arg => arg instanceof LogLine_js_1.LogLineIssueArg);
|
|
47
49
|
__classPrivateFieldGet(this, _LogLinesHandler_lines, "f").push({
|
|
48
50
|
seq: __classPrivateFieldGet(this, _LogLinesHandler_lines, "f").length,
|
|
49
51
|
level: toLogLineLevel(logRecord.level),
|
|
50
52
|
...(trail === undefined ? {} : { trail }),
|
|
51
53
|
message: logRecord.msg,
|
|
52
54
|
...(error === undefined ? {} : { error: (0, SerializedError_js_1.toSerializedError)(error) }),
|
|
55
|
+
...(issueArg === undefined ? {} : { issue: issueArg.issue }),
|
|
53
56
|
time: logRecord.datetime.getTime()
|
|
54
57
|
});
|
|
55
58
|
}
|
|
@@ -202,6 +202,9 @@ export declare class ParseContext {
|
|
|
202
202
|
* mirrors to the logger. Both protocols' surface methods funnel
|
|
203
203
|
* here.
|
|
204
204
|
*
|
|
205
|
+
* The log line's message is `<TYPE> at <document location>: <message>`,
|
|
206
|
+
* and its `issue` field holds the issue's fields.
|
|
207
|
+
*
|
|
205
208
|
* `parent` is an optional log-time-only field — surface methods
|
|
206
209
|
* forward the surrounding object so log readers see its shape, not
|
|
207
210
|
* just the leaf address. Stringified here so the logger payload
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
12
|
};
|
|
13
|
-
var _ParseContext_instances, _ParseContext_refConsumers, _ParseContext_refErrors, _ParseContext_oasRefs, _ParseContext_refTargets, _ParseContext_refTarget, _ParseContext_keptRefs, _ParseContext_issueIdentities, _ParseContext_rootFrames, _ParseContext_removeComponent, _ParseContext_parseRefTargets, _ParseContext_inRefTarget, _ParseContext_addIssue, _ParseContext_removeConsumer, _ParseContext_removePathParameterConsumer, _ParseContext_logDependencyIssue, _ParseContext_toDocumentTrail, _ParseContext_checkRefs, _ParseContext_toRefError, _ParseContext_toLoopOf, _ParseContext_removeHolder;
|
|
13
|
+
var _ParseContext_instances, _ParseContext_refConsumers, _ParseContext_refErrors, _ParseContext_oasRefs, _ParseContext_refTargets, _ParseContext_refTarget, _ParseContext_keptRefs, _ParseContext_issueIdentities, _ParseContext_rootFrames, _ParseContext_removeComponent, _ParseContext_parseRefTargets, _ParseContext_inRefTarget, _ParseContext_addIssue, _ParseContext_removeConsumer, _ParseContext_removePathParameterConsumer, _ParseContext_logDependencyIssue, _ParseContext_toDocumentLocation, _ParseContext_toDocumentTrail, _ParseContext_checkRefs, _ParseContext_toRefError, _ParseContext_toLoopOf, _ParseContext_removeHolder;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ParseContext = void 0;
|
|
16
16
|
/**
|
|
@@ -45,6 +45,7 @@ const isPlainObject_js_1 = require("../parse/isPlainObject.js");
|
|
|
45
45
|
const keptRefs_js_1 = require("../parse/keptRefs.js");
|
|
46
46
|
const pathParameters_js_1 = require("../parse/pathParameters.js");
|
|
47
47
|
const SerializedError_js_1 = require("../types/SerializedError.js");
|
|
48
|
+
const LogLine_js_1 = require("../types/LogLine.js");
|
|
48
49
|
const tryParseAt_js_1 = require("./tryParseAt.js");
|
|
49
50
|
const DanglingRefError_js_1 = require("../oas/ref/DanglingRefError.js");
|
|
50
51
|
const refFns_js_1 = require("../helpers/refFns.js");
|
|
@@ -62,7 +63,9 @@ const toRefTargetV3_js_3 = require("../parse/v3-2/ref/toRefTargetV3.js");
|
|
|
62
63
|
*/
|
|
63
64
|
const toRefKey = ({ refName, refPath }) => {
|
|
64
65
|
const bucket = (0, refFns_js_1.toRefPathBucket)(refPath);
|
|
65
|
-
return bucket === undefined
|
|
66
|
+
return bucket === undefined
|
|
67
|
+
? (0, refFns_js_1.toRefPointer)({ refName, refPath })
|
|
68
|
+
: `#/components/${bucket}/${refName}`;
|
|
66
69
|
};
|
|
67
70
|
/** The issue logged when a ref target's parser throws. */
|
|
68
71
|
const toInvalidType = (refType) => {
|
|
@@ -506,6 +509,9 @@ class ParseContext {
|
|
|
506
509
|
* mirrors to the logger. Both protocols' surface methods funnel
|
|
507
510
|
* here.
|
|
508
511
|
*
|
|
512
|
+
* The log line's message is `<TYPE> at <document location>: <message>`,
|
|
513
|
+
* and its `issue` field holds the issue's fields.
|
|
514
|
+
*
|
|
509
515
|
* `parent` is an optional log-time-only field — surface methods
|
|
510
516
|
* forward the surrounding object so log readers see its shape, not
|
|
511
517
|
* just the leaf address. Stringified here so the logger payload
|
|
@@ -517,25 +523,24 @@ class ParseContext {
|
|
|
517
523
|
logIssueAt(issue, parent) {
|
|
518
524
|
const added = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_addIssue).call(this, toParseIssue(issue));
|
|
519
525
|
if (added && !this.silent) {
|
|
520
|
-
const
|
|
521
|
-
|
|
526
|
+
const message = `${issue.type} at ${__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentLocation).call(this, issue)}: ${issue.message}`;
|
|
527
|
+
const issueArg = new LogLine_js_1.LogLineIssueArg({
|
|
528
|
+
type: issue.type,
|
|
522
529
|
level: issue.level,
|
|
523
530
|
location: issue.location,
|
|
524
|
-
message: issue.message,
|
|
525
|
-
type: issue.type,
|
|
526
531
|
...(parent === undefined ? {} : { parent: JSON.stringify(parent) })
|
|
527
|
-
};
|
|
532
|
+
});
|
|
528
533
|
// Each issue is logged at its own level, so a log threshold above
|
|
529
534
|
// DEBUG leaves `debug` issues out.
|
|
530
535
|
switch (issue.level) {
|
|
531
536
|
case 'error':
|
|
532
|
-
this.logger.error(
|
|
537
|
+
this.logger.error(message, issueArg);
|
|
533
538
|
break;
|
|
534
539
|
case 'warning':
|
|
535
|
-
this.logger.warn(
|
|
540
|
+
this.logger.warn(message, issueArg);
|
|
536
541
|
break;
|
|
537
542
|
case 'debug':
|
|
538
|
-
this.logger.debug(
|
|
543
|
+
this.logger.debug(message, issueArg);
|
|
539
544
|
break;
|
|
540
545
|
default: {
|
|
541
546
|
const _exhaustive = issue;
|
|
@@ -671,7 +676,9 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
671
676
|
const key = toRefKey(ref);
|
|
672
677
|
// A ref to a component, of its own kind or not, is resolved in
|
|
673
678
|
// `components`; `#checkRefs` reports one of the wrong kind.
|
|
674
|
-
if (ref.refName === '' ||
|
|
679
|
+
if (ref.refName === '' ||
|
|
680
|
+
(0, refFns_js_1.toRefPathBucket)(ref.refPath) !== undefined ||
|
|
681
|
+
__classPrivateFieldGet(this, _ParseContext_refTargets, "f").has(key)) {
|
|
675
682
|
continue;
|
|
676
683
|
}
|
|
677
684
|
const value = (0, refFns_js_1.toRawRefTarget)(documentObject, ref);
|
|
@@ -686,7 +693,13 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
686
693
|
context: this,
|
|
687
694
|
type: toInvalidType(ref.refType),
|
|
688
695
|
parent: value,
|
|
689
|
-
fn: () => toRefTarget({
|
|
696
|
+
fn: () => toRefTarget({
|
|
697
|
+
refType: ref.refType,
|
|
698
|
+
name: ref.refName,
|
|
699
|
+
value,
|
|
700
|
+
stackTrail: parent,
|
|
701
|
+
context: this
|
|
702
|
+
})
|
|
690
703
|
}));
|
|
691
704
|
if (target !== undefined) {
|
|
692
705
|
oasDocument.setRefTarget(key, target);
|
|
@@ -803,6 +816,9 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
803
816
|
throw new Error(`Unhandled protocol type: ${JSON.stringify(_exhaustive)}`);
|
|
804
817
|
}
|
|
805
818
|
}
|
|
819
|
+
}, _ParseContext_toDocumentLocation = function _ParseContext_toDocumentLocation({ protocol, location }) {
|
|
820
|
+
const documentTrail = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, StackTrail_js_1.StackTrail.fromString(location));
|
|
821
|
+
return protocol === 'oas' ? documentTrail.toJsonPointer() : documentTrail.stackTrail.join('.');
|
|
806
822
|
}, _ParseContext_toDocumentTrail = function _ParseContext_toDocumentTrail(stackTrail) {
|
|
807
823
|
const frames = stackTrail.stackTrail;
|
|
808
824
|
const rootFrames = __classPrivateFieldGet(this, _ParseContext_rootFrames, "f");
|
|
@@ -857,7 +873,9 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
857
873
|
return error;
|
|
858
874
|
}
|
|
859
875
|
const loop = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toLoopOf).call(this, ref);
|
|
860
|
-
return loop === undefined
|
|
876
|
+
return loop === undefined
|
|
877
|
+
? undefined
|
|
878
|
+
: new DanglingRefError_js_1.DanglingRefError(ref.$ref, { loop: loop.map(({ $ref }) => $ref) });
|
|
861
879
|
}, _ParseContext_toLoopOf = function _ParseContext_toLoopOf(ref) {
|
|
862
880
|
try {
|
|
863
881
|
const loop = ref.toLoop();
|
|
@@ -883,5 +901,9 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
883
901
|
const location = consumer.toString();
|
|
884
902
|
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeConsumer).call(this, consumer, documentTrail)
|
|
885
903
|
.filter(removed => removed !== location)
|
|
886
|
-
.forEach(removed => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDependencyIssue).call(this, {
|
|
904
|
+
.forEach(removed => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDependencyIssue).call(this, {
|
|
905
|
+
location: removed,
|
|
906
|
+
refKey: ref.$ref,
|
|
907
|
+
rootCause: { error, location }
|
|
908
|
+
}));
|
|
887
909
|
};
|
|
@@ -92,7 +92,13 @@ _ResultsLog_results = new WeakMap(), _ResultsLog_instances = new WeakSet(), _Res
|
|
|
92
92
|
};
|
|
93
93
|
/** Writes an own, enumerable property, even for keys such as `__proto__`. */
|
|
94
94
|
const defineOwn = (node, key, value) => {
|
|
95
|
-
|
|
95
|
+
// An assignment to `__proto__` would set the prototype, so that key is defined.
|
|
96
|
+
if (key === '__proto__') {
|
|
97
|
+
Object.defineProperty(node, key, { value, enumerable: true, writable: true, configurable: true });
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
node[key] = value;
|
|
101
|
+
}
|
|
96
102
|
};
|
|
97
103
|
/**
|
|
98
104
|
* Severity of each result type. A higher number replaces a lower one
|