@likec4/config 1.47.0 → 1.48.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
@@ -84,7 +84,8 @@
84
84
  },
85
85
  "required": [
86
86
  "paths"
87
- ]
87
+ ],
88
+ "additionalProperties": false
88
89
  },
89
90
  "StylesConfiguration": {
90
91
  "id": "StylesConfiguration",
@@ -96,6 +97,9 @@
96
97
  },
97
98
  "defaults": {
98
99
  "$ref": "#/$defs/DefaultStyleValues"
100
+ },
101
+ "customCss": {
102
+ "$ref": "#/$defs/CustomStylesheets"
99
103
  }
100
104
  },
101
105
  "additionalProperties": false
@@ -117,55 +121,13 @@
117
121
  "ThemeColors": {
118
122
  "id": "ThemeColors",
119
123
  "description": "Override theme colors",
120
- "anyOf": [
121
- {
122
- "type": "object",
123
- "propertyNames": {
124
- "$ref": "#/$defs/ColorName"
125
- },
126
- "additionalProperties": {
127
- "$ref": "#/$defs/ThemeColorValues"
128
- }
129
- },
130
- {
131
- "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
- }
166
- }
167
- }
168
- ]
124
+ "type": "object",
125
+ "propertyNames": {
126
+ "$ref": "#/$defs/ColorName"
127
+ },
128
+ "additionalProperties": {
129
+ "$ref": "#/$defs/ThemeColorValues"
130
+ }
169
131
  },
170
132
  "ColorName": {
171
133
  "id": "ColorName",
@@ -174,8 +136,7 @@
174
136
  "$ref": "#/$defs/ThemeColor"
175
137
  },
176
138
  {
177
- "type": "string",
178
- "minLength": 1
139
+ "$ref": "#/$defs/CustomColorName"
179
140
  }
180
141
  ]
181
142
  },
@@ -196,6 +157,11 @@
196
157
  "sky"
197
158
  ]
198
159
  },
160
+ "CustomColorName": {
161
+ "id": "CustomColorName",
162
+ "type": "string",
163
+ "minLength": 1
164
+ },
199
165
  "ThemeColorValues": {
200
166
  "id": "ThemeColorValues",
201
167
  "description": "Exact value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values",
@@ -204,36 +170,7 @@
204
170
  "$ref": "#/$defs/ColorLiteral"
205
171
  },
206
172
  {
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
173
+ "$ref": "#/$defs/StrictThemeColorValues"
237
174
  }
238
175
  ]
239
176
  },
@@ -243,6 +180,39 @@
243
180
  "type": "string",
244
181
  "minLength": 1
245
182
  },
183
+ "StrictThemeColorValues": {
184
+ "id": "StrictThemeColorValues",
185
+ "type": "object",
186
+ "properties": {
187
+ "elements": {
188
+ "description": "Element color value (or a breakdown of specific color values)",
189
+ "anyOf": [
190
+ {
191
+ "$ref": "#/$defs/ColorLiteral"
192
+ },
193
+ {
194
+ "$ref": "#/$defs/ElementColorValues"
195
+ }
196
+ ]
197
+ },
198
+ "relationships": {
199
+ "description": "Relationship color value (or a breakdown of specific color values)",
200
+ "anyOf": [
201
+ {
202
+ "$ref": "#/$defs/ColorLiteral"
203
+ },
204
+ {
205
+ "$ref": "#/$defs/RelationshipColorValues"
206
+ }
207
+ ]
208
+ }
209
+ },
210
+ "required": [
211
+ "elements",
212
+ "relationships"
213
+ ],
214
+ "additionalProperties": false
215
+ },
246
216
  "ElementColorValues": {
247
217
  "id": "ElementColorValues",
248
218
  "type": "object",
@@ -363,6 +333,10 @@
363
333
  "description": "Default shape for elements",
364
334
  "$ref": "#/$defs/ElementShape"
365
335
  },
