@likec4/core 1.9.0 → 1.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/dist/index.cjs +107 -8
- package/dist/index.d.cts +18 -6
- package/dist/index.d.mts +18 -6
- package/dist/index.d.ts +793 -0
- package/dist/index.mjs +104 -10
- package/dist/shared/{core.9l7eW3pn.d.cts → core.CpR2fq5B.d.cts} +54 -38
- package/dist/shared/{core.9l7eW3pn.d.mts → core.CpR2fq5B.d.mts} +54 -38
- package/dist/shared/core.CpR2fq5B.d.ts +833 -0
- package/dist/shared/{core.DcPLm41i.cjs → core.Db3ntVII.cjs} +17 -3
- package/dist/shared/{core.DfUTsojZ.mjs → core.DeifT5lC.mjs} +16 -4
- package/dist/types/index.cjs +3 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.mjs +1 -1
- package/package.json +4 -2
- package/src/index.ts +1 -0
- package/src/types/element.ts +3 -0
- package/src/types/expression.ts +4 -0
- package/src/types/relation.ts +3 -0
- package/src/types/view.ts +37 -6
- package/src/utils/compare-natural.spec.ts +37 -0
- package/src/utils/compare-natural.ts +14 -0
- package/src/utils/fqn.spec.ts +99 -2
- package/src/utils/fqn.ts +38 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/relations.spec.ts +1 -1
- package/src/utils/relations.ts +7 -7
|
@@ -24,6 +24,8 @@ function o(a){return t=>!a(t)}
|
|
|
24
24
|
|
|
25
25
|
function e$1(n){return n==null}
|
|
26
26
|
|
|
27
|
+
function n(r){return Array.isArray(r)}
|
|
28
|
+
|
|
27
29
|
function t(...a){return u(e,a)}var e=(a,o)=>o.every(l=>l(a));
|
|
28
30
|
|
|
29
31
|
function y(...a){return u(r,a)}var r=(a,o)=>o.some(e=>e(a));
|
|
@@ -208,6 +210,9 @@ function isViewRuleAutoLayout(rule) {
|
|
|
208
210
|
function isDynamicViewIncludeRule(rule) {
|
|
209
211
|
return "include" in rule && Array.isArray(rule.include);
|
|
210
212
|
}
|
|
213
|
+
function isDynamicViewParallelSteps(step) {
|
|
214
|
+
return "__parallel" in step && n(step.__parallel);
|
|
215
|
+
}
|
|
211
216
|
function isDynamicView(view) {
|
|
212
217
|
return view.__ === "dynamic";
|
|
213
218
|
}
|
|
@@ -220,8 +225,9 @@ function isExtendsElementView(view) {
|
|
|
220
225
|
function isScopedElementView(view) {
|
|
221
226
|
return isElementView(view) && "viewOf" in view;
|
|
222
227
|
}
|
|
223
|
-
function StepEdgeId(step) {
|
|
224
|
-
|
|
228
|
+
function StepEdgeId(step, parallelStep) {
|
|
229
|
+
const id = `step-${String(step).padStart(2, "0")}`;
|
|
230
|
+
return parallelStep ? `${id}.${parallelStep}` : id;
|
|
225
231
|
}
|
|
226
232
|
function isStepEdgeId(id) {
|
|
227
233
|
return id.startsWith("step-");
|
|
@@ -230,7 +236,13 @@ function extractStep(id) {
|
|
|
230
236
|
if (!isStepEdgeId(id)) {
|
|
231
237
|
throw new Error(`Invalid step edge id: ${id}`);
|
|
232
238
|
}
|
|
233
|
-
return
|
|
239
|
+
return parseFloat(id.slice("step-".length));
|
|
240
|
+
}
|
|
241
|
+
function getParallelStepsPrefix(id) {
|
|
242
|
+
if (isStepEdgeId(id) && id.includes(".")) {
|
|
243
|
+
return id.slice(0, id.indexOf(".") + 1);
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
234
246
|
}
|
|
235
247
|
function isComputedDynamicView(view) {
|
|
236
248
|
return view.__ === "dynamic";
|
|
@@ -263,6 +275,7 @@ exports.e = e$1;
|
|
|
263
275
|
exports.expression = expression;
|
|
264
276
|
exports.extractStep = extractStep;
|
|
265
277
|
exports.getBBoxCenter = getBBoxCenter;
|
|
278
|
+
exports.getParallelStepsPrefix = getParallelStepsPrefix;
|
|
266
279
|
exports.invariant = invariant;
|
|
267
280
|
exports.isAndOperator = isAndOperator;
|
|
268
281
|
exports.isComputedDynamicView = isComputedDynamicView;
|
|
@@ -271,6 +284,7 @@ exports.isCustomElement = isCustomElement;
|
|
|
271
284
|
exports.isCustomRelationExpr = isCustomRelationExpr;
|
|
272
285
|
exports.isDynamicView = isDynamicView;
|
|
273
286
|
exports.isDynamicViewIncludeRule = isDynamicViewIncludeRule;
|
|
287
|
+
exports.isDynamicViewParallelSteps = isDynamicViewParallelSteps;
|
|
274
288
|
exports.isElement = isElement;
|
|
275
289
|
exports.isElementKindExpr = isElementKindExpr;
|
|
276
290
|
exports.isElementPredicateExpr = isElementPredicateExpr;
|
|
@@ -22,6 +22,8 @@ function o(a){return t=>!a(t)}
|
|
|
22
22
|
|
|
23
23
|
function e$1(n){return n==null}
|
|
24
24
|
|
|
25
|
+
function n(r){return Array.isArray(r)}
|
|
26
|
+
|
|
25
27
|
function t(...a){return u(e,a)}var e=(a,o)=>o.every(l=>l(a));
|
|
26
28
|
|
|
27
29
|
function y(...a){return u(r,a)}var r=(a,o)=>o.some(e=>e(a));
|
|
@@ -206,6 +208,9 @@ function isViewRuleAutoLayout(rule) {
|
|
|
206
208
|
function isDynamicViewIncludeRule(rule) {
|
|
207
209
|
return "include" in rule && Array.isArray(rule.include);
|
|
208
210
|
}
|
|
211
|
+
function isDynamicViewParallelSteps(step) {
|
|
212
|
+
return "__parallel" in step && n(step.__parallel);
|
|
213
|
+
}
|
|
209
214
|
function isDynamicView(view) {
|
|
210
215
|
return view.__ === "dynamic";
|
|
211
216
|
}
|
|
@@ -218,8 +223,9 @@ function isExtendsElementView(view) {
|
|
|
218
223
|
function isScopedElementView(view) {
|
|
219
224
|
return isElementView(view) && "viewOf" in view;
|
|
220
225
|
}
|
|
221
|
-
function StepEdgeId(step) {
|
|
222
|
-
|
|
226
|
+
function StepEdgeId(step, parallelStep) {
|
|
227
|
+
const id = `step-${String(step).padStart(2, "0")}`;
|
|
228
|
+
return parallelStep ? `${id}.${parallelStep}` : id;
|
|
223
229
|
}
|
|
224
230
|
function isStepEdgeId(id) {
|
|
225
231
|
return id.startsWith("step-");
|
|
@@ -228,7 +234,13 @@ function extractStep(id) {
|
|
|
228
234
|
if (!isStepEdgeId(id)) {
|
|
229
235
|
throw new Error(`Invalid step edge id: ${id}`);
|
|
230
236
|
}
|
|
231
|
-
return
|
|
237
|
+
return parseFloat(id.slice("step-".length));
|
|
238
|
+
}
|
|
239
|
+
function getParallelStepsPrefix(id) {
|
|
240
|
+
if (isStepEdgeId(id) && id.includes(".")) {
|
|
241
|
+
return id.slice(0, id.indexOf(".") + 1);
|
|
242
|
+
}
|
|
243
|
+
return null;
|
|
232
244
|
}
|
|
233
245
|
function isComputedDynamicView(view) {
|
|
234
246
|
return view.__ === "dynamic";
|
|
@@ -248,4 +260,4 @@ function getBBoxCenter({
|
|
|
248
260
|
};
|
|
249
261
|
}
|
|
250
262
|
|
|
251
|
-
export { AsFqn as A, BorderStyles as B, isNotOperator as C, DefaultElementShape as D, ElementShapes as E, isAndOperator as F, isOrOperator as G, whereOperatorAsPredicate as H, DefaultLineStyle as I, DefaultArrowType as J, DefaultRelationshipColor as K, isThemeColor as L, isViewRulePredicate as M, isViewRuleStyle as N, isViewRuleAutoLayout as O, isDynamicViewIncludeRule as P,
|
|
263
|
+
export { getBBoxCenter as $, AsFqn as A, BorderStyles as B, isNotOperator as C, DefaultElementShape as D, ElementShapes as E, isAndOperator as F, isOrOperator as G, whereOperatorAsPredicate as H, DefaultLineStyle as I, DefaultArrowType as J, DefaultRelationshipColor as K, isThemeColor as L, isViewRulePredicate as M, isViewRuleStyle as N, isViewRuleAutoLayout as O, isDynamicViewIncludeRule as P, isDynamicViewParallelSteps as Q, isDynamicView as R, isElementView as S, isExtendsElementView as T, isScopedElementView as U, StepEdgeId as V, isStepEdgeId as W, extractStep as X, getParallelStepsPrefix as Y, isComputedDynamicView as Z, isComputedElementView as _, DefaultThemeColor as a, nonexhaustive as b, expression as c, isElementRef as d, e$1 as e, isExpandedElementExpr as f, isCustomElement as g, isWildcard as h, invariant as i, isElementKindExpr as j, isElementTagExpr as k, isElement as l, isElementWhere as m, nonNullable as n, isElementPredicateExpr as o, isRelation as p, isInOut as q, isIncoming as r, isOutgoing as s, isRelationExpression as t, u, isRelationWhere as v, isCustomRelationExpr as w, isRelationPredicateExpr as x, isTagEqual as y, isKindEqual as z };
|
package/dist/types/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const types_index = require('../shared/core.
|
|
3
|
+
const types_index = require('../shared/core.Db3ntVII.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -16,6 +16,7 @@ exports.Expr = types_index.expression;
|
|
|
16
16
|
exports.StepEdgeId = types_index.StepEdgeId;
|
|
17
17
|
exports.extractStep = types_index.extractStep;
|
|
18
18
|
exports.getBBoxCenter = types_index.getBBoxCenter;
|
|
19
|
+
exports.getParallelStepsPrefix = types_index.getParallelStepsPrefix;
|
|
19
20
|
exports.isAndOperator = types_index.isAndOperator;
|
|
20
21
|
exports.isComputedDynamicView = types_index.isComputedDynamicView;
|
|
21
22
|
exports.isComputedElementView = types_index.isComputedElementView;
|
|
@@ -23,6 +24,7 @@ exports.isCustomElement = types_index.isCustomElement;
|
|
|
23
24
|
exports.isCustomRelationExpr = types_index.isCustomRelationExpr;
|
|
24
25
|
exports.isDynamicView = types_index.isDynamicView;
|
|
25
26
|
exports.isDynamicViewIncludeRule = types_index.isDynamicViewIncludeRule;
|
|
27
|
+
exports.isDynamicViewParallelSteps = types_index.isDynamicViewParallelSteps;
|
|
26
28
|
exports.isElement = types_index.isElement;
|
|
27
29
|
exports.isElementKindExpr = types_index.isElementKindExpr;
|
|
28
30
|
exports.isElementPredicateExpr = types_index.isElementPredicateExpr;
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { aq as AndOperator, A as AsFqn, aP as AutoLayoutDirection,
|
|
1
|
+
export { aq as AndOperator, A as AsFqn, aP as AutoLayoutDirection, bl as BBox, aU as BasicElementView, aT as BasicView, o as BorderStyle, B as BorderStyles, e as Color, aE as ColorLiteral, bi as ComputedDynamicView, f as ComputedEdge, bh as ComputedElementView, g as ComputedLikeC4Model, b as ComputedNode, C as ComputedView, m as CustomColor, b4 as CustomColorDefinitions, G as CustomElementExpr, ad as CustomRelationExpr, aA as DefaultArrowType, q as DefaultElementShape, az as DefaultLineStyle, aB as DefaultRelationshipColor, D as DefaultThemeColor, bo as DiagramEdge, bn as DiagramNode, bp as DiagramView, b2 as DynamicView, a$ as DynamicViewIncludeRule, aZ as DynamicViewParallelSteps, b1 as DynamicViewRule, aY as DynamicViewStep, a_ as DynamicViewStepOrParallel, E as EdgeId, h as Element, U as ElementExpression, c as ElementKind, M as ElementKindExpr, v as ElementKindSpecification, u as ElementKindSpecificationStyle, bs as ElementNotation, $ as ElementPredicateExpression, w as ElementRefExpr, d as ElementShape, p as ElementShapes, r as ElementStyle, Q as ElementTagExpr, aG as ElementThemeColorValues, aH as ElementThemeColors, aX as ElementView, Z as ElementWhereExpr, aj as EqualOperator, y as ExpandedElementExpr, l as Expr, ah as Expression, aW as ExtendsElementView, F as Fqn, H as HexColorLiteral, I as IconUrl, a3 as InOutExpr, a5 as IncomingExpr, am as KindEqual, aK as LikeC4Theme, b5 as LikeC4View, t as Link, N as NodeId, k as NonEmptyArray, ao as NotOperator, as as OrOperator, a7 as OutgoingExpr, aw as OverviewGraph, ai as ParsedLikeC4Model, n as Point, i as Relation, a1 as RelationExpr, a9 as RelationExpression, R as RelationID, af as RelationPredicateExpression, ab as RelationWhereExpr, ay as RelationshipArrowType, j as RelationshipKind, aC as RelationshipKindSpecification, ax as RelationshipLineType, aI as RelationshipThemeColorValues, aJ as RelationshipThemeColors, aV as ScopedElementView, bb as StepEdgeId, ba as StepEdgeIdLiteral, a as Tag, ak as TagEqual, s as TagSpec, aD as ThemeColor, T as ThemeColorValues, br as ViewChange, V as ViewID, bq as ViewManualLayout, aS as ViewRule, aQ as ViewRuleAutoLayout, aL as ViewRulePredicate, aN as ViewRuleStyle, bf as ViewWithHash, bg as ViewWithNotation, au as WhereOperator, W as WildcardExpr, X as XYPoint, bd as extractStep, bm as getBBoxCenter, be as getParallelStepsPrefix, ar as isAndOperator, bj as isComputedDynamicView, bk as isComputedElementView, J as isCustomElement, ae as isCustomRelationExpr, b6 as isDynamicView, b0 as isDynamicViewIncludeRule, b3 as isDynamicViewParallelSteps, Y as isElement, O as isElementKindExpr, a0 as isElementPredicateExpr, x as isElementRef, S as isElementTagExpr, b7 as isElementView, _ as isElementWhere, z as isExpandedElementExpr, b8 as isExtendsElementView, a4 as isInOut, a6 as isIncoming, an as isKindEqual, ap as isNotOperator, at as isOrOperator, a8 as isOutgoing, a2 as isRelation, aa as isRelationExpression, ag as isRelationPredicateExpr, ac as isRelationWhere, b9 as isScopedElementView, bc as isStepEdgeId, al as isTagEqual, aF as isThemeColor, aR as isViewRuleAutoLayout, aM as isViewRulePredicate, aO as isViewRuleStyle, K as isWildcard, av as whereOperatorAsPredicate } from '../shared/core.CpR2fq5B.cjs';
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { aq as AndOperator, A as AsFqn, aP as AutoLayoutDirection,
|
|
1
|
+
export { aq as AndOperator, A as AsFqn, aP as AutoLayoutDirection, bl as BBox, aU as BasicElementView, aT as BasicView, o as BorderStyle, B as BorderStyles, e as Color, aE as ColorLiteral, bi as ComputedDynamicView, f as ComputedEdge, bh as ComputedElementView, g as ComputedLikeC4Model, b as ComputedNode, C as ComputedView, m as CustomColor, b4 as CustomColorDefinitions, G as CustomElementExpr, ad as CustomRelationExpr, aA as DefaultArrowType, q as DefaultElementShape, az as DefaultLineStyle, aB as DefaultRelationshipColor, D as DefaultThemeColor, bo as DiagramEdge, bn as DiagramNode, bp as DiagramView, b2 as DynamicView, a$ as DynamicViewIncludeRule, aZ as DynamicViewParallelSteps, b1 as DynamicViewRule, aY as DynamicViewStep, a_ as DynamicViewStepOrParallel, E as EdgeId, h as Element, U as ElementExpression, c as ElementKind, M as ElementKindExpr, v as ElementKindSpecification, u as ElementKindSpecificationStyle, bs as ElementNotation, $ as ElementPredicateExpression, w as ElementRefExpr, d as ElementShape, p as ElementShapes, r as ElementStyle, Q as ElementTagExpr, aG as ElementThemeColorValues, aH as ElementThemeColors, aX as ElementView, Z as ElementWhereExpr, aj as EqualOperator, y as ExpandedElementExpr, l as Expr, ah as Expression, aW as ExtendsElementView, F as Fqn, H as HexColorLiteral, I as IconUrl, a3 as InOutExpr, a5 as IncomingExpr, am as KindEqual, aK as LikeC4Theme, b5 as LikeC4View, t as Link, N as NodeId, k as NonEmptyArray, ao as NotOperator, as as OrOperator, a7 as OutgoingExpr, aw as OverviewGraph, ai as ParsedLikeC4Model, n as Point, i as Relation, a1 as RelationExpr, a9 as RelationExpression, R as RelationID, af as RelationPredicateExpression, ab as RelationWhereExpr, ay as RelationshipArrowType, j as RelationshipKind, aC as RelationshipKindSpecification, ax as RelationshipLineType, aI as RelationshipThemeColorValues, aJ as RelationshipThemeColors, aV as ScopedElementView, bb as StepEdgeId, ba as StepEdgeIdLiteral, a as Tag, ak as TagEqual, s as TagSpec, aD as ThemeColor, T as ThemeColorValues, br as ViewChange, V as ViewID, bq as ViewManualLayout, aS as ViewRule, aQ as ViewRuleAutoLayout, aL as ViewRulePredicate, aN as ViewRuleStyle, bf as ViewWithHash, bg as ViewWithNotation, au as WhereOperator, W as WildcardExpr, X as XYPoint, bd as extractStep, bm as getBBoxCenter, be as getParallelStepsPrefix, ar as isAndOperator, bj as isComputedDynamicView, bk as isComputedElementView, J as isCustomElement, ae as isCustomRelationExpr, b6 as isDynamicView, b0 as isDynamicViewIncludeRule, b3 as isDynamicViewParallelSteps, Y as isElement, O as isElementKindExpr, a0 as isElementPredicateExpr, x as isElementRef, S as isElementTagExpr, b7 as isElementView, _ as isElementWhere, z as isExpandedElementExpr, b8 as isExtendsElementView, a4 as isInOut, a6 as isIncoming, an as isKindEqual, ap as isNotOperator, at as isOrOperator, a8 as isOutgoing, a2 as isRelation, aa as isRelationExpression, ag as isRelationPredicateExpr, ac as isRelationWhere, b9 as isScopedElementView, bc as isStepEdgeId, al as isTagEqual, aF as isThemeColor, aR as isViewRuleAutoLayout, aM as isViewRulePredicate, aO as isViewRuleStyle, K as isWildcard, av as whereOperatorAsPredicate } from '../shared/core.CpR2fq5B.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { aq as AndOperator, A as AsFqn, aP as AutoLayoutDirection, bl as BBox, aU as BasicElementView, aT as BasicView, o as BorderStyle, B as BorderStyles, e as Color, aE as ColorLiteral, bi as ComputedDynamicView, f as ComputedEdge, bh as ComputedElementView, g as ComputedLikeC4Model, b as ComputedNode, C as ComputedView, m as CustomColor, b4 as CustomColorDefinitions, G as CustomElementExpr, ad as CustomRelationExpr, aA as DefaultArrowType, q as DefaultElementShape, az as DefaultLineStyle, aB as DefaultRelationshipColor, D as DefaultThemeColor, bo as DiagramEdge, bn as DiagramNode, bp as DiagramView, b2 as DynamicView, a$ as DynamicViewIncludeRule, aZ as DynamicViewParallelSteps, b1 as DynamicViewRule, aY as DynamicViewStep, a_ as DynamicViewStepOrParallel, E as EdgeId, h as Element, U as ElementExpression, c as ElementKind, M as ElementKindExpr, v as ElementKindSpecification, u as ElementKindSpecificationStyle, bs as ElementNotation, $ as ElementPredicateExpression, w as ElementRefExpr, d as ElementShape, p as ElementShapes, r as ElementStyle, Q as ElementTagExpr, aG as ElementThemeColorValues, aH as ElementThemeColors, aX as ElementView, Z as ElementWhereExpr, aj as EqualOperator, y as ExpandedElementExpr, l as Expr, ah as Expression, aW as ExtendsElementView, F as Fqn, H as HexColorLiteral, I as IconUrl, a3 as InOutExpr, a5 as IncomingExpr, am as KindEqual, aK as LikeC4Theme, b5 as LikeC4View, t as Link, N as NodeId, k as NonEmptyArray, ao as NotOperator, as as OrOperator, a7 as OutgoingExpr, aw as OverviewGraph, ai as ParsedLikeC4Model, n as Point, i as Relation, a1 as RelationExpr, a9 as RelationExpression, R as RelationID, af as RelationPredicateExpression, ab as RelationWhereExpr, ay as RelationshipArrowType, j as RelationshipKind, aC as RelationshipKindSpecification, ax as RelationshipLineType, aI as RelationshipThemeColorValues, aJ as RelationshipThemeColors, aV as ScopedElementView, bb as StepEdgeId, ba as StepEdgeIdLiteral, a as Tag, ak as TagEqual, s as TagSpec, aD as ThemeColor, T as ThemeColorValues, br as ViewChange, V as ViewID, bq as ViewManualLayout, aS as ViewRule, aQ as ViewRuleAutoLayout, aL as ViewRulePredicate, aN as ViewRuleStyle, bf as ViewWithHash, bg as ViewWithNotation, au as WhereOperator, W as WildcardExpr, X as XYPoint, bd as extractStep, bm as getBBoxCenter, be as getParallelStepsPrefix, ar as isAndOperator, bj as isComputedDynamicView, bk as isComputedElementView, J as isCustomElement, ae as isCustomRelationExpr, b6 as isDynamicView, b0 as isDynamicViewIncludeRule, b3 as isDynamicViewParallelSteps, Y as isElement, O as isElementKindExpr, a0 as isElementPredicateExpr, x as isElementRef, S as isElementTagExpr, b7 as isElementView, _ as isElementWhere, z as isExpandedElementExpr, b8 as isExtendsElementView, a4 as isInOut, a6 as isIncoming, an as isKindEqual, ap as isNotOperator, at as isOrOperator, a8 as isOutgoing, a2 as isRelation, aa as isRelationExpression, ag as isRelationPredicateExpr, ac as isRelationWhere, b9 as isScopedElementView, bc as isStepEdgeId, al as isTagEqual, aF as isThemeColor, aR as isViewRuleAutoLayout, aM as isViewRulePredicate, aO as isViewRuleStyle, K as isWildcard, av as whereOperatorAsPredicate } from '../shared/core.CpR2fq5B.js';
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AsFqn, B as BorderStyles, J as DefaultArrowType, D as DefaultElementShape, I as DefaultLineStyle, K as DefaultRelationshipColor, a as DefaultThemeColor, E as ElementShapes, c as Expr,
|
|
1
|
+
export { A as AsFqn, B as BorderStyles, J as DefaultArrowType, D as DefaultElementShape, I as DefaultLineStyle, K as DefaultRelationshipColor, a as DefaultThemeColor, E as ElementShapes, c as Expr, V as StepEdgeId, X as extractStep, $ as getBBoxCenter, Y as getParallelStepsPrefix, F as isAndOperator, Z as isComputedDynamicView, _ as isComputedElementView, g as isCustomElement, w as isCustomRelationExpr, R as isDynamicView, P as isDynamicViewIncludeRule, Q as isDynamicViewParallelSteps, l as isElement, j as isElementKindExpr, o as isElementPredicateExpr, d as isElementRef, k as isElementTagExpr, S as isElementView, m as isElementWhere, f as isExpandedElementExpr, T as isExtendsElementView, q as isInOut, r as isIncoming, z as isKindEqual, C as isNotOperator, G as isOrOperator, s as isOutgoing, p as isRelation, t as isRelationExpression, x as isRelationPredicateExpr, v as isRelationWhere, U as isScopedElementView, W as isStepEdgeId, y as isTagEqual, L as isThemeColor, O as isViewRuleAutoLayout, M as isViewRulePredicate, N as isViewRuleStyle, h as isWildcard, H as whereOperatorAsPredicate } from '../shared/core.DeifT5lC.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://likec4.dev",
|
|
6
6
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
@@ -74,10 +74,12 @@
|
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@likec4/tsconfig": "1.
|
|
77
|
+
"@likec4/tsconfig": "1.10.0",
|
|
78
78
|
"@mantine/colors-generator": "^7.12.2",
|
|
79
|
+
"@types/natural-compare-lite": "^1",
|
|
79
80
|
"chroma-js": "^3.0.0",
|
|
80
81
|
"execa": "^9.3.1",
|
|
82
|
+
"natural-compare-lite": "^1.4.0",
|
|
81
83
|
"remeda": "^2.11.0",
|
|
82
84
|
"turbo": "^2.1.1",
|
|
83
85
|
"type-fest": "^4.26.0",
|
package/src/index.ts
CHANGED
package/src/types/element.ts
CHANGED
|
@@ -43,7 +43,10 @@ export interface TagSpec {
|
|
|
43
43
|
|
|
44
44
|
export interface Link {
|
|
45
45
|
readonly title?: string
|
|
46
|
+
// Value from Likec4 DSL
|
|
46
47
|
readonly url: string
|
|
48
|
+
// Relative to workspace root (if url is relative),
|
|
49
|
+
readonly relative?: string
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
export interface Element {
|
package/src/types/expression.ts
CHANGED
|
@@ -161,6 +161,10 @@ export interface CustomRelationExpr extends Omit<BaseExpr, 'customRelation'> {
|
|
|
161
161
|
description?: string
|
|
162
162
|
technology?: string
|
|
163
163
|
notation?: string
|
|
164
|
+
// Link to dynamic view
|
|
165
|
+
navigateTo?: ViewID
|
|
166
|
+
// Notes for walkthrough
|
|
167
|
+
notes?: string
|
|
164
168
|
color?: Color
|
|
165
169
|
line?: RelationshipLineType
|
|
166
170
|
head?: RelationshipArrowType
|
package/src/types/relation.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Tagged } from 'type-fest'
|
|
|
2
2
|
import type { NonEmptyArray } from './_common'
|
|
3
3
|
import type { Fqn, Link, Tag } from './element'
|
|
4
4
|
import type { Color, ThemeColor } from './theme'
|
|
5
|
+
import type { ViewID } from './view'
|
|
5
6
|
|
|
6
7
|
export type RelationID = Tagged<string, 'RelationID'>
|
|
7
8
|
export type RelationshipKind = Tagged<string, 'RelationshipKind'>
|
|
@@ -40,6 +41,8 @@ export interface Relation {
|
|
|
40
41
|
readonly head?: RelationshipArrowType
|
|
41
42
|
readonly tail?: RelationshipArrowType
|
|
42
43
|
readonly links?: NonEmptyArray<Link>
|
|
44
|
+
// Link to dynamic view
|
|
45
|
+
readonly navigateTo?: ViewID
|
|
43
46
|
readonly metadata?: { [key: string]: string }
|
|
44
47
|
}
|
|
45
48
|
|
package/src/types/view.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isNullish } from 'remeda'
|
|
1
|
+
import { isArray, isNullish } from 'remeda'
|
|
2
2
|
import type { Tagged } from 'type-fest'
|
|
3
3
|
import type { IconUrl, NonEmptyArray, Point, XYPoint } from './_common'
|
|
4
4
|
import type { ElementKind, ElementShape, ElementStyle, Fqn, Link, Tag } from './element'
|
|
@@ -100,13 +100,24 @@ export interface DynamicViewStep {
|
|
|
100
100
|
readonly description?: string
|
|
101
101
|
readonly technology?: string
|
|
102
102
|
readonly notation?: string
|
|
103
|
+
// Notes for walkthrough
|
|
104
|
+
readonly notes?: string
|
|
103
105
|
readonly color?: Color
|
|
104
106
|
readonly line?: RelationshipLineType
|
|
105
107
|
readonly head?: RelationshipArrowType
|
|
106
108
|
readonly tail?: RelationshipArrowType
|
|
107
109
|
readonly isBackward?: boolean
|
|
110
|
+
// Link to dynamic view
|
|
111
|
+
readonly navigateTo?: ViewID
|
|
112
|
+
__parallel?: never
|
|
108
113
|
}
|
|
109
114
|
|
|
115
|
+
export interface DynamicViewParallelSteps {
|
|
116
|
+
readonly __parallel: DynamicViewStep[]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type DynamicViewStepOrParallel = DynamicViewStep | DynamicViewParallelSteps
|
|
120
|
+
|
|
110
121
|
export type DynamicViewIncludeRule = {
|
|
111
122
|
include: ElementPredicateExpression[]
|
|
112
123
|
}
|
|
@@ -119,11 +130,15 @@ export type DynamicViewRule = DynamicViewIncludeRule | ViewRuleStyle | ViewRuleA
|
|
|
119
130
|
export interface DynamicView extends BasicView<'dynamic'> {
|
|
120
131
|
readonly __: 'dynamic'
|
|
121
132
|
|
|
122
|
-
readonly steps:
|
|
133
|
+
readonly steps: DynamicViewStepOrParallel[]
|
|
123
134
|
|
|
124
135
|
readonly rules: DynamicViewRule[]
|
|
125
136
|
}
|
|
126
137
|
|
|
138
|
+
export function isDynamicViewParallelSteps(step: DynamicViewStepOrParallel): step is DynamicViewParallelSteps {
|
|
139
|
+
return '__parallel' in step && isArray(step.__parallel)
|
|
140
|
+
}
|
|
141
|
+
|
|
127
142
|
export type CustomColorDefinitions = { [key: string]: ThemeColorValues }
|
|
128
143
|
|
|
129
144
|
export type LikeC4View = ElementView | DynamicView
|
|
@@ -146,20 +161,31 @@ export function isScopedElementView(view: LikeC4View): view is ScopedElementView
|
|
|
146
161
|
export type NodeId = Tagged<string, 'Fqn'>
|
|
147
162
|
|
|
148
163
|
export type EdgeId = Tagged<string, 'EdgeId'>
|
|
149
|
-
export type StepEdgeIdLiteral = `step-${number}`
|
|
164
|
+
export type StepEdgeIdLiteral = `step-${number}` | `step-${number}.${number}`
|
|
150
165
|
export type StepEdgeId = Tagged<StepEdgeIdLiteral, 'EdgeId'>
|
|
151
|
-
export function StepEdgeId(step: number): StepEdgeId {
|
|
152
|
-
|
|
166
|
+
export function StepEdgeId(step: number, parallelStep?: number): StepEdgeId {
|
|
167
|
+
const id = `step-${String(step).padStart(2, '0')}` as StepEdgeId
|
|
168
|
+
return parallelStep ? `${id}.${parallelStep}` as StepEdgeId : id
|
|
153
169
|
}
|
|
154
170
|
|
|
155
171
|
export function isStepEdgeId(id: string): id is StepEdgeId {
|
|
156
172
|
return id.startsWith('step-')
|
|
157
173
|
}
|
|
174
|
+
|
|
158
175
|
export function extractStep(id: EdgeId): number {
|
|
159
176
|
if (!isStepEdgeId(id)) {
|
|
160
177
|
throw new Error(`Invalid step edge id: ${id}`)
|
|
161
178
|
}
|
|
162
|
-
return
|
|
179
|
+
return parseFloat(id.slice('step-'.length))
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Get the prefix of the parallel steps
|
|
183
|
+
// i.e. step-01.1 -> step-01.
|
|
184
|
+
export function getParallelStepsPrefix(id: string): string | null {
|
|
185
|
+
if (isStepEdgeId(id) && id.includes('.')) {
|
|
186
|
+
return id.slice(0, id.indexOf('.') + 1)
|
|
187
|
+
}
|
|
188
|
+
return null
|
|
163
189
|
}
|
|
164
190
|
|
|
165
191
|
export interface ComputedNode {
|
|
@@ -205,11 +231,16 @@ export interface ComputedEdge {
|
|
|
205
231
|
technology?: string
|
|
206
232
|
relations: RelationID[]
|
|
207
233
|
kind?: RelationshipKind
|
|
234
|
+
notation?: string
|
|
235
|
+
// Notes for walkthrough
|
|
236
|
+
notes?: string
|
|
208
237
|
color?: Color
|
|
209
238
|
line?: RelationshipLineType
|
|
210
239
|
head?: RelationshipArrowType
|
|
211
240
|
tail?: RelationshipArrowType
|
|
212
241
|
tags?: NonEmptyArray<Tag>
|
|
242
|
+
// Link to dynamic view
|
|
243
|
+
navigateTo?: ViewID
|
|
213
244
|
/**
|
|
214
245
|
* If this edge is derived from custom relationship predicate
|
|
215
246
|
*/
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { sort as remedaSort } from 'remeda'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { compareNatural } from './compare-natural'
|
|
4
|
+
|
|
5
|
+
describe('compareNatural', () => {
|
|
6
|
+
const sort = (array: Array<string | undefined>) => remedaSort(array, compareNatural)
|
|
7
|
+
|
|
8
|
+
it('should move undefined to the end', () => {
|
|
9
|
+
expect(
|
|
10
|
+
sort([
|
|
11
|
+
undefined,
|
|
12
|
+
'apple',
|
|
13
|
+
undefined,
|
|
14
|
+
'banana'
|
|
15
|
+
])
|
|
16
|
+
).toEqual([
|
|
17
|
+
'apple',
|
|
18
|
+
'banana',
|
|
19
|
+
undefined,
|
|
20
|
+
undefined
|
|
21
|
+
])
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('should sort array of strings', () => {
|
|
25
|
+
expect(sort([
|
|
26
|
+
'apple1',
|
|
27
|
+
'apple11',
|
|
28
|
+
'apple2',
|
|
29
|
+
'apple10'
|
|
30
|
+
])).toEqual([
|
|
31
|
+
'apple1',
|
|
32
|
+
'apple2',
|
|
33
|
+
'apple10',
|
|
34
|
+
'apple11'
|
|
35
|
+
])
|
|
36
|
+
})
|
|
37
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import compare from 'natural-compare-lite'
|
|
2
|
+
import { isString } from 'remeda'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export function compareNatural(a: string | undefined, b: string | undefined): -1 | 0 | 1 {
|
|
6
|
+
if (a === b) return 0
|
|
7
|
+
if (isString(a)) {
|
|
8
|
+
if (isString(b)) {
|
|
9
|
+
return compare(a, b)
|
|
10
|
+
}
|
|
11
|
+
return 1
|
|
12
|
+
}
|
|
13
|
+
return isString(b) ? -1 : 0
|
|
14
|
+
}
|
package/src/utils/fqn.spec.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { prop } from 'remeda'
|
|
1
2
|
import { describe, expect, it } from 'vitest'
|
|
2
3
|
import type { Element, Fqn } from '../types'
|
|
3
4
|
import {
|
|
@@ -7,7 +8,9 @@ import {
|
|
|
7
8
|
isAncestor,
|
|
8
9
|
isDescendantOf,
|
|
9
10
|
notDescendantOf,
|
|
10
|
-
parentFqn
|
|
11
|
+
parentFqn,
|
|
12
|
+
sortByFqnHierarchically,
|
|
13
|
+
sortNaturalByFqn
|
|
11
14
|
} from './fqn'
|
|
12
15
|
|
|
13
16
|
const el = (id: string): Element => ({ id }) as unknown as Element
|
|
@@ -88,7 +91,13 @@ describe('notDescendantOf', () => {
|
|
|
88
91
|
|
|
89
92
|
describe('compareFqnHierarchically', () => {
|
|
90
93
|
it('should compare hierarchically', () => {
|
|
91
|
-
expect([
|
|
94
|
+
expect([
|
|
95
|
+
'a',
|
|
96
|
+
'b',
|
|
97
|
+
'a.b',
|
|
98
|
+
'a.b.c',
|
|
99
|
+
'a.c.c'
|
|
100
|
+
].sort(compareFqnHierarchically)).toEqual([
|
|
92
101
|
'a',
|
|
93
102
|
'b',
|
|
94
103
|
'a.b',
|
|
@@ -103,3 +112,91 @@ describe('compareFqnHierarchically', () => {
|
|
|
103
112
|
).toEqual(['aaa', 'aa', 'a', 'aaa.c', 'aa.b', 'a.c', 'a.b'])
|
|
104
113
|
})
|
|
105
114
|
})
|
|
115
|
+
|
|
116
|
+
describe('sortNaturalByFqn', () => {
|
|
117
|
+
it('should sort hierarchically', () => {
|
|
118
|
+
expect(
|
|
119
|
+
sortNaturalByFqn([
|
|
120
|
+
el('a.b'),
|
|
121
|
+
el('a'),
|
|
122
|
+
el('a.c.a.b'),
|
|
123
|
+
el('a.c.c'),
|
|
124
|
+
el('b'),
|
|
125
|
+
el('a.b.c')
|
|
126
|
+
]).map(prop('id'))
|
|
127
|
+
).toEqual([
|
|
128
|
+
'a',
|
|
129
|
+
'b',
|
|
130
|
+
'a.b',
|
|
131
|
+
'a.b.c',
|
|
132
|
+
'a.c.c',
|
|
133
|
+
'a.c.a.b'
|
|
134
|
+
])
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('should sort natural', () => {
|
|
138
|
+
expect(
|
|
139
|
+
sortNaturalByFqn([
|
|
140
|
+
el('b'),
|
|
141
|
+
el('a.c.c'),
|
|
142
|
+
el('a'),
|
|
143
|
+
el('a.b1'),
|
|
144
|
+
el('a.b2'),
|
|
145
|
+
el('a.b10'),
|
|
146
|
+
el('a.b2.c')
|
|
147
|
+
]).map(prop('id'))
|
|
148
|
+
).toEqual([
|
|
149
|
+
'a',
|
|
150
|
+
'b',
|
|
151
|
+
'a.b1',
|
|
152
|
+
'a.b2',
|
|
153
|
+
'a.b10',
|
|
154
|
+
'a.b2.c',
|
|
155
|
+
'a.c.c'
|
|
156
|
+
])
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
describe('sortByFqnHierarchically', () => {
|
|
161
|
+
it('should sort hierarchically', () => {
|
|
162
|
+
expect(
|
|
163
|
+
sortByFqnHierarchically([
|
|
164
|
+
el('a.b'),
|
|
165
|
+
el('a'),
|
|
166
|
+
el('a.b.c'),
|
|
167
|
+
el('a.c.a.b'),
|
|
168
|
+
el('a.c.c'),
|
|
169
|
+
el('b')
|
|
170
|
+
]).map(prop('id'))
|
|
171
|
+
).toEqual([
|
|
172
|
+
'a',
|
|
173
|
+
'b',
|
|
174
|
+
'a.b',
|
|
175
|
+
'a.b.c',
|
|
176
|
+
'a.c.c',
|
|
177
|
+
'a.c.a.b'
|
|
178
|
+
])
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('should preserve initial order', () => {
|
|
182
|
+
expect(
|
|
183
|
+
sortByFqnHierarchically([
|
|
184
|
+
el('b'),
|
|
185
|
+
el('a.c.c'),
|
|
186
|
+
el('a'),
|
|
187
|
+
el('a.b10'),
|
|
188
|
+
el('a.b2.c'),
|
|
189
|
+
el('a.b1'),
|
|
190
|
+
el('a.b2')
|
|
191
|
+
]).map(prop('id'))
|
|
192
|
+
).toEqual([
|
|
193
|
+
'b',
|
|
194
|
+
'a',
|
|
195
|
+
'a.b10',
|
|
196
|
+
'a.b1',
|
|
197
|
+
'a.b2',
|
|
198
|
+
'a.c.c',
|
|
199
|
+
'a.b2.c'
|
|
200
|
+
])
|
|
201
|
+
})
|
|
202
|
+
})
|
package/src/utils/fqn.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Element, Fqn } from '../types'
|
|
2
|
+
import { compareNatural } from './compare-natural'
|
|
2
3
|
import { isString } from './guards'
|
|
3
4
|
|
|
4
5
|
type Predicate<T> = (x: T) => boolean
|
|
@@ -101,7 +102,7 @@ export function ancestorsFqn(fqn: Fqn): Fqn[] {
|
|
|
101
102
|
* - Positive number if a is deeper than b.
|
|
102
103
|
* - Negative number if b is deeper than a.
|
|
103
104
|
*/
|
|
104
|
-
export function compareFqnHierarchically<T extends string = string>(a: T, b: T):
|
|
105
|
+
export function compareFqnHierarchically<T extends string = string>(a: T, b: T): -1 | 0 | 1 {
|
|
105
106
|
const depthA = a.split('.').length
|
|
106
107
|
const depthB = b.split('.').length
|
|
107
108
|
switch (true) {
|
|
@@ -120,3 +121,39 @@ export function compareFqnHierarchically<T extends string = string>(a: T, b: T):
|
|
|
120
121
|
export function compareByFqnHierarchically<T extends { id: string }>(a: T, b: T) {
|
|
121
122
|
return compareFqnHierarchically(a.id, b.id)
|
|
122
123
|
}
|
|
124
|
+
|
|
125
|
+
type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly []
|
|
126
|
+
type ReorderedArray<T extends IterableContainer> = {
|
|
127
|
+
-readonly [P in keyof T]: T[number]
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function sortByFqnHierarchically<T extends { id: string }, A extends IterableContainer<T>>(
|
|
131
|
+
array: A
|
|
132
|
+
): ReorderedArray<A> {
|
|
133
|
+
return array
|
|
134
|
+
.map(item => ({ item, fqn: item.id.split('.') }))
|
|
135
|
+
.sort((a, b) => {
|
|
136
|
+
return a.fqn.length - b.fqn.length
|
|
137
|
+
})
|
|
138
|
+
.map(({ item }) => item) as ReorderedArray<A>
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function sortNaturalByFqn<T extends { id: string }, A extends IterableContainer<T>>(
|
|
142
|
+
array: A
|
|
143
|
+
): ReorderedArray<A> {
|
|
144
|
+
return array
|
|
145
|
+
.map(item => ({ item, fqn: item.id.split('.') }))
|
|
146
|
+
.sort((a, b) => {
|
|
147
|
+
if (a.fqn.length !== b.fqn.length) {
|
|
148
|
+
return a.fqn.length - b.fqn.length
|
|
149
|
+
}
|
|
150
|
+
for (let i = 0; i < a.fqn.length; i++) {
|
|
151
|
+
const compare = compareNatural(a.fqn[i], b.fqn[i])
|
|
152
|
+
if (compare !== 0) {
|
|
153
|
+
return compare
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return 0
|
|
157
|
+
})
|
|
158
|
+
.map(({ item }) => item) as ReorderedArray<A>
|
|
159
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -170,7 +170,7 @@ describe('compareRelations', () => {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
function sorted(...relations: Array<{ source: string; target: string }>) {
|
|
173
|
-
return relations.
|
|
173
|
+
return relations.toSorted(compareRelations).map(r => r.source + ' -> ' + r.target)
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
it('should sort by source and target', () => {
|
package/src/utils/relations.ts
CHANGED
|
@@ -22,14 +22,14 @@ export const compareRelations = <T extends { source: string; target: string }>(a
|
|
|
22
22
|
return -1
|
|
23
23
|
}
|
|
24
24
|
const compareParents = parentA && parentB ? compareFqnHierarchically(parentA, parentB) : 0
|
|
25
|
-
if (compareParents
|
|
26
|
-
|
|
27
|
-
if (compareSource !== 0) {
|
|
28
|
-
return compareSource
|
|
29
|
-
}
|
|
30
|
-
return compareFqnHierarchically(a.target, b.target)
|
|
25
|
+
if (compareParents !== 0) {
|
|
26
|
+
return compareParents
|
|
31
27
|
}
|
|
32
|
-
|
|
28
|
+
const compareSource = compareFqnHierarchically(a.source, b.source)
|
|
29
|
+
if (compareSource !== 0) {
|
|
30
|
+
return compareSource
|
|
31
|
+
}
|
|
32
|
+
return compareFqnHierarchically(a.target, b.target)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export const isInside = (parent: Fqn): RelationPredicate => {
|