@theguild/federation-composition 0.9.0 → 0.10.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/README.md +2 -1
- package/cjs/specifications/link.js +40 -5
- package/cjs/subgraph/helpers.js +2 -2
- package/cjs/subgraph/state.js +8 -0
- package/cjs/subgraph/validation/rules/elements/provides.js +8 -6
- package/cjs/subgraph/validation/rules/elements/requires.js +9 -7
- package/cjs/subgraph/validation/validate-state.js +9 -3
- package/cjs/subgraph/validation/validate-subgraph.js +4 -2
- package/cjs/subgraph/validation/validation-context.js +10 -0
- package/cjs/supergraph/composition/directive.js +3 -0
- package/cjs/supergraph/composition/enum-type.js +3 -0
- package/cjs/supergraph/composition/input-object-type.js +3 -0
- package/cjs/supergraph/composition/interface-type.js +4 -0
- package/cjs/supergraph/composition/object-type.js +18 -20
- package/cjs/supergraph/composition/scalar-type.js +2 -0
- package/cjs/supergraph/composition/union-type.js +2 -0
- package/cjs/supergraph/state.js +24 -26
- package/cjs/supergraph/validation/rules/fields-of-the-same-type-rule.js +35 -0
- package/cjs/supergraph/validation/rules/invalid-field-sharing-rule.js +4 -1
- package/cjs/supergraph/validation/rules/satisfiablity/constants.js +4 -0
- package/cjs/supergraph/validation/rules/satisfiablity/edge.js +64 -0
- package/cjs/supergraph/validation/rules/satisfiablity/errors.js +44 -0
- package/cjs/supergraph/validation/rules/satisfiablity/fields.js +147 -0
- package/cjs/supergraph/validation/rules/satisfiablity/finder.js +267 -0
- package/cjs/supergraph/validation/rules/satisfiablity/graph.js +675 -0
- package/cjs/supergraph/validation/rules/satisfiablity/helpers.js +41 -0
- package/cjs/supergraph/validation/rules/satisfiablity/move-validator.js +337 -0
- package/cjs/supergraph/validation/rules/satisfiablity/moves.js +52 -0
- package/cjs/supergraph/validation/rules/satisfiablity/node.js +89 -0
- package/cjs/supergraph/validation/rules/satisfiablity/operation-path.js +70 -0
- package/cjs/supergraph/validation/rules/satisfiablity/supergraph.js +37 -0
- package/cjs/supergraph/validation/rules/satisfiablity/walker.js +306 -0
- package/cjs/supergraph/validation/rules/satisfiablity-rule.js +45 -1081
- package/cjs/supergraph/validation/validate-supergraph.js +1 -1
- package/cjs/utils/logger.js +127 -0
- package/esm/specifications/link.js +40 -5
- package/esm/subgraph/helpers.js +2 -2
- package/esm/subgraph/state.js +8 -0
- package/esm/subgraph/validation/rules/elements/provides.js +8 -6
- package/esm/subgraph/validation/rules/elements/requires.js +9 -7
- package/esm/subgraph/validation/validate-state.js +9 -3
- package/esm/subgraph/validation/validate-subgraph.js +4 -2
- package/esm/subgraph/validation/validation-context.js +11 -1
- package/esm/supergraph/composition/directive.js +3 -0
- package/esm/supergraph/composition/enum-type.js +3 -0
- package/esm/supergraph/composition/input-object-type.js +3 -0
- package/esm/supergraph/composition/interface-type.js +4 -0
- package/esm/supergraph/composition/object-type.js +18 -20
- package/esm/supergraph/composition/scalar-type.js +2 -0
- package/esm/supergraph/composition/union-type.js +2 -0
- package/esm/supergraph/state.js +24 -26
- package/esm/supergraph/validation/rules/fields-of-the-same-type-rule.js +35 -0
- package/esm/supergraph/validation/rules/invalid-field-sharing-rule.js +4 -1
- package/esm/supergraph/validation/rules/satisfiablity/constants.js +1 -0
- package/esm/supergraph/validation/rules/satisfiablity/edge.js +54 -0
- package/esm/supergraph/validation/rules/satisfiablity/errors.js +40 -0
- package/esm/supergraph/validation/rules/satisfiablity/fields.js +142 -0
- package/esm/supergraph/validation/rules/satisfiablity/finder.js +261 -0
- package/esm/supergraph/validation/rules/satisfiablity/graph.js +671 -0
- package/esm/supergraph/validation/rules/satisfiablity/helpers.js +35 -0
- package/esm/supergraph/validation/rules/satisfiablity/move-validator.js +333 -0
- package/esm/supergraph/validation/rules/satisfiablity/moves.js +46 -0
- package/esm/supergraph/validation/rules/satisfiablity/node.js +85 -0
- package/esm/supergraph/validation/rules/satisfiablity/operation-path.js +66 -0
- package/esm/supergraph/validation/rules/satisfiablity/supergraph.js +33 -0
- package/esm/supergraph/validation/rules/satisfiablity/walker.js +301 -0
- package/esm/supergraph/validation/rules/satisfiablity-rule.js +40 -1076
- package/esm/supergraph/validation/validate-supergraph.js +1 -1
- package/esm/utils/logger.js +119 -0
- package/package.json +2 -1
- package/typings/subgraph/state.d.cts +2 -0
- package/typings/subgraph/state.d.ts +2 -0
- package/typings/subgraph/validation/validate-state.d.cts +2 -1
- package/typings/subgraph/validation/validate-state.d.ts +2 -1
- package/typings/subgraph/validation/validation-context.d.cts +3 -0
- package/typings/subgraph/validation/validation-context.d.ts +3 -0
- package/typings/supergraph/composition/common.d.cts +2 -1
- package/typings/supergraph/composition/common.d.ts +2 -1
- package/typings/supergraph/composition/directive.d.cts +4 -0
- package/typings/supergraph/composition/directive.d.ts +4 -0
- package/typings/supergraph/composition/enum-type.d.cts +4 -0
- package/typings/supergraph/composition/enum-type.d.ts +4 -0
- package/typings/supergraph/composition/input-object-type.d.cts +4 -0
- package/typings/supergraph/composition/input-object-type.d.ts +4 -0
- package/typings/supergraph/composition/interface-type.d.cts +5 -0
- package/typings/supergraph/composition/interface-type.d.ts +5 -0
- package/typings/supergraph/composition/object-type.d.cts +5 -0
- package/typings/supergraph/composition/object-type.d.ts +5 -0
- package/typings/supergraph/composition/scalar-type.d.cts +3 -0
- package/typings/supergraph/composition/scalar-type.d.ts +3 -0
- package/typings/supergraph/composition/union-type.d.cts +3 -0
- package/typings/supergraph/composition/union-type.d.ts +3 -0
- package/typings/supergraph/state.d.cts +4 -4
- package/typings/supergraph/state.d.ts +4 -4
- package/typings/supergraph/validation/rules/satisfiablity/constants.d.cts +2 -0
- package/typings/supergraph/validation/rules/satisfiablity/constants.d.ts +2 -0
- package/typings/supergraph/validation/rules/satisfiablity/edge.d.cts +31 -0
- package/typings/supergraph/validation/rules/satisfiablity/edge.d.ts +31 -0
- package/typings/supergraph/validation/rules/satisfiablity/errors.d.cts +17 -0
- package/typings/supergraph/validation/rules/satisfiablity/errors.d.ts +17 -0
- package/typings/supergraph/validation/rules/satisfiablity/fields.d.cts +33 -0
- package/typings/supergraph/validation/rules/satisfiablity/fields.d.ts +33 -0
- package/typings/supergraph/validation/rules/satisfiablity/finder.d.cts +28 -0
- package/typings/supergraph/validation/rules/satisfiablity/finder.d.ts +28 -0
- package/typings/supergraph/validation/rules/satisfiablity/graph.d.cts +63 -0
- package/typings/supergraph/validation/rules/satisfiablity/graph.d.ts +63 -0
- package/typings/supergraph/validation/rules/satisfiablity/helpers.d.cts +7 -0
- package/typings/supergraph/validation/rules/satisfiablity/helpers.d.ts +7 -0
- package/typings/supergraph/validation/rules/satisfiablity/move-validator.d.cts +25 -0
- package/typings/supergraph/validation/rules/satisfiablity/move-validator.d.ts +25 -0
- package/typings/supergraph/validation/rules/satisfiablity/moves.d.cts +24 -0
- package/typings/supergraph/validation/rules/satisfiablity/moves.d.ts +24 -0
- package/typings/supergraph/validation/rules/satisfiablity/node.d.cts +31 -0
- package/typings/supergraph/validation/rules/satisfiablity/node.d.ts +31 -0
- package/typings/supergraph/validation/rules/satisfiablity/operation-path.d.cts +29 -0
- package/typings/supergraph/validation/rules/satisfiablity/operation-path.d.ts +29 -0
- package/typings/supergraph/validation/rules/satisfiablity/supergraph.d.cts +14 -0
- package/typings/supergraph/validation/rules/satisfiablity/supergraph.d.ts +14 -0
- package/typings/supergraph/validation/rules/satisfiablity/walker.d.cts +35 -0
- package/typings/supergraph/validation/rules/satisfiablity/walker.d.ts +35 -0
- package/typings/utils/logger.d.cts +33 -0
- package/typings/utils/logger.d.ts +33 -0
- package/cjs/utils/dependency-graph.js +0 -227
- package/esm/utils/dependency-graph.js +0 -222
- package/typings/utils/dependency-graph.d.cts +0 -31
- package/typings/utils/dependency-graph.d.ts +0 -31
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DirectiveDefinitionNode, TypeDefinitionNode } from 'graphql';
|
|
2
2
|
import { Link } from '../specifications/link.js';
|
|
3
3
|
import { SubgraphState } from '../subgraph/state.js';
|
|
4
|
-
import { Graph } from './composition/common.js';
|
|
5
4
|
import { DirectiveState } from './composition/directive.js';
|
|
6
5
|
import { EnumTypeState } from './composition/enum-type.js';
|
|
7
6
|
import { InputObjectTypeState } from './composition/input-object-type.js';
|
|
@@ -10,7 +9,7 @@ import { ObjectTypeState } from './composition/object-type.js';
|
|
|
10
9
|
import { ScalarTypeState } from './composition/scalar-type.js';
|
|
11
10
|
import { UnionTypeState } from './composition/union-type.js';
|
|
12
11
|
export type SupergraphState = {
|
|
13
|
-
|
|
12
|
+
subgraphs: Map<string, SubgraphState>;
|
|
14
13
|
scalarTypes: Map<string, ScalarTypeState>;
|
|
15
14
|
objectTypes: Map<string, ObjectTypeState>;
|
|
16
15
|
interfaceTypes: Map<string, InterfaceTypeState>;
|
|
@@ -31,10 +30,11 @@ export type SupergraphState = {
|
|
|
31
30
|
};
|
|
32
31
|
export type SupergraphStateBuilder = ReturnType<typeof createSupergraphStateBuilder>;
|
|
33
32
|
export declare function createSupergraphStateBuilder(): {
|
|
34
|
-
|
|
35
|
-
getGraph(id: string):
|
|
33
|
+
addSubgraph(subgraph: SubgraphState): void;
|
|
34
|
+
getGraph(id: string): SubgraphState | undefined;
|
|
36
35
|
visitSubgraphState(subgraphState: SubgraphState): void;
|
|
37
36
|
getSupergraphState(): SupergraphState;
|
|
37
|
+
getSubgraphState(graphId: string): SubgraphState | undefined;
|
|
38
38
|
links(): readonly {
|
|
39
39
|
name: string | null;
|
|
40
40
|
version: string | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SatisfiabilityError } from './errors';
|
|
2
|
+
import { AbstractMove, EntityMove, FieldMove, Move } from './moves';
|
|
3
|
+
import { Node } from './node';
|
|
4
|
+
type EdgeResolvabilityResult = {
|
|
5
|
+
success: true;
|
|
6
|
+
error: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
success: false;
|
|
9
|
+
error: SatisfiabilityError;
|
|
10
|
+
};
|
|
11
|
+
export declare function isEntityEdge(edge: Edge): edge is Edge<EntityMove>;
|
|
12
|
+
export declare function assertEntityEdge(edge: Edge): asserts edge is Edge<EntityMove>;
|
|
13
|
+
export declare function isAbstractEdge(edge: Edge): edge is Edge<AbstractMove>;
|
|
14
|
+
export declare function assertAbstractEdge(edge: Edge): asserts edge is Edge<AbstractMove>;
|
|
15
|
+
export declare function isFieldEdge(edge: Edge): edge is Edge<FieldMove>;
|
|
16
|
+
export declare function assertFieldEdge(edge: Edge): asserts edge is Edge<FieldMove>;
|
|
17
|
+
export declare class Edge<T = Move> {
|
|
18
|
+
head: Node;
|
|
19
|
+
move: T;
|
|
20
|
+
tail: Node;
|
|
21
|
+
private resolvable;
|
|
22
|
+
private _toString;
|
|
23
|
+
constructor(head: Node, move: T, tail: Node);
|
|
24
|
+
isCrossGraphEdge(): boolean;
|
|
25
|
+
toString(): string;
|
|
26
|
+
getResolvability(graphNames: string[]): EdgeResolvabilityResult | undefined;
|
|
27
|
+
setResolvable(success: true, graphNames: string[]): EdgeResolvabilityResult;
|
|
28
|
+
setResolvable(success: false, graphNames: string[], error: SatisfiabilityError): EdgeResolvabilityResult;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=edge.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SatisfiabilityError } from './errors';
|
|
2
|
+
import { AbstractMove, EntityMove, FieldMove, Move } from './moves';
|
|
3
|
+
import { Node } from './node';
|
|
4
|
+
type EdgeResolvabilityResult = {
|
|
5
|
+
success: true;
|
|
6
|
+
error: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
success: false;
|
|
9
|
+
error: SatisfiabilityError;
|
|
10
|
+
};
|
|
11
|
+
export declare function isEntityEdge(edge: Edge): edge is Edge<EntityMove>;
|
|
12
|
+
export declare function assertEntityEdge(edge: Edge): asserts edge is Edge<EntityMove>;
|
|
13
|
+
export declare function isAbstractEdge(edge: Edge): edge is Edge<AbstractMove>;
|
|
14
|
+
export declare function assertAbstractEdge(edge: Edge): asserts edge is Edge<AbstractMove>;
|
|
15
|
+
export declare function isFieldEdge(edge: Edge): edge is Edge<FieldMove>;
|
|
16
|
+
export declare function assertFieldEdge(edge: Edge): asserts edge is Edge<FieldMove>;
|
|
17
|
+
export declare class Edge<T = Move> {
|
|
18
|
+
head: Node;
|
|
19
|
+
move: T;
|
|
20
|
+
tail: Node;
|
|
21
|
+
private resolvable;
|
|
22
|
+
private _toString;
|
|
23
|
+
constructor(head: Node, move: T, tail: Node);
|
|
24
|
+
isCrossGraphEdge(): boolean;
|
|
25
|
+
toString(): string;
|
|
26
|
+
getResolvability(graphNames: string[]): EdgeResolvabilityResult | undefined;
|
|
27
|
+
setResolvable(success: true, graphNames: string[]): EdgeResolvabilityResult;
|
|
28
|
+
setResolvable(success: false, graphNames: string[], error: SatisfiabilityError): EdgeResolvabilityResult;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=edge.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type SatisfiabilityErrorKind = 'KEY' | 'REQUIRE' | 'EXTERNAL' | 'MISSING_FIELD' | 'NO_KEY';
|
|
2
|
+
export declare class SatisfiabilityError extends Error {
|
|
3
|
+
kind: SatisfiabilityErrorKind;
|
|
4
|
+
sourceGraphName: string;
|
|
5
|
+
typeName: string;
|
|
6
|
+
fieldName: string | null;
|
|
7
|
+
static forKey(sourceGraphName: string, targetGraphName: string, typeName: string, keyFields: string): SatisfiabilityError;
|
|
8
|
+
static forRequire(sourceGraphName: string, typeName: string, fieldName: string): SatisfiabilityError;
|
|
9
|
+
static forExternal(sourceGraphName: string, typeName: string, fieldName: string): SatisfiabilityError;
|
|
10
|
+
static forMissingField(sourceGraphName: string, typeName: string, fieldName: string): SatisfiabilityError;
|
|
11
|
+
static forNoKey(sourceGraphName: string, targetGraphName: string, typeName: string, fieldName: string): SatisfiabilityError;
|
|
12
|
+
private constructor();
|
|
13
|
+
isMatchingField(typeName: string, fieldName: string): boolean;
|
|
14
|
+
toString(): string;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type SatisfiabilityErrorKind = 'KEY' | 'REQUIRE' | 'EXTERNAL' | 'MISSING_FIELD' | 'NO_KEY';
|
|
2
|
+
export declare class SatisfiabilityError extends Error {
|
|
3
|
+
kind: SatisfiabilityErrorKind;
|
|
4
|
+
sourceGraphName: string;
|
|
5
|
+
typeName: string;
|
|
6
|
+
fieldName: string | null;
|
|
7
|
+
static forKey(sourceGraphName: string, targetGraphName: string, typeName: string, keyFields: string): SatisfiabilityError;
|
|
8
|
+
static forRequire(sourceGraphName: string, typeName: string, fieldName: string): SatisfiabilityError;
|
|
9
|
+
static forExternal(sourceGraphName: string, typeName: string, fieldName: string): SatisfiabilityError;
|
|
10
|
+
static forMissingField(sourceGraphName: string, typeName: string, fieldName: string): SatisfiabilityError;
|
|
11
|
+
static forNoKey(sourceGraphName: string, targetGraphName: string, typeName: string, fieldName: string): SatisfiabilityError;
|
|
12
|
+
private constructor();
|
|
13
|
+
isMatchingField(typeName: string, fieldName: string): boolean;
|
|
14
|
+
toString(): string;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SupergraphState } from '../../../state';
|
|
2
|
+
export type Field = {
|
|
3
|
+
typeName: string;
|
|
4
|
+
fieldName: string;
|
|
5
|
+
selectionSet: null;
|
|
6
|
+
} | {
|
|
7
|
+
typeName: string;
|
|
8
|
+
fieldName: string;
|
|
9
|
+
selectionSet: Array<Field>;
|
|
10
|
+
};
|
|
11
|
+
export declare class Fields {
|
|
12
|
+
private typeName;
|
|
13
|
+
private source;
|
|
14
|
+
fields: Field[];
|
|
15
|
+
constructor(typeName: string, source: string, fields: Field[]);
|
|
16
|
+
contains(typeName: string, fieldName: string): boolean;
|
|
17
|
+
equals(other: Fields): boolean;
|
|
18
|
+
private _fieldsEqual;
|
|
19
|
+
private _contains;
|
|
20
|
+
toString(): string;
|
|
21
|
+
}
|
|
22
|
+
export declare class FieldsResolver {
|
|
23
|
+
private supergraphState;
|
|
24
|
+
private cache;
|
|
25
|
+
constructor(supergraphState: SupergraphState);
|
|
26
|
+
resolve(typeName: string, keyFields: string): Fields;
|
|
27
|
+
private keyFactory;
|
|
28
|
+
private resolveFieldNode;
|
|
29
|
+
private resolveInlineFragmentNode;
|
|
30
|
+
private resolveSelectionSetNode;
|
|
31
|
+
private sortFields;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SupergraphState } from '../../../state';
|
|
2
|
+
export type Field = {
|
|
3
|
+
typeName: string;
|
|
4
|
+
fieldName: string;
|
|
5
|
+
selectionSet: null;
|
|
6
|
+
} | {
|
|
7
|
+
typeName: string;
|
|
8
|
+
fieldName: string;
|
|
9
|
+
selectionSet: Array<Field>;
|
|
10
|
+
};
|
|
11
|
+
export declare class Fields {
|
|
12
|
+
private typeName;
|
|
13
|
+
private source;
|
|
14
|
+
fields: Field[];
|
|
15
|
+
constructor(typeName: string, source: string, fields: Field[]);
|
|
16
|
+
contains(typeName: string, fieldName: string): boolean;
|
|
17
|
+
equals(other: Fields): boolean;
|
|
18
|
+
private _fieldsEqual;
|
|
19
|
+
private _contains;
|
|
20
|
+
toString(): string;
|
|
21
|
+
}
|
|
22
|
+
export declare class FieldsResolver {
|
|
23
|
+
private supergraphState;
|
|
24
|
+
private cache;
|
|
25
|
+
constructor(supergraphState: SupergraphState);
|
|
26
|
+
resolve(typeName: string, keyFields: string): Fields;
|
|
27
|
+
private keyFactory;
|
|
28
|
+
private resolveFieldNode;
|
|
29
|
+
private resolveInlineFragmentNode;
|
|
30
|
+
private resolveSelectionSetNode;
|
|
31
|
+
private sortFields;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Logger } from '../../../../utils/logger';
|
|
2
|
+
import { Edge } from './edge';
|
|
3
|
+
import { SatisfiabilityError } from './errors';
|
|
4
|
+
import { Fields } from './fields';
|
|
5
|
+
import type { Graph } from './graph';
|
|
6
|
+
import type { MoveValidator } from './move-validator';
|
|
7
|
+
import type { OperationPath } from './operation-path';
|
|
8
|
+
export declare function concatIfNotExistsString(list: string[], item: string): string[];
|
|
9
|
+
export declare function concatIfNotExistsFields(list: Fields[], item: Fields): Fields[];
|
|
10
|
+
type PathFinderResult = {
|
|
11
|
+
success: true;
|
|
12
|
+
paths: OperationPath[];
|
|
13
|
+
errors: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
success: false;
|
|
16
|
+
paths: undefined;
|
|
17
|
+
errors: SatisfiabilityError[];
|
|
18
|
+
};
|
|
19
|
+
export declare class PathFinder {
|
|
20
|
+
private logger;
|
|
21
|
+
private graph;
|
|
22
|
+
private moveValidator;
|
|
23
|
+
constructor(logger: Logger, graph: Graph, moveValidator: MoveValidator);
|
|
24
|
+
findDirectPaths(path: OperationPath, typeName: string, fieldName: string | null, visitedEdges: Edge[]): PathFinderResult;
|
|
25
|
+
findIndirectPaths(path: OperationPath, typeName: string, fieldName: string | null, visitedEdges: Edge[], visitedGraphs: string[], visitedFields: Fields[]): PathFinderResult;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=finder.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Logger } from '../../../../utils/logger';
|
|
2
|
+
import { Edge } from './edge';
|
|
3
|
+
import { SatisfiabilityError } from './errors';
|
|
4
|
+
import { Fields } from './fields';
|
|
5
|
+
import type { Graph } from './graph';
|
|
6
|
+
import type { MoveValidator } from './move-validator';
|
|
7
|
+
import type { OperationPath } from './operation-path';
|
|
8
|
+
export declare function concatIfNotExistsString(list: string[], item: string): string[];
|
|
9
|
+
export declare function concatIfNotExistsFields(list: Fields[], item: Fields): Fields[];
|
|
10
|
+
type PathFinderResult = {
|
|
11
|
+
success: true;
|
|
12
|
+
paths: OperationPath[];
|
|
13
|
+
errors: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
success: false;
|
|
16
|
+
paths: undefined;
|
|
17
|
+
errors: SatisfiabilityError[];
|
|
18
|
+
};
|
|
19
|
+
export declare class PathFinder {
|
|
20
|
+
private logger;
|
|
21
|
+
private graph;
|
|
22
|
+
private moveValidator;
|
|
23
|
+
constructor(logger: Logger, graph: Graph, moveValidator: MoveValidator);
|
|
24
|
+
findDirectPaths(path: OperationPath, typeName: string, fieldName: string | null, visitedEdges: Edge[]): PathFinderResult;
|
|
25
|
+
findIndirectPaths(path: OperationPath, typeName: string, fieldName: string | null, visitedEdges: Edge[], visitedGraphs: string[], visitedFields: Fields[]): PathFinderResult;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=finder.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Logger } from '../../../../utils/logger';
|
|
2
|
+
import type { SupergraphState } from '../../../state';
|
|
3
|
+
import { Edge } from './edge';
|
|
4
|
+
import type { FieldsResolver } from './fields';
|
|
5
|
+
import { Node } from './node';
|
|
6
|
+
export declare class Graph {
|
|
7
|
+
name: string;
|
|
8
|
+
private supergraphState;
|
|
9
|
+
private fieldsResolver;
|
|
10
|
+
private ignoreInaccessible;
|
|
11
|
+
private _warnedAboutIncorrectEdge;
|
|
12
|
+
private nodesByTypeIndex;
|
|
13
|
+
private edgesByHeadTypeIndex;
|
|
14
|
+
private edgesByTailTypeIndex;
|
|
15
|
+
private typeNameToNodeIndexes;
|
|
16
|
+
private typeChildren;
|
|
17
|
+
private typeChildrenCache;
|
|
18
|
+
private isSubgraph;
|
|
19
|
+
private logger;
|
|
20
|
+
private id;
|
|
21
|
+
private idSymbol;
|
|
22
|
+
constructor(logger: Logger, id: string | Symbol, name: string, supergraphState: SupergraphState, fieldsResolver: FieldsResolver, ignoreInaccessible?: boolean);
|
|
23
|
+
addUnreachableTypes(): this;
|
|
24
|
+
addFromRoots(): this;
|
|
25
|
+
addFromEntities(): this;
|
|
26
|
+
addSubgraph(graph: Graph): void;
|
|
27
|
+
private connectUnionOrInterface;
|
|
28
|
+
private connectEntities;
|
|
29
|
+
private addProvidedInterfaceFields;
|
|
30
|
+
private addProvidedField;
|
|
31
|
+
joinSubgraphs(): this;
|
|
32
|
+
private duplicateNode;
|
|
33
|
+
private replaceEdgeAt;
|
|
34
|
+
print(asLink?: boolean): string;
|
|
35
|
+
graphNameToId(graphName: string): string | undefined;
|
|
36
|
+
nodeOf(typeName: string, failIfMissing?: boolean): Node | undefined;
|
|
37
|
+
nodesOf(typeName: string, failIfMissing?: boolean): Node[];
|
|
38
|
+
private getSameGraphEdgesOfIndex;
|
|
39
|
+
fieldEdgesOfHead(head: Node, fieldName: string): Edge[];
|
|
40
|
+
abstractEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
41
|
+
entityEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
42
|
+
crossGraphEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
43
|
+
edgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
44
|
+
edgesOfTail(tail: Node): Edge<import("./moves").Move>[];
|
|
45
|
+
possibleTypesOf(typeName: string): string[];
|
|
46
|
+
canReachTypeFromType(fromTypeName: string, toTypeName: string): boolean;
|
|
47
|
+
private createNodesAndEdgesForType;
|
|
48
|
+
private ensureNonOrSingleNode;
|
|
49
|
+
private createNodesAndEdgesForObjectType;
|
|
50
|
+
private createNodeForScalarType;
|
|
51
|
+
private createNodeForEnumType;
|
|
52
|
+
private createNodeForUnionType;
|
|
53
|
+
private createNodeForInterfaceType;
|
|
54
|
+
private createEdgeForObjectTypeField;
|
|
55
|
+
private createTypeNode;
|
|
56
|
+
private createNode;
|
|
57
|
+
private addNode;
|
|
58
|
+
private addEdge;
|
|
59
|
+
private getIndexesOfType;
|
|
60
|
+
private trueOrIfSubgraphThen;
|
|
61
|
+
private isSupergraph;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Logger } from '../../../../utils/logger';
|
|
2
|
+
import type { SupergraphState } from '../../../state';
|
|
3
|
+
import { Edge } from './edge';
|
|
4
|
+
import type { FieldsResolver } from './fields';
|
|
5
|
+
import { Node } from './node';
|
|
6
|
+
export declare class Graph {
|
|
7
|
+
name: string;
|
|
8
|
+
private supergraphState;
|
|
9
|
+
private fieldsResolver;
|
|
10
|
+
private ignoreInaccessible;
|
|
11
|
+
private _warnedAboutIncorrectEdge;
|
|
12
|
+
private nodesByTypeIndex;
|
|
13
|
+
private edgesByHeadTypeIndex;
|
|
14
|
+
private edgesByTailTypeIndex;
|
|
15
|
+
private typeNameToNodeIndexes;
|
|
16
|
+
private typeChildren;
|
|
17
|
+
private typeChildrenCache;
|
|
18
|
+
private isSubgraph;
|
|
19
|
+
private logger;
|
|
20
|
+
private id;
|
|
21
|
+
private idSymbol;
|
|
22
|
+
constructor(logger: Logger, id: string | Symbol, name: string, supergraphState: SupergraphState, fieldsResolver: FieldsResolver, ignoreInaccessible?: boolean);
|
|
23
|
+
addUnreachableTypes(): this;
|
|
24
|
+
addFromRoots(): this;
|
|
25
|
+
addFromEntities(): this;
|
|
26
|
+
addSubgraph(graph: Graph): void;
|
|
27
|
+
private connectUnionOrInterface;
|
|
28
|
+
private connectEntities;
|
|
29
|
+
private addProvidedInterfaceFields;
|
|
30
|
+
private addProvidedField;
|
|
31
|
+
joinSubgraphs(): this;
|
|
32
|
+
private duplicateNode;
|
|
33
|
+
private replaceEdgeAt;
|
|
34
|
+
print(asLink?: boolean): string;
|
|
35
|
+
graphNameToId(graphName: string): string | undefined;
|
|
36
|
+
nodeOf(typeName: string, failIfMissing?: boolean): Node | undefined;
|
|
37
|
+
nodesOf(typeName: string, failIfMissing?: boolean): Node[];
|
|
38
|
+
private getSameGraphEdgesOfIndex;
|
|
39
|
+
fieldEdgesOfHead(head: Node, fieldName: string): Edge[];
|
|
40
|
+
abstractEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
41
|
+
entityEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
42
|
+
crossGraphEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
43
|
+
edgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
44
|
+
edgesOfTail(tail: Node): Edge<import("./moves").Move>[];
|
|
45
|
+
possibleTypesOf(typeName: string): string[];
|
|
46
|
+
canReachTypeFromType(fromTypeName: string, toTypeName: string): boolean;
|
|
47
|
+
private createNodesAndEdgesForType;
|
|
48
|
+
private ensureNonOrSingleNode;
|
|
49
|
+
private createNodesAndEdgesForObjectType;
|
|
50
|
+
private createNodeForScalarType;
|
|
51
|
+
private createNodeForEnumType;
|
|
52
|
+
private createNodeForUnionType;
|
|
53
|
+
private createNodeForInterfaceType;
|
|
54
|
+
private createEdgeForObjectTypeField;
|
|
55
|
+
private createTypeNode;
|
|
56
|
+
private createNode;
|
|
57
|
+
private addNode;
|
|
58
|
+
private addEdge;
|
|
59
|
+
private getIndexesOfType;
|
|
60
|
+
private trueOrIfSubgraphThen;
|
|
61
|
+
private isSupergraph;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function occurrences(str: string, subString: string): number;
|
|
2
|
+
export declare function scoreKeyFields(keyFields: string): number;
|
|
3
|
+
export declare function lazy(factory: () => string): {
|
|
4
|
+
get(): string;
|
|
5
|
+
invalidate(): void;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function occurrences(str: string, subString: string): number;
|
|
2
|
+
export declare function scoreKeyFields(keyFields: string): number;
|
|
3
|
+
export declare function lazy(factory: () => string): {
|
|
4
|
+
get(): string;
|
|
5
|
+
invalidate(): void;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Logger } from '../../../../utils/logger';
|
|
2
|
+
import { Edge } from './edge';
|
|
3
|
+
import { SatisfiabilityError } from './errors';
|
|
4
|
+
import type { Fields } from './fields';
|
|
5
|
+
import type { Graph } from './graph';
|
|
6
|
+
import { OperationPath } from './operation-path';
|
|
7
|
+
export declare class MoveValidator {
|
|
8
|
+
private supergraph;
|
|
9
|
+
private cache;
|
|
10
|
+
private logger;
|
|
11
|
+
private pathFinder;
|
|
12
|
+
constructor(logger: Logger, supergraph: Graph);
|
|
13
|
+
private canResolveFields;
|
|
14
|
+
private validateRequirement;
|
|
15
|
+
isExternal(edge: Edge): boolean;
|
|
16
|
+
private isOverridden;
|
|
17
|
+
isEdgeResolvable(edge: Edge, path: OperationPath, visitedEdges: Edge[], visitedGraphs: string[], visitedFields: Fields[]): {
|
|
18
|
+
success: true;
|
|
19
|
+
error: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
success: false;
|
|
22
|
+
error: SatisfiabilityError;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=move-validator.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Logger } from '../../../../utils/logger';
|
|
2
|
+
import { Edge } from './edge';
|
|
3
|
+
import { SatisfiabilityError } from './errors';
|
|
4
|
+
import type { Fields } from './fields';
|
|
5
|
+
import type { Graph } from './graph';
|
|
6
|
+
import { OperationPath } from './operation-path';
|
|
7
|
+
export declare class MoveValidator {
|
|
8
|
+
private supergraph;
|
|
9
|
+
private cache;
|
|
10
|
+
private logger;
|
|
11
|
+
private pathFinder;
|
|
12
|
+
constructor(logger: Logger, supergraph: Graph);
|
|
13
|
+
private canResolveFields;
|
|
14
|
+
private validateRequirement;
|
|
15
|
+
isExternal(edge: Edge): boolean;
|
|
16
|
+
private isOverridden;
|
|
17
|
+
isEdgeResolvable(edge: Edge, path: OperationPath, visitedEdges: Edge[], visitedGraphs: string[], visitedFields: Fields[]): {
|
|
18
|
+
success: true;
|
|
19
|
+
error: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
success: false;
|
|
22
|
+
error: SatisfiabilityError;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=move-validator.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Fields } from './fields';
|
|
2
|
+
export interface Move {
|
|
3
|
+
toString(): string;
|
|
4
|
+
}
|
|
5
|
+
export declare class FieldMove implements Move {
|
|
6
|
+
typeName: string;
|
|
7
|
+
fieldName: string;
|
|
8
|
+
requires: Fields | null;
|
|
9
|
+
provides: Fields | null;
|
|
10
|
+
provided: boolean;
|
|
11
|
+
private _toString;
|
|
12
|
+
constructor(typeName: string, fieldName: string, requires?: Fields | null, provides?: Fields | null, provided?: boolean);
|
|
13
|
+
toString(): string;
|
|
14
|
+
}
|
|
15
|
+
export declare class AbstractMove implements Move {
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
18
|
+
export declare class EntityMove implements Move {
|
|
19
|
+
keyFields: Fields;
|
|
20
|
+
private _toString;
|
|
21
|
+
constructor(keyFields: Fields);
|
|
22
|
+
toString(): string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=moves.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Fields } from './fields';
|
|
2
|
+
export interface Move {
|
|
3
|
+
toString(): string;
|
|
4
|
+
}
|
|
5
|
+
export declare class FieldMove implements Move {
|
|
6
|
+
typeName: string;
|
|
7
|
+
fieldName: string;
|
|
8
|
+
requires: Fields | null;
|
|
9
|
+
provides: Fields | null;
|
|
10
|
+
provided: boolean;
|
|
11
|
+
private _toString;
|
|
12
|
+
constructor(typeName: string, fieldName: string, requires?: Fields | null, provides?: Fields | null, provided?: boolean);
|
|
13
|
+
toString(): string;
|
|
14
|
+
}
|
|
15
|
+
export declare class AbstractMove implements Move {
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
18
|
+
export declare class EntityMove implements Move {
|
|
19
|
+
keyFields: Fields;
|
|
20
|
+
private _toString;
|
|
21
|
+
constructor(keyFields: Fields);
|
|
22
|
+
toString(): string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=moves.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { EnumTypeState } from '../../../composition/enum-type';
|
|
2
|
+
import type { InterfaceTypeState } from '../../../composition/interface-type';
|
|
3
|
+
import type { ObjectTypeState } from '../../../composition/object-type';
|
|
4
|
+
import type { ScalarTypeState } from '../../../composition/scalar-type';
|
|
5
|
+
import type { UnionTypeState } from '../../../composition/union-type';
|
|
6
|
+
export declare class Node {
|
|
7
|
+
index: number;
|
|
8
|
+
typeName: string;
|
|
9
|
+
typeState: ObjectTypeState | InterfaceTypeState | EnumTypeState | ScalarTypeState | UnionTypeState | null;
|
|
10
|
+
graphId: string;
|
|
11
|
+
graphName: string;
|
|
12
|
+
private _toString;
|
|
13
|
+
isLeaf: boolean;
|
|
14
|
+
private childrenIndex;
|
|
15
|
+
private visitedGraphCombos;
|
|
16
|
+
constructor(index: number, typeName: string, typeState: ObjectTypeState | InterfaceTypeState | EnumTypeState | ScalarTypeState | UnionTypeState | null, graphId: string, graphName: string);
|
|
17
|
+
withoutState(): this;
|
|
18
|
+
addFieldEdge(fieldName: string, edgeAt: number): void;
|
|
19
|
+
getFieldEdgeIndexes(fieldName: string): number[] | undefined;
|
|
20
|
+
addEntityEdge(typeName: string, edgeAt: number): void;
|
|
21
|
+
getEntityEdgeIndexes(typeName: string): number[] | undefined;
|
|
22
|
+
addAbstractEdge(typeName: string, edgeAt: number): void;
|
|
23
|
+
getAbstractEdgeIndexes(typeName: string): number[] | undefined;
|
|
24
|
+
addCrossGraphEdge(typeName: string, edgeAt: number): void;
|
|
25
|
+
getCrossGraphEdgeIndexes(typeName: string): number[] | undefined;
|
|
26
|
+
private pushToChildrenIndex;
|
|
27
|
+
isGraphComboVisited(graphNameProvidesCombos: string[]): boolean;
|
|
28
|
+
setGraphComboAsVisited(graphNames: string[]): void;
|
|
29
|
+
toString(): string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { EnumTypeState } from '../../../composition/enum-type';
|
|
2
|
+
import type { InterfaceTypeState } from '../../../composition/interface-type';
|
|
3
|
+
import type { ObjectTypeState } from '../../../composition/object-type';
|
|
4
|
+
import type { ScalarTypeState } from '../../../composition/scalar-type';
|
|
5
|
+
import type { UnionTypeState } from '../../../composition/union-type';
|
|
6
|
+
export declare class Node {
|
|
7
|
+
index: number;
|
|
8
|
+
typeName: string;
|
|
9
|
+
typeState: ObjectTypeState | InterfaceTypeState | EnumTypeState | ScalarTypeState | UnionTypeState | null;
|
|
10
|
+
graphId: string;
|
|
11
|
+
graphName: string;
|
|
12
|
+
private _toString;
|
|
13
|
+
isLeaf: boolean;
|
|
14
|
+
private childrenIndex;
|
|
15
|
+
private visitedGraphCombos;
|
|
16
|
+
constructor(index: number, typeName: string, typeState: ObjectTypeState | InterfaceTypeState | EnumTypeState | ScalarTypeState | UnionTypeState | null, graphId: string, graphName: string);
|
|
17
|
+
withoutState(): this;
|
|
18
|
+
addFieldEdge(fieldName: string, edgeAt: number): void;
|
|
19
|
+
getFieldEdgeIndexes(fieldName: string): number[] | undefined;
|
|
20
|
+
addEntityEdge(typeName: string, edgeAt: number): void;
|
|
21
|
+
getEntityEdgeIndexes(typeName: string): number[] | undefined;
|
|
22
|
+
addAbstractEdge(typeName: string, edgeAt: number): void;
|
|
23
|
+
getAbstractEdgeIndexes(typeName: string): number[] | undefined;
|
|
24
|
+
addCrossGraphEdge(typeName: string, edgeAt: number): void;
|
|
25
|
+
getCrossGraphEdgeIndexes(typeName: string): number[] | undefined;
|
|
26
|
+
private pushToChildrenIndex;
|
|
27
|
+
isGraphComboVisited(graphNameProvidesCombos: string[]): boolean;
|
|
28
|
+
setGraphComboAsVisited(graphNames: string[]): void;
|
|
29
|
+
toString(): string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Edge } from './edge';
|
|
2
|
+
import type { Node } from './node';
|
|
3
|
+
export type Step = FieldStep | AbstractStep;
|
|
4
|
+
export type FieldStep = {
|
|
5
|
+
fieldName: string;
|
|
6
|
+
typeName: string;
|
|
7
|
+
};
|
|
8
|
+
export type AbstractStep = {
|
|
9
|
+
typeName: string;
|
|
10
|
+
};
|
|
11
|
+
export declare class OperationPath {
|
|
12
|
+
private _rootNode;
|
|
13
|
+
private _toString;
|
|
14
|
+
private previousNodes;
|
|
15
|
+
private previousEdges;
|
|
16
|
+
private previousSteps;
|
|
17
|
+
constructor(_rootNode: Node);
|
|
18
|
+
move(edge: Edge): OperationPath;
|
|
19
|
+
clone(): OperationPath;
|
|
20
|
+
depth(): number;
|
|
21
|
+
edge(): Edge | undefined;
|
|
22
|
+
steps(): Step[];
|
|
23
|
+
tail(): Node | undefined;
|
|
24
|
+
rootNode(): Node;
|
|
25
|
+
isVisitedEdge(edge: Edge): boolean;
|
|
26
|
+
toString(): string;
|
|
27
|
+
private advance;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=operation-path.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Edge } from './edge';
|
|
2
|
+
import type { Node } from './node';
|
|
3
|
+
export type Step = FieldStep | AbstractStep;
|
|
4
|
+
export type FieldStep = {
|
|
5
|
+
fieldName: string;
|
|
6
|
+
typeName: string;
|
|
7
|
+
};
|
|
8
|
+
export type AbstractStep = {
|
|
9
|
+
typeName: string;
|
|
10
|
+
};
|
|
11
|
+
export declare class OperationPath {
|
|
12
|
+
private _rootNode;
|
|
13
|
+
private _toString;
|
|
14
|
+
private previousNodes;
|
|
15
|
+
private previousEdges;
|
|
16
|
+
private previousSteps;
|
|
17
|
+
constructor(_rootNode: Node);
|
|
18
|
+
move(edge: Edge): OperationPath;
|
|
19
|
+
clone(): OperationPath;
|
|
20
|
+
depth(): number;
|
|
21
|
+
edge(): Edge | undefined;
|
|
22
|
+
steps(): Step[];
|
|
23
|
+
tail(): Node | undefined;
|
|
24
|
+
rootNode(): Node;
|
|
25
|
+
isVisitedEdge(edge: Edge): boolean;
|
|
26
|
+
toString(): string;
|
|
27
|
+
private advance;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=operation-path.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OperationTypeNode } from 'graphql';
|
|
2
|
+
import type { SupergraphState } from '../../../state';
|
|
3
|
+
import { Step } from './operation-path';
|
|
4
|
+
export declare class Supergraph {
|
|
5
|
+
private supergraph;
|
|
6
|
+
private mergedGraph;
|
|
7
|
+
private fieldsResolver;
|
|
8
|
+
private moveRequirementChecker;
|
|
9
|
+
private logger;
|
|
10
|
+
constructor(supergraphState: SupergraphState);
|
|
11
|
+
validate(): import("./walker").WalkTracker[];
|
|
12
|
+
validateOperation(operation: OperationTypeNode, steps: Step[]): import("./walker").WalkTracker;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=supergraph.d.ts.map
|