@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.
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  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");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- 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;
12
+ 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;
13
13
  import { applyGeneratedSuffixToWorkspacePath, normalizeWorkspacePath } from '../helpers/normalizeWorkspacePath.js';
14
14
  import { getByWorkspacePath } from '../helpers/getByWorkspacePath.js';
15
15
  import { DEFAULT_GENERATED_SUFFIX } from '../helpers/applyGeneratedSuffix.js';
@@ -32,10 +32,27 @@ import { isDefinitionContainer } from '../dsl/DefinitionContainer.js';
32
32
  import { JsonFile } from '../dsl/JsonFile.js';
33
33
  import { MarkdownFile } from '../dsl/MarkdownFile.js';
34
34
  import invariant from 'tiny-invariant';
35
+ import { toCountPhrase } from '../helpers/toCountPhrase.js';
35
36
  import { EnrichmentAudit, hasVariantEnrichment } from '../enrichments/EnrichmentAudit.js';
36
37
  import { toSerializedError } from '../types/SerializedError.js';
37
38
  import { GenerationFailure } from './toGenerationFailure.js';
38
39
  import { formatEnrichmentPath } from '../enrichments/EnrichmentWarning.js';
40
+ /** What one of a generator's subjects is called on its log line. */
41
+ const toSubjectNoun = ({ type }) => {
42
+ switch (type) {
43
+ case 'oasOperation':
44
+ case 'gqlOperation':
45
+ return 'operation';
46
+ case 'webhook':
47
+ return 'webhook';
48
+ case 'model':
49
+ return 'model';
50
+ default: {
51
+ const _exhaustive = type;
52
+ throw new Error(`Invalid generator type: ${JSON.stringify(_exhaustive)}`);
53
+ }
54
+ }
55
+ };
39
56
  /**
40
57
  * The generation context for the second phase of the SKMTC transformation pipeline.
41
58
  *
@@ -85,7 +102,7 @@ const isGqlToOperationSettingsFields = (args) => args.operation.oasType === 'gql
85
102
  * (`{ fields, title, … }`). Narrows `unknown` without an `as` cast. */
86
103
  const isEnrichmentLeaf = (value) => typeof value === 'object' && value !== null;
