@likec4/generators 0.6.3 → 0.8.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.
@@ -0,0 +1,5 @@
1
+ import type { ComputedView, DiagramView } from '@likec4/core/types';
2
+ export declare const fakeDiagram: DiagramView;
3
+ export declare const fakeDiagram2: DiagramView;
4
+ export declare const fakeComputedView3Levels: ComputedView;
5
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1,456 @@
1
+ export const fakeDiagram = {
2
+ edges: [
3
+ {
4
+ headArrow: [
5
+ [294, 487],
6
+ [291, 496],
7
+ [288, 487]
8
+ ],
9
+ id: 'cloud.frontend:cloud.backend',
10
+ label: 'requests',
11
+ labelBox: {
12
+ align: 'left',
13
+ width: 62,
14
+ x: 295,
15
+ y: 459
16
+ },
17
+ points: [
18
+ [291, 406],
19
+ [291, 432],
20
+ [291, 461],
21
+ [291, 487]
22
+ ],
23
+ relations: [
24
+ 'cloud.frontend.dashboard:cloud.backend.graphql',
25
+ 'cloud.frontend.adminPanel:cloud.backend.graphql'
26
+ ],
27
+ source: 'cloud.frontend',
28
+ target: 'cloud.backend'
29
+ },
30
+ {
31
+ headArrow: [
32
+ [294, 701],
33
+ [291, 711],
34
+ [288, 701]
35
+ ],
36
+ id: 'cloud.backend:amazon',
37
+ label: null,
38
+ labelBox: null,
39
+ points: [
40
+ [291, 641],
41
+ [291, 660],
42
+ [291, 681],
43
+ [291, 702]
44
+ ],
45
+ relations: ['cloud.backend.storage:amazon.s3'],
46
+ source: 'cloud.backend',
47
+ target: 'amazon'
48
+ },
49
+ {
50
+ headArrow: [
51
+ [344, 257],
52
+ [336, 263],
53
+ [338, 253]
54
+ ],
55
+ id: 'support:cloud.frontend',
56
+ label: null,
57
+ labelBox: null,
58
+ points: [
59
+ [413, 141],
60
+ [391, 176],
61
+ [364, 218],
62
+ [342, 255]
63
+ ],
64
+ relations: ['support:cloud.frontend.adminPanel'],
65
+ source: 'support',
66
+ target: 'cloud.frontend'
67
+ },
68
+ {
69
+ headArrow: [
70
+ [244, 253],
71
+ [246, 263],
72
+ [239, 257]
73
+ ],
74
+ id: 'customer:cloud.frontend',
75
+ label: 'opens',
76
+ labelBox: {
77
+ align: 'left',
78
+ width: 44,
79
+ x: 208,
80
+ y: 193
81
+ },
82
+ points: [
83
+ [169, 141],
84
+ [191, 176],
85
+ [218, 218],
86
+ [241, 255]
87
+ ],
88
+ relations: ['customer:cloud.frontend.dashboard'],
89
+ source: 'customer',
90
+ target: 'cloud.frontend'
91
+ }
92
+ ],
93
+ height: 855,
94
+ id: 'fakeView',
95
+ nodes: [
96
+ {
97
+ children: [],
98
+ color: 'primary',
99
+ id: 'amazon',
100
+ parent: null,
101
+ position: [165, 715],
102
+ relative: [165, 715],
103
+ shape: 'rectangle',
104
+ size: {
105
+ height: 140,
106
+ width: 251
107
+ },
108
+ title: 'amazon'
109
+ },
110
+ {
111
+ children: ['cloud.backend', 'cloud.frontend'],
112
+ color: 'primary',
113
+ id: 'cloud',
114
+ parent: null,
115
+ position: [139, 210],
116
+ relative: [139, 210],
117
+ shape: 'rectangle',
118
+ size: {
119
+ height: 457,
120
+ width: 304
121
+ },
122
+ title: 'cloud'
123
+ },
124
+ {
125
+ children: [],
126
+ color: 'primary',
127
+ id: 'customer',
128
+ parent: null,
129
+ position: [0, 0],
130
+ relative: [0, 0],
131
+ shape: 'rectangle',
132
+ size: {
133
+ height: 140,
134
+ width: 251
135
+ },
136
+ title: 'customer'
137
+ },
138
+ {
139
+ children: [],
140
+ color: 'primary',
141
+ id: 'support',
142
+ parent: null,
143
+ position: [330, 0],
144
+ relative: [330, 0],
145
+ shape: 'rectangle',
146
+ size: {
147
+ height: 140,
148
+ width: 251
149
+ },
150
+ title: 'support'
151
+ },
152
+ {
153
+ children: [],
154
+ color: 'primary',
155
+ id: 'cloud.backend',
156
+ parent: 'cloud',
157
+ position: [165, 500],
158
+ relative: [26, 290],
159
+ shape: 'rectangle',
160
+ size: {
161
+ height: 140,
162
+ width: 251
163
+ },
164
+ title: 'backend'
165
+ },
166
+ {
167
+ children: [],
168
+ color: 'primary',
169
+ id: 'cloud.frontend',
170
+ parent: 'cloud',
171
+ position: [165, 266],
172
+ relative: [26, 56],
173
+ shape: 'rectangle',
174
+ size: {
175
+ height: 140,
176
+ width: 251
177
+ },
178
+ title: 'frontend'
179
+ }
180
+ ],
181
+ rules: [
182
+ {
183
+ exprs: [
184
+ {
185
+ wildcard: true
186
+ }
187
+ ],
188
+ isInclude: true
189
+ }
190
+ ],
191
+ title: '',
192
+ viewOf: 'cloud',
193
+ width: 582
194
+ };
195
+ export const fakeDiagram2 = {
196
+ edges: [
197
+ {
198
+ headArrow: [
199
+ [129, 456],
200
+ [126, 465],
201
+ [123, 456]
202
+ ],
203
+ id: 'system.frontend:system.backend',
204
+ label: 'requests',
205
+ labelBox: {
206
+ align: 'left',
207
+ width: 62,
208
+ x: 130,
209
+ y: 428
210
+ },
211
+ points: [
212
+ [126, 375],
213
+ [126, 400],
214
+ [126, 429],
215
+ [126, 456]
216
+ ],
217
+ relations: ['671e3db5eb605d5f245f247d95925bd0953e0e4c'],
218
+ source: 'system.frontend',
219
+ target: 'system.backend'
220
+ },
221
+ {
222
+ headArrow: [
223
+ [129, 221],
224
+ [126, 231],
225
+ [123, 221]
226
+ ],
227
+ id: 'client:system.frontend',
228
+ label: 'opens',
229
+ labelBox: {
230
+ align: 'left',
231
+ width: 44,
232
+ x: 130,
233
+ y: 193
234
+ },
235
+ points: [
236
+ [126, 141],
237
+ [126, 166],
238
+ [126, 195],
239
+ [126, 221]
240
+ ],
241
+ relations: ['99bffdfd5c78e024393e6223cd9b19225321a5e3'],
242
+ source: 'client',
243
+ target: 'system.frontend'
244
+ }
245
+ ],
246
+ height: 609,
247
+ id: '74f5364fa4b',
248
+ nodes: [
249
+ {
250
+ children: [],
251
+ color: 'primary',
252
+ id: 'client',
253
+ parent: null,
254
+ position: [0, 0],
255
+ relative: [0, 0],
256
+ shape: 'rectangle',
257
+ size: {
258
+ height: 140,
259
+ width: 251
260
+ },
261
+ title: 'client'
262
+ },
263
+ {
264
+ children: [],
265
+ color: 'primary',
266
+ id: 'system.backend',
267
+ parent: null,
268
+ position: [0, 469],
269
+ relative: [0, 469],
270
+ shape: 'rectangle',
271
+ size: {
272
+ height: 140,
273
+ width: 251
274
+ },
275
+ title: 'backend'
276
+ },
277
+ {
278
+ children: [],
279
+ color: 'primary',
280
+ id: 'system.frontend',
281
+ parent: null,
282
+ position: [0, 235],
283
+ relative: [0, 235],
284
+ shape: 'rectangle',
285
+ size: {
286
+ height: 140,
287
+ width: 251
288
+ },
289
+ title: 'frontend'
290
+ }
291
+ ],
292
+ rules: [
293
+ {
294
+ exprs: [
295
+ {
296
+ wildcard: true
297
+ }
298
+ ],
299
+ isInclude: true
300
+ }
301
+ ],
302
+ title: 'frontend',
303
+ viewOf: 'system.frontend',
304
+ width: 251
305
+ };
306
+ export const fakeComputedView3Levels = {
307
+ edges: [
308
+ {
309
+ id: 'cloud.frontend.dashboard:cloud.backend.graphql',
310
+ label: null,
311
+ relations: ['cloud.frontend.dashboard:cloud.backend.graphql'],
312
+ source: 'cloud.frontend.dashboard',
313
+ target: 'cloud.backend.graphql'
314
+ },
315
+ {
316
+ id: 'cloud.frontend.adminPanel:cloud.backend.graphql',
317
+ label: null,
318
+ relations: ['cloud.frontend.adminPanel:cloud.backend.graphql'],
319
+ source: 'cloud.frontend.adminPanel',
320
+ target: 'cloud.backend.graphql'
321
+ },
322
+ {
323
+ id: 'cloud.backend.storage:amazon',
324
+ label: null,
325
+ relations: ['cloud.backend.storage:amazon.s3'],
326
+ source: 'cloud.backend.storage',
327
+ target: 'amazon'
328
+ },
329
+ {
330
+ id: 'cloud.backend.graphql:cloud.backend.storage',
331
+ label: null,
332
+ relations: ['cloud.backend.graphql:cloud.backend.storage'],
333
+ source: 'cloud.backend.graphql',
334
+ target: 'cloud.backend.storage'
335
+ },
336
+ {
337
+ id: 'support:cloud.frontend.adminPanel',
338
+ label: null,
339
+ relations: ['support:cloud.frontend.adminPanel'],
340
+ source: 'support',
341
+ target: 'cloud.frontend.adminPanel'
342
+ },
343
+ {
344
+ id: 'customer:cloud.frontend.dashboard',
345
+ label: null,
346
+ relations: ['customer:cloud.frontend.dashboard'],
347
+ source: 'customer',
348
+ target: 'cloud.frontend.dashboard'
349
+ }
350
+ ],
351
+ id: 'cloud3levels',
352
+ nodes: [
353
+ {
354
+ children: [],
355
+ color: 'primary',
356
+ id: 'amazon',
357
+ parent: null,
358
+ shape: 'rectangle',
359
+ title: 'amazon'
360
+ },
361
+ {
362
+ children: ['cloud.backend', 'cloud.frontend.adminPanel', 'cloud.frontend.dashboard'],
363
+ color: 'primary',
364
+ id: 'cloud',
365
+ navigateTo: 'fakeView',
366
+ parent: null,
367
+ shape: 'rectangle',
368
+ title: 'cloud'
369
+ },
370
+ {
371
+ children: [],
372
+ color: 'primary',
373
+ id: 'customer',
374
+ parent: null,
375
+ shape: 'rectangle',
376
+ title: 'customer'
377
+ },
378
+ {
379
+ children: [],
380
+ color: 'primary',
381
+ id: 'support',
382
+ parent: null,
383
+ shape: 'rectangle',
384
+ title: 'support'
385
+ },
386
+ {
387
+ children: ['cloud.backend.graphql', 'cloud.backend.storage'],
388
+ color: 'primary',
389
+ id: 'cloud.backend',
390
+ parent: 'cloud',
391
+ shape: 'rectangle',
392
+ title: 'backend'
393
+ },
394
+ {
395
+ children: [],
396
+ color: 'primary',
397
+ id: 'cloud.backend.graphql',
398
+ parent: 'cloud.backend',
399
+ shape: 'rectangle',
400
+ title: 'graphql'
401
+ },
402
+ {
403
+ children: [],
404
+ color: 'primary',
405
+ id: 'cloud.backend.storage',
406
+ parent: 'cloud.backend',
407
+ shape: 'rectangle',
408
+ title: 'storage'
409
+ },
410
+ {
411
+ children: [],
412
+ color: 'primary',
413
+ id: 'cloud.frontend.adminPanel',
414
+ parent: 'cloud',
415
+ shape: 'rectangle',
416
+ title: 'adminPanel'
417
+ },
418
+ {
419
+ children: [],
420
+ color: 'primary',
421
+ id: 'cloud.frontend.dashboard',
422
+ parent: 'cloud',
423
+ shape: 'rectangle',
424
+ title: 'dashboard'
425
+ }
426
+ ],
427
+ rules: [
428
+ {
429
+ exprs: [
430
+ {
431
+ wildcard: true
432
+ },
433
+ {
434
+ element: 'cloud.frontend',
435
+ isDescedants: true
436
+ },
437
+ {
438
+ element: 'cloud.backend',
439
+ isDescedants: true
440
+ }
441
+ ],
442
+ isInclude: true
443
+ },
444
+ {
445
+ exprs: [
446
+ {
447
+ element: 'cloud.frontend',
448
+ isDescedants: false
449
+ }
450
+ ],
451
+ isInclude: false
452
+ }
453
+ ],
454
+ title: '',
455
+ viewOf: 'cloud'
456
+ };
@@ -1,2 +1,3 @@
1
1
  import type { ComputedView } from '@likec4/core/types';
