@likec4/core 0.40.0 → 0.42.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.
Files changed (124) hide show
  1. package/README.md +2 -6
  2. package/dist/cjs/colors/element.d.ts +68 -0
  3. package/dist/{esm/colors.js → cjs/colors/element.js} +9 -23
  4. package/dist/cjs/colors/index.d.ts +132 -0
  5. package/dist/cjs/colors/index.js +27 -0
  6. package/dist/cjs/colors/relationships.d.ts +57 -0
  7. package/dist/cjs/colors/relationships.js +76 -0
  8. package/dist/cjs/index.d.ts +0 -2
  9. package/dist/cjs/index.js +0 -22
  10. package/dist/cjs/types/computed-view.d.ts +10 -7
  11. package/dist/cjs/types/diagram.d.ts +14 -5
  12. package/dist/cjs/types/expression.d.ts +1 -1
  13. package/dist/cjs/types/relation.d.ts +12 -0
  14. package/dist/cjs/types/relation.js +12 -1
  15. package/dist/cjs/types/theme.d.ts +12 -14
  16. package/dist/cjs/types/view.d.ts +7 -4
  17. package/dist/cjs/types/view.js +1 -1
  18. package/dist/cjs/utils/fqn.d.ts +6 -1
  19. package/dist/cjs/utils/fqn.js +17 -4
  20. package/dist/cjs/utils/guards.d.ts +1 -0
  21. package/dist/cjs/utils/guards.js +7 -0
  22. package/dist/cjs/utils/index.d.ts +0 -1
  23. package/dist/cjs/utils/index.js +0 -11
  24. package/dist/esm/colors/element.d.ts +68 -0
  25. package/dist/{cjs/colors.js → esm/colors/element.js} +1 -33
  26. package/dist/esm/colors/index.d.ts +132 -0
  27. package/dist/esm/colors/index.js +9 -0
  28. package/dist/esm/colors/relationships.d.ts +57 -0
  29. package/dist/esm/colors/relationships.js +64 -0
  30. package/dist/esm/index.d.ts +0 -2
  31. package/dist/esm/index.js +1 -3
  32. package/dist/esm/types/computed-view.d.ts +10 -7
  33. package/dist/esm/types/diagram.d.ts +14 -5
  34. package/dist/esm/types/expression.d.ts +1 -1
  35. package/dist/esm/types/relation.d.ts +12 -0
  36. package/dist/esm/types/relation.js +3 -0
  37. package/dist/esm/types/theme.d.ts +12 -14
  38. package/dist/esm/types/view.d.ts +7 -4
  39. package/dist/esm/types/view.js +1 -1
  40. package/dist/esm/utils/fqn.d.ts +6 -1
  41. package/dist/esm/utils/fqn.js +16 -4
  42. package/dist/esm/utils/guards.d.ts +1 -0
  43. package/dist/esm/utils/guards.js +1 -0
  44. package/dist/esm/utils/index.d.ts +0 -1
  45. package/dist/esm/utils/index.js +0 -1
  46. package/dist/types/colors/element.d.ts +69 -0
  47. package/dist/types/colors/index.d.ts +133 -0
  48. package/dist/types/colors/relationships.d.ts +58 -0
  49. package/dist/types/errors/index.d.ts +46 -0
  50. package/dist/types/index.d.ts +7 -0
  51. package/dist/types/types/_common.d.ts +4 -0
  52. package/dist/types/types/computed-view.d.ts +45 -0
  53. package/dist/types/types/diagram.d.ts +42 -0
  54. package/dist/types/types/element.d.ts +30 -0
  55. package/dist/types/types/expression.d.ts +57 -0
  56. package/dist/types/types/index.d.ts +12 -0
  57. package/dist/types/types/model.d.ts +15 -0
  58. package/dist/types/types/opaque.d.ts +103 -0
  59. package/dist/types/types/relation.d.ts +23 -0
  60. package/dist/types/types/theme.d.ts +27 -0
  61. package/dist/types/types/view.d.ts +62 -0
  62. package/dist/types/utils/fqn.d.ts +34 -0
  63. package/dist/types/utils/guards.d.ts +5 -0
  64. package/dist/types/utils/index.d.ts +4 -0
  65. package/dist/types/utils/relations.d.ts +26 -0
  66. package/package.json +51 -54
  67. package/dist/cjs/colors.d.ts +0 -148
  68. package/dist/cjs/compute-view/EdgeBuilder.d.ts +0 -6
  69. package/dist/cjs/compute-view/EdgeBuilder.js +0 -37
  70. package/dist/cjs/compute-view/compute-ctx.d.ts +0 -20
  71. package/dist/cjs/compute-view/compute-ctx.js +0 -91
  72. package/dist/cjs/compute-view/compute-element-view.d.ts +0 -3
  73. package/dist/cjs/compute-view/compute-element-view.js +0 -100
  74. package/dist/cjs/compute-view/compute-predicates.d.ts +0 -16
  75. package/dist/cjs/compute-view/compute-predicates.js +0 -363
  76. package/dist/cjs/compute-view/compute.d.ts +0 -14
  77. package/dist/cjs/compute-view/compute.js +0 -46
  78. package/dist/cjs/compute-view/index.d.ts +0 -4
  79. package/dist/cjs/compute-view/index.js +0 -49
  80. package/dist/cjs/compute-view/resolve-extended-views.d.ts +0 -6
  81. package/dist/cjs/compute-view/resolve-extended-views.js +0 -53
  82. package/dist/cjs/compute-view/resolve-relative-paths.d.ts +0 -2
  83. package/dist/cjs/compute-view/resolve-relative-paths.js +0 -84
  84. package/dist/cjs/compute-view/utils/anyPossibleRelations.d.ts +0 -2
  85. package/dist/cjs/compute-view/utils/anyPossibleRelations.js +0 -18
  86. package/dist/cjs/compute-view/utils/applyViewRuleStyles.d.ts +0 -2
  87. package/dist/cjs/compute-view/utils/applyViewRuleStyles.js +0 -57
  88. package/dist/cjs/compute-view/utils/sortNodes.d.ts +0 -19
  89. package/dist/cjs/compute-view/utils/sortNodes.js +0 -47
  90. package/dist/cjs/model-index/ModelIndex.d.ts +0 -27
  91. package/dist/cjs/model-index/ModelIndex.js +0 -139
  92. package/dist/cjs/model-index/index.d.ts +0 -1
  93. package/dist/cjs/model-index/index.js +0 -13
  94. package/dist/cjs/utils/compute-node-levels.d.ts +0 -7
  95. package/dist/cjs/utils/compute-node-levels.js +0 -48
  96. package/dist/esm/colors.d.ts +0 -148
  97. package/dist/esm/compute-view/EdgeBuilder.d.ts +0 -6
  98. package/dist/esm/compute-view/EdgeBuilder.js +0 -30
  99. package/dist/esm/compute-view/compute-ctx.d.ts +0 -20
  100. package/dist/esm/compute-view/compute-ctx.js +0 -100
  101. package/dist/esm/compute-view/compute-element-view.d.ts +0 -3
  102. package/dist/esm/compute-view/compute-element-view.js +0 -98
  103. package/dist/esm/compute-view/compute-predicates.d.ts +0 -16
  104. package/dist/esm/compute-view/compute-predicates.js +0 -324
  105. package/dist/esm/compute-view/compute.d.ts +0 -14
  106. package/dist/esm/compute-view/compute.js +0 -36
  107. package/dist/esm/compute-view/index.d.ts +0 -4
  108. package/dist/esm/compute-view/index.js +0 -4
  109. package/dist/esm/compute-view/resolve-extended-views.d.ts +0 -6
  110. package/dist/esm/compute-view/resolve-extended-views.js +0 -41
  111. package/dist/esm/compute-view/resolve-relative-paths.d.ts +0 -2
  112. package/dist/esm/compute-view/resolve-relative-paths.js +0 -76
  113. package/dist/esm/compute-view/utils/anyPossibleRelations.d.ts +0 -2
  114. package/dist/esm/compute-view/utils/anyPossibleRelations.js +0 -12
  115. package/dist/esm/compute-view/utils/applyViewRuleStyles.d.ts +0 -2
  116. package/dist/esm/compute-view/utils/applyViewRuleStyles.js +0 -50
  117. package/dist/esm/compute-view/utils/sortNodes.d.ts +0 -19
  118. package/dist/esm/compute-view/utils/sortNodes.js +0 -37
  119. package/dist/esm/model-index/ModelIndex.d.ts +0 -27
  120. package/dist/esm/model-index/ModelIndex.js +0 -127
  121. package/dist/esm/model-index/index.d.ts +0 -1
  122. package/dist/esm/model-index/index.js +0 -1
  123. package/dist/esm/utils/compute-node-levels.d.ts +0 -7
  124. package/dist/esm/utils/compute-node-levels.js +0 -31
