@likec4/core 1.41.0 → 1.42.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/builder/package.json +4 -0
- package/compute-view/package.json +4 -0
- package/compute-view/relationships/package.json +4 -0
- package/dist/builder/index.d.mts +13 -11
- package/dist/builder/index.mjs +111 -91
- package/dist/compute-view/index.d.mts +8 -7
- package/dist/compute-view/index.mjs +14 -11
- package/dist/compute-view/relationships-view/index.d.mts +9 -8
- package/dist/compute-view/relationships-view/index.mjs +6 -6
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +11 -11
- package/dist/model/connection/deployment/index.d.mts +11 -10
- package/dist/model/connection/deployment/index.mjs +2 -2
- package/dist/model/connection/index.d.mts +12 -11
- package/dist/model/connection/index.mjs +3 -3
- package/dist/model/connection/model/index.d.mts +11 -10
- package/dist/model/connection/model/index.mjs +2 -2
- package/dist/model/index.d.mts +14 -14
- package/dist/model/index.mjs +4 -5
- package/dist/shared/{core.Ae86Y3tB.mjs → core.01VTr9qu.mjs} +8 -26
- package/dist/shared/core.1vX5a9AY.mjs +86 -0
- package/dist/shared/{core.BVNaR17u.mjs → core.B7KhhkRY.mjs} +1 -1
- package/dist/shared/core.B85MJLTf.mjs +5 -0
- package/dist/shared/{core.DA5vzwZ9.mjs → core.BIqHjQiH.mjs} +56 -42
- package/dist/shared/core.BKlholso.mjs +3 -0
- package/dist/shared/core.BR4zXDH-.mjs +13 -0
- package/dist/shared/{core.CXy1NLUG.mjs → core.BYNkXQ8A.mjs} +21 -12
- package/dist/shared/{core.BuoXfSMj.mjs → core.BbE4y-yl.mjs} +1 -1
- package/dist/shared/core.BoYfZOBm.mjs +3 -0
- package/dist/shared/core.BsSXS-_R.mjs +7 -0
- package/dist/shared/{core.DJp8fgok.mjs → core.BzTakU3I.mjs} +14 -10
- package/dist/shared/{core.4u1dVmfX.mjs → core.C2TiyjI6.mjs} +2 -2
- package/dist/shared/{core.DLpidoWc.mjs → core.C3JowhaZ.mjs} +3 -3
- package/dist/shared/{core.CNGyqkJh.mjs → core.C4x8aaWa.mjs} +3 -1
- package/dist/shared/{core.BB6zA-UU.mjs → core.C8YY6Uub.mjs} +38 -9
- package/dist/shared/{core.Asc11Mjy.mjs → core.C8sl5Y8Z.mjs} +122 -58
- package/dist/shared/{core.BvMRMo7Z.mjs → core.CNgZvKb8.mjs} +3 -5198
- package/dist/shared/{core.CUG6vpyL.d.mts → core.CQngdcuj.d.mts} +85 -4
- package/dist/shared/{core.Be1n9a0i.mjs → core.C_Ni6yHl.mjs} +5 -4
- package/dist/shared/core.CbT8JVYL.mjs +5 -0
- package/dist/shared/core.CqAJJpK_.mjs +3 -0
- package/dist/shared/{core.BXsxn-hf.d.mts → core.D0PjZzIS.d.mts} +27 -15
- package/dist/shared/{core.DgesAwC8.d.mts → core.D5fzJWbF.d.mts} +2 -2
- package/dist/shared/{core.hfOE3RfK.d.mts → core.DACpKp35.d.mts} +5 -5
- package/dist/shared/core.DFi2dOTl.mjs +39548 -0
- package/dist/shared/{core.xSQO0XYD.d.mts → core.DIol3syK.d.mts} +2 -2
- package/dist/shared/{core.DlG1xWt2.mjs → core.DMMOWQqc.mjs} +3 -2
- package/dist/shared/core.DNbUPnve.mjs +3990 -0
- package/dist/shared/{core.CCD1ID81.mjs → core.DRJma0Ol.mjs} +4 -3
- package/dist/shared/{core.DgttqsJc.mjs → core.DRhg-gVU.mjs} +9 -9
- package/dist/shared/core.DSO_rTC2.mjs +5322 -0
- package/dist/shared/{core.FUPplpae.d.mts → core.D_vkffV4.d.mts} +4 -2
- package/dist/shared/core.DdMJk7nx.d.mts +476 -0
- package/dist/shared/{core.BhpgpOep.d.mts → core.Dgs6-nuz.d.mts} +2 -2
- package/dist/shared/{core.Be4Jy9Qx.mjs → core.FZ305VYd.mjs} +2 -2
- package/dist/shared/core.OHD4KXm9.mjs +5 -0
- package/dist/shared/{core.GTgsmXS_.mjs → core.QJD_fcrc.mjs} +2 -2
- package/dist/shared/core.RfnaEmgA.mjs +7 -0
- package/dist/shared/core.fHR_8Tnq.d.mts +450 -0
- package/dist/shared/{core.D0EgVMQK.mjs → core.lRvxPoao.mjs} +14 -12
- package/dist/shared/{core.CaT0SUUK.mjs → core.rCeaAqgW.mjs} +1 -84
- package/dist/shared/{core.zxTBF_PD.d.mts → core.s9uwOt60.d.mts} +4 -4
- package/dist/shared/core.yna0OdV5.d.mts +98 -0
- package/dist/styles/index.d.mts +106 -0
- package/dist/styles/index.mjs +1 -0
- package/dist/types/_aux.d.mts +2 -2
- package/dist/types/expression-model.d.mts +3 -4
- package/dist/types/expression.d.mts +3 -4
- package/dist/types/fqnRef.d.mts +2 -2
- package/dist/types/fqnRef.mjs +3 -3
- package/dist/types/index.d.mts +8 -8
- package/dist/types/index.mjs +150 -5
- package/dist/types/scalar.mjs +3 -2
- package/dist/utils/graphology/index.d.mts +1864 -0
- package/dist/utils/graphology/index.mjs +1 -0
- package/dist/utils/index.d.mts +11 -6
- package/dist/utils/index.mjs +21 -37
- package/dist/utils/iterable/index.d.mts +1 -1
- package/dist/utils/iterable/index.mjs +45 -7
- package/model/package.json +4 -0
- package/package.json +42 -24
- package/styles/package.json +4 -0
- package/types/package.json +4 -0
- package/utils/graphology/package.json +4 -0
- package/utils/package.json +4 -0
- package/dist/shared/core.6_Vp2iiN.mjs +0 -172
- package/dist/shared/core.CUw_2J9j.mjs +0 -47
- package/dist/shared/core.CzdwsPmY.d.mts +0 -69
- package/dist/shared/core.D-ZGWDDt.d.mts +0 -831
- package/dist/shared/core.DoM6aM9N.mjs +0 -7
- package/dist/shared/core.ILwny7BV.mjs +0 -38
- package/dist/theme/index.d.mts +0 -11
- package/dist/theme/index.mjs +0 -232
- package/src/builder/Builder.deployment.ts +0 -224
- package/src/builder/Builder.deploymentModel.ts +0 -449
- package/src/builder/Builder.element.ts +0 -241
- package/src/builder/Builder.model.ts +0 -494
- package/src/builder/Builder.ts +0 -946
- package/src/builder/Builder.view-common.ts +0 -273
- package/src/builder/Builder.view-deployment.ts +0 -135
- package/src/builder/Builder.view-element.ts +0 -202
- package/src/builder/Builder.views.ts +0 -399
- package/src/builder/Builder.with.ts +0 -156
- package/src/builder/_types.ts +0 -324
- package/src/builder/index.ts +0 -11
- package/src/compute-view/compute-view.ts +0 -80
- package/src/compute-view/deployment-view/_types.ts +0 -38
- package/src/compute-view/deployment-view/clean-connections.ts +0 -236
- package/src/compute-view/deployment-view/compute.ts +0 -94
- package/src/compute-view/deployment-view/memory/index.ts +0 -9
- package/src/compute-view/deployment-view/memory/memory.ts +0 -96
- package/src/compute-view/deployment-view/predicates/deploymentRefs-where.ts +0 -18
- package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +0 -154
- package/src/compute-view/deployment-view/predicates/index.ts +0 -8
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +0 -243
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +0 -70
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +0 -101
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +0 -95
- package/src/compute-view/deployment-view/predicates/relation-where.ts +0 -18
- package/src/compute-view/deployment-view/predicates/utils.ts +0 -282
- package/src/compute-view/deployment-view/predicates/wildcard.ts +0 -41
- package/src/compute-view/deployment-view/stages/stage-exclude.ts +0 -5
- package/src/compute-view/deployment-view/stages/stage-final.ts +0 -245
- package/src/compute-view/deployment-view/stages/stage-include.ts +0 -95
- package/src/compute-view/deployment-view/utils.ts +0 -297
- package/src/compute-view/dynamic-view/compute.ts +0 -312
- package/src/compute-view/element-view/_types.ts +0 -47
- package/src/compute-view/element-view/clean-connections.ts +0 -117
- package/src/compute-view/element-view/compute.ts +0 -324
- package/src/compute-view/element-view/memory/NodeGroup.ts +0 -31
- package/src/compute-view/element-view/memory/index.ts +0 -10
- package/src/compute-view/element-view/memory/memory.ts +0 -178
- package/src/compute-view/element-view/memory/stage-exclude.ts +0 -59
- package/src/compute-view/element-view/memory/stage-final.ts +0 -129
- package/src/compute-view/element-view/memory/stage-include.ts +0 -130
- package/src/compute-view/element-view/predicates/_utils.ts +0 -91
- package/src/compute-view/element-view/predicates/element-expand.ts +0 -29
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +0 -27
- package/src/compute-view/element-view/predicates/element-ref.ts +0 -24
- package/src/compute-view/element-view/predicates/relation-direct.ts +0 -321
- package/src/compute-view/element-view/predicates/relation-in-out.ts +0 -64
- package/src/compute-view/element-view/predicates/relation-in.ts +0 -115
- package/src/compute-view/element-view/predicates/relation-out.ts +0 -119
- package/src/compute-view/element-view/predicates/wildcard.ts +0 -88
- package/src/compute-view/element-view/utils.ts +0 -65
- package/src/compute-view/index.ts +0 -4
- package/src/compute-view/memory/AbstractMemory.ts +0 -45
- package/src/compute-view/memory/AbstractStageExclude.ts +0 -215
- package/src/compute-view/memory/AbstractStageInclude.ts +0 -200
- package/src/compute-view/memory/_types.ts +0 -148
- package/src/compute-view/memory/index.ts +0 -5
- package/src/compute-view/memory/ops.ts +0 -43
- package/src/compute-view/relationships-view/_types.ts +0 -16
- package/src/compute-view/relationships-view/compute.ts +0 -159
- package/src/compute-view/relationships-view/index.ts +0 -3
- package/src/compute-view/relationships-view/layout.ts +0 -358
- package/src/compute-view/relationships-view/utils.ts +0 -73
- package/src/compute-view/utils/ancestorsOfNode.ts +0 -19
- package/src/compute-view/utils/applyCustomElementProperties.ts +0 -107
- package/src/compute-view/utils/applyCustomRelationProperties.ts +0 -58
- package/src/compute-view/utils/applyViewRuleStyles.ts +0 -73
- package/src/compute-view/utils/buildComputedNodes.ts +0 -166
- package/src/compute-view/utils/buildElementNotations.ts +0 -64
- package/src/compute-view/utils/elementExpressionToPredicate.ts +0 -50
- package/src/compute-view/utils/link-nodes-with-edges.ts +0 -56
- package/src/compute-view/utils/merge-props-from-relationships.ts +0 -161
- package/src/compute-view/utils/relationExpressionToPredicates.ts +0 -55
- package/src/compute-view/utils/resolve-extended-views.ts +0 -85
- package/src/compute-view/utils/resolve-global-rules.ts +0 -88
- package/src/compute-view/utils/topological-sort.ts +0 -256
- package/src/compute-view/utils/view-hash.ts +0 -45
- package/src/compute-view/utils/with-readable-edges.ts +0 -40
- package/src/index.ts +0 -32
- package/src/model/DeploymentElementModel.ts +0 -712
- package/src/model/DeploymentModel.ts +0 -393
- package/src/model/ElementModel.ts +0 -316
- package/src/model/LikeC4Model.ts +0 -882
- package/src/model/RelationModel.ts +0 -152
- package/src/model/connection/Connection.ts +0 -72
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +0 -185
- package/src/model/connection/deployment/find.ts +0 -120
- package/src/model/connection/deployment/index.ts +0 -8
- package/src/model/connection/index.ts +0 -22
- package/src/model/connection/model/ConnectionModel.ts +0 -158
- package/src/model/connection/model/find.ts +0 -117
- package/src/model/connection/model/index.ts +0 -8
- package/src/model/connection/ops.ts +0 -276
- package/src/model/guards.ts +0 -77
- package/src/model/index.ts +0 -72
- package/src/model/types.ts +0 -67
- package/src/model/utils.ts +0 -66
- package/src/model/view/EdgeModel.ts +0 -121
- package/src/model/view/LikeC4ViewModel.ts +0 -361
- package/src/model/view/LikeC4ViewsFolder.ts +0 -151
- package/src/model/view/NodeModel.ts +0 -247
- package/src/theme/element.ts +0 -61
- package/src/theme/index.ts +0 -127
- package/src/theme/relationships.ts +0 -54
- package/src/types/RichText.ts +0 -205
- package/src/types/_aux.ts +0 -317
- package/src/types/_common.ts +0 -102
- package/src/types/const.ts +0 -34
- package/src/types/expression-model.ts +0 -294
- package/src/types/expression.ts +0 -313
- package/src/types/fqnRef.ts +0 -91
- package/src/types/geometry.ts +0 -159
- package/src/types/global.ts +0 -21
- package/src/types/index.ts +0 -44
- package/src/types/model-data.ts +0 -77
- package/src/types/model-deployment.ts +0 -78
- package/src/types/model-dump.ts +0 -79
- package/src/types/model-logical.ts +0 -126
- package/src/types/model-spec.ts +0 -88
- package/src/types/operators.ts +0 -156
- package/src/types/project.ts +0 -14
- package/src/types/scalar.ts +0 -162
- package/src/types/styles.ts +0 -122
- package/src/types/view-changes.ts +0 -32
- package/src/types/view-common.ts +0 -157
- package/src/types/view-computed.ts +0 -126
- package/src/types/view-layouted.ts +0 -94
- package/src/types/view-parsed.deployment.ts +0 -39
- package/src/types/view-parsed.dynamic.ts +0 -89
- package/src/types/view-parsed.element.ts +0 -65
- package/src/types/view.ts +0 -113
- package/src/utils/common-head.ts +0 -22
- package/src/utils/compare-natural.ts +0 -60
- package/src/utils/const.ts +0 -1
- package/src/utils/fqn.ts +0 -302
- package/src/utils/getOrCreate.ts +0 -8
- package/src/utils/guards.ts +0 -9
- package/src/utils/index.ts +0 -68
- package/src/utils/invariant.ts +0 -29
- package/src/utils/iterable/_types.ts +0 -5
- package/src/utils/iterable/filter.ts +0 -55
- package/src/utils/iterable/find.ts +0 -38
- package/src/utils/iterable/first.ts +0 -48
- package/src/utils/iterable/flat.ts +0 -17
- package/src/utils/iterable/head.ts +0 -22
- package/src/utils/iterable/index.ts +0 -15
- package/src/utils/iterable/map.ts +0 -40
- package/src/utils/iterable/reduce.ts +0 -24
- package/src/utils/iterable/some.ts +0 -36
- package/src/utils/iterable/to.ts +0 -19
- package/src/utils/iterable/unique.ts +0 -23
- package/src/utils/markdown/index.ts +0 -2
- package/src/utils/markdown/to-html.ts +0 -32
- package/src/utils/markdown/to-text.ts +0 -14
- package/src/utils/memoize-prop.ts +0 -30
- package/src/utils/mnemonist.ts +0 -9
- package/src/utils/object-hash.ts +0 -14
- package/src/utils/promises.ts +0 -24
- package/src/utils/relations.ts +0 -36
- package/src/utils/set.ts +0 -83
- package/src/utils/string-hash.ts +0 -16
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import { isArray, isString, map } from 'remeda'
|
|
2
|
-
import type { LiteralUnion, Simplify } from 'type-fest'
|
|
3
|
-
import {
|
|
4
|
-
type Any,
|
|
5
|
-
type AnyAux,
|
|
6
|
-
type AnyViewRuleStyle as ViewRuleStyle,
|
|
7
|
-
type AutoLayoutDirection,
|
|
8
|
-
type Expression,
|
|
9
|
-
type ModelRelationExpr,
|
|
10
|
-
type NonEmptyArray,
|
|
11
|
-
type WhereOperator,
|
|
12
|
-
ModelFqnExpr,
|
|
13
|
-
} from '../types'
|
|
14
|
-
import type { Participant, ParticipantOperator } from '../types/operators'
|
|
15
|
-
import type { AnyTypes, Types } from './_types'
|
|
16
|
-
|
|
17
|
-
export interface LikeC4ViewBuilder<
|
|
18
|
-
Types extends AnyTypes,
|
|
19
|
-
Fqn extends string,
|
|
20
|
-
TypedExpr,
|
|
21
|
-
ElementExpr extends string = ViewPredicate.ElementExpr<Fqn>,
|
|
22
|
-
Expr extends string = ViewPredicate.AllExpression<ElementExpr>,
|
|
23
|
-
> {
|
|
24
|
-
Types: Types
|
|
25
|
-
ElementExpr: ElementExpr
|
|
26
|
-
Expr: Expr
|
|
27
|
-
TypedExpr: TypedExpr
|
|
28
|
-
$expr(expr: Expr | TypedExpr): TypedExpr
|
|
29
|
-
include(...exprs: Expr[]): this
|
|
30
|
-
exclude(...exprs: Expr[]): this
|
|
31
|
-
style(rule: ViewRuleStyle<any>): this
|
|
32
|
-
autoLayout(layout: AutoLayoutDirection): this
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export namespace ViewPredicate {
|
|
36
|
-
export type ElementExpr<Fqn extends string> = '*' | Fqn | `${Fqn}.*` | `${Fqn}._` | `${Fqn}.**`
|
|
37
|
-
|
|
38
|
-
export type AllExpression<ElementExpr extends string> =
|
|
39
|
-
| ElementExpr
|
|
40
|
-
| `-> ${ElementExpr} ->`
|
|
41
|
-
| `-> ${ElementExpr}`
|
|
42
|
-
| `${ElementExpr} ->`
|
|
43
|
-
| `${ElementExpr} ${'->' | '<->'} ${ElementExpr}`
|
|
44
|
-
|
|
45
|
-
export type Expression<T extends AnyTypes> = T extends
|
|
46
|
-
Types<any, infer F extends string, any, any, any, any, any, any> ? AllExpression<ViewPredicate.ElementExpr<F>>
|
|
47
|
-
: never
|
|
48
|
-
|
|
49
|
-
export type ConnectionExpression<T extends AnyTypes> = T extends
|
|
50
|
-
Types<any, infer F extends string, any, any, any, any, any, any> ? `${F} -> ${F}`
|
|
51
|
-
: never
|
|
52
|
-
|
|
53
|
-
export type DeploymentExpression<T extends AnyTypes> = T extends
|
|
54
|
-
Types<any, any, any, any, any, any, any, infer F extends string> ? AllExpression<ViewPredicate.ElementExpr<F>>
|
|
55
|
-
: never
|
|
56
|
-
|
|
57
|
-
export type DeploymentConnectionExpression<T extends AnyTypes> = T extends
|
|
58
|
-
Types<any, any, any, any, any, any, any, infer F extends string> ? `${F} -> ${F}`
|
|
59
|
-
: never
|
|
60
|
-
|
|
61
|
-
export type WhereTag<Tag extends string> = `tag ${'is' | 'is not'} #${Tag}`
|
|
62
|
-
export type WhereKind<Kind extends string> = `kind ${'is' | 'is not'} ${Kind}`
|
|
63
|
-
export type WhereParticipant<Types extends AnyTypes> = `${Participant}.${
|
|
64
|
-
| WhereTag<Types['Tag']>
|
|
65
|
-
| WhereKind<Types['ElementKind']>}`
|
|
66
|
-
|
|
67
|
-
export type WhereEq<Types extends AnyTypes> =
|
|
68
|
-
| ViewPredicate.WhereTag<Types['Tag']>
|
|
69
|
-
| ViewPredicate.WhereKind<Types['ElementKind']>
|
|
70
|
-
| ViewPredicate.WhereKind<Types['DeploymentKind']>
|
|
71
|
-
| ViewPredicate.WhereParticipant<Types>
|
|
72
|
-
|
|
73
|
-
export type WhereOperator<Types extends AnyTypes> = ViewPredicate.WhereEq<Types> | {
|
|
74
|
-
and: NonEmptyArray<ViewPredicate.WhereOperator<Types>>
|
|
75
|
-
or?: never
|
|
76
|
-
not?: never
|
|
77
|
-
} | {
|
|
78
|
-
or: NonEmptyArray<ViewPredicate.WhereOperator<Types>>
|
|
79
|
-
and?: never
|
|
80
|
-
not?: never
|
|
81
|
-
} | {
|
|
82
|
-
not: ViewPredicate.WhereOperator<Types>
|
|
83
|
-
and?: never
|
|
84
|
-
or?: never
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export type Custom<Types extends AnyTypes> = {
|
|
88
|
-
where?: ViewPredicate.WhereOperator<Types>
|
|
89
|
-
with?: Simplify<
|
|
90
|
-
Omit<
|
|
91
|
-
ModelFqnExpr.Custom['custom'] & ModelRelationExpr.Custom['customRelation'],
|
|
92
|
-
'expr' | 'relation' | 'navigateTo'
|
|
93
|
-
> & {
|
|
94
|
-
navigateTo?: Types['ViewId']
|
|
95
|
-
}
|
|
96
|
-
>
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function parseWhere(where: ViewPredicate.WhereOperator<AnyTypes>): WhereOperator<Any> {
|
|
101
|
-
if (isString(where)) {
|
|
102
|
-
const op = where as LiteralUnion<ViewPredicate.WhereEq<AnyTypes>, string>
|
|
103
|
-
switch (true) {
|
|
104
|
-
case op.startsWith('tag is not #'):
|
|
105
|
-
return {
|
|
106
|
-
tag: {
|
|
107
|
-
neq: op.replace('tag is not #', ''),
|
|
108
|
-
},
|
|
109
|
-
}
|
|
110
|
-
case op.startsWith('tag is #'):
|
|
111
|
-
return {
|
|
112
|
-
tag: {
|
|
113
|
-
eq: op.replace('tag is #', ''),
|
|
114
|
-
},
|
|
115
|
-
}
|
|
116
|
-
case op.startsWith('kind is not '):
|
|
117
|
-
return {
|
|
118
|
-
kind: {
|
|
119
|
-
neq: op.replace('kind is not ', ''),
|
|
120
|
-
},
|
|
121
|
-
}
|
|
122
|
-
case op.startsWith('kind is '):
|
|
123
|
-
return {
|
|
124
|
-
kind: {
|
|
125
|
-
eq: op.replace('kind is ', ''),
|
|
126
|
-
},
|
|
127
|
-
}
|
|
128
|
-
case op.startsWith('source.'):
|
|
129
|
-
return {
|
|
130
|
-
operator: parseWhere(
|
|
131
|
-
op.replace('source.', '') as ViewPredicate.WhereOperator<AnyTypes>,
|
|
132
|
-
) as ParticipantOperator<AnyAux>['operator'],
|
|
133
|
-
participant: 'source',
|
|
134
|
-
}
|
|
135
|
-
case op.startsWith('target.'):
|
|
136
|
-
return {
|
|
137
|
-
operator: parseWhere(
|
|
138
|
-
op.replace('target.', '') as ViewPredicate.WhereOperator<AnyTypes>,
|
|
139
|
-
) as ParticipantOperator<AnyAux>['operator'],
|
|
140
|
-
participant: 'target',
|
|
141
|
-
}
|
|
142
|
-
default:
|
|
143
|
-
throw new Error(`Unknown where operator: ${where}`)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (where.and) {
|
|
148
|
-
return {
|
|
149
|
-
and: map(where.and, parseWhere),
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (where.or) {
|
|
153
|
-
return {
|
|
154
|
-
or: map(where.or, parseWhere),
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (where.not) {
|
|
158
|
-
return {
|
|
159
|
-
not: parseWhere(where.not),
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
throw new Error(`Unknown where operator: ${where}`)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function $include<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
|
|
167
|
-
...args:
|
|
168
|
-
| [B['Expr']]
|
|
169
|
-
| [B['TypedExpr']]
|
|
170
|
-
| [B['Expr'], ViewPredicate.Custom<B['Types']>]
|
|
171
|
-
): (b: B) => B {
|
|
172
|
-
return (b) => {
|
|
173
|
-
let expr = b.$expr(args[0])
|
|
174
|
-
if (args.length === 2) {
|
|
175
|
-
const condition = args[1].where ? parseWhere(args[1].where) : undefined
|
|
176
|
-
if (condition) {
|
|
177
|
-
expr = {
|
|
178
|
-
where: {
|
|
179
|
-
expr: expr as any,
|
|
180
|
-
condition,
|
|
181
|
-
},
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const custom = args[1].with
|
|
186
|
-
if (custom) {
|
|
187
|
-
const isElement = ModelFqnExpr.is(expr)
|
|
188
|
-
if (isElement) {
|
|
189
|
-
expr = {
|
|
190
|
-
custom: {
|
|
191
|
-
...custom,
|
|
192
|
-
expr: expr as any,
|
|
193
|
-
},
|
|
194
|
-
}
|
|
195
|
-
} else {
|
|
196
|
-
expr = {
|
|
197
|
-
customRelation: {
|
|
198
|
-
...custom,
|
|
199
|
-
expr: expr as any,
|
|
200
|
-
},
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
b.include(expr as any)
|
|
206
|
-
return b
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function $exclude<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
|
|
211
|
-
...args:
|
|
212
|
-
| [B['Expr']]
|
|
213
|
-
| [B['TypedExpr']]
|
|
214
|
-
| [B['Expr'], ViewPredicate.Custom<B['Types']>]
|
|
215
|
-
| [B['TypedExpr'], ViewPredicate.Custom<B['Types']>]
|
|
216
|
-
): (b: B) => B {
|
|
217
|
-
return (b) => {
|
|
218
|
-
let expr = b.$expr(args[0]) as Expression
|
|
219
|
-
if (args.length === 2 && args[1].where) {
|
|
220
|
-
const condition = parseWhere(args[1].where)
|
|
221
|
-
expr = {
|
|
222
|
-
where: {
|
|
223
|
-
expr: expr as any,
|
|
224
|
-
condition,
|
|
225
|
-
},
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
b.exclude(expr)
|
|
229
|
-
return b
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* @example
|
|
235
|
-
* builder.views(({ view, $style }, _) =>
|
|
236
|
-
* _(
|
|
237
|
-
* view('view1').with(
|
|
238
|
-
* $style('*', {
|
|
239
|
-
* color: 'red',
|
|
240
|
-
* }),
|
|
241
|
-
* $style(['bob', 'alice'], {
|
|
242
|
-
* color: 'blue',
|
|
243
|
-
* }),
|
|
244
|
-
* ),
|
|
245
|
-
* )
|
|
246
|
-
* )
|
|
247
|
-
*/
|
|
248
|
-
function $style<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
|
|
249
|
-
element: B['ElementExpr'] | B['TypedExpr'] | NonEmptyArray<B['ElementExpr']>,
|
|
250
|
-
{ notation, ...style }: ViewRuleStyle<any>['style'] & { notation?: string },
|
|
251
|
-
): (b: B) => B {
|
|
252
|
-
return (b) =>
|
|
253
|
-
b.style({
|
|
254
|
-
targets: (isArray(element) ? element : [element]).map(e => b.$expr(e as any) as ModelFqnExpr),
|
|
255
|
-
...(notation ? { notation } : {}),
|
|
256
|
-
style: {
|
|
257
|
-
...style,
|
|
258
|
-
},
|
|
259
|
-
})
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function $autoLayout<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(
|
|
263
|
-
layout: AutoLayoutDirection,
|
|
264
|
-
): (b: B) => B {
|
|
265
|
-
return (b) => b.autoLayout(layout)
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
type Op<T> = (b: T) => T
|
|
269
|
-
function $rules<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...rules: Op<B>[]): (b: B) => B {
|
|
270
|
-
return (b) => rules.reduce((b, rule) => rule(b), b)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export { $autoLayout, $exclude, $include, $rules, $style }
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { isString } from 'remeda'
|
|
2
|
-
import { type DeploymentFqn, type Expression } from '../types'
|
|
3
|
-
import type { AnyTypes, Types } from './_types'
|
|
4
|
-
import type { LikeC4ViewBuilder, ViewPredicate } from './Builder.view-common'
|
|
5
|
-
import type { ViewsBuilder } from './Builder.views'
|
|
6
|
-
|
|
7
|
-
export interface DeploymentViewBuilder<T extends AnyTypes>
|
|
8
|
-
extends LikeC4ViewBuilder<T, T['DeploymentFqn'], Types.ToExpression<T>>
|
|
9
|
-
{
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type DeploymentRulesBuilderOp<Types extends AnyTypes> = (
|
|
13
|
-
b: DeploymentViewBuilder<Types>,
|
|
14
|
-
) => DeploymentViewBuilder<Types>
|
|
15
|
-
|
|
16
|
-
export interface AddDeploymentViewRules<Id extends string> {
|
|
17
|
-
with<S extends AnyTypes>(
|
|
18
|
-
...rules: DeploymentRulesBuilderOp<S>[]
|
|
19
|
-
): (builder: ViewsBuilder<S>) => ViewsBuilder<Types.AddView<S, Id>>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Chainable builder to create element
|
|
24
|
-
*/
|
|
25
|
-
export interface AddDeploymentViewHelper {
|
|
26
|
-
<
|
|
27
|
-
const Id extends string,
|
|
28
|
-
T extends AnyTypes,
|
|
29
|
-
>(
|
|
30
|
-
id: Id,
|
|
31
|
-
): AddDeploymentViewRules<Id> & {
|
|
32
|
-
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
const Id extends string,
|
|
37
|
-
T extends AnyTypes,
|
|
38
|
-
>(
|
|
39
|
-
id: Id,
|
|
40
|
-
bulder: (b: DeploymentViewBuilder<T>) => DeploymentViewBuilder<T>,
|
|
41
|
-
): (builder: ViewsBuilder<T>) => ViewsBuilder<Types.AddView<T, Id>>
|
|
42
|
-
|
|
43
|
-
<
|
|
44
|
-
const Id extends string,
|
|
45
|
-
T extends AnyTypes,
|
|
46
|
-
>(
|
|
47
|
-
id: Id,
|
|
48
|
-
propsOrTitle: T['NewViewProps'] | string,
|
|
49
|
-
): AddDeploymentViewRules<Id> & {
|
|
50
|
-
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
<
|
|
54
|
-
const Id extends string,
|
|
55
|
-
T extends AnyTypes,
|
|
56
|
-
>(
|
|
57
|
-
id: Id,
|
|
58
|
-
propsOrTitle: T['NewViewProps'] | string,
|
|
59
|
-
bulder: (b: DeploymentViewBuilder<T>) => DeploymentViewBuilder<T>,
|
|
60
|
-
): (builder: ViewsBuilder<T>) => ViewsBuilder<Types.AddView<T, Id>>
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function $deploymentExpr<T extends AnyTypes>(
|
|
64
|
-
expr: ViewPredicate.DeploymentExpression<T> | Expression,
|
|
65
|
-
): Types.ToExpression<T> {
|
|
66
|
-
if (!isString(expr)) {
|
|
67
|
-
return expr as any
|
|
68
|
-
}
|
|
69
|
-
const asTypedDeploymentExpression = (expr: Expression): Types.ToExpression<T> => {
|
|
70
|
-
return expr as any
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (expr === '*') {
|
|
74
|
-
return asTypedDeploymentExpression({ wildcard: true })
|
|
75
|
-
}
|
|
76
|
-
if (expr.startsWith('->')) {
|
|
77
|
-
if (expr.endsWith('->')) {
|
|
78
|
-
return asTypedDeploymentExpression({
|
|
79
|
-
inout: $deploymentExpr(expr.replace(/->/g, '').trim()) as any,
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
return asTypedDeploymentExpression({
|
|
83
|
-
incoming: $deploymentExpr(expr.replace('-> ', '')) as any,
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
if (expr.endsWith(' ->')) {
|
|
87
|
-
return asTypedDeploymentExpression({
|
|
88
|
-
outgoing: $deploymentExpr(expr.replace(' ->', '')) as any,
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
if (expr.includes(' <-> ')) {
|
|
92
|
-
const [source, target] = expr.split(' <-> ')
|
|
93
|
-
return asTypedDeploymentExpression({
|
|
94
|
-
source: $deploymentExpr(source) as any,
|
|
95
|
-
target: $deploymentExpr(target) as any,
|
|
96
|
-
isBidirectional: true,
|
|
97
|
-
})
|
|
98
|
-
}
|
|
99
|
-
if (expr.includes(' -> ')) {
|
|
100
|
-
const [source, target] = expr.split(' -> ')
|
|
101
|
-
return asTypedDeploymentExpression({
|
|
102
|
-
source: $deploymentExpr(source) as any,
|
|
103
|
-
target: $deploymentExpr(target) as any,
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
if (expr.endsWith('._')) {
|
|
107
|
-
return asTypedDeploymentExpression({
|
|
108
|
-
ref: {
|
|
109
|
-
deployment: expr.replace('._', '') as DeploymentFqn,
|
|
110
|
-
},
|
|
111
|
-
selector: 'expanded',
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
if (expr.endsWith('.**')) {
|
|
115
|
-
return asTypedDeploymentExpression({
|
|
116
|
-
ref: {
|
|
117
|
-
deployment: expr.replace('.**', '') as DeploymentFqn,
|
|
118
|
-
},
|
|
119
|
-
selector: 'descendants',
|
|
120
|
-
})
|
|
121
|
-
}
|
|
122
|
-
if (expr.endsWith('.*')) {
|
|
123
|
-
return asTypedDeploymentExpression({
|
|
124
|
-
ref: {
|
|
125
|
-
deployment: expr.replace('.*', '') as DeploymentFqn,
|
|
126
|
-
},
|
|
127
|
-
selector: 'children',
|
|
128
|
-
})
|
|
129
|
-
}
|
|
130
|
-
return asTypedDeploymentExpression({
|
|
131
|
-
ref: {
|
|
132
|
-
deployment: expr as DeploymentFqn,
|
|
133
|
-
},
|
|
134
|
-
})
|
|
135
|
-
}
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { isString } from 'remeda'
|
|
2
|
-
import type { IsLiteral } from 'type-fest'
|
|
3
|
-
import { type Expression, type Fqn } from '../types'
|
|
4
|
-
import type { AnyTypes, Invalid, Types } from './_types'
|
|
5
|
-
import type { LikeC4ViewBuilder, ViewPredicate } from './Builder.view-common'
|
|
6
|
-
import type { ViewsBuilder } from './Builder.views'
|
|
7
|
-
|
|
8
|
-
export interface ElementViewBuilder<T extends AnyTypes>
|
|
9
|
-
extends LikeC4ViewBuilder<T, T['Fqn'], Expression<Types.ToAux<T>>>
|
|
10
|
-
{
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type ElementViewRulesBuilder<T extends AnyTypes> = (b: ElementViewBuilder<T>) => ElementViewBuilder<T>
|
|
14
|
-
|
|
15
|
-
export interface AddViewRules<Id extends string> {
|
|
16
|
-
with<S extends AnyTypes>(
|
|
17
|
-
...rules: ElementViewRulesBuilder<S>[]
|
|
18
|
-
): (builder: ViewsBuilder<S>) => ViewsBuilder<Types.AddView<S, Id>>
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface AddViewHelper {
|
|
22
|
-
<
|
|
23
|
-
const Id extends string,
|
|
24
|
-
T extends AnyTypes,
|
|
25
|
-
>(
|
|
26
|
-
id: Id,
|
|
27
|
-
): AddViewRules<Id> & {
|
|
28
|
-
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
const Id extends string,
|
|
33
|
-
T extends AnyTypes,
|
|
34
|
-
>(
|
|
35
|
-
id: Id,
|
|
36
|
-
builder: (b: ElementViewBuilder<T>) => ElementViewBuilder<T>,
|
|
37
|
-
): AddViewRules<Id> & {
|
|
38
|
-
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
const Id extends string,
|
|
43
|
-
T extends AnyTypes,
|
|
44
|
-
>(
|
|
45
|
-
id: Id,
|
|
46
|
-
propsOrTitle: NoInfer<T['NewViewProps']> | string,
|
|
47
|
-
): AddViewRules<Id> & {
|
|
48
|
-
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
<
|
|
52
|
-
const Id extends string,
|
|
53
|
-
T extends AnyTypes,
|
|
54
|
-
>(
|
|
55
|
-
id: Id,
|
|
56
|
-
propsOrTitle: NoInfer<T['NewViewProps']> | string | undefined,
|
|
57
|
-
builder: (b: ElementViewBuilder<T>) => ElementViewBuilder<T>,
|
|
58
|
-
): AddViewRules<Id> & {
|
|
59
|
-
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
type ValidFqn<T extends AnyTypes> = IsLiteral<T['Fqn']> extends true ? T['Fqn']
|
|
64
|
-
: Invalid<'Fqn must be a literal'>
|
|
65
|
-
|
|
66
|
-
export interface AddViewOfHelper {
|
|
67
|
-
<
|
|
68
|
-
const Id extends string,
|
|
69
|
-
T extends AnyTypes,
|
|
70
|
-
>(
|
|
71
|
-
id: Id,
|
|
72
|
-
of: ValidFqn<T>,
|
|
73
|
-
): (builder: ViewsBuilder<T>) => ViewsBuilder<Types.AddView<T, Id>>
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
-
const Id extends string,
|
|
77
|
-
T extends AnyTypes,
|
|
78
|
-
>(
|
|
79
|
-
id: Id,
|
|
80
|
-
of: ValidFqn<T>,
|
|
81
|
-
propsOrTitle: T['NewViewProps'] | string | ElementViewRulesBuilder<T>,
|
|
82
|
-
): (builder: ViewsBuilder<T>) => ViewsBuilder<Types.AddView<T, Id>>
|
|
83
|
-
|
|
84
|
-
<
|
|
85
|
-
const Id extends string,
|
|
86
|
-
T extends AnyTypes,
|
|
87
|
-
>(
|
|
88
|
-
id: Id,
|
|
89
|
-
of: ValidFqn<T>,
|
|
90
|
-
propsOrTitle: NoInfer<T>['NewViewProps'] | string,
|
|
91
|
-
builder: (b: ElementViewBuilder<T>) => ElementViewBuilder<T>,
|
|
92
|
-
): (builder: ViewsBuilder<T>) => ViewsBuilder<Types.AddView<T, Id>>
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface TypedAddViewOfHelper<A extends AnyTypes> {
|
|
96
|
-
<
|
|
97
|
-
const Id extends string,
|
|
98
|
-
T extends AnyTypes,
|
|
99
|
-
>(
|
|
100
|
-
id: Id,
|
|
101
|
-
of: ValidFqn<A>,
|
|
102
|
-
): AddViewRules<Id> & {
|
|
103
|
-
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
const Id extends string,
|
|
108
|
-
T extends AnyTypes,
|
|
109
|
-
>(
|
|
110
|
-
id: Id,
|
|
111
|
-
of: ValidFqn<A>,
|
|
112
|
-
builder: ((b: ElementViewBuilder<A>) => ElementViewBuilder<A>) | A['NewViewProps'] | string,
|
|
113
|
-
): AddViewRules<Id> & {
|
|
114
|
-
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
<
|
|
118
|
-
const Id extends string,
|
|
119
|
-
T extends AnyTypes,
|
|
120
|
-
>(
|
|
121
|
-
id: Id,
|
|
122
|
-
of: ValidFqn<A>,
|
|
123
|
-
propsOrTitle: A['NewViewProps'] | string,
|
|
124
|
-
builder: (b: ElementViewBuilder<A>) => ElementViewBuilder<A>,
|
|
125
|
-
): AddViewRules<Id> & {
|
|
126
|
-
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
// To hook types
|
|
130
|
-
const asTypedExpr = <T extends AnyTypes>(expr: Expression): Expression<Types.ToAux<T>> => {
|
|
131
|
-
return expr as Expression<Types.ToAux<T>>
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export function $expr<T extends AnyTypes>(
|
|
135
|
-
expr: ViewPredicate.Expression<T> | Expression,
|
|
136
|
-
): Expression<Types.ToAux<T>> {
|
|
137
|
-
if (!isString(expr)) {
|
|
138
|
-
return expr as Expression<Types.ToAux<T>>
|
|
139
|
-
}
|
|
140
|
-
if (expr === '*') {
|
|
141
|
-
return asTypedExpr({ wildcard: true })
|
|
142
|
-
}
|
|
143
|
-
if (expr.startsWith('->')) {
|
|
144
|
-
if (expr.endsWith('->')) {
|
|
145
|
-
return asTypedExpr({
|
|
146
|
-
inout: $expr(expr.replace(/->/g, '').trim()) as any,
|
|
147
|
-
})
|
|
148
|
-
}
|
|
149
|
-
return asTypedExpr({
|
|
150
|
-
incoming: $expr(expr.replace('-> ', '')) as any,
|
|
151
|
-
})
|
|
152
|
-
}
|
|
153
|
-
if (expr.endsWith(' ->')) {
|
|
154
|
-
return asTypedExpr({
|
|
155
|
-
outgoing: $expr(expr.replace(' ->', '')) as any,
|
|
156
|
-
})
|
|
157
|
-
}
|
|
158
|
-
if (expr.includes(' <-> ')) {
|
|
159
|
-
const [source, target] = expr.split(' <-> ')
|
|
160
|
-
return asTypedExpr({
|
|
161
|
-
source: $expr(source) as any,
|
|
162
|
-
target: $expr(target) as any,
|
|
163
|
-
isBidirectional: true,
|
|
164
|
-
})
|
|
165
|
-
}
|
|
166
|
-
if (expr.includes(' -> ')) {
|
|
167
|
-
const [source, target] = expr.split(' -> ')
|
|
168
|
-
return asTypedExpr({
|
|
169
|
-
source: $expr(source) as any,
|
|
170
|
-
target: $expr(target) as any,
|
|
171
|
-
})
|
|
172
|
-
}
|
|
173
|
-
if (expr.endsWith('._')) {
|
|
174
|
-
return asTypedExpr({
|
|
175
|
-
ref: {
|
|
176
|
-
model: expr.replace('._', '') as Fqn,
|
|
177
|
-
},
|
|
178
|
-
selector: 'expanded',
|
|
179
|
-
})
|
|
180
|
-
}
|
|
181
|
-
if (expr.endsWith('.**')) {
|
|
182
|
-
return asTypedExpr({
|
|
183
|
-
ref: {
|
|
184
|
-
model: expr.replace('.**', '') as Fqn,
|
|
185
|
-
},
|
|
186
|
-
selector: 'descendants',
|
|
187
|
-
})
|
|
188
|
-
}
|
|
189
|
-
if (expr.endsWith('.*')) {
|
|
190
|
-
return asTypedExpr({
|
|
191
|
-
ref: {
|
|
192
|
-
model: expr.replace('.*', '') as Fqn,
|
|
193
|
-
},
|
|
194
|
-
selector: 'children',
|
|
195
|
-
})
|
|
196
|
-
}
|
|
197
|
-
return asTypedExpr({
|
|
198
|
-
ref: {
|
|
199
|
-
model: expr as any as Fqn,
|
|
200
|
-
},
|
|
201
|
-
})
|
|
202
|
-
}
|