2
2
  export declare function generateD2<V extends ComputedView>({ nodes, edges }: V): string;
3
+ //# sourceMappingURL=generate-d2.d.ts.map
@@ -34,7 +34,7 @@ export function generateD2({ nodes, edges }) {
34
34
  .indent({
35
35
  indentedChildren: indent => indent
36
36
  .append('label: "', label, '"', NL)
37
- .append('shape: ', shape, NL)
37
+ .appendIf(shape !== 'rectangle', 'shape: ', shape, NL)
38
38
  .appendIf(node.children.length > 0, NL, joinToNode(nodes.filter(n => n.parent === node.id), n => printNode(n, fqnName))),
39
39
  indentation: 2
40
40
  })
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generate-d2.spec.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { expect, test } from 'vitest';
2
+ import { fakeDiagram, fakeDiagram2, fakeComputedView3Levels } from '../__mocks__/data';
3
+ import { generateD2 } from './generate-d2';
4
+ test('generate D2 - fakeDiagram', () => {
5
+ expect(generateD2(fakeDiagram)).toMatchSnapshot();
6
+ });
7
+ test('generate D2 - fakeDiagram2', () => {
8
+ expect(generateD2(fakeDiagram2)).toMatchSnapshot();
9
+ });
10
+ test('generate D2 - fakeComputedView 3 Levels', () => {
11
+ expect(generateD2(fakeComputedView3Levels)).toMatchSnapshot();
12
+ });
@@ -1 +1,2 @@
1
1
  export * from './generate-d2';
2
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { generateReact } from './react/generate-react';
2
2
  export { generateD2 } from './d2/generate-d2';
3
3
  export { generateViewsDataTs } from './views-data-ts/generate-views-data';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,3 @@
1
1
  import type { DiagramView } from '@likec4/core/types';
2
2
  export declare function generateReact(views: DiagramView[]): string;
3
+ //# sourceMappingURL=generate-react.d.ts.map
@@ -24,7 +24,6 @@ export function generateReact(views) {
24
24
 
25
25
  import type { DiagramView, EmbeddedDiagramProps } from '@likec4/diagrams'
26
26
  import { EmbeddedDiagram } from '@likec4/diagrams'
27
- import '@likec4/diagrams/dist/index.css'
28
27
  `.append(NL, NL);
29
28
  if (components.length == 0) {
30
29
  out.append('export {}', NL);
@@ -43,17 +42,17 @@ export function generateReact(views) {
43
42
  })
44
43
  .append('} as const', NL, NL).appendTemplate `
45
44
  export type LikeC4ViewsData = typeof LikeC4ViewsData
46
- export type ViewId = keyof LikeC4ViewsData
47
- export function isViewId(value: unknown): value is ViewId {
45
+ export type LikeC4ViewId = keyof LikeC4ViewsData
46
+ export function isLikeC4ViewId(value: unknown): value is LikeC4ViewId {
48
47
  return typeof value === 'string' && value in LikeC4ViewsData
49
48
  }
50
49
 
51
- export type LikeC4ViewProps = Omit<EmbeddedDiagramProps<LikeC4ViewsData, ViewId>, 'views'>;
50
+ export type LikeC4ViewProps = Omit<EmbeddedDiagramProps<LikeC4ViewsData, LikeC4ViewId>, 'views'>;
52
51
  export function LikeC4View(props: LikeC4ViewProps) {
53
52
  return <EmbeddedDiagram views={LikeC4ViewsData} {...props}/>
54
53
  }
55
54
 
56
- type LikeC4ViewsProps = Omit<EmbeddedDiagramProps<LikeC4ViewsData, ViewId>, 'views' | 'viewId'>
55
+ type LikeC4ViewsProps = Omit<EmbeddedDiagramProps<LikeC4ViewsData, LikeC4ViewId>, 'views' | 'viewId'>
57
56
  export const LikeC4Views = {
58
57
  `
59
58
  .append(NL)
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generate-react.spec.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { expect, test } from 'vitest';
2
+ import { fakeDiagram, fakeDiagram2 } from '../__mocks__/data';
3
+ import { generateReact } from './generate-react';
4
+ test('generate react', () => {
5
+ expect(generateReact([fakeDiagram, fakeDiagram2])).toMatchSnapshot();
6
+ });
@@ -1 +1,2 @@
1
1
  export * from './generate-react';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,3 @@
1
1
  import type { DiagramView } from '@likec4/core/types';
2
2
  export declare function generateViewsDataTs(views: DiagramView[]): string;
3
+ //# sourceMappingURL=generate-views-data.d.ts.map
@@ -24,8 +24,8 @@ export function generateViewsDataTs(views) {
24
24
  })
25
25
  .append('} as const', NL, NL).appendTemplate `
26
26
  export type LikeC4ViewsData = typeof LikeC4ViewsData
27
- export type ViewId = keyof LikeC4ViewsData
28
- export function isViewId(value: unknown): value is ViewId {
27
+ export type LikeC4ViewId = keyof LikeC4ViewsData
28
+ export function isLikeC4ViewId(value: unknown): value is LikeC4ViewId {
29
29
  return typeof value === 'string' && value in LikeC4ViewsData
30
30
  }
31
31
  `.append(NL);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generate-views-data.spec.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { expect, test } from 'vitest';
2
+ import { fakeDiagram, fakeDiagram2 } from '../__mocks__/data';
3
+ import { generateViewsDataTs } from './generate-views-data';
4
+ test('generate generateViewsDataTs', () => {
5
+ expect(generateViewsDataTs([fakeDiagram, fakeDiagram2])).toMatchSnapshot();
6
+ });
@@ -1 +1,2 @@
1
1
  export * from './generate-views-data';
2
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@likec4/generators",
3
- "version": "0.6.3",
3
+ "version": "0.8.0",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
- "homepage": "https://like-c4.dev",
6
+ "homepage": "https://likec4.dev",
7
7
  "author": "Denis Davydkov <denis@davydkov.com>",
8
8
  "files": [
9
- "dist"
9
+ "dist",
10
+ "!**/*.map"
10
11
  ],
11
12
  "repository": {
12
13
  "type": "git",
@@ -14,6 +15,7 @@
14
15
  "directory": "packages/generators"
15
16
  },
16
17
  "main": "./dist/index.js",
18
+ "module": "./dist/index.js",
17
19
  "types": "./dist/index.d.ts",
18
20
  "type": "module",
19
21
  "sideEffects": false,
@@ -22,18 +24,10 @@
22
24
  "access": "public",
23
25
  "main": "./dist/index.js",
24
26
  "module": "./dist/index.js",
25
- "types": "./dist/index.d.ts",
26
- "exports": {
27
- ".": {
28
- "types": "./dist/index.d.ts",
29
- "import": "./dist/index.js",
30
- "default": "./dist/index.js"
31
- }
32
- }
27
+ "types": "./dist/index.d.ts"
33
28
  },
34
29
  "scripts": {
35
- "compile": "tsc --emitDeclarationOnly",
36
- "build:release": "tsc -p tsconfig.esm.json",
30
+ "compile": "tsc --noEmit",
37
31
  "build": "tsc",
38
32
  "dev": "tsc --watch",
39
33
  "lint": "run -T eslint src/ --fix",
@@ -42,23 +36,14 @@
42
36
  "test:watch": "vitest"
43
37
  },
44
38
  "dependencies": {
45
- "@likec4/core": "0.6.3",
39
+ "@likec4/core": "0.7.0",
46
40
  "json5": "^2.2.3",
47
- "langium": "^1.1.0",
48
- "rambdax": "^9.1.0"
41
+ "langium": "^1.2.0",
42
+ "rambdax": "^9.1.1"
49
43
  },
50
44
  "devDependencies": {
51
45
  "@types/node": "^18.15.11",
52
46
  "typescript": "^5.0.4",
53
- "vite": "^4.2.2",
54
- "vitest": "^0.30.1"
55
- },
56
- "module": "./dist/index.js",
57
- "exports": {
58
- ".": {
59
- "types": "./dist/index.d.ts",
60
- "import": "./dist/index.js",
61
- "default": "./dist/index.js"
62
- }
47
+ "vitest": "^0.31.0"
63
48
  }
64
49
  }