@likec4/generators 1.38.1 → 1.39.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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  compareNatural,
3
3
  sortNaturalByFqn
4
- } from "@likec4/core";
4
+ } from "@likec4/core/utils";
5
5
  import { keys, map, pipe, values } from "remeda";
6
6
  function toUnion(elements) {
7
7
  if (elements.length === 0) {
@@ -1,4 +1,4 @@
1
- import { invariant } from "@likec4/core";
1
+ import { invariant } from "@likec4/core/utils";
2
2
  import { generateAux } from "../model/generate-aux.js";
3
3
  export function generateReactTypes(model) {
4
4
  invariant(!model.isParsed(), "can not generate react types for parsed model");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/generators",
3
- "version": "1.38.1",
3
+ "version": "1.39.0",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -8,7 +8,11 @@
8
8
  "description": "Converts LikeC4 Model to other formats, like Mermaid, PlantUML, SVG, etc. Also generates typings for Model API and React",
9
9
  "files": [
10
10
  "dist",
11
- "src"
11
+ "src",
12
+ "!**/*.spec.ts",
13
+ "!**/__mocks__/*",
14
+ "!**/__snapshots__/*",
15
+ "!**/*.map"
12
16
  ],
13
17
  "repository": {
14
18
  "type": "git",
@@ -35,14 +39,14 @@
35
39
  "json5": "^2.2.3",
36
40
  "langium": "3.5.0",
37
41
  "remeda": "^2.23.1",
38
- "@likec4/core": "1.38.1"
42
+ "@likec4/core": "1.39.0"
39
43
  },
40
44
  "devDependencies": {
41
- "@types/node": "~20.19.2",
45
+ "@types/node": "~20.19.11",
42
46
  "typescript": "5.9.2",
43
47
  "unbuild": "3.5.0",
44
48
  "vitest": "3.2.4",
45
- "@likec4/tsconfig": "1.38.1"
49
+ "@likec4/tsconfig": "1.39.0"
46
50
  },
47
51
  "scripts": {
48
52
  "typecheck": "tsc -b --verbose",
@@ -1,8 +1,8 @@
1
+ import { type AnyLikeC4Model } from '@likec4/core/model'
1
2
  import {
2
3
  compareNatural,
3
4
  sortNaturalByFqn,
4
- } from '@likec4/core'
5
- import { type AnyLikeC4Model } from '@likec4/core/model'
5
+ } from '@likec4/core/utils'
6
6
  import { keys, map, pipe, values } from 'remeda'
7
7
 
8
8
  function toUnion(elements: string[]) {
@@ -1,5 +1,5 @@
1
- import { invariant } from '@likec4/core'
2
1
  import type { AnyLikeC4Model } from '@likec4/core/model'
2
+ import { invariant } from '@likec4/core/utils'
3
3
  import { generateAux } from '../model/generate-aux'
4
4
 
5
5
  export function generateReactTypes(model: AnyLikeC4Model) {
@@ -1,463 +0,0 @@
1
- import type { ComputedView, DiagramView } from '@likec4/core/types'
2
-
3
- export const fakeDiagram: DiagramView = {
4
- edges: [
5
- {
6
- headArrow: [
7
- [294, 487],
8
- [291, 496],
9
- [288, 487],
10
- ],
11
- id: 'cloud.frontend:cloud.backend',
12
- label: 'requests',
13
- labelBox: {
14
- align: 'left',
15
- width: 62,
16
- x: 295,
17
- y: 459,
18
- },
19
- points: [
20
- [291, 406],
21
- [291, 432],
22
- [291, 461],
23
- [291, 487],
24
- ],
25
- relations: [
26
- 'cloud.frontend.dashboard:cloud.backend.graphql',
27
- 'cloud.frontend.adminPanel:cloud.backend.graphql',
28
- ],
29
- source: 'cloud.frontend',
30
- target: 'cloud.backend',
31
- },
32
- {
33
- headArrow: [
34
- [294, 701],
35
- [291, 711],
36
- [288, 701],
37
- ],
38
- id: 'cloud.backend:amazon',
39
- label: null,
40
- labelBox: null,
41
- points: [
42
- [291, 641],
43
- [291, 660],
44
- [291, 681],
45
- [291, 702],
46
- ],
47
- relations: ['cloud.backend.storage:amazon.s3'],
48
- source: 'cloud.backend',
49
- target: 'amazon',
50
- },
51
- {
52
- headArrow: [
53
- [344, 257],
54
- [336, 263],
55
- [338, 253],
56
- ],
57
- id: 'support:cloud.frontend',
58
- label: null,
59
- labelBox: null,
60
- points: [
61
- [413, 141],
62
- [391, 176],
63
- [364, 218],
64
- [342, 255],
65
- ],
66
- relations: ['support:cloud.frontend.adminPanel'],
67
- source: 'support',
68
- target: 'cloud.frontend',
69
- },
70
- {
71
- headArrow: [
72
- [244, 253],
73
- [246, 263],
74
- [239, 257],
75
- ],
76
- id: 'customer:cloud.frontend',
77
- label: 'opens',
78
- labelBox: {
79
- align: 'left',
80
- width: 44,
81
- x: 208,
82
- y: 193,
83
- },
84
- points: [
85
- [169, 141],
86
- [191, 176],
87
- [218, 218],
88
- [241, 255],
89
- ],
90
- relations: ['customer:cloud.frontend.dashboard'],
91
- source: 'customer',
92
- target: 'cloud.frontend',
93
- },
94
- ],
95
- height: 855,
96
- id: 'fakeView',
97
- nodes: [
98
- {
99
- children: [],
100
- color: 'primary',
101
- id: 'amazon',
102
- parent: null,
103
- position: [165, 715],
104
- relative: [165, 715],
105
- shape: 'rectangle',
106
- size: {
107
- height: 140,
108
- width: 251,
109
- },
110
- title: 'amazon',
111
- },
112
- {
113
- children: ['cloud.backend', 'cloud.frontend'],
114
- color: 'primary',
115
- id: 'cloud',
116
- parent: null,
117
- position: [139, 210],
118
- relative: [139, 210],
119
- shape: 'rectangle',
120
- size: {
121
- height: 457,
122
- width: 304,
123
- },
124
- title: 'cloud',
125
- },
126
- {
127
- children: [],
128
- color: 'primary',
129
- id: 'customer',
130
- parent: null,
131
- position: [0, 0],
132
- relative: [0, 0],
133
- shape: 'rectangle',
134
- size: {
135
- height: 140,
136
- width: 251,
137
- },
138
- title: 'customer',
139
- },
140
- {
141
- children: [],
142
- color: 'primary',
143
- id: 'support',
144
- parent: null,
145
- position: [330, 0],
146
- relative: [330, 0],
147
- shape: 'rectangle',
148
- size: {
149
- height: 140,
150
- width: 251,
151
- },
152
- title: 'support',
153
- },
154
- {
155
- children: [],
156
- color: 'primary',
157
- id: 'cloud.backend',
158
- parent: 'cloud',
159
- position: [165, 500],
160
- relative: [26, 290],
161
- shape: 'rectangle',
162
- size: {
163
- height: 140,
164
- width: 251,
165
- },
166
- title: 'backend',
167
- },
168
- {
169
- children: [],
170
- color: 'primary',
171
- id: 'cloud.frontend',
172
- parent: 'cloud',
173
- position: [165, 266],
174
- relative: [26, 56],
175
- shape: 'rectangle',
176
- size: {
177
- height: 140,
178
- width: 251,
179
- },
180
- title: 'frontend',
181
- },
182
- ],
183
- autoLayout: { direction: 'TB' },
184
- rules: [
185
- {
186
- exprs: [
187
- {
188
- wildcard: true,
189
- },
190
- ],
191
- isInclude: true,
192
- },
193
- ],
194
- title: '',
195
- viewOf: 'cloud',
196
- width: 582,
197
- } as any
198
-
199
- export const fakeDiagram2: DiagramView = {
200
- edges: [
201
- {
202
- headArrow: [
203
- [129, 456],
204
- [126, 465],
205
- [123, 456],
206
- ],
207
- id: 'system.frontend:system.backend',
208
- label: 'requests',
209
- labelBox: {
210
- align: 'left',
211
- width: 62,
212
- x: 130,
213
- y: 428,
214
- },
215
- points: [
216
- [126, 375],
217
- [126, 400],
218
- [126, 429],
219
- [126, 456],
220
- ],
221
- relations: ['671e3db5eb605d5f245f247d95925bd0953e0e4c'],
222
- source: 'system.frontend',
223
- target: 'system.backend',
224
- },
225
- {
226
- headArrow: [
227
- [129, 221],
228
- [126, 231],
229
- [123, 221],
230
- ],
231
- id: 'client:system.frontend',
232
- label: 'opens',
233
- labelBox: {
234
- align: 'left',
235
- width: 44,
236
- x: 130,
237
- y: 193,
238
- },
239
- points: [
240
- [126, 141],
241
- [126, 166],
242
- [126, 195],
243
- [126, 221],
244
- ],
245
- relations: ['99bffdfd5c78e024393e6223cd9b19225321a5e3'],
246
- source: 'client',
247
- target: 'system.frontend',
248
- },
249
- ],
250
- height: 609,
251
- id: '74f5364fa4b',
252
- nodes: [
253
- {
254
- children: [],
255
- color: 'primary',
256
- id: 'client',
257
- parent: null,
258
- position: [0, 0],
259
- relative: [0, 0],
260
- shape: 'rectangle',
261
- size: {
262
- height: 140,
263
- width: 251,
264
- },
265
- title: 'client',
266
- },
267
- {
268
- children: [],
269
- color: 'primary',
270
- id: 'system.backend',
271
- parent: null,
272
- position: [0, 469],
273
- relative: [0, 469],
274
- shape: 'rectangle',
275
- size: {
276
- height: 140,
277
- width: 251,
278
- },
279
- title: 'backend',
280
- },
281
- {
282
- children: [],
283
- color: 'primary',
284
- id: 'system.frontend',
285
- parent: null,
286
- position: [0, 235],
287
- relative: [0, 235],
288
- shape: 'rectangle',
289
- size: {
290
- height: 140,
291
- width: 251,
292
- },
293
- title: 'frontend',
294
- },
295
- ],
296
- autoLayout: { direction: 'TB' },
297
- rules: [
298
- {
299
- exprs: [
300
- {
301
- wildcard: true,
302
- },
303
- ],
304
- isInclude: true,
305
- },
306
- ],
307
- title: 'frontend',
308
- viewOf: 'system.frontend',
309
- width: 251,
310
- } as any
311
-
312
- export const fakeComputedView3Levels: ComputedView = {
313
- edges: [
314
- {
315
- id: 'cloud.frontend.dashboard:cloud.backend.graphql',
316
- label: null,
317
- relations: ['cloud.frontend.dashboard:cloud.backend.graphql'],
318
- source: 'cloud.frontend.dashboard',
319
- target: 'cloud.backend.graphql',
320
- },
321
- {
322
- id: 'cloud.frontend.adminPanel:cloud.backend.graphql',
323
- label: null,
324
- relations: ['cloud.frontend.adminPanel:cloud.backend.graphql'],
325
- source: 'cloud.frontend.adminPanel',
326
- target: 'cloud.backend.graphql',
327
- },
328
- {
329
- id: 'cloud.backend.storage:amazon',
330
- label: null,
331
- relations: ['cloud.backend.storage:amazon.s3'],
332
- source: 'cloud.backend.storage',
333
- target: 'amazon',
334
- },
335
- {
336
- id: 'cloud.backend.graphql:cloud.backend.storage',
337
- label: null,
338
- relations: ['cloud.backend.graphql:cloud.backend.storage'],
339
- source: 'cloud.backend.graphql',
340
- target: 'cloud.backend.storage',
341
- },
342
- {
343
- id: 'support:cloud.frontend.adminPanel',
344
- label: null,
345
- relations: ['support:cloud.frontend.adminPanel'],
346
- source: 'support',
347
- target: 'cloud.frontend.adminPanel',
348
- },
349
- {
350
- id: 'customer:cloud.frontend.dashboard',
351
- label: null,
352
- relations: ['customer:cloud.frontend.dashboard'],
353
- source: 'customer',
354
- target: 'cloud.frontend.dashboard',
355
- },
356
- ],
357
- id: 'cloud3levels',
358
- nodes: [
359
- {
360
- children: [],
361
- color: 'primary',
362
- id: 'amazon',
363
- parent: null,
364
- shape: 'rectangle',
365
- title: 'amazon',
366
- },
367
- {
368
- children: ['cloud.backend', 'cloud.frontend.adminPanel', 'cloud.frontend.dashboard'],
369
- color: 'primary',
370
- id: 'cloud',
371
- navigateTo: 'fakeView',
372
- parent: null,
373
- shape: 'rectangle',
374
- title: 'cloud',
375
- },
376
- {
377
- children: [],
378
- color: 'primary',
379
- id: 'customer',
380
- parent: null,
381
- shape: 'rectangle',
382
- title: 'customer',
383
- },
384
- {
385
- children: [],
386
- color: 'primary',
387
- id: 'support',
388
- parent: null,
389
- shape: 'rectangle',
390
- title: 'support',
391
- },
392
- {
393
- children: ['cloud.backend.graphql', 'cloud.backend.storage'],
394
- color: 'primary',
395
- id: 'cloud.backend',
396
- parent: 'cloud',
397
- shape: 'rectangle',
398
- title: 'backend',
399
- },
400
- {
401
- children: [],
402
- color: 'primary',
403
- id: 'cloud.backend.graphql',
404
- parent: 'cloud.backend',
405
- shape: 'rectangle',
406
- title: 'graphql',
407
- },
408
- {
409
- children: [],
410
- color: 'primary',
411
- id: 'cloud.backend.storage',
412
- parent: 'cloud.backend',
413
- shape: 'rectangle',
414
- title: 'storage',
415
- },
416
- {
417
- children: [],
418
- color: 'primary',
419
- id: 'cloud.frontend.adminPanel',
420
- parent: 'cloud',
421
- shape: 'rectangle',
422
- title: 'adminPanel',
423
- },
424
- {
425
- children: [],
426
- color: 'primary',
427
- id: 'cloud.frontend.dashboard',
428
- parent: 'cloud',
429
- shape: 'rectangle',
430
- title: 'dashboard',
431
- },
432
- ],
433
- autoLayout: { direction: 'TB' },
434
- rules: [
435
- {
436
- exprs: [
437
- {
438
- wildcard: true,
439
- },
440
- {
441
- element: 'cloud.frontend',
442
- isChildren: true,
443
- },
444
- {
445
- element: 'cloud.backend',
446
- isChildren: true,
447
- },
448
- ],
449
- isInclude: true,
450
- },
451
- {
452
- exprs: [
453
- {
454
- element: 'cloud.frontend',
455
- isChildren: false,
456
- },
457
- ],
458
- isInclude: false,
459
- },
460
- ],
461
- title: 'Context: Cloud',
462
- viewOf: 'cloud',
463
- } as any
@@ -1,169 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`generate D2 - element view 1`] = `
4
- "direction: down
5
-
6
- Alice: {
7
- label: "Alice"
8
- }
9
- Bob: {
10
- label: "Bob"
11
- }
12
- Cloud: {
13
- label: "Cloud"
14
-
15
- Frontend: {
16
- label: "frontend"
17
- }
18
- Backend: {
19
- label: "Backend"
20
- }
21
- }
22
-
23
- Alice -> Cloud.Frontend: "uses \\n at home"
24
- Bob -> Cloud.Frontend: "uses \\n at work"
25
- Cloud.Frontend -> Cloud.Backend: "requests"
26
- "
27
- `;
28
-
29
- exports[`generate D2 - element view 3 levels 1`] = `
30
- "direction: down
31
-
32
- Alice: {
33
- label: "Alice"
34
- }
35
- Bob: {
36
- label: "Bob"
37
- }
38
- Cloud: {
39
- label: "Cloud"
40
-
41
- Frontend: {
42
- label: "frontend"
43
- }
44
- Backend: {
45
- label: "Backend"
46
-
47
- Api: {
48
- label: "API"
49
- }
50
- Db: {
51
- label: "DB"
52
- }
53
- }
54
- }
55
-
56
- Cloud.Frontend -> Cloud.Backend.Api: "requests"
57
- Cloud.Backend.Api -> Cloud.Backend.Db
58
- Alice -> Cloud.Frontend: "uses \\n at home"
59
- Bob -> Cloud.Frontend: "uses \\n at work"
60
- "
61
- `;
62
-
63
- exports[`generate D2 - fakeComputedView 3 Levels 1`] = `
64
- "direction: down
65
-
66
- Amazon: {
67
- label: "amazon"
68
- }
69
- Cloud: {
70
- label: "cloud"
71
-
72
- Backend: {
73
- label: "backend"
74
-
75
- Graphql: {
76
- label: "graphql"
77
- }
78
- Storage: {
79
- label: "storage"
80
- }
81
- }
82
- FrontendAdminPanel: {
83
- label: "adminPanel"
84
- }
85
- FrontendDashboard: {
86
- label: "dashboard"
87
- }
88
- }
89
- Customer: {
90
- label: "customer"
91
- }
92
- Support: {
93
- label: "support"
94
- }
95
-
96
- Cloud.FrontendDashboard -> Cloud.Backend.Graphql
97
- Cloud.FrontendAdminPanel -> Cloud.Backend.Graphql
98
- Cloud.Backend.Storage -> Amazon
99
- Cloud.Backend.Graphql -> Cloud.Backend.Storage
100
- Support -> Cloud.FrontendAdminPanel
101
- Customer -> Cloud.FrontendDashboard
102
- "
103
- `;
104
-
105
- exports[`generate D2 - fakeDiagram 1`] = `
106
- "direction: down
107
-
108
- Amazon: {
109
- label: "amazon"
110
- }
111
- Cloud: {
112
- label: "cloud"
113
-
114
- Backend: {
115
- label: "backend"
116
- }
117
- Frontend: {
118
- label: "frontend"
119
- }
120
- }
121
- Customer: {
122
- label: "customer"
123
- }
124
- Support: {
125
- label: "support"
126
- }
127
-
128
- Cloud.Frontend -> Cloud.Backend: "requests"
129
- Cloud.Backend -> Amazon
130
- Support -> Cloud.Frontend
131
- Customer -> Cloud.Frontend: "opens"
132
- "
133
- `;
134
-
135
- exports[`generate D2 - fakeDiagram2 1`] = `
136
- "direction: down
137
-
138
- Client: {
139
- label: "client"
140
- }
141
- SystemBackend: {
142
- label: "backend"
143
- }
144
- SystemFrontend: {
145
- label: "frontend"
146
- }
147
-
148
- SystemFrontend -> SystemBackend: "requests"
149
- Client -> SystemFrontend: "opens"
150
- "
151
- `;
152
-
153
- exports[`generate D2 - landscape 1`] = `
154
- "direction: down
155
-
156
- Alice: {
157
- label: "Alice"
158
- }
159
- Bob: {
160
- label: "Bob"
161
- }
162
- Cloud: {
163
- label: "Cloud"
164
- }
165
-
166
- Alice -> Cloud: "uses \\n at home"
167
- Bob -> Cloud: "uses \\n at work"
168
- "
169
- `;