@likec4/config 1.47.0 → 1.49.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/schema.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "description": "LikeC4 project configuration",
3
+ "id": "LikeC4ProjectConfig",
4
+ "description": "LikeC4 Project Configuration",
4
5
  "type": "object",
5
6
  "properties": {
6
7
  "name": {
@@ -8,6 +9,23 @@
8
9
  "type": "string",
9
10
  "minLength": 1
10
11
  },
12
+ "extends": {
13
+ "description": "Extend styles from other config files",
14
+ "anyOf": [
15
+ {
16
+ "type": "string",
17
+ "minLength": 1
18
+ },
19
+ {
20
+ "minItems": 1,
21
+ "type": "array",
22
+ "items": {
23
+ "type": "string",
24
+ "minLength": 1
25
+ }
26
+ }
27
+ ]
28
+ },
11
29
  "title": {
12
30
  "description": "A human readable title for the project",
13
31
  "type": "string",
@@ -18,25 +36,31 @@
18
36
  "type": "string",
19
37
  "minLength": 1
20
38
  },
21
- "imageAliases": {
22
- "description": "Map of image alias prefixes to relative paths (keys must match /^@\\w+$/; values must be relative paths without protocol or leading slash).",
39
+ "styles": {
40
+ "description": "Project styles customization",
23
41
  "type": "object",
24
- "propertyNames": {
25
- "type": "string"
42
+ "properties": {
43
+ "theme": {
44
+ "description": "Project theme customization",
45
+ "$ref": "#/$defs/ThemeCustomization"
46
+ },
47
+ "defaults": {
48
+ "description": "Override default values for style properties\nThese values will be used if such property is not defined",
49
+ "$ref": "#/$defs/DefaultStyleValues"
50
+ },
51
+ "customCss": {
52
+ "description": "Custom CSS (or list of CSS files) to be included in the generated diagrams",
53
+ "$ref": "#/$defs/CustomStylesheets"
54
+ }
26
55
  },
27
- "additionalProperties": {
28
- "type": "string",
29
- "minLength": 1,
30
- "pattern": "^(?!\\/|[A-Za-z]:[\\\\\\/])(?!.*:\\/\\/).*$"
31
- }
56
+ "additionalProperties": false
57
+ },
58
+ "imageAliases": {
59
+ "$ref": "#/$defs/ImageAliases"
32
60
  },
33
61
  "include": {
34
- "description": "Configuration for including additional LikeC4 source files from other directories.\nExample: { \"paths\": [\"../shared\", \"../common/specs\"], \"maxDepth\": 5, \"fileThreshold\": 50 }",
35
62
  "$ref": "#/$defs/include-config"
36
63
  },
37
- "styles": {
38
- "$ref": "#/$defs/StylesConfiguration"
39
- },
40
64
  "exclude": {
41
65
  "description": "List of file patterns to exclude from the project, default is [\"**/node_modules/**\"]",
42
66
  "type": "array",
@@ -45,142 +69,68 @@
45
69
  }
46
70
  },
47
71
  "manualLayouts": {
48
- "$ref": "#/$defs/manual-layouts-config"
72
+ "$ref": "#/$defs/ManualLayoutsConfig"
49
73
  }
50
74
  },
51
75
  "required": [
52
76
  "name"
53
77
  ],
54
78
  "$defs": {
55
- "include-config": {
56
- "id": "include-config",
57
- "description": "Configuration for including additional LikeC4 source files",
58
- "type": "object",
59
- "properties": {
60
- "paths": {
61
- "description": "Additional relative directory paths to include LikeC4 source files from, searched recursively.\nPaths are relative to the project folder (the folder containing this config file).\nExample: [\"../shared\", \"../common/specs\"]",
62
- "minItems": 1,
63
- "type": "array",
64
- "items": {
65
- "type": "string",
66
- "minLength": 1,
67
- "pattern": "^(?!\\/|[A-Za-z]:[\\\\\\/])(?!.*:\\/\\/).*$"
68
- }
69
- },
70
- "maxDepth": {
71
- "description": "Maximum directory depth to scan when searching for .c4 files in include paths.\nPrevents excessive scanning of deeply nested directories.\nDefault: 3",
72
- "default": 3,
73
- "type": "integer",
74
- "minimum": 1,
75
- "maximum": 20
76
- },
77
- "fileThreshold": {
78
- "description": "Maximum number of files to load from include paths before warning.\nHelps identify performance issues from accidentally including large directories.\nDefault: 30",
79
- "default": 30,
80
- "type": "integer",
81
- "minimum": 1,
82
- "maximum": 9007199254740991
83
- }
84
- },
85
- "required": [
86
- "paths"
87
- ]
88
- },
89
- "StylesConfiguration": {
90
- "id": "StylesConfiguration",
91
- "description": "Project styles customization",
92
- "type": "object",
93
- "properties": {
94
- "theme": {
95
- "$ref": "#/$defs/ThemeCustomization"
96
- },
97
- "defaults": {
98
- "$ref": "#/$defs/DefaultStyleValues"
99
- }
100
- },
101
- "additionalProperties": false
102
- },
103
79
  "ThemeCustomization": {
104
80
  "id": "ThemeCustomization",
105
- "description": "Theme customization",
81
+ "description": "Customize theme colors and sizes",
106
82
  "type": "object",
107
83
  "properties": {
108
84
  "colors": {
109
- "$ref": "#/$defs/ThemeColors"
110
- },
111
- "sizes": {
112
- "$ref": "#/$defs/ThemeSizes"
113
- }
114
- },
115
- "additionalProperties": false
116
- },
117
- "ThemeColors": {
118
- "id": "ThemeColors",
119
- "description": "Override theme colors",
120
- "anyOf": [
121
- {
85
+ "description": "Override theme colors",
122
86
  "type": "object",
123
87
  "propertyNames": {
124
- "$ref": "#/$defs/ColorName"
88
+ "anyOf": [
89
+ {
90
+ "$ref": "#/$defs/ColorName"
91
+ },
92
+ {
93
+ "not": {}
94
+ }
95
+ ]
125
96
  },
126
97
  "additionalProperties": {
127
98
  "$ref": "#/$defs/ThemeColorValues"
128
99
  }
129
100
  },
130
- {
101
+ "sizes": {
102
+ "description": "Override theme sizes",
131
103
  "type": "object",
132
- "properties": {
133
- "amber": {
134
- "$ref": "#/$defs/ThemeColorValues"
135
- },
136
- "blue": {
137
- "$ref": "#/$defs/ThemeColorValues"
138
- },
139
- "gray": {
140
- "$ref": "#/$defs/ThemeColorValues"
141
- },
142
- "slate": {
143
- "$ref": "#/$defs/ThemeColorValues"
144
- },
145
- "green": {
146
- "$ref": "#/$defs/ThemeColorValues"
147
- },
148
- "indigo": {
149
- "$ref": "#/$defs/ThemeColorValues"
150
- },
151
- "muted": {
152
- "$ref": "#/$defs/ThemeColorValues"
153
- },
154
- "primary": {
155
- "$ref": "#/$defs/ThemeColorValues"
156
- },
157
- "red": {
158
- "$ref": "#/$defs/ThemeColorValues"
159
- },
160
- "secondary": {
161
- "$ref": "#/$defs/ThemeColorValues"
162
- },
163
- "sky": {
164
- "$ref": "#/$defs/ThemeColorValues"
165
- }
104
+ "propertyNames": {
105
+ "anyOf": [
106
+ {
107
+ "$ref": "#/$defs/ElementSize"
108
+ },
109
+ {
110
+ "not": {}
111
+ }
112
+ ]
113
+ },
114
+ "additionalProperties": {
115
+ "$ref": "#/$defs/Dimensions"
166
116
  }
167
117
  }
168
- ]
118
+ },
119
+ "additionalProperties": false
169
120
  },
170
121
  "ColorName": {
171
122
  "id": "ColorName",
172
123
  "anyOf": [
173
124
  {
174
- "$ref": "#/$defs/ThemeColor"
125
+ "$ref": "#/$defs/ThemeColorName"
175
126
  },
176
127
  {
177
- "type": "string",
178
- "minLength": 1
128
+ "$ref": "#/$defs/CustomColorName"
179
129
  }
180
130
  ]
181
131
  },
182
- "ThemeColor": {
183
- "id": "ThemeColor",
132
+ "ThemeColorName": {
133
+ "id": "ThemeColorName",
184
134
  "type": "string",
185
135
  "enum": [
186
136
  "amber",
@@ -196,52 +146,54 @@
196
146
  "sky"
197
147
  ]
198
148
  },
149
+ "CustomColorName": {
150
+ "id": "CustomColorName"
151
+ },
199
152
  "ThemeColorValues": {
200
153
  "id": "ThemeColorValues",
201
154
  "description": "Exact value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values",
202
155
  "anyOf": [
203
156
  {
204
- "$ref": "#/$defs/ColorLiteral"
157
+ "$ref": "#/$defs/StrictThemeColorValues"
205
158
  },
206
159
  {
207
- "type": "object",
208
- "properties": {
209
- "elements": {
210
- "description": "Element color value (or a breakdown of specific color values)",
211
- "anyOf": [
212
- {
213
- "$ref": "#/$defs/ColorLiteral"
214
- },
215
- {
216
- "$ref": "#/$defs/ElementColorValues"
217
- }
218
- ]
219
- },
220
- "relationships": {
221
- "description": "Relationship color value (or a breakdown of specific color values)",
222
- "anyOf": [
223
- {
224
- "$ref": "#/$defs/ColorLiteral"
225
- },
226
- {
227
- "$ref": "#/$defs/RelationshipColorValues"
228
- }
229
- ]
230
- }
231
- },
232
- "required": [
233
- "elements",
234
- "relationships"
235
- ],
236
- "additionalProperties": false
160
+ "$ref": "#/$defs/ColorLiteral"
237
161
  }
238
162
  ]
239
163
  },
240
- "ColorLiteral": {
241
- "id": "ColorLiteral",
242
- "description": "Color value in any valid CSS format: hex, rgb, rgba, hsl, hsla ...",
243
- "type": "string",
244
- "minLength": 1
164
+ "StrictThemeColorValues": {
165
+ "id": "StrictThemeColorValues",
166
+ "description": "Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color value",
167
+ "type": "object",
168
+ "properties": {
169
+ "elements": {
170
+ "description": "Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values",
171
+ "anyOf": [
172
+ {
173
+ "$ref": "#/$defs/ElementColorValues"
174
+ },
175
+ {
176
+ "$ref": "#/$defs/ColorLiteral"
177
+ }
178
+ ]
179
+ },
180
+ "relationships": {
181
+ "description": "Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values",
182
+ "anyOf": [
183
+ {
184
+ "$ref": "#/$defs/RelationshipColorValues"
185
+ },
186
+ {
187
+ "$ref": "#/$defs/ColorLiteral"
188
+ }
189
+ ]
190
+ }
191
+ },
192
+ "required": [
193
+ "elements",
194
+ "relationships"
195
+ ],
196
+ "additionalProperties": false
245
197
  },
246
198
  "ElementColorValues": {
247
199
  "id": "ElementColorValues",
@@ -272,6 +224,11 @@
272
224
  ],
273
225
  "additionalProperties": false
274
226
  },
227
+ "ColorLiteral": {
228
+ "id": "ColorLiteral",
229
+ "type": "string",
230
+ "minLength": 1
231
+ },
275
232
  "RelationshipColorValues": {
276
233
  "id": "RelationshipColorValues",
277
234
  "type": "object",
@@ -286,6 +243,7 @@
286
243
  },
287
244
  "labelBg": {
288
245
  "description": "Label background color",
246
+ "default": "rgba(0, 0, 0, 0.5)",
289
247
  "$ref": "#/$defs/ColorLiteral"
290
248
  }
291
249
  },
@@ -295,32 +253,20 @@
295
253
  ],
296
254
  "additionalProperties": false
297
255
  },
298
- "ThemeSizes": {
299
- "id": "ThemeSizes",
300
- "description": "Override theme sizes",
301
- "type": "object",
302
- "properties": {
303
- "xs": {
304
- "$ref": "#/$defs/Dimensions"
305
- },
306
- "sm": {
307
- "$ref": "#/$defs/Dimensions"
308
- },
309
- "md": {
310
- "$ref": "#/$defs/Dimensions"
311
- },
312
- "lg": {
313
- "$ref": "#/$defs/Dimensions"
314
- },
315
- "xl": {
316
- "$ref": "#/$defs/Dimensions"
317
- }
318
- },
319
- "additionalProperties": false
256
+ "ElementSize": {
257
+ "id": "ElementSize",
258
+ "type": "string",
259
+ "enum": [
260
+ "xs",
261
+ "sm",
262
+ "md",
263
+ "lg",
264
+ "xl"
265
+ ]
320
266
  },
321
267
  "Dimensions": {
322
268
  "id": "Dimensions",
323
- "description": "Dimensions",
269
+ "description": "Defines dimensions for theme size",
324
270
  "type": "object",
325
271
  "properties": {
326
272
  "width": {
@@ -340,7 +286,6 @@
340
286
  },
341
287
  "DefaultStyleValues": {
342
288
  "id": "DefaultStyleValues",
343
- "description": "Override default values for style properties\nThese values will be used if such property is not defined",
344
289
  "type": "object",
345
290
  "properties": {
346
291
  "color": {
@@ -363,12 +308,16 @@
363
308
  "description": "Default shape for elements",
364
309
  "$ref": "#/$defs/ElementShape"
365
310
  },
311
+ "iconPosition": {
312
+ "description": "Default icon position for elements",
313
+ "$ref": "#/$defs/IconPosition"
314
+ },
366
315
  "group": {
367
- "description": "Default style values for groups",
316
+ "description": "Override default values for group style properties\nThese values will be used if such property is not defined",
368
317
  "$ref": "#/$defs/GroupDefaultStyleValues"
369
318
  },
370
319
  "relationship": {
371
- "description": "Default style values for relationships",
320
+ "description": "Override default values for relationship style properties\nThese values will be used if such property is not defined",
372
321
  "$ref": "#/$defs/RelationshipDefaultStyleValues"
373
322
  }
374
323
  },
@@ -391,17 +340,6 @@
391
340
  "none"
392
341
  ]
393
342
  },
394
- "ElementSize": {
395
- "id": "ElementSize",
396
- "type": "string",
397
- "enum": [
398
- "xs",
399
- "sm",
400
- "md",
401
- "lg",
402
- "xl"
403
- ]
404
- },
405
343
  "ElementShape": {
406
344
  "id": "ElementShape",
407
345
  "type": "string",
@@ -414,12 +352,22 @@
414
352
  "storage",
415
353
  "queue",
416
354
  "bucket",
417
- "document"
355
+ "document",
356
+ "component"
357
+ ]
358
+ },
359
+ "IconPosition": {
360
+ "id": "IconPosition",
361
+ "type": "string",
362
+ "enum": [
363
+ "left",
364
+ "right",
365
+ "top",
366
+ "bottom"
418
367
  ]
419
368
  },
420
369
  "GroupDefaultStyleValues": {
421
370
  "id": "GroupDefaultStyleValues",
422
- "description": "Override default values for group style properties\nThese values will be used if such property is not defined",
423
371
  "type": "object",
424
372
  "properties": {
425
373
  "color": {
@@ -482,8 +430,73 @@
482
430
  "vee"
483
431
  ]
484
432
  },
485
- "manual-layouts-config": {
486
- "id": "manual-layouts-config",
433
+ "CustomStylesheets": {
434
+ "id": "CustomStylesheets",
435
+ "anyOf": [
436
+ {
437
+ "type": "string",
438
+ "minLength": 1
439
+ },
440
+ {
441
+ "type": "array",
442
+ "items": {
443
+ "type": "string",
444
+ "minLength": 1
445
+ }
446
+ }
447
+ ]
448
+ },
449
+ "ImageAliases": {
450
+ "id": "ImageAliases",
451
+ "description": "Map of image alias prefixes to relative paths (keys must match /^@\\w+$/; values must be relative paths without protocol or leading slash).",
452
+ "type": "object",
453
+ "propertyNames": {
454
+ "type": "string",
455
+ "minLength": 1,
456
+ "pattern": "^@[A-Za-z0-9_-]*$"
457
+ },
458
+ "additionalProperties": {
459
+ "type": "string",
460
+ "minLength": 1,
461
+ "pattern": "^(?!\\/|[A-Za-z]:[\\\\\\/])(?!.*:\\/\\/).*$"
462
+ }
463
+ },
464
+ "include-config": {
465
+ "id": "include-config",
466
+ "description": "Configuration for including additional LikeC4 source files from other directories.\nExample: { \"paths\": [\"../shared\", \"../common/specs\"], \"maxDepth\": 5, \"fileThreshold\": 50 }",
467
+ "type": "object",
468
+ "properties": {
469
+ "paths": {
470
+ "description": "Additional relative directory paths to include LikeC4 source files from, searched recursively.\nPaths are relative to the project folder (the folder containing this config file).\nExample: [\"../shared\", \"../common/specs\"]",
471
+ "type": "array",
472
+ "items": {
473
+ "type": "string",
474
+ "minLength": 1,
475
+ "pattern": "^(?!\\/|[A-Za-z]:[\\\\\\/])(?!.*:\\/\\/).*$"
476
+ }
477
+ },
478
+ "maxDepth": {
479
+ "description": "Maximum directory depth to scan when searching for .c4 files in include paths.\nPrevents excessive scanning of deeply nested directories.\nDefault: 3",
480
+ "default": 3,
481
+ "type": "integer",
482
+ "minimum": 1,
483
+ "maximum": 20
484
+ },
485
+ "fileThreshold": {
486
+ "description": "Maximum number of files to load from include paths before warning.\nHelps identify performance issues from accidentally including large directories.\nDefault: 30",
487
+ "default": 30,
488
+ "type": "integer",
489
+ "minimum": 1,
490
+ "maximum": 10000
491
+ }
492
+ },
493
+ "required": [
494
+ "paths"
495
+ ],
496
+ "additionalProperties": false
497
+ },
498
+ "ManualLayoutsConfig": {
499
+ "id": "ManualLayoutsConfig",
487
500
  "description": "Configuration for manual layouts",
488
501
  "type": "object",
489
502
  "properties": {
@@ -492,7 +505,8 @@
492
505
  "default": ".likec4",
493
506
  "type": "string"
494
507
  }
495
- }
508
+ },
509
+ "additionalProperties": false
496
510
  }
497
511
  }
498
512
  }
