@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
@@ -4,10 +4,13 @@ import type { ElementExpression, Expression } from './expression';
4
4
  import type { IconUrl, NonEmptyArray } from './_common';
5
5
  import type { ThemeColor } from './theme';
6
6
  export type ViewID = Opaque<string, 'ViewID'>;
7
- export interface ViewRuleExpression {
8
- isInclude: boolean;
9
- exprs: Expression[];
10
- }
7
+ export type ViewRuleExpression = {
8
+ include: Expression[];
9
+ exclude?: never;
10
+ } | {
11
+ include?: never;
12
+ exclude: Expression[];
13
+ };
11
14
  export declare function isViewRuleExpression(rule: ViewRule): rule is ViewRuleExpression;
12
15
  export interface ViewRuleStyle {
13
16
  targets: ElementExpression[];
@@ -1,5 +1,5 @@
1
1
  export function isViewRuleExpression(rule) {
2
- return "exprs" in rule && "isInclude" in rule;
2
+ return "include" in rule && Array.isArray(rule.include) || "exclude" in rule && Array.isArray(rule.exclude);
3
3
  }
4
4
  export function isViewRuleStyle(rule) {
5
5
  return "style" in rule && "targets" in rule;
@@ -5,13 +5,18 @@ export declare function isAncestor<E extends {
5
5
  }>(...args: [ancestor: Fqn, another: Fqn] | [ancestor: E, another: E]): boolean;
6
6
  export declare function isSameHierarchy<E extends {
7
7
  id: Fqn;
8
- }>(...args: [one: Fqn, another: Fqn] | [one: E, another: E]): boolean;
8
+ }>(one: E | Fqn, another: E | Fqn): boolean;
9
9
  export declare function isDescendantOf<E extends {
10
10
  id: Fqn;
11
11
  }>(ancestors: E[]): (e: E) => boolean;
12
12
  export declare function notDescendantOf(ancestors: Element[]): (e: Element) => boolean;
13
13
  export declare function commonAncestor(first: Fqn, second: Fqn): Fqn | null;
14
14
  export declare function parentFqn(fqn: Fqn): Fqn | null;
15
+ /**
16
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
17
+ * (from closest to root)
18
+ */
19
+ export declare function ancestorsFqn(fqn: Fqn): Fqn[];
15
20
  /**
16
21
  * Compares two fully qualified names (fqns) hierarchically based on their depth.
17
22
  * From parent nodes to leaves
@@ -13,10 +13,10 @@ export function isAncestor(...args) {
13
13
  const another = isString(args[1]) ? args[1] : args[1].id;
14
14
  return another.startsWith(ancestor + ".");
15
15
  }
16
- export function isSameHierarchy(...args) {
17
- const one = isString(args[0]) ? args[0] : args[0].id;
18
- const another = isString(args[1]) ? args[1] : args[1].id;
19
- return one === another || another.startsWith(one + ".") || one.startsWith(another + ".");
16
+ export function isSameHierarchy(one, another) {
17
+ const first = isString(one) ? one : one.id;
18
+ const second = isString(another) ? another : another.id;
19
+ return first === second || second.startsWith(first + ".") || first.startsWith(second + ".");
20
20
  }
21
21
  export function isDescendantOf(ancestors) {
22
22
  const predicates = ancestors.flatMap((a) => [(e) => e.id === a.id, (e) => isAncestor(a, e)]);
@@ -52,6 +52,18 @@ export function parentFqn(fqn) {
52
52
  }
53
53
  return null;
54
54
  }
55
+ export function ancestorsFqn(fqn) {
56
+ const path = fqn.split(".");
57
+ path.pop();
58
+ if (path.length === 0) {
59
+ return [];
60
+ }
61
+ return path.reduce((acc, _, idx) => {
62
+ const ancestor = path.slice(0, idx + 1).join(".");
63
+ acc.unshift(ancestor);
64
+ return acc;
65
+ }, []);
66
+ }
55
67
  export function compareFqnHierarchically(a, b) {
56
68
  const depthA = a.split(".").length;
57
69
  const depthB = b.split(".").length;
@@ -1,3 +1,4 @@
1
1
  import type { NonEmptyArray } from '../types';
2
+ export { hasAtLeast } from 'remeda';
2
3
  export declare function isString(value: unknown): value is string;
3
4
  export declare function isNonEmptyArray<A>(arr: ArrayLike<A>): arr is NonEmptyArray<A>;
@@ -1,3 +1,4 @@
1
+ export { hasAtLeast } from "remeda";
1
2
  export function isString(value) {
2
3
  return value != null && typeof value === "string";
3
4
  }
@@ -1,4 +1,3 @@
1
1
  export * from './fqn';
2
2
  export * from './guards';
3
- export * from './compute-node-levels';
4
3
  export * from './relations';
@@ -1,4 +1,3 @@
1
1
  export * from "./fqn.js";
2
2
  export * from "./guards.js";
3
- export * from "./compute-node-levels.js";
4
3
  export * from "./relations.js";
@@ -0,0 +1,69 @@
1
+ export declare const ElementColors: {
2
+ readonly primary: {
3
+ fill: "#3b82f6";
4
+ stroke: "#2563eb";
5
+ hiContrast: "#eff6ff";
6
+ loContrast: "#bfdbfe";
7
+ };
8
+ readonly blue: {
9
+ fill: "#3b82f6";
10
+ stroke: "#2563eb";
11
+ hiContrast: "#eff6ff";
12
+ loContrast: "#bfdbfe";
13
+ };
14
+ readonly secondary: {
15
+ fill: "#0284c7";
16
+ stroke: "#0369a1";
17
+ hiContrast: "#f0f9ff";
18
+ loContrast: "#e0f2fe";
19
+ };
20
+ readonly sky: {
21
+ fill: "#0284c7";
22
+ stroke: "#0369a1";
23
+ hiContrast: "#f0f9ff";
24
+ loContrast: "#e0f2fe";
25
+ };
26
+ readonly muted: {
27
+ fill: "#64748b";
28
+ stroke: "#475569";
29
+ hiContrast: "#f8fafc";
30
+ loContrast: "#e2e8f0";
31
+ };
32
+ readonly slate: {
33
+ fill: "#64748b";
34
+ stroke: "#475569";
35
+ hiContrast: "#f8fafc";
36
+ loContrast: "#e2e8f0";
37
+ };
38
+ readonly gray: {
39
+ readonly fill: "#737373";
40
+ readonly stroke: "#525252";
41
+ readonly hiContrast: "#fafafa";
42
+ readonly loContrast: "#e5e5e5";
43
+ };
44
+ readonly red: {
45
+ readonly fill: "#b54548";
46
+ readonly stroke: "#8c333a";
47
+ readonly hiContrast: "#f8fafc";
48
+ readonly loContrast: "#F9C6C6";
49
+ };
50
+ readonly green: {
51
+ readonly fill: "#428a4f";
52
+ readonly stroke: "#2d5d39";
53
+ readonly hiContrast: "#f8fafc";
54
+ readonly loContrast: "#c2f0c2";
55
+ };
56
+ readonly amber: {
57
+ readonly fill: "#d97706";
58
+ readonly stroke: "#b45309";
59
+ readonly hiContrast: "#f8fafc";
60
+ readonly loContrast: "#ffe0c2";
61
+ };
62
+ readonly indigo: {
63
+ readonly fill: "#6366f1";
64
+ readonly stroke: "#4f46e5";
65
+ readonly hiContrast: "#eef2ff";
66
+ readonly loContrast: "#c7d2fe";
67
+ };
68
+ };
69
+ //# sourceMappingURL=element.d.ts.map
@@ -0,0 +1,133 @@
1
+ import { ElementColors } from './element';
2
+ import { RelationshipColors } from './relationships';
3
+ export declare const defaultTheme: {
4
+ elements: {
5
+ readonly primary: {
6
+ fill: "#3b82f6";
7
+ stroke: "#2563eb";
8
+ hiContrast: "#eff6ff";
9
+ loContrast: "#bfdbfe";
10
+ };
11
+ readonly blue: {
12
+ fill: "#3b82f6";
13
+ stroke: "#2563eb";
14
+ hiContrast: "#eff6ff";
15
+ loContrast: "#bfdbfe";
16
+ };
17
+ readonly secondary: {
18
+ fill: "#0284c7";
19
+ stroke: "#0369a1";
20
+ hiContrast: "#f0f9ff";
21
+ loContrast: "#e0f2fe";
22
+ };
23
+ readonly sky: {
24
+ fill: "#0284c7";
25
+ stroke: "#0369a1";
26
+ hiContrast: "#f0f9ff";
27
+ loContrast: "#e0f2fe";
28
+ };
29
+ readonly muted: {
30
+ fill: "#64748b";
31
+ stroke: "#475569";
32
+ hiContrast: "#f8fafc";
33
+ loContrast: "#e2e8f0";
34
+ };
35
+ readonly slate: {
36
+ fill: "#64748b";
37
+ stroke: "#475569";
38
+ hiContrast: "#f8fafc";
39
+ loContrast: "#e2e8f0";
40
+ };
41
+ readonly gray: {
42
+ readonly fill: "#737373";
43
+ readonly stroke: "#525252";
44
+ readonly hiContrast: "#fafafa";
45
+ readonly loContrast: "#e5e5e5";
46
+ };
47
+ readonly red: {
48
+ readonly fill: "#b54548";
49
+ readonly stroke: "#8c333a";
50
+ readonly hiContrast: "#f8fafc";
51
+ readonly loContrast: "#F9C6C6";
52
+ };
53
+ readonly green: {
54
+ readonly fill: "#428a4f";
55
+ readonly stroke: "#2d5d39";
56
+ readonly hiContrast: "#f8fafc";
57
+ readonly loContrast: "#c2f0c2";
58
+ };
59
+ readonly amber: {
60
+ readonly fill: "#d97706";
61
+ readonly stroke: "#b45309";
62
+ readonly hiContrast: "#f8fafc";
63
+ readonly loContrast: "#ffe0c2";
64
+ };
65
+ readonly indigo: {
66
+ readonly fill: "#6366f1";
67
+ readonly stroke: "#4f46e5";
68
+ readonly hiContrast: "#eef2ff";
69
+ readonly loContrast: "#c7d2fe";
70
+ };
71
+ };
72
+ relationships: {
73
+ amber: {
74
+ lineColor: "#b45309";
75
+ labelBgColor: "#78350f";
76
+ labelColor: "#f59e0b";
77
+ };
78
+ blue: {
79
+ lineColor: "#3b82f6";
80
+ labelBgColor: "#172554";
81
+ labelColor: "#60a5fa";
82
+ };
83
+ gray: {
84
+ lineColor: "#6E6E6E";
85
+ labelBgColor: "#18191b";
86
+ labelColor: "#C6C6C6";
87
+ };
88
+ green: {
89
+ lineColor: "#15803d";
90
+ labelBgColor: "#052e16";
91
+ labelColor: "#22c55e";
92
+ };
93
+ indigo: {
94
+ lineColor: "#6366f1";
95
+ labelBgColor: "#1e1b4b";
96
+ labelColor: "#818cf8";
97
+ };
98
+ muted: {
99
+ lineColor: "#64748b";
100
+ labelBgColor: "#0f172a";
101
+ labelColor: "#cbd5e1";
102
+ };
103
+ primary: {
104
+ lineColor: "#3b82f6";
105
+ labelBgColor: "#172554";
106
+ labelColor: "#60a5fa";
107
+ };
108
+ red: {
109
+ lineColor: "#b91c1c";
110
+ labelBgColor: "#b91c1c";
111
+ labelColor: "#dc2626";
112
+ };
113
+ secondary: {
114
+ lineColor: "#0ea5e9";
115
+ labelBgColor: "#082f49";
116
+ labelColor: "#38bdf8";
117
+ };
118
+ sky: {
119
+ lineColor: "#0ea5e9";
120
+ labelBgColor: "#082f49";
121
+ labelColor: "#38bdf8";
122
+ };
123
+ slate: {
124
+ lineColor: "#64748b";
125
+ labelBgColor: "#0f172a";
126
+ labelColor: "#cbd5e1";
127
+ };
128
+ };
129
+ font: "Helvetica";
130
+ shadow: "#0a0a0a";
131
+ };
132
+ export { ElementColors, RelationshipColors };
133
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,58 @@
1
+ export declare const RelationshipColors: {
2
+ amber: {
3
+ lineColor: "#b45309";
4
+ labelBgColor: "#78350f";
5
+ labelColor: "#f59e0b";
6
+ };
7
+ blue: {
8
+ lineColor: "#3b82f6";
9
+ labelBgColor: "#172554";
10
+ labelColor: "#60a5fa";
11
+ };
12
+ gray: {
13
+ lineColor: "#6E6E6E";
14
+ labelBgColor: "#18191b";
15
+ labelColor: "#C6C6C6";
16
+ };
17
+ green: {
18
+ lineColor: "#15803d";
19
+ labelBgColor: "#052e16";
20
+ labelColor: "#22c55e";
21
+ };
22
+ indigo: {
23
+ lineColor: "#6366f1";
24
+ labelBgColor: "#1e1b4b";
25
+ labelColor: "#818cf8";
26
+ };
27
+ muted: {
28
+ lineColor: "#64748b";
29
+ labelBgColor: "#0f172a";
30
+ labelColor: "#cbd5e1";
31
+ };
32
+ primary: {
33
+ lineColor: "#3b82f6";
34
+ labelBgColor: "#172554";
35
+ labelColor: "#60a5fa";
36
+ };
37
+ red: {
38
+ lineColor: "#b91c1c";
39
+ labelBgColor: "#b91c1c";
40
+ labelColor: "#dc2626";
41
+ };
42
+ secondary: {
43
+ lineColor: "#0ea5e9";
44
+ labelBgColor: "#082f49";
45
+ labelColor: "#38bdf8";
46
+ };
47
+ sky: {
48
+ lineColor: "#0ea5e9";
49
+ labelBgColor: "#082f49";
50
+ labelColor: "#38bdf8";
51
+ };
52
+ slate: {
53
+ lineColor: "#64748b";
54
+ labelBgColor: "#0f172a";
55
+ labelColor: "#cbd5e1";
56
+ };
57
+ };
58
+ //# sourceMappingURL=relationships.d.ts.map
@@ -0,0 +1,46 @@
1
+ import { CustomError } from 'ts-custom-error';
2
+ export interface BaseErrorOptions {
3
+ cause?: unknown;
4
+ }
5
+ /**
6
+ * Base class for all errors in the LikeC4 library.
7
+ */
8
+ export declare class BaseError extends CustomError {
9
+ constructor(message: string, options?: BaseErrorOptions);
10
+ }
11
+ export declare class InvalidArgError extends BaseError {
12
+ constructor(message: string, options?: BaseErrorOptions);
13
+ }
14
+ /**
15
+ * Unknown error, mosly probably a bug, unhandled case or coming from a third-party library.
16
+ */
17
+ export declare class UnknownError extends BaseError {
18
+ constructor(message: string, options?: BaseErrorOptions);
19
+ }
20
+ export declare class NullableError extends BaseError {
21
+ constructor(message: string, options?: BaseErrorOptions);
22
+ }
23
+ export declare class InvariantError extends BaseError {
24
+ constructor(message: string, options?: BaseErrorOptions);
25
+ }
26
+ export declare function nonNullable<T>(value: T, message?: string): T & {};
27
+ export declare class RelationRefError extends BaseError {
28
+ constructor(message: string, options?: BaseErrorOptions);
29
+ }
30
+ export declare function normalizeError(e: unknown): BaseError;
31
+ export declare function serializeError(e: unknown): {
32
+ name: string;
33
+ message: string;
34
+ error: BaseError;
35
+ };
36
+ export declare function throwNormalizedError(e: unknown): never;
37
+ export declare function invariant(condition: any, message?: string): asserts condition;
38
+ export declare class NonExhaustiveError extends BaseError {
39
+ constructor(message: string, options?: BaseErrorOptions);
40
+ }
41
+ export declare function nonexhaustive(value: never): never;
42
+ export declare class InvalidModelError extends BaseError {
43
+ constructor(message: string, options?: BaseErrorOptions);
44
+ }
45
+ export declare function ensureModel(condition: any, message?: string): asserts condition;
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ export * from './colors';
2
+ export * from './errors';
3
+ export * from './types';
4
+ export * from './utils';
5
+ export type * as likec4 from './types';
6
+ export type * as c4 from './types';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { Opaque } from './opaque';
2
+ export type NonEmptyArray<T> = [T, ...T[]];
3
+ export type IconUrl = Opaque<string, 'IconUrl'>;
4
+ //# sourceMappingURL=_common.d.ts.map
@@ -0,0 +1,45 @@
1
+ import type { Opaque } from './opaque';
2
+ import type { ElementKind, ElementShape, Fqn, Tag } from './element';
3
+ import type { RelationID, RelationshipArrowType, RelationshipLineType } from './relation';
4
+ import type { BasicElementView, ViewID, ViewRuleAutoLayout } from './view';
5
+ import type { IconUrl, NonEmptyArray } from './_common';
6
+ import type { ThemeColor } from './theme';
7
+ export type NodeId = Fqn;
8
+ export type EdgeId = Opaque<string, 'EdgeId'>;
9
+ export interface ComputedNode {
10
+ id: NodeId;
11
+ kind: ElementKind;
12
+ parent: NodeId | null;
13
+ title: string;
14
+ description: string | null;
15
+ technology: string | null;
16
+ tags: NonEmptyArray<Tag> | null;
17
+ links: NonEmptyArray<string> | null;
18
+ children: NodeId[];
19
+ inEdges: EdgeId[];
20
+ outEdges: EdgeId[];
21
+ shape: ElementShape;
22
+ color: ThemeColor;
23
+ icon?: IconUrl;
24
+ navigateTo?: ViewID;
25
+ level: number;
26
+ }
27
+ export interface ComputedEdge {
28
+ id: EdgeId;
29
+ parent: NodeId | null;
30
+ source: NodeId;
31
+ target: NodeId;
32
+ label: string | null;
33
+ relations: RelationID[];
34
+ color?: ThemeColor;
35
+ line?: RelationshipLineType;
36
+ head?: RelationshipArrowType;
37
+ tail?: RelationshipArrowType;
38
+ }
39
+ export interface ComputedView extends Omit<BasicElementView, 'rules'> {
40
+ readonly extends?: ViewID;
41
+ readonly autoLayout: ViewRuleAutoLayout['autoLayout'];
42
+ readonly nodes: ComputedNode[];
43
+ readonly edges: ComputedEdge[];
44
+ }
45
+ //# sourceMappingURL=computed-view.d.ts.map
@@ -0,0 +1,42 @@
1
+ import type { ColorLiteral } from './theme';
2
+ import type { ComputedEdge, ComputedNode, ComputedView } from './computed-view';
3
+ import type { NonEmptyArray } from './_common';
4
+ export type Point = [x: number, y: number];
5
+ export type BBox = {
6
+ x: number;
7
+ y: number;
8
+ width: number;
9
+ height: number;
10
+ };
11
+ export interface DiagramLabel {
12
+ align: 'left' | 'right' | 'center';
13
+ fontStyle?: 'bold' | 'normal';
14
+ color?: ColorLiteral;
15
+ fontSize: number;
16
+ pt: Point;
17
+ width: number;
18
+ text: string;
19
+ }
20
+ export interface DiagramNode extends ComputedNode {
21
+ size: {
22
+ width: number;
23
+ height: number;
24
+ };
25
+ labels: DiagramLabel[];
26
+ position: Point;
27
+ depth?: number;
28
+ }
29
+ export interface DiagramEdge extends ComputedEdge {
30
+ points: NonEmptyArray<Point>;
31
+ headArrow?: NonEmptyArray<Point>;
32
+ tailArrow?: NonEmptyArray<Point>;
33
+ labels?: NonEmptyArray<DiagramLabel>;
34
+ labelBBox?: BBox;
35
+ }
36
+ export interface DiagramView extends Omit<ComputedView, 'nodes' | 'edges'> {
37
+ readonly nodes: DiagramNode[];
38
+ readonly edges: DiagramEdge[];
39
+ readonly width: number;
40
+ readonly height: number;
41
+ }
42
+ //# sourceMappingURL=diagram.d.ts.map
@@ -0,0 +1,30 @@
1
+ import type { IconUrl, NonEmptyArray } from './_common';
2
+ import type { Opaque } from './opaque';
3
+ import type { ThemeColor } from './theme';
4
+ export type Fqn = Opaque<string, 'Fqn'>;
5
+ export declare function AsFqn(name: string, parent?: Fqn | null): Fqn;
6
+ export type ElementKind = Opaque<string, 'ElementKind'>;
7
+ export type ElementShape = 'rectangle' | 'person' | 'browser' | 'mobile' | 'cylinder' | 'storage' | 'queue';
8
+ export declare const DefaultThemeColor = "primary";
9
+ export declare const DefaultElementShape = "rectangle";
10
+ export interface ElementStyle {
11
+ shape?: ElementShape;
12
+ }
13
+ export type Tag = Opaque<string, 'Tag'>;
14
+ export interface TagSpec {
15
+ readonly id: Tag;
16
+ readonly style: ElementStyle;
17
+ }
18
+ export interface Element {
19
+ readonly id: Fqn;
20
+ readonly kind: ElementKind;
21
+ readonly title: string;
22
+ readonly description: string | null;
23
+ readonly technology: string | null;
24
+ readonly tags: NonEmptyArray<Tag> | null;
25
+ readonly links: NonEmptyArray<string> | null;
26
+ readonly icon?: IconUrl;
27
+ readonly shape?: ElementShape;
28
+ readonly color?: ThemeColor;
29
+ }
30
+ //# sourceMappingURL=element.d.ts.map
@@ -0,0 +1,57 @@
1
+ import type { ElementKind, Fqn, Tag } from './element';
2
+ interface BaseExpr {
3
+ element?: never;
4
+ elementKind?: never;
5
+ elementTag?: never;
6
+ isEqual?: never;
7
+ isDescedants?: never;
8
+ wildcard?: never;
9
+ source?: never;
10
+ target?: never;
11
+ inout?: never;
12
+ incoming?: never;
13
+ outgoing?: never;
14
+ }
15
+ export interface ElementRefExpr extends Omit<BaseExpr, 'element' | 'isDescedants'> {
16
+ element: Fqn;
17
+ isDescedants?: boolean;
18
+ }
19
+ export declare function isElementRef(expr: Expression): expr is ElementRefExpr;
20
+ export interface WildcardExpr extends Omit<BaseExpr, 'wildcard'> {
21
+ wildcard: true;
22
+ }
23
+ export declare function isWildcard(expr: Expression): expr is WildcardExpr;
24
+ export interface ElementKindExpr extends Omit<BaseExpr, 'elementKind' | 'isEqual'> {
25
+ elementKind: ElementKind;
26
+ isEqual: boolean;
27
+ }
28
+ export declare function isElementKindExpr(expr: Expression): expr is ElementKindExpr;
29
+ export interface ElementTagExpr extends Omit<BaseExpr, 'elementTag' | 'isEqual'> {
30
+ elementTag: Tag;
31
+ isEqual: boolean;
32
+ }
33
+ export declare function isElementTagExpr(expr: Expression): expr is ElementTagExpr;
34
+ export type ElementExpression = ElementRefExpr | WildcardExpr | ElementKindExpr | ElementTagExpr;
35
+ export declare function isElement(expr: Expression): expr is ElementExpression;
36
+ export interface RelationExpr extends Omit<BaseExpr, 'source' | 'target'> {
37
+ source: ElementExpression;
38
+ target: ElementExpression;
39
+ }
40
+ export declare function isRelation(expr: Expression): expr is RelationExpr;
41
+ export interface InOutExpr extends Omit<BaseExpr, 'inout'> {
42
+ inout: ElementExpression;
43
+ }
44
+ export declare function isInOut(expr: Expression): expr is InOutExpr;
45
+ export interface IncomingExpr extends Omit<BaseExpr, 'incoming'> {
46
+ incoming: ElementExpression;
47
+ }
48
+ export declare function isIncoming(expr: Expression): expr is IncomingExpr;
49
+ export interface OutgoingExpr extends Omit<BaseExpr, 'outgoing'> {
50
+ outgoing: ElementExpression;
51
+ }
52
+ export declare function isOutgoing(expr: Expression): expr is OutgoingExpr;
53
+ export type AnyRelationExpression = RelationExpr | InOutExpr | IncomingExpr | OutgoingExpr;
54
+ export declare function isAnyRelation(expr: Expression): expr is AnyRelationExpression;
55
+ export type Expression = ElementExpression | AnyRelationExpression;
56
+ export {};
57
+ //# sourceMappingURL=expression.d.ts.map
@@ -0,0 +1,12 @@
1
+ export * from './opaque';
2
+ export * from './_common';
3
+ export * from './theme';
4
+ export * from './element';
5
+ export * from './relation';
6
+ export * from './model';
7
+ export * from './view';
8
+ export * from './expression';
9
+ export * from './computed-view';
10
+ export * from './diagram';
11
+ export * as Expr from './expression';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { ComputedView } from './computed-view';
2
+ import type { Element, Fqn } from './element';
3
+ import type { Relation, RelationID } from './relation';
4
+ import type { ElementView, ViewID } from './view';
5
+ export interface LikeC4RawModel {
6
+ elements: Record<Fqn, Element>;
7
+ relations: Record<RelationID, Relation>;
8
+ views: Record<ViewID, ElementView>;
9
+ }
10
+ export interface LikeC4Model {
11
+ elements: Record<Fqn, Element>;
12
+ relations: Record<RelationID, Relation>;
13
+ views: Record<ViewID, ComputedView>;
14
+ }
15
+ //# sourceMappingURL=model.d.ts.map