336
+ "iconPosition": {
337
+ "description": "Default icon position for elements",
338
+ "$ref": "#/$defs/IconPosition"
339
+ },
366
340
  "group": {
367
341
  "description": "Default style values for groups",
368
342
  "$ref": "#/$defs/GroupDefaultStyleValues"
@@ -417,6 +391,16 @@
417
391
  "document"
418
392
  ]
419
393
  },
394
+ "IconPosition": {
395
+ "id": "IconPosition",
396
+ "type": "string",
397
+ "enum": [
398
+ "left",
399
+ "right",
400
+ "top",
401
+ "bottom"
402
+ ]
403
+ },
420
404
  "GroupDefaultStyleValues": {
421
405
  "id": "GroupDefaultStyleValues",
422
406
  "description": "Override default values for group style properties\nThese values will be used if such property is not defined",
@@ -482,6 +466,23 @@
482
466
  "vee"
483
467
  ]
484
468
  },
469
+ "CustomStylesheets": {
470
+ "id": "CustomStylesheets",
471
+ "description": "Custom CSS (or list of CSS files) to be included in the generated diagrams",
472
+ "anyOf": [
473
+ {
474
+ "type": "string",
475
+ "minLength": 1
476
+ },
477
+ {
478
+ "type": "array",
479
+ "items": {
480
+ "type": "string",
481
+ "minLength": 1
482
+ }
483
+ }
484
+ ]
485
+ },
485
486
  "manual-layouts-config": {
486
487
  "id": "manual-layouts-config",
487
488
  "description": "Configuration for manual layouts",
@@ -492,7 +493,8 @@
492
493
  "default": ".likec4",
493
494
  "type": "string"
494
495
  }
495
- }
496
+ },
497
+ "additionalProperties": false
496
498
  }
497
499
  }
498
500
  }
