@likec4/core 1.35.0 → 1.36.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 +1 -1
- package/dist/builder/index.d.mts +15 -4
- package/dist/builder/index.mjs +13 -10
- package/dist/compute-view/index.d.mts +3 -3
- package/dist/compute-view/index.mjs +10 -8
- package/dist/compute-view/relationships-view/index.d.mts +3 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +7 -3
- package/dist/model/connection/deployment/index.d.mts +5 -5
- package/dist/model/connection/deployment/index.mjs +3 -2
- package/dist/model/connection/index.d.mts +6 -6
- package/dist/model/connection/index.mjs +3 -2
- package/dist/model/connection/model/index.d.mts +5 -5
- package/dist/model/index.d.mts +8 -8
- package/dist/model/index.mjs +6 -4
- package/dist/shared/{core.DAj3LuFH.d.mts → core.BFb3p5d-.d.mts} +4 -2
- package/dist/shared/{core.RnUJywKk.mjs → core.BlwZ4tBa.mjs} +9 -5
- package/dist/shared/{core.DhTO8rgm.d.mts → core.Bt3kuGUN.d.mts} +3 -3
- package/dist/shared/{core.CQS11dNK.mjs → core.Bus32P0S.mjs} +2 -1
- package/dist/shared/{core.rpF8esVq.mjs → core.BvIGRozf.mjs} +13 -3
- package/dist/shared/{core.B1ZN723l.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.72IoI17N.d.mts → core.D8bTI5KC.d.mts} +2 -2
- package/dist/shared/{core.NBNeVyag.d.mts → core.DHYd2-VU.d.mts} +3 -3
- package/dist/shared/{core.SciGxb--.d.mts → core.DoNP3Yl-.d.mts} +6 -5
- package/dist/shared/{core.Ddua-wiI.d.mts → core.DxDn5nB5.d.mts} +21 -6
- package/dist/shared/{core.BajmN8zR.mjs → core._jnYNUQ-.mjs} +4 -66
- package/dist/theme/index.mjs +2 -3508
- 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/package.json +8 -14
- 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/utils/applyCustomRelationProperties.ts +2 -0
- package/src/model/LikeC4Model.ts +16 -6
- package/src/theme/element.ts +0 -19
- 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/project.ts +9 -0
- package/src/types/view-computed.ts +1 -1
- package/src/types/view-parsed.dynamic.ts +2 -2
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/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.1",
|
|
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,12 +97,13 @@
|
|
|
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": {
|
|
109
105
|
"@types/chroma-js": "^3.1.1",
|
|
110
106
|
"@dagrejs/dagre": "1.1.5",
|
|
111
|
-
"@mantine/colors-generator": "8.2.1",
|
|
112
107
|
"@types/extend": "3.0.4",
|
|
113
108
|
"@types/hast": "3.0.4",
|
|
114
109
|
"@types/mdast": "4.0.4",
|
|
@@ -116,7 +111,6 @@
|
|
|
116
111
|
"@types/object-hash": "^3.0.6",
|
|
117
112
|
"@types/unist": "3.0.3",
|
|
118
113
|
"@types/node": "~20.19.2",
|
|
119
|
-
"chroma-js": "^3.1.2",
|
|
120
114
|
"defu": "^6.1.4",
|
|
121
115
|
"fdir": "6.4.6",
|
|
122
116
|
"graphology": "^0.25.4",
|
|
@@ -128,10 +122,10 @@
|
|
|
128
122
|
"obliterator": "^2.0.5",
|
|
129
123
|
"remeda": "^2.23.1",
|
|
130
124
|
"turbo": "2.5.5",
|
|
131
|
-
"typescript": "5.
|
|
125
|
+
"typescript": "5.9.2",
|
|
132
126
|
"unbuild": "3.5.0",
|
|
133
127
|
"vitest": "3.2.4",
|
|
134
|
-
"@likec4/tsconfig": "1.
|
|
128
|
+
"@likec4/tsconfig": "1.36.1"
|
|
135
129
|
},
|
|
136
130
|
"scripts": {
|
|
137
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: {},
|
|
@@ -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
|
}
|
package/src/model/LikeC4Model.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
IteratorLike,
|
|
9
9
|
LayoutedLikeC4ModelData,
|
|
10
10
|
LikeC4ModelDump,
|
|
11
|
+
LikeC4Project,
|
|
11
12
|
ModelGlobals,
|
|
12
13
|
ParsedLikeC4ModelData,
|
|
13
14
|
Relationship,
|
|
@@ -119,6 +120,7 @@ export class LikeC4Model<A extends Any = aux.Unknown> {
|
|
|
119
120
|
const {
|
|
120
121
|
_stage: stage = 'layouted',
|
|
121
122
|
projectId = 'unknown',
|
|
123
|
+
project,
|
|
122
124
|
globals,
|
|
123
125
|
imports,
|
|
124
126
|
deployments,
|
|
@@ -130,6 +132,7 @@ export class LikeC4Model<A extends Any = aux.Unknown> {
|
|
|
130
132
|
return new LikeC4Model({
|
|
131
133
|
[_stage]: stage as 'layouted',
|
|
132
134
|
projectId,
|
|
135
|
+
project,
|
|
133
136
|
globals: {
|
|
134
137
|
predicates: globals?.predicates ?? {},
|
|
135
138
|
dynamicPredicates: globals?.dynamicPredicates ?? {},
|
|
@@ -295,6 +298,12 @@ export class LikeC4Model<A extends Any = aux.Unknown> {
|
|
|
295
298
|
return this.$data.projectId ?? 'unknown' as any
|
|
296
299
|
}
|
|
297
300
|
|
|
301
|
+
get project(): LikeC4Project {
|
|
302
|
+
return this.$data.project ?? memoizeProp(this, Symbol.for('project'), () => ({
|
|
303
|
+
id: this.projectId as unknown as scalar.ProjectId,
|
|
304
|
+
}))
|
|
305
|
+
}
|
|
306
|
+
|
|
298
307
|
get specification(): Specification<A> {
|
|
299
308
|
return this.$data.specification
|
|
300
309
|
}
|
|
@@ -806,6 +815,7 @@ export namespace LikeC4Model {
|
|
|
806
815
|
export const EMPTY = LikeC4Model.create<aux.UnknownComputed>({
|
|
807
816
|
_stage: 'computed',
|
|
808
817
|
projectId: 'default' as never,
|
|
818
|
+
project: { id: 'default' as never },
|
|
809
819
|
specification: {
|
|
810
820
|
elements: {},
|
|
811
821
|
relationships: {},
|
|
@@ -831,24 +841,24 @@ export namespace LikeC4Model {
|
|
|
831
841
|
// dprint-ignore
|
|
832
842
|
aux.Unknown extends A
|
|
833
843
|
? LikeC4Model<aux.UnknownParsed>
|
|
834
|
-
: A extends Aux<any, infer E, infer D, infer V, infer
|
|
835
|
-
? LikeC4Model<Aux<'parsed', E, D, V,
|
|
844
|
+
: A extends Aux<any, infer E, infer D, infer V, infer PID, infer Spec>
|
|
845
|
+
? LikeC4Model<Aux<'parsed', E, D, V, PID, Spec>>
|
|
836
846
|
: never
|
|
837
847
|
|
|
838
848
|
export type Computed<A = aux.Unknown> =
|
|
839
849
|
// dprint-ignore
|
|
840
850
|
aux.Unknown extends A
|
|
841
851
|
? LikeC4Model<aux.UnknownComputed>
|
|
842
|
-
: A extends Aux<any, infer E, infer D, infer V, infer
|
|
843
|
-
? LikeC4Model<Aux<'computed', E, D, V,
|
|
852
|
+
: A extends Aux<any, infer E, infer D, infer V, infer PID, infer Spec>
|
|
853
|
+
? LikeC4Model<Aux<'computed', E, D, V, PID, Spec>>
|
|
844
854
|
: never
|
|
845
855
|
|
|
846
856
|
export type Layouted<A = aux.Unknown> =
|
|
847
857
|
// dprint-ignore
|
|
848
858
|
aux.Unknown extends A
|
|
849
859
|
? LikeC4Model<aux.UnknownLayouted>
|
|
850
|
-
: A extends Aux<any, infer E, infer D, infer V, infer
|
|
851
|
-
? LikeC4Model<Aux<'layouted', E, D, V,
|
|
860
|
+
: A extends Aux<any, infer E, infer D, infer V, infer PID, infer Spec>
|
|
861
|
+
? LikeC4Model<Aux<'layouted', E, D, V, PID, Spec>>
|
|
852
862
|
: never
|
|
853
863
|
|
|
854
864
|
export type Node<A = aux.Unknown> = A extends aux.AnyAux ? NodeModel<A> : never
|
package/src/theme/element.ts
CHANGED
|
@@ -29,30 +29,15 @@ export const ElementColors = {
|
|
|
29
29
|
muted: slate,
|
|
30
30
|
slate,
|
|
31
31
|
gray: {
|
|
32
|
-
// fill: colors.neutral[500],
|
|
33
|
-
// stroke: colors.neutral[600],
|
|
34
|
-
// hiContrast: colors.neutral[50],
|
|
35
|
-
// loContrast: colors.neutral[200],
|
|
36
32
|
fill: '#737373',
|
|
37
33
|
stroke: '#525252',
|
|
38
34
|
hiContrast: '#fafafa',
|
|
39
35
|
loContrast: '#d4d4d4',
|
|
40
36
|
},
|
|
41
37
|
red: {
|
|
42
|
-
// fill: colors.red[500],
|
|
43
|
-
// stroke: colors.red[600],
|
|
44
|
-
// hiContrast: colors.red[50],
|
|
45
|
-
// loContrast: colors.red[200],
|
|
46
38
|
fill: '#AC4D39',
|
|
47
|
-
// fill: '#b54548',
|
|
48
39
|
stroke: '#853A2D',
|
|
49
|
-
// hiContrast: '#fef2f2',
|
|
50
|
-
// loContrast: '#fecaca',
|
|
51
|
-
// hiContrast: '#191111', // colors.gray[900],
|
|
52
|
-
// loContrast: '#3b1219' // colors.gray[800],
|
|
53
40
|
hiContrast: '#FBD3CB',
|
|
54
|
-
// hiContrast: '#f8fafc',
|
|
55
|
-
// loContrast: '#fdd8d8' // radix black red 12
|
|
56
41
|
loContrast: '#f5b2a3',
|
|
57
42
|
},
|
|
58
43
|
green: {
|
|
@@ -68,10 +53,6 @@ export const ElementColors = {
|
|
|
68
53
|
loContrast: '#f9b27c',
|
|
69
54
|
},
|
|
70
55
|
indigo: {
|
|
71
|
-
// fill: colors.indigo[500],
|
|
72
|
-
// stroke: colors.indigo[600],
|
|
73
|
-
// hiContrast: colors.indigo[50],
|
|
74
|
-
// loContrast: colors.indigo[200],
|
|
75
56
|
fill: '#6366f1',
|
|
76
57
|
stroke: '#4f46e5',
|
|
77
58
|
hiContrast: '#eef2ff',
|
package/src/types/_aux.ts
CHANGED
|
@@ -149,6 +149,12 @@ export type toLayouted<A> = A extends Aux<any, infer E, infer D, infer V, infer
|
|
|
149
149
|
*/
|
|
150
150
|
export type ProjectId<A> = A extends infer T extends Any ? Coalesce<T['ProjectId']> : never
|
|
151
151
|
|
|
152
|
+
export type setProject<A, P extends string> =
|
|
153
|
+
// dprint-ignore
|
|
154
|
+
A extends Aux<infer S, infer E, infer D, infer V, any, infer Spec>
|
|
155
|
+
? Aux<S, E, D, V, P, Spec>
|
|
156
|
+
: never
|
|
157
|
+
|
|
152
158
|
/**
|
|
153
159
|
* Element FQN from Aux as branded type
|
|
154
160
|
*/
|
package/src/types/index.ts
CHANGED
package/src/types/model-data.ts
CHANGED
|
@@ -7,11 +7,13 @@ import type { ModelGlobals } from './global'
|
|
|
7
7
|
import type { DeploymentElement, DeploymentRelationship } from './model-deployment'
|
|
8
8
|
import type { Element, Relationship } from './model-logical'
|
|
9
9
|
import type { Specification } from './model-spec'
|
|
10
|
+
import type { LikeC4Project } from './project'
|
|
10
11
|
import type * as scalar from './scalar'
|
|
11
12
|
import type { ComputedView, LayoutedView, ParsedView } from './view'
|
|
12
13
|
|
|
13
14
|
interface BaseLikeC4ModelData<A extends aux.Any> {
|
|
14
15
|
projectId: aux.ProjectId<A>
|
|
16
|
+
project: LikeC4Project
|
|
15
17
|
specification: Specification<A>
|
|
16
18
|
elements: Record<aux.ElementId<A>, Element<A>>
|
|
17
19
|
deployments: {
|
package/src/types/model-dump.ts
CHANGED
|
@@ -39,6 +39,7 @@ export type SpecTypesFromDump<J> = J extends SpecificationDump ? aux.SpecAux<
|
|
|
39
39
|
export type LikeC4ModelDump = {
|
|
40
40
|
[_stage]?: 'computed' | 'layouted'
|
|
41
41
|
projectId?: string
|
|
42
|
+
project?: ProjectDump
|
|
42
43
|
specification: SpecificationDump
|
|
43
44
|
elements?: {
|
|
44
45
|
[kind: string]: object
|
|
@@ -61,12 +62,18 @@ export type LikeC4ModelDump = {
|
|
|
61
62
|
imports?: {}
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
export type ProjectDump = {
|
|
66
|
+
id: string
|
|
67
|
+
name?: string
|
|
68
|
+
title?: string | undefined
|
|
69
|
+
}
|
|
70
|
+
|
|
64
71
|
export type AuxFromDump<D> = D extends LikeC4ModelDump ? aux.Aux<
|
|
65
72
|
D[_stage] extends infer S extends string & 'computed' | 'layouted' ? S : 'computed' | 'layouted' | 'parsed',
|
|
66
73
|
KeysOf<D['elements']>,
|
|
67
74
|
KeysOf<D['deployments']['elements']>,
|
|
68
75
|
KeysOf<D['views']>,
|
|
69
|
-
D['projectId'] extends infer
|
|
76
|
+
D['projectId'] extends infer PID extends string ? PID : never,
|
|
70
77
|
SpecTypesFromDump<D['specification']>
|
|
71
78
|
>
|
|
72
79
|
: aux.Never
|
|
@@ -66,7 +66,7 @@ export interface ComputedEdge<A extends Any = Any> extends aux.WithOptionalTags<
|
|
|
66
66
|
kind?: aux.RelationKind<A> | typeof scalar.StepEdgeKind
|
|
67
67
|
notation?: string
|
|
68
68
|
// Notes for walkthrough
|
|
69
|
-
notes?:
|
|
69
|
+
notes?: scalar.MarkdownOrString
|
|
70
70
|
color?: Color
|
|
71
71
|
line?: RelationshipLineType
|
|
72
72
|
head?: RelationshipArrowType
|
|
@@ -5,7 +5,7 @@ import type { AnyAux } from './_aux'
|
|
|
5
5
|
import type { ExclusiveUnion } from './_common'
|
|
6
6
|
import type { _type } from './const'
|
|
7
7
|
import type { ModelFqnExpr } from './expression-model'
|
|
8
|
-
import { isStepEdgeId } from './scalar'
|
|
8
|
+
import { type MarkdownOrString, isStepEdgeId } from './scalar'
|
|
9
9
|
import type { Color, RelationshipArrowType, RelationshipLineType } from './styles'
|
|
10
10
|
import type {
|
|
11
11
|
BaseParsedViewProperties,
|
|
@@ -23,7 +23,7 @@ export interface DynamicViewStep<A extends AnyAux = AnyAux> {
|
|
|
23
23
|
readonly technology?: string
|
|
24
24
|
readonly notation?: string
|
|
25
25
|
// Notes for walkthrough
|
|
26
|
-
readonly notes?:
|
|
26
|
+
readonly notes?: MarkdownOrString
|
|
27
27
|
readonly color?: Color
|
|
28
28
|
readonly line?: RelationshipLineType
|
|
29
29
|
readonly head?: RelationshipArrowType
|