87
104
  export class GenerateContext {
88
- constructor({ document, settings, logger, captureCurrentResult, toGeneratorConfigMap, captureChannel }) {
105
+ constructor({ document, settings, logger, captureCurrentResult, toGeneratorConfigMap, captureChannel, logsGeneratorLines = false }) {
89
106
  _GenerateContext_instances.add(this);
90
107
  _GenerateContext_files.set(this, void 0);
91
108
  /** Each subject whose generation threw: its trail and the error message. */
@@ -155,8 +172,13 @@ export class GenerateContext {
155
172
  _GenerateContext_enrichmentAudit.set(this, void 0);
156
173
  /** See {@link currentSubjectTrail}. */
157
174
  _GenerateContext_currentSubjectTrail.set(this, void 0);
175
+ /** Whether each generator logs a line after it ran. */
176
+ _GenerateContext_logsGeneratorLines.set(this, void 0);
177
+ /** The counts of the generator {@link toArtifacts} is running. */
178
+ _GenerateContext_subjectCounts.set(this, { offered: 0, transformed: 0, failed: 0 });
158
179
  _GenerateContext_ejectedBySuffixedPathCache.set(this, void 0);
159
180
  this.logger = logger;
181
+ __classPrivateFieldSet(this, _GenerateContext_logsGeneratorLines, logsGeneratorLines, "f");
160
182
  __classPrivateFieldSet(this, _GenerateContext_files, new Map(), "f");
161
183
  __classPrivateFieldSet(this, _GenerateContext_previews, {}, "f");
162
184
  this.document = document;
@@ -225,66 +247,21 @@ export class GenerateContext {
225
247
  const generators = Object.values(this.toGeneratorConfigMap());
226
248
  generators.forEach(generatorConfig => {
227
249
  stackTrail.trace(generatorConfig.id, st => {
228
- // Whole-generator skip (string entry in `skip`). Silent no-op:
229
- // no per-operation `skipped` results emitted.
250
+ // Whole-generator skip (string entry in `skip`). No per-operation
251
+ // `skipped` results emitted.
230
252
  if (this.settings?.skip?.includes(generatorConfig.id)) {
253
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logGeneratorLine).call(this, st, `${generatorConfig.id}: skipped by settings.skip`);
231
254
  return;
232
255
  }
233
- // `include` is per-generator, not document-global. A generator
234
- // with a per-operation include slice runs in allow-list mode
235
- // (only the listed operations); a generator absent from
236
- // `include` is unaffected and runs default-on. There is
237
- // therefore no whole-generator include gate here — the slice
238
- // extracted below is applied per-operation in the run* arms.
239
- // (Whole-generator opt-out is `skip`. A bare-string `include`
240
- // entry carries no per-operation filter and is a no-op.)
241
- // skmtc#330: every object entry for this generator, merged, not only the first one.
242
- const skip = toGeneratorFilter(this.settings?.skip, generatorConfig.id);
243
- // Extract the per-generator include slice (if any). Same
244
- // dispatch shape as skip: object entries get matched by key,
245
- // string entries don't produce a per-op filter (they mean
246
- // "everything from this generator is included", which is
247
- // semantically equivalent to "no per-op filter" once the
248
- // whole-generator gate above has admitted us).
249
- const include = toGeneratorFilter(this.settings?.include, generatorConfig.id);
250
- switch (generatorConfig.type) {
251
- case 'oasOperation':
252
- if (this.document.type !== 'oas') {
253
- // Generator targets OAS; current document is GraphQL — skip silently.
254
- return;
255
- }
256
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOasOperationGenerator).call(this, this.document.value, generatorConfig, toIncludePaths(include, generatorConfig.id), toSkipPaths(skip, generatorConfig.id), st);
257
- break;
258
- case 'webhook':
259
- if (this.document.type !== 'oas') {
260
- // Webhooks are an OAS 3.1 feature; current document is GraphQL —
261
- // skip silently.
262
- return;
263
- }
264
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runWebhookGenerator).call(this, this.document.value, generatorConfig, toIncludePaths(include, generatorConfig.id), toSkipPaths(skip, generatorConfig.id), st);
265
- break;
266
- case 'gqlOperation':
267
- if (this.document.type !== 'gql') {
268
- // Generator targets GraphQL; current document is OAS — skip silently.
269
- return;
270
- }
271
- // GraphQL operations don't yet have skip/include support
272
- // at the per-operation level. The whole-generator gate
273
- // above does apply (so `include: ['my-gql-gen']` works as
274
- // expected), but per-(rootKind, fieldName) filtering is a
275
- // follow-up that needs the same dispatch shape added for
276
- // GqlOperation. Tracked alongside the existing GQL-skip
277
- // gap.
278
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runGqlOperationGenerator).call(this, this.document.value, generatorConfig, st);
279
- break;
280
- case 'model':
281
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, this.document, generatorConfig, toIncludeModels(include, generatorConfig.id), toSkipModels(skip, generatorConfig.id), st);
282
- break;
283
- default: {
284
- const _exhaustive = generatorConfig;
285
- throw new Error(`Invalid generator type: ${JSON.stringify(_exhaustive)}`);
286
- }
287
- }
256
+ const startedAt = performance.now();
257
+ const fileCountBefore = __classPrivateFieldGet(this, _GenerateContext_files, "f").size;
258
+ __classPrivateFieldSet(this, _GenerateContext_subjectCounts, { offered: 0, transformed: 0, failed: 0 }, "f");
259
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runGenerator).call(this, generatorConfig, st);
260
+ const { offered, transformed, failed } = __classPrivateFieldGet(this, _GenerateContext_subjectCounts, "f");
261
+ const fileCount = __classPrivateFieldGet(this, _GenerateContext_files, "f").size - fileCountBefore;
262
+ const milliseconds = Math.round(performance.now() - startedAt);
263
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logGeneratorLine).call(this, st, `${generatorConfig.id}: ${transformed} of ${toCountPhrase(offered, toSubjectNoun(generatorConfig))}, ` +
264
+ `${failed} failed, ${toCountPhrase(fileCount, 'file')}, ${milliseconds} ms`);
288
265
  });
289
266
  });
290
267
  // Post-walk consumption audit: every enrichment lookup above was
@@ -365,7 +342,11 @@ export class GenerateContext {
365
342
  break;
366
343
  }
367
344
  case 'model': {
368
- const models = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this).filter(refName => generatorConfig.isSupported({ ref: toSchemaComponentRef(refName), context: this, variant: DEFAULT_VARIANT }));
345
+ const models = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this).filter(refName => generatorConfig.isSupported({
346
+ ref: toSchemaComponentRef(refName),
347
+ context: this,
348
+ variant: DEFAULT_VARIANT
349
+ }));
369
350
  out[generatorConfig.id] = { type: 'model', models };
