@skmtc/core 0.54.0 → 0.55.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.
@@ -13,9 +13,9 @@ 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_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;
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_runSubjects, _GenerateContext_addPreview, _GenerateContext_toContentSettingsExportPath, _GenerateContext_ejectedBySuffixedPath_get, _GenerateContext_ejectedBySuffixedPathCache, _GenerateContext_findContainer, _GenerateContext_toContainer;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.toModelSource = exports.toGqlOperationSource = exports.toWebhookSource = exports.toOasOperationSource = exports.GenerateContext = void 0;
18
+ exports.GenerateContext = exports.toWebhookSource = exports.toOasOperationSource = exports.toModelSource = exports.toGqlOperationSource = void 0;
19
19
  const normalizeWorkspacePath_js_1 = require("../helpers/normalizeWorkspacePath.js");
20
20
  const getByWorkspacePath_js_1 = require("../helpers/getByWorkspacePath.js");
21
21
  const applyGeneratedSuffix_js_1 = require("../helpers/applyGeneratedSuffix.js");
@@ -31,6 +31,13 @@ const InsertOptions_js_1 = require("../types/InsertOptions.js");
31
31
  const ContentSettings_js_1 = require("../dsl/ContentSettings.js");
32
32
  const Variant_js_1 = require("../types/Variant.js");
33
33
  const toVariantList_js_1 = require("../helpers/toVariantList.js");
34
+ const Subject_js_1 = require("./Subject.js");
35
+ const FilePlan_js_1 = require("./FilePlan.js");
36
+ var Subject_js_2 = require("./Subject.js");
37
+ Object.defineProperty(exports, "toGqlOperationSource", { enumerable: true, get: function () { return Subject_js_2.toGqlOperationSource; } });
38
+ Object.defineProperty(exports, "toModelSource", { enumerable: true, get: function () { return Subject_js_2.toModelSource; } });
39
+ Object.defineProperty(exports, "toOasOperationSource", { enumerable: true, get: function () { return Subject_js_2.toOasOperationSource; } });
40
+ Object.defineProperty(exports, "toWebhookSource", { enumerable: true, get: function () { return Subject_js_2.toWebhookSource; } });
34
41
  const get_js_1 = __importDefault(require("lodash-es/get.js"));
35
42
  const Inserted_js_1 = require("../dsl/Inserted.js");
36
43
  const CodeFileBase_js_1 = require("../dsl/CodeFileBase.js");
@@ -300,6 +307,32 @@ class GenerateContext {
300
307
  enrichmentWarnings
301
308
  };
302
309
  }
