@likec4/core 1.34.2 → 1.36.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/README.md +1 -1
- package/dist/builder/index.d.mts +15 -4
- package/dist/builder/index.mjs +19 -15
- package/dist/compute-view/index.d.mts +3 -3
- package/dist/compute-view/index.mjs +16 -13
- package/dist/compute-view/relationships-view/index.d.mts +3 -3
- package/dist/compute-view/relationships-view/index.mjs +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +14 -9
- package/dist/model/connection/deployment/index.d.mts +5 -5
- package/dist/model/connection/deployment/index.mjs +5 -4
- package/dist/model/connection/index.d.mts +6 -6
- package/dist/model/connection/index.mjs +6 -5
- package/dist/model/connection/model/index.d.mts +5 -5
- package/dist/model/connection/model/index.mjs +3 -3
- package/dist/model/index.d.mts +33 -9
- package/dist/model/index.mjs +12 -10
- package/dist/shared/{core.DAj3LuFH.d.mts → core.BFb3p5d-.d.mts} +4 -2
- package/dist/shared/{core.PqNe5WxQ.mjs → core.BlwZ4tBa.mjs} +98 -92
- package/dist/shared/core.BpJu1RrF.mjs +5 -0
- package/dist/shared/{core.CJSFKrYf.d.mts → core.Bt3kuGUN.d.mts} +3 -3
- package/dist/shared/{core.D5qVzkws.mjs → core.Bus32P0S.mjs} +4 -3
- package/dist/shared/{core.4SpVCM9m.mjs → core.BvIGRozf.mjs} +364 -28
- package/dist/shared/{core.C80Z37Eu.mjs → core.C1GV0WWV.mjs} +1 -1
- package/dist/shared/{core.DXRAwwDB.mjs → core.CaJp8Amg.mjs} +3 -2
- package/dist/shared/{core.D56nCp7e.mjs → core.CaaYNQDM.mjs} +1 -3
- package/dist/shared/core.CnIyafWn.mjs +3 -0
- package/dist/shared/{core.D3xEWj5B.d.mts → core.D8bTI5KC.d.mts} +2 -2
- package/dist/shared/{core.Di7__sMg.d.mts → core.DHYd2-VU.d.mts} +3 -3
- package/dist/shared/{core.C_C-3c1S.mjs → core.DQj9iv_y.mjs} +3 -5
- package/dist/shared/{core.DrS4Bf4y.d.mts → core.DoNP3Yl-.d.mts} +187 -11
- package/dist/shared/{core.IWLie-Ma.d.mts → core.DxDn5nB5.d.mts} +24 -6
- package/dist/shared/{core.CtKXPqN_.mjs → core.HUONfQfd.mjs} +1 -1
- package/dist/shared/{core.BTnf14gD.mjs → core.Y3j3s-oq.mjs} +2 -2
- package/dist/shared/{core.Br7Fab9l.mjs → core._jnYNUQ-.mjs} +8 -70
- package/dist/shared/{core.XptQjhMA.mjs → core.b2BzqGz0.mjs} +2 -2
- package/dist/shared/{core.BMCb0wJI.mjs → core.yaRvRnMW.mjs} +1 -1
- package/dist/theme/index.mjs +34 -3510
- package/dist/types/_aux.d.mts +1 -1
- package/dist/types/index.d.mts +3 -3
- package/dist/types/index.mjs +6 -4
- package/dist/types/scalar.d.mts +2 -0
- package/dist/types/scalar.mjs +68 -0
- package/dist/utils/index.d.mts +6 -8
- package/dist/utils/index.mjs +5 -5
- package/dist/utils/iterable/index.d.mts +18 -1
- package/dist/utils/iterable/index.mjs +22 -2
- package/package.json +11 -16
- package/src/builder/Builder.ts +17 -6
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +9 -0
- package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +3 -0
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +3 -0
- package/src/builder/_types.ts +10 -0
- package/src/compute-view/dynamic-view/compute.ts +2 -0
- package/src/compute-view/element-view/__test__/fixture.ts +1 -0
- package/src/compute-view/element-view/predicates/relation-direct.ts +8 -2
- package/src/compute-view/utils/applyCustomRelationProperties.ts +2 -0
- package/src/model/DeploymentModel.ts +1 -1
- package/src/model/LikeC4Model.ts +162 -13
- package/src/model/index.ts +8 -0
- package/src/model/types.ts +1 -8
- package/src/model/utils.ts +66 -0
- package/src/model/view/LikeC4ViewModel.ts +62 -7
- package/src/model/view/LikeC4ViewsFolder.ts +151 -0
- package/src/theme/__test__/theme-index.ts +29 -0
- package/src/theme/element.ts +0 -19
- package/src/theme/index.ts +49 -3
- package/src/types/_aux.ts +6 -0
- package/src/types/index.ts +1 -0
- package/src/types/model-data.ts +2 -0
- package/src/types/model-dump.ts +8 -1
- package/src/types/model-spec.ts +4 -0
- package/src/types/project.ts +9 -0
- package/src/types/view-computed.ts +1 -1
- package/src/types/view-parsed.dynamic.ts +2 -2
- package/src/utils/compare-natural.ts +14 -12
- package/src/utils/index.ts +1 -0
- package/src/utils/iterable/first.ts +48 -0
- package/src/utils/iterable/index.ts +1 -0
package/dist/types/_aux.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'type-fest';
|
|
2
2
|
import '../shared/core.DuSLYTG6.mjs';
|
|
3
|
-
export {
|
|
3
|
+
export { y as AllKinds, A as Any, A as AnyAux, G as AnySpec, a as Aux, p as DeploymentFqn, s as DeploymentId, D as DeploymentKind, C as EdgeId, g as ElementId, k as ElementKind, F as Fqn, o as LooseDeploymentId, a4 as LooseDeploymentKind, n as LooseElementId, a3 as LooseElementKind, a5 as LooseRelationKind, L as LooseTag, a2 as LooseTags, w as LooseViewId, h as Metadata, j as MetadataKey, N as Never, J as NodeId, a1 as OrString, H as PickByStage, P as ProjectId, l as RelationId, R as RelationKind, K as Spec, S as SpecAux, r as Stage, p as StrictDeploymentFqn, Y as StrictDeploymentKind, X as StrictElementKind, F as StrictFqn, O as StrictProjectId, Z as StrictRelationKind, Q as StrictTag, m as StrictViewId, u as Tag, T as Tags, U as Unknown, b as UnknownComputed, c as UnknownLayouted, d as UnknownParsed, V as ViewId, a0 as WithLinks, B as WithMetadata, z as WithOptionalLinks, W as WithOptionalTags, $ as WithTags, x as setProject, I as setStage, t as toComputed, q as toLayouted, v as toParsed } from '../shared/core.BFb3p5d-.mjs';
|
|
4
4
|
import '../shared/core.668kXpZq.mjs';
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { N as NonEmptyArray } from '../shared/core.DuSLYTG6.mjs';
|
|
2
2
|
export { C as Coalesce, E as ExclusiveUnion, I as IteratorLike, K as KeysOf, L as Link, b as NTuple, a as NonEmptyReadonlyArray, P as Predicate } from '../shared/core.DuSLYTG6.mjs';
|
|
3
|
-
export { A as Any, A as AnyAux, a as Aux, E as ExtractOnStage, M as ModelStage, S as SpecAux, U as Unknown, b as UnknownComputed, c as UnknownLayouted, d as UnknownParsed, e as _stage, f as _type, _ as aux, i as isOnStage } from '../shared/core.
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
3
|
+
export { A as Any, A as AnyAux, a as Aux, E as ExtractOnStage, M as ModelStage, S as SpecAux, U as Unknown, b as UnknownComputed, c as UnknownLayouted, d as UnknownParsed, e as _stage, f as _type, _ as aux, i as isOnStage } from '../shared/core.BFb3p5d-.mjs';
|
|
4
|
+
import { aR as ViewManualLayout, aM as AutoLayoutDirection } from '../shared/core.DxDn5nB5.mjs';
|
|
5
|
+
export { Y as AbstractRelationship, ae as AndOperator, aG as AnyExcludePredicate, aF as AnyIncludePredicate, as as AnyView, aH as AnyViewRuleStyle, H as AuxFromDump, A as AuxFromLikeC4ModelData, B as BBox, aU as BaseParsedViewProperties, aT as BaseViewProperties, a$ as ComputedDeploymentView, b0 as ComputedDynamicView, aZ as ComputedEdge, a_ as ComputedElementView, C as ComputedLikeC4ModelData, aY as ComputedNode, aq as ComputedView, V as DefaultArrowType, J as DefaultElementShape, U as DefaultLineStyle, N as DefaultPaddingSize, W as DefaultRelationshipColor, K as DefaultShapeSize, O as DefaultTextSize, I as DefaultThemeColor, q as DeployedInstance, r as DeploymentElement, s as DeploymentElementRef, D as DeploymentElementStyle, p as DeploymentNode, w as DeploymentRelation, v as DeploymentRelationship, b7 as DeploymentViewExcludePredicate, b6 as DeploymentViewIncludePredicate, b8 as DeploymentViewPredicate, ba as DeploymentViewRule, b9 as DeploymentViewRuleStyle, b2 as DiagramEdge, b1 as DiagramNode, ao as DiagramView, bg as DynamicViewIncludeRule, bd as DynamicViewParallelSteps, bh as DynamicViewRule, bc as DynamicViewStep, bf as DynamicViewStepOrParallel, T as Element, $ as ElementSpecification, Q as ElementStyle, bl as ElementViewExcludePredicate, bk as ElementViewIncludePredicate, bm as ElementViewPredicate, bq as ElementViewRule, bn as ElementViewRuleGroup, bp as ElementViewRuleStyle, a4 as EqualOperator, E as Expression, aj as Filterable, F as FqnExpr, f as FqnRef, j as GlobalDynamicPredicates, G as GlobalPredicateId, i as GlobalPredicates, k as GlobalStyleID, l as GlobalStyles, a7 as KindEqual, b4 as LayoutedDeploymentView, b5 as LayoutedDynamicView, b3 as LayoutedElementView, L as LayoutedLikeC4ModelData, ao as LayoutedView, o as LikeC4ModelData, y as LikeC4ModelDump, am as LikeC4Project, an as LikeC4View, e as ModelExpression, M as ModelFqnExpr, m as ModelGlobals, _ as ModelRelation, d as ModelRelationExpr, aV as NodeNotation, ac as NotOperator, ak as OperatorPredicate, ag as OrOperator, bb as ParsedDeploymentView, bi as ParsedDynamicView, br as ParsedElementView, n as ParsedLikeC4ModelData, an as ParsedView, a9 as Participant, aa as ParticipantOperator, g as Point, P as PredicateSelector, ar as ProcessedView, z as ProjectDump, h as RectBox, c as RelationExpr, Z as Relationship, a2 as RelationshipSpecification, R as RichText, a as RichTextEmpty, b as RichTextOrEmpty, x as SpecTypesFromDump, a3 as Specification, S as SpecificationDump, a5 as TagEqual, a0 as TagSpecification, aQ as ViewAutoLayout, at as ViewOnStage, av as ViewRule, aO as ViewRuleAutoLayout, aK as ViewRuleGlobalPredicateRef, aI as ViewRuleGlobalStyle, aw as ViewRulePredicate, aS as ViewType, aX as ViewWithHash, aW as ViewWithNotation, au as ViewWithType, ai as WhereOperator, X as XYPoint, be as getParallelStepsPrefix, af as isAndOperator, aN as isAutoLayoutDirection, az as isComputedView, u as isDeployedInstance, t as isDeploymentNode, aD as isDeploymentView, ap as isDiagramView, aE as isDynamicView, bj as isDynamicViewParallelSteps, aA as isElementView, aC as isExtendsElementView, a8 as isKindEqual, ap as isLayoutedView, ad as isNotOperator, ah as isOrOperator, ab as isParticipantOperator, aB as isScopedElementView, a1 as isTagColorSpecified, a6 as isTagEqual, aP as isViewRuleAutoLayout, aL as isViewRuleGlobalPredicateRef, aJ as isViewRuleGlobalStyle, bo as isViewRuleGroup, ax as isViewRulePredicate, ay as isViewRuleStyle, al as whereOperatorAsPredicate } from '../shared/core.DxDn5nB5.mjs';
|
|
6
6
|
import { F as Fqn, D as DeploymentFqn } from '../shared/core.668kXpZq.mjs';
|
|
7
7
|
export { A as AnyFqn, B as BuiltInIcon, b as DeploymentKind, j as EdgeId, E as ElementKind, e as GlobalFqn, G as GroupElementKind, I as Icon, a as IconUrl, M as MarkdownOrString, N as NodeId, P as ProjectId, d as RelationId, R as RelationKind, c as RelationshipKind, k as StepEdgeId, S as StepEdgeIdLiteral, m as StepEdgeKind, T as Tag, V as ViewId, o as extractStep, f as flattenMarkdownOrString, g as isGlobalFqn, i as isGroupElementKind, n as isStepEdgeId, s as scalar, h as splitGlobalFqn, l as stepEdgeId } from '../shared/core.668kXpZq.mjs';
|
|
8
8
|
import { b as BorderStyle, c as ElementShape, h as ThemeColor } from '../shared/core.CzdwsPmY.mjs';
|
package/dist/types/index.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { E as Expression, F as FqnExpr, b as ModelExpression, M as ModelFqnExpr, a as ModelRelationExpr, R as RelationExpr, p as getParallelStepsPrefix, n as isAutoLayoutDirection, d as isComputedView, j as isDeploymentView, e as isDiagramView, k as isDynamicView, q as isDynamicViewParallelSteps, f as isElementView, h as isExtendsElementView, e as isLayoutedView, g as isScopedElementView, o as isViewRuleAutoLayout, m as isViewRuleGlobalPredicateRef, l as isViewRuleGlobalStyle, r as isViewRuleGroup, i as isViewRulePredicate, c as isViewRuleStyle } from '../shared/core.
|
|
1
|
+
export { F as FqnRef, _ as _stage, a as _type, h as isAndOperator, c as isDeployedInstance, b as isDeploymentNode, e as isKindEqual, g as isNotOperator, i as isOnStage, j as isOrOperator, f as isParticipantOperator, d as isTagEqual, w as whereOperatorAsPredicate } from '../shared/core._jnYNUQ-.mjs';
|
|
2
|
+
export { E as Expression, F as FqnExpr, b as ModelExpression, M as ModelFqnExpr, a as ModelRelationExpr, R as RelationExpr, p as getParallelStepsPrefix, n as isAutoLayoutDirection, d as isComputedView, j as isDeploymentView, e as isDiagramView, k as isDynamicView, q as isDynamicViewParallelSteps, f as isElementView, h as isExtendsElementView, e as isLayoutedView, g as isScopedElementView, o as isViewRuleAutoLayout, m as isViewRuleGlobalPredicateRef, l as isViewRuleGlobalStyle, r as isViewRuleGroup, i as isViewRulePredicate, c as isViewRuleStyle } from '../shared/core.CaJp8Amg.mjs';
|
|
3
3
|
export { B as BBox, a as BorderStyles, E as ElementShapes, R as RectBox, T as ThemeColors, i as isTagColorSpecified, b as isThemeColor } from '../shared/core.CxGKeL-L.mjs';
|
|
4
|
-
export { f as DefaultArrowType, a as DefaultElementShape, e as DefaultLineStyle, c as DefaultPaddingSize, g as DefaultRelationshipColor, b as DefaultShapeSize, d as DefaultTextSize, D as DefaultThemeColor, R as RichText } from '../shared/core.
|
|
4
|
+
export { f as DefaultArrowType, a as DefaultElementShape, e as DefaultLineStyle, c as DefaultPaddingSize, g as DefaultRelationshipColor, b as DefaultShapeSize, d as DefaultTextSize, D as DefaultThemeColor, R as RichText } from '../shared/core.CaaYNQDM.mjs';
|
|
5
|
+
export { DeploymentFqn, EdgeId, Fqn, GlobalFqn, GroupElementKind, NodeId, RelationId, StepEdgeKind, ViewId, extractStep, flattenMarkdownOrString, isGlobalFqn, isGroupElementKind, isStepEdgeId, splitGlobalFqn, stepEdgeId } from './scalar.mjs';
|
|
5
6
|
import '../shared/core.zLlww-07.mjs';
|
|
6
|
-
import '../shared/core.
|
|
7
|
+
import '../shared/core.CnIyafWn.mjs';
|
|
7
8
|
import '../shared/core.BgvIuGGU.mjs';
|
|
8
9
|
import '../shared/core.DbRvwARP.mjs';
|
|
10
|
+
import '../shared/core.D4npX2q8.mjs';
|
|
9
11
|
import '../shared/core.B0oEIXqd.mjs';
|
|
10
12
|
import 'rehype-raw';
|
|
11
13
|
import 'rehype-sanitize';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import 'type-fest';
|
|
2
|
+
export { A as AnyFqn, B as BuiltInIcon, D as DeploymentFqn, b as DeploymentKind, j as EdgeId, E as ElementKind, F as Fqn, e as GlobalFqn, G as GroupElementKind, I as Icon, a as IconUrl, M as MarkdownOrString, N as NodeId, P as ProjectId, d as RelationId, R as RelationKind, c as RelationshipKind, k as StepEdgeId, S as StepEdgeIdLiteral, m as StepEdgeKind, T as Tag, V as ViewId, o as extractStep, f as flattenMarkdownOrString, g as isGlobalFqn, i as isGroupElementKind, n as isStepEdgeId, h as splitGlobalFqn, l as stepEdgeId } from '../shared/core.668kXpZq.mjs';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { n } from '../shared/core.CnIyafWn.mjs';
|
|
2
|
+
import { t } from '../shared/core.zLlww-07.mjs';
|
|
3
|
+
import { i as invariant } from '../shared/core.D4npX2q8.mjs';
|
|
4
|
+
|
|
5
|
+
function flattenMarkdownOrString(value) {
|
|
6
|
+
if (value === null || value === void 0) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const content = t(value) ? value : value.txt ?? value.md;
|
|
10
|
+
return n(content?.trim()) ? content : null;
|
|
11
|
+
}
|
|
12
|
+
function Fqn(name, parent) {
|
|
13
|
+
return parent ? parent + "." + name : name;
|
|
14
|
+
}
|
|
15
|
+
const GroupElementKind = "@group";
|
|
16
|
+
function isGroupElementKind(v) {
|
|
17
|
+
return v.kind === GroupElementKind;
|
|
18
|
+
}
|
|
19
|
+
function DeploymentFqn(name, parent) {
|
|
20
|
+
return parent ? parent + "." + name : name;
|
|
21
|
+
}
|
|
22
|
+
function ViewId(id) {
|
|
23
|
+
return id;
|
|
24
|
+
}
|
|
25
|
+
function RelationId(id) {
|
|
26
|
+
return id;
|
|
27
|
+
}
|
|
28
|
+
function GlobalFqn(projectId, name) {
|
|
29
|
+
invariant(n(projectId), "Project ID must start with @");
|
|
30
|
+
return "@" + projectId + "." + name;
|
|
31
|
+
}
|
|
32
|
+
function isGlobalFqn(fqn) {
|
|
33
|
+
return fqn.startsWith("@");
|
|
34
|
+
}
|
|
35
|
+
function splitGlobalFqn(fqn) {
|
|
36
|
+
if (!fqn.startsWith("@")) {
|
|
37
|
+
return [null, fqn];
|
|
38
|
+
}
|
|
39
|
+
const firstDot = fqn.indexOf(".");
|
|
40
|
+
if (firstDot < 2) {
|
|
41
|
+
throw new Error("Invalid global FQN");
|
|
42
|
+
}
|
|
43
|
+
const projectId = fqn.slice(1, firstDot);
|
|
44
|
+
const name = fqn.slice(firstDot + 1);
|
|
45
|
+
return [projectId, name];
|
|
46
|
+
}
|
|
47
|
+
function NodeId(id) {
|
|
48
|
+
return id;
|
|
49
|
+
}
|
|
50
|
+
function EdgeId(id) {
|
|
51
|
+
return id;
|
|
52
|
+
}
|
|
53
|
+
function stepEdgeId(step, parallelStep) {
|
|
54
|
+
const id = `step-${String(step).padStart(2, "0")}`;
|
|
55
|
+
return parallelStep ? `${id}.${parallelStep}` : id;
|
|
56
|
+
}
|
|
57
|
+
const StepEdgeKind = "@step";
|
|
58
|
+
function isStepEdgeId(id) {
|
|
59
|
+
return id.startsWith("step-");
|
|
60
|
+
}
|
|
61
|
+
function extractStep(id) {
|
|
62
|
+
if (!isStepEdgeId(id)) {
|
|
63
|
+
throw new Error(`Invalid step edge id: ${id}`);
|
|
64
|
+
}
|
|
65
|
+
return parseFloat(id.slice("step-".length));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { DeploymentFqn, EdgeId, Fqn, GlobalFqn, GroupElementKind, NodeId, RelationId, StepEdgeKind, ViewId, extractStep, flattenMarkdownOrString, isGlobalFqn, isGroupElementKind, isStepEdgeId, splitGlobalFqn, stepEdgeId };
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ export { D as DefaultMap } from '../shared/core.CywrQs86.mjs';
|
|
|
2
2
|
export { I as IterableContainer, R as ReorderedArray, a as ancestorsFqn, c as commonAncestor, b as compareByFqnHierarchically, d as compareFqnHierarchically, h as hierarchyDistance, e as hierarchyLevel, i as isAncestor, f as isDescendantOf, g as isSameHierarchy, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, j as sortNaturalByFqn, k as sortParentsFirst } from '../shared/core.CF82MWyh.mjs';
|
|
3
3
|
import { N as NonEmptyArray } from '../shared/core.DuSLYTG6.mjs';
|
|
4
4
|
import { Tagged, Simplify, Or, IfNever, IsLiteral, And, GreaterThan, IsNever, IsEqual, ReadonlyTuple, IsNumericLiteral } from 'type-fest';
|
|
5
|
-
export { ifilter, ifind, iflat, ihead, imap, ireduce, isIterable, isome, iunique, toArray, toSet } from './iterable/index.mjs';
|
|
5
|
+
export { ifilter, ifind, ifirst, iflat, ihead, imap, ireduce, isIterable, isome, iunique, toArray, toSet } from './iterable/index.mjs';
|
|
6
6
|
import '../shared/core.668kXpZq.mjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -231,22 +231,20 @@ declare function commonHead<T>(sources: ReadonlyArray<T>, targets: ReadonlyArray
|
|
|
231
231
|
|
|
232
232
|
declare function compareNatural(a: string | undefined, b: string | undefined): -1 | 0 | 1;
|
|
233
233
|
/**
|
|
234
|
-
* Compares two strings hierarchically based on their depth
|
|
234
|
+
* Compares two strings lexicographically first, then hierarchically based on their depth.\
|
|
235
235
|
* From parent nodes to leaves
|
|
236
236
|
*
|
|
237
237
|
* @example
|
|
238
238
|
* const lines = [
|
|
239
|
+
* 'b.c',
|
|
240
|
+
* 'b',
|
|
239
241
|
* 'a.b.c',
|
|
240
|
-
* 'a',
|
|
241
|
-
* 'a.b',
|
|
242
|
-
* 'a.c.c',
|
|
243
242
|
* ]
|
|
244
243
|
* lines.sort(compareNaturalHierarchically('.'))
|
|
245
244
|
* // [
|
|
246
|
-
* // 'a',
|
|
247
|
-
* // 'a.b',
|
|
248
245
|
* // 'a.b.c',
|
|
249
|
-
* // '
|
|
246
|
+
* // 'b',
|
|
247
|
+
* // 'b.c',
|
|
250
248
|
* // ]
|
|
251
249
|
*/
|
|
252
250
|
declare function compareNaturalHierarchically(separator?: string): (a: string | undefined, b: string | undefined) => number;
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export { i as invariant, a as nonNullable, n as nonexhaustive } from '../shared/core.D4npX2q8.mjs';
|
|
2
|
-
export { S as Stack, c as commonHead, o as objectHash } from '../shared/core.
|
|
3
|
-
export { b as ancestorsFqn, d as commonAncestor, e as compareByFqnHierarchically, f as compareFqnHierarchically, c as compareNatural, a as compareNaturalHierarchically, h as hierarchyDistance, g as hierarchyLevel, i as isAncestor, j as isDescendantOf, o as isNonEmptyArray, k as isSameHierarchy, q as isString, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, l as sortNaturalByFqn, m as sortParentsFirst } from '../shared/core.
|
|
2
|
+
export { S as Stack, c as commonHead, o as objectHash } from '../shared/core.HUONfQfd.mjs';
|
|
3
|
+
export { b as ancestorsFqn, d as commonAncestor, e as compareByFqnHierarchically, f as compareFqnHierarchically, c as compareNatural, a as compareNaturalHierarchically, h as hierarchyDistance, g as hierarchyLevel, i as isAncestor, j as isDescendantOf, o as isNonEmptyArray, k as isSameHierarchy, q as isString, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, l as sortNaturalByFqn, m as sortParentsFirst } from '../shared/core.DQj9iv_y.mjs';
|
|
4
4
|
export { g as getOrCreate } from '../shared/core.DcS-0zys.mjs';
|
|
5
5
|
export { a as markdownToHtml, b as markdownToText, m as memoizeProp } from '../shared/core.B0oEIXqd.mjs';
|
|
6
|
-
export { b as BiMap, d as DefaultWeakMap, l as LinkedList, m as MultiMap, q as Queue, c as compareRelations, a as delay, p as promiseNextTick } from '../shared/core.
|
|
6
|
+
export { b as BiMap, d as DefaultWeakMap, l as LinkedList, m as MultiMap, q as Queue, c as compareRelations, a as delay, p as promiseNextTick } from '../shared/core.b2BzqGz0.mjs';
|
|
7
7
|
export { d as difference, e as equalsSet, i as hasAtLeast, a as intersection, b as stringHash, s as symmetricDifference, u as union } from '../shared/core.CpwrZi3D.mjs';
|
|
8
|
-
export { D as DefaultMap } from '../shared/core.
|
|
8
|
+
export { D as DefaultMap } from '../shared/core.yaRvRnMW.mjs';
|
|
9
9
|
export { i as ifilter } from '../shared/core.BH9nN-_I.mjs';
|
|
10
10
|
export { i as ifind, a as ihead } from '../shared/core.DsMrjY2q.mjs';
|
|
11
|
+
export { ifirst, ireduce } from './iterable/index.mjs';
|
|
11
12
|
export { i as iflat, a as isIterable, b as iunique } from '../shared/core.8KM0D6va.mjs';
|
|
12
13
|
export { i as imap, t as toArray, a as toSet } from '../shared/core.Btl47GOn.mjs';
|
|
13
|
-
export { ireduce } from './iterable/index.mjs';
|
|
14
14
|
export { i as isome } from '../shared/core.BoyJPEen.mjs';
|
|
15
15
|
import '../shared/core.DbRvwARP.mjs';
|
|
16
16
|
import '../shared/core.ByrmCl9I.mjs';
|
|
@@ -39,6 +39,23 @@ declare function ifind<T>(predicate: (item: T) => boolean): (iterable: Iterable<
|
|
|
39
39
|
declare function ifind<T, S extends T>(iterable: Iterable<T>, predicate: (item: T) => item is S): S | undefined;
|
|
40
40
|
declare function ifind<T>(iterable: Iterable<T>, predicate: (item: T) => boolean): T | undefined;
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Takes the first N elements from an iterable.
|
|
44
|
+
* Composable first version of `ifirst`.
|
|
45
|
+
* @signature
|
|
46
|
+
* ifirst(count)(data)
|
|
47
|
+
*/
|
|
48
|
+
declare function ifirst<T>(count: number): (iterable: Iterable<T>) => IteratorLike<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Takes the first N elements from an iterable.
|
|
51
|
+
* Data first version of `ifirst`.
|
|
52
|
+
* @signature
|
|
53
|
+
* ifirst(data, count)
|
|
54
|
+
* @example
|
|
55
|
+
* ifirst([1, 2, 3, 4, 5], 3) // => Iterable<[1, 2, 3]>
|
|
56
|
+
*/
|
|
57
|
+
declare function ifirst<T>(iterable: Iterable<T>, count: number): IteratorLike<T>;
|
|
58
|
+
|
|
42
59
|
declare function iflat(): <T>(iterable: Iterable<IteratorLike<T>>) => IteratorLike<T>;
|
|
43
60
|
declare function iflat<T>(iterable: Iterable<IteratorLike<T>>): IteratorLike<T>;
|
|
44
61
|
|
|
@@ -97,4 +114,4 @@ declare function toSet<T>(iterable: Iterable<T>): Set<T>;
|
|
|
97
114
|
declare function iunique(): <T>(iterable: Iterable<T>) => IteratorLike<T>;
|
|
98
115
|
declare function iunique<T>(iterable: Iterable<T>): IteratorLike<T>;
|
|
99
116
|
|
|
100
|
-
export { ifilter, ifind, iflat, ihead, imap, ireduce, isIterable, isome, iunique, toArray, toSet };
|
|
117
|
+
export { ifilter, ifind, ifirst, iflat, ihead, imap, ireduce, isIterable, isome, iunique, toArray, toSet };
|
|
@@ -3,10 +3,30 @@ export { i as iflat, a as isIterable, b as iunique } from '../../shared/core.8KM
|
|
|
3
3
|
import { t } from '../../shared/core.BH9nN-_I.mjs';
|
|
4
4
|
export { i as ifilter } from '../../shared/core.BH9nN-_I.mjs';
|
|
5
5
|
export { i as ifind, a as ihead } from '../../shared/core.DsMrjY2q.mjs';
|
|
6
|
-
export { i as imap, t as toArray, a as toSet } from '../../shared/core.Btl47GOn.mjs';
|
|
7
6
|
import { i as invariant } from '../../shared/core.D4npX2q8.mjs';
|
|
7
|
+
export { i as imap, t as toArray, a as toSet } from '../../shared/core.Btl47GOn.mjs';
|
|
8
8
|
export { i as isome } from '../../shared/core.BoyJPEen.mjs';
|
|
9
9
|
|
|
10
|
+
function ifirst(arg1, arg2) {
|
|
11
|
+
const count = arg2 ?? arg1;
|
|
12
|
+
invariant(typeof count === "number" && count >= 0, "Count must be a non-negative number");
|
|
13
|
+
function* _first(iter) {
|
|
14
|
+
let taken = 0;
|
|
15
|
+
for (const value of iter) {
|
|
16
|
+
if (taken >= count) {
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
yield value;
|
|
20
|
+
taken++;
|
|
21
|
+
}
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (arg2 === void 0) {
|
|
25
|
+
return (iterable) => _first(iterable);
|
|
26
|
+
}
|
|
27
|
+
return _first(arg1);
|
|
28
|
+
}
|
|
29
|
+
|
|
10
30
|
function ireduce(arg1, arg2, arg3) {
|
|
11
31
|
const reducer = n(arg3) ? arg2 : arg1;
|
|
12
32
|
const initialValue = arg3 ?? arg2;
|
|
@@ -21,4 +41,4 @@ function ireduce(arg1, arg2, arg3) {
|
|
|
21
41
|
return n(arg3) ? _reduce(arg1) : _reduce;
|
|
22
42
|
}
|
|
23
43
|
|
|
24
|
-
export { ireduce };
|
|
44
|
+
export { ifirst, ireduce };
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://likec4.dev",
|
|
6
6
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
7
|
+
"description": "A core package for LikeC4, containing types, api, utilities and guards.",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
10
|
"url": "git+https://github.com/likec4/likec4.git",
|
|
@@ -69,14 +70,6 @@
|
|
|
69
70
|
"default": "./dist/utils/index.mjs"
|
|
70
71
|
}
|
|
71
72
|
},
|
|
72
|
-
"./types/_aux": {
|
|
73
|
-
"sources": "./src/types/_aux.ts",
|
|
74
|
-
"default": {
|
|
75
|
-
"types": "./dist/types/_aux.d.mts",
|
|
76
|
-
"import": "./dist/types/_aux.mjs",
|
|
77
|
-
"default": "./dist/types/_aux.mjs"
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
73
|
"./types": {
|
|
81
74
|
"sources": "./src/types/index.ts",
|
|
82
75
|
"default": {
|
|
@@ -86,6 +79,7 @@
|
|
|
86
79
|
}
|
|
87
80
|
},
|
|
88
81
|
"./src": "./src/index.ts",
|
|
82
|
+
"./src/*": "./src/*",
|
|
89
83
|
"./package.json": "./package.json"
|
|
90
84
|
},
|
|
91
85
|
"publishConfig": {
|
|
@@ -103,19 +97,20 @@
|
|
|
103
97
|
"remark-parse": "11.0.0",
|
|
104
98
|
"remark-rehype": "11.1.2",
|
|
105
99
|
"type-fest": "^4.41.0",
|
|
106
|
-
"unified": "11.0.5"
|
|
100
|
+
"unified": "11.0.5",
|
|
101
|
+
"chroma-js": "^3.1.2",
|
|
102
|
+
"@mantine/colors-generator": "8.2.2"
|
|
107
103
|
},
|
|
108
104
|
"devDependencies": {
|
|
105
|
+
"@types/chroma-js": "^3.1.1",
|
|
109
106
|
"@dagrejs/dagre": "1.1.5",
|
|
110
|
-
"@mantine/colors-generator": "8.1.2",
|
|
111
107
|
"@types/extend": "3.0.4",
|
|
112
108
|
"@types/hast": "3.0.4",
|
|
113
109
|
"@types/mdast": "4.0.4",
|
|
114
110
|
"@types/natural-compare-lite": "^1.4.2",
|
|
115
111
|
"@types/object-hash": "^3.0.6",
|
|
116
112
|
"@types/unist": "3.0.3",
|
|
117
|
-
"@types/node": "~20.19.
|
|
118
|
-
"chroma-js": "^3.1.2",
|
|
113
|
+
"@types/node": "~20.19.2",
|
|
119
114
|
"defu": "^6.1.4",
|
|
120
115
|
"fdir": "6.4.6",
|
|
121
116
|
"graphology": "^0.25.4",
|
|
@@ -126,11 +121,11 @@
|
|
|
126
121
|
"object-hash": "^3.0.0",
|
|
127
122
|
"obliterator": "^2.0.5",
|
|
128
123
|
"remeda": "^2.23.1",
|
|
129
|
-
"turbo": "2.5.
|
|
130
|
-
"typescript": "5.
|
|
124
|
+
"turbo": "2.5.5",
|
|
125
|
+
"typescript": "5.9.2",
|
|
131
126
|
"unbuild": "3.5.0",
|
|
132
127
|
"vitest": "3.2.4",
|
|
133
|
-
"@likec4/tsconfig": "1.
|
|
128
|
+
"@likec4/tsconfig": "1.36.0"
|
|
134
129
|
},
|
|
135
130
|
"scripts": {
|
|
136
131
|
"typecheck": "tsc -b --verbose",
|
package/src/builder/Builder.ts
CHANGED
|
@@ -16,8 +16,10 @@ import { computeLikeC4Model } from '../compute-view/compute-view'
|
|
|
16
16
|
import { LikeC4Model } from '../model/LikeC4Model'
|
|
17
17
|
import type {
|
|
18
18
|
Any,
|
|
19
|
+
aux,
|
|
19
20
|
DeployedInstance,
|
|
20
21
|
DeploymentFqn,
|
|
22
|
+
LikeC4Project,
|
|
21
23
|
ParsedElementView,
|
|
22
24
|
ParsedLikeC4ModelData,
|
|
23
25
|
Specification,
|
|
@@ -47,7 +49,7 @@ import {
|
|
|
47
49
|
} from '../types'
|
|
48
50
|
import { invariant } from '../utils'
|
|
49
51
|
import { isSameHierarchy, nameFromFqn, parentFqn } from '../utils/fqn'
|
|
50
|
-
import type { AnyTypes, BuilderSpecification, Types } from './_types'
|
|
52
|
+
import type { AnyTypes, BuilderProjectSpecification, BuilderSpecification, Types } from './_types'
|
|
51
53
|
import type { AddDeploymentNode } from './Builder.deployment'
|
|
52
54
|
import type {
|
|
53
55
|
AddDeploymentNodeHelpers,
|
|
@@ -177,11 +179,19 @@ export interface Builder<T extends AnyTypes> extends BuilderMethods<T> {
|
|
|
177
179
|
* Views are not computed or layouted
|
|
178
180
|
* {@link toLikeC4Model} should be used to get model with computed views
|
|
179
181
|
*/
|
|
182
|
+
build<const Project extends BuilderProjectSpecification>(
|
|
183
|
+
project: Project,
|
|
184
|
+
): ParsedLikeC4ModelData<aux.setProject<Types.ToAux<T>, Project['id']>>
|
|
185
|
+
|
|
180
186
|
build(): ParsedLikeC4ModelData<Types.ToAux<T>>
|
|
181
187
|
|
|
182
188
|
/**
|
|
183
189
|
* Returns Computed LikeC4Model
|
|
184
190
|
*/
|
|
191
|
+
toLikeC4Model<const Project extends BuilderProjectSpecification>(
|
|
192
|
+
project: Project,
|
|
193
|
+
): LikeC4Model.Computed<aux.setProject<Types.ToAux<T>, Project['id']>>
|
|
194
|
+
|
|
185
195
|
toLikeC4Model(): LikeC4Model.Computed<Types.ToAux<T>>
|
|
186
196
|
}
|
|
187
197
|
|
|
@@ -395,9 +405,10 @@ function builder<Spec extends BuilderSpecification, T extends AnyTypes>(
|
|
|
395
405
|
})
|
|
396
406
|
return self
|
|
397
407
|
},
|
|
398
|
-
build: () => ({
|
|
408
|
+
build: (project?: LikeC4Project) => ({
|
|
399
409
|
[_stage]: 'parsed',
|
|
400
|
-
projectId: 'from-builder',
|
|
410
|
+
projectId: project?.id ?? 'from-builder',
|
|
411
|
+
project: project ?? { id: 'from-builder' },
|
|
401
412
|
specification: toLikeC4Specification(),
|
|
402
413
|
elements: fromEntries(
|
|
403
414
|
structuredClone(
|
|
@@ -421,9 +432,9 @@ function builder<Spec extends BuilderSpecification, T extends AnyTypes>(
|
|
|
421
432
|
),
|
|
422
433
|
imports: {},
|
|
423
434
|
} as any),
|
|
424
|
-
toLikeC4Model: () => {
|
|
425
|
-
const parsed = self.build()
|
|
426
|
-
return computeLikeC4Model(parsed)
|
|
435
|
+
toLikeC4Model: (project?: LikeC4Project) => {
|
|
436
|
+
const parsed = self.build(project as any)
|
|
437
|
+
return computeLikeC4Model(parsed) as any
|
|
427
438
|
},
|
|
428
439
|
helpers: () => ({
|
|
429
440
|
model: {
|
|
@@ -95,6 +95,9 @@ exports[`Builder (style1) > should build nested elements and relTo 1`] = `
|
|
|
95
95
|
"styles": {},
|
|
96
96
|
},
|
|
97
97
|
"imports": {},
|
|
98
|
+
"project": {
|
|
99
|
+
"id": "from-builder",
|
|
100
|
+
},
|
|
98
101
|
"projectId": "from-builder",
|
|
99
102
|
"relations": {
|
|
100
103
|
"rel1": {
|
|
@@ -208,6 +211,9 @@ exports[`Builder (style1) > should build view 1`] = `
|
|
|
208
211
|
"styles": {},
|
|
209
212
|
},
|
|
210
213
|
"imports": {},
|
|
214
|
+
"project": {
|
|
215
|
+
"id": "from-builder",
|
|
216
|
+
},
|
|
211
217
|
"projectId": "from-builder",
|
|
212
218
|
"relations": {},
|
|
213
219
|
"specification": {
|
|
@@ -350,6 +356,9 @@ exports[`Builder (style1) > should build viewOf 1`] = `
|
|
|
350
356
|
"styles": {},
|
|
351
357
|
},
|
|
352
358
|
"imports": {},
|
|
359
|
+
"project": {
|
|
360
|
+
"id": "from-builder",
|
|
361
|
+
},
|
|
353
362
|
"projectId": "from-builder",
|
|
354
363
|
"relations": {},
|
|
355
364
|
"specification": {
|
package/src/builder/_types.ts
CHANGED
|
@@ -41,6 +41,16 @@ export type BuilderSpecification = {
|
|
|
41
41
|
metadataKeys?: string[]
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* We need with `id: string` to be able to derive the project id
|
|
46
|
+
*
|
|
47
|
+
* @see {@link LikeC4Project}
|
|
48
|
+
*/
|
|
49
|
+
export type BuilderProjectSpecification = {
|
|
50
|
+
id: string
|
|
51
|
+
title?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
export type Metadata<MetadataKey extends string> = IsNever<MetadataKey> extends true ? never :
|
|
45
55
|
IsLiteral<MetadataKey> extends true ? {
|
|
46
56
|
[key in MetadataKey]?: string
|
|
@@ -356,6 +356,7 @@ export const globalStyles = {
|
|
|
356
356
|
export type FakeRelationIds = (typeof fakeRelations)[number]['id']
|
|
357
357
|
const fakeParsedModel = {
|
|
358
358
|
_stage: 'computed' as const,
|
|
359
|
+
project: { id: 'test-project', config: { name: 'test-project' } },
|
|
359
360
|
specification: {
|
|
360
361
|
elements: {
|
|
361
362
|
actor: {},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { concat, constant, flatMap, hasAtLeast, map, partition, pipe, piped, prop, when } from 'remeda'
|
|
2
|
-
import type { RelationshipModel } from '../../../model'
|
|
1
|
+
import { concat, constant, filter, flatMap, hasAtLeast, map, partition, pipe, piped, prop, when } from 'remeda'
|
|
2
|
+
import type { ElementModel, RelationshipModel } from '../../../model'
|
|
3
3
|
import { ConnectionModel } from '../../../model'
|
|
4
4
|
import { type AnyAux, type ModelRelationExpr, FqnRef, ModelFqnExpr } from '../../../types'
|
|
5
5
|
import { invariant, isSameHierarchy } from '../../../utils'
|
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
} from './_utils'
|
|
17
17
|
|
|
18
18
|
const isWildcard = ModelFqnExpr.isWildcard
|
|
19
|
+
const isAncestorOrDescendantOf = (a: ElementModel<AnyAux>, b: ElementModel<AnyAux>) =>
|
|
20
|
+
a.isAncestorOf(b) || a.isDescendantOf(b)
|
|
19
21
|
|
|
20
22
|
export const DirectRelationExprPredicate: PredicateExecutor<ModelRelationExpr.Direct<AnyAux>> = {
|
|
21
23
|
include: ({ expr: { source, target, isBidirectional = false }, memory, model, stage, where, filterWhere }) => {
|
|
@@ -75,6 +77,7 @@ export const DirectRelationExprPredicate: PredicateExecutor<ModelRelationExpr.Di
|
|
|
75
77
|
concat(
|
|
76
78
|
pipe(
|
|
77
79
|
outgoing,
|
|
80
|
+
filter(r => !isAncestorOrDescendantOf(source, r.target)),
|
|
78
81
|
map(outgoing =>
|
|
79
82
|
new ConnectionModel(
|
|
80
83
|
source,
|
|
@@ -85,6 +88,7 @@ export const DirectRelationExprPredicate: PredicateExecutor<ModelRelationExpr.Di
|
|
|
85
88
|
),
|
|
86
89
|
pipe(
|
|
87
90
|
incoming,
|
|
91
|
+
filter(r => !isAncestorOrDescendantOf(source, r.source)),
|
|
88
92
|
map(incoming =>
|
|
89
93
|
new ConnectionModel(
|
|
90
94
|
incoming.source,
|
|
@@ -133,6 +137,7 @@ export const DirectRelationExprPredicate: PredicateExecutor<ModelRelationExpr.Di
|
|
|
133
137
|
concat(
|
|
134
138
|
pipe(
|
|
135
139
|
outgoing,
|
|
140
|
+
filter(r => !isAncestorOrDescendantOf(target, r.target)),
|
|
136
141
|
map(outgoing =>
|
|
137
142
|
new ConnectionModel(
|
|
138
143
|
target,
|
|
@@ -143,6 +148,7 @@ export const DirectRelationExprPredicate: PredicateExecutor<ModelRelationExpr.Di
|
|
|
143
148
|
),
|
|
144
149
|
pipe(
|
|
145
150
|
incoming,
|
|
151
|
+
filter(r => !isAncestorOrDescendantOf(target, r.source)),
|
|
146
152
|
map(incoming =>
|
|
147
153
|
new ConnectionModel(
|
|
148
154
|
incoming.source,
|
|
@@ -19,6 +19,7 @@ export function applyCustomRelationProperties<A extends AnyAux>(
|
|
|
19
19
|
expr,
|
|
20
20
|
title,
|
|
21
21
|
description,
|
|
22
|
+
notes,
|
|
22
23
|
...customprops
|
|
23
24
|
},
|
|
24
25
|
} of rules
|
|
@@ -46,6 +47,7 @@ export function applyCustomRelationProperties<A extends AnyAux>(
|
|
|
46
47
|
...edge,
|
|
47
48
|
...props,
|
|
48
49
|
...description && { description: { txt: description } },
|
|
50
|
+
...notes && { notes: { txt: notes } },
|
|
49
51
|
label: title ?? edge.label,
|
|
50
52
|
isCustomized: true,
|
|
51
53
|
}
|
|
@@ -30,8 +30,8 @@ import {
|
|
|
30
30
|
type IncomingFilter,
|
|
31
31
|
type OutgoingFilter,
|
|
32
32
|
type RelationOrId,
|
|
33
|
-
getId,
|
|
34
33
|
} from './types'
|
|
34
|
+
import { getId } from './utils'
|
|
35
35
|
import type { LikeC4ViewModel } from './view/LikeC4ViewModel'
|
|
36
36
|
|
|
37
37
|
export class LikeC4DeploymentModel<A extends Any = Any> {
|