UNPKG

1.66 kBTypeScriptView Raw
1import { Subject } from "./Subject";
2import { EntityMetadata } from "../metadata/EntityMetadata";
3/**
4 * Orders insert or remove subjects in proper order (using topological sorting)
5 * to make sure insert or remove operations are executed in a proper order.
6 */
7export declare class SubjectTopoligicalSorter {
8 /**
9 * Insert subjects needs to be sorted.
10 */
11 subjects: Subject[];
12 /**
13 * Unique list of entity metadatas of this subject.
14 */
15 metadatas: EntityMetadata[];
16 constructor(subjects: Subject[]);
17 /**
18 * Sorts (orders) subjects in their topological order.
19 */
20 sort(direction: "insert" | "delete"): Subject[];
21 /**
22 * Removes already sorted subjects from this.subjects list of subjects.
23 */
24 protected removeAlreadySorted(subjects: Subject[]): void;
25 /**
26 * Extracts all unique metadatas from the given subjects.
27 */
28 protected getUniqueMetadatas(subjects: Subject[]): EntityMetadata[];
29 /**
30 * Gets dependency tree for all entity metadatas with non-nullable relations.
31 * We need to execute insertions first for entities which non-nullable relations.
32 */
33 protected getNonNullableDependencies(): string[][];
34 /**
35 * Gets dependency tree for all entity metadatas with non-nullable relations.
36 * We need to execute insertions first for entities which non-nullable relations.
37 */
38 protected getDependencies(): string[][];
39 /**
40 * Sorts given graph using topological sorting algorithm.
41 *
42 * Algorithm is kindly taken from https://github.com/marcelklehr/toposort repository.
43 */
44 protected toposort(edges: any[][]): any[];
45}