@likec4/core 1.31.0 → 1.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +407 -5
- package/dist/builder/index.d.mts +221 -42
- package/dist/builder/index.mjs +118 -65
- package/dist/compute-view/index.d.mts +23 -7
- package/dist/compute-view/index.mjs +11 -6
- package/dist/compute-view/relationships-view/index.d.mts +9 -7
- package/dist/compute-view/relationships-view/index.mjs +3 -2
- package/dist/index.d.mts +10 -14
- package/dist/index.mjs +9 -6
- package/dist/model/index.d.mts +173 -19
- package/dist/model/index.mjs +6 -1
- package/dist/shared/core.BaYE_r29.d.mts +258 -0
- package/dist/shared/core.Bk7wEZFG.mjs +276 -0
- package/dist/shared/core.BrCnZFTn.mjs +32 -0
- package/dist/shared/core.BuO4ncfY.d.mts +146 -0
- package/dist/shared/{core.Bq753SYD.mjs → core.CBpKAlhj.mjs} +2012 -4422
- package/dist/shared/core.CUYDgv2-.mjs +214 -0
- package/dist/shared/{core.Cu-UdkSl.mjs → core.CpXlRyE5.mjs} +7 -494
- package/dist/shared/{core.C-YXI-43.mjs → core.Cy9smucx.mjs} +3 -1
- package/dist/shared/core.CywrQs86.d.mts +31 -0
- package/dist/shared/core.DXzRBkuI.d.mts +1264 -0
- package/dist/shared/core.DoK86JEe.mjs +518 -0
- package/dist/shared/{core.D2830qgg.d.mts → core.Pf5I9o0e.d.mts} +1 -1
- package/dist/shared/core.cbA9VZ02.mjs +2681 -0
- package/dist/shared/{core.CQXU9DF7.mjs → core.rmvsy0n3.mjs} +23 -32
- package/dist/shared/core.znRaUX_A.d.mts +920 -0
- package/dist/types/aux.d.mts +3 -0
- package/dist/types/aux.mjs +1 -0
- package/dist/types/index.d.mts +7 -45
- package/dist/types/index.mjs +130 -3
- package/dist/utils/index.d.mts +221 -53
- package/dist/utils/index.mjs +14 -10
- package/package.json +16 -8
- package/src/builder/Builder.deploymentModel.ts +82 -18
- package/src/builder/Builder.element.ts +40 -20
- package/src/builder/Builder.model.ts +66 -17
- package/src/builder/Builder.ts +168 -76
- package/src/builder/Builder.view-common.ts +35 -17
- package/src/builder/Builder.view-deployment.ts +25 -25
- package/src/builder/Builder.view-element.ts +13 -12
- package/src/builder/Builder.views.ts +12 -7
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +62 -34
- package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +319 -0
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +45 -24
- package/src/builder/_types.ts +34 -27
- package/src/compute-view/compute-view.ts +31 -34
- package/src/compute-view/deployment-view/__test__/TestHelper.ts +27 -14
- package/src/compute-view/deployment-view/__test__/fixture.ts +15 -13
- package/src/compute-view/deployment-view/_types.ts +10 -10
- package/src/compute-view/deployment-view/clean-connections.ts +5 -7
- package/src/compute-view/deployment-view/compute.ts +16 -13
- package/src/compute-view/deployment-view/memory/memory.ts +5 -6
- package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +4 -5
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +25 -50
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +5 -7
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +7 -11
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +7 -10
- package/src/compute-view/deployment-view/predicates/utils.ts +37 -31
- package/src/compute-view/deployment-view/predicates/wildcard.ts +3 -2
- package/src/compute-view/deployment-view/stages/stage-final.ts +2 -2
- package/src/compute-view/deployment-view/stages/stage-include.ts +1 -1
- package/src/compute-view/deployment-view/utils.ts +79 -72
- package/src/compute-view/dynamic-view/__test__/fixture.ts +20 -11
- package/src/compute-view/dynamic-view/compute.ts +60 -53
- package/src/compute-view/element-view/__test__/TestHelper.ts +53 -29
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +26 -26
- package/src/compute-view/element-view/__test__/fixture.ts +134 -83
- package/src/compute-view/element-view/_types.ts +14 -19
- package/src/compute-view/element-view/clean-connections.ts +12 -8
- package/src/compute-view/element-view/compute.ts +61 -51
- package/src/compute-view/element-view/memory/NodeGroup.ts +8 -9
- package/src/compute-view/element-view/memory/memory.ts +22 -22
- package/src/compute-view/element-view/memory/stage-include.ts +5 -3
- package/src/compute-view/element-view/predicates/_utils.ts +18 -14
- package/src/compute-view/element-view/predicates/element-expand.ts +4 -5
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +3 -4
- package/src/compute-view/element-view/predicates/element-ref.ts +3 -4
- package/src/compute-view/element-view/predicates/relation-direct.ts +16 -12
- package/src/compute-view/element-view/predicates/relation-in-out.ts +7 -8
- package/src/compute-view/element-view/predicates/relation-in.ts +19 -26
- package/src/compute-view/element-view/predicates/relation-out.ts +20 -21
- package/src/compute-view/element-view/predicates/wildcard.ts +3 -3
- package/src/compute-view/element-view/utils.ts +25 -23
- package/src/compute-view/index.ts +1 -1
- package/src/compute-view/memory/AbstractStageExclude.ts +3 -4
- package/src/compute-view/memory/AbstractStageInclude.ts +1 -1
- package/src/compute-view/memory/_types.ts +3 -2
- package/src/compute-view/relationships-view/_types.ts +3 -4
- package/src/compute-view/relationships-view/compute.ts +8 -11
- package/src/compute-view/relationships-view/layout.ts +6 -6
- package/src/compute-view/relationships-view/utils.ts +4 -4
- package/src/compute-view/utils/ancestorsOfNode.ts +7 -7
- package/src/compute-view/utils/applyCustomElementProperties.ts +16 -8
- package/src/compute-view/utils/applyCustomRelationProperties.ts +19 -9
- package/src/compute-view/utils/applyViewRuleStyles.ts +18 -10
- package/src/compute-view/utils/buildComputedNodes.ts +40 -40
- package/src/compute-view/utils/buildElementNotations.ts +14 -14
- package/src/compute-view/utils/elementExpressionToPredicate.ts +14 -15
- package/src/compute-view/utils/link-nodes-with-edges.ts +6 -4
- package/src/compute-view/utils/merge-props-from-relationships.ts +52 -20
- package/src/compute-view/utils/relationExpressionToPredicates.ts +19 -19
- package/src/compute-view/utils/resolve-extended-views.ts +8 -7
- package/src/compute-view/utils/resolve-global-rules.ts +31 -26
- package/src/compute-view/utils/topological-sort.ts +14 -14
- package/src/compute-view/utils/view-hash.ts +2 -2
- package/src/compute-view/utils/with-readable-edges.ts +9 -5
- package/src/index.ts +0 -32
- package/src/model/DeploymentElementModel.ts +171 -144
- package/src/model/DeploymentModel.ts +88 -65
- package/src/model/ElementModel.ts +85 -74
- package/src/model/LikeC4Model.ts +430 -241
- package/src/model/RelationModel.ts +63 -29
- package/src/model/__test__/fixture.ts +50 -36
- package/src/model/connection/Connection.ts +2 -2
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +21 -24
- package/src/model/connection/deployment/find.ts +1 -1
- package/src/model/connection/model/ConnectionModel.ts +21 -20
- package/src/model/connection/model/find.ts +7 -7
- package/src/model/connection/ops.ts +6 -6
- package/src/model/guards.ts +66 -14
- package/src/model/index.ts +20 -7
- package/src/model/types.ts +41 -97
- package/src/model/view/EdgeModel.ts +47 -41
- package/src/model/view/LikeC4ViewModel.ts +130 -80
- package/src/model/view/NodeModel.ts +102 -96
- package/src/theme/element.ts +1 -1
- package/src/theme/index.ts +9 -9
- package/src/theme/relationships.ts +1 -1
- package/src/types/_common.ts +21 -15
- package/src/types/aux.ts +285 -0
- package/src/types/const.ts +34 -0
- package/src/types/expression-model.ts +292 -0
- package/src/types/expression.ts +311 -0
- package/src/types/fqnRef.ts +88 -0
- package/src/types/geometry.ts +131 -0
- package/src/types/global.ts +10 -8
- package/src/types/index.ts +39 -201
- package/src/types/model-data.ts +52 -84
- package/src/types/model-deployment.ts +87 -0
- package/src/types/model-dump.ts +72 -0
- package/src/types/model-logical.ts +111 -0
- package/src/types/model-spec.ts +81 -0
- package/src/types/operators.ts +51 -52
- package/src/types/scalar.ts +114 -0
- package/src/types/{theme.ts → styles.ts} +55 -15
- package/src/types/view-changes.ts +4 -5
- package/src/types/view-common.ts +157 -0
- package/src/types/view-computed.ts +113 -0
- package/src/types/view-layouted.ts +82 -0
- package/src/types/view-parsed.deployment.ts +40 -0
- package/src/types/view-parsed.dynamic.ts +78 -0
- package/src/types/view-parsed.element.ts +65 -0
- package/src/types/view.ts +122 -542
- package/src/utils/compare-natural.ts +43 -1
- package/src/utils/getOrCreate.ts +0 -34
- package/src/utils/index.ts +7 -12
- package/src/utils/iterable/filter.ts +1 -1
- package/src/utils/iterable/find.ts +3 -1
- package/src/utils/iterable/head.ts +22 -0
- package/src/utils/iterable/index.ts +1 -0
- package/src/utils/iterable/map.ts +1 -1
- package/src/utils/iterable/reduce.ts +1 -1
- package/src/utils/iterable/some.ts +1 -1
- package/src/utils/memoize-prop.ts +30 -0
- package/src/utils/object-hash.ts +1 -1
- package/src/utils/relations.ts +14 -11
- package/src/utils/string-hash.ts +1 -1
- package/dist/shared/core.CQDU11hR.d.mts +0 -753
- package/dist/shared/core.DJvmfnEi.d.mts +0 -1153
- package/dist/shared/core.DgfwjBtu.mjs +0 -495
- package/dist/shared/core.Dx7siloV.d.mts +0 -146
- package/dist/shared/core.SjLhMA7a.d.mts +0 -62
- package/src/builder/__snapshots__/Builder.spec.ts.snap +0 -374
- package/src/compute-view/element-view/predicates.ts +0 -520
- package/src/compute-view/utils/uniqueTags.ts +0 -21
- package/src/types/deployments.ts +0 -170
- package/src/types/element.ts +0 -109
- package/src/types/expression-v2-model.ts +0 -314
- package/src/types/expression-v2.ts +0 -392
- package/src/types/overview-graph.ts +0 -43
- package/src/types/relation.ts +0 -61
- package/src/types/scalars.ts +0 -39
- package/src/types/view-notation.ts +0 -9
- package/src/utils/graphlib.ts +0 -10
- /package/src/{errors/index.ts → utils/invariant.ts} +0 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { i as invariant, t as t$1, a as nonexhaustive } from './core.Cy9smucx.mjs';
|
|
2
|
+
import { u } from './core.DbRvwARP.mjs';
|
|
3
|
+
|
|
4
|
+
function isOnStage(value, stage) {
|
|
5
|
+
return value[_stage] === stage;
|
|
6
|
+
}
|
|
7
|
+
const _stage = "_stage";
|
|
8
|
+
const _type = "_type";
|
|
9
|
+
|
|
10
|
+
function n$1(e){return !!e}
|
|
11
|
+
|
|
12
|
+
function n(e){return e==null}
|
|
13
|
+
|
|
14
|
+
function o(a){return t=>!a(t)}
|
|
15
|
+
|
|
16
|
+
function t(...a){return u(e,a)}var e=(a,o)=>o.every(l=>l(a));
|
|
17
|
+
|
|
18
|
+
function y(...a){return u(r,a)}var r=(a,o)=>o.some(e=>e(a));
|
|
19
|
+
|
|
20
|
+
function Fqn(name, parent) {
|
|
21
|
+
return parent ? parent + "." + name : name;
|
|
22
|
+
}
|
|
23
|
+
const GroupElementKind = "@group";
|
|
24
|
+
function isGroupElementKind(v) {
|
|
25
|
+
return v.kind === GroupElementKind;
|
|
26
|
+
}
|
|
27
|
+
function DeploymentFqn(name, parent) {
|
|
28
|
+
return parent ? parent + "." + name : name;
|
|
29
|
+
}
|
|
30
|
+
function ViewId(id) {
|
|
31
|
+
return id;
|
|
32
|
+
}
|
|
33
|
+
function RelationId(id) {
|
|
34
|
+
return id;
|
|
35
|
+
}
|
|
36
|
+
function GlobalFqn(projectId, name) {
|
|
37
|
+
invariant(n$1(projectId), "Project ID must start with @");
|
|
38
|
+
return "@" + projectId + "." + name;
|
|
39
|
+
}
|
|
40
|
+
function isGlobalFqn(fqn) {
|
|
41
|
+
return fqn.startsWith("@");
|
|
42
|
+
}
|
|
43
|
+
function splitGlobalFqn(fqn) {
|
|
44
|
+
if (!fqn.startsWith("@")) {
|
|
45
|
+
return [null, fqn];
|
|
46
|
+
}
|
|
47
|
+
const firstDot = fqn.indexOf(".");
|
|
48
|
+
if (firstDot < 2) {
|
|
49
|
+
throw new Error("Invalid global FQN");
|
|
50
|
+
}
|
|
51
|
+
const projectId = fqn.slice(1, firstDot);
|
|
52
|
+
const name = fqn.slice(firstDot + 1);
|
|
53
|
+
return [projectId, name];
|
|
54
|
+
}
|
|
55
|
+
function NodeId(id) {
|
|
56
|
+
return id;
|
|
57
|
+
}
|
|
58
|
+
function EdgeId(id) {
|
|
59
|
+
return id;
|
|
60
|
+
}
|
|
61
|
+
function stepEdgeId(step, parallelStep) {
|
|
62
|
+
const id = `step-${String(step).padStart(2, "0")}`;
|
|
63
|
+
return parallelStep ? `${id}.${parallelStep}` : id;
|
|
64
|
+
}
|
|
65
|
+
const StepEdgeKind = "@step";
|
|
66
|
+
function isStepEdgeId(id) {
|
|
67
|
+
return id.startsWith("step-");
|
|
68
|
+
}
|
|
69
|
+
function extractStep(id) {
|
|
70
|
+
if (!isStepEdgeId(id)) {
|
|
71
|
+
throw new Error(`Invalid step edge id: ${id}`);
|
|
72
|
+
}
|
|
73
|
+
return parseFloat(id.slice("step-".length));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var FqnRef;
|
|
77
|
+
((FqnRef2) => {
|
|
78
|
+
function isElementRef(ref) {
|
|
79
|
+
return "model" in ref && !("project" in ref);
|
|
80
|
+
}
|
|
81
|
+
FqnRef2.isElementRef = isElementRef;
|
|
82
|
+
function isImportRef(ref) {
|
|
83
|
+
return "project" in ref && "model" in ref;
|
|
84
|
+
}
|
|
85
|
+
FqnRef2.isImportRef = isImportRef;
|
|
86
|
+
function flatten(ref) {
|
|
87
|
+
if (t$1(ref)) {
|
|
88
|
+
throw new Error(`Expected FqnRef, got: "${ref}"`);
|
|
89
|
+
}
|
|
90
|
+
if (isImportRef(ref)) {
|
|
91
|
+
return GlobalFqn(ref.project, ref.model);
|
|
92
|
+
}
|
|
93
|
+
if (isElementRef(ref)) {
|
|
94
|
+
return ref.model;
|
|
95
|
+
}
|
|
96
|
+
throw new Error("Expected FqnRef.ModelRef or FqnRef.ImportRef");
|
|
97
|
+
}
|
|
98
|
+
FqnRef2.flatten = flatten;
|
|
99
|
+
function isModelRef(ref) {
|
|
100
|
+
return isElementRef(ref) || isImportRef(ref);
|
|
101
|
+
}
|
|
102
|
+
FqnRef2.isModelRef = isModelRef;
|
|
103
|
+
function isInsideInstanceRef(ref) {
|
|
104
|
+
return "deployment" in ref && "element" in ref;
|
|
105
|
+
}
|
|
106
|
+
FqnRef2.isInsideInstanceRef = isInsideInstanceRef;
|
|
107
|
+
function isDeploymentElementRef(ref) {
|
|
108
|
+
return "deployment" in ref && !("element" in ref);
|
|
109
|
+
}
|
|
110
|
+
FqnRef2.isDeploymentElementRef = isDeploymentElementRef;
|
|
111
|
+
function isDeploymentRef(ref) {
|
|
112
|
+
return isDeploymentElementRef(ref) || isInsideInstanceRef(ref);
|
|
113
|
+
}
|
|
114
|
+
FqnRef2.isDeploymentRef = isDeploymentRef;
|
|
115
|
+
})(FqnRef || (FqnRef = {}));
|
|
116
|
+
|
|
117
|
+
function isDeploymentNode(el) {
|
|
118
|
+
return "kind" in el && !n$1(el.element);
|
|
119
|
+
}
|
|
120
|
+
function isDeployedInstance(el) {
|
|
121
|
+
return "element" in el && n$1(el.element);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const DefaultThemeColor = "primary";
|
|
125
|
+
const DefaultElementShape = "rectangle";
|
|
126
|
+
const DefaultShapeSize = "md";
|
|
127
|
+
const DefaultPaddingSize = "md";
|
|
128
|
+
const DefaultTextSize = "md";
|
|
129
|
+
const DefaultLineStyle = "dashed";
|
|
130
|
+
const DefaultArrowType = "normal";
|
|
131
|
+
const DefaultRelationshipColor = "gray";
|
|
132
|
+
|
|
133
|
+
function isTagEqual(operator) {
|
|
134
|
+
return "tag" in operator;
|
|
135
|
+
}
|
|
136
|
+
function isKindEqual(operator) {
|
|
137
|
+
return "kind" in operator;
|
|
138
|
+
}
|
|
139
|
+
function isParticipantOperator(operator) {
|
|
140
|
+
return "participant" in operator;
|
|
141
|
+
}
|
|
142
|
+
function isNotOperator(operator) {
|
|
143
|
+
return "not" in operator;
|
|
144
|
+
}
|
|
145
|
+
function isAndOperator(operator) {
|
|
146
|
+
return "and" in operator;
|
|
147
|
+
}
|
|
148
|
+
function isOrOperator(operator) {
|
|
149
|
+
return "or" in operator;
|
|
150
|
+
}
|
|
151
|
+
function whereOperatorAsPredicate(operator) {
|
|
152
|
+
switch (true) {
|
|
153
|
+
case isParticipantOperator(operator): {
|
|
154
|
+
const participant = operator.participant;
|
|
155
|
+
const participantPredicate = whereOperatorAsPredicate(operator.operator);
|
|
156
|
+
return participantIs(participant, participantPredicate);
|
|
157
|
+
}
|
|
158
|
+
case isTagEqual(operator): {
|
|
159
|
+
if (t$1(operator.tag) || "eq" in operator.tag) {
|
|
160
|
+
const tag2 = t$1(operator.tag) ? operator.tag : operator.tag.eq;
|
|
161
|
+
return (value) => {
|
|
162
|
+
return Array.isArray(value.tags) && value.tags.includes(tag2);
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const tag = operator.tag.neq;
|
|
166
|
+
return (value) => {
|
|
167
|
+
return !Array.isArray(value.tags) || !value.tags.includes(tag);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
case isKindEqual(operator): {
|
|
171
|
+
if (t$1(operator.kind) || "eq" in operator.kind) {
|
|
172
|
+
const kind2 = t$1(operator.kind) ? operator.kind : operator.kind.eq;
|
|
173
|
+
return (value) => {
|
|
174
|
+
return value.kind === kind2;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const kind = operator.kind.neq;
|
|
178
|
+
return (value) => {
|
|
179
|
+
return n(value.kind) || value.kind !== kind;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
case isNotOperator(operator): {
|
|
183
|
+
const predicate = whereOperatorAsPredicate(operator.not);
|
|
184
|
+
return o(predicate);
|
|
185
|
+
}
|
|
186
|
+
case isAndOperator(operator): {
|
|
187
|
+
const predicates = operator.and.map(whereOperatorAsPredicate);
|
|
188
|
+
return t(predicates);
|
|
189
|
+
}
|
|
190
|
+
case isOrOperator(operator): {
|
|
191
|
+
const predicates = operator.or.map(whereOperatorAsPredicate);
|
|
192
|
+
return y(predicates);
|
|
193
|
+
}
|
|
194
|
+
default:
|
|
195
|
+
nonexhaustive(operator);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function participantIs(participant, predicate) {
|
|
199
|
+
return (value) => {
|
|
200
|
+
if (!value.source || !value.target) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
switch (participant) {
|
|
204
|
+
case "source": {
|
|
205
|
+
return predicate(value.source);
|
|
206
|
+
}
|
|
207
|
+
case "target": {
|
|
208
|
+
return predicate(value.target);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export { DeploymentFqn as A, GlobalFqn as B, isGlobalFqn as C, DefaultElementShape as D, splitGlobalFqn as E, FqnRef as F, GroupElementKind as G, EdgeId as H, extractStep as I, NodeId as N, RelationId as R, StepEdgeKind as S, ViewId as V, _type as _, DefaultThemeColor as a, _stage as b, n$1 as c, isStepEdgeId as d, isGroupElementKind as e, DefaultArrowType as f, DefaultLineStyle as g, DefaultRelationshipColor as h, isDeployedInstance as i, isOnStage as j, isDeploymentNode as k, DefaultShapeSize as l, DefaultPaddingSize as m, n, o, DefaultTextSize as p, isTagEqual as q, isKindEqual as r, stepEdgeId as s, isParticipantOperator as t, isNotOperator as u, isAndOperator as v, whereOperatorAsPredicate as w, isOrOperator as x, y, Fqn as z };
|