370
351
  break;
371
352
  }
@@ -446,10 +427,18 @@ export class GenerateContext {
446
427
  // `undefined` for schemas it doesn't seed.
447
428
  const models = {};
448
429
  for (const refName of __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this)) {
449
- if (!generatorConfig.isSupported({ ref: toSchemaComponentRef(refName), context: this, variant: DEFAULT_VARIANT })) {
430
+ if (!generatorConfig.isSupported({
431
+ ref: toSchemaComponentRef(refName),
432
+ context: this,
433
+ variant: DEFAULT_VARIANT
434
+ })) {
450
435
  continue;
451
436
  }
452
- const leaf = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_subjectDefaults).call(this, () => toDefaults({ ref: toSchemaComponentRef(refName), context: this, variant: DEFAULT_VARIANT }));
437
+ const leaf = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_subjectDefaults).call(this, () => toDefaults({
438
+ ref: toSchemaComponentRef(refName),
439
+ context: this,
440
+ variant: DEFAULT_VARIANT
441
+ }));
453
442
  if (leaf === undefined)
454
443
  continue;
455
444
  models[refName] = { [DEFAULT_VARIANT]: leaf };
@@ -661,7 +650,10 @@ export class GenerateContext {
661
650
  // @TODO Using mapped types would help avoid generics casting
662
651
  return definition;
663
652
  }
664
- const cachedDefinition = this.findDefinition({ name: fallbackName, exportPath: destinationPath });
653
+ const cachedDefinition = this.findDefinition({
654
+ name: fallbackName,
655
+ exportPath: destinationPath
656
+ });
665
657
  // @TODO add check to make sure retrieved definition
666
658
  // used same generator and same schema #SKM-47
667
659
  if (cachedDefinition) {
@@ -899,7 +891,7 @@ export class GenerateContext {
899
891
  return place?.findDefinitions({ name })?.[0];
900
892
  }
901
893
  }
