@skmtc/core 0.53.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/ParseContext.d.ts +7 -0
- package/esm/context/ParseContext.js +16 -16
- package/esm/context/Subject.d.ts +165 -0
- package/esm/context/Subject.js +328 -0
- package/esm/parse/Reach.d.ts +56 -0
- package/esm/parse/Reach.js +131 -0
- package/esm/parse/toCyclicRefs.d.ts +3 -0
- package/esm/parse/toCyclicRefs.js +1 -1
- package/esm/parse/toRefKey.d.ts +11 -0
- package/esm/parse/toRefKey.js +16 -0
- package/package.json +1 -1
- package/script/context/GenerateContext.d.ts +1 -61
- package/script/context/GenerateContext.js +50 -395
- package/script/context/ParseContext.d.ts +7 -0
- package/script/context/ParseContext.js +18 -18
- package/script/context/Subject.d.ts +165 -0
- package/script/context/Subject.js +339 -0
- package/script/parse/Reach.d.ts +56 -0
- package/script/parse/Reach.js +135 -0
- package/script/parse/toCyclicRefs.d.ts +3 -0
- package/script/parse/toCyclicRefs.js +3 -2
- package/script/parse/toRefKey.d.ts +11 -0
- package/script/parse/toRefKey.js +20 -0
|
@@ -11,11 +11,10 @@ import type { BuildModelSettingsArgs, GenerateContextType, GenerateResult, Inser
|
|
|
11
11
|
import type { ClientSettings } from '../types/Settings.js';
|
|
12
12
|
import { type Method } from '../types/Method.js';
|
|
13
13
|
import type { OasOperation } from '../oas/operation/Operation.js';
|
|
14
|
-
import type { OasWebhook } from '../oas/webhook/Webhook.js';
|
|
15
14
|
import { type ProjectionOptionsRest } from '../types/ProjectionOptions.js';
|
|
16
15
|
import type { GeneratedValue } from '../dsl/GeneratedValue.js';
|
|
17
16
|
import { ContentSettings } from '../dsl/ContentSettings.js';
|
|
18
|
-
|
|
17
|
+
export { toGqlOperationSource, toModelSource, toOasOperationSource, toWebhookSource } from './Subject.js';
|
|
19
18
|
import type * as log from '../deps/jsr.io/@std/log/0.224.14/mod.js';
|
|
20
19
|
import type { Logger } from '../types/Logger.js';
|
|
21
20
|
import type { ResultType } from '../types/Results.js';
|
|
@@ -26,8 +25,6 @@ import { Inserted } from '../dsl/Inserted.js';
|
|
|
26
25
|
import type { CaptureChannel, CaptureSink } from '../anchors/CaptureSink.js';
|
|
27
26
|
import type { FileBase } from '../dsl/FileBase.js';
|
|
28
27
|
import type { GeneratorsMapContainer } from '../types/GeneratorType.js';
|
|
29
|
-
import type { OasOperationSource, WebhookSource, GqlOperationSource, ModelSource } from '../types/Preview.js';
|
|
30
|
-
import type { GqlOperation } from '../gql/operation/GqlOperation.js';
|
|
31
28
|
import type { OasVoid } from '../oas/void/Void.js';
|
|
32
29
|
import type { ModelProjection, NormalizedModelProjection } from '../dsl/model/types.js';
|
|
33
30
|
import { type EnrichmentWarning } from '../enrichments/EnrichmentWarning.js';
|
|
@@ -366,60 +363,3 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
366
363
|
*/
|
|
367
364
|
findDefinition({ name, exportPath, into }: FindDefinitionArgs): DefinitionBase | undefined;
|
|
368
365
|
}
|
|
369
|
-
type ToOasOperationSourceArgs = {
|
|
370
|
-
operation: OasOperation;
|
|
371
|
-
generatorId: string;
|
|
372
|
-
/** Operation variant the artifact was emitted for (see {@link Variant}) */
|
|
373
|
-
variant: string;
|
|
374
|
-
};
|
|
375
|
-
/**
|
|
376
|
-
* Creates an OasOperationSource from an operation, generator ID, and variant.
|
|
377
|
-
*
|
|
378
|
-
* Transforms operation and generator information into a source descriptor
|
|
379
|
-
* that can be used for tracking operation origins in the generation pipeline.
|
|
380
|
-
*
|
|
381
|
-
* @param args - Arguments containing operation, generator ID, and variant
|
|
382
|
-
* @returns OasOperationSource descriptor for the operation
|
|
383
|
-
*/
|
|
384
|
-
export declare const toOasOperationSource: ({ operation, generatorId, variant }: ToOasOperationSourceArgs) => OasOperationSource;
|
|
385
|
-
type ToWebhookSourceArgs = {
|
|
386
|
-
webhook: OasWebhook;
|
|
387
|
-
generatorId: string;
|
|
388
|
-
/** Webhook variant the artifact was emitted for (see {@link Variant}) */
|
|
389
|
-
variant: string;
|
|
390
|
-
};
|
|
391
|
-
/**
|
|
392
|
-
* Creates a {@link WebhookSource} from a webhook, generator ID, and variant.
|
|
393
|
-
* Sibling of {@link toOasOperationSource} for the 3.1 webhook subject.
|
|
394
|
-
*/
|
|
395
|
-
export declare const toWebhookSource: ({ webhook, generatorId, variant }: ToWebhookSourceArgs) => WebhookSource;
|
|
396
|
-
type ToGqlOperationSourceArgs = {
|
|
397
|
-
operation: GqlOperation;
|
|
398
|
-
generatorId: string;
|
|
399
|
-
/** Operation variant the artifact was emitted for (see {@link Variant}) */
|
|
400
|
-
variant: string;
|
|
401
|
-
};
|
|
402
|
-
/**
|
|
403
|
-
* Creates a GraphQL operation source descriptor.
|
|
404
|
-
*
|
|
405
|
-
* Sibling to {@link toOasOperationSource} for the GraphQL protocol — encodes
|
|
406
|
-
* `rootKind` and `fieldName` instead of `path` / `method`.
|
|
407
|
-
*/
|
|
408
|
-
export declare const toGqlOperationSource: ({ operation, generatorId, variant }: ToGqlOperationSourceArgs) => GqlOperationSource;
|
|
409
|
-
type ToModelSourceArgs = {
|
|
410
|
-
refName: RefName;
|
|
411
|
-
generatorId: string;
|
|
412
|
-
/** Model variant the artifact was emitted for (see {@link Variant}) */
|
|
413
|
-
variant: string;
|
|
414
|
-
};
|
|
415
|
-
/**
|
|
416
|
-
* Creates a ModelSource from a reference name, generator ID, and variant.
|
|
417
|
-
*
|
|
418
|
-
* Transforms model reference and generator information into a source descriptor
|
|
419
|
-
* that can be used for tracking model origins in the generation pipeline.
|
|
420
|
-
*
|
|
421
|
-
* @param args - Arguments containing reference name, generator ID, and variant
|
|
422
|
-
* @returns ModelSource descriptor for the model
|
|
423
|
-
*/
|
|
424
|
-
export declare const toModelSource: ({ refName, generatorId, variant }: ToModelSourceArgs) => ModelSource;
|
|
425
|
-
export {};
|
|
@@ -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,8 @@ 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
|
+
export { toGqlOperationSource, toModelSource, toOasOperationSource, toWebhookSource } from './Subject.js';
|
|
28
30
|
import get from 'lodash-es/get.js';
|
|
29
31
|
import { Inserted } from '../dsl/Inserted.js';
|
|
30
32
|
import { CodeFileBase } from '../dsl/CodeFileBase.js';
|
|
@@ -935,7 +937,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
935
937
|
// (only the listed operations); a generator absent from
|
|
936
938
|
// `include` is unaffected and runs default-on. There is
|
|
937
939
|
// therefore no whole-generator include gate here — the slice
|
|
938
|
-
// extracted below is applied per
|
|
940
|
+
// extracted below is applied per subject and variant in `#runSubjects`.
|
|
939
941
|
// (Whole-generator opt-out is `skip`. A bare-string `include`
|
|
940
942
|
// entry carries no per-operation filter and is a no-op.)
|
|
941
943
|
// skmtc#330: every object entry for this generator, merged, not only the first one.
|
|
@@ -953,7 +955,10 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
953
955
|
// Generator targets OAS; current document is GraphQL — skip silently.
|
|
954
956
|
return;
|
|
955
957
|
}
|
|
956
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
958
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runSubjects).call(this, generatorConfig, this.document.value.operations.map(operation => new OasOperationSubject(operation)), {
|
|
959
|
+
include: toIncludePaths(include, generatorConfig.id),
|
|
960
|
+
skip: toSkipPaths(skip, generatorConfig.id)
|
|
961
|
+
}, st);
|
|
957
962
|
break;
|
|
958
963
|
case 'webhook':
|
|
959
964
|
if (this.document.type !== 'oas') {
|
|
@@ -961,7 +966,10 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
961
966
|
// skip silently.
|
|
962
967
|
return;
|
|
963
968
|
}
|
|
964
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
969
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runSubjects).call(this, generatorConfig, this.document.value.webhooks.map(webhook => new WebhookSubject(webhook)), {
|
|
970
|
+
include: toIncludePaths(include, generatorConfig.id),
|
|
971
|
+
skip: toSkipPaths(skip, generatorConfig.id)
|
|
972
|
+
}, st);
|
|
965
973
|
break;
|
|
966
974
|
case 'gqlOperation':
|
|
967
975
|
if (this.document.type !== 'gql') {
|
|
@@ -969,16 +977,20 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
969
977
|
return;
|
|
970
978
|
}
|
|
971
979
|
// GraphQL operations don't yet have skip/include support
|
|
972
|
-
// at the per-operation level.
|
|
973
|
-
//
|
|
974
|
-
//
|
|
980
|
+
// at the per-operation level. Only a whole-generator `skip`
|
|
981
|
+
// acts on a GraphQL generator: `settings.include` and
|
|
982
|
+
// `settings.skip` have no per-operation filter for GraphQL
|
|
983
|
+
// operations. Per-(rootKind, fieldName) filtering is a
|
|
975
984
|
// follow-up that needs the same dispatch shape added for
|
|
976
985
|
// GqlOperation. Tracked alongside the existing GQL-skip
|
|
977
986
|
// gap.
|
|
978
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
987
|
+
__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
988
|
break;
|
|
980
989
|
case 'model':
|
|
981
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m",
|
|
990
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runSubjects).call(this, generatorConfig, __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this).map(refName => new ModelSubject(refName)), {
|
|
991
|
+
include: toIncludeModels(include, generatorConfig.id),
|
|
992
|
+
skip: toSkipModels(skip, generatorConfig.id)
|
|
993
|
+
}, st);
|
|
982
994
|
break;
|
|
983
995
|
default: {
|
|
984
996
|
const _exhaustive = generatorConfig;
|
|
@@ -1009,283 +1021,40 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1009
1021
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_logError).call(this, error);
|
|
1010
1022
|
return undefined;
|
|
1011
1023
|
}
|
|
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
|
-
]);
|
|
1024
|
+
}, _GenerateContext_runSubjects = function _GenerateContext_runSubjects(entry, subjects, filters, stackTrail) {
|
|
1025
|
+
subjects.forEach(subject => {
|
|
1026
|
+
stackTrail.trace(subject.trail, subjectTrail => {
|
|
1027
|
+
// The enrichments of a subject are a record of variant names, at
|
|
1028
|
+
// `[generatorId][...subject.enrichmentPath]`. `toVariantList` gives
|
|
1029
|
+
// `['main']` for a block that is absent or no record, and throws
|
|
1030
|
+
// for a record that lacks `main`: no output with no error is worse.
|
|
1031
|
+
const enrichmentPath = [entry.id, ...subject.enrichmentPath];
|
|
1032
|
+
const enrichments = this.readEnrichment(enrichmentPath);
|
|
1031
1033
|
const variants = toVariantList({
|
|
1032
|
-
opEnrichments,
|
|
1033
|
-
generatorId:
|
|
1034
|
-
operationLabel:
|
|
1034
|
+
opEnrichments: enrichments,
|
|
1035
|
+
generatorId: entry.id,
|
|
1036
|
+
operationLabel: subject.label
|
|
1035
1037
|
});
|
|
1036
1038
|
variants.forEach(variant => {
|
|
1037
|
-
|
|
1039
|
+
subjectTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
|
|
1038
1040
|
try {
|
|
1039
|
-
if (
|
|
1040
|
-
!generatorConfig.isSupported({ operation, context: this, variant })) {
|
|
1041
|
+
if (!subject.isSupported({ entry, context: this, variant })) {
|
|
1041
1042
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
|
|
1042
1043
|
return;
|
|
1043
1044
|
}
|
|
1044
|
-
// Order: isSupported (capability)
|
|
1045
|
-
// (deny).
|
|
1046
|
-
//
|
|
1047
|
-
// this
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
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
|
-
]);
|
|
1045
|
+
// Order: isSupported (capability), then include (allow), then
|
|
1046
|
+
// skip (deny). A filter names a subject with an empty list of
|
|
1047
|
+
// variants, which is every variant, or with a list that has
|
|
1048
|
+
// this one.
|
|
1049
|
+
const isLeftOut = (filters.include !== undefined && !subject.matches(filters.include, variant)) ||
|
|
1050
|
+
subject.matches(filters.skip, variant);
|
|
1051
|
+
if (isLeftOut) {
|
|
1052
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_reportSkippedEnrichment).call(this, enrichments, variant, [...enrichmentPath, variant]);
|
|
1062
1053
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
|
|
1063
1054
|
return;
|
|
1064
1055
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
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
|
-
]);
|
|
1112
|
-
const variants = toVariantList({
|
|
1113
|
-
opEnrichments: webhookEnrichments,
|
|
1114
|
-
generatorId: generatorConfig.id,
|
|
1115
|
-
operationLabel: `webhook '${webhook.name}' (${webhook.method.toUpperCase()})`
|
|
1116
|
-
});
|
|
1117
|
-
variants.forEach(variant => {
|
|
1118
|
-
webhookTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
|
|
1119
|
-
try {
|
|
1120
|
-
if (typeof generatorConfig?.isSupported === 'function' &&
|
|
1121
|
-
!generatorConfig.isSupported({ webhook, context: this, variant })) {
|
|
1122
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'notSupported', st);
|
|
1123
|
-
return;
|
|
1124
|
-
}
|
|
1125
|
-
// Order: isSupported (capability) → include (allow) → skip
|
|
1126
|
-
// (deny). The skip/include shape is structurally identical to
|
|
1127
|
-
// operations (the webhook name occupies the `path` slot), so
|
|
1128
|
-
// `matchesPathFilter` is reused with `path: webhook.name`.
|
|
1129
|
-
if (include !== undefined &&
|
|
1130
|
-
!matchesPathFilter({
|
|
1131
|
-
paths: include,
|
|
1132
|
-
path: webhook.name,
|
|
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
|
-
]);
|
|
1157
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'skipped', st);
|
|
1158
|
-
return;
|
|
1159
|
-
}
|
|
1160
|
-
generatorConfig.transform({
|
|
1161
|
-
context: this,
|
|
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 }));
|
|
1056
|
+
subject.transform({ entry, context: this, variant });
|
|
1057
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, subject.toSource({ generatorId: entry.id, variant }), subject.toPreviewModule({ entry, context: this, variant }));
|
|
1289
1058
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_captureSubjectResult).call(this, 'success', st);
|
|
1290
1059
|
}
|
|
1291
1060
|
catch (error) {
|
|
@@ -1333,120 +1102,6 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1333
1102
|
`Its value must implement addDefinition and findDefinitions.`);
|
|
1334
1103
|
return definition.value;
|
|
1335
1104
|
};
|
|
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
1105
|
/** Variants of one subject. `[]` is every variant, so it wins a merge. */
|
|
1451
1106
|
const mergeVariants = (a, b) => a.length === 0 || b.length === 0 ? [] : [...new Set([...a, ...b])];
|
|
1452
1107
|
/** Whether a filter is operation-shaped: its values are records of methods, not lists of variants. */
|
|
@@ -32,6 +32,7 @@ import type { ParseIssue } from './ParseIssue.js';
|
|
|
32
32
|
import type { OasRef } from '../oas/ref/Ref.js';
|
|
33
33
|
import type { OasRefData } from '../oas/ref/ref-types.js';
|
|
34
34
|
import { DanglingRefError } from '../oas/ref/DanglingRefError.js';
|
|
35
|
+
import { Reach } from '../parse/Reach.js';
|
|
35
36
|
export type { ParseIssue, GqlIssueType } from './ParseIssue.js';
|
|
36
37
|
export type { GqlParseOptions, LogAtArgs, LogIssueArgs, LogIssueAtArgs, LogIssueNoKeyArgs, LogSkippedValuesArgs, ParseContextType, ParseErrorInput, ParseIssueInput, ParseWarningInput } from './parseTypes.js';
|
|
37
38
|
type OasProtocolState = {
|
|
@@ -163,6 +164,12 @@ export declare class ParseContext {
|
|
|
163
164
|
* ```
|
|
164
165
|
*/
|
|
165
166
|
withStackTrail<T>(stackTrail: StackTrail, fn: () => T): T;
|
|
167
|
+
/**
|
|
168
|
+
* @internal
|
|
169
|
+
* What each subject of the parsed document can reach through `$ref`s, read
|
|
170
|
+
* from the refs this parse read. Call it when the document is parsed.
|
|
171
|
+
*/
|
|
172
|
+
toReach(): Reach;
|
|
166
173
|
/**
|
|
167
174
|
* Register a `$ref`-style consumer site. The key encoding is up to
|
|
168
175
|
* the caller — OAS uses `#/components/schemas/User` strings, GQL
|