@skmtc/core 0.45.0 → 0.46.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/anchors/attribute.js +3 -2
- package/esm/context/CoreContext.d.ts +1 -1
- package/esm/context/CoreContext.js +1 -1
- package/esm/context/GenerateContext.d.ts +13 -10
- package/esm/context/GenerateContext.js +36 -25
- package/esm/context/ParseContext.js +136 -34
- package/esm/context/generateTypes.d.ts +5 -4
- package/esm/dsl/GeneratorKeys.d.ts +21 -15
- package/esm/dsl/GeneratorKeys.js +16 -11
- package/esm/dsl/Inserted.d.ts +1 -1
- package/esm/dsl/Inserted.js +1 -1
- package/esm/dsl/model/ModelDriver.d.ts +6 -5
- package/esm/dsl/model/ModelDriver.js +22 -20
- package/esm/dsl/model/toModelEntry.d.ts +18 -18
- package/esm/dsl/model/toModelEntry.js +9 -9
- package/esm/dsl/model/toModelProjectionBase.d.ts +17 -16
- package/esm/dsl/model/toModelProjectionBase.js +12 -8
- package/esm/dsl/model/types.d.ts +26 -17
- package/esm/dsl/operation/gql/toGqlOperationProjectionBase.d.ts +2 -2
- package/esm/dsl/operation/gql/toGqlOperationProjectionBase.js +2 -2
- package/esm/dsl/operation/oas/toOasOperationProjectionBase.d.ts +2 -2
- package/esm/dsl/operation/oas/toOasOperationProjectionBase.js +2 -2
- package/esm/dsl/webhook/toWebhookProjectionBase.d.ts +2 -2
- package/esm/dsl/webhook/toWebhookProjectionBase.js +2 -2
- package/esm/helpers/refFns.d.ts +108 -43
- package/esm/helpers/refFns.js +166 -57
- package/esm/oas/document/Document.d.ts +6 -0
- package/esm/oas/document/Document.js +44 -2
- package/esm/oas/ref/DanglingRefError.d.ts +5 -2
- package/esm/oas/ref/DanglingRefError.js +4 -3
- package/esm/oas/ref/Ref.d.ts +23 -12
- package/esm/oas/ref/Ref.js +68 -72
- package/esm/oas/schemaPath/traverseSchema.js +11 -5
- package/esm/parse/v3-0/ref/toRefTargetV3.d.ts +23 -0
- package/esm/parse/v3-0/ref/toRefTargetV3.js +70 -0
- package/esm/parse/v3-1/ref/toRefTargetV3.d.ts +23 -0
- package/esm/parse/v3-1/ref/toRefTargetV3.js +70 -0
- package/esm/parse/v3-2/ref/toRefTargetV3.d.ts +23 -0
- package/esm/parse/v3-2/ref/toRefTargetV3.js +70 -0
- package/esm/types/GeneratorType.d.ts +1 -1
- package/esm/types/ProjectionOptions.d.ts +1 -1
- package/esm/types/ProjectionOptions.js +1 -1
- package/esm/types/RefName.d.ts +3 -3
- package/esm/types/TypeSystem.d.ts +3 -3
- package/package.json +1 -1
- package/script/anchors/attribute.js +3 -2
- package/script/context/CoreContext.d.ts +1 -1
- package/script/context/CoreContext.js +1 -1
- package/script/context/GenerateContext.d.ts +13 -10
- package/script/context/GenerateContext.js +36 -25
- package/script/context/ParseContext.js +135 -33
- package/script/context/generateTypes.d.ts +5 -4
- package/script/dsl/GeneratorKeys.d.ts +21 -15
- package/script/dsl/GeneratorKeys.js +16 -11
- package/script/dsl/Inserted.d.ts +1 -1
- package/script/dsl/Inserted.js +1 -1
- package/script/dsl/model/ModelDriver.d.ts +6 -5
- package/script/dsl/model/ModelDriver.js +22 -20
- package/script/dsl/model/toModelEntry.d.ts +18 -18
- package/script/dsl/model/toModelEntry.js +9 -9
- package/script/dsl/model/toModelProjectionBase.d.ts +17 -16
- package/script/dsl/model/toModelProjectionBase.js +12 -8
- package/script/dsl/model/types.d.ts +26 -17
- package/script/dsl/operation/gql/toGqlOperationProjectionBase.d.ts +2 -2
- package/script/dsl/operation/gql/toGqlOperationProjectionBase.js +2 -2
- package/script/dsl/operation/oas/toOasOperationProjectionBase.d.ts +2 -2
- package/script/dsl/operation/oas/toOasOperationProjectionBase.js +2 -2
- package/script/dsl/webhook/toWebhookProjectionBase.d.ts +2 -2
- package/script/dsl/webhook/toWebhookProjectionBase.js +2 -2
- package/script/helpers/refFns.d.ts +108 -43
- package/script/helpers/refFns.js +180 -59
- package/script/oas/document/Document.d.ts +6 -0
- package/script/oas/document/Document.js +44 -2
- package/script/oas/ref/DanglingRefError.d.ts +5 -2
- package/script/oas/ref/DanglingRefError.js +4 -3
- package/script/oas/ref/Ref.d.ts +23 -12
- package/script/oas/ref/Ref.js +67 -71
- package/script/oas/schemaPath/traverseSchema.js +10 -4
- package/script/parse/v3-0/ref/toRefTargetV3.d.ts +23 -0
- package/script/parse/v3-0/ref/toRefTargetV3.js +74 -0
- package/script/parse/v3-1/ref/toRefTargetV3.d.ts +23 -0
- package/script/parse/v3-1/ref/toRefTargetV3.js +74 -0
- package/script/parse/v3-2/ref/toRefTargetV3.d.ts +23 -0
- package/script/parse/v3-2/ref/toRefTargetV3.js +74 -0
- package/script/types/GeneratorType.d.ts +1 -1
- package/script/types/ProjectionOptions.d.ts +1 -1
- package/script/types/ProjectionOptions.js +1 -1
- package/script/types/RefName.d.ts +3 -3
- package/script/types/TypeSystem.d.ts +3 -3
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.attribute = void 0;
|
|
18
18
|
const GeneratorKeys_js_1 = require("../dsl/GeneratorKeys.js");
|
|
19
19
|
const Definition_js_1 = require("../dsl/Definition.js");
|
|
20
|
+
const refFns_js_1 = require("../helpers/refFns.js");
|
|
20
21
|
/**
|
|
21
22
|
* Derive the attribution tuple for a producer.
|
|
22
23
|
*
|
|
@@ -57,7 +58,7 @@ exports.attribute = attribute;
|
|
|
57
58
|
*
|
|
58
59
|
* - OAS operation → `#/paths/<escaped-path>/<method>`
|
|
59
60
|
* - GQL operation → `<rootKind>.<fieldName>`
|
|
60
|
-
* - Model → `#/components/schemas/<refName>`
|
|
61
|
+
* - Model → its ref's pointer: `#/components/schemas/<refName>` for a component
|
|
61
62
|
* - Container / generator-only / no key → `''` (no schema location to point
|
|
62
63
|
* at — a container is a place many subjects insert into, so it has no
|
|
63
64
|
* position of its own; its MEMBERS carry their subjects' keys)
|
|
@@ -73,7 +74,7 @@ const schemaPointerFromKey = (parsed) => {
|
|
|
73
74
|
case 'gqlOperation':
|
|
74
75
|
return `${parsed.rootKind}.${parsed.fieldName}`;
|
|
75
76
|
case 'model':
|
|
76
|
-
return
|
|
77
|
+
return (0, refFns_js_1.toRefPointer)(parsed.ref);
|
|
77
78
|
case 'container':
|
|
78
79
|
case 'generator-only':
|
|
79
80
|
return '';
|
|
@@ -264,7 +264,7 @@ export declare class CoreContext {
|
|
|
264
264
|
* toGeneratorConfigMap: () => ({
|
|
265
265
|
* 'typescript-models': toModelEntry({
|
|
266
266
|
* id: 'typescript-models',
|
|
267
|
-
* transform: ({ context,
|
|
267
|
+
* transform: ({ context, ref }) => {}
|
|
268
268
|
* }),
|
|
269
269
|
* 'api-client': toOasOperationEntry({
|
|
270
270
|
* id: 'api-client',
|
|
@@ -299,7 +299,7 @@ class CoreContext {
|
|
|
299
299
|
* toGeneratorConfigMap: () => ({
|
|
300
300
|
* 'typescript-models': toModelEntry({
|
|
301
301
|
* id: 'typescript-models',
|
|
302
|
-
* transform: ({ context,
|
|
302
|
+
* transform: ({ context, ref }) => {}
|
|
303
303
|
* }),
|
|
304
304
|
* 'api-client': toOasOperationEntry({
|
|
305
305
|
* id: 'api-client',
|
|
@@ -2,6 +2,7 @@ import type { DefinitionBase } from '../dsl/Definition.js';
|
|
|
2
2
|
import type { PendingDefinition } from '../dsl/PendingDefinition.js';
|
|
3
3
|
import type { OasSchema } from '../oas/schema/Schema.js';
|
|
4
4
|
import type { OasRef } from '../oas/ref/Ref.js';
|
|
5
|
+
import { type RefParts } from '../helpers/refFns.js';
|
|
5
6
|
import type { SkmtcParsedDocument } from '../types/SkmtcDocument.js';
|
|
6
7
|
import type { SupportedSubjects } from '../types/SupportedSubjects.js';
|
|
7
8
|
import type { EnrichmentDefaults } from '../types/EnrichmentDefaults.js';
|
|
@@ -78,8 +79,8 @@ export type CreateAndRegisterDefinition<Schema extends SchemaType> = {
|
|
|
78
79
|
destinationPath: string;
|
|
79
80
|
/** Function to transform the schema into a generated value */
|
|
80
81
|
schemaToValueFn: SchemaToValueFn;
|
|
81
|
-
/**
|
|
82
|
-
rootRef?:
|
|
82
|
+
/** The ref of the model whose value tree holds the schema */
|
|
83
|
+
rootRef?: RefParts;
|
|
83
84
|
/** Whether to exclude this definition from exports */
|
|
84
85
|
noExport?: boolean;
|
|
85
86
|
};
|
|
@@ -120,8 +121,8 @@ export type AddRenderDependencyArgs = {
|
|
|
120
121
|
export type ToModelSettingsArgs = {
|
|
121
122
|
/** The ID of the generator requesting model settings */
|
|
122
123
|
generatorId: string;
|
|
123
|
-
/** The
|
|
124
|
-
|
|
124
|
+
/** The model's ref */
|
|
125
|
+
ref: RefParts;
|
|
125
126
|
};
|
|
126
127
|
/**
|
|
127
128
|
* Return type for insert operations in the generation context.
|
|
@@ -301,7 +302,7 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
301
302
|
*
|
|
302
303
|
* @mutates this.files
|
|
303
304
|
*/
|
|
304
|
-
insertModel<V extends GeneratedValue, EnrichmentType, ProjectionOptions = undefined>(projection: ModelProjection<V, EnrichmentType, ProjectionOptions>,
|
|
305
|
+
insertModel<V extends GeneratedValue, EnrichmentType, ProjectionOptions = undefined>(projection: ModelProjection<V, EnrichmentType, ProjectionOptions>, ref: RefParts, ...rest: ProjectionOptionsRest<InsertModelOptions<ProjectionOptions>, ProjectionOptions>): Inserted<V, EnrichmentType>;
|
|
305
306
|
/**
|
|
306
307
|
* Build content settings for an operation projection by calling its
|
|
307
308
|
* statics `toIdentifierName` + `toIdentifierType`, `toExportPath`, and
|
|
@@ -319,18 +320,20 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
319
320
|
* Build content settings for a model projection by calling its statics
|
|
320
321
|
* `toIdentifierName` (pure, for the name) + `toIdentifierType`
|
|
321
322
|
* (context-aware, for type/typeName/exported), `toExportPath`, and
|
|
322
|
-
* `toEnrichments` against the given `
|
|
323
|
+
* `toEnrichments` against the given `ref` and `variant`. The full
|
|
323
324
|
* identifier is assembled through the projection's language
|
|
324
325
|
* (`lang.toIdentifier`).
|
|
325
326
|
*/
|
|
326
327
|
toModelContentSettings<V extends GeneratedValue, EnrichmentType, ProjectionOptions>(args: BuildModelSettingsArgs<V, EnrichmentType, ProjectionOptions>): ContentSettings<EnrichmentType>;
|
|
327
328
|
/**
|
|
328
|
-
* Perform one lookup of schema by `refName
|
|
329
|
-
*
|
|
329
|
+
* Perform one lookup of a model's schema: a component by `refName`, or,
|
|
330
|
+
* with a `refPath` other than `#/components/schemas`, the ref target the
|
|
331
|
+
* parser kept under its whole pointer.
|
|
332
|
+
* @param ref - The model's ref; an `OasRef<'schema'>` fits as it is
|
|
330
333
|
* @returns Matching schema or ref
|
|
331
|
-
* @throws {DanglingRefError} when no schema
|
|
334
|
+
* @throws {DanglingRefError} when no schema is found there
|
|
332
335
|
*/
|
|
333
|
-
resolveSchemaRefOnce(
|
|
336
|
+
resolveSchemaRefOnce(ref: RefParts): OasSchema | OasRef<'schema'>;
|
|
334
337
|
/**
|
|
335
338
|
* Check if definition name `name` in file with path `exportPath`
|
|
336
339
|
* has already been created and registered.
|
|
@@ -19,6 +19,7 @@ exports.toModelSource = exports.toGqlOperationSource = exports.toWebhookSource =
|
|
|
19
19
|
const normalizeWorkspacePath_js_1 = require("../helpers/normalizeWorkspacePath.js");
|
|
20
20
|
const applyGeneratedSuffix_js_1 = require("../helpers/applyGeneratedSuffix.js");
|
|
21
21
|
const DanglingRefError_js_1 = require("../oas/ref/DanglingRefError.js");
|
|
22
|
+
const refFns_js_1 = require("../helpers/refFns.js");
|
|
22
23
|
const Method_js_1 = require("../types/Method.js");
|
|
23
24
|
const OasOperationDriver_js_1 = require("../dsl/operation/oas/OasOperationDriver.js");
|
|
24
25
|
const WebhookDriver_js_1 = require("../dsl/webhook/WebhookDriver.js");
|
|
@@ -68,11 +69,11 @@ const EnrichmentWarning_js_1 = require("../enrichments/EnrichmentWarning.js");
|
|
|
68
69
|
*
|
|
69
70
|
* class TypeScriptInterface extends ModelProjectionBase {
|
|
70
71
|
* generate(): Definition {
|
|
71
|
-
* const schema = this.context.
|
|
72
|
+
* const schema = this.context.resolveSchemaRefOnce(this.ref);
|
|
72
73
|
*
|
|
73
74
|
* return new Definition({
|
|
74
75
|
* context: this.context,
|
|
75
|
-
* identifier: createType(this.refName),
|
|
76
|
+
* identifier: createType(this.ref.refName),
|
|
76
77
|
* description: schema.description,
|
|
77
78
|
* value: {
|
|
78
79
|
* generatorKey: this.generatorKey,
|
|
@@ -369,7 +370,7 @@ class GenerateContext {
|
|
|
369
370
|
break;
|
|
370
371
|
}
|
|
371
372
|
case 'model': {
|
|
372
|
-
const models = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this).filter(refName => generatorConfig.isSupported({ refName, context: this, variant: Variant_js_1.DEFAULT_VARIANT }));
|
|
373
|
+
const models = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this).filter(refName => generatorConfig.isSupported({ ref: (0, refFns_js_1.toSchemaComponentRef)(refName), context: this, variant: Variant_js_1.DEFAULT_VARIANT }));
|
|
373
374
|
out[generatorConfig.id] = { type: 'model', models };
|
|
374
375
|
break;
|
|
375
376
|
}
|
|
@@ -450,10 +451,10 @@ class GenerateContext {
|
|
|
450
451
|
// `undefined` for schemas it doesn't seed.
|
|
451
452
|
const models = {};
|
|
452
453
|
for (const refName of __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this)) {
|
|
453
|
-
if (!generatorConfig.isSupported({ refName, context: this, variant: Variant_js_1.DEFAULT_VARIANT })) {
|
|
454
|
+
if (!generatorConfig.isSupported({ ref: (0, refFns_js_1.toSchemaComponentRef)(refName), context: this, variant: Variant_js_1.DEFAULT_VARIANT })) {
|
|
454
455
|
continue;
|
|
455
456
|
}
|
|
456
|
-
const leaf = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_subjectDefaults).call(this, () => toDefaults({ refName, context: this, variant: Variant_js_1.DEFAULT_VARIANT }));
|
|
457
|
+
const leaf = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_subjectDefaults).call(this, () => toDefaults({ ref: (0, refFns_js_1.toSchemaComponentRef)(refName), context: this, variant: Variant_js_1.DEFAULT_VARIANT }));
|
|
457
458
|
if (leaf === undefined)
|
|
458
459
|
continue;
|
|
459
460
|
models[refName] = { [Variant_js_1.DEFAULT_VARIANT]: leaf };
|
|
@@ -654,7 +655,7 @@ class GenerateContext {
|
|
|
654
655
|
insertNormalizedModel(projection, { schema, fallbackName, destinationPath }, ...rest) {
|
|
655
656
|
const insertOptions = (0, InsertOptions_js_1.toPeerInsertOptions)(rest);
|
|
656
657
|
if (schema.isRef()) {
|
|
657
|
-
const { definition } = this.insertModel(projection, schema
|
|
658
|
+
const { definition } = this.insertModel(projection, schema, {
|
|
658
659
|
...insertOptions,
|
|
659
660
|
destinationPath
|
|
660
661
|
});
|
|
@@ -701,14 +702,14 @@ class GenerateContext {
|
|
|
701
702
|
*
|
|
702
703
|
* @mutates this.files
|
|
703
704
|
*/
|
|
704
|
-
insertModel(projection,
|
|
705
|
+
insertModel(projection, ref, ...rest) {
|
|
705
706
|
// The Driver defaults `variant` and `noExport` and reads the caller's
|
|
706
707
|
// options off the call.
|
|
707
708
|
const { settings, definition } = new ModelDriver_js_1.ModelDriver({
|
|
708
709
|
context: this,
|
|
709
710
|
projection,
|
|
710
|
-
|
|
711
|
-
rootRef:
|
|
711
|
+
ref,
|
|
712
|
+
rootRef: ref,
|
|
712
713
|
...(0, InsertOptions_js_1.toInsertOptions)(rest)
|
|
713
714
|
});
|
|
714
715
|
return new Inserted_js_1.Inserted({ settings, definition });
|
|
@@ -815,36 +816,43 @@ class GenerateContext {
|
|
|
815
816
|
* Build content settings for a model projection by calling its statics
|
|
816
817
|
* `toIdentifierName` (pure, for the name) + `toIdentifierType`
|
|
817
818
|
* (context-aware, for type/typeName/exported), `toExportPath`, and
|
|
818
|
-
* `toEnrichments` against the given `
|
|
819
|
+
* `toEnrichments` against the given `ref` and `variant`. The full
|
|
819
820
|
* identifier is assembled through the projection's language
|
|
820
821
|
* (`lang.toIdentifier`).
|
|
821
822
|
*/
|
|
822
823
|
toModelContentSettings(args) {
|
|
823
|
-
const {
|
|
824
|
+
const { ref, projection, variant = Variant_js_1.DEFAULT_VARIANT } = args;
|
|
824
825
|
const options = (0, ProjectionOptions_js_1.readProjectionOptions)(args);
|
|
825
|
-
const enrichments = projection.toEnrichments({
|
|
826
|
+
const enrichments = projection.toEnrichments({ ref, context: this, variant });
|
|
826
827
|
return new ContentSettings_js_1.ContentSettings({
|
|
827
828
|
identifier: projection.lang.toIdentifier({
|
|
828
|
-
name: projection.toIdentifierName({
|
|
829
|
-
...projection.toIdentifierType(
|
|
829
|
+
name: projection.toIdentifierName({ ref, enrichments, variant, options }),
|
|
830
|
+
...projection.toIdentifierType(ref, this)
|
|
830
831
|
}),
|
|
831
|
-
exportPath: __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContentSettingsExportPath).call(this, projection.toExportPath({
|
|
832
|
+
exportPath: __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContentSettingsExportPath).call(this, projection.toExportPath({ ref, enrichments, variant, options }), projection.id),
|
|
832
833
|
enrichments,
|
|
833
834
|
variant
|
|
834
835
|
});
|
|
835
836
|
}
|
|
836
837
|
/**
|
|
837
|
-
* Perform one lookup of schema by `refName
|
|
838
|
-
*
|
|
838
|
+
* Perform one lookup of a model's schema: a component by `refName`, or,
|
|
839
|
+
* with a `refPath` other than `#/components/schemas`, the ref target the
|
|
840
|
+
* parser kept under its whole pointer.
|
|
841
|
+
* @param ref - The model's ref; an `OasRef<'schema'>` fits as it is
|
|
839
842
|
* @returns Matching schema or ref
|
|
840
|
-
* @throws {DanglingRefError} when no schema
|
|
843
|
+
* @throws {DanglingRefError} when no schema is found there
|
|
841
844
|
*/
|
|
842
|
-
resolveSchemaRefOnce(
|
|
845
|
+
resolveSchemaRefOnce(ref) {
|
|
846
|
+
const { refName, refPath } = ref;
|
|
843
847
|
switch (this.document.type) {
|
|
844
848
|
case 'oas': {
|
|
845
|
-
const
|
|
846
|
-
|
|
847
|
-
|
|
849
|
+
const document = this.document.value;
|
|
850
|
+
const component = (0, refFns_js_1.isDefaultRefPath)({ refPath, refType: 'schema' })
|
|
851
|
+
? document.components?.schemas?.[refName]
|
|
852
|
+
: document.toRefTarget((0, refFns_js_1.toRefPointer)({ refName, refPath }));
|
|
853
|
+
// The parser keeps ref targets of every kind; a model is built only from a schema.
|
|
854
|
+
if (component === undefined || !isSchemaEntry(component)) {
|
|
855
|
+
throw new DanglingRefError_js_1.DanglingRefError((0, refFns_js_1.toModelKey)(ref), { remote: (0, refFns_js_1.isRemoteRefPath)(refPath) });
|
|
848
856
|
}
|
|
849
857
|
const target = component.resolveOnce();
|
|
850
858
|
// One step, with what the component adds next to its reference
|
|
@@ -1148,6 +1156,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1148
1156
|
? (document.value.components?.toSchemasRefNames() ?? [])
|
|
1149
1157
|
: document.value.registry.toSchemasRefNames();
|
|
1150
1158
|
refNames.forEach(refName => {
|
|
1159
|
+
const ref = (0, refFns_js_1.toSchemaComponentRef)(refName);
|
|
1151
1160
|
stackTrail.trace(refName, refTrail => {
|
|
1152
1161
|
// Resolve the variant list to fan out over. The consumer's
|
|
1153
1162
|
// enrichments are keyed `[generatorId][refName][variant]`; the
|
|
@@ -1170,7 +1179,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1170
1179
|
refTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
|
|
1171
1180
|
try {
|
|
1172
1181
|
if (typeof generatorConfig.isSupported === 'function' &&
|
|
1173
|
-
!generatorConfig.isSupported({
|
|
1182
|
+
!generatorConfig.isSupported({ ref, context: this, variant })) {
|
|
1174
1183
|
this.captureCurrentResult('notSupported', st);
|
|
1175
1184
|
return;
|
|
1176
1185
|
}
|
|
@@ -1199,7 +1208,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1199
1208
|
}
|
|
1200
1209
|
generatorConfig.transform({
|
|
1201
1210
|
context: this,
|
|
1202
|
-
|
|
1211
|
+
ref,
|
|
1203
1212
|
variant
|
|
1204
1213
|
});
|
|
1205
1214
|
const source = (0, exports.toModelSource)({
|
|
@@ -1207,7 +1216,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1207
1216
|
generatorId: generatorConfig.id,
|
|
1208
1217
|
variant
|
|
1209
1218
|
});
|
|
1210
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this,
|
|
1219
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, ref, variant }));
|
|
1211
1220
|
this.captureCurrentResult('success', st);
|
|
1212
1221
|
}
|
|
1213
1222
|
catch (error) {
|
|
@@ -1488,3 +1497,5 @@ const toIncludeModels = (include, generatorId) => {
|
|
|
1488
1497
|
}
|
|
1489
1498
|
return undefined;
|
|
1490
1499
|
};
|
|
1500
|
+
/** Whether a ref target is a schema, or a ref to one: what a model is built from. */
|
|
1501
|
+
const isSchemaEntry = (entry) => entry.isRef() ? entry.isSchemaRef() : entry.oasType === 'schema';
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _ParseContext_instances, _ParseContext_refConsumers, _ParseContext_refErrors, _ParseContext_oasRefs, _ParseContext_rootFrames, _ParseContext_removeComponent, _ParseContext_removeConsumer, _ParseContext_removePathParameterConsumer,
|
|
13
|
+
var _ParseContext_instances, _ParseContext_refConsumers, _ParseContext_refErrors, _ParseContext_oasRefs, _ParseContext_refTargets, _ParseContext_refTarget, _ParseContext_issueIdentities, _ParseContext_rootFrames, _ParseContext_removeComponent, _ParseContext_parseRefTargets, _ParseContext_inRefTarget, _ParseContext_addIssue, _ParseContext_removeConsumer, _ParseContext_removePathParameterConsumer, _ParseContext_logDependencyIssue, _ParseContext_toDocumentTrail, _ParseContext_checkRefs, _ParseContext_toRefError, _ParseContext_toLoopOf, _ParseContext_removeHolder;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ParseContext = void 0;
|
|
16
16
|
/**
|
|
@@ -44,20 +44,52 @@ const StackTrail_js_1 = require("./StackTrail.js");
|
|
|
44
44
|
const isPlainObject_js_1 = require("../parse/isPlainObject.js");
|
|
45
45
|
const pathParameters_js_1 = require("../parse/pathParameters.js");
|
|
46
46
|
const SerializedError_js_1 = require("../types/SerializedError.js");
|
|
47
|
+
const tryParseAt_js_1 = require("./tryParseAt.js");
|
|
47
48
|
const DanglingRefError_js_1 = require("../oas/ref/DanglingRefError.js");
|
|
48
49
|
const refFns_js_1 = require("../helpers/refFns.js");
|
|
50
|
+
const toRefTargetV3_js_1 = require("../parse/v3-0/ref/toRefTargetV3.js");
|
|
51
|
+
const toRefTargetV3_js_2 = require("../parse/v3-1/ref/toRefTargetV3.js");
|
|
52
|
+
const toRefTargetV3_js_3 = require("../parse/v3-2/ref/toRefTargetV3.js");
|
|
49
53
|
/**
|
|
50
|
-
* The key a `$ref`'s consumers and errors are kept under. A
|
|
51
|
-
* `#/components/<bucket
|
|
52
|
-
*
|
|
54
|
+
* The key a `$ref`'s consumers and errors are kept under. A component ref
|
|
55
|
+
* (`#/components/<bucket>/<name>`) is keyed by the name it resolves,
|
|
56
|
+
* unescaped, which is the key `StackTrail.toStackRef()` gives that
|
|
53
57
|
* component's own errors: `#/components/schemas/Foo%20Bar` is kept under
|
|
54
|
-
* `#/components/schemas/Foo Bar`. Any other
|
|
58
|
+
* `#/components/schemas/Foo Bar`. Any other ref is keyed by its whole
|
|
59
|
+
* pointer in one spelling (`toRefPointer`), which is also the key its
|
|
60
|
+
* parsed target is kept under.
|
|
55
61
|
*/
|
|
56
|
-
const toRefKey = (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return bucket === undefined ? $ref : `#/components/${bucket}/${(0, refFns_js_1.toRefName)($ref)}`;
|
|
62
|
+
const toRefKey = ({ refName, refPath }) => {
|
|
63
|
+
const bucket = (0, refFns_js_1.toRefPathBucket)(refPath);
|
|
64
|
+
return bucket === undefined ? (0, refFns_js_1.toRefPointer)({ refName, refPath }) : `#/components/${bucket}/${refName}`;
|
|
60
65
|
};
|
|
66
|
+
/** The issue logged when a ref target's parser throws. */
|
|
67
|
+
const toInvalidType = (refType) => {
|
|
68
|
+
switch (refType) {
|
|
69
|
+
case 'schema':
|
|
70
|
+
return 'INVALID_SCHEMA';
|
|
71
|
+
case 'requestBody':
|
|
72
|
+
return 'INVALID_REQUEST_BODY';
|
|
73
|
+
case 'parameter':
|
|
74
|
+
return 'INVALID_PARAMETER';
|
|
75
|
+
case 'response':
|
|
76
|
+
case 'link':
|
|
77
|
+
// A link has no type of its own: in the document's walk its response reports it.
|
|
78
|
+
return 'INVALID_RESPONSE';
|
|
79
|
+
case 'example':
|
|
80
|
+
return 'INVALID_EXAMPLE';
|
|
81
|
+
case 'header':
|
|
82
|
+
return 'INVALID_HEADER';
|
|
83
|
+
case 'securityScheme':
|
|
84
|
+
return 'INVALID_SECURITY_SCHEME';
|
|
85
|
+
default: {
|
|
86
|
+
const _exhaustive = refType;
|
|
87
|
+
throw new Error(`Unhandled ref type: ${_exhaustive}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
/** Two issues with the same level, type, location and message are the same issue. */
|
|
92
|
+
const toIssueIdentity = (issue) => [issue.level, issue.type, issue.location, issue.message].join('\u0000');
|
|
61
93
|
/** The stored form of an issue: an error's `cause` as a `SerializedError`. */
|
|
62
94
|
const toParseIssue = (issue) => {
|
|
63
95
|
if (issue.level !== 'error') {
|
|
@@ -134,6 +166,16 @@ class ParseContext {
|
|
|
134
166
|
);
|
|
135
167
|
/** Each OAS ref and the place it is written, which `#checkRefs` resolves once the document is parsed. */
|
|
136
168
|
_ParseContext_oasRefs.set(this, []
|
|
169
|
+
/** The key (`toRefKey`) of each ref target `#parseRefTargets` parsed. */
|
|
170
|
+
);
|
|
171
|
+
/** The key (`toRefKey`) of each ref target `#parseRefTargets` parsed. */
|
|
172
|
+
_ParseContext_refTargets.set(this, new Set()
|
|
173
|
+
/** The key of the ref target `#inRefTarget` runs for; `undefined` in the document's own walk. */
|
|
174
|
+
);
|
|
175
|
+
/** The key of the ref target `#inRefTarget` runs for; `undefined` in the document's own walk. */
|
|
176
|
+
_ParseContext_refTarget.set(this, void 0);
|
|
177
|
+
/** What identifies each issue logged so far (`toIssueIdentity`). */
|
|
178
|
+
_ParseContext_issueIdentities.set(this, new Set()
|
|
137
179
|
/**
|
|
138
180
|
* Frames of the trail `parse()` was called with (`[traceId, spanId,
|
|
139
181
|
* 'parse']` through `toArtifacts`). Every trail built during the walk
|
|
@@ -263,6 +305,7 @@ class ParseContext {
|
|
|
263
305
|
stackTrail,
|
|
264
306
|
context: this
|
|
265
307
|
});
|
|
308
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_parseRefTargets).call(this, toRefTargetV3_js_1.toRefTargetV3);
|
|
266
309
|
break;
|
|
267
310
|
case '3.1':
|
|
268
311
|
oasState.oasDocument.fields = (0, toDocumentFieldsV3_js_2.toDocumentFieldsV3)({
|
|
@@ -270,6 +313,7 @@ class ParseContext {
|
|
|
270
313
|
stackTrail,
|
|
271
314
|
context: this
|
|
272
315
|
});
|
|
316
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_parseRefTargets).call(this, toRefTargetV3_js_2.toRefTargetV3);
|
|
273
317
|
break;
|
|
274
318
|
case '3.2':
|
|
275
319
|
oasState.oasDocument.fields = (0, toDocumentFieldsV3_js_3.toDocumentFieldsV3)({
|
|
@@ -277,6 +321,7 @@ class ParseContext {
|
|
|
277
321
|
stackTrail,
|
|
278
322
|
context: this
|
|
279
323
|
});
|
|
324
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_parseRefTargets).call(this, toRefTargetV3_js_3.toRefTargetV3);
|
|
280
325
|
break;
|
|
281
326
|
default: {
|
|
282
327
|
const _exhaustive = dialect;
|
|
@@ -330,7 +375,15 @@ class ParseContext {
|
|
|
330
375
|
pending.forEach(({ refKey }) => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeComponent).call(this, refKey));
|
|
331
376
|
// `pending` grows while it is walked: each removed component queues its own consumers.
|
|
332
377
|
for (const { refKey, rootCause } of pending) {
|
|
333
|
-
for (const consumer of __classPrivateFieldGet(this, _ParseContext_refConsumers, "f").get(refKey) ?? []) {
|
|
378
|
+
for (const { consumer, refTarget } of __classPrivateFieldGet(this, _ParseContext_refConsumers, "f").get(refKey) ?? []) {
|
|
379
|
+
// The ref is inside a ref target: the target is removed, and what refers to it next.
|
|
380
|
+
if (refTarget !== undefined) {
|
|
381
|
+
if (this.oasDocument.removeRefTarget(refTarget) !== undefined) {
|
|
382
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_inRefTarget).call(this, refTarget, () => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDependencyIssue).call(this, { location: consumer.toString(), refKey, rootCause }));
|
|
383
|
+
pending.push({ refKey: refTarget, rootCause });
|
|
384
|
+
}
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
334
387
|
const documentTrail = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, consumer);
|
|
335
388
|
const removedLocations = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeConsumer).call(this, consumer, documentTrail);
|
|
336
389
|
removedLocations.forEach(location => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDependencyIssue).call(this, { location, refKey, rootCause }));
|
|
@@ -375,12 +428,13 @@ class ParseContext {
|
|
|
375
428
|
* would use type names or qualified field paths.
|
|
376
429
|
*/
|
|
377
430
|
registerRef(consumer, refKey) {
|
|
431
|
+
const refConsumer = { consumer, refTarget: __classPrivateFieldGet(this, _ParseContext_refTarget, "f") };
|
|
378
432
|
const existing = __classPrivateFieldGet(this, _ParseContext_refConsumers, "f").get(refKey);
|
|
379
433
|
if (existing) {
|
|
380
|
-
existing.push(
|
|
434
|
+
existing.push(refConsumer);
|
|
381
435
|
}
|
|
382
436
|
else {
|
|
383
|
-
__classPrivateFieldGet(this, _ParseContext_refConsumers, "f").set(refKey, [
|
|
437
|
+
__classPrivateFieldGet(this, _ParseContext_refConsumers, "f").set(refKey, [refConsumer]);
|
|
384
438
|
}
|
|
385
439
|
}
|
|
386
440
|
/**
|
|
@@ -390,8 +444,8 @@ class ParseContext {
|
|
|
390
444
|
* resolve it there.
|
|
391
445
|
*/
|
|
392
446
|
registerOasRef(consumer, ref) {
|
|
393
|
-
this.registerRef(consumer, toRefKey(ref
|
|
394
|
-
__classPrivateFieldGet(this, _ParseContext_oasRefs, "f").push({ consumer, ref });
|
|
447
|
+
this.registerRef(consumer, toRefKey(ref));
|
|
448
|
+
__classPrivateFieldGet(this, _ParseContext_oasRefs, "f").push({ consumer, ref, refTarget: __classPrivateFieldGet(this, _ParseContext_refTarget, "f") });
|
|
395
449
|
}
|
|
396
450
|
/**
|
|
397
451
|
* What a merge reads in place of a `$ref` that names nothing: an `allOf`
|
|
@@ -451,8 +505,8 @@ class ParseContext {
|
|
|
451
505
|
* manifest).
|
|
452
506
|
*/
|
|
453
507
|
logIssueAt(issue, parent) {
|
|
454
|
-
this.
|
|
455
|
-
if (!this.silent) {
|
|
508
|
+
const added = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_addIssue).call(this, toParseIssue(issue));
|
|
509
|
+
if (added && !this.silent) {
|
|
456
510
|
this.logger.warn({
|
|
457
511
|
protocol: issue.protocol,
|
|
458
512
|
level: issue.level,
|
|
@@ -486,7 +540,7 @@ class ParseContext {
|
|
|
486
540
|
// points at. No-op for non-component trails (and for GQL
|
|
487
541
|
// trails) because `toStackRef` returns `undefined` and
|
|
488
542
|
// `registerRefError` ignores undefined refs.
|
|
489
|
-
this.registerRefError(issue.cause ?? issue.message, __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, stackTrail).toStackRef(), location);
|
|
543
|
+
this.registerRefError(issue.cause ?? issue.message, __classPrivateFieldGet(this, _ParseContext_refTarget, "f") ?? __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, stackTrail).toStackRef(), location);
|
|
490
544
|
this.logIssueAt({
|
|
491
545
|
protocol,
|
|
492
546
|
level: 'error',
|
|
@@ -569,14 +623,65 @@ class ParseContext {
|
|
|
569
623
|
}
|
|
570
624
|
}
|
|
571
625
|
exports.ParseContext = ParseContext;
|
|
572
|
-
_ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMap(), _ParseContext_oasRefs = new WeakMap(), _ParseContext_rootFrames = new WeakMap(), _ParseContext_instances = new WeakSet(), _ParseContext_removeComponent = function _ParseContext_removeComponent(refKey) {
|
|
626
|
+
_ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMap(), _ParseContext_oasRefs = new WeakMap(), _ParseContext_refTargets = new WeakMap(), _ParseContext_refTarget = new WeakMap(), _ParseContext_issueIdentities = new WeakMap(), _ParseContext_rootFrames = new WeakMap(), _ParseContext_instances = new WeakSet(), _ParseContext_removeComponent = function _ParseContext_removeComponent(refKey) {
|
|
573
627
|
if (this.protocol.type !== 'oas') {
|
|
574
628
|
return;
|
|
575
629
|
}
|
|
630
|
+
if (__classPrivateFieldGet(this, _ParseContext_refTargets, "f").has(refKey)) {
|
|
631
|
+
this.protocol.oasDocument.removeRefTarget(refKey);
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
576
634
|
const match = /^#\/components\/([^/]+)\/(.+)$/.exec(refKey);
|
|
577
635
|
if (match) {
|
|
578
636
|
this.protocol.oasDocument.removeItem(new StackTrail_js_1.StackTrail(['components', match[1], match[2]]));
|
|
579
637
|
}
|
|
638
|
+
}, _ParseContext_parseRefTargets = function _ParseContext_parseRefTargets(toRefTarget) {
|
|
639
|
+
if (this.protocol.type !== 'oas') {
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
const { oasDocument, documentObject } = this.protocol;
|
|
643
|
+
for (const { ref } of __classPrivateFieldGet(this, _ParseContext_oasRefs, "f")) {
|
|
644
|
+
const key = toRefKey(ref);
|
|
645
|
+
// A ref to a component, of its own kind or not, is resolved in
|
|
646
|
+
// `components`; `#checkRefs` reports one of the wrong kind.
|
|
647
|
+
if (ref.refName === '' || (0, refFns_js_1.toRefPathBucket)(ref.refPath) !== undefined || __classPrivateFieldGet(this, _ParseContext_refTargets, "f").has(key)) {
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
const value = (0, refFns_js_1.toRawRefTarget)(documentObject, ref);
|
|
651
|
+
if (!(0, isPlainObject_js_1.isPlainObject)(value)) {
|
|
652
|
+
continue;
|
|
653
|
+
}
|
|
654
|
+
__classPrivateFieldGet(this, _ParseContext_refTargets, "f").add(key);
|
|
655
|
+
const parent = new StackTrail_js_1.StackTrail([...__classPrivateFieldGet(this, _ParseContext_rootFrames, "f"), ...(0, refFns_js_1.toRefPathSegments)(ref.refPath)]);
|
|
656
|
+
const target = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_inRefTarget).call(this, key, () => (0, tryParseAt_js_1.tryParseAt)({
|
|
657
|
+
stackTrail: parent,
|
|
658
|
+
key: ref.refName,
|
|
659
|
+
context: this,
|
|
660
|
+
type: toInvalidType(ref.refType),
|
|
661
|
+
parent: value,
|
|
662
|
+
fn: () => toRefTarget({ refType: ref.refType, name: ref.refName, value, stackTrail: parent, context: this })
|
|
663
|
+
}));
|
|
664
|
+
if (target !== undefined) {
|
|
665
|
+
oasDocument.setRefTarget(key, target);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}, _ParseContext_inRefTarget = function _ParseContext_inRefTarget(key, fn) {
|
|
669
|
+
const previous = __classPrivateFieldGet(this, _ParseContext_refTarget, "f");
|
|
670
|
+
__classPrivateFieldSet(this, _ParseContext_refTarget, key, "f");
|
|
671
|
+
try {
|
|
672
|
+
return fn();
|
|
673
|
+
}
|
|
674
|
+
finally {
|
|
675
|
+
__classPrivateFieldSet(this, _ParseContext_refTarget, previous, "f");
|
|
676
|
+
}
|
|
677
|
+
}, _ParseContext_addIssue = function _ParseContext_addIssue(issue) {
|
|
678
|
+
const identity = toIssueIdentity(issue);
|
|
679
|
+
if (__classPrivateFieldGet(this, _ParseContext_refTarget, "f") !== undefined && __classPrivateFieldGet(this, _ParseContext_issueIdentities, "f").has(identity)) {
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
__classPrivateFieldGet(this, _ParseContext_issueIdentities, "f").add(identity);
|
|
683
|
+
this.issues.push(issue);
|
|
684
|
+
return true;
|
|
580
685
|
}, _ParseContext_removeConsumer = function _ParseContext_removeConsumer(consumer, documentTrail) {
|
|
581
686
|
switch (this.protocol.type) {
|
|
582
687
|
case 'oas': {
|
|
@@ -615,7 +720,9 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
615
720
|
: [];
|
|
616
721
|
const rawEntry = rawEntries[Number(index)];
|
|
617
722
|
const entryRef = (0, isPlainObject_js_1.isPlainObject)(rawEntry) && typeof rawEntry.$ref === 'string' ? rawEntry.$ref : undefined;
|
|
618
|
-
const nameAndIn = (0, pathParameters_js_1.toNameAndIn)(entryRef === undefined
|
|
723
|
+
const nameAndIn = (0, pathParameters_js_1.toNameAndIn)(entryRef === undefined
|
|
724
|
+
? rawEntry
|
|
725
|
+
: (0, refFns_js_1.toRawRefTarget)(documentObject, (0, refFns_js_1.toRefParts)({ $ref: entryRef })));
|
|
619
726
|
const broken = [{ location: documentTrail.toString(), message: '', ...nameAndIn }];
|
|
620
727
|
const operations = first === 'paths'
|
|
621
728
|
? oasDocument.operations.filter(({ path }) => path === second)
|
|
@@ -637,13 +744,6 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
637
744
|
: [new StackTrail_js_1.StackTrail([...prefix, first, second, method]).toString()];
|
|
638
745
|
});
|
|
639
746
|
return removedLocations;
|
|
640
|
-
}, _ParseContext_toRawComponentParameter = function _ParseContext_toRawComponentParameter($ref) {
|
|
641
|
-
if (this.protocol.type !== 'oas') {
|
|
642
|
-
return undefined;
|
|
643
|
-
}
|
|
644
|
-
const match = /^#\/components\/parameters\/(.+)$/.exec($ref);
|
|
645
|
-
const parameters = this.protocol.documentObject.components?.parameters;
|
|
646
|
-
return match && (0, isPlainObject_js_1.isPlainObject)(parameters) ? parameters[match[1]] : undefined;
|
|
647
747
|
}, _ParseContext_logDependencyIssue = function _ParseContext_logDependencyIssue({ location, refKey, rootCause }) {
|
|
648
748
|
const { error } = rootCause;
|
|
649
749
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -651,7 +751,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
651
751
|
const message = `Depends on '${refKey}', removed because of the error${at}: ${errorMessage}`;
|
|
652
752
|
switch (this.protocol.type) {
|
|
653
753
|
case 'oas':
|
|
654
|
-
this.
|
|
754
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_addIssue).call(this, {
|
|
655
755
|
protocol: 'oas',
|
|
656
756
|
level: 'error',
|
|
657
757
|
type: 'INVALID_DEPENDENCY_REF',
|
|
@@ -661,7 +761,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
661
761
|
});
|
|
662
762
|
break;
|
|
663
763
|
case 'gql':
|
|
664
|
-
this.
|
|
764
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_addIssue).call(this, {
|
|
665
765
|
protocol: 'gql',
|
|
666
766
|
level: 'error',
|
|
667
767
|
type: 'INVALID_DEPENDENCY_REF',
|
|
@@ -683,8 +783,8 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
683
783
|
rootFrames.every((frame, index) => frames[index] === frame);
|
|
684
784
|
return startsWithRoot ? new StackTrail_js_1.StackTrail(frames.slice(rootFrames.length)) : stackTrail;
|
|
685
785
|
}, _ParseContext_checkRefs = function _ParseContext_checkRefs() {
|
|
686
|
-
__classPrivateFieldGet(this, _ParseContext_oasRefs, "f").forEach(({ consumer, ref }) => {
|
|
687
|
-
if (__classPrivateFieldGet(this, _ParseContext_refErrors, "f").has(toRefKey(ref
|
|
786
|
+
__classPrivateFieldGet(this, _ParseContext_oasRefs, "f").forEach(({ consumer, ref, refTarget }) => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_inRefTarget).call(this, refTarget, () => {
|
|
787
|
+
if (__classPrivateFieldGet(this, _ParseContext_refErrors, "f").has(toRefKey(ref))) {
|
|
688
788
|
return;
|
|
689
789
|
}
|
|
690
790
|
const error = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toRefError).call(this, ref);
|
|
@@ -694,6 +794,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
694
794
|
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeHolder).call(this, {
|
|
695
795
|
consumer,
|
|
696
796
|
ref,
|
|
797
|
+
refTarget,
|
|
697
798
|
error,
|
|
698
799
|
type: 'REF_TYPE_MISMATCH',
|
|
699
800
|
message: `${message}, so what holds it is removed.`
|
|
@@ -712,13 +813,14 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
712
813
|
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeHolder).call(this, {
|
|
713
814
|
consumer,
|
|
714
815
|
ref,
|
|
816
|
+
refTarget,
|
|
715
817
|
error,
|
|
716
818
|
type: 'DANGLING_REF',
|
|
717
819
|
message: `${error.message}, so what holds it is removed. To keep it, list '${ref.refType}' in system.danglingRefs.`
|
|
718
820
|
});
|
|
719
821
|
}
|
|
720
822
|
}
|
|
721
|
-
});
|
|
823
|
+
}));
|
|
722
824
|
}, _ParseContext_toRefError = function _ParseContext_toRefError(ref) {
|
|
723
825
|
try {
|
|
724
826
|
ref.resolveOnce();
|
|
@@ -737,7 +839,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
737
839
|
// A ref further on names nothing or the wrong kind: it reports that itself.
|
|
738
840
|
return undefined;
|
|
739
841
|
}
|
|
740
|
-
}, _ParseContext_removeHolder = function _ParseContext_removeHolder({ consumer, ref, error, type, message }) {
|
|
842
|
+
}, _ParseContext_removeHolder = function _ParseContext_removeHolder({ consumer, ref, refTarget, error, type, message }) {
|
|
741
843
|
this.logIssueNoKey({
|
|
742
844
|
level: 'error',
|
|
743
845
|
message,
|
|
@@ -747,7 +849,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
747
849
|
type
|
|
748
850
|
});
|
|
749
851
|
const documentTrail = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, consumer);
|
|
750
|
-
if (documentTrail.toStackRef() !== undefined) {
|
|
852
|
+
if (refTarget !== undefined || documentTrail.toStackRef() !== undefined) {
|
|
751
853
|
return;
|
|
752
854
|
}
|
|
753
855
|
const location = consumer.toString();
|