902
- _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) {
894
+ _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) {
903
895
  if (!hasVariantEnrichment(block, variant))
904
896
  return;
905
897
  __classPrivateFieldGet(this, _GenerateContext_enrichmentAudit, "f").report({
@@ -913,8 +905,78 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
913
905
  this.logger.error(toSerializedError(error).message, error);
914
906
  }, _GenerateContext_failItem = function _GenerateContext_failItem(error, stackTrail) {
915
907
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logError).call(this, error);
916
- this.captureCurrentResult('error', stackTrail);
908
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'error', stackTrail);
917
909
  __classPrivateFieldGet(this, _GenerateContext_failedItems, "f").push({ trail: `${stackTrail}`, message: toSerializedError(error).message });
910
+ }, _GenerateContext_captureSubjectResult = function _GenerateContext_captureSubjectResult(result, stackTrail) {
911
+ this.captureCurrentResult(result, stackTrail);
912
+ __classPrivateFieldGet(this, _GenerateContext_subjectCounts, "f").offered += 1;
913
+ if (result === 'success' || result === 'error') {
914
+ __classPrivateFieldGet(this, _GenerateContext_subjectCounts, "f").transformed += 1;
915
+ }
916
+ if (result === 'error') {
917
+ __classPrivateFieldGet(this, _GenerateContext_subjectCounts, "f").failed += 1;
918
+ }
919
+ }, _GenerateContext_logGeneratorLine = function _GenerateContext_logGeneratorLine(generatorTrail, message) {
920
+ if (!__classPrivateFieldGet(this, _GenerateContext_logsGeneratorLines, "f")) {
921
+ return;
922
+ }
923
+ this.withSubjectTrail(generatorTrail, () => this.logger.info(message));
924
+ }, _GenerateContext_runGenerator = function _GenerateContext_runGenerator(generatorConfig, st) {
925
+ // `include` is per-generator, not document-global. A generator
926
+ // with a per-operation include slice runs in allow-list mode
927
+ // (only the listed operations); a generator absent from
928
+ // `include` is unaffected and runs default-on. There is
929
+ // therefore no whole-generator include gate here — the slice
930
+ // extracted below is applied per-operation in the run* arms.
931
+ // (Whole-generator opt-out is `skip`. A bare-string `include`
932
+ // entry carries no per-operation filter and is a no-op.)
933
+ // skmtc#330: every object entry for this generator, merged, not only the first one.
934
+ const skip = toGeneratorFilter(this.settings?.skip, generatorConfig.id);
935
+ // Extract the per-generator include slice (if any). Same
936
+ // dispatch shape as skip: object entries get matched by key,
937
+ // string entries don't produce a per-op filter (they mean
938
+ // "everything from this generator is included", which is
939
+ // semantically equivalent to "no per-op filter" once the
940
+ // whole-generator gate above has admitted us).
941
+ const include = toGeneratorFilter(this.settings?.include, generatorConfig.id);
942
+ switch (generatorConfig.type) {
943
+ case 'oasOperation':
944
+ if (this.document.type !== 'oas') {
945
+ // Generator targets OAS; current document is GraphQL — skip silently.
946
+ return;
947
+ }
948
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOasOperationGenerator).call(this, this.document.value, generatorConfig, toIncludePaths(include, generatorConfig.id), toSkipPaths(skip, generatorConfig.id), st);
949
+ break;
950
+ case 'webhook':
951
+ if (this.document.type !== 'oas') {
952
+ // Webhooks are an OAS 3.1 feature; current document is GraphQL —
953
+ // skip silently.
954
+ return;
955
+ }
956
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runWebhookGenerator).call(this, this.document.value, generatorConfig, toIncludePaths(include, generatorConfig.id), toSkipPaths(skip, generatorConfig.id), st);
957
+ break;
958
+ case 'gqlOperation':
959
+ if (this.document.type !== 'gql') {
960
+ // Generator targets GraphQL; current document is OAS — skip silently.
961
+ return;
962
+ }
963
+ // GraphQL operations don't yet have skip/include support
964
+ // at the per-operation level. The whole-generator gate
965
+ // above does apply (so `include: ['my-gql-gen']` works as
966
+ // expected), but per-(rootKind, fieldName) filtering is a
967
+ // follow-up that needs the same dispatch shape added for
968
+ // GqlOperation. Tracked alongside the existing GQL-skip
969
+ // gap.
970
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runGqlOperationGenerator).call(this, this.document.value, generatorConfig, st);
971
+ break;
972
+ case 'model':
973
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, this.document, generatorConfig, toIncludeModels(include, generatorConfig.id), toSkipModels(skip, generatorConfig.id), st);
974
+ break;
975
+ default: {
976
+ const _exhaustive = generatorConfig;
977
+ throw new Error(`Invalid generator type: ${JSON.stringify(_exhaustive)}`);
978
+ }
979
+ }
918
980
  }, _GenerateContext_schemaRefNames = function _GenerateContext_schemaRefNames() {
919
981
  switch (this.document.type) {
920
982
  case 'oas':
@@ -968,7 +1030,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
968
1030
  try {
969
1031
  if (typeof generatorConfig?.isSupported === 'function' &&
970
1032
  !generatorConfig.isSupported({ operation, context: this, variant })) {
971
- this.captureCurrentResult('notSupported', st);
1033
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
972
1034
  return;
973
1035
  }
974
1036
  // Order: isSupported (capability) → include (allow) → skip
@@ -989,7 +1051,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
989
1051
  operation.method,
990
1052
  variant
991
1053
  ]);
992
- this.captureCurrentResult('skipped', st);
1054
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
993
1055
  return;
994
1056
  }
995
1057
  if (matchesPathFilter({
@@ -1004,7 +1066,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1004
1066
  operation.method,
1005
1067
  variant
1006
1068
  ]);
1007
- this.captureCurrentResult('skipped', st);
1069
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
1008
1070
  return;
1009
1071
  }
1010
1072
  generatorConfig.transform({
@@ -1018,7 +1080,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1018
1080
  variant
1019
1081
  });
1020
1082
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, operation, variant }));
1021
- this.captureCurrentResult('success', st);
1083
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
1022
1084
  }
1023
1085
  catch (error) {
1024
1086
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
@@ -1049,7 +1111,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1049
1111
  try {
1050
1112
  if (typeof generatorConfig?.isSupported === 'function' &&
1051
1113
  !generatorConfig.isSupported({ webhook, context: this, variant })) {
1052
- this.captureCurrentResult('notSupported', st);
1114
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
1053
1115
  return;
1054
1116
  }
1055
1117
  // Order: isSupported (capability) → include (allow) → skip
@@ -1069,7 +1131,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1069
1131
  webhook.method,
1070
1132
  variant
1071
1133
  ]);
