@likec4/core 1.20.0 → 1.20.2
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.cjs +6 -6
- package/dist/builder/index.d.cts +3 -3
- package/dist/builder/index.d.mts +3 -3
- package/dist/builder/index.d.ts +3 -3
- package/dist/builder/index.mjs +6 -6
- package/dist/compute-view/index.cjs +5 -5
- package/dist/compute-view/index.d.cts +4 -4
- package/dist/compute-view/index.d.mts +4 -4
- package/dist/compute-view/index.d.ts +4 -4
- package/dist/compute-view/index.mjs +6 -6
- package/dist/index.cjs +71 -573
- package/dist/index.d.cts +9 -133
- package/dist/index.d.mts +9 -133
- package/dist/index.d.ts +9 -133
- package/dist/index.mjs +8 -512
- package/dist/model/index.cjs +1 -1
- package/dist/model/index.d.cts +5 -5
- package/dist/model/index.d.mts +5 -5
- package/dist/model/index.d.ts +5 -5
- package/dist/model/index.mjs +1 -1
- package/dist/shared/{core.DunIMHRf.mjs → core.0PxLtLpP.mjs} +1 -1
- package/dist/shared/{core.BvdNMbcA.d.cts → core.88YY6vtF.d.mts} +2 -2
- package/dist/shared/{core.ByNgh-mC.d.cts → core.BIZD3l1g.d.cts} +1 -1
- package/dist/shared/{core.D74xkKkG.d.ts → core.BJfn72tj.d.cts} +5 -0
- package/dist/shared/{core.D74xkKkG.d.cts → core.BJfn72tj.d.mts} +5 -0
- package/dist/shared/{core.D74xkKkG.d.mts → core.BJfn72tj.d.ts} +5 -0
- package/dist/shared/{core.M-JWF7SS.mjs → core.Bezy7K65.mjs} +1 -1
- package/dist/shared/{core.D_Gc58Gt.d.ts → core.Bs71hdR4.d.ts} +2 -1
- package/dist/shared/{core.D6-fWbM3.d.ts → core.BtISRjMA.d.ts} +1 -1
- package/dist/shared/{core.B72vUaNB.d.cts → core.C0ygs98j.d.cts} +2 -1
- package/dist/shared/core.CCyhaU-4.mjs +14819 -0
- package/dist/shared/{core.DsoCu540.cjs → core.CKYxnFEl.cjs} +1 -1
- package/dist/shared/{core.Damrzla-.d.ts → core.CNUzoKM7.d.ts} +2 -2
- package/dist/shared/{core.sLaWHBjR.d.mts → core.CajOK_t3.d.mts} +1 -1
- package/dist/shared/{core.BdbFkE_p.d.cts → core.Cmfo_N4F.d.mts} +3 -3
- package/dist/shared/{core.jy6z2iRn.d.mts → core.CwZmAghJ.d.cts} +3 -3
- package/dist/shared/{core.ZWiGANIJ.d.ts → core.D4wZW7zR.d.ts} +3 -3
- package/dist/shared/{core.gv1bMwCC.cjs → core.Db_OTRdC.cjs} +1 -1
- package/dist/shared/{core.Dfzrh1VA.d.mts → core.DjMYkPMQ.d.mts} +2 -1
- package/dist/shared/{core.BGus30EM.cjs → core.DxJ1KbOs.cjs} +48 -643
- package/dist/shared/{core.m3rCQAv6.mjs → core.El-gigOM.mjs} +1 -1
- package/dist/shared/core.FACQZmma.cjs +14874 -0
- package/dist/shared/{core.BRuJ3Wzf.d.mts → core.Lh2RFJf1.d.cts} +2 -2
- package/dist/shared/{core.CqCTxzMY.mjs → core.PYycpzvA.mjs} +28 -619
- package/dist/shared/{core.B2QYWlYe.cjs → core.uxHtIZaH.cjs} +1 -1
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +4 -4
- package/dist/types/index.d.mts +4 -4
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.mjs +1 -1
- package/dist/utils/index.cjs +6 -2
- package/dist/utils/index.d.cts +129 -145
- package/dist/utils/index.d.mts +129 -145
- package/dist/utils/index.d.ts +129 -145
- package/dist/utils/index.mjs +3 -3
- package/package.json +7 -6
- package/src/compute-view/deployment-view/clean-connections.ts +1 -1
- package/src/compute-view/deployment-view/stages/stage-final.ts +1 -1
- package/src/compute-view/element-view/__test__/fixture.ts +2 -0
- package/src/compute-view/element-view/compute.ts +1 -1
- package/src/compute-view/element-view/memory/memory.ts +2 -2
- package/src/compute-view/memory/ops.ts +1 -1
- package/src/compute-view/relationships-view/layout.ts +1 -1
- package/src/compute-view/relationships-view/utils.ts +1 -1
- package/src/compute-view/utils/applyCustomElementProperties.ts +9 -6
- package/src/compute-view/utils/applyViewRuleStyles.ts +7 -4
- package/src/index.ts +0 -8
- package/src/model/DeploymentModel.ts +1 -1
- package/src/model/LikeC4Model.ts +3 -3
- package/src/types/element.ts +7 -2
- package/src/types/expression.ts +1 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/set.ts +5 -2
- package/dist/shared/core.BxvDITEI.mjs +0 -859
- package/dist/shared/core.C9DCnJh8.cjs +0 -908
- package/src/builder/Builder-style1.test-d.ts +0 -190
- package/src/builder/Builder-style2.test-d.ts +0 -175
- package/src/compute-view/utils/uniqueTags.test.ts +0 -42
- package/src/model/LikeC4Model.test-d.ts +0 -152
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf, test } from 'vitest'
|
|
2
|
-
import type { LikeC4Model } from '../model/LikeC4Model'
|
|
3
|
-
import type { ParsedLikeC4Model } from '../types'
|
|
4
|
-
import { Builder } from './Builder'
|
|
5
|
-
|
|
6
|
-
test('Builder types - style 1', () => {
|
|
7
|
-
const {
|
|
8
|
-
model: {
|
|
9
|
-
model,
|
|
10
|
-
actor,
|
|
11
|
-
system,
|
|
12
|
-
component,
|
|
13
|
-
relTo,
|
|
14
|
-
},
|
|
15
|
-
deployment: {
|
|
16
|
-
deployment,
|
|
17
|
-
instanceOf,
|
|
18
|
-
env,
|
|
19
|
-
vm,
|
|
20
|
-
},
|
|
21
|
-
views: {
|
|
22
|
-
deploymentView,
|
|
23
|
-
views,
|
|
24
|
-
view,
|
|
25
|
-
viewOf,
|
|
26
|
-
$rules,
|
|
27
|
-
$include,
|
|
28
|
-
},
|
|
29
|
-
builder,
|
|
30
|
-
} = Builder.forSpecification({
|
|
31
|
-
elements: {
|
|
32
|
-
actor: {
|
|
33
|
-
style: {
|
|
34
|
-
shape: 'person',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
system: {},
|
|
38
|
-
component: {},
|
|
39
|
-
},
|
|
40
|
-
deployments: {
|
|
41
|
-
env: {},
|
|
42
|
-
vm: {},
|
|
43
|
-
},
|
|
44
|
-
relationships: {
|
|
45
|
-
like: {},
|
|
46
|
-
dislike: {},
|
|
47
|
-
},
|
|
48
|
-
tags: ['tag1', 'tag2', 'tag1'],
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
const m = builder
|
|
52
|
-
.with(
|
|
53
|
-
model(
|
|
54
|
-
actor('alice'),
|
|
55
|
-
actor('bob'),
|
|
56
|
-
system('cloud').with(
|
|
57
|
-
component('backend').with(
|
|
58
|
-
component('api'),
|
|
59
|
-
component('db'),
|
|
60
|
-
),
|
|
61
|
-
component('frontend').with(
|
|
62
|
-
relTo('cloud.backend.api'),
|
|
63
|
-
),
|
|
64
|
-
),
|
|
65
|
-
),
|
|
66
|
-
deployment(
|
|
67
|
-
env('prod').with(
|
|
68
|
-
vm('vm1'),
|
|
69
|
-
),
|
|
70
|
-
env('prod.vm2'),
|
|
71
|
-
env('dev').with(
|
|
72
|
-
vm('vm1'),
|
|
73
|
-
instanceOf('cloud.backend.api'),
|
|
74
|
-
instanceOf(
|
|
75
|
-
'wrong',
|
|
76
|
-
// @ts-expect-error
|
|
77
|
-
'non-existing',
|
|
78
|
-
),
|
|
79
|
-
vm('vm2'),
|
|
80
|
-
),
|
|
81
|
-
),
|
|
82
|
-
views(
|
|
83
|
-
view(
|
|
84
|
-
'view',
|
|
85
|
-
// @ts-expect-error
|
|
86
|
-
$include('wrong'),
|
|
87
|
-
), // rules inside
|
|
88
|
-
view(
|
|
89
|
-
'view',
|
|
90
|
-
// @ts-expect-error #tag22 is not defined
|
|
91
|
-
$include('cloud.backend', {
|
|
92
|
-
where: 'tag is #tag22',
|
|
93
|
-
}),
|
|
94
|
-
),
|
|
95
|
-
// using with
|
|
96
|
-
view('view').with(
|
|
97
|
-
// @ts-expect-error
|
|
98
|
-
$include('wrong'),
|
|
99
|
-
// @ts-expect-error
|
|
100
|
-
$style('wrong', { color: 'red' }),
|
|
101
|
-
),
|
|
102
|
-
),
|
|
103
|
-
views(
|
|
104
|
-
viewOf('view-of', 'cloud.backend.api'),
|
|
105
|
-
// @ts-expect-error
|
|
106
|
-
viewOf('view-of', 'wrong'),
|
|
107
|
-
viewOf(
|
|
108
|
-
'view-of',
|
|
109
|
-
'cloud.backend.api',
|
|
110
|
-
$rules(
|
|
111
|
-
$include('* -> *'),
|
|
112
|
-
// @ts-expect-error
|
|
113
|
-
$include('wrong'),
|
|
114
|
-
),
|
|
115
|
-
),
|
|
116
|
-
viewOf(
|
|
117
|
-
'view-of',
|
|
118
|
-
// @ts-expect-error
|
|
119
|
-
'-cloud.backend.api',
|
|
120
|
-
'Title',
|
|
121
|
-
),
|
|
122
|
-
viewOf(
|
|
123
|
-
'view-of',
|
|
124
|
-
// @ts-expect-error
|
|
125
|
-
'-cloud.backend.api',
|
|
126
|
-
$rules(),
|
|
127
|
-
),
|
|
128
|
-
viewOf(
|
|
129
|
-
'view-of',
|
|
130
|
-
'cloud.backend.api',
|
|
131
|
-
{ title: 'asdasd' },
|
|
132
|
-
$rules(
|
|
133
|
-
$include('* -> *'),
|
|
134
|
-
// @ts-expect-error
|
|
135
|
-
$include('wrong'),
|
|
136
|
-
),
|
|
137
|
-
),
|
|
138
|
-
),
|
|
139
|
-
views(
|
|
140
|
-
deploymentView(
|
|
141
|
-
'deployment',
|
|
142
|
-
$rules(
|
|
143
|
-
// @ts-expect-error
|
|
144
|
-
$include('pr'),
|
|
145
|
-
),
|
|
146
|
-
),
|
|
147
|
-
deploymentView(
|
|
148
|
-
'deployment',
|
|
149
|
-
'Title',
|
|
150
|
-
$rules(
|
|
151
|
-
// @ts-expect-error
|
|
152
|
-
$include('pr'),
|
|
153
|
-
),
|
|
154
|
-
),
|
|
155
|
-
deploymentView('deployment').with(
|
|
156
|
-
// @ts-expect-error
|
|
157
|
-
$include('pr'),
|
|
158
|
-
),
|
|
159
|
-
),
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
expectTypeOf(m.Types.Fqn).toEqualTypeOf(
|
|
163
|
-
'' as 'alice' | 'bob' | 'cloud' | 'cloud.backend' | 'cloud.backend.api' | 'cloud.backend.db' | 'cloud.frontend',
|
|
164
|
-
)
|
|
165
|
-
expectTypeOf(m.Types.ViewId).toEqualTypeOf(
|
|
166
|
-
'' as 'view' | 'view-of' | 'deployment',
|
|
167
|
-
)
|
|
168
|
-
expectTypeOf(m.Types.DeploymentFqn).toEqualTypeOf(
|
|
169
|
-
'' as 'prod' | 'dev' | 'prod.vm1' | 'prod.vm2' | 'dev.vm1' | 'dev.vm2' | 'dev.api' | 'dev.wrong',
|
|
170
|
-
)
|
|
171
|
-
|
|
172
|
-
expectTypeOf(m.build()).toEqualTypeOf(
|
|
173
|
-
{} as ParsedLikeC4Model<
|
|
174
|
-
'actor' | 'system' | 'component',
|
|
175
|
-
'like' | 'dislike',
|
|
176
|
-
'tag1' | 'tag2',
|
|
177
|
-
'alice' | 'bob' | 'cloud' | 'cloud.backend' | 'cloud.backend.api' | 'cloud.backend.db' | 'cloud.frontend',
|
|
178
|
-
'view' | 'view-of' | 'deployment',
|
|
179
|
-
'prod' | 'dev' | 'prod.vm1' | 'prod.vm2' | 'dev.vm1' | 'dev.vm2' | 'dev.api' | 'dev.wrong'
|
|
180
|
-
>,
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
expectTypeOf(m.toLikeC4Model()).toEqualTypeOf(
|
|
184
|
-
{} as LikeC4Model.Computed<
|
|
185
|
-
'alice' | 'bob' | 'cloud' | 'cloud.backend' | 'cloud.backend.api' | 'cloud.backend.db' | 'cloud.frontend',
|
|
186
|
-
'prod' | 'dev' | 'prod.vm1' | 'prod.vm2' | 'dev.vm1' | 'dev.vm2' | 'dev.api' | 'dev.wrong',
|
|
187
|
-
'view' | 'view-of' | 'deployment'
|
|
188
|
-
>,
|
|
189
|
-
)
|
|
190
|
-
})
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf, test } from 'vitest'
|
|
2
|
-
import type { LikeC4Model } from '../model/LikeC4Model'
|
|
3
|
-
import type { ParsedLikeC4Model } from '../types'
|
|
4
|
-
import { Builder } from './Builder'
|
|
5
|
-
|
|
6
|
-
test('Builder types - style 2', () => {
|
|
7
|
-
const m = Builder
|
|
8
|
-
.specification({
|
|
9
|
-
elements: {
|
|
10
|
-
actor: {
|
|
11
|
-
style: {
|
|
12
|
-
shape: 'person',
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
system: {},
|
|
16
|
-
component: {},
|
|
17
|
-
},
|
|
18
|
-
deployments: {
|
|
19
|
-
env: {},
|
|
20
|
-
vm: {},
|
|
21
|
-
},
|
|
22
|
-
relationships: {
|
|
23
|
-
like: {},
|
|
24
|
-
dislike: {},
|
|
25
|
-
},
|
|
26
|
-
tags: ['tag1', 'tag2', 'tag1'],
|
|
27
|
-
})
|
|
28
|
-
.model(({ actor, system, component, relTo }, _) =>
|
|
29
|
-
_(
|
|
30
|
-
actor('alice'),
|
|
31
|
-
actor('bob'),
|
|
32
|
-
system('cloud').with(
|
|
33
|
-
component('backend').with(
|
|
34
|
-
component('api'),
|
|
35
|
-
component('db'),
|
|
36
|
-
),
|
|
37
|
-
component('frontend').with(
|
|
38
|
-
// @ts-expect-error
|
|
39
|
-
relTo('non-existing'),
|
|
40
|
-
),
|
|
41
|
-
),
|
|
42
|
-
)
|
|
43
|
-
)
|
|
44
|
-
.deployment(({ env, vm, instanceOf }, _) =>
|
|
45
|
-
_(
|
|
46
|
-
env('prod').with(
|
|
47
|
-
vm('vm1'),
|
|
48
|
-
vm('vm2'),
|
|
49
|
-
),
|
|
50
|
-
env('dev').with(
|
|
51
|
-
vm('vm1'),
|
|
52
|
-
instanceOf('cloud.backend.api'),
|
|
53
|
-
instanceOf(
|
|
54
|
-
'wrong',
|
|
55
|
-
// @ts-expect-error
|
|
56
|
-
'non-existing',
|
|
57
|
-
),
|
|
58
|
-
vm('vm2'),
|
|
59
|
-
),
|
|
60
|
-
)
|
|
61
|
-
)
|
|
62
|
-
// Test Element View
|
|
63
|
-
.views(({ view, $include, $style }, _) =>
|
|
64
|
-
_(
|
|
65
|
-
// rules inside
|
|
66
|
-
view(
|
|
67
|
-
'view',
|
|
68
|
-
// @ts-expect-error
|
|
69
|
-
$include('wrong'),
|
|
70
|
-
// @ts-expect-error #tag22 is not defined
|
|
71
|
-
$include('cloud.backend', {
|
|
72
|
-
where: 'tag is #tag22',
|
|
73
|
-
}),
|
|
74
|
-
),
|
|
75
|
-
// using with
|
|
76
|
-
view('view').with(
|
|
77
|
-
// @ts-expect-error
|
|
78
|
-
$include('wrong'),
|
|
79
|
-
// @ts-expect-error
|
|
80
|
-
$style('wrong', { color: 'red' }),
|
|
81
|
-
),
|
|
82
|
-
)
|
|
83
|
-
)
|
|
84
|
-
// Test Element View Of
|
|
85
|
-
.views(({ viewOf, $rules, $include }, _) =>
|
|
86
|
-
_(
|
|
87
|
-
viewOf('view-of', 'cloud.backend'),
|
|
88
|
-
// @ts-expect-error
|
|
89
|
-
viewOf('view-of', 'wrong'),
|
|
90
|
-
viewOf(
|
|
91
|
-
'view-of',
|
|
92
|
-
'cloud.backend.api',
|
|
93
|
-
$rules(
|
|
94
|
-
// @ts-expect-error
|
|
95
|
-
$include('wrong'),
|
|
96
|
-
),
|
|
97
|
-
),
|
|
98
|
-
viewOf(
|
|
99
|
-
'view-of',
|
|
100
|
-
'cloud.backend.api',
|
|
101
|
-
$rules(
|
|
102
|
-
// @ts-expect-error
|
|
103
|
-
$include('wrong'),
|
|
104
|
-
),
|
|
105
|
-
).with(
|
|
106
|
-
$include('* -> alice.*'),
|
|
107
|
-
// @ts-expect-error
|
|
108
|
-
$include('wrong'),
|
|
109
|
-
),
|
|
110
|
-
viewOf(
|
|
111
|
-
'view-of',
|
|
112
|
-
// @ts-expect-error
|
|
113
|
-
'cloud.backensd.api',
|
|
114
|
-
'Title',
|
|
115
|
-
).with(
|
|
116
|
-
$include('* -> alice.*'),
|
|
117
|
-
// @ts-expect-error
|
|
118
|
-
$include('wrong'),
|
|
119
|
-
),
|
|
120
|
-
)
|
|
121
|
-
)
|
|
122
|
-
// Test Deployment View
|
|
123
|
-
.views(({ deploymentView, $rules, $include }, _) =>
|
|
124
|
-
_(
|
|
125
|
-
deploymentView(
|
|
126
|
-
'deployment',
|
|
127
|
-
$rules(
|
|
128
|
-
// @ts-expect-error
|
|
129
|
-
$include('pr'),
|
|
130
|
-
),
|
|
131
|
-
),
|
|
132
|
-
deploymentView(
|
|
133
|
-
'deployment',
|
|
134
|
-
'Title',
|
|
135
|
-
$rules(
|
|
136
|
-
// @ts-expect-error
|
|
137
|
-
$include('pr'),
|
|
138
|
-
),
|
|
139
|
-
),
|
|
140
|
-
deploymentView('deployment').with(
|
|
141
|
-
// @ts-expect-error
|
|
142
|
-
$include('pr'),
|
|
143
|
-
),
|
|
144
|
-
)
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
expectTypeOf(m.Types.Fqn).toEqualTypeOf(
|
|
148
|
-
'' as 'alice' | 'bob' | 'cloud' | 'cloud.backend' | 'cloud.backend.api' | 'cloud.backend.db' | 'cloud.frontend',
|
|
149
|
-
)
|
|
150
|
-
expectTypeOf(m.Types.ViewId).toEqualTypeOf(
|
|
151
|
-
'' as 'view' | 'view-of' | 'deployment',
|
|
152
|
-
)
|
|
153
|
-
expectTypeOf(m.Types.DeploymentFqn).toEqualTypeOf(
|
|
154
|
-
'' as 'prod' | 'dev' | 'prod.vm1' | 'prod.vm2' | 'dev.vm1' | 'dev.vm2' | 'dev.api' | 'dev.wrong',
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
expectTypeOf(m.build()).toEqualTypeOf(
|
|
158
|
-
{} as ParsedLikeC4Model<
|
|
159
|
-
'actor' | 'system' | 'component',
|
|
160
|
-
'like' | 'dislike',
|
|
161
|
-
'tag1' | 'tag2',
|
|
162
|
-
'alice' | 'bob' | 'cloud' | 'cloud.backend' | 'cloud.backend.api' | 'cloud.backend.db' | 'cloud.frontend',
|
|
163
|
-
'view' | 'view-of' | 'deployment',
|
|
164
|
-
'prod' | 'dev' | 'prod.vm1' | 'prod.vm2' | 'dev.vm1' | 'dev.vm2' | 'dev.api' | 'dev.wrong'
|
|
165
|
-
>,
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
expectTypeOf(m.toLikeC4Model()).toEqualTypeOf(
|
|
169
|
-
{} as LikeC4Model.Computed<
|
|
170
|
-
'alice' | 'bob' | 'cloud' | 'cloud.backend' | 'cloud.backend.api' | 'cloud.backend.db' | 'cloud.frontend',
|
|
171
|
-
'prod' | 'dev' | 'prod.vm1' | 'prod.vm2' | 'dev.vm1' | 'dev.vm2' | 'dev.api' | 'dev.wrong',
|
|
172
|
-
'view' | 'view-of' | 'deployment'
|
|
173
|
-
>,
|
|
174
|
-
)
|
|
175
|
-
})
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { uniqueTags } from './uniqueTags'
|
|
3
|
-
|
|
4
|
-
describe('uniqueTags function', () => {
|
|
5
|
-
it('returns unique tags from an array of elements', () => {
|
|
6
|
-
const input = [
|
|
7
|
-
{ tags: ['tag1', 'tag2', 'tag3'] },
|
|
8
|
-
{ tags: ['tag2', 'tag3', 'tag4'] },
|
|
9
|
-
{ tags: ['tag3', 'tag4', 'tag5'] }
|
|
10
|
-
] as const
|
|
11
|
-
const result = uniqueTags(input)
|
|
12
|
-
expect(result).toEqual(['tag1', 'tag2', 'tag3', 'tag4', 'tag5'])
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('should return unique tags naturally sorted', () => {
|
|
16
|
-
const input = [
|
|
17
|
-
{ tags: ['tag1', 'tag20', 'tag30'] },
|
|
18
|
-
{ tags: ['tag2', 'tag23', 'tag34'] },
|
|
19
|
-
{ tags: ['tag3'] }
|
|
20
|
-
] as const
|
|
21
|
-
const result = uniqueTags(input)
|
|
22
|
-
expect(result).toEqual([
|
|
23
|
-
'tag1',
|
|
24
|
-
'tag2',
|
|
25
|
-
'tag3',
|
|
26
|
-
'tag20',
|
|
27
|
-
'tag23',
|
|
28
|
-
'tag30',
|
|
29
|
-
'tag34'
|
|
30
|
-
])
|
|
31
|
-
// ].sort(compareNatural))
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it('returns null if the tags array is null', () => {
|
|
35
|
-
const input = [
|
|
36
|
-
{ tags: null },
|
|
37
|
-
{}
|
|
38
|
-
]
|
|
39
|
-
const result = uniqueTags(input)
|
|
40
|
-
expect(result).toBeNull()
|
|
41
|
-
})
|
|
42
|
-
})
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf, test } from 'vitest'
|
|
2
|
-
import { Builder } from '../builder'
|
|
3
|
-
import type { ComputedView, Fqn, ViewId } from '../types'
|
|
4
|
-
import { LikeC4Model } from './LikeC4Model'
|
|
5
|
-
|
|
6
|
-
test('LikeC4Model.create: should have types', () => {
|
|
7
|
-
const {
|
|
8
|
-
model: {
|
|
9
|
-
model,
|
|
10
|
-
actor,
|
|
11
|
-
system,
|
|
12
|
-
component,
|
|
13
|
-
relTo
|
|
14
|
-
},
|
|
15
|
-
deployment: {
|
|
16
|
-
deployment,
|
|
17
|
-
instanceOf,
|
|
18
|
-
env,
|
|
19
|
-
vm
|
|
20
|
-
},
|
|
21
|
-
views: {
|
|
22
|
-
deploymentView,
|
|
23
|
-
views,
|
|
24
|
-
view,
|
|
25
|
-
$include
|
|
26
|
-
},
|
|
27
|
-
builder
|
|
28
|
-
} = Builder.forSpecification({
|
|
29
|
-
elements: {
|
|
30
|
-
actor: {
|
|
31
|
-
style: {
|
|
32
|
-
shape: 'person'
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
system: {},
|
|
36
|
-
component: {}
|
|
37
|
-
},
|
|
38
|
-
deployments: {
|
|
39
|
-
env: {},
|
|
40
|
-
vm: {}
|
|
41
|
-
},
|
|
42
|
-
relationships: {
|
|
43
|
-
like: {},
|
|
44
|
-
dislike: {}
|
|
45
|
-
},
|
|
46
|
-
tags: ['tag1', 'tag2', 'tag1']
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
const source = builder
|
|
50
|
-
.with(
|
|
51
|
-
model(
|
|
52
|
-
actor('alice'),
|
|
53
|
-
actor('bob'),
|
|
54
|
-
system('cloud').with(
|
|
55
|
-
component('backend').with(
|
|
56
|
-
component('api'),
|
|
57
|
-
component('db')
|
|
58
|
-
),
|
|
59
|
-
component('frontend').with(
|
|
60
|
-
relTo('cloud.backend.api')
|
|
61
|
-
)
|
|
62
|
-
)
|
|
63
|
-
),
|
|
64
|
-
deployment(
|
|
65
|
-
env('prod').with(
|
|
66
|
-
vm('vm1'),
|
|
67
|
-
vm('vm2')
|
|
68
|
-
),
|
|
69
|
-
env('dev').with(
|
|
70
|
-
vm('vm1'),
|
|
71
|
-
instanceOf('api', 'cloud.backend.api'),
|
|
72
|
-
vm('vm2')
|
|
73
|
-
)
|
|
74
|
-
),
|
|
75
|
-
views(
|
|
76
|
-
view('index', $include('*')),
|
|
77
|
-
deploymentView('prodview', $include('*'))
|
|
78
|
-
)
|
|
79
|
-
)
|
|
80
|
-
.build()
|
|
81
|
-
|
|
82
|
-
const m = LikeC4Model.compute(source)
|
|
83
|
-
|
|
84
|
-
// @ts-expect-error
|
|
85
|
-
m.element('wrong')
|
|
86
|
-
|
|
87
|
-
expectTypeOf(m.Aux.Element).toEqualTypeOf(
|
|
88
|
-
'' as 'alice' | 'bob' | 'cloud' | 'cloud.backend' | 'cloud.backend.api' | 'cloud.backend.db' | 'cloud.frontend'
|
|
89
|
-
)
|
|
90
|
-
expectTypeOf(m.Aux.Fqn).toEqualTypeOf(
|
|
91
|
-
'' as Fqn<'alice' | 'bob' | 'cloud' | 'cloud.backend' | 'cloud.backend.api' | 'cloud.backend.db' | 'cloud.frontend'>
|
|
92
|
-
)
|
|
93
|
-
expectTypeOf(m.Aux.ViewId).toEqualTypeOf(
|
|
94
|
-
'' as ViewId<'index' | 'prodview'>
|
|
95
|
-
)
|
|
96
|
-
expectTypeOf(m.Aux.ViewType).toEqualTypeOf(
|
|
97
|
-
{} as ComputedView<ViewId<'index' | 'prodview'>>
|
|
98
|
-
)
|
|
99
|
-
expectTypeOf(m.Aux.Deployment).toEqualTypeOf(
|
|
100
|
-
'' as 'prod' | 'dev' | 'prod.vm1' | 'prod.vm2' | 'dev.vm1' | 'dev.vm2' | 'dev.api'
|
|
101
|
-
)
|
|
102
|
-
expectTypeOf(m.Aux.DeploymentFqn).toEqualTypeOf(
|
|
103
|
-
'' as Fqn<'prod' | 'dev' | 'prod.vm1' | 'prod.vm2' | 'dev.vm1' | 'dev.vm2' | 'dev.api'>
|
|
104
|
-
)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
test('LikeC4Model.fromDump: should have types', () => {
|
|
108
|
-
const m = LikeC4Model.fromDump({
|
|
109
|
-
specification: {
|
|
110
|
-
tags: [],
|
|
111
|
-
elements: {},
|
|
112
|
-
relationships: {},
|
|
113
|
-
deployments: {}
|
|
114
|
-
},
|
|
115
|
-
elements: {
|
|
116
|
-
el1: {},
|
|
117
|
-
el2: {}
|
|
118
|
-
},
|
|
119
|
-
relations: {},
|
|
120
|
-
globals: {
|
|
121
|
-
predicates: {},
|
|
122
|
-
dynamicPredicates: {},
|
|
123
|
-
styles: {}
|
|
124
|
-
},
|
|
125
|
-
views: {
|
|
126
|
-
v1: {},
|
|
127
|
-
v2: {}
|
|
128
|
-
},
|
|
129
|
-
deployments: {
|
|
130
|
-
elements: {
|
|
131
|
-
d1: {},
|
|
132
|
-
d2: {}
|
|
133
|
-
},
|
|
134
|
-
relations: {}
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
expectTypeOf(m.Aux.Element).toEqualTypeOf(
|
|
138
|
-
'' as 'el1' | 'el2'
|
|
139
|
-
)
|
|
140
|
-
expectTypeOf(m.Aux.Fqn).toEqualTypeOf(
|
|
141
|
-
'' as Fqn<'el1' | 'el2'>
|
|
142
|
-
)
|
|
143
|
-
expectTypeOf(m.Aux.ViewId).toEqualTypeOf(
|
|
144
|
-
'' as ViewId<'v1' | 'v2'>
|
|
145
|
-
)
|
|
146
|
-
expectTypeOf(m.Aux.Deployment).toEqualTypeOf(
|
|
147
|
-
'' as 'd1' | 'd2'
|
|
148
|
-
)
|
|
149
|
-
expectTypeOf(m.Aux.DeploymentFqn).toEqualTypeOf(
|
|
150
|
-
'' as Fqn<'d1' | 'd2'>
|
|
151
|
-
)
|
|
152
|
-
})
|