@wundergraph/composition 0.5.3 → 0.6.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/dist/ast/ast.d.ts +21 -3
- package/dist/ast/ast.js +24 -11
- package/dist/ast/ast.js.map +1 -1
- package/dist/ast/utils.d.ts +17 -103
- package/dist/ast/utils.js +158 -16
- package/dist/ast/utils.js.map +1 -1
- package/dist/errors/errors.d.ts +17 -4
- package/dist/errors/errors.js +101 -22
- package/dist/errors/errors.js.map +1 -1
- package/dist/federation/federation-factory.d.ts +38 -25
- package/dist/federation/federation-factory.js +736 -461
- package/dist/federation/federation-factory.js.map +1 -1
- package/dist/federation/utils.d.ts +138 -0
- package/dist/federation/utils.js +23 -0
- package/dist/federation/utils.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/normalization/normalization-factory.d.ts +12 -3
- package/dist/normalization/normalization-factory.js +235 -75
- package/dist/normalization/normalization-factory.js.map +1 -1
- package/dist/normalization/utils.d.ts +4 -0
- package/dist/normalization/utils.js +24 -5
- package/dist/normalization/utils.js.map +1 -1
- package/dist/subgraph/field-configuration.d.ts +12 -1
- package/dist/subgraph/subgraph.d.ts +3 -2
- package/dist/subgraph/subgraph.js +50 -86
- package/dist/subgraph/subgraph.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/constants.js +93 -10
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/string-constants.d.ts +19 -2
- package/dist/utils/string-constants.js +21 -3
- package/dist/utils/string-constants.js.map +1 -1
- package/dist/utils/utils.d.ts +16 -3
- package/dist/utils/utils.js +68 -23
- package/dist/utils/utils.js.map +1 -1
- package/package.json +4 -3
- package/dist/federation/federation-result.d.ts +0 -6
- package/dist/federation/federation-result.js +0 -3
- package/dist/federation/federation-result.js.map +0 -1
package/dist/ast/ast.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { BooleanValueNode, ConstValueNode, DirectiveDefinitionNode, EnumTypeDefinitionNode, EnumValueDefinitionNode, EnumValueNode, FieldDefinitionNode, FloatValueNode, InputObjectTypeDefinitionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, IntValueNode, Kind, NamedTypeNode, NameNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, ScalarTypeDefinitionNode, StringValueNode, TypeNode, UnionTypeDefinitionNode } from 'graphql';
|
|
2
|
-
import { InterfaceTypeExtensionNode } from 'graphql/index';
|
|
1
|
+
import { BooleanValueNode, ConstDirectiveNode, ConstValueNode, DirectiveDefinitionNode, EnumTypeDefinitionNode, EnumValueDefinitionNode, EnumValueNode, FieldDefinitionNode, FloatValueNode, InputObjectTypeDefinitionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode, IntValueNode, Kind, NamedTypeNode, NameNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, ScalarTypeDefinitionNode, StringValueNode, TypeNode, UnionTypeDefinitionNode } from 'graphql';
|
|
3
2
|
export type ConstValueNodeWithValue = IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | EnumValueNode;
|
|
4
3
|
export declare function deepCopyTypeNode(node: TypeNode, parentName: string, fieldName: string): TypeNode;
|
|
4
|
+
export type MutableDirectiveDefinitionNode = {
|
|
5
|
+
arguments?: InputValueDefinitionNode[];
|
|
6
|
+
description?: StringValueNode;
|
|
7
|
+
kind: Kind.DIRECTIVE_DEFINITION;
|
|
8
|
+
locations: NameNode[];
|
|
9
|
+
name: NameNode;
|
|
10
|
+
repeatable: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function directiveDefinitionNodeToMutable(node: DirectiveDefinitionNode): MutableDirectiveDefinitionNode;
|
|
5
13
|
export type MutableEnumTypeDefinitionNode = {
|
|
6
14
|
description?: StringValueNode;
|
|
15
|
+
directives?: ConstDirectiveNode[];
|
|
7
16
|
kind: Kind.ENUM_TYPE_DEFINITION;
|
|
8
17
|
name: NameNode;
|
|
9
18
|
values: MutableEnumValueDefinitionNode[];
|
|
@@ -11,6 +20,7 @@ export type MutableEnumTypeDefinitionNode = {
|
|
|
11
20
|
export declare function enumTypeDefinitionNodeToMutable(node: EnumTypeDefinitionNode): MutableEnumTypeDefinitionNode;
|
|
12
21
|
export type MutableEnumValueDefinitionNode = {
|
|
13
22
|
description?: StringValueNode;
|
|
23
|
+
directives?: ConstDirectiveNode[];
|
|
14
24
|
kind: Kind.ENUM_VALUE_DEFINITION;
|
|
15
25
|
name: NameNode;
|
|
16
26
|
};
|
|
@@ -18,6 +28,7 @@ export declare function enumValueDefinitionNodeToMutable(node: EnumValueDefiniti
|
|
|
18
28
|
export type MutableFieldDefinitionNode = {
|
|
19
29
|
arguments: MutableInputValueDefinitionNode[];
|
|
20
30
|
description?: StringValueNode;
|
|
31
|
+
directives?: ConstDirectiveNode[];
|
|
21
32
|
kind: Kind.FIELD_DEFINITION;
|
|
22
33
|
name: NameNode;
|
|
23
34
|
type: TypeNode;
|
|
@@ -25,6 +36,7 @@ export type MutableFieldDefinitionNode = {
|
|
|
25
36
|
export declare function fieldDefinitionNodeToMutable(node: FieldDefinitionNode, parentName: string): MutableFieldDefinitionNode;
|
|
26
37
|
export type MutableInputObjectTypeDefinitionNode = {
|
|
27
38
|
description?: StringValueNode;
|
|
39
|
+
directives?: ConstDirectiveNode[];
|
|
28
40
|
fields: InputValueDefinitionNode[];
|
|
29
41
|
kind: Kind.INPUT_OBJECT_TYPE_DEFINITION;
|
|
30
42
|
name: NameNode;
|
|
@@ -33,6 +45,7 @@ export declare function inputObjectTypeDefinitionNodeToMutable(node: InputObject
|
|
|
33
45
|
export type MutableInputValueDefinitionNode = {
|
|
34
46
|
defaultValue?: ConstValueNode;
|
|
35
47
|
description?: StringValueNode;
|
|
48
|
+
directives?: ConstDirectiveNode[];
|
|
36
49
|
kind: Kind.INPUT_VALUE_DEFINITION;
|
|
37
50
|
name: NameNode;
|
|
38
51
|
type: TypeNode;
|
|
@@ -40,6 +53,7 @@ export type MutableInputValueDefinitionNode = {
|
|
|
40
53
|
export declare function inputValueDefinitionNodeToMutable(node: InputValueDefinitionNode, parentName: string): MutableInputValueDefinitionNode;
|
|
41
54
|
export type MutableInterfaceTypeDefinitionNode = {
|
|
42
55
|
description?: StringValueNode;
|
|
56
|
+
directives?: ConstDirectiveNode[];
|
|
43
57
|
fields: FieldDefinitionNode[];
|
|
44
58
|
interfaces: NamedTypeNode[];
|
|
45
59
|
kind: Kind.INTERFACE_TYPE_DEFINITION;
|
|
@@ -48,6 +62,7 @@ export type MutableInterfaceTypeDefinitionNode = {
|
|
|
48
62
|
export declare function interfaceTypeDefinitionNodeToMutable(node: InterfaceTypeDefinitionNode): MutableInterfaceTypeDefinitionNode;
|
|
49
63
|
export type MutableObjectTypeDefinitionNode = {
|
|
50
64
|
description?: StringValueNode;
|
|
65
|
+
directives?: ConstDirectiveNode[];
|
|
51
66
|
fields: FieldDefinitionNode[];
|
|
52
67
|
interfaces: NamedTypeNode[];
|
|
53
68
|
kind: Kind.OBJECT_TYPE_DEFINITION;
|
|
@@ -56,6 +71,7 @@ export type MutableObjectTypeDefinitionNode = {
|
|
|
56
71
|
export declare function objectTypeDefinitionNodeToMutable(node: ObjectTypeDefinitionNode): MutableObjectTypeDefinitionNode;
|
|
57
72
|
export type MutableObjectTypeExtensionNode = {
|
|
58
73
|
description?: StringValueNode;
|
|
74
|
+
directives?: ConstDirectiveNode[];
|
|
59
75
|
fields: FieldDefinitionNode[];
|
|
60
76
|
interfaces: NamedTypeNode[];
|
|
61
77
|
kind: Kind.OBJECT_TYPE_EXTENSION;
|
|
@@ -65,6 +81,7 @@ export declare function objectTypeExtensionNodeToMutable(node: ObjectTypeExtensi
|
|
|
65
81
|
export declare function objectTypeExtensionNodeToMutableDefinitionNode(node: ObjectTypeExtensionNode): MutableObjectTypeDefinitionNode;
|
|
66
82
|
export type MutableScalarTypeDefinitionNode = {
|
|
67
83
|
description?: StringValueNode;
|
|
84
|
+
directives?: ConstDirectiveNode[];
|
|
68
85
|
kind: Kind.SCALAR_TYPE_DEFINITION;
|
|
69
86
|
name: NameNode;
|
|
70
87
|
};
|
|
@@ -77,10 +94,11 @@ export type MutableTypeNode = {
|
|
|
77
94
|
export declare const maximumTypeNesting = 30;
|
|
78
95
|
export type MutableUnionTypeDefinitionNode = {
|
|
79
96
|
description?: StringValueNode;
|
|
97
|
+
directives?: ConstDirectiveNode[];
|
|
80
98
|
kind: Kind.UNION_TYPE_DEFINITION;
|
|
81
99
|
name: NameNode;
|
|
82
100
|
types: NamedTypeNode[];
|
|
83
101
|
};
|
|
84
102
|
export declare function unionTypeDefinitionNodeToMutable(node: UnionTypeDefinitionNode): MutableUnionTypeDefinitionNode;
|
|
85
|
-
export type MutableTypeDefinitionNode =
|
|
103
|
+
export type MutableTypeDefinitionNode = MutableDirectiveDefinitionNode | MutableEnumTypeDefinitionNode | MutableInputObjectTypeDefinitionNode | MutableInterfaceTypeDefinitionNode | MutableObjectTypeDefinitionNode | MutableScalarTypeDefinitionNode | MutableUnionTypeDefinitionNode;
|
|
86
104
|
export type ObjectLikeTypeDefinitionNode = InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode | ObjectTypeDefinitionNode | ObjectTypeExtensionNode;
|
package/dist/ast/ast.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unionTypeDefinitionNodeToMutable = exports.maximumTypeNesting = exports.scalarTypeDefinitionNodeToMutable = exports.objectTypeExtensionNodeToMutableDefinitionNode = exports.objectTypeExtensionNodeToMutable = exports.objectTypeDefinitionNodeToMutable = exports.interfaceTypeDefinitionNodeToMutable = exports.inputValueDefinitionNodeToMutable = exports.inputObjectTypeDefinitionNodeToMutable = exports.fieldDefinitionNodeToMutable = exports.enumValueDefinitionNodeToMutable = exports.enumTypeDefinitionNodeToMutable = exports.deepCopyTypeNode = void 0;
|
|
3
|
+
exports.unionTypeDefinitionNodeToMutable = exports.maximumTypeNesting = exports.scalarTypeDefinitionNodeToMutable = exports.objectTypeExtensionNodeToMutableDefinitionNode = exports.objectTypeExtensionNodeToMutable = exports.objectTypeDefinitionNodeToMutable = exports.interfaceTypeDefinitionNodeToMutable = exports.inputValueDefinitionNodeToMutable = exports.inputObjectTypeDefinitionNodeToMutable = exports.fieldDefinitionNodeToMutable = exports.enumValueDefinitionNodeToMutable = exports.enumTypeDefinitionNodeToMutable = exports.directiveDefinitionNodeToMutable = exports.deepCopyTypeNode = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
5
|
const errors_1 = require("../errors/errors");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
6
7
|
function deepCopyFieldsAndInterfaces(node, fields, interfaces) {
|
|
7
8
|
if (node.fields) {
|
|
8
9
|
for (const field of node.fields) {
|
|
@@ -42,6 +43,17 @@ function deepCopyTypeNode(node, parentName, fieldName) {
|
|
|
42
43
|
throw new Error(`Field ${parentName}.${fieldName} has more than 30 layers of nesting, or there is a cyclical error.`);
|
|
43
44
|
}
|
|
44
45
|
exports.deepCopyTypeNode = deepCopyTypeNode;
|
|
46
|
+
function directiveDefinitionNodeToMutable(node) {
|
|
47
|
+
return {
|
|
48
|
+
arguments: node.arguments ? [...node.arguments] : undefined,
|
|
49
|
+
description: (0, utils_1.formatDescription)(node.description),
|
|
50
|
+
kind: node.kind,
|
|
51
|
+
locations: [...node.locations],
|
|
52
|
+
name: { ...node.name },
|
|
53
|
+
repeatable: node.repeatable,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
exports.directiveDefinitionNodeToMutable = directiveDefinitionNodeToMutable;
|
|
45
57
|
function enumTypeDefinitionNodeToMutable(node) {
|
|
46
58
|
const values = [];
|
|
47
59
|
if (node.values) {
|
|
@@ -50,7 +62,7 @@ function enumTypeDefinitionNodeToMutable(node) {
|
|
|
50
62
|
}
|
|
51
63
|
}
|
|
52
64
|
return {
|
|
53
|
-
description:
|
|
65
|
+
description: (0, utils_1.formatDescription)(node.description),
|
|
54
66
|
kind: node.kind,
|
|
55
67
|
name: { ...node.name },
|
|
56
68
|
values,
|
|
@@ -59,7 +71,7 @@ function enumTypeDefinitionNodeToMutable(node) {
|
|
|
59
71
|
exports.enumTypeDefinitionNodeToMutable = enumTypeDefinitionNodeToMutable;
|
|
60
72
|
function enumValueDefinitionNodeToMutable(node) {
|
|
61
73
|
return {
|
|
62
|
-
description:
|
|
74
|
+
description: (0, utils_1.formatDescription)(node.description),
|
|
63
75
|
kind: node.kind,
|
|
64
76
|
name: { ...node.name },
|
|
65
77
|
};
|
|
@@ -69,12 +81,12 @@ function fieldDefinitionNodeToMutable(node, parentName) {
|
|
|
69
81
|
const args = [];
|
|
70
82
|
if (node.arguments) {
|
|
71
83
|
for (const argument of node.arguments) {
|
|
72
|
-
args.push(inputValueDefinitionNodeToMutable(argument, node.name.value));
|
|
84
|
+
args.push(inputValueDefinitionNodeToMutable(argument, node.name.value));
|
|
73
85
|
}
|
|
74
86
|
}
|
|
75
87
|
return {
|
|
76
88
|
arguments: args,
|
|
77
|
-
description:
|
|
89
|
+
description: (0, utils_1.formatDescription)(node.description),
|
|
78
90
|
kind: node.kind,
|
|
79
91
|
name: { ...node.name },
|
|
80
92
|
type: deepCopyTypeNode(node.type, parentName, node.name.value),
|
|
@@ -89,7 +101,7 @@ function inputObjectTypeDefinitionNodeToMutable(node) {
|
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
103
|
return {
|
|
92
|
-
description:
|
|
104
|
+
description: (0, utils_1.formatDescription)(node.description),
|
|
93
105
|
fields,
|
|
94
106
|
kind: node.kind,
|
|
95
107
|
name: { ...node.name },
|
|
@@ -99,7 +111,8 @@ exports.inputObjectTypeDefinitionNodeToMutable = inputObjectTypeDefinitionNodeTo
|
|
|
99
111
|
function inputValueDefinitionNodeToMutable(node, parentName) {
|
|
100
112
|
return {
|
|
101
113
|
defaultValue: node.defaultValue ? { ...node.defaultValue } : undefined,
|
|
102
|
-
description:
|
|
114
|
+
description: (0, utils_1.formatDescription)(node.description),
|
|
115
|
+
directives: node.directives ? [...node.directives] : undefined,
|
|
103
116
|
kind: node.kind,
|
|
104
117
|
name: { ...node.name },
|
|
105
118
|
type: deepCopyTypeNode(node.type, parentName, node.name.value),
|
|
@@ -111,7 +124,7 @@ function interfaceTypeDefinitionNodeToMutable(node) {
|
|
|
111
124
|
const interfaces = [];
|
|
112
125
|
deepCopyFieldsAndInterfaces(node, fields, interfaces);
|
|
113
126
|
return {
|
|
114
|
-
description:
|
|
127
|
+
description: (0, utils_1.formatDescription)(node.description),
|
|
115
128
|
fields,
|
|
116
129
|
interfaces,
|
|
117
130
|
kind: node.kind,
|
|
@@ -124,7 +137,7 @@ function objectTypeDefinitionNodeToMutable(node) {
|
|
|
124
137
|
const interfaces = [];
|
|
125
138
|
deepCopyFieldsAndInterfaces(node, fields, interfaces);
|
|
126
139
|
return {
|
|
127
|
-
description:
|
|
140
|
+
description: (0, utils_1.formatDescription)(node.description),
|
|
128
141
|
fields,
|
|
129
142
|
interfaces,
|
|
130
143
|
kind: node.kind,
|
|
@@ -158,7 +171,7 @@ function objectTypeExtensionNodeToMutableDefinitionNode(node) {
|
|
|
158
171
|
exports.objectTypeExtensionNodeToMutableDefinitionNode = objectTypeExtensionNodeToMutableDefinitionNode;
|
|
159
172
|
function scalarTypeDefinitionNodeToMutable(node) {
|
|
160
173
|
return {
|
|
161
|
-
description:
|
|
174
|
+
description: (0, utils_1.formatDescription)(node.description),
|
|
162
175
|
kind: graphql_1.Kind.SCALAR_TYPE_DEFINITION,
|
|
163
176
|
name: { ...node.name },
|
|
164
177
|
};
|
|
@@ -173,7 +186,7 @@ function unionTypeDefinitionNodeToMutable(node) {
|
|
|
173
186
|
}
|
|
174
187
|
}
|
|
175
188
|
return {
|
|
176
|
-
description:
|
|
189
|
+
description: (0, utils_1.formatDescription)(node.description),
|
|
177
190
|
kind: node.kind,
|
|
178
191
|
name: { ...node.name },
|
|
179
192
|
types,
|
package/dist/ast/ast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/ast/ast.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/ast/ast.ts"],"names":[],"mappings":";;;AAAA,qCAwBiB;AACjB,6CAAqE;AACrE,mCAA4C;AAE5C,SAAS,2BAA2B,CAClC,IAAsF,EACtF,MAAoC,EAAE,UAA2B;IAEjE,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;YAC/B,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,kCAAkC;SACtG;KACF;IACD,IAAI,IAAI,CAAC,UAAU,EAAE;QACnB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;YAClC,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;SAC9B;KACF;AACH,CAAC;AAID,SAAgB,gBAAgB,CAAC,IAAc,EAAE,UAAkB,EAAE,SAAiB;IACpF,MAAM,QAAQ,GAAoB,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IACtD,IAAI,YAAY,GAAG,QAAQ,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,0BAAkB,EAAE,CAAC,EAAE,EAAE;QAC3C,QAAQ,IAAI,CAAC,IAAI,EAAE;YACjB,KAAK,cAAI,CAAC,UAAU;gBAClB,YAAY,CAAC,IAAI,GAAG,EAAE,GAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACtC,OAAO,QAAoB,CAAC;YAC9B,KAAK,cAAI,CAAC,SAAS;gBACjB,YAAY,CAAC,IAAI,G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,CAAC;AAVD,wGAUC;AASD,SAAgB,iCAAiC,CAAC,IAA8B;IAC9E,OAAO;QACL,WAAW,EAAE,IAAA,yBAAiB,EAAC,IAAI,CAAC,WAAW,CAAC;QAChD,IAAI,EAAE,cAAI,CAAC,sBAAsB;QACjC,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE;KACvB,CAAC;AACJ,CAAC;AAND,8EAMC;AAQY,QAAA,kBAAkB,GAAG,EAAE,CAAC;AAUrC,SAAgB,gCAAgC,CAAC,IAA6B;IAC5E,MAAM,KAAK,GAAoB,EAAE,CAAC;IAClC,IAAI,IAAI,CAAC,KAAK,EAAE;QACd,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,KAAK,EAAE;YAC/B,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;SAC3B;KACF;IACD,OAAO;QACL,WAAW,EAAE,IAAA,yBAAiB,EAAC,IAAI,CAAC,WAAW,CAAC;QAChD,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE;QACtB,KAAK;KACN,CAAC;AACJ,CAAC;AAbD,4EAaC"}
|
package/dist/ast/utils.d.ts
CHANGED
|
@@ -1,107 +1,10 @@
|
|
|
1
|
-
import { FieldDefinitionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode, Kind, NamedTypeNode, NameNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, OperationTypeNode } from 'graphql';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
INTERSECTION = 1,
|
|
6
|
-
CONSISTENT = 2
|
|
7
|
-
}
|
|
8
|
-
export type EntityContainer = {
|
|
9
|
-
fields: Set<string>;
|
|
10
|
-
keys: Set<string>;
|
|
11
|
-
subgraphs: Set<string>;
|
|
12
|
-
};
|
|
13
|
-
export type EnumContainer = {
|
|
14
|
-
appearances: number;
|
|
15
|
-
values: EnumValueMap;
|
|
16
|
-
kind: Kind.ENUM_TYPE_DEFINITION;
|
|
17
|
-
node: MutableEnumTypeDefinitionNode;
|
|
18
|
-
};
|
|
19
|
-
export type EnumValueContainer = {
|
|
20
|
-
appearances: number;
|
|
21
|
-
node: MutableEnumValueDefinitionNode;
|
|
22
|
-
};
|
|
23
|
-
export type EnumValueMap = Map<string, EnumValueContainer>;
|
|
24
|
-
export type FieldContainer = {
|
|
25
|
-
appearances: number;
|
|
26
|
-
arguments: InputValueMap;
|
|
27
|
-
isShareable: boolean;
|
|
28
|
-
node: MutableFieldDefinitionNode;
|
|
29
|
-
rootTypeName: string;
|
|
30
|
-
subgraphs: Set<string>;
|
|
31
|
-
subgraphsByShareable: Map<string, boolean>;
|
|
32
|
-
};
|
|
33
|
-
export type FieldMap = Map<string, FieldContainer>;
|
|
34
|
-
export type InputValueContainer = {
|
|
35
|
-
appearances: number;
|
|
36
|
-
includeDefaultValue: boolean;
|
|
37
|
-
node: MutableInputValueDefinitionNode;
|
|
38
|
-
};
|
|
39
|
-
export type InputValueMap = Map<string, InputValueContainer>;
|
|
40
|
-
export type InputObjectContainer = {
|
|
41
|
-
appearances: number;
|
|
42
|
-
fields: InputValueMap;
|
|
43
|
-
kind: Kind.INPUT_OBJECT_TYPE_DEFINITION;
|
|
44
|
-
node: MutableInputObjectTypeDefinitionNode;
|
|
45
|
-
};
|
|
46
|
-
export type InterfaceContainer = {
|
|
47
|
-
appearances: number;
|
|
48
|
-
fields: FieldMap;
|
|
49
|
-
interfaces: Set<string>;
|
|
50
|
-
kind: Kind.INTERFACE_TYPE_DEFINITION;
|
|
51
|
-
node: MutableInterfaceTypeDefinitionNode;
|
|
52
|
-
subgraphs: Set<string>;
|
|
53
|
-
};
|
|
54
|
-
export type ObjectContainer = {
|
|
55
|
-
appearances: number;
|
|
56
|
-
fields: FieldMap;
|
|
57
|
-
entityKeys: Set<string>;
|
|
58
|
-
interfaces: Set<string>;
|
|
59
|
-
isRootType: boolean;
|
|
60
|
-
kind: Kind.OBJECT_TYPE_DEFINITION;
|
|
61
|
-
node: MutableObjectTypeDefinitionNode;
|
|
62
|
-
subgraphs: Set<string>;
|
|
63
|
-
};
|
|
64
|
-
export type ObjectExtensionContainer = {
|
|
65
|
-
appearances: number;
|
|
66
|
-
fields: FieldMap;
|
|
67
|
-
entityKeys: Set<string>;
|
|
68
|
-
interfaces: Set<string>;
|
|
69
|
-
isRootType: boolean;
|
|
70
|
-
kind: Kind.OBJECT_TYPE_EXTENSION;
|
|
71
|
-
node: MutableObjectTypeExtensionNode;
|
|
72
|
-
subgraphs: Set<string>;
|
|
73
|
-
};
|
|
74
|
-
export type RootTypeField = {
|
|
75
|
-
inlineFragment: string;
|
|
76
|
-
path: string;
|
|
77
|
-
name: string;
|
|
78
|
-
parentTypeName: string;
|
|
79
|
-
responseType: string;
|
|
80
|
-
rootTypeName: string;
|
|
81
|
-
subgraphs: Set<string>;
|
|
82
|
-
};
|
|
83
|
-
export type PotentiallyUnresolvableField = {
|
|
84
|
-
fieldContainer: FieldContainer;
|
|
85
|
-
fullResolverPaths: string[];
|
|
86
|
-
rootTypeField: RootTypeField;
|
|
87
|
-
};
|
|
88
|
-
export type ScalarContainer = {
|
|
89
|
-
appearances: number;
|
|
90
|
-
kind: Kind.SCALAR_TYPE_DEFINITION;
|
|
91
|
-
node: MutableScalarTypeDefinitionNode;
|
|
92
|
-
};
|
|
93
|
-
export type UnionContainer = {
|
|
94
|
-
appearances: number;
|
|
95
|
-
kind: Kind.UNION_TYPE_DEFINITION;
|
|
96
|
-
members: Set<string>;
|
|
97
|
-
node: MutableUnionTypeDefinitionNode;
|
|
98
|
-
};
|
|
99
|
-
export type ParentContainer = EnumContainer | InputObjectContainer | InterfaceContainer | ObjectContainer | UnionContainer | ScalarContainer;
|
|
100
|
-
export type ExtensionContainer = ObjectExtensionContainer;
|
|
101
|
-
export type ParentMap = Map<string, ParentContainer>;
|
|
1
|
+
import { FieldDefinitionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode, Kind, NamedTypeNode, NameNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, OperationTypeNode, StringValueNode, UnionTypeExtensionNode } from 'graphql';
|
|
2
|
+
import { MutableEnumValueDefinitionNode, MutableFieldDefinitionNode, MutableInputValueDefinitionNode, MutableTypeDefinitionNode, ObjectLikeTypeDefinitionNode } from './ast';
|
|
3
|
+
import { UnionTypeDefinitionNode } from 'graphql/index';
|
|
4
|
+
import { DirectiveContainer, NodeContainer } from '../federation/utils';
|
|
102
5
|
export declare function isObjectLikeNodeEntity(node: ObjectLikeTypeDefinitionNode): boolean;
|
|
103
6
|
export declare function isNodeExtension(node: ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode): boolean;
|
|
104
|
-
export declare function extractEntityKeys(node: ObjectTypeDefinitionNode | ObjectTypeExtensionNode, keySet: Set<string
|
|
7
|
+
export declare function extractEntityKeys(node: ObjectTypeDefinitionNode | ObjectTypeExtensionNode, keySet: Set<string>, errors: Error[]): Set<string>;
|
|
105
8
|
export type EntityKey = {
|
|
106
9
|
nestedKeys?: EntityKey[];
|
|
107
10
|
parent: string;
|
|
@@ -119,12 +22,23 @@ export type EntityKeyExtractionResults = {
|
|
|
119
22
|
export declare function getEntityKeyExtractionResults(node: ObjectTypeDefinitionNode | ObjectTypeExtensionNode, entityKeyMap: Map<string, EntityKey>): EntityKeyExtractionResults;
|
|
120
23
|
export declare function extractInterfaces(node: InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode | ObjectTypeDefinitionNode | ObjectTypeExtensionNode, interfaces: Set<string>, errors?: Error[]): Set<string>;
|
|
121
24
|
export declare function isNodeShareable(node: ObjectTypeDefinitionNode | ObjectTypeExtensionNode | FieldDefinitionNode): boolean;
|
|
25
|
+
export declare function isNodeExternal(node: ObjectTypeDefinitionNode | ObjectTypeExtensionNode | FieldDefinitionNode): boolean;
|
|
26
|
+
export declare function isNodeOverridden(node: ObjectTypeDefinitionNode | ObjectTypeExtensionNode | FieldDefinitionNode): boolean;
|
|
122
27
|
export declare function areBaseAndExtensionKindsCompatible(baseKind: Kind, extensionKind: Kind, typeName: string): boolean;
|
|
123
28
|
export declare function stringToNameNode(value: string): NameNode;
|
|
124
|
-
export declare function
|
|
29
|
+
export declare function stringArrayToNameNodeArray(values: string[]): NameNode[];
|
|
30
|
+
export declare function setToNameNodeArray(set: Set<string>): NameNode[];
|
|
125
31
|
export declare function stringToNamedTypeNode(value: string): NamedTypeNode;
|
|
126
32
|
export declare function setToNamedTypeNodeArray(set: Set<string>): NamedTypeNode[];
|
|
127
33
|
export declare function nodeKindToDirectiveLocation(kind: Kind): string;
|
|
128
34
|
export declare const operationTypeNodeToDefaultType: Map<OperationTypeNode, string>;
|
|
129
35
|
export declare function isKindAbstract(kind: Kind): boolean;
|
|
130
36
|
export declare function getInlineFragmentString(parentTypeName: string): string;
|
|
37
|
+
export declare function extractNameNodeStringsToSet(nodes: readonly NameNode[] | NameNode[], set: Set<string>): Set<string>;
|
|
38
|
+
export declare function extractExecutableDirectiveLocations(nodes: readonly NameNode[] | NameNode[], set: Set<string>): Set<string>;
|
|
39
|
+
export declare function mergeExecutableDirectiveLocations(nodes: readonly NameNode[] | NameNode[], directiveContainer: DirectiveContainer): Set<string>;
|
|
40
|
+
export declare function pushPersistedDirectivesAndGetNode<T extends NodeContainer>(container: T): T['node'];
|
|
41
|
+
export declare function addConcreteTypesForImplementedInterfaces(node: ObjectTypeDefinitionNode | ObjectTypeExtensionNode | InterfaceTypeDefinitionNode, abstractToConcreteTypeNames: Map<string, Set<string>>): void;
|
|
42
|
+
export declare function addConcreteTypesForUnion(node: UnionTypeDefinitionNode | UnionTypeExtensionNode, abstractToConcreteTypeNames: Map<string, Set<string>>): void;
|
|
43
|
+
export declare function formatDescription(description?: StringValueNode): StringValueNode | undefined;
|
|
44
|
+
export declare function setLongestDescriptionForNode(existingNode: MutableFieldDefinitionNode | MutableEnumValueDefinitionNode | MutableInputValueDefinitionNode | MutableTypeDefinitionNode, newDescription?: StringValueNode): void;
|
package/dist/ast/utils.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInlineFragmentString = exports.isKindAbstract = exports.operationTypeNodeToDefaultType = exports.nodeKindToDirectiveLocation = exports.setToNamedTypeNodeArray = exports.stringToNamedTypeNode = exports.
|
|
3
|
+
exports.setLongestDescriptionForNode = exports.formatDescription = exports.addConcreteTypesForUnion = exports.addConcreteTypesForImplementedInterfaces = exports.pushPersistedDirectivesAndGetNode = exports.mergeExecutableDirectiveLocations = exports.extractExecutableDirectiveLocations = exports.extractNameNodeStringsToSet = exports.getInlineFragmentString = exports.isKindAbstract = exports.operationTypeNodeToDefaultType = exports.nodeKindToDirectiveLocation = exports.setToNamedTypeNodeArray = exports.stringToNamedTypeNode = exports.setToNameNodeArray = exports.stringArrayToNameNodeArray = exports.stringToNameNode = exports.areBaseAndExtensionKindsCompatible = exports.isNodeOverridden = exports.isNodeExternal = exports.isNodeShareable = exports.extractInterfaces = exports.getEntityKeyExtractionResults = exports.getEntityKeyExtractionResult = exports.extractEntityKeys = exports.isNodeExtension = exports.isObjectLikeNodeEntity = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
5
|
const string_constants_1 = require("../utils/string-constants");
|
|
6
6
|
const errors_1 = require("../errors/errors");
|
|
7
7
|
const utils_1 = require("../utils/utils");
|
|
8
|
-
|
|
9
|
-
(function (MergeMethod) {
|
|
10
|
-
MergeMethod[MergeMethod["UNION"] = 0] = "UNION";
|
|
11
|
-
MergeMethod[MergeMethod["INTERSECTION"] = 1] = "INTERSECTION";
|
|
12
|
-
MergeMethod[MergeMethod["CONSISTENT"] = 2] = "CONSISTENT";
|
|
13
|
-
})(MergeMethod || (exports.MergeMethod = MergeMethod = {}));
|
|
8
|
+
const utils_2 = require("../federation/utils");
|
|
14
9
|
function isObjectLikeNodeEntity(node) {
|
|
15
10
|
// Interface entities are currently unsupported
|
|
16
11
|
if (node.kind === graphql_1.Kind.INTERFACE_TYPE_DEFINITION
|
|
@@ -38,14 +33,18 @@ function isNodeExtension(node) {
|
|
|
38
33
|
return false;
|
|
39
34
|
}
|
|
40
35
|
exports.isNodeExtension = isNodeExtension;
|
|
41
|
-
function extractEntityKeys(node, keySet) {
|
|
36
|
+
function extractEntityKeys(node, keySet, errors) {
|
|
42
37
|
if (!node.directives?.length) {
|
|
43
38
|
return keySet;
|
|
44
39
|
}
|
|
40
|
+
const typeName = node.name.value;
|
|
45
41
|
for (const directive of node.directives) {
|
|
46
42
|
if (directive.name.value === string_constants_1.KEY) {
|
|
47
43
|
if (!directive.arguments) {
|
|
48
|
-
|
|
44
|
+
errors.push((0, errors_1.invalidKeyDirectiveError)(typeName, [
|
|
45
|
+
(0, errors_1.undefinedRequiredArgumentsErrorMessage)(string_constants_1.KEY, typeName, [string_constants_1.NAME])
|
|
46
|
+
]));
|
|
47
|
+
continue;
|
|
49
48
|
}
|
|
50
49
|
for (const arg of directive.arguments) {
|
|
51
50
|
if (arg.name.value !== string_constants_1.FIELDS) {
|
|
@@ -68,8 +67,9 @@ function getEntityKeyExtractionResult(rawEntityKey, parentTypeName) {
|
|
|
68
67
|
let currentSegment = '';
|
|
69
68
|
let segmentEnded = true;
|
|
70
69
|
let currentKey;
|
|
70
|
+
rawEntityKey = rawEntityKey.replaceAll(/[,\n]/g, ' ');
|
|
71
71
|
for (const char of rawEntityKey) {
|
|
72
|
-
currentKey = (0, utils_1.getOrThrowError)(entityKeyMap, keyPath.join('.'));
|
|
72
|
+
currentKey = (0, utils_1.getOrThrowError)(entityKeyMap, keyPath.join('.'), 'entityKeyMap');
|
|
73
73
|
switch (char) {
|
|
74
74
|
case ' ':
|
|
75
75
|
segmentEnded = true;
|
|
@@ -131,10 +131,10 @@ function getEntityKeyExtractionResult(rawEntityKey, parentTypeName) {
|
|
|
131
131
|
}
|
|
132
132
|
exports.getEntityKeyExtractionResult = getEntityKeyExtractionResult;
|
|
133
133
|
function getEntityKeyExtractionResults(node, entityKeyMap) {
|
|
134
|
+
const parentTypeName = node.name.value;
|
|
134
135
|
if (!node.directives?.length) {
|
|
135
|
-
return { entityKeyMap, errors: [
|
|
136
|
+
return { entityKeyMap, errors: [(0, errors_1.expectedEntityError)(parentTypeName)] };
|
|
136
137
|
}
|
|
137
|
-
const parentTypeName = node.name.value;
|
|
138
138
|
const rawEntityKeys = new Set();
|
|
139
139
|
const errorMessages = [];
|
|
140
140
|
for (const directive of node.directives) {
|
|
@@ -147,6 +147,9 @@ function getEntityKeyExtractionResults(node, entityKeyMap) {
|
|
|
147
147
|
}
|
|
148
148
|
for (const arg of directive.arguments) {
|
|
149
149
|
const argumentName = arg.name.value;
|
|
150
|
+
if (arg.name.value === string_constants_1.RESOLVABLE) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
150
153
|
if (arg.name.value !== string_constants_1.FIELDS) {
|
|
151
154
|
errorMessages.push((0, errors_1.unexpectedDirectiveArgumentErrorMessage)(string_constants_1.KEY, argumentName));
|
|
152
155
|
break;
|
|
@@ -208,6 +211,30 @@ function isNodeShareable(node) {
|
|
|
208
211
|
return false;
|
|
209
212
|
}
|
|
210
213
|
exports.isNodeShareable = isNodeShareable;
|
|
214
|
+
function isNodeExternal(node) {
|
|
215
|
+
if (!node.directives) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
for (const directive of node.directives) {
|
|
219
|
+
if (directive.name.value === string_constants_1.EXTERNAL) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
exports.isNodeExternal = isNodeExternal;
|
|
226
|
+
function isNodeOverridden(node) {
|
|
227
|
+
if (!node.directives) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
for (const directive of node.directives) {
|
|
231
|
+
if (directive.name.value === string_constants_1.OVERRIDE) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
exports.isNodeOverridden = isNodeOverridden;
|
|
211
238
|
function areBaseAndExtensionKindsCompatible(baseKind, extensionKind, typeName) {
|
|
212
239
|
switch (baseKind) {
|
|
213
240
|
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
@@ -234,14 +261,22 @@ function stringToNameNode(value) {
|
|
|
234
261
|
};
|
|
235
262
|
}
|
|
236
263
|
exports.stringToNameNode = stringToNameNode;
|
|
237
|
-
function
|
|
264
|
+
function stringArrayToNameNodeArray(values) {
|
|
238
265
|
const nameNodes = [];
|
|
239
266
|
for (const value of values) {
|
|
240
267
|
nameNodes.push(stringToNameNode(value));
|
|
241
268
|
}
|
|
242
269
|
return nameNodes;
|
|
243
270
|
}
|
|
244
|
-
exports.
|
|
271
|
+
exports.stringArrayToNameNodeArray = stringArrayToNameNodeArray;
|
|
272
|
+
function setToNameNodeArray(set) {
|
|
273
|
+
const nameNodes = [];
|
|
274
|
+
for (const value of set) {
|
|
275
|
+
nameNodes.push(stringToNameNode(value));
|
|
276
|
+
}
|
|
277
|
+
return nameNodes;
|
|
278
|
+
}
|
|
279
|
+
exports.setToNameNodeArray = setToNameNodeArray;
|
|
245
280
|
function stringToNamedTypeNode(value) {
|
|
246
281
|
return {
|
|
247
282
|
kind: graphql_1.Kind.NAMED_TYPE,
|
|
@@ -267,6 +302,14 @@ function nodeKindToDirectiveLocation(kind) {
|
|
|
267
302
|
return string_constants_1.ENUM_VALUE_UPPER;
|
|
268
303
|
case graphql_1.Kind.FIELD_DEFINITION:
|
|
269
304
|
return string_constants_1.FIELD_DEFINITION_UPPER;
|
|
305
|
+
case graphql_1.Kind.FRAGMENT_DEFINITION:
|
|
306
|
+
return string_constants_1.FRAGMENT_DEFINITION_UPPER;
|
|
307
|
+
case graphql_1.Kind.FRAGMENT_SPREAD:
|
|
308
|
+
return string_constants_1.FRAGMENT_SPREAD_UPPER;
|
|
309
|
+
case graphql_1.Kind.INLINE_FRAGMENT:
|
|
310
|
+
return string_constants_1.INLINE_FRAGMENT_UPPER;
|
|
311
|
+
case graphql_1.Kind.INPUT_VALUE_DEFINITION:
|
|
312
|
+
return string_constants_1.INPUT_FIELD_DEFINITION_UPPER;
|
|
270
313
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
271
314
|
// intentional fallthrough
|
|
272
315
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION:
|
|
@@ -290,9 +333,9 @@ function nodeKindToDirectiveLocation(kind) {
|
|
|
290
333
|
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
291
334
|
// intentional fallthrough
|
|
292
335
|
case graphql_1.Kind.UNION_TYPE_EXTENSION:
|
|
293
|
-
return string_constants_1.
|
|
336
|
+
return string_constants_1.UNION_UPPER;
|
|
294
337
|
default:
|
|
295
|
-
|
|
338
|
+
return kind;
|
|
296
339
|
}
|
|
297
340
|
}
|
|
298
341
|
exports.nodeKindToDirectiveLocation = nodeKindToDirectiveLocation;
|
|
@@ -309,4 +352,103 @@ function getInlineFragmentString(parentTypeName) {
|
|
|
309
352
|
return ` ... on ${parentTypeName} `;
|
|
310
353
|
}
|
|
311
354
|
exports.getInlineFragmentString = getInlineFragmentString;
|
|
355
|
+
function extractNameNodeStringsToSet(nodes, set) {
|
|
356
|
+
for (const node of nodes) {
|
|
357
|
+
set.add(node.value);
|
|
358
|
+
}
|
|
359
|
+
return set;
|
|
360
|
+
}
|
|
361
|
+
exports.extractNameNodeStringsToSet = extractNameNodeStringsToSet;
|
|
362
|
+
function extractExecutableDirectiveLocations(nodes, set) {
|
|
363
|
+
for (const node of nodes) {
|
|
364
|
+
const name = node.value;
|
|
365
|
+
if (utils_2.EXECUTABLE_DIRECTIVE_LOCATIONS.has(name)) {
|
|
366
|
+
set.add(name);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return set;
|
|
370
|
+
}
|
|
371
|
+
exports.extractExecutableDirectiveLocations = extractExecutableDirectiveLocations;
|
|
372
|
+
function mergeExecutableDirectiveLocations(nodes, directiveContainer) {
|
|
373
|
+
const mergedSet = new Set();
|
|
374
|
+
for (const node of nodes) {
|
|
375
|
+
const name = node.value;
|
|
376
|
+
if (directiveContainer.executableLocations.has(name)) {
|
|
377
|
+
mergedSet.add(name);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
directiveContainer.executableLocations = mergedSet;
|
|
381
|
+
return mergedSet;
|
|
382
|
+
}
|
|
383
|
+
exports.mergeExecutableDirectiveLocations = mergeExecutableDirectiveLocations;
|
|
384
|
+
function pushPersistedDirectivesAndGetNode(container) {
|
|
385
|
+
const persistedDirectives = [...container.directives.tags.values()];
|
|
386
|
+
const deprecatedDirective = container.directives.deprecated.directive;
|
|
387
|
+
if (deprecatedDirective) {
|
|
388
|
+
persistedDirectives.push(deprecatedDirective);
|
|
389
|
+
}
|
|
390
|
+
for (const directives of container.directives.directives.values()) {
|
|
391
|
+
persistedDirectives.push(...directives);
|
|
392
|
+
}
|
|
393
|
+
container.node.directives = persistedDirectives;
|
|
394
|
+
return container.node;
|
|
395
|
+
}
|
|
396
|
+
exports.pushPersistedDirectivesAndGetNode = pushPersistedDirectivesAndGetNode;
|
|
397
|
+
function addConcreteTypesForImplementedInterfaces(node, abstractToConcreteTypeNames) {
|
|
398
|
+
if (!node.interfaces || node.interfaces.length < 1) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const concreteTypeName = node.name.value;
|
|
402
|
+
for (const iFace of node.interfaces) {
|
|
403
|
+
const interfaceName = iFace.name.value;
|
|
404
|
+
const concreteTypes = abstractToConcreteTypeNames.get(interfaceName);
|
|
405
|
+
if (concreteTypes) {
|
|
406
|
+
concreteTypes.add(concreteTypeName);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
abstractToConcreteTypeNames.set(interfaceName, new Set([concreteTypeName]));
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
exports.addConcreteTypesForImplementedInterfaces = addConcreteTypesForImplementedInterfaces;
|
|
414
|
+
function addConcreteTypesForUnion(node, abstractToConcreteTypeNames) {
|
|
415
|
+
if (!node.types || node.types.length < 1) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
const unionName = node.name.value;
|
|
419
|
+
for (const member of node.types) {
|
|
420
|
+
const memberName = member.name.value;
|
|
421
|
+
const concreteTypes = abstractToConcreteTypeNames.get(unionName);
|
|
422
|
+
if (concreteTypes) {
|
|
423
|
+
concreteTypes.add(memberName);
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
abstractToConcreteTypeNames.set(unionName, new Set([memberName]));
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
exports.addConcreteTypesForUnion = addConcreteTypesForUnion;
|
|
431
|
+
function formatDescription(description) {
|
|
432
|
+
if (!description) {
|
|
433
|
+
return description;
|
|
434
|
+
}
|
|
435
|
+
let value = description.value;
|
|
436
|
+
if (description.block) {
|
|
437
|
+
const lines = value.split('\n');
|
|
438
|
+
if (lines.length > 1) {
|
|
439
|
+
value = lines.map((line) => line.trimStart()).join('\n');
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return { ...description, value: value, block: true };
|
|
443
|
+
}
|
|
444
|
+
exports.formatDescription = formatDescription;
|
|
445
|
+
function setLongestDescriptionForNode(existingNode, newDescription) {
|
|
446
|
+
if (!newDescription) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (!existingNode.description || newDescription.value.length > existingNode.description.value.length) {
|
|
450
|
+
existingNode.description = { ...newDescription, block: true };
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
exports.setLongestDescriptionForNode = setLongestDescriptionForNode;
|
|
312
454
|
//# sourceMappingURL=utils.js.map
|