1072
- this.captureCurrentResult('skipped', st);
1134
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
1073
1135
  return;
1074
1136
  }
1075
1137
  if (matchesPathFilter({
@@ -1084,7 +1146,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1084
1146
  webhook.method,
1085
1147
  variant
1086
1148
  ]);
1087
- this.captureCurrentResult('skipped', st);
1149
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
1088
1150
  return;
1089
1151
  }
1090
1152
  generatorConfig.transform({
@@ -1098,7 +1160,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1098
1160
  variant
1099
1161
  });
1100
1162
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, webhook, variant }));
1101
- this.captureCurrentResult('success', st);
1163
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
1102
1164
  }
1103
1165
  catch (error) {
1104
1166
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
@@ -1127,7 +1189,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1127
1189
  try {
1128
1190
  if (typeof generatorConfig.isSupported === 'function' &&
1129
1191
  !generatorConfig.isSupported({ operation, context: this, variant })) {
1130
- this.captureCurrentResult('notSupported', st);
1192
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
1131
1193
  return;
1132
1194
  }
1133
1195
  generatorConfig.transform({
@@ -1141,7 +1203,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1141
1203
  variant
1142
1204
  });
1143
1205
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, operation, variant }));
1144
- this.captureCurrentResult('success', st);
1206
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
1145
1207
  }
1146
1208
  catch (error) {
1147
1209
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
@@ -1179,7 +1241,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1179
1241
  try {
1180
1242
  if (typeof generatorConfig.isSupported === 'function' &&
1181
1243
  !generatorConfig.isSupported({ ref, context: this, variant })) {
1182
- this.captureCurrentResult('notSupported', st);
1244
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
1183
1245
  return;
1184
1246
  }
1185
1247
  // Order: isSupported (capability) → include (allow) → skip
@@ -1193,7 +1255,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1193
1255
  refName,
1194
1256
  variant
1195
1257
  ]);
1196
- this.captureCurrentResult('skipped', st);
1258
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
1197
1259
  return;
1198
1260
  }
1199
1261
  if (matchesRefFilter({ refs: skip, refName, variant })) {
@@ -1202,7 +1264,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1202
1264
  refName,
1203
1265
  variant
1204
1266
  ]);
1205
- this.captureCurrentResult('skipped', st);
1267
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
1206
1268
  return;
1207
1269
  }
1208
1270
  generatorConfig.transform({
@@ -1216,7 +1278,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1216
1278
  variant
1217
1279
  });
1218
1280
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, ref, variant }));
1219
- this.captureCurrentResult('success', st);
1281
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
1220
1282
  }
1221
1283
  catch (error) {
1222
1284
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
@@ -1388,13 +1450,19 @@ const mergePathsFilters = (a, b) => Object.entries(b).reduce((merged, [path, met
1388
1450
  return acc;
1389
1451
  }
1390
1452
  const current = acc[method];
1391
- return { ...acc, [method]: current === undefined ? variants : mergeVariants(current, variants) };
1453
+ return {
1454
+ ...acc,
1455
+ [method]: current === undefined ? variants : mergeVariants(current, variants)
1456
+ };
1392
1457
  }, { ...existing });
1393
1458
  return { ...merged, [path]: combined };
1394
1459
  }, { ...a });
1395
1460
  const mergeModelsFilters = (a, b) => Object.entries(b).reduce((merged, [refName, variants]) => {
1396
1461
  const current = merged[refName];
1397
- return { ...merged, [refName]: current === undefined ? variants : mergeVariants(current, variants) };
1462
+ return {
1463
+ ...merged,
1464
+ [refName]: current === undefined ? variants : mergeVariants(current, variants)
1465
+ };
1398
1466
  }, { ...a });
1399
1467
  /** Two filters of one generator, merged. Filters of two shapes cannot merge: the first stays. */
1400
1468
  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 { LogLine } from '../types/LogLine.js';
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. */
@@ -12,6 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12
12
  var _LogLinesHandler_toTrail, _LogLinesHandler_lines;
13
13
  import { LogLevels } from '../deps/jsr.io/@std/log/0.224.14/levels.js';
14
14
  import { BaseHandler } from '../deps/jsr.io/@std/log/0.224.14/base_handler.js';
