@skmtc/core 0.54.0 → 0.54.1
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/GenerateContext.d.ts +1 -61
- package/esm/context/GenerateContext.js +45 -390
- package/esm/context/Subject.d.ts +165 -0
- package/esm/context/Subject.js +328 -0
- package/package.json +1 -1
- package/script/context/GenerateContext.d.ts +1 -61
- package/script/context/GenerateContext.js +50 -395
- package/script/context/Subject.d.ts +165 -0
- package/script/context/Subject.js +339 -0
|
@@ -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,
|
|
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.
|
|
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,12 @@ 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
|
+
var Subject_js_2 = require("./Subject.js");
|
|
36
|
+
Object.defineProperty(exports, "toGqlOperationSource", { enumerable: true, get: function () { return Subject_js_2.toGqlOperationSource; } });
|
|
37
|
+
Object.defineProperty(exports, "toModelSource", { enumerable: true, get: function () { return Subject_js_2.toModelSource; } });
|
|
38
|
+
Object.defineProperty(exports, "toOasOperationSource", { enumerable: true, get: function () { return Subject_js_2.toOasOperationSource; } });
|
|
39
|
+
Object.defineProperty(exports, "toWebhookSource", { enumerable: true, get: function () { return Subject_js_2.toWebhookSource; } });
|
|
34
40
|
const get_js_1 = __importDefault(require("lodash-es/get.js"));
|
|
35
41
|
const Inserted_js_1 = require("../dsl/Inserted.js");
|
|
36
42
|
const CodeFileBase_js_1 = require("../dsl/CodeFileBase.js");
|
|
@@ -942,7 +948,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
942
948
|
// (only the listed operations); a generator absent from
|
|
943
949
|
// `include` is unaffected and runs default-on. There is
|
|
944
950
|
// therefore no whole-generator include gate here — the slice
|
|
945
|
-
// extracted below is applied per
|
|
951
|
+
// extracted below is applied per subject and variant in `#runSubjects`.
|
|
946
952
|
// (Whole-generator opt-out is `skip`. A bare-string `include`
|
|
947
953
|
// entry carries no per-operation filter and is a no-op.)
|
|
948
954
|
// skmtc#330: every object entry for this generator, merged, not only the first one.
|
|
@@ -960,7 +966,10 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
960
966
|
// Generator targets OAS; current document is GraphQL — skip silently.
|
|
961
967
|
return;
|
|
962
968
|
}
|
|
963
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
969
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runSubjects).call(this, generatorConfig, this.document.value.operations.map(operation => new Subject_js_1.OasOperationSubject(operation)), {
|
|
970
|
+
include: toIncludePaths(include, generatorConfig.id),
|
|
971
|
+
skip: toSkipPaths(skip, generatorConfig.id)
|
|
972
|
+
}, st);
|
|
964
973
|
break;
|
|
965
974
|
case 'webhook':
|
|
966
975
|
if (this.document.type !== 'oas') {
|
|
@@ -968,7 +977,10 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
968
977
|
// skip silently.
|
|
969
978
|
return;
|
|
970
979
|
}
|
|
971
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
980
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runSubjects).call(this, generatorConfig, this.document.value.webhooks.map(webhook => new Subject_js_1.WebhookSubject(webhook)), {
|
|
981
|
+
include: toIncludePaths(include, generatorConfig.id),
|
|
982
|
+
skip: toSkipPaths(skip, generatorConfig.id)
|
|
983
|
+
}, st);
|
|
972
984
|
break;
|
|
973
985
|
case 'gqlOperation':
|
|
974
986
|
if (this.document.type !== 'gql') {
|
|
@@ -976,16 +988,20 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
976
988
|
return;
|
|
977
989
|
}
|
|
978
990
|
// GraphQL operations don't yet have skip/include support
|
|
979
|
-
// at the per-operation level.
|
|
980
|
-
//
|
|
981
|
-
//
|
|
991
|
+
// at the per-operation level. Only a whole-generator `skip`
|
|
992
|
+
// acts on a GraphQL generator: `settings.include` and
|
|
993
|
+
// `settings.skip` have no per-operation filter for GraphQL
|
|
994
|
+
// operations. Per-(rootKind, fieldName) filtering is a
|
|
982
995
|
// follow-up that needs the same dispatch shape added for
|
|
983
996
|
// GqlOperation. Tracked alongside the existing GQL-skip
|
|
984
997
|
// gap.
|
|
985
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
998
|
+
__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
999
|
break;
|
|
987
1000
|
case 'model':
|
|
988
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
1001
|
+
__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(refName)), {
|
|
1002
|
+
include: toIncludeModels(include, generatorConfig.id),
|
|
1003
|
+
skip: toSkipModels(skip, generatorConfig.id)
|
|
1004
|
+
}, st);
|
|
989
1005
|
break;
|
|
990
1006
|
default: {
|
|
991
1007
|
const _exhaustive = generatorConfig;
|
|
@@ -1016,283 +1032,40 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1016
1032
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logError).call(this, error);
|
|
1017
1033
|
return undefined;
|
|
1018
1034
|
}
|
|
1019
|
-
},
|
|
1020
|
-
|
|
1021
|
-
stackTrail.trace(
|
|
1022
|
-
//
|
|
1023
|
-
//
|
|
1024
|
-
//
|
|
1025
|
-
//
|
|
1026
|
-
|
|
1027
|
-
|
|
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
|
-
]);
|
|
1035
|
+
}, _GenerateContext_runSubjects = function _GenerateContext_runSubjects(entry, subjects, filters, stackTrail) {
|
|
1036
|
+
subjects.forEach(subject => {
|
|
1037
|
+
stackTrail.trace(subject.trail, subjectTrail => {
|
|
1038
|
+
// The enrichments of a subject are a record of variant names, at
|
|
1039
|
+
// `[generatorId][...subject.enrichmentPath]`. `toVariantList` gives
|
|
1040
|
+
// `['main']` for a block that is absent or no record, and throws
|
|
1041
|
+
// for a record that lacks `main`: no output with no error is worse.
|
|
1042
|
+
const enrichmentPath = [entry.id, ...subject.enrichmentPath];
|
|
1043
|
+
const enrichments = this.readEnrichment(enrichmentPath);
|
|
1038
1044
|
const variants = (0, toVariantList_js_1.toVariantList)({
|
|
1039
|
-
opEnrichments,
|
|
1040
|
-
generatorId:
|
|
1041
|
-
operationLabel:
|
|
1045
|
+
opEnrichments: enrichments,
|
|
1046
|
+
generatorId: entry.id,
|
|
1047
|
+
operationLabel: subject.label
|
|
1042
1048
|
});
|
|
1043
1049
|
variants.forEach(variant => {
|
|
1044
|
-
|
|
1050
|
+
subjectTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
|
|
1045
1051
|
try {
|
|
1046
|
-
if (
|
|
1047
|
-
!generatorConfig.isSupported({ operation, context: this, variant })) {
|
|
1052
|
+
if (!subject.isSupported({ entry, context: this, variant })) {
|
|
1048
1053
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
|
|
1049
1054
|
return;
|
|
1050
1055
|
}
|
|
1051
|
-
// Order: isSupported (capability)
|
|
1052
|
-
// (deny).
|
|
1053
|
-
//
|
|
1054
|
-
// this
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
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
|
-
]);
|
|
1056
|
+
// Order: isSupported (capability), then include (allow), then
|
|
1057
|
+
// skip (deny). A filter names a subject with an empty list of
|
|
1058
|
+
// variants, which is every variant, or with a list that has
|
|
1059
|
+
// this one.
|
|
1060
|
+
const isLeftOut = (filters.include !== undefined && !subject.matches(filters.include, variant)) ||
|
|
1061
|
+
subject.matches(filters.skip, variant);
|
|
1062
|
+
if (isLeftOut) {
|
|
1063
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_reportSkippedEnrichment).call(this, enrichments, variant, [...enrichmentPath, variant]);
|
|
1069
1064
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
|
|
1070
1065
|
return;
|
|
1071
1066
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
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
|
-
]);
|
|
1119
|
-
const variants = (0, toVariantList_js_1.toVariantList)({
|
|
1120
|
-
opEnrichments: webhookEnrichments,
|
|
1121
|
-
generatorId: generatorConfig.id,
|
|
1122
|
-
operationLabel: `webhook '${webhook.name}' (${webhook.method.toUpperCase()})`
|
|
1123
|
-
});
|
|
1124
|
-
variants.forEach(variant => {
|
|
1125
|
-
webhookTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
|
|
1126
|
-
try {
|
|
1127
|
-
if (typeof generatorConfig?.isSupported === 'function' &&
|
|
1128
|
-
!generatorConfig.isSupported({ webhook, context: this, variant })) {
|
|
1129
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
|
|
1130
|
-
return;
|
|
1131
|
-
}
|
|
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
|
-
]);
|
|
1164
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
|
|
1165
|
-
return;
|
|
1166
|
-
}
|
|
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 }));
|
|
1067
|
+
subject.transform({ entry, context: this, variant });
|
|
1068
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, subject.toSource({ generatorId: entry.id, variant }), subject.toPreviewModule({ entry, context: this, variant }));
|
|
1296
1069
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
|
|
1297
1070
|
}
|
|
1298
1071
|
catch (error) {
|
|
@@ -1340,124 +1113,6 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1340
1113
|
`Its value must implement addDefinition and findDefinitions.`);
|
|
1341
1114
|
return definition.value;
|
|
1342
1115
|
};
|
|
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
1116
|
/** Variants of one subject. `[]` is every variant, so it wins a merge. */
|
|
1462
1117
|
const mergeVariants = (a, b) => a.length === 0 || b.length === 0 ? [] : [...new Set([...a, ...b])];
|
|
1463
1118
|
/** Whether a filter is operation-shaped: its values are records of methods, not lists of variants. */
|