@@ -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
@@ -6,8 +6,10 @@ const configJsonFilenames = [
6
6
 
7
7
  const configNonJsonFilenames = [
8
8
  'likec4.config.js',
9
+ 'likec4.config.cjs',
9
10
  'likec4.config.mjs',
10
11
  'likec4.config.ts',
12
+ 'likec4.config.cts',
11
13
  'likec4.config.mts',
12
14
  ] as const
13
15
 
package/src/node/index.ts CHANGED
@@ -1,2 +1,40 @@
1
- export * from '../index'
1
+ export type {
2
+ GeneratorFn,
3
+ GeneratorFnContext,
4
+ GeneratorFnParams,
5
+ LikeC4ProjectConfig,
6
+ LikeC4ProjectConfigInput,
7
+ LikeC4ProjectJsonConfig,
8
+ LocateResult,
9
+ ManualLayoutsConfigSchema,
10
+ } from '../schema'
11
+
12
+ export type {
13
+ IncludeConfig,
14
+ } from '../schema.include'
15
+
16
+ export type {
17
+ LikeC4StylesConfig,
18
+ LikeC4StylesConfigInput,
19
+ } from '../schema.theme'
20
+
21
+ export { validateProjectConfig } from '../schema'
22
+
23
+ export { normalizeIncludeConfig, validateIncludePaths } from '../schema.include'
24
+
25
+ export {
26
+ ConfigFilenames,
27
+ isLikeC4Config,
28
+ isLikeC4JsonConfig,
29
+ isLikeC4NonJsonConfig,
30
+ } from '../filenames'
31
+
32
+ export {
33
+ defineConfig,
34
+ defineGenerators,
35
+ defineStyle,
36
+ defineTheme,
37
+ defineThemeColor,
38
+ } from '../define-config'
39
+
2
40
  export { loadConfig } from './load-config'
@@ -1,18 +1,19 @@
1
1
  import { invariant } from '@likec4/core'
2
+ import { rootLogger } from '@likec4/log'
2
3
  import { bundleRequire } from 'bundle-require'
3
4
  import * as fs from 'node:fs/promises'
4
5
  import { dirname } from 'node:path'
5
- import type { URI } from 'vscode-uri'
6
6
  import { defineConfig } from '../define-config'
7
7
  import { isLikeC4JsonConfig, isLikeC4NonJsonConfig } from '../filenames'
8
- import { logger } from '../logger'
9
- import { type LikeC4ProjectConfig, validateProjectConfig } from '../schema'
8
+ import type { LikeC4ProjectConfig, VscodeURI } from '../schema'
9
+ import { validateProjectConfig } from '../schema'
10
10
 
11
11
  /**
12
12
  * Load LikeC4 Project config file.
13
13
  * If filepath is a non-JSON file, it will be bundled and required
14
14
  */
15
- export async function loadConfig(filepath: URI): Promise<LikeC4ProjectConfig> {
15
+ export async function loadConfig(filepath: VscodeURI): Promise<LikeC4ProjectConfig> {
16
+ const logger = rootLogger.getChild('config')
16
17
  logger.debug`Loading config file: ${filepath.fsPath}`
17
18
  if (isLikeC4JsonConfig(filepath.fsPath)) {
18
19
  try {
@@ -31,12 +32,12 @@ export async function loadConfig(filepath: URI): Promise<LikeC4ProjectConfig> {
31
32
  filepath: filepath.fsPath,
32
33
  cwd,
33
34
  esbuildOptions: {
34
- resolveExtensions: ['.mjs', '.js', '.ts', '.mts'],
35
+ resolveExtensions: ['.ts', '.mts', '.cts', '.mjs', '.js', '.cjs'],
35
36
  plugins: [{
36
37
  name: 'likec4-config',
37
38
  setup(build) {
38
39
  /**
39
- * Intercept @likec4/config imports
40
+ * Intercept @likec4/config and likec4/config imports
40
41
  */
41
42
  build.onResolve({ filter: /^@?likec4\/config$/ }, (args) => ({
42
43
  path: args.path,
@@ -1,4 +1,4 @@
1
- import * as z from 'zod'
1
+ import z from 'zod/v4'
2
2
 
3
3
  // Key must be prefixed with "@" and contain only allowed characters
4
4
  const IMAGE_ALIAS_KEY_REGEX = /^@[A-Za-z0-9_-]*$/
@@ -1,4 +1,4 @@
1
- import * as z from 'zod'
1
+ import z from 'zod/v4'
2
2
 
3
3
  // Relative path (no leading slash, drive letter, or protocol)
4
4
  // eslint-disable-next-line no-useless-escape
@@ -13,7 +13,7 @@ const IncludePathValue = z
13
13
  'Include path must be a relative path (no leading slash, drive letter, or protocol)',
14
14
  )
15
15
 
16
- export const IncludeConfigSchema = z.object({
16
+ export const IncludeConfigSchema = z.strictObject({
17
17
  paths: z.array(IncludePathValue)
18
18
  .min(1, 'Include paths cannot be empty')
19
19
  .meta({
@@ -72,7 +72,7 @@ export function normalizeIncludeConfig(include?: LikeC4IncludeConfig): IncludeCo
72
72
  return include
73
73
  }
74
74
 
75
- export function validateIncludePaths(include?: LikeC4IncludeConfig) {
75
+ export function validateIncludePaths(include?: LikeC4IncludeConfig): void {
76
76
  if (!include?.paths) {
77
77
  return
78
78
  }
@@ -85,7 +85,7 @@ export function validateIncludePaths(include?: LikeC4IncludeConfig) {
85
85
  }
86
86
  }
87
87
 
88
- if (invalidPaths.length) {
88
+ if (invalidPaths.length > 0) {
89
89
  throw new Error(
90
90
  `Invalid include path(s): ${
91
91
  invalidPaths
@@ -1,24 +1,30 @@
1
+ // oxlint-disable no-unsafe-type-assertion
2
+ import type {
3
+ ColorLiteral,
4
+ ElementColorValues,
5
+ RelationshipColorValues,
6
+ ThemeColorValues,
7
+ } from '@likec4/core/styles'
1
8
  import {
2
- type ColorLiteral,
3
- type ElementColorValues,
4
- type RelationshipColorValues,
5
- type ThemeColor,
6
- type ThemeColorValues,
7
9
  BorderStyles,
8
10
  computeColorValues,
9
11
  ElementShapes,
12
+ IconPositions,
10
13
  RelationshipArrowTypes,
11
14
  Sizes,
12
15
  ThemeColors,
13
16
  } from '@likec4/core/styles'
14
- import {
15
- type LikeC4ProjectStyleDefaults,
16
- type LikeC4ProjectStylesConfig,
17
- type LikeC4ProjectTheme,
18
- exact,
17
+ import type {
18
+ CustomColor,
19
+ LikeC4ProjectStyleDefaults,
20
+ LikeC4ProjectStylesConfig,
21
+ LikeC4ProjectStylesCustomStylesheets,
22
+ LikeC4ProjectTheme,
23
+ ThemeColor,
19
24
  } from '@likec4/core/types'
25
+ import { exact } from '@likec4/core/types'
20
26
  import { fromKeys } from 'remeda'
21
- import * as z from 'zod'
27
+ import z from 'zod/v4'
22
28
 
23
29
  const opacity = z
24
30
  .int()
@@ -41,6 +47,10 @@ const size = z
41
47
  .literal(Sizes)
42
48
  .meta({ id: 'ElementSize' })
43
49
 
50
+ const iconPosition = z
51
+ .literal(IconPositions)
52
+ .meta({ id: 'IconPosition' })
53
+
44
54
  const arrow = z
45
55
  .literal(RelationshipArrowTypes)
46
56
  .meta({ id: 'ArrowType' })
@@ -53,10 +63,19 @@ const themeColor = z
53
63
  .literal(ThemeColors)
54
64
  .meta({ id: 'ThemeColor' })
55
65
 
66
+ const customColor = z
67
+ .string()
68
+ .min(1, 'Custom color name cannot be empty')
69
+ .transform(value => value as unknown as CustomColor)
70
+ .meta({ id: 'CustomColorName' })
71
+
72
+ // type ColorNameLiteral = ThemeColor | string & Record<never, never>
73
+
56
74
  const color = z
75
+ // .custom<ColorNameLiteral>(v => typeof v === 'string')
57
76
  .union([
58
77
  themeColor,
59
- z.string().min(1, 'Color name cannot be empty'),
78
+ customColor,
60
79
  ])
61
80
  .transform(value => value as ThemeColor)
62
81
  .meta({ id: 'ColorName' })
@@ -90,35 +109,40 @@ const RelationshipColorValuesSchema = z
90
109
  label: colorSchema.meta({ description: 'Label text color' }),
91
110
  labelBg: colorSchema
92
111
  .optional()
93
- .default('rgba(0, 0, 0, 0)')
112
+ .default('rgba(0, 0, 0, 0.5)')
94
113
  .meta({ description: 'Label background color' }),
95
114
  })
96
115
  .meta({ id: 'RelationshipColorValues' })
97
116
  .transform(value => value as RelationshipColorValues)
98
117
 
118
+ const StrictThemeColorValuesSchema = z.strictObject({
119
+ elements: z
120
+ .union([colorSchema, ElementColorValuesSchema])
121
+ .meta({ description: 'Element color value (or a breakdown of specific color values)' })
122
+ .transform((value): ElementColorValues => {
123
+ if (typeof value === 'string') {
124
+ return computeColorValues(value).elements
125
+ }
126
+ return value
127
+ }),
128
+ relationships: z
129
+ .union([colorSchema, RelationshipColorValuesSchema])
130
+ .meta({
131
+ description: 'Relationship color value (or a breakdown of specific color values)',
132
+ })
133
+ .transform((value): RelationshipColorValues => {
134
+ if (typeof value === 'string') {
135
+ return computeColorValues(value).relationships
136
+ }
137
+ return value
138
+ }),
139
+ })
140
+ .meta({ id: 'StrictThemeColorValues' })
141
+
99
142
  export const ThemeColorValuesSchema = z
100
143
  .union([
101
144
  colorSchema,
102
- z.strictObject({
103
- elements: z
104
- .union([colorSchema, ElementColorValuesSchema])
105
- .meta({ description: 'Element color value (or a breakdown of specific color values)' })
106
- .transform((value): ElementColorValues => {
107
- if (typeof value === 'string') {
108
- return computeColorValues(value).elements
109
- }
110
- return value
111
- }),
112
- relationships: z
113
- .union([colorSchema, RelationshipColorValuesSchema])
114
- .meta({ description: 'Relationship color value (or a breakdown of specific color values)' })
115
- .transform((value): RelationshipColorValues => {
116
- if (typeof value === 'string') {
117
- return computeColorValues(value).relationships
118
- }
119
- return value
120
- }),
121
- }),
145
+ StrictThemeColorValuesSchema,
122
146
  ])
123
147
  .meta({
124
148
  id: 'ThemeColorValues',
@@ -132,18 +156,12 @@ export const ThemeColorValuesSchema = z
132
156
  })
133
157
  export type ThemeColorValuesInput = z.input<typeof ThemeColorValuesSchema>
134
158
 
135
- const ThemeColorsSchema = z.union([
136
- z.record(
137
- color,
138
- ThemeColorValuesSchema,
139
- ),
140
- z.object(
141
- fromKeys(ThemeColors, () => ThemeColorValuesSchema.optional()),
142
- ),
143
- ]).meta({
144
- id: 'ThemeColors',
145
- description: 'Override theme colors',
146
- })
159
+ const ThemeColorsSchema = z.record(color, ThemeColorValuesSchema)
160
+ .meta({
161
+ id: 'ThemeColors',
162
+ description: 'Override theme colors',
163
+ })
164
+ .transform(value => value as Record<ThemeColor, ThemeColorValues>)
147
165
 
148
166
  const DimensionsSchema = z.strictObject({
149
167
  width: z.number().min(50),
@@ -220,6 +238,7 @@ const LikeC4Config_Styles_Defaults = z
220
238
  }),
221
239
  size: size.optional().meta({ description: 'Default size for elements' }),
222
240
  shape: shape.optional().meta({ description: 'Default shape for elements' }),
241
+ iconPosition: iconPosition.optional().meta({ description: 'Default icon position for elements' }),
223
242
  group: LikeC4Config_Styles_Defaults_Group.optional().meta({ description: 'Default style values for groups' }),
224
243
  relationship: LikeC4Config_Styles_Defaults_Relationship.optional().meta({
225
244
  description: 'Default style values for relationships',
@@ -231,21 +250,32 @@ const LikeC4Config_Styles_Defaults = z
231
250
  'Override default values for style properties\nThese values will be used if such property is not defined',
232
251
  })
233
252
 
253
+ const LikeC4Config_Styles_CustomStylesheets = z
254
+ .union([
255
+ z.string().min(1, 'Custom CSS file path cannot be empty'),
256
+ z.array(
257
+ z.string().min(1, 'Custom CSS file path cannot be empty'),
258
+ ),
259
+ ])
260
+ .meta({
261
+ id: 'CustomStylesheets',
262
+ description: 'Custom CSS (or list of CSS files) to be included in the generated diagrams',
263
+ })
264
+
234
265
  export const LikeC4StylesConfigSchema = z
235
266
  .strictObject({
236
267
  theme: LikeC4Config_Styles_Theme.optional(),
237
268
  defaults: LikeC4Config_Styles_Defaults.optional(),
238
- // customCss: z
239
- // .array(z.string())
240
- // .meta({ description: 'List of custom CSS files' }),
269
+ customCss: LikeC4Config_Styles_CustomStylesheets.optional(),
241
270
  })
242
271
  .meta({
243
272
  id: 'StylesConfiguration',
244
273
  description: 'Project styles customization',
245
274
  })
246
- .transform(({ theme, defaults }): LikeC4ProjectStylesConfig =>
275
+ .transform(({ theme, defaults, customCss }): LikeC4ProjectStylesConfig =>
247
276
  exact({
248
277
  defaults: normalizeDefaults(defaults),
278
+ customCss: normalizeStylesheets(customCss),
249
279
  theme,
250
280
  })
251
281
  )
@@ -262,7 +292,24 @@ function normalizeDefaults(
262
292
  const { relationship, group, ...rest } = defaults
263
293
  return exact({
264
294
  ...rest,
265
- relationship: relationship && exact(relationship) as LikeC4ProjectStyleDefaults['relationship'],
266
- group: group && exact(group) as LikeC4ProjectStyleDefaults['group'],
295
+ relationship: relationship && exact(relationship) satisfies LikeC4ProjectStyleDefaults['relationship'],
296
+ group: group && exact(group) satisfies LikeC4ProjectStyleDefaults['group'],
267
297
  })
268
298
  }
299
+
300
+ function normalizeStylesheets(
301
+ stylesheets?: z.infer<typeof LikeC4Config_Styles_CustomStylesheets>,
302
+ ): LikeC4ProjectStylesCustomStylesheets | undefined {
303
+ if (!stylesheets) {
304
+ return undefined
305
+ }
306
+ const paths = (Array.isArray(stylesheets) ? stylesheets : [stylesheets]).filter(Boolean)
307
+ if (paths.length === 0) {
308
+ return undefined
309
+ }
310
+
311
+ return {
312
+ paths,
313
+ content: '',
314
+ }
315
+ }
package/src/schema.ts CHANGED
@@ -12,14 +12,23 @@ import type {
12
12
  } from '@likec4/core/types'
13
13
  import JSON5 from 'json5'
14
14
  import type { SimplifyDeep } from 'type-fest'
15
- import type { URI } from 'vscode-uri'
16
- import * as z from 'zod'
15
+ import z from 'zod/v4'
17
16
  import { ImageAliasesSchema, validateImageAliases } from './schema.image-alias'
18
17
  import { IncludeSchema, validateIncludePaths } from './schema.include'
19
18
  import { LikeC4StylesConfigSchema } from './schema.theme'
20
19
 
20
+ export interface VscodeURI {
21
+ readonly scheme: string
22
+ readonly authority: string
23
+ readonly path: string
24
+ readonly fsPath: string
25
+ readonly query: string
26
+ readonly fragment: string
27
+ toString(): string
28
+ }
29
+
21
30
  export const ManualLayoutsConfigSchema = z
22
- .object({
31
+ .strictObject({
23
32
  outDir: z.string()
24
33
  .default('.likec4')
25
34
  .meta({
@@ -101,7 +110,7 @@ export type LocateResult = {
101
110
  /**
102
111
  * Full path to the source file
103
112
  */
104
- document: URI
113
+ document: VscodeURI
105
114
  /**
106
115
  * Document path relative to the project folder
107
116
  */
@@ -120,7 +129,7 @@ export interface GeneratorFnContext {
120
129
  /**
121
130
  * Workspace root directory
122
131
  */
123
- readonly workspace: URI
132
+ readonly workspace: VscodeURI
124
133
 
125
134
  /**
126
135
  * Current project
@@ -136,7 +145,7 @@ export interface GeneratorFnContext {
136
145
  /**
137
146
  * Project folder
138
147
  */
139
- readonly folder: URI
148
+ readonly folder: VscodeURI
140
149
  }
141
150
 
142
151
  /**
@@ -158,7 +167,7 @@ export interface GeneratorFnContext {
158
167
  * @param content - Content of the file
159
168
  */
160
169
  write(file: {
161
- path: string | string[] | URI
170
+ path: string | string[] | VscodeURI
162
171
  content:
163
172
  | string
164
173
  | NodeJS.ArrayBufferView