15
+ import { LogLineIssueArg } from '../types/LogLine.js';
15
16
  import { toSerializedError } from '../types/SerializedError.js';
16
17
  /**
17
18
  * Keeps each log record at or above its level as a {@link LogLine}, in
@@ -41,12 +42,14 @@ export class LogLinesHandler extends BaseHandler {
41
42
  // Taken now: the trail object changes after the subject's callback returns.
42
43
  const trail = __classPrivateFieldGet(this, _LogLinesHandler_toTrail, "f").call(this);
43
44
  const error = logRecord.args.find(arg => arg instanceof Error);
45
+ const issueArg = logRecord.args.find(arg => arg instanceof LogLineIssueArg);
44
46
  __classPrivateFieldGet(this, _LogLinesHandler_lines, "f").push({
45
47
  seq: __classPrivateFieldGet(this, _LogLinesHandler_lines, "f").length,
46
48
  level: toLogLineLevel(logRecord.level),
47
49
  ...(trail === undefined ? {} : { trail }),
48
50
  message: logRecord.msg,
49
51
  ...(error === undefined ? {} : { error: toSerializedError(error) }),
52
+ ...(issueArg === undefined ? {} : { issue: issueArg.issue }),
50
53
  time: logRecord.datetime.getTime()
51
54
  });
52
55
  }
@@ -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
@@ -9,7 +9,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
9
9
  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");
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
- 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;
12
+ 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;
13
13
  /**
14
14
  * Unified parse context for both OAS and GraphQL inputs.
15
15
  *
@@ -42,6 +42,7 @@ import { isPlainObject } from '../parse/isPlainObject.js';
42
42
  import { toKeptRefs } from '../parse/keptRefs.js';
43
43
  import { toApplyingBrokenParameter, toNameAndIn } from '../parse/pathParameters.js';
44
44
  import { toSerializedError } from '../types/SerializedError.js';
45
+ import { LogLineIssueArg } from '../types/LogLine.js';
45
46
  import { tryParseAt } from './tryParseAt.js';
46
47
  import { DanglingRefError } from '../oas/ref/DanglingRefError.js';
47
48
  import { toRawRefTarget, toRefParts, toRefPathBucket, toRefPathSegments, toRefPointer } from '../helpers/refFns.js';
@@ -59,7 +60,9 @@ import { toRefTargetV3 as toRefTargetV32 } from '../parse/v3-2/ref/toRefTargetV3
59
60
  */
60
61
  const toRefKey = ({ refName, refPath }) => {
61
62
  const bucket = toRefPathBucket(refPath);
62
- return bucket === undefined ? toRefPointer({ refName, refPath }) : `#/components/${bucket}/${refName}`;
63
+ return bucket === undefined
64
+ ? toRefPointer({ refName, refPath })
65
+ : `#/components/${bucket}/${refName}`;
63
66
  };
64
67
  /** The issue logged when a ref target's parser throws. */
