@likec4/core 1.32.2 → 1.33.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/builder/index.d.mts +6 -4
- package/dist/builder/index.mjs +45 -13
- package/dist/compute-view/index.d.mts +6 -4
- package/dist/compute-view/index.mjs +33 -10
- package/dist/compute-view/relationships-view/index.d.mts +6 -4
- package/dist/compute-view/relationships-view/index.mjs +6 -3
- package/dist/index.d.mts +9 -138
- package/dist/index.mjs +31 -3712
- package/dist/model/connection/deployment/index.d.mts +10 -0
- package/dist/model/connection/deployment/index.mjs +18 -0
- package/dist/model/connection/index.d.mts +70 -0
- package/dist/model/connection/index.mjs +23 -0
- package/dist/model/connection/model/index.d.mts +10 -0
- package/dist/model/connection/model/index.mjs +11 -0
- package/dist/model/index.d.mts +14 -256
- package/dist/model/index.mjs +27 -5
- package/dist/shared/{core.Bdz6fBF1.d.mts → core.1pNeDdRk.d.mts} +92 -81
- package/dist/shared/{core.BuO4ncfY.d.mts → core.668kXpZq.d.mts} +42 -52
- package/dist/shared/core.8KM0D6va.mjs +33 -0
- package/dist/shared/core.B0oEIXqd.mjs +47 -0
- package/dist/shared/core.BH9nN-_I.mjs +22 -0
- package/dist/shared/core.BMCb0wJI.mjs +177 -0
- package/dist/shared/core.BTnf14gD.mjs +331 -0
- package/dist/shared/core.BgvIuGGU.mjs +3 -0
- package/dist/shared/core.BoyJPEen.mjs +21 -0
- package/dist/shared/{core.CUYDgv2-.mjs → core.Br7Fab9l.mjs} +12 -15
- package/dist/shared/{core.BrCnZFTn.mjs → core.Btl47GOn.mjs} +3 -3
- package/dist/shared/core.ByrmCl9I.mjs +5 -0
- package/dist/shared/core.C80Z37Eu.mjs +29 -0
- package/dist/shared/{core.Pf5I9o0e.d.mts → core.CF82MWyh.d.mts} +1 -1
- package/dist/shared/{core.rmvsy0n3.mjs → core.C_C-3c1S.mjs} +5 -198
- package/dist/shared/core.CeQbbp7K.d.mts +41 -0
- package/dist/shared/{core.DoK86JEe.mjs → core.CpwrZi3D.mjs} +2 -73
- package/dist/shared/{core.CpXlRyE5.mjs → core.CtKXPqN_.mjs} +5 -36
- package/dist/shared/core.CxGKeL-L.mjs +144 -0
- package/dist/shared/core.CzdwsPmY.d.mts +69 -0
- package/dist/shared/{core.Cy9smucx.mjs → core.D4npX2q8.mjs} +1 -3
- package/dist/shared/core.D56nCp7e.mjs +168 -0
- package/dist/shared/core.D5qVzkws.mjs +724 -0
- package/dist/shared/core.DDAPzd3T.d.mts +87 -0
- package/dist/shared/{core.CBpKAlhj.mjs → core.DDynPqbh.mjs} +96 -56
- package/dist/shared/{core.Bk7wEZFG.mjs → core.DXRAwwDB.mjs} +3 -2
- package/dist/shared/core.DcS-0zys.mjs +10 -0
- package/dist/shared/{core.CBxTtXMi.d.mts → core.De___iBS.d.mts} +3 -2
- package/dist/shared/core.DsMrjY2q.mjs +34 -0
- package/dist/shared/core.DuSLYTG6.d.mts +57 -0
- package/dist/shared/core.Dy-F3xRP.d.mts +83 -0
- package/dist/shared/{core.DaAyklhe.d.mts → core.OLInHaJx.d.mts} +30 -22
- package/dist/shared/core.XptQjhMA.mjs +1295 -0
- package/dist/shared/{core.cbA9VZ02.mjs → core.hoq9W4rW.mjs} +28 -1073
- package/dist/shared/core.zLlww-07.mjs +3 -0
- package/dist/theme/index.d.mts +134 -0
- package/dist/theme/index.mjs +3709 -0
- package/dist/types/aux.d.mts +3 -2
- package/dist/types/index.d.mts +9 -5
- package/dist/types/index.mjs +17 -146
- package/dist/utils/index.d.mts +15 -100
- package/dist/utils/index.mjs +25 -1315
- package/dist/utils/iterable/index.d.mts +100 -0
- package/dist/utils/iterable/index.mjs +24 -0
- package/package.json +23 -7
- package/src/builder/Builder.ts +13 -4
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +0 -13
- package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +2 -6
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +0 -7
- package/src/compute-view/deployment-view/__test__/fixture.ts +15 -5
- package/src/compute-view/deployment-view/utils.ts +13 -13
- package/src/compute-view/dynamic-view/compute.ts +2 -1
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +2 -2
- package/src/compute-view/relationships-view/layout.ts +1 -1
- package/src/compute-view/utils/applyCustomElementProperties.ts +8 -0
- package/src/compute-view/utils/applyCustomRelationProperties.ts +2 -0
- package/src/compute-view/utils/buildComputedNodes.ts +4 -3
- package/src/compute-view/utils/merge-props-from-relationships.ts +6 -5
- package/src/compute-view/utils/view-hash.ts +24 -3
- package/src/model/DeploymentElementModel.ts +20 -16
- package/src/model/ElementModel.ts +9 -3
- package/src/model/RelationModel.ts +19 -16
- package/src/model/index.ts +2 -0
- package/src/model/types.ts +1 -0
- package/src/model/view/EdgeModel.ts +4 -3
- package/src/model/view/LikeC4ViewModel.ts +5 -0
- package/src/model/view/NodeModel.ts +4 -2
- package/src/theme/index.ts +12 -5
- package/src/types/RichText.ts +200 -0
- package/src/types/index.ts +2 -0
- package/src/types/model-deployment.ts +4 -3
- package/src/types/model-logical.ts +3 -3
- package/src/types/scalar.ts +47 -2
- package/src/types/view-common.ts +1 -1
- package/src/types/view-computed.ts +2 -4
- package/src/types/view-layouted.ts +9 -0
- package/src/utils/index.ts +4 -9
- package/src/utils/markdown/index.ts +2 -0
- package/src/utils/markdown/to-html.ts +32 -0
- package/src/utils/markdown/to-text.ts +14 -0
|
@@ -5,6 +5,7 @@ import type { AnyAux, Unknown } from './aux'
|
|
|
5
5
|
import type { FqnRef } from './fqnRef'
|
|
6
6
|
import type { AbstractRelationship, ElementStyle } from './model-logical'
|
|
7
7
|
import type { Icon } from './scalar'
|
|
8
|
+
import type * as scalar from './scalar'
|
|
8
9
|
import type { Color, ElementShape } from './styles'
|
|
9
10
|
|
|
10
11
|
export interface DeploymentElementStyle extends ElementStyle {
|
|
@@ -25,12 +26,12 @@ export interface DeploymentNode<A extends AnyAux = Unknown>
|
|
|
25
26
|
readonly id: aux.StrictDeploymentFqn<A>
|
|
26
27
|
readonly kind: aux.DeploymentKind<A>
|
|
27
28
|
readonly title: string
|
|
28
|
-
readonly description?:
|
|
29
|
+
readonly description?: scalar.MarkdownOrString | null
|
|
29
30
|
readonly technology?: string | null
|
|
30
31
|
readonly tags?: aux.Tags<A> | null
|
|
31
32
|
readonly links?: readonly Link[] | null
|
|
32
33
|
readonly style: DeploymentElementStyle
|
|
33
|
-
readonly notation?: string
|
|
34
|
+
readonly notation?: string | null
|
|
34
35
|
readonly metadata?: aux.Metadata<A>
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -49,7 +50,7 @@ export interface DeployedInstance<A extends AnyAux = Unknown>
|
|
|
49
50
|
readonly id: aux.StrictDeploymentFqn<A>
|
|
50
51
|
readonly element: aux.StrictFqn<A>
|
|
51
52
|
readonly title?: string
|
|
52
|
-
readonly description?:
|
|
53
|
+
readonly description?: scalar.MarkdownOrString | null
|
|
53
54
|
readonly technology?: string | null
|
|
54
55
|
readonly tags?: aux.Tags<A> | null
|
|
55
56
|
readonly links?: readonly Link[] | null
|
|
@@ -57,7 +57,7 @@ export interface Element<A extends AnyAux = AnyAux>
|
|
|
57
57
|
readonly id: aux.StrictFqn<A>
|
|
58
58
|
readonly kind: aux.ElementKind<A>
|
|
59
59
|
readonly title: string
|
|
60
|
-
readonly description?:
|
|
60
|
+
readonly description?: scalar.MarkdownOrString | null
|
|
61
61
|
readonly technology?: string | null
|
|
62
62
|
readonly tags?: aux.Tags<A> | null
|
|
63
63
|
readonly links?: readonly Link[] | null
|
|
@@ -65,7 +65,7 @@ export interface Element<A extends AnyAux = AnyAux>
|
|
|
65
65
|
readonly shape?: ElementShape
|
|
66
66
|
readonly color?: Color
|
|
67
67
|
readonly style?: ElementStyle
|
|
68
|
-
readonly notation?: string
|
|
68
|
+
readonly notation?: string | null
|
|
69
69
|
readonly metadata?: aux.Metadata<A>
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -82,7 +82,7 @@ export interface AbstractRelationship<A extends AnyAux>
|
|
|
82
82
|
{
|
|
83
83
|
readonly id: scalar.RelationId
|
|
84
84
|
readonly title?: string | null
|
|
85
|
-
readonly description?:
|
|
85
|
+
readonly description?: scalar.MarkdownOrString | null
|
|
86
86
|
readonly technology?: string | null
|
|
87
87
|
readonly kind?: aux.RelationKind<A>
|
|
88
88
|
readonly color?: Color
|
package/src/types/scalar.ts
CHANGED
|
@@ -1,9 +1,54 @@
|
|
|
1
|
-
import { isTruthy } from 'remeda'
|
|
1
|
+
import { isString, isTruthy } from 'remeda'
|
|
2
2
|
import type { Tagged } from 'type-fest'
|
|
3
|
-
import { invariant } from '../utils
|
|
3
|
+
import { invariant } from '../utils'
|
|
4
4
|
|
|
5
5
|
export type ProjectId<T = string> = Tagged<T, 'ProjectID'>
|
|
6
6
|
|
|
7
|
+
export type MarkdownOrString = { txt: string; md?: never } | { md: string; txt?: never }
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Converts a MarkdownOrString object or a plain string into a simple string representation.
|
|
11
|
+
* This utility function handles different types of text content and normalizes them to a string format.
|
|
12
|
+
*
|
|
13
|
+
* @param value - The content to be flattened.
|
|
14
|
+
* Can be one of:
|
|
15
|
+
* - A plain string
|
|
16
|
+
* - A MarkdownOrString object with either txt or md property
|
|
17
|
+
* - undefined or null
|
|
18
|
+
*
|
|
19
|
+
* @returns The string content contained within the input value.
|
|
20
|
+
* - Returns the input directly if it's already a string
|
|
21
|
+
* - Returns the txt property if available in a MarkdownOrString object
|
|
22
|
+
* - Falls back to the md property if txt is not available
|
|
23
|
+
* - Returns null if:
|
|
24
|
+
* - The input is null or undefined
|
|
25
|
+
* - The resulting string value is empty, whitespace, or null
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // String input
|
|
29
|
+
* flattenMarkdownOrString("Hello world") // Returns: "Hello world"
|
|
30
|
+
* flattenMarkdownOrString(" ") // Returns: null
|
|
31
|
+
*
|
|
32
|
+
* // MarkdownOrString with txt property
|
|
33
|
+
* flattenMarkdownOrString({ txt: "Plain text" }) // Returns: "Plain text"
|
|
34
|
+
* flattenMarkdownOrString({ txt: " " }) // Returns: null
|
|
35
|
+
*
|
|
36
|
+
* // MarkdownOrString with md property
|
|
37
|
+
* flattenMarkdownOrString({ md: "**Bold markdown**" }) // Returns: "**Bold markdown**"
|
|
38
|
+
*
|
|
39
|
+
* // Null input
|
|
40
|
+
* flattenMarkdownOrString(null) // Returns: null
|
|
41
|
+
*/
|
|
42
|
+
export function flattenMarkdownOrString(value: MarkdownOrString | string): string
|
|
43
|
+
export function flattenMarkdownOrString(value: MarkdownOrString | string | undefined | null): string | null
|
|
44
|
+
export function flattenMarkdownOrString(value: MarkdownOrString | string | undefined | null): string | null {
|
|
45
|
+
if (value === null || value === undefined) {
|
|
46
|
+
return null
|
|
47
|
+
}
|
|
48
|
+
const content = isString(value) ? value : value.txt ?? value.md
|
|
49
|
+
return isTruthy(content?.trim()) ? content : null
|
|
50
|
+
}
|
|
51
|
+
|
|
7
52
|
export type BuiltInIcon = 'none' | `${'aws' | 'azure' | 'gcp' | 'tech'}:${string}`
|
|
8
53
|
export type Icon = Tagged<string, 'Icon'> | BuiltInIcon
|
|
9
54
|
export type IconUrl = Icon
|
package/src/types/view-common.ts
CHANGED
|
@@ -106,7 +106,7 @@ export type ViewType = 'element' | 'dynamic' | 'deployment'
|
|
|
106
106
|
export interface BaseViewProperties<A extends AnyAux> extends aux.WithOptionalTags<A>, aux.WithOptionalLinks {
|
|
107
107
|
readonly id: aux.StrictViewId<A>
|
|
108
108
|
readonly title: string | null
|
|
109
|
-
readonly description:
|
|
109
|
+
readonly description: scalar.MarkdownOrString | null
|
|
110
110
|
/**
|
|
111
111
|
* For all views we find common ancestor path.
|
|
112
112
|
* This is used to generate relative paths, i.e.:
|
|
@@ -26,16 +26,14 @@ export interface ComputedNode<A extends Any = Any> extends aux.WithOptionalLinks
|
|
|
26
26
|
parent: scalar.NodeId | null
|
|
27
27
|
/**
|
|
28
28
|
* Reference to model element
|
|
29
|
-
* If 1 - node id is a reference
|
|
30
29
|
*/
|
|
31
30
|
modelRef?: aux.Fqn<A> | undefined
|
|
32
31
|
/**
|
|
33
32
|
* Reference to deployment element
|
|
34
|
-
* If 1 - node id is a reference
|
|
35
33
|
*/
|
|
36
34
|
deploymentRef?: aux.DeploymentFqn<A> | undefined
|
|
37
35
|
title: string
|
|
38
|
-
description?:
|
|
36
|
+
description?: scalar.MarkdownOrString | null
|
|
39
37
|
technology?: string | null
|
|
40
38
|
notation?: string
|
|
41
39
|
children: scalar.NodeId[]
|
|
@@ -62,7 +60,7 @@ export interface ComputedEdge<A extends Any = Any> extends aux.WithOptionalTags<
|
|
|
62
60
|
source: scalar.NodeId
|
|
63
61
|
target: scalar.NodeId
|
|
64
62
|
label: string | null
|
|
65
|
-
description?:
|
|
63
|
+
description?: scalar.MarkdownOrString | null
|
|
66
64
|
technology?: string
|
|
67
65
|
relations: scalar.RelationId[]
|
|
68
66
|
kind?: aux.RelationKind<A> | typeof scalar.StepEdgeKind
|
|
@@ -26,6 +26,10 @@ export interface DiagramNode<A extends AnyAux = AnyAux> extends ComputedNode<A>,
|
|
|
26
26
|
* (Absolute coordinates)
|
|
27
27
|
*/
|
|
28
28
|
labelBBox: BBox
|
|
29
|
+
|
|
30
|
+
// description?: scalar.HtmlOrString | null
|
|
31
|
+
// technology?: scalar.HtmlOrString | null
|
|
32
|
+
// notation?: scalar.HtmlOrString | null
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
export interface DiagramEdge<A extends AnyAux = AnyAux> extends ComputedEdge<A> {
|
|
@@ -51,6 +55,11 @@ export interface DiagramEdge<A extends AnyAux = AnyAux> extends ComputedEdge<A>
|
|
|
51
55
|
* @deprecated
|
|
52
56
|
*/
|
|
53
57
|
dotpos?: string
|
|
58
|
+
// label: scalar.HtmlOrString | null
|
|
59
|
+
// description?: scalar.HtmlOrString | null
|
|
60
|
+
// technology?: scalar.HtmlOrString | null
|
|
61
|
+
// notation?: scalar.HtmlOrString | null
|
|
62
|
+
// notes?: scalar.HtmlOrString | null
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
interface BaseLayoutedViewProperties<A extends AnyAux> extends BaseViewProperties<A>, ViewWithHash, ViewWithNotation {
|
package/src/utils/index.ts
CHANGED
|
@@ -54,9 +54,7 @@ export {
|
|
|
54
54
|
export { memoizeProp } from './memoize-prop'
|
|
55
55
|
export { delay, promiseNextTick } from './promises'
|
|
56
56
|
|
|
57
|
-
export {
|
|
58
|
-
compareRelations,
|
|
59
|
-
} from './relations'
|
|
57
|
+
export { compareRelations } from './relations'
|
|
60
58
|
|
|
61
59
|
export {
|
|
62
60
|
difference,
|
|
@@ -66,10 +64,7 @@ export {
|
|
|
66
64
|
union,
|
|
67
65
|
} from './set'
|
|
68
66
|
|
|
69
|
-
export {
|
|
70
|
-
|
|
71
|
-
} from './string-hash'
|
|
67
|
+
export { objectHash } from './object-hash'
|
|
68
|
+
export { stringHash } from './string-hash'
|
|
72
69
|
|
|
73
|
-
export {
|
|
74
|
-
objectHash,
|
|
75
|
-
} from './object-hash'
|
|
70
|
+
export { markdownToHtml, markdownToText } from './markdown'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import rehypeRaw from 'rehype-raw'
|
|
2
|
+
import rehypeSanitize from 'rehype-sanitize'
|
|
3
|
+
import rehypeStringify from 'rehype-stringify'
|
|
4
|
+
import remarkGfm from 'remark-gfm'
|
|
5
|
+
import remarkParse from 'remark-parse'
|
|
6
|
+
import remarkRehype from 'remark-rehype'
|
|
7
|
+
import { unified } from 'unified'
|
|
8
|
+
|
|
9
|
+
// let _remark
|
|
10
|
+
function remark() {
|
|
11
|
+
return unified()
|
|
12
|
+
.use(remarkParse)
|
|
13
|
+
.use(remarkGfm)
|
|
14
|
+
.use(remarkRehype, {
|
|
15
|
+
// Tight paragraphs prevent extra newlines
|
|
16
|
+
allowDangerousHtml: true,
|
|
17
|
+
clobberPrefix: '',
|
|
18
|
+
tableCellPadding: false,
|
|
19
|
+
tight: true,
|
|
20
|
+
})
|
|
21
|
+
.use(rehypeRaw)
|
|
22
|
+
.use(rehypeSanitize)
|
|
23
|
+
.use(rehypeStringify, {
|
|
24
|
+
// Prevent extra closing newlines
|
|
25
|
+
closeSelfClosing: true,
|
|
26
|
+
tightSelfClosing: true,
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function markdownToHtml(markdown: string): string {
|
|
31
|
+
return String(remark().processSync(markdown.trim())).trim()
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { fromMarkdown } from 'mdast-util-from-markdown'
|
|
2
|
+
import { toString } from 'mdast-util-to-string'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts markdown to plain text, removing any markdown formatting.
|
|
6
|
+
* @param markdown - The markdown to convert.
|
|
7
|
+
* @returns The plain text.
|
|
8
|
+
*/
|
|
9
|
+
export function markdownToText(markdown: string): string {
|
|
10
|
+
return toString(fromMarkdown(markdown), {
|
|
11
|
+
includeHtml: false,
|
|
12
|
+
includeImageAlt: false,
|
|
13
|
+
})
|
|
14
|
+
}
|