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