@@ -1,6 +0,0 @@
1
- import { type ElementView } from '../types';
2
- /**
3
- * Resolve rules of extended views
4
- * (Removes invalid views)
5
- */
6
- export declare function resolveRulesExtendedViews<V extends Record<any, ElementView>>(unresolvedViews: V): V;
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resolveRulesExtendedViews = resolveRulesExtendedViews;
7
- var _graphlib = _interopRequireDefault(require("@dagrejs/graphlib"));
8
- var _types = require("../types");
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- const {
11
- Graph,
12
- alg
13
- } = _graphlib.default;
14
- function resolveRulesExtendedViews(unresolvedViews) {
15
- const g = new Graph({
16
- directed: true,
17
- multigraph: false,
18
- compound: false
19
- });
20
- for (const view of Object.values(unresolvedViews)) {
21
- g.setNode(view.id);
22
- if ((0, _types.isExtendsElementView)(view)) {
23
- g.setEdge(view.id, view.extends);
24
- }
25
- }
26
- const cycles = alg.findCycles(g);
27
- if (cycles.length > 0) {
28
- cycles.flat().forEach(id => g.removeNode(id));
29
- }
30
- const ordered = alg.postorder(g, g.sources());
31
- return ordered.reduce((acc, id) => {
32
- const view = unresolvedViews[id];
33
- if (!view) {
34
- return acc;
35
- }
36
- if ((0, _types.isExtendsElementView)(view)) {
37
- const extendsFrom = acc[view.extends];
38
- if (!extendsFrom) {
39
- return acc;
40
- }
41
- return Object.assign(acc, {
42
- [view.id]: {
43
- ...extendsFrom,
44
- ...view,
45
- rules: [...extendsFrom.rules, ...view.rules]
46
- }
47
- });
48
- }
49
- return Object.assign(acc, {
50
- [view.id]: view
51
- });
52
- }, {});
53
- }
@@ -1,2 +0,0 @@
1
- import type { ElementView } from '../types';
2
- export declare function resolveRelativePaths(views: ElementView[]): ElementView[];
@@ -1,84 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resolveRelativePaths = resolveRelativePaths;
7
- var _rambdax = require("rambdax");
8
- var _remeda = require("remeda");
9
- var _errors = require("../errors");
10
- function commonAncestorPath(views, sep = "/") {
11
- if (views.length <= 1) return "";
12
- const uniqURIs = (0, _rambdax.uniq)(views.flatMap(({
13
- docUri
14
- }) => docUri ? [docUri] : []));
15
- if (uniqURIs.length === 0) return "";
16
- if (uniqURIs.length === 1) {
17
- (0, _errors.invariant)((0, _remeda.hasAtLeast)(uniqURIs, 1));
18
- return new URL(uniqURIs[0]).pathname;
19
- }
20
- (0, _errors.invariant)((0, _remeda.hasAtLeast)(uniqURIs, 2), "Expected at least 2 unique URIs");
21
- const [baseUri, ...tail] = uniqURIs;
22
- const parts = new URL(baseUri).pathname.split(sep);
23
- let endOfPrefix = parts.length;
24
- for (const uri of tail) {
25
- if (uri === baseUri) {
26
- continue;
27
- }
28
- const compare = new URL(uri).pathname.split(sep);
29
- for (let i = 0; i < endOfPrefix; i++) {
30
- if (compare[i] !== parts[i]) {
31
- endOfPrefix = i;
32
- }
33
- }
34
- if (endOfPrefix === 0) return "";
35
- }
36
- const prefix = parts.slice(0, endOfPrefix).join(sep);
37
- return prefix.endsWith(sep) ? prefix : prefix + sep;
38
- }
39
- function resolveRelativePaths(views) {
40
- const commonPrefix = commonAncestorPath(views);
41
- return views.map(view => {
42
- if (!view.docUri) {
43
- return {
44
- ...view,
45
- parts: []
46
- };
47
- }
48
- const path = new URL(view.docUri).pathname;
49
- const parts = path.replace(commonPrefix, "").split("/");
50
- parts.pop();
51
- return {
52
- ...view,
53
- parts
54
- };
55
- }).sort((a, b) => {
56
- if (a.parts.length === b.parts.length) {
57
- if (a.parts.length === 0) {
58
- return 0;
59
- }
60
- if (a.parts.length === 1 && (0, _remeda.hasAtLeast)(a.parts, 1) && (0, _remeda.hasAtLeast)(b.parts, 1)) {
61
- return a.parts[0].localeCompare(b.parts[0]);
62
- }
63
- for (const [_a, _b] of (0, _rambdax.zip)(a.parts, b.parts)) {
64
- const compare = _a.localeCompare(_b);
65
- if (compare !== 0) {
66
- return compare;
67
- }
68
- }
69
- return 0;
70
- }
71
- return a.parts.length - b.parts.length;
72
- }).map(({
73
- parts,
74
- ...view
75
- }) => {
76
- if (view.docUri) {
77
- return {
78
- ...view,
79
- relativePath: parts.join("/")
80
- };
81
- }
82
- return view;
83
- });
84
- }
@@ -1,2 +0,0 @@
1
- import type { Element } from '../../types';
2
- export declare function anyPossibleRelations(elements: Element[]): Generator<[source: Element, target: Element]>;
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.anyPossibleRelations = anyPossibleRelations;
7
- var _rambdax = require("rambdax");
8
- var _utils = require("../../utils");
9
- function* anyPossibleRelations(elements) {
10
- const uniqElements = (0, _rambdax.uniqBy)((0, _rambdax.prop)("id"), elements).sort(_utils.compareByFqnHierarchically).reverse();
11
- for (const source of uniqElements) {
12
- for (const target of uniqElements) {
13
- if (source !== target && !(0, _utils.isAncestor)(source, target) && !(0, _utils.isAncestor)(target, source)) {
14
- yield [source, target];
15
- }
16
- }
17
- }
18
- }
@@ -1,2 +0,0 @@
1
- import type { ComputedNode, ViewRuleStyle } from '../../types';
2
- export declare function applyViewRuleStyles(rules: ViewRuleStyle[], _nodes: ComputedNode[]): ComputedNode[];
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.applyViewRuleStyles = applyViewRuleStyles;
7
- var _rambdax = require("rambdax");
8
- var _remeda = require("remeda");
9
- var _errors = require("../../errors");
10
- var _types = require("../../types");
11
- function applyViewRuleStyles(rules, _nodes) {
12
- if (rules.length === 0) {
13
- return _nodes;
14
- }
15
- const nodes = (0, _rambdax.clone)(_nodes);
16
- for (const rule of rules) {
17
- const predicates = [];
18
- if (!rule.style.color && !rule.style.shape) {
19
- continue;
20
- }
21
- for (const target of rule.targets) {
22
- if (_types.Expr.isWildcard(target)) {
23
- predicates.push(() => true);
24
- break;
25
- }
26
- if (_types.Expr.isElementKindExpr(target)) {
27
- predicates.push(target.isEqual ? n => n.kind === target.elementKind : n => n.kind !== target.elementKind);
28
- continue;
29
- }
30
- if (_types.Expr.isElementTagExpr(target)) {
31
- predicates.push(target.isEqual ? ({
32
- tags
33
- }) => !!tags && tags.includes(target.elementTag) : ({
34
- tags
35
- }) => (0, _rambdax.isNil)(tags) || !tags.includes(target.elementTag));
36
- continue;
37
- }
38
- if (_types.Expr.isElementRef(target)) {
39
- const {
40
- element,
41
- isDescedants
42
- } = target;
43
- predicates.push(isDescedants ? n => n.id.startsWith(element + ".") : n => n.id === element);
44
- continue;
45
- }
46
- (0, _errors.nonexhaustive)(target);
47
- }
48
- (0, _rambdax.filter)((0, _rambdax.anyPass)(predicates), nodes).forEach(n => {
49
- n.shape = rule.style.shape ?? n.shape;
50
- n.color = rule.style.color ?? n.color;
51
- if (_remeda.isDefined.strict(rule.style.icon)) {
52
- n.icon = rule.style.icon;
53
- }
54
- });
55
- }
56
- return nodes;
57
- }
@@ -1,19 +0,0 @@
1
- import type { ComputedEdge, ComputedNode } from '../../types';
2
- export declare function sortNodes(_nodes: ComputedNode[], edges: ComputedEdge[]): {
3
- children: import("../../types").Fqn[];
4
- id: import("../../types").Fqn;
5
- kind: import("../../types").ElementKind;
6
- parent: import("../../types").Fqn | null;
7
- title: string;
8
- description: string | null;
9
- technology: string | null;
10
- tags: import("../../types").NonEmptyArray<import("../../types").Tag> | null;
11
- links: import("../../types").NonEmptyArray<string> | null;
12
- inEdges: import("../../types").EdgeId[];
13
- outEdges: import("../../types").EdgeId[];
14
- shape: import("../../types").ElementShape;
15
- color: import("../../types").ThemeColor;
16
- icon?: import("../../types").IconUrl | undefined;
17
- navigateTo?: import("../../types").ViewID | undefined;
18
- level: number;
19
- }[];
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.sortNodes = sortNodes;
7
- var _graphlib = _interopRequireDefault(require("@dagrejs/graphlib"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- const {
10
- Graph,
11
- alg
12
- } = _graphlib.default;
13
- function fillChildren(nodes) {
14
- return nodes.map(node => ({
15
- ...node,
16
- children: nodes.flatMap(n => n.parent === node.id ? n.id : [])
17
- }));
18
- }
19
- function sortNodes(_nodes, edges) {
20
- if (edges.length === 0) {
21
- return fillChildren(_nodes);
22
- }
23
- const g = new Graph({
24
- compound: true,
25
- directed: true,
26
- multigraph: false
27
- });
28
- for (const e of edges) {
29
- g.setEdge(e.source, e.target);
30
- }
31
- for (const n of _nodes) {
32
- g.setNode(n.id);
33
- if (n.parent) {
34
- g.setEdge(n.id, n.parent);
35
- }
36
- }
37
- const unprocessed = [..._nodes];
38
- const sorted = [];
39
- const ordered = alg.postorder(g, g.sources()).reverse();
40
- for (const id of ordered) {
41
- const inx = unprocessed.findIndex(n => n.id === id);
42
- if (inx >= 0) {
43
- sorted.push(...unprocessed.splice(inx, 1));
44
- }
45
- }
46
- return fillChildren(sorted.concat(unprocessed));
47
- }
@@ -1,27 +0,0 @@
1
- import type { Element, Fqn, Relation, RelationID } from '../types';
2
- type ModelInput = {
3
- elements: Record<Fqn, Element>;
4
- relations: Record<RelationID, Relation>;
5
- };
6
- export default class ModelIndex {
7
- private root;
8
- private _elements;
9
- private _relations;
10
- get relations(): Relation[];
11
- filterRelations(predicate: (r: Relation) => boolean): Relation[];
12
- static from({ elements, relations }: ModelInput): ModelIndex;
13
- addElement(el: Element): void;
14
- private locateTrie;
15
- find: (id: Fqn) => Element;
16
- children: (id: Fqn) => Element[];
17
- siblings: (id: Fqn) => Element[];
18
- /**
19
- * Ancestors from closest parent to root
20
- */
21
- ancestors(id: Fqn): Element[];
22
- rootElements(): Element[];
23
- get elements(): Element[];
24
- hasElement(fqn: Fqn): boolean;
25
- addRelation(rel: Relation): void;
26
- }
27
- export {};
@@ -1,139 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- module.exports = void 0;
7
- var _remeda = require("remeda");
8
- var _errors = require("../errors");
9
- var _utils = require("../utils");
10
- function childrenOf(trie) {
11
- const children = [];
12
- for (const {
13
- el
14
- } of (0, _remeda.values)(trie.children)) {
15
- if (el) {
16
- children.push(el);
17
- }
18
- }
19
- return children;
20
- }
21
- function asPath(id) {
22
- return id.split(".");
23
- }
24
- class ModelIndex {
25
- root = {
26
- children: {}
27
- };
28
- _elements = /* @__PURE__ */new Map();
29
- _relations = /* @__PURE__ */new Map();
30
- // private _taggedElements = new Map<Tag, Set<Element>>()
31
- // private _taggedRelations = new Map<Tag, Set<Relation>>()
32
- get relations() {
33
- return Array.from(this._relations.values());
34
- }
35
- filterRelations(predicate) {
36
- return this.relations.filter(predicate);
37
- }
38
- static from({
39
- elements,
40
- relations
41
- }) {
42
- const index = new ModelIndex();
43
- for (const el of (0, _remeda.values)(elements)) {
44
- index.addElement(el);
45
- }
46
- for (const rel of (0, _remeda.values)(relations)) {
47
- index.addRelation(rel);
48
- }
49
- return index;
50
- }
51
- addElement(el) {
52
- if (this.hasElement(el.id)) {
53
- throw new _errors.InvalidModelError(`Element already exists with id ${el.id}`);
54
- }
55
- const path = asPath(el.id);
56
- let scope = this.root;
57
- for (const name of path) {
58
- const next = scope.children[name] ?? {
59
- children: {}
60
- };
61
- scope.children[name] = next;
62
- scope = next;
63
- }
64
- scope.el = el;
65
- this._elements.set(el.id, el);
66
- }
67
- locateTrie = id => {
68
- let scope = this.root;
69
- for (const name of asPath(id)) {
70
- const next = scope.children[name];
71
- (0, _errors.ensureModel)(next, `Invalid index, Element not found at path ${name} of ${id}`);
72
- scope = next;
73
- }
74
- return scope;
75
- };
76
- find = id => {
77
- const el = this._elements.get(id);
78
- (0, _errors.ensureModel)(el, `Element not found with id ${id}`);
79
- return el;
80
- };
81
- children = id => {
82
- return childrenOf(this.locateTrie(id));
83
- };
84
- siblings = id => {
85
- const parent = (0, _utils.parentFqn)(id);
86
- const trie = parent ? this.locateTrie(parent) : this.root;
87
- return childrenOf(trie).filter(e => e.id !== id);
88
- };
89
- /**
90
- * Ancestors from closest parent to root
91
- */
92
- ancestors(id) {
93
- const path = asPath(id);
94
- const ancestors = [];
95
- if (path.length === 1) {
96
- return ancestors;
97
- }
98
- path.pop();
99
- let name = path.shift();
100
- let trie = this.root;
101
- while (name) {
102
- const next = trie.children[name];
103
- (0, _errors.ensureModel)(next, `Invalid index, Element not found at path ${name} of ${id}`);
104
- trie = next;
105
- (0, _errors.ensureModel)(trie.el, `invalid index, no element ${name} found in ${id}`);
106
- ancestors.unshift(trie.el);
107
- name = path.shift();
108
- }
109
- return ancestors;
110
- }
111
- // tagged = (tag?: Tag): TaggedResult => {
112
- // return tag ? {
113
- // elements: [...this._taggedElements.get(tag)?.values() ?? []],
114
- // relations: [...this._taggedRelations.get(tag)?.values() ?? []],
115
- // } : {
116
- // elements: uniq([...this._taggedElements.values()].flatMap(s => [...s.values()])),
117
- // relations: uniq([...this._taggedRelations.values()].flatMap(s => [...s.values()]))
118
- // }
119
- // }
120
- rootElements() {
121
- return childrenOf(this.root);
122
- }
123
- get elements() {
124
- return Array.from(this._elements.values());
125
- }
126
- hasElement(fqn) {
127
- return this._elements.has(fqn);
128
- }
129
- addRelation(rel) {
130
- if (!this.hasElement(rel.source)) {
131
- throw new _errors.InvalidModelError(`Source of relation not found ${rel.source}`);
132
- }
133
- if (!this.hasElement(rel.target)) {
134
- throw new _errors.InvalidModelError(`Target of relation not found ${rel.target}`);
135
- }
136
- this._relations.set(rel.id, rel);
137
- }
138
- }
139
- module.exports = ModelIndex;
@@ -1 +0,0 @@
1
- export { default as ModelIndex } from './ModelIndex';
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "ModelIndex", {
7
- enumerable: true,
8
- get: function () {
9
- return _ModelIndex.default;
10
- }
11
- });
12
- var _ModelIndex = _interopRequireDefault(require("./ModelIndex"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,7 +0,0 @@
1
- import type { ComputedView } from '../types';
2
- type NodeLevelDepth = {
3
- level: number;
4
- depth: number;
5
- };
6
- export declare const computeNodeLevels: ({ nodes }: ComputedView) => Record<import("../types").Fqn, NodeLevelDepth>;
7
- export {};
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.computeNodeLevels = void 0;
7
- var _errors = require("../errors");
8
- const computeNodeLevels = ({
9
- nodes
10
- }) => {
11
- const nodeLevels = {};
12
- const compute = (node, level) => {
13
- let levels = nodeLevels[node.id];
14
- if (levels) {
15
- return levels;
16
- }
17
- if (node.children.length === 0) {
18
- levels = {
19
- level,
20
- depth: 0
21
- };
22
- nodeLevels[node.id] = levels;
23
- return levels;
24
- }
25
- let depth = 1;
26
- for (const childId of node.children) {
27
- const child = nodes.find(n => n.id === childId);
28
- (0, _errors.invariant)(child, `Child ${childId} not found`);
29
- const {
30
- depth: childDepth
31
- } = compute(child, level + 1);
32
- depth = Math.max(childDepth + 1, depth);
33
- }
34
- levels = {
35
- level,
36
- depth
37
- };
38
- nodeLevels[node.id] = levels;
39
- return levels;
40
- };
41
- for (const node of nodes) {
42
- if (!node.parent) {
43
- compute(node, 0);
44
- }
45
- }
46
- return nodeLevels;
47
- };
48
- exports.computeNodeLevels = computeNodeLevels;
@@ -1,148 +0,0 @@
1
- export declare const RelationColors: {
2
- readonly lineColor: "#b1b1b1";
3
- readonly labelColor: "#b1b1b1";
4
- };
5
- export declare const Colors: {
6
- readonly primary: {
7
- fill: "#3b82f6";
8
- stroke: "#2563eb";
9
- hiContrast: "#eff6ff";
10
- loContrast: "#bfdbfe";
11
- };
12
- readonly blue: {
13
- fill: "#3b82f6";
14
- stroke: "#2563eb";
15
- hiContrast: "#eff6ff";
16
- loContrast: "#bfdbfe";
17
- };
18
- readonly secondary: {
19
- fill: "#0284c7";
20
- stroke: "#0369a1";
21
- hiContrast: "#f0f9ff";
22
- loContrast: "#e0f2fe";
23
- };
24
- readonly sky: {
25
- fill: "#0284c7";
26
- stroke: "#0369a1";
27
- hiContrast: "#f0f9ff";
28
- loContrast: "#e0f2fe";
29
- };
30
- readonly muted: {
31
- fill: "#64748b";
32
- stroke: "#475569";
33
- hiContrast: "#f8fafc";
34
- loContrast: "#e2e8f0";
35
- };
36
- readonly slate: {
37
- fill: "#64748b";
38
- stroke: "#475569";
39
- hiContrast: "#f8fafc";
40
- loContrast: "#e2e8f0";
41
- };
42
- readonly gray: {
43
- readonly fill: "#737373";
44
- readonly stroke: "#525252";
45
- readonly hiContrast: "#fafafa";
46
- readonly loContrast: "#e5e5e5";
47
- };
48
- readonly red: {
49
- readonly fill: "#b54548";
50
- readonly stroke: "#8c333a";
51
- readonly hiContrast: "#f8fafc";
52
- readonly loContrast: "#F9C6C6";
53
- };
54
- readonly green: {
55
- readonly fill: "#428a4f";
56
- readonly stroke: "#2d5d39";
57
- readonly hiContrast: "#f8fafc";
58
- readonly loContrast: "#c2f0c2";
59
- };
60
- readonly amber: {
61
- readonly fill: "#d97706";
62
- readonly stroke: "#b45309";
63
- readonly hiContrast: "#f8fafc";
64
- readonly loContrast: "#ffe0c2";
65
- };
66
- readonly indigo: {
67
- readonly fill: "#6366f1";
68
- readonly stroke: "#4f46e5";
69
- readonly hiContrast: "#eef2ff";
70
- readonly loContrast: "#c7d2fe";
71
- };
72
- };
73
- export declare const defaultTheme: {
74
- readonly font: "Helvetica";
75
- readonly shadow: "#0a0a0a";
76
- readonly relation: {
77
- readonly lineColor: "#b1b1b1";
78
- readonly labelColor: "#b1b1b1";
79
- };
80
- readonly colors: {
81
- readonly primary: {
82
- fill: "#3b82f6";
83
- stroke: "#2563eb";
84
- hiContrast: "#eff6ff";
85
- loContrast: "#bfdbfe";
86
- };
87
- readonly blue: {
88
- fill: "#3b82f6";
89
- stroke: "#2563eb";
90
- hiContrast: "#eff6ff";
91
- loContrast: "#bfdbfe";
92
- };
93
- readonly secondary: {
94
- fill: "#0284c7";
95
- stroke: "#0369a1";
96
- hiContrast: "#f0f9ff";
97
- loContrast: "#e0f2fe";
98
- };
99
- readonly sky: {
100
- fill: "#0284c7";
101
- stroke: "#0369a1";
102
- hiContrast: "#f0f9ff";
103
- loContrast: "#e0f2fe";
104
- };
105
- readonly muted: {
106
- fill: "#64748b";
107
- stroke: "#475569";
108
- hiContrast: "#f8fafc";
109
- loContrast: "#e2e8f0";
110
- };
111
- readonly slate: {
112
- fill: "#64748b";
113
- stroke: "#475569";
114
- hiContrast: "#f8fafc";
115
- loContrast: "#e2e8f0";
116
- };
117
- readonly gray: {
118
- readonly fill: "#737373";
119
- readonly stroke: "#525252";
120
- readonly hiContrast: "#fafafa";
121
- readonly loContrast: "#e5e5e5";
122
- };
123
- readonly red: {
124
- readonly fill: "#b54548";
125
- readonly stroke: "#8c333a";
126
- readonly hiContrast: "#f8fafc";
127
- readonly loContrast: "#F9C6C6";
128
- };
129
- readonly green: {
130
- readonly fill: "#428a4f";
131
- readonly stroke: "#2d5d39";
132
- readonly hiContrast: "#f8fafc";
133
- readonly loContrast: "#c2f0c2";
134
- };
135
- readonly amber: {
136
- readonly fill: "#d97706";
137
- readonly stroke: "#b45309";
138
- readonly hiContrast: "#f8fafc";
139
- readonly loContrast: "#ffe0c2";
140
- };
141
- readonly indigo: {
142
- readonly fill: "#6366f1";
143
- readonly stroke: "#4f46e5";
144
- readonly hiContrast: "#eef2ff";
145
- readonly loContrast: "#c7d2fe";
146
- };
147
- };
148
- };