65
68
  const toInvalidType = (refType) => {
@@ -503,6 +506,9 @@ export class ParseContext {
503
506
  * mirrors to the logger. Both protocols' surface methods funnel
504
507
  * here.
505
508
  *
509
+ * The log line's message is `<TYPE> at <document location>: <message>`,
510
+ * and its `issue` field holds the issue's fields.
511
+ *
506
512
  * `parent` is an optional log-time-only field — surface methods
507
513
  * forward the surrounding object so log readers see its shape, not
508
514
  * just the leaf address. Stringified here so the logger payload
@@ -514,25 +520,24 @@ export class ParseContext {
514
520
  logIssueAt(issue, parent) {
515
521
  const added = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_addIssue).call(this, toParseIssue(issue));
516
522
  if (added && !this.silent) {
517
- const payload = {
518
- protocol: issue.protocol,
523
+ const message = `${issue.type} at ${__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentLocation).call(this, issue)}: ${issue.message}`;
524
+ const issueArg = new LogLineIssueArg({
525
+ type: issue.type,
519
526
  level: issue.level,
520
527
  location: issue.location,
521
- message: issue.message,
522
- type: issue.type,
523
528
  ...(parent === undefined ? {} : { parent: JSON.stringify(parent) })
524
- };
529
+ });
525
530
  // Each issue is logged at its own level, so a log threshold above
526
531
  // DEBUG leaves `debug` issues out.
527
532
  switch (issue.level) {
528
533
  case 'error':
529
- this.logger.error(payload);
534
+ this.logger.error(message, issueArg);
530
535
  break;
531
536
  case 'warning':
532
- this.logger.warn(payload);
537
+ this.logger.warn(message, issueArg);
533
538
  break;
534
539
  case 'debug':
535
- this.logger.debug(payload);
540
+ this.logger.debug(message, issueArg);
536
541
  break;
537
542
  default: {
538
543
  const _exhaustive = issue;
@@ -667,7 +672,9 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
667
672
  const key = toRefKey(ref);
668
673
  // A ref to a component, of its own kind or not, is resolved in
669
674
  // `components`; `#checkRefs` reports one of the wrong kind.
670
- if (ref.refName === '' || toRefPathBucket(ref.refPath) !== undefined || __classPrivateFieldGet(this, _ParseContext_refTargets, "f").has(key)) {
675
+ if (ref.refName === '' ||
676
+ toRefPathBucket(ref.refPath) !== undefined ||
677
+ __classPrivateFieldGet(this, _ParseContext_refTargets, "f").has(key)) {
671
678
  continue;
672
679
  }
673
680
  const value = toRawRefTarget(documentObject, ref);
@@ -682,7 +689,13 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
682
689
  context: this,
683
690
  type: toInvalidType(ref.refType),
684
691
  parent: value,
685
- fn: () => toRefTarget({ refType: ref.refType, name: ref.refName, value, stackTrail: parent, context: this })
692
+ fn: () => toRefTarget({
693
+ refType: ref.refType,
694
+ name: ref.refName,
695
+ value,
696
+ stackTrail: parent,
697
+ context: this
698
+ })
686
699
  }));
687
700
  if (target !== undefined) {
688
701
  oasDocument.setRefTarget(key, target);
@@ -799,6 +812,9 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
799
812
  throw new Error(`Unhandled protocol type: ${JSON.stringify(_exhaustive)}`);
800
813
  }
801
814
  }
815
+ }, _ParseContext_toDocumentLocation = function _ParseContext_toDocumentLocation({ protocol, location }) {
816
+ const documentTrail = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, StackTrail.fromString(location));
817
+ return protocol === 'oas' ? documentTrail.toJsonPointer() : documentTrail.stackTrail.join('.');
802
818
  }, _ParseContext_toDocumentTrail = function _ParseContext_toDocumentTrail(stackTrail) {
803
819
  const frames = stackTrail.stackTrail;
804
820
  const rootFrames = __classPrivateFieldGet(this, _ParseContext_rootFrames, "f");
@@ -853,7 +869,9 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
853
869
  return error;
854
870
  }
855
871
  const loop = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toLoopOf).call(this, ref);
856
- return loop === undefined ? undefined : new DanglingRefError(ref.$ref, { loop: loop.map(({ $ref }) => $ref) });
872
+ return loop === undefined
873
+ ? undefined
874
+ : new DanglingRefError(ref.$ref, { loop: loop.map(({ $ref }) => $ref) });
857
875
  }, _ParseContext_toLoopOf = function _ParseContext_toLoopOf(ref) {
858
876
  try {
859
877
  const loop = ref.toLoop();
@@ -879,5 +897,9 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
879
897
  const location = consumer.toString();
880
898
  __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeConsumer).call(this, consumer, documentTrail)
881
899
  .filter(removed => removed !== location)
882
- .forEach(removed => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDependencyIssue).call(this, { location: removed, refKey: ref.$ref, rootCause: { error, location } }));
900
+ .forEach(removed => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDependencyIssue).call(this, {
901
+ location: removed,
902
+ refKey: ref.$ref,
903
+ rootCause: { error, location }
904
+ }));
883
905
  };
@@ -88,7 +88,13 @@ _ResultsLog_results = new WeakMap(), _ResultsLog_instances = new WeakSet(), _Res
88
88
  };
89
89
  /** Writes an own, enumerable property, even for keys such as `__proto__`. */
90
90
  const defineOwn = (node, key, value) => {
91
- Object.defineProperty(node, key, { value, enumerable: true, writable: true, configurable: true });
91
+ // An assignment to `__proto__` would set the prototype, so that key is defined.
92
+ if (key === '__proto__') {
93
+ Object.defineProperty(node, key, { value, enumerable: true, writable: true, configurable: true });
94
+ }
95
+ else {
96
+ node[key] = value;
97
+ }
92
98
  };
93
99
  /**
94
100
  * Severity of each result type. A higher number replaces a lower one