310
+ /**
311
+ * @internal
312
+ * The file plan of a run of this context: which of `subjects` hold each
313
+ * file, from the projection classes that the entries of the run declared.
314
+ * An entry that declared none adds no file to the plan, and a generator
315
+ * that `settings.skip` names whole adds none either, and a GraphQL
316
+ * document's plan knows no file. Building the plan
317
+ * leaves the run as it is: its reads of enrichments are not recorded.
318
+ */
319
+ toFilePlan({ subjects, reach }) {
320
+ const skipped = this.settings?.skip ?? [];
321
+ const generators = Object.values(this.toGeneratorConfigMap());
322
+ // A GraphQL document has no reach (`toReach` reads only OpenAPI refs), so
323
+ // no subject would hold the files of the models it reaches. Its plan
324
+ // knows no file, and each file stays to the end.
325
+ const projections = this.document.type === 'gql'
326
+ ? []
327
+ : generators.filter(({ id }) => !skipped.includes(id)).flatMap(generator => generator.projections ?? []);
328
+ return __classPrivateFieldGet(this, _GenerateContext_enrichmentAudit, "f").withoutRecording(() => new FilePlan_js_1.FilePlan({
329
+ context: this,
330
+ subjects,
331
+ projections: [...new Set(projections)],
332
+ reach,
333
+ toFilePath: (exportPath, generatorId) => __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContentSettingsExportPath).call(this, exportPath, generatorId)
334
+ }));
335
+ }
303
336
  /**
304
337
  * Evaluate each generator's `isSupported` over the parsed document's subjects
305
338
  * and report the subjects each generator supports — capability only, no
@@ -942,7 +975,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
942
975
  // (only the listed operations); a generator absent from
943
976
  // `include` is unaffected and runs default-on. There is
944
977
  // therefore no whole-generator include gate here — the slice
945
- // extracted below is applied per-operation in the run* arms.
978
+ // extracted below is applied per subject and variant in `#runSubjects`.
946
979
  // (Whole-generator opt-out is `skip`. A bare-string `include`
947
980
  // entry carries no per-operation filter and is a no-op.)
948
981
  // skmtc#330: every object entry for this generator, merged, not only the first one.
@@ -960,7 +993,10 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
960
993
  // Generator targets OAS; current document is GraphQL — skip silently.
961
994
  return;
962
995
  }
963
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOasOperationGenerator).call(this, this.document.value, generatorConfig, toIncludePaths(include, generatorConfig.id), toSkipPaths(skip, generatorConfig.id), st);
996
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runSubjects).call(this, generatorConfig, this.document.value.operations.map(operation => new Subject_js_1.OasOperationSubject(operation)), {
997
+ include: toIncludePaths(include, generatorConfig.id),
998
+ skip: toSkipPaths(skip, generatorConfig.id)
999
+ }, st);
964
1000
  break;
965
1001
  case 'webhook':
966
1002
  if (this.document.type !== 'oas') {
@@ -968,7 +1004,10 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
968
1004
  // skip silently.
969
1005
  return;
970
1006
  }
971
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runWebhookGenerator).call(this, this.document.value, generatorConfig, toIncludePaths(include, generatorConfig.id), toSkipPaths(skip, generatorConfig.id), st);
1007
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runSubjects).call(this, generatorConfig, this.document.value.webhooks.map(webhook => new Subject_js_1.WebhookSubject(webhook)), {
1008
+ include: toIncludePaths(include, generatorConfig.id),
1009
+ skip: toSkipPaths(skip, generatorConfig.id)
1010
+ }, st);
972
1011
  break;
973
1012
  case 'gqlOperation':
974
1013
  if (this.document.type !== 'gql') {
@@ -976,16 +1015,20 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
976
1015
  return;
977
1016
  }
978
1017
  // GraphQL operations don't yet have skip/include support
979
- // at the per-operation level. The whole-generator gate
980
- // above does apply (so `include: ['my-gql-gen']` works as
981
- // expected), but per-(rootKind, fieldName) filtering is a
1018
+ // at the per-operation level. Only a whole-generator `skip`
1019
+ // acts on a GraphQL generator: `settings.include` and
1020
+ // `settings.skip` have no per-operation filter for GraphQL
1021
+ // operations. Per-(rootKind, fieldName) filtering is a
982
1022
  // follow-up that needs the same dispatch shape added for
983
1023
  // GqlOperation. Tracked alongside the existing GQL-skip
984
1024
  // gap.
985
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runGqlOperationGenerator).call(this, this.document.value, generatorConfig, st);
1025
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runSubjects).call(this, generatorConfig, this.document.value.operations.map(operation => new Subject_js_1.GqlOperationSubject(operation)), { include: undefined, skip: undefined }, st);
986
1026
  break;
987
1027
  case 'model':
988
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, this.document, generatorConfig, toIncludeModels(include, generatorConfig.id), toSkipModels(skip, generatorConfig.id), st);
1028
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runSubjects).call(this, generatorConfig, __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this).map(refName => new Subject_js_1.ModelSubject((0, refFns_js_1.toSchemaComponentRef)(refName))), {
1029
+ include: toIncludeModels(include, generatorConfig.id),
1030
+ skip: toSkipModels(skip, generatorConfig.id)
1031
+ }, st);
989
1032
  break;
990
1033
  default: {
991
1034
  const _exhaustive = generatorConfig;
@@ -1016,283 +1059,40 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1016
1059
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logError).call(this, error);
1017
1060
  return undefined;
1018
1061
  }
1019
- }, _GenerateContext_runOasOperationGenerator = function _GenerateContext_runOasOperationGenerator(oasDocument, generatorConfig, include, skip, stackTrail) {
1020
- oasDocument.operations.forEach(operation => {
1021
- stackTrail.trace([operation.path, operation.method], opTrail => {
1022
- // Resolve the variant list to fan out over. The consumer's
1023
- // enrichments are keyed `[generatorId][path][method][variant]`;
1024
- // the block at `[path][method]` is therefore a record of
1025
- // variant names. Three cases handled in `toVariantList`:
1026
- //
1027
- // - absent → run a single 'main' pass with no enrichment
1028
- // - present, non-object → treat as a single 'main' pass
1029
- // (the per-variant Valibot wrap will reject this shape
1030
- // at config-load time once it lands)
1031
- // - present, object → enumerate keys; 'main' must be among
1032
- // them or we throw (loud beats silent zero-output)
1033
- const opEnrichments = this.readEnrichment([
1034
- generatorConfig.id,
1035
- operation.path,
1036
- operation.method
1037
- ]);
1038
- const variants = (0, toVariantList_js_1.toVariantList)({
1039
- opEnrichments,
1040
- generatorId: generatorConfig.id,
1041
- operationLabel: `${operation.method.toUpperCase()} ${operation.path}`
1042
- });
1043
- variants.forEach(variant => {
1044
- opTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
1045
- try {
1046
- if (typeof generatorConfig?.isSupported === 'function' &&
1047
- !generatorConfig.isSupported({ operation, context: this, variant })) {
1048
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
1049
- return;
1050
- }
1051
- // Order: isSupported (capability) → include (allow) → skip
1052
- // (deny). Match is now on `(path, method, variant)`. An
1053
- // empty variant array on a method means "every variant of
1054
- // this method"; a populated array names the variants the
1055
- // entry applies to.
1056
- if (include !== undefined &&
1057
- !matchesPathFilter({
1058
- paths: include,
1059
- path: operation.path,
1060
- method: operation.method,
1061
- variant
1062
- })) {
1063
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_reportSkippedEnrichment).call(this, opEnrichments, variant, [
1064
- generatorConfig.id,
1065
- operation.path,
1066
- operation.method,
1067
- variant
1068
- ]);
1069
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
1070
- return;
1071
- }
1072
- if (matchesPathFilter({
1073
- paths: skip,
1074
- path: operation.path,
1075
- method: operation.method,
1076
- variant
1077
- })) {
1078
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_reportSkippedEnrichment).call(this, opEnrichments, variant, [
1079
- generatorConfig.id,
1080
- operation.path,
1081
- operation.method,
1082
- variant
1083
- ]);
1084
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
1085
- return;
1086
- }
1087
- generatorConfig.transform({
1088
- context: this,
1089
- operation,
1090
- variant
1091
- });
1092
- const source = (0, exports.toOasOperationSource)({
1093
- operation,
1094
- generatorId: generatorConfig.id,
1095
- variant
1096
- });
1097
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, operation, variant }));
1098
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
1099
- }
1100
- catch (error) {
1101
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
1102
- }
1103
- }));
1104
- });
1105
- });
1106
- });
1107
- }, _GenerateContext_runWebhookGenerator = function _GenerateContext_runWebhookGenerator(oasDocument, generatorConfig, include, skip, stackTrail) {
1108
- oasDocument.webhooks.forEach(webhook => {
1109
- stackTrail.trace(['webhook', webhook.name, webhook.method], webhookTrail => {
1110
- // Variant fan-out, keyed `[generatorId][name][method][variant]` —
1111
- // the webhook analogue of the operation routing. `toVariantList`
1112
- // handles absent / non-object / object enrichment blocks and
1113
- // enforces the `'main'`-must-be-present rule.
1114
- const webhookEnrichments = this.readEnrichment([
1115
- generatorConfig.id,
1116
- webhook.name,
1117
- webhook.method
1118
- ]);
1062
+ }, _GenerateContext_runSubjects = function _GenerateContext_runSubjects(entry, subjects, filters, stackTrail) {
1063
+ subjects.forEach(subject => {
1064
+ stackTrail.trace(subject.trail, subjectTrail => {
1065
+ // The enrichments of a subject are a record of variant names, at
1066
+ // `[generatorId][...subject.enrichmentPath]`. `toVariantList` gives
1067
+ // `['main']` for a block that is absent or no record, and throws
1068
+ // for a record that lacks `main`: no output with no error is worse.
1069
+ const enrichmentPath = [entry.id, ...subject.enrichmentPath];
1070
+ const enrichments = this.readEnrichment(enrichmentPath);
1119
1071
  const variants = (0, toVariantList_js_1.toVariantList)({
1120
- opEnrichments: webhookEnrichments,
1121
- generatorId: generatorConfig.id,
1122
- operationLabel: `webhook '${webhook.name}' (${webhook.method.toUpperCase()})`
1072
+ opEnrichments: enrichments,
1073
+ generatorId: entry.id,
1074
+ operationLabel: subject.label
1123
1075
  });
1124
1076
  variants.forEach(variant => {
1125
- webhookTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
1077
+ subjectTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
1126
1078
  try {
1127
- if (typeof generatorConfig?.isSupported === 'function' &&
1128
- !generatorConfig.isSupported({ webhook, context: this, variant })) {
1079
+ if (!subject.isSupported({ entry, context: this, variant })) {
1129
1080
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
1130
1081
  return;
1131
1082
  }
1132
- // Order: isSupported (capability) → include (allow) → skip
1133
- // (deny). The skip/include shape is structurally identical to
1134
- // operations (the webhook name occupies the `path` slot), so
1135
- // `matchesPathFilter` is reused with `path: webhook.name`.
1136
- if (include !== undefined &&
1137
- !matchesPathFilter({
1138
- paths: include,
1139
- path: webhook.name,
1140
- method: webhook.method,
1141
- variant
1142
- })) {
1143
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_reportSkippedEnrichment).call(this, webhookEnrichments, variant, [
1144
- generatorConfig.id,
1145
- webhook.name,
1146
- webhook.method,
1147
- variant
1148
- ]);
1149
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
1150
- return;
1151
- }
1152
- if (matchesPathFilter({
1153
- paths: skip,
1154
- path: webhook.name,
1155
- method: webhook.method,
1156
- variant
1157
- })) {
1158
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_reportSkippedEnrichment).call(this, webhookEnrichments, variant, [
1159
- generatorConfig.id,
1160
- webhook.name,
1161
- webhook.method,
1162
- variant
1163
- ]);
1083
+ // Order: isSupported (capability), then include (allow), then
1084
+ // skip (deny). A filter names a subject with an empty list of
1085
+ // variants, which is every variant, or with a list that has
1086
+ // this one.
1087
+ const isLeftOut = (filters.include !== undefined && !subject.matches(filters.include, variant)) ||
1088
+ subject.matches(filters.skip, variant);
1089
+ if (isLeftOut) {
1090
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_reportSkippedEnrichment).call(this, enrichments, variant, [...enrichmentPath, variant]);
1164
1091
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
1165
1092
  return;
1166
1093
  }
1167
- generatorConfig.transform({
1168
- context: this,
1169
- webhook,
1170
- variant
1171
- });
1172
- const source = (0, exports.toWebhookSource)({
1173
- webhook,
1174
- generatorId: generatorConfig.id,
1175
- variant
1176
- });
1177
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, webhook, variant }));
1178
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
1179
- }
1180
- catch (error) {
1181
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
1182
- }
1183
- }));
1184
- });
1185
- });
1186
- });
1187
- }, _GenerateContext_runGqlOperationGenerator = function _GenerateContext_runGqlOperationGenerator(gqlDocument, generatorConfig, stackTrail) {
1188
- gqlDocument.operations.forEach(operation => {
1189
- stackTrail.trace([operation.rootKind, operation.fieldName], opTrail => {
1190
- // GraphQL enrichment routing key is
1191
- // `[generatorId][rootKind][fieldName][variant]`.
1192
- const opEnrichments = this.readEnrichment([
1193
- generatorConfig.id,
1194
- operation.rootKind,
1195
- operation.fieldName
1196
- ]);
1197
- const variants = (0, toVariantList_js_1.toVariantList)({
1198
- opEnrichments,
1199
- generatorId: generatorConfig.id,
1200
- operationLabel: `${operation.rootKind} ${operation.fieldName}`
1201
- });
1202
- variants.forEach(variant => {
1203
- opTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
1204
- try {
1205
- if (typeof generatorConfig.isSupported === 'function' &&
1206
- !generatorConfig.isSupported({ operation, context: this, variant })) {
1207
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
1208
- return;
1209
- }
1210
- generatorConfig.transform({
1211
- context: this,
1212
- operation,
1213
- variant
1214
- });
1215
- const source = (0, exports.toGqlOperationSource)({
1216
- operation,
1217
- generatorId: generatorConfig.id,
1218
- variant
1219
- });
1220
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, operation, variant }));
1221
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
1222
- }
1223
- catch (error) {
1224
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_failItem).call(this, error, st);
1225
- }
1226
- }));
1227
- });
1228
- });
1229
- });
1230
- }, _GenerateContext_runModelGenerator = function _GenerateContext_runModelGenerator(document, generatorConfig, include, skip, stackTrail) {
1231
- const refNames = document.type === 'oas'
1232
- ? (document.value.components?.toSchemasRefNames() ?? [])
1233
- : document.value.registry.toSchemasRefNames();
1234
- refNames.forEach(refName => {
1235
- const ref = (0, refFns_js_1.toSchemaComponentRef)(refName);
1236
- stackTrail.trace(refName, refTrail => {
1237
- // Resolve the variant list to fan out over. The consumer's
1238
- // enrichments are keyed `[generatorId][refName][variant]`; the
1239
- // block at `[refName]` is therefore a record of variant names.
1240
- // Three cases handled in `toVariantList`:
1241
- //
1242
- // - absent → run a single 'main' pass with no enrichment
1243
- // - present, non-object → treat as a single 'main' pass
1244
- // (the per-variant Valibot wrap will reject this shape
1245
- // at config-load time once it lands)
1246
- // - present, object → enumerate keys; 'main' must be among
1247
- // them or we throw (loud beats silent zero-output)
1248
- const modelEnrichments = this.readEnrichment([generatorConfig.id, refName]);
1249
- const variants = (0, toVariantList_js_1.toVariantList)({
1250
- opEnrichments: modelEnrichments,
1251
- generatorId: generatorConfig.id,
1252
- operationLabel: refName
1253
- });
1254
- variants.forEach(variant => {
1255
- refTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
1256
- try {
1257
- if (typeof generatorConfig.isSupported === 'function' &&
1258
- !generatorConfig.isSupported({ ref, context: this, variant })) {
1259
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
1260
- return;
1261
- }
1262
- // Order: isSupported (capability) → include (allow) → skip
1263
- // (deny). Match is on `(refName, variant)`. An empty variant
1264
- // array on a refName means "every variant of this refName"; a
1265
- // populated array names the variants the entry applies to.
1266
- if (include !== undefined &&
1267
- !matchesRefFilter({ refs: include, refName, variant })) {
1268
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_reportSkippedEnrichment).call(this, modelEnrichments, variant, [
1269
- generatorConfig.id,
1270
- refName,
1271
- variant
1272
- ]);
1273
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
1274
- return;
1275
- }
1276
- if (matchesRefFilter({ refs: skip, refName, variant })) {
1277
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_reportSkippedEnrichment).call(this, modelEnrichments, variant, [
1278
- generatorConfig.id,
1279
- refName,
1280
- variant
1281
- ]);
1282
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
1283
- return;
1284
- }
1285
- generatorConfig.transform({
1286
- context: this,
1287
- ref,
1288
- variant
1289
- });
1290
- const source = (0, exports.toModelSource)({
1291
- refName,
1292
- generatorId: generatorConfig.id,
1293
- variant
1294
- });
1295
- __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, ref, variant }));
1094
+ subject.transform({ entry, context: this, variant });
1095
+ __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, subject.toSource({ generatorId: entry.id, variant }), subject.toPreviewModule({ entry, context: this, variant }));
1296
1096
  __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
1297
1097
  }
1298
1098
  catch (error) {
@@ -1340,124 +1140,6 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
1340
1140
  `Its value must implement addDefinition and findDefinitions.`);
1341
1141
  return definition.value;
1342
1142
  };
1343
- /**
1344
- * Match a `(path, method, variant)` tuple against an operation-shaped
1345
- * skip or include entry. Shared by both arms because skip and include
1346
- * have the same matching rules; only the engine's interpretation of
1347
- * the result differs (skip = deny, include = allow).
1348
- *
1349
- * Returns `false` when:
1350
- * - `paths` is `undefined` (no filter applies)
1351
- * - the `path` isn't keyed in the entry
1352
- * - the `method` isn't present in the inner record
1353
- *
1354
- * Returns `true` when:
1355
- * - the method's variant array is empty (matches every variant)
1356
- * - the method's variant array contains `variant`
1357
- */
1358
- const matchesPathFilter = ({ paths, path, method, variant }) => {
1359
- if (!paths) {
1360
- return false;
1361
- }
1362
- const methodMap = paths[path];
1363
- if (!methodMap) {
1364
- return false;
1365
- }
1366
- const variants = methodMap[method];
1367
- if (variants === undefined) {
1368
- return false;
1369
- }
1370
- if (variants.length === 0) {
1371
- return true;
1372
- }
1373
- return variants.includes(variant);
1374
- };
1375
- /**
1376
- * Match a `(refName, variant)` tuple against a model-shaped skip or
1377
- * include entry. Sibling to {@link matchesPathFilter} — both arms
1378
- * share matching rules; only the engine's interpretation of the
1379
- * result differs (skip = deny, include = allow).
1380
- *
1381
- * Returns `false` when:
1382
- * - `refs` is `undefined` (no filter applies)
1383
- * - the `refName` isn't keyed in the entry
1384
- *
1385
- * Returns `true` when:
1386
- * - the refName's variant array is empty (matches every variant)
1387
- * - the refName's variant array contains `variant`
1388
- */
1389
- const matchesRefFilter = ({ refs, refName, variant }) => {
1390
- if (!refs) {
1391
- return false;
1392
- }
1393
- const variants = refs[refName];
1394
- if (variants === undefined) {
1395
- return false;
1396
- }
1397
- if (variants.length === 0) {
1398
- return true;
1399
- }
1400
- return variants.includes(variant);
1401
- };
1402
- /**
1403
- * Creates an OasOperationSource from an operation, generator ID, and variant.
1404
- *
1405
- * Transforms operation and generator information into a source descriptor
1406
- * that can be used for tracking operation origins in the generation pipeline.
1407
- *
1408
- * @param args - Arguments containing operation, generator ID, and variant
1409
- * @returns OasOperationSource descriptor for the operation
1410
- */
1411
- const toOasOperationSource = ({ operation, generatorId, variant }) => ({
1412
- type: 'oasOperation',
1413
- generatorId,
1414
- operationPath: operation.path,
1415
- operationMethod: operation.method,
1416
- variant
1417
- });
1418
- exports.toOasOperationSource = toOasOperationSource;
1419
- /**
1420
- * Creates a {@link WebhookSource} from a webhook, generator ID, and variant.
1421
- * Sibling of {@link toOasOperationSource} for the 3.1 webhook subject.
1422
- */
1423
- const toWebhookSource = ({ webhook, generatorId, variant }) => ({
1424
- type: 'webhook',
1425
- generatorId,
1426
- webhookName: webhook.name,
1427
- webhookMethod: webhook.method,
1428
- variant
1429
- });
1430
- exports.toWebhookSource = toWebhookSource;
1431
- /**
1432
- * Creates a GraphQL operation source descriptor.
1433
- *
1434
- * Sibling to {@link toOasOperationSource} for the GraphQL protocol — encodes
1435
- * `rootKind` and `fieldName` instead of `path` / `method`.
1436
- */
1437
- const toGqlOperationSource = ({ operation, generatorId, variant }) => ({
1438
- type: 'gqlOperation',
1439
- generatorId,
1440
- rootKind: operation.rootKind,
1441
- fieldName: operation.fieldName,
1442
- variant
1443
- });
1444
- exports.toGqlOperationSource = toGqlOperationSource;
1445
- /**
1446
- * Creates a ModelSource from a reference name, generator ID, and variant.
1447
- *
1448
- * Transforms model reference and generator information into a source descriptor
1449
- * that can be used for tracking model origins in the generation pipeline.
1450
- *
1451
- * @param args - Arguments containing reference name, generator ID, and variant
1452
- * @returns ModelSource descriptor for the model
1453
- */
1454
- const toModelSource = ({ refName, generatorId, variant }) => ({
1455
- type: 'model',
1456
- generatorId,
1457
- refName,
1458
- variant
1459
- });
1460
- exports.toModelSource = toModelSource;
1461
1143
  /** Variants of one subject. `[]` is every variant, so it wins a merge. */
1462
1144
  const mergeVariants = (a, b) => a.length === 0 || b.length === 0 ? [] : [...new Set([...a, ...b])];
1463
1145
  /** Whether a filter is operation-shaped: its values are records of methods, not lists of variants. */