@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
package/esm/anchors/attribute.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { fromGeneratorKey, toGeneratorId } from '../dsl/GeneratorKeys.js';
|
|
16
16
|
import { DefinitionBase } from '../dsl/Definition.js';
|
|
17
|
+
import { toRefPointer } from '../helpers/refFns.js';
|
|
17
18
|
/**
|
|
18
19
|
* Derive the attribution tuple for a producer.
|
|
19
20
|
*
|
|
@@ -53,7 +54,7 @@ export const attribute = (producer) => {
|
|
|
53
54
|
*
|
|
54
55
|
* - OAS operation → `#/paths/<escaped-path>/<method>`
|
|
55
56
|
* - GQL operation → `<rootKind>.<fieldName>`
|
|
56
|
-
* - Model → `#/components/schemas/<refName>`
|
|
57
|
+
* - Model → its ref's pointer: `#/components/schemas/<refName>` for a component
|
|
57
58
|
* - Container / generator-only / no key → `''` (no schema location to point
|
|
58
59
|
* at — a container is a place many subjects insert into, so it has no
|
|
59
60
|
* position of its own; its MEMBERS carry their subjects' keys)
|
|
@@ -69,7 +70,7 @@ const schemaPointerFromKey = (parsed) => {
|
|
|
69
70
|
case 'gqlOperation':
|
|
70
71
|
return `${parsed.rootKind}.${parsed.fieldName}`;
|
|
71
72
|
case 'model':
|
|
72
|
-
return
|
|
73
|
+
return toRefPointer(parsed.ref);
|
|
73
74
|
case 'container':
|
|
74
75
|
case 'generator-only':
|
|
75
76
|
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',
|
|
@@ -261,7 +261,7 @@ export class CoreContext {
|
|
|
261
261
|
* toGeneratorConfigMap: () => ({
|
|
262
262
|
* 'typescript-models': toModelEntry({
|
|
263
263
|
* id: 'typescript-models',
|
|
264
|
-
* transform: ({ context,
|
|
264
|
+
* transform: ({ context, ref }) => {}
|
|
265
265
|
* }),
|
|
266
266
|
* 'api-client': toOasOperationEntry({
|
|
267
267
|
* 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.
|
|
@@ -13,6 +13,7 @@ var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_failedI
|
|
|
13
13
|
import { normalizeWorkspacePath } from '../helpers/normalizeWorkspacePath.js';
|
|
14
14
|
import { applyGeneratedSuffix, DEFAULT_GENERATED_SUFFIX } from '../helpers/applyGeneratedSuffix.js';
|
|
15
15
|
import { DanglingRefError } from '../oas/ref/DanglingRefError.js';
|
|
16
|
+
import { isDefaultRefPath, isRemoteRefPath, toModelKey, toRefPointer, toSchemaComponentRef } from '../helpers/refFns.js';
|
|
16
17
|
import { isMethod } from '../types/Method.js';
|
|
17
18
|
import { OasOperationDriver } from '../dsl/operation/oas/OasOperationDriver.js';
|
|
18
19
|
import { WebhookDriver } from '../dsl/webhook/WebhookDriver.js';
|
|
@@ -62,11 +63,11 @@ import { formatEnrichmentPath } from '../enrichments/EnrichmentWarning.js';
|
|
|
62
63
|
*
|
|
63
64
|
* class TypeScriptInterface extends ModelProjectionBase {
|
|
64
65
|
* generate(): Definition {
|
|
65
|
-
* const schema = this.context.
|
|
66
|
+
* const schema = this.context.resolveSchemaRefOnce(this.ref);
|
|
66
67
|
*
|
|
67
68
|
* return new Definition({
|
|
68
69
|
* context: this.context,
|
|
69
|
-
* identifier: createType(this.refName),
|
|
70
|
+
* identifier: createType(this.ref.refName),
|
|
70
71
|
* description: schema.description,
|
|
71
72
|
* value: {
|
|
72
73
|
* generatorKey: this.generatorKey,
|
|
@@ -363,7 +364,7 @@ export class GenerateContext {
|
|
|
363
364
|
break;
|
|
364
365
|
}
|
|
365
366
|
case 'model': {
|
|
366
|
-
const models = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this).filter(refName => generatorConfig.isSupported({ refName, context: this, variant: DEFAULT_VARIANT }));
|
|
367
|
+
const models = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this).filter(refName => generatorConfig.isSupported({ ref: toSchemaComponentRef(refName), context: this, variant: DEFAULT_VARIANT }));
|
|
367
368
|
out[generatorConfig.id] = { type: 'model', models };
|
|
368
369
|
break;
|
|
369
370
|
}
|
|
@@ -444,10 +445,10 @@ export class GenerateContext {
|
|
|
444
445
|
// `undefined` for schemas it doesn't seed.
|
|
445
446
|
const models = {};
|
|
446
447
|
for (const refName of __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_schemaRefNames).call(this)) {
|
|
447
|
-
if (!generatorConfig.isSupported({ refName, context: this, variant: DEFAULT_VARIANT })) {
|
|
448
|
+
if (!generatorConfig.isSupported({ ref: toSchemaComponentRef(refName), context: this, variant: DEFAULT_VARIANT })) {
|
|
448
449
|
continue;
|
|
449
450
|
}
|
|
450
|
-
const leaf = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_subjectDefaults).call(this, () => toDefaults({ refName, context: this, variant: DEFAULT_VARIANT }));
|
|
451
|
+
const leaf = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_subjectDefaults).call(this, () => toDefaults({ ref: toSchemaComponentRef(refName), context: this, variant: DEFAULT_VARIANT }));
|
|
451
452
|
if (leaf === undefined)
|
|
452
453
|
continue;
|
|
453
454
|
models[refName] = { [DEFAULT_VARIANT]: leaf };
|
|
@@ -648,7 +649,7 @@ export class GenerateContext {
|
|
|
648
649
|
insertNormalizedModel(projection, { schema, fallbackName, destinationPath }, ...rest) {
|
|
649
650
|
const insertOptions = toPeerInsertOptions(rest);
|
|
650
651
|
if (schema.isRef()) {
|
|
651
|
-
const { definition } = this.insertModel(projection, schema
|
|
652
|
+
const { definition } = this.insertModel(projection, schema, {
|
|
652
653
|
...insertOptions,
|
|
653
654
|
destinationPath
|
|
654
655
|
});
|
|
@@ -695,14 +696,14 @@ export class GenerateContext {
|
|
|
695
696
|
*
|
|
696
697
|
* @mutates this.files
|
|
697
698
|
*/
|
|
698
|
-
insertModel(projection,
|
|
699
|
+
insertModel(projection, ref, ...rest) {
|
|
699
700
|
// The Driver defaults `variant` and `noExport` and reads the caller's
|
|
700
701
|
// options off the call.
|
|
701
702
|
const { settings, definition } = new ModelDriver({
|
|
702
703
|
context: this,
|
|
703
704
|
projection,
|
|
704
|
-
|
|
705
|
-
rootRef:
|
|
705
|
+
ref,
|
|
706
|
+
rootRef: ref,
|
|
706
707
|
...toInsertOptions(rest)
|
|
707
708
|
});
|
|
708
709
|
return new Inserted({ settings, definition });
|
|
@@ -809,36 +810,43 @@ export class GenerateContext {
|
|
|
809
810
|
* Build content settings for a model projection by calling its statics
|
|
810
811
|
* `toIdentifierName` (pure, for the name) + `toIdentifierType`
|
|
811
812
|
* (context-aware, for type/typeName/exported), `toExportPath`, and
|
|
812
|
-
* `toEnrichments` against the given `
|
|
813
|
+
* `toEnrichments` against the given `ref` and `variant`. The full
|
|
813
814
|
* identifier is assembled through the projection's language
|
|
814
815
|
* (`lang.toIdentifier`).
|
|
815
816
|
*/
|
|
816
817
|
toModelContentSettings(args) {
|
|
817
|
-
const {
|
|
818
|
+
const { ref, projection, variant = DEFAULT_VARIANT } = args;
|
|
818
819
|
const options = readProjectionOptions(args);
|
|
819
|
-
const enrichments = projection.toEnrichments({
|
|
820
|
+
const enrichments = projection.toEnrichments({ ref, context: this, variant });
|
|
820
821
|
return new ContentSettings({
|
|
821
822
|
identifier: projection.lang.toIdentifier({
|
|
822
|
-
name: projection.toIdentifierName({
|
|
823
|
-
...projection.toIdentifierType(
|
|
823
|
+
name: projection.toIdentifierName({ ref, enrichments, variant, options }),
|
|
824
|
+
...projection.toIdentifierType(ref, this)
|
|
824
825
|
}),
|
|
825
|
-
exportPath: __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContentSettingsExportPath).call(this, projection.toExportPath({
|
|
826
|
+
exportPath: __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContentSettingsExportPath).call(this, projection.toExportPath({ ref, enrichments, variant, options }), projection.id),
|
|
826
827
|
enrichments,
|
|
827
828
|
variant
|
|
828
829
|
});
|
|
829
830
|
}
|
|
830
831
|
/**
|
|
831
|
-
* Perform one lookup of schema by `refName
|
|
832
|
-
*
|
|
832
|
+
* Perform one lookup of a model's schema: a component by `refName`, or,
|
|
833
|
+
* with a `refPath` other than `#/components/schemas`, the ref target the
|
|
834
|
+
* parser kept under its whole pointer.
|
|
835
|
+
* @param ref - The model's ref; an `OasRef<'schema'>` fits as it is
|
|
833
836
|
* @returns Matching schema or ref
|
|
834
|
-
* @throws {DanglingRefError} when no schema
|
|
837
|
+
* @throws {DanglingRefError} when no schema is found there
|
|
835
838
|
*/
|
|
836
|
-
resolveSchemaRefOnce(
|
|
839
|
+
resolveSchemaRefOnce(ref) {
|
|
840
|
+
const { refName, refPath } = ref;
|
|
837
841
|
switch (this.document.type) {
|
|
838
842
|
case 'oas': {
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
|
|
843
|
+
const document = this.document.value;
|
|
844
|
+
const component = isDefaultRefPath({ refPath, refType: 'schema' })
|
|
845
|
+
? document.components?.schemas?.[refName]
|
|
846
|
+
: document.toRefTarget(toRefPointer({ refName, refPath }));
|
|
847
|
+
// The parser keeps ref targets of every kind; a model is built only from a schema.
|
|
848
|
+
if (component === undefined || !isSchemaEntry(component)) {
|
|
849
|
+
throw new DanglingRefError(toModelKey(ref), { remote: isRemoteRefPath(refPath) });
|
|
842
850
|
}
|
|
843
851
|
const target = component.resolveOnce();
|
|
844
852
|
// One step, with what the component adds next to its reference
|
|
@@ -1141,6 +1149,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1141
1149
|
? (document.value.components?.toSchemasRefNames() ?? [])
|
|
1142
1150
|
: document.value.registry.toSchemasRefNames();
|
|
1143
1151
|
refNames.forEach(refName => {
|
|
1152
|
+
const ref = toSchemaComponentRef(refName);
|
|
1144
1153
|
stackTrail.trace(refName, refTrail => {
|
|
1145
1154
|
// Resolve the variant list to fan out over. The consumer's
|
|
1146
1155
|
// enrichments are keyed `[generatorId][refName][variant]`; the
|
|
@@ -1163,7 +1172,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1163
1172
|
refTrail.trace(['variant', variant], st => this.withSubjectTrail(st, () => {
|
|
1164
1173
|
try {
|
|
1165
1174
|
if (typeof generatorConfig.isSupported === 'function' &&
|
|
1166
|
-
!generatorConfig.isSupported({
|
|
1175
|
+
!generatorConfig.isSupported({ ref, context: this, variant })) {
|
|
1167
1176
|
this.captureCurrentResult('notSupported', st);
|
|
1168
1177
|
return;
|
|
1169
1178
|
}
|
|
@@ -1192,7 +1201,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1192
1201
|
}
|
|
1193
1202
|
generatorConfig.transform({
|
|
1194
1203
|
context: this,
|
|
1195
|
-
|
|
1204
|
+
ref,
|
|
1196
1205
|
variant
|
|
1197
1206
|
});
|
|
1198
1207
|
const source = toModelSource({
|
|
@@ -1200,7 +1209,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1200
1209
|
generatorId: generatorConfig.id,
|
|
1201
1210
|
variant
|
|
1202
1211
|
});
|
|
1203
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this,
|
|
1212
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, source, generatorConfig.toPreviewModule?.({ context: this, ref, variant }));
|
|
1204
1213
|
this.captureCurrentResult('success', st);
|
|
1205
1214
|
}
|
|
1206
1215
|
catch (error) {
|
|
@@ -1477,3 +1486,5 @@ const toIncludeModels = (include, generatorId) => {
|
|
|
1477
1486
|
}
|
|
1478
1487
|
return undefined;
|
|
1479
1488
|
};
|
|
1489
|
+
/** Whether a ref target is a schema, or a ref to one: what a model is built from. */
|
|
1490
|
+
const isSchemaEntry = (entry) => entry.isRef() ? entry.isSchemaRef() : entry.oasType === 'schema';
|
|
@@ -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 _ParseContext_instances, _ParseContext_refConsumers, _ParseContext_refErrors, _ParseContext_oasRefs, _ParseContext_rootFrames, _ParseContext_removeComponent, _ParseContext_removeConsumer, _ParseContext_removePathParameterConsumer,
|
|
12
|
+
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;
|
|
13
13
|
/**
|
|
14
14
|
* Unified parse context for both OAS and GraphQL inputs.
|
|
15
15
|
*
|
|
@@ -41,20 +41,52 @@ import { StackTrail } from './StackTrail.js';
|
|
|
41
41
|
import { isPlainObject } from '../parse/isPlainObject.js';
|
|
42
42
|
import { toApplyingBrokenParameter, toNameAndIn } from '../parse/pathParameters.js';
|
|
43
43
|
import { toSerializedError } from '../types/SerializedError.js';
|
|
44
|
+
import { tryParseAt } from './tryParseAt.js';
|
|
44
45
|
import { DanglingRefError } from '../oas/ref/DanglingRefError.js';
|
|
45
|
-
import {
|
|
46
|
+
import { toRawRefTarget, toRefParts, toRefPathBucket, toRefPathSegments, toRefPointer } from '../helpers/refFns.js';
|
|
47
|
+
import { toRefTargetV3 } from '../parse/v3-0/ref/toRefTargetV3.js';
|
|
48
|
+
import { toRefTargetV3 as toRefTargetV31 } from '../parse/v3-1/ref/toRefTargetV3.js';
|
|
49
|
+
import { toRefTargetV3 as toRefTargetV32 } from '../parse/v3-2/ref/toRefTargetV3.js';
|
|
46
50
|
/**
|
|
47
|
-
* The key a `$ref`'s consumers and errors are kept under. A
|
|
48
|
-
* `#/components/<bucket
|
|
49
|
-
*
|
|
51
|
+
* The key a `$ref`'s consumers and errors are kept under. A component ref
|
|
52
|
+
* (`#/components/<bucket>/<name>`) is keyed by the name it resolves,
|
|
53
|
+
* unescaped, which is the key `StackTrail.toStackRef()` gives that
|
|
50
54
|
* component's own errors: `#/components/schemas/Foo%20Bar` is kept under
|
|
51
|
-
* `#/components/schemas/Foo Bar`. Any other
|
|
55
|
+
* `#/components/schemas/Foo Bar`. Any other ref is keyed by its whole
|
|
56
|
+
* pointer in one spelling (`toRefPointer`), which is also the key its
|
|
57
|
+
* parsed target is kept under.
|
|
52
58
|
*/
|
|
53
|
-
const toRefKey = (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return bucket === undefined ? $ref : `#/components/${bucket}/${toRefName($ref)}`;
|
|
59
|
+
const toRefKey = ({ refName, refPath }) => {
|
|
60
|
+
const bucket = toRefPathBucket(refPath);
|
|
61
|
+
return bucket === undefined ? toRefPointer({ refName, refPath }) : `#/components/${bucket}/${refName}`;
|
|
57
62
|
};
|
|
63
|
+
/** The issue logged when a ref target's parser throws. */
|
|
64
|
+
const toInvalidType = (refType) => {
|
|
65
|
+
switch (refType) {
|
|
66
|
+
case 'schema':
|
|
67
|
+
return 'INVALID_SCHEMA';
|
|
68
|
+
case 'requestBody':
|
|
69
|
+
return 'INVALID_REQUEST_BODY';
|
|
70
|
+
case 'parameter':
|
|
71
|
+
return 'INVALID_PARAMETER';
|
|
72
|
+
case 'response':
|
|
73
|
+
case 'link':
|
|
74
|
+
// A link has no type of its own: in the document's walk its response reports it.
|
|
75
|
+
return 'INVALID_RESPONSE';
|
|
76
|
+
case 'example':
|
|
77
|
+
return 'INVALID_EXAMPLE';
|
|
78
|
+
case 'header':
|
|
79
|
+
return 'INVALID_HEADER';
|
|
80
|
+
case 'securityScheme':
|
|
81
|
+
return 'INVALID_SECURITY_SCHEME';
|
|
82
|
+
default: {
|
|
83
|
+
const _exhaustive = refType;
|
|
84
|
+
throw new Error(`Unhandled ref type: ${_exhaustive}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/** Two issues with the same level, type, location and message are the same issue. */
|
|
89
|
+
const toIssueIdentity = (issue) => [issue.level, issue.type, issue.location, issue.message].join('\u0000');
|
|
58
90
|
/** The stored form of an issue: an error's `cause` as a `SerializedError`. */
|
|
59
91
|
const toParseIssue = (issue) => {
|
|
60
92
|
if (issue.level !== 'error') {
|
|
@@ -131,6 +163,16 @@ export class ParseContext {
|
|
|
131
163
|
);
|
|
132
164
|
/** Each OAS ref and the place it is written, which `#checkRefs` resolves once the document is parsed. */
|
|
133
165
|
_ParseContext_oasRefs.set(this, []
|
|
166
|
+
/** The key (`toRefKey`) of each ref target `#parseRefTargets` parsed. */
|
|
167
|
+
);
|
|
168
|
+
/** The key (`toRefKey`) of each ref target `#parseRefTargets` parsed. */
|
|
169
|
+
_ParseContext_refTargets.set(this, new Set()
|
|
170
|
+
/** The key of the ref target `#inRefTarget` runs for; `undefined` in the document's own walk. */
|
|
171
|
+
);
|
|
172
|
+
/** The key of the ref target `#inRefTarget` runs for; `undefined` in the document's own walk. */
|
|
173
|
+
_ParseContext_refTarget.set(this, void 0);
|
|
174
|
+
/** What identifies each issue logged so far (`toIssueIdentity`). */
|
|
175
|
+
_ParseContext_issueIdentities.set(this, new Set()
|
|
134
176
|
/**
|
|
135
177
|
* Frames of the trail `parse()` was called with (`[traceId, spanId,
|
|
136
178
|
* 'parse']` through `toArtifacts`). Every trail built during the walk
|
|
@@ -260,6 +302,7 @@ export class ParseContext {
|
|
|
260
302
|
stackTrail,
|
|
261
303
|
context: this
|
|
262
304
|
});
|
|
305
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_parseRefTargets).call(this, toRefTargetV3);
|
|
263
306
|
break;
|
|
264
307
|
case '3.1':
|
|
265
308
|
oasState.oasDocument.fields = toDocumentFieldsV31({
|
|
@@ -267,6 +310,7 @@ export class ParseContext {
|
|
|
267
310
|
stackTrail,
|
|
268
311
|
context: this
|
|
269
312
|
});
|
|
313
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_parseRefTargets).call(this, toRefTargetV31);
|
|
270
314
|
break;
|
|
271
315
|
case '3.2':
|
|
272
316
|
oasState.oasDocument.fields = toDocumentFieldsV32({
|
|
@@ -274,6 +318,7 @@ export class ParseContext {
|
|
|
274
318
|
stackTrail,
|
|
275
319
|
context: this
|
|
276
320
|
});
|
|
321
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_parseRefTargets).call(this, toRefTargetV32);
|
|
277
322
|
break;
|
|
278
323
|
default: {
|
|
279
324
|
const _exhaustive = dialect;
|
|
@@ -327,7 +372,15 @@ export class ParseContext {
|
|
|
327
372
|
pending.forEach(({ refKey }) => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeComponent).call(this, refKey));
|
|
328
373
|
// `pending` grows while it is walked: each removed component queues its own consumers.
|
|
329
374
|
for (const { refKey, rootCause } of pending) {
|
|
330
|
-
for (const consumer of __classPrivateFieldGet(this, _ParseContext_refConsumers, "f").get(refKey) ?? []) {
|
|
375
|
+
for (const { consumer, refTarget } of __classPrivateFieldGet(this, _ParseContext_refConsumers, "f").get(refKey) ?? []) {
|
|
376
|
+
// The ref is inside a ref target: the target is removed, and what refers to it next.
|
|
377
|
+
if (refTarget !== undefined) {
|
|
378
|
+
if (this.oasDocument.removeRefTarget(refTarget) !== undefined) {
|
|
379
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_inRefTarget).call(this, refTarget, () => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDependencyIssue).call(this, { location: consumer.toString(), refKey, rootCause }));
|
|
380
|
+
pending.push({ refKey: refTarget, rootCause });
|
|
381
|
+
}
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
331
384
|
const documentTrail = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, consumer);
|
|
332
385
|
const removedLocations = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeConsumer).call(this, consumer, documentTrail);
|
|
333
386
|
removedLocations.forEach(location => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_logDependencyIssue).call(this, { location, refKey, rootCause }));
|
|
@@ -372,12 +425,13 @@ export class ParseContext {
|
|
|
372
425
|
* would use type names or qualified field paths.
|
|
373
426
|
*/
|
|
374
427
|
registerRef(consumer, refKey) {
|
|
428
|
+
const refConsumer = { consumer, refTarget: __classPrivateFieldGet(this, _ParseContext_refTarget, "f") };
|
|
375
429
|
const existing = __classPrivateFieldGet(this, _ParseContext_refConsumers, "f").get(refKey);
|
|
376
430
|
if (existing) {
|
|
377
|
-
existing.push(
|
|
431
|
+
existing.push(refConsumer);
|
|
378
432
|
}
|
|
379
433
|
else {
|
|
380
|
-
__classPrivateFieldGet(this, _ParseContext_refConsumers, "f").set(refKey, [
|
|
434
|
+
__classPrivateFieldGet(this, _ParseContext_refConsumers, "f").set(refKey, [refConsumer]);
|
|
381
435
|
}
|
|
382
436
|
}
|
|
383
437
|
/**
|
|
@@ -387,8 +441,8 @@ export class ParseContext {
|
|
|
387
441
|
* resolve it there.
|
|
388
442
|
*/
|
|
389
443
|
registerOasRef(consumer, ref) {
|
|
390
|
-
this.registerRef(consumer, toRefKey(ref
|
|
391
|
-
__classPrivateFieldGet(this, _ParseContext_oasRefs, "f").push({ consumer, ref });
|
|
444
|
+
this.registerRef(consumer, toRefKey(ref));
|
|
445
|
+
__classPrivateFieldGet(this, _ParseContext_oasRefs, "f").push({ consumer, ref, refTarget: __classPrivateFieldGet(this, _ParseContext_refTarget, "f") });
|
|
392
446
|
}
|
|
393
447
|
/**
|
|
394
448
|
* What a merge reads in place of a `$ref` that names nothing: an `allOf`
|
|
@@ -448,8 +502,8 @@ export class ParseContext {
|
|
|
448
502
|
* manifest).
|
|
449
503
|
*/
|
|
450
504
|
logIssueAt(issue, parent) {
|
|
451
|
-
this.
|
|
452
|
-
if (!this.silent) {
|
|
505
|
+
const added = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_addIssue).call(this, toParseIssue(issue));
|
|
506
|
+
if (added && !this.silent) {
|
|
453
507
|
this.logger.warn({
|
|
454
508
|
protocol: issue.protocol,
|
|
455
509
|
level: issue.level,
|
|
@@ -483,7 +537,7 @@ export class ParseContext {
|
|
|
483
537
|
// points at. No-op for non-component trails (and for GQL
|
|
484
538
|
// trails) because `toStackRef` returns `undefined` and
|
|
485
539
|
// `registerRefError` ignores undefined refs.
|
|
486
|
-
this.registerRefError(issue.cause ?? issue.message, __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, stackTrail).toStackRef(), location);
|
|
540
|
+
this.registerRefError(issue.cause ?? issue.message, __classPrivateFieldGet(this, _ParseContext_refTarget, "f") ?? __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, stackTrail).toStackRef(), location);
|
|
487
541
|
this.logIssueAt({
|
|
488
542
|
protocol,
|
|
489
543
|
level: 'error',
|
|
@@ -565,14 +619,65 @@ export class ParseContext {
|
|
|
565
619
|
});
|
|
566
620
|
}
|
|
567
621
|
}
|
|
568
|
-
_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) {
|
|
622
|
+
_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) {
|
|
569
623
|
if (this.protocol.type !== 'oas') {
|
|
570
624
|
return;
|
|
571
625
|
}
|
|
626
|
+
if (__classPrivateFieldGet(this, _ParseContext_refTargets, "f").has(refKey)) {
|
|
627
|
+
this.protocol.oasDocument.removeRefTarget(refKey);
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
572
630
|
const match = /^#\/components\/([^/]+)\/(.+)$/.exec(refKey);
|
|
573
631
|
if (match) {
|
|
574
632
|
this.protocol.oasDocument.removeItem(new StackTrail(['components', match[1], match[2]]));
|
|
575
633
|
}
|
|
634
|
+
}, _ParseContext_parseRefTargets = function _ParseContext_parseRefTargets(toRefTarget) {
|
|
635
|
+
if (this.protocol.type !== 'oas') {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
const { oasDocument, documentObject } = this.protocol;
|
|
639
|
+
for (const { ref } of __classPrivateFieldGet(this, _ParseContext_oasRefs, "f")) {
|
|
640
|
+
const key = toRefKey(ref);
|
|
641
|
+
// A ref to a component, of its own kind or not, is resolved in
|
|
642
|
+
// `components`; `#checkRefs` reports one of the wrong kind.
|
|
643
|
+
if (ref.refName === '' || toRefPathBucket(ref.refPath) !== undefined || __classPrivateFieldGet(this, _ParseContext_refTargets, "f").has(key)) {
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
const value = toRawRefTarget(documentObject, ref);
|
|
647
|
+
if (!isPlainObject(value)) {
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
__classPrivateFieldGet(this, _ParseContext_refTargets, "f").add(key);
|
|
651
|
+
const parent = new StackTrail([...__classPrivateFieldGet(this, _ParseContext_rootFrames, "f"), ...toRefPathSegments(ref.refPath)]);
|
|
652
|
+
const target = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_inRefTarget).call(this, key, () => tryParseAt({
|
|
653
|
+
stackTrail: parent,
|
|
654
|
+
key: ref.refName,
|
|
655
|
+
context: this,
|
|
656
|
+
type: toInvalidType(ref.refType),
|
|
657
|
+
parent: value,
|
|
658
|
+
fn: () => toRefTarget({ refType: ref.refType, name: ref.refName, value, stackTrail: parent, context: this })
|
|
659
|
+
}));
|
|
660
|
+
if (target !== undefined) {
|
|
661
|
+
oasDocument.setRefTarget(key, target);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}, _ParseContext_inRefTarget = function _ParseContext_inRefTarget(key, fn) {
|
|
665
|
+
const previous = __classPrivateFieldGet(this, _ParseContext_refTarget, "f");
|
|
666
|
+
__classPrivateFieldSet(this, _ParseContext_refTarget, key, "f");
|
|
667
|
+
try {
|
|
668
|
+
return fn();
|
|
669
|
+
}
|
|
670
|
+
finally {
|
|
671
|
+
__classPrivateFieldSet(this, _ParseContext_refTarget, previous, "f");
|
|
672
|
+
}
|
|
673
|
+
}, _ParseContext_addIssue = function _ParseContext_addIssue(issue) {
|
|
674
|
+
const identity = toIssueIdentity(issue);
|
|
675
|
+
if (__classPrivateFieldGet(this, _ParseContext_refTarget, "f") !== undefined && __classPrivateFieldGet(this, _ParseContext_issueIdentities, "f").has(identity)) {
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
678
|
+
__classPrivateFieldGet(this, _ParseContext_issueIdentities, "f").add(identity);
|
|
679
|
+
this.issues.push(issue);
|
|
680
|
+
return true;
|
|
576
681
|
}, _ParseContext_removeConsumer = function _ParseContext_removeConsumer(consumer, documentTrail) {
|
|
577
682
|
switch (this.protocol.type) {
|
|
578
683
|
case 'oas': {
|
|
@@ -611,7 +716,9 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
611
716
|
: [];
|
|
612
717
|
const rawEntry = rawEntries[Number(index)];
|
|
613
718
|
const entryRef = isPlainObject(rawEntry) && typeof rawEntry.$ref === 'string' ? rawEntry.$ref : undefined;
|
|
614
|
-
const nameAndIn = toNameAndIn(entryRef === undefined
|
|
719
|
+
const nameAndIn = toNameAndIn(entryRef === undefined
|
|
720
|
+
? rawEntry
|
|
721
|
+
: toRawRefTarget(documentObject, toRefParts({ $ref: entryRef })));
|
|
615
722
|
const broken = [{ location: documentTrail.toString(), message: '', ...nameAndIn }];
|
|
616
723
|
const operations = first === 'paths'
|
|
617
724
|
? oasDocument.operations.filter(({ path }) => path === second)
|
|
@@ -633,13 +740,6 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
633
740
|
: [new StackTrail([...prefix, first, second, method]).toString()];
|
|
634
741
|
});
|
|
635
742
|
return removedLocations;
|
|
636
|
-
}, _ParseContext_toRawComponentParameter = function _ParseContext_toRawComponentParameter($ref) {
|
|
637
|
-
if (this.protocol.type !== 'oas') {
|
|
638
|
-
return undefined;
|
|
639
|
-
}
|
|
640
|
-
const match = /^#\/components\/parameters\/(.+)$/.exec($ref);
|
|
641
|
-
const parameters = this.protocol.documentObject.components?.parameters;
|
|
642
|
-
return match && isPlainObject(parameters) ? parameters[match[1]] : undefined;
|
|
643
743
|
}, _ParseContext_logDependencyIssue = function _ParseContext_logDependencyIssue({ location, refKey, rootCause }) {
|
|
644
744
|
const { error } = rootCause;
|
|
645
745
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -647,7 +747,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
647
747
|
const message = `Depends on '${refKey}', removed because of the error${at}: ${errorMessage}`;
|
|
648
748
|
switch (this.protocol.type) {
|
|
649
749
|
case 'oas':
|
|
650
|
-
this.
|
|
750
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_addIssue).call(this, {
|
|
651
751
|
protocol: 'oas',
|
|
652
752
|
level: 'error',
|
|
653
753
|
type: 'INVALID_DEPENDENCY_REF',
|
|
@@ -657,7 +757,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
657
757
|
});
|
|
658
758
|
break;
|
|
659
759
|
case 'gql':
|
|
660
|
-
this.
|
|
760
|
+
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_addIssue).call(this, {
|
|
661
761
|
protocol: 'gql',
|
|
662
762
|
level: 'error',
|
|
663
763
|
type: 'INVALID_DEPENDENCY_REF',
|
|
@@ -679,8 +779,8 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
679
779
|
rootFrames.every((frame, index) => frames[index] === frame);
|
|
680
780
|
return startsWithRoot ? new StackTrail(frames.slice(rootFrames.length)) : stackTrail;
|
|
681
781
|
}, _ParseContext_checkRefs = function _ParseContext_checkRefs() {
|
|
682
|
-
__classPrivateFieldGet(this, _ParseContext_oasRefs, "f").forEach(({ consumer, ref }) => {
|
|
683
|
-
if (__classPrivateFieldGet(this, _ParseContext_refErrors, "f").has(toRefKey(ref
|
|
782
|
+
__classPrivateFieldGet(this, _ParseContext_oasRefs, "f").forEach(({ consumer, ref, refTarget }) => __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_inRefTarget).call(this, refTarget, () => {
|
|
783
|
+
if (__classPrivateFieldGet(this, _ParseContext_refErrors, "f").has(toRefKey(ref))) {
|
|
684
784
|
return;
|
|
685
785
|
}
|
|
686
786
|
const error = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toRefError).call(this, ref);
|
|
@@ -690,6 +790,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
690
790
|
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeHolder).call(this, {
|
|
691
791
|
consumer,
|
|
692
792
|
ref,
|
|
793
|
+
refTarget,
|
|
693
794
|
error,
|
|
694
795
|
type: 'REF_TYPE_MISMATCH',
|
|
695
796
|
message: `${message}, so what holds it is removed.`
|
|
@@ -708,13 +809,14 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
708
809
|
__classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_removeHolder).call(this, {
|
|
709
810
|
consumer,
|
|
710
811
|
ref,
|
|
812
|
+
refTarget,
|
|
711
813
|
error,
|
|
712
814
|
type: 'DANGLING_REF',
|
|
713
815
|
message: `${error.message}, so what holds it is removed. To keep it, list '${ref.refType}' in system.danglingRefs.`
|
|
714
816
|
});
|
|
715
817
|
}
|
|
716
818
|
}
|
|
717
|
-
});
|
|
819
|
+
}));
|
|
718
820
|
}, _ParseContext_toRefError = function _ParseContext_toRefError(ref) {
|
|
719
821
|
try {
|
|
720
822
|
ref.resolveOnce();
|
|
@@ -733,7 +835,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
733
835
|
// A ref further on names nothing or the wrong kind: it reports that itself.
|
|
734
836
|
return undefined;
|
|
735
837
|
}
|
|
736
|
-
}, _ParseContext_removeHolder = function _ParseContext_removeHolder({ consumer, ref, error, type, message }) {
|
|
838
|
+
}, _ParseContext_removeHolder = function _ParseContext_removeHolder({ consumer, ref, refTarget, error, type, message }) {
|
|
737
839
|
this.logIssueNoKey({
|
|
738
840
|
level: 'error',
|
|
739
841
|
message,
|
|
@@ -743,7 +845,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
743
845
|
type
|
|
744
846
|
});
|
|
745
847
|
const documentTrail = __classPrivateFieldGet(this, _ParseContext_instances, "m", _ParseContext_toDocumentTrail).call(this, consumer);
|
|
746
|
-
if (documentTrail.toStackRef() !== undefined) {
|
|
848
|
+
if (refTarget !== undefined || documentTrail.toStackRef() !== undefined) {
|
|
747
849
|
return;
|
|
748
850
|
}
|
|
749
851
|
const location = consumer.toString();
|