@@ -1,14 +1,8 @@
1
1
  import type { LikeC4ProjectStylesConfig, LikeC4ProjectTheme, ThemeColorValues } from '@likec4/core/types'
2
2
  import type { GeneratorFn, LikeC4ProjectConfig, LikeC4ProjectConfigInput } from './schema'
3
3
  import { GeneratorsSchema, LikeC4ProjectConfigSchema } from './schema'
4
- import {
5
- type LikeC4ConfigThemeInput,
6
- type LikeC4StylesConfigInput,
7
- type ThemeColorValuesInput,
8
- LikeC4Config_Styles_Theme,
9
- LikeC4StylesConfigSchema,
10
- ThemeColorValuesSchema,
11
- } from './schema.theme'
4
+ import type { LikeC4ConfigThemeInput, LikeC4StylesConfigInput, ThemeColorValuesInput } from './schema.theme'
5
+ import { LikeC4Config_Styles_Theme, LikeC4StylesConfigSchema, ThemeColorValuesSchema } from './schema.theme'
12
6
 
13
7
  /**
14
8
  * Defines LikeC4 Project, allows custom generators that can be executed using CLI:
@@ -22,9 +16,10 @@ import {
22
16
  * export default defineConfig({
23
17
  * name: 'my-project',
24
18
  * title: 'My Project',
19
+ *
25
20
  * exclude: ['picomatch pattern'],
26
21
  * generators: {
27
- * 'my-generator': async ({ likec4model, ctx }) => {
22
+ * '<generator-name>': async ({ likec4model, ctx }) => {
28
23
  * await ctx.write('my-generator.txt', likec4model.project.id)
29
24
  * }
30
25
  * }
package/src/filenames.ts CHANGED
@@ -1,13 +1,17 @@
1
- const configJsonFilenames = [
1
+ import { basename } from 'pathe'
2
+
3
+ export const configJsonFilenames = [
2
4
  '.likec4rc',
3
5
  '.likec4.config.json',
4
6
  'likec4.config.json',
5
7
  ] as const
6
8
 
7
- const configNonJsonFilenames = [
9
+ export const configNonJsonFilenames = [
8
10
  'likec4.config.js',
11
+ 'likec4.config.cjs',
9
12
  'likec4.config.mjs',
10
13
  'likec4.config.ts',
14
+ 'likec4.config.cts',
11
15
  'likec4.config.mts',
12
16
  ] as const
13
17
 
@@ -20,24 +24,14 @@ export const ConfigFilenames = [
20
24
  * Checks if the given filename is a LikeC4 JSON config file (JSON, RC).
21
25
  */
22
26
  export function isLikeC4JsonConfig(filename: string): filename is typeof configJsonFilenames[number] {
23
- for (const ext of configJsonFilenames) {
24
- if (filename.endsWith(ext)) {
25
- return true
26
- }
27
- }
28
- return false
27
+ return (configJsonFilenames as readonly string[]).includes(basename(filename))
29
28
  }
30
29
 
31
30
  /**
32
31
  * Checks if the given filename is a LikeC4 non-JSON config file (JS, MJS, TS, MTS)
33
32
  */
34
33
  export function isLikeC4NonJsonConfig(filename: string): filename is typeof configNonJsonFilenames[number] {
35
- for (const ext of configNonJsonFilenames) {
36
- if (filename.endsWith(ext)) {
37
- return true
38
- }
39
- }
40
- return false
34
+ return (configNonJsonFilenames as readonly string[]).includes(basename(filename))
41
35
  }
42
36
 
43
37
  /**
package/src/index.ts CHANGED
@@ -6,7 +6,10 @@ export type {
6
6
  LikeC4ProjectConfigInput,
7
7
  LikeC4ProjectJsonConfig,
8
8
  LocateResult,
9
- ManualLayoutsConfigSchema,
9
+ } from './schema'
10
+
11
+ export {
12
+ LikeC4ProjectConfigOps,
10
13
  } from './schema'
11
14
 
12
15
  export type {
@@ -14,14 +17,12 @@ export type {
14
17
  } from './schema.include'
15
18
 
16
19
  export type {
20
+ LikeC4ConfigThemeInput,
17
21
  LikeC4StylesConfig,
18
22
  LikeC4StylesConfigInput,
23
+ ThemeColorValuesInput,
19
24
  } from './schema.theme'
20
25
 
21
- export { validateProjectConfig } from './schema'
22
-
23
- export { normalizeIncludeConfig, validateIncludePaths } from './schema.include'
24
-
25
26
  export {
26
27
  ConfigFilenames,
27
28
  isLikeC4Config,
package/src/node/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from '../index'
2
+
2
3
  export { loadConfig } from './load-config'