@likec4/language-server 1.19.0 → 1.19.1

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.
Files changed (59) hide show
  1. package/dist/Rpc.js +6 -0
  2. package/dist/browser.d.ts +1 -0
  3. package/dist/documentation/documentation-provider.d.ts +8 -0
  4. package/dist/documentation/documentation-provider.js +46 -0
  5. package/dist/documentation/index.d.ts +1 -0
  6. package/dist/documentation/index.js +1 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +3 -2
  9. package/dist/lsp/DocumentSymbolProvider.d.ts +11 -2
  10. package/dist/lsp/DocumentSymbolProvider.js +78 -6
  11. package/dist/model/fqn-computation.js +2 -2
  12. package/dist/model/model-builder.js +3 -3
  13. package/dist/module.d.ts +9 -1
  14. package/dist/module.js +47 -8
  15. package/dist/protocol.d.ts +19 -1
  16. package/dist/protocol.js +1 -0
  17. package/dist/references/scope-computation.d.ts +2 -2
  18. package/dist/references/scope-computation.js +9 -9
  19. package/dist/validation/dynamic-view-rule.js +3 -2
  20. package/dist/validation/dynamic-view-step.js +23 -27
  21. package/dist/validation/property-checks.js +3 -2
  22. package/dist/validation/specification.js +14 -14
  23. package/dist/validation/view-predicates/element-with.js +3 -2
  24. package/dist/validation/view-predicates/expanded-element.js +3 -2
  25. package/dist/validation/view-predicates/incoming.js +3 -2
  26. package/dist/validation/view-predicates/outgoing.js +3 -2
  27. package/dist/validation/view-predicates/relation-with.js +3 -2
  28. package/dist/validation/view.js +3 -3
  29. package/dist/views/configurable-layouter.d.ts +7 -0
  30. package/dist/views/configurable-layouter.js +55 -0
  31. package/dist/views/index.d.ts +1 -0
  32. package/dist/views/index.js +1 -0
  33. package/dist/views/likec4-views.d.ts +26 -0
  34. package/dist/views/likec4-views.js +113 -0
  35. package/package.json +13 -10
  36. package/src/Rpc.ts +13 -7
  37. package/src/browser.ts +1 -0
  38. package/src/documentation/documentation-provider.ts +52 -0
  39. package/src/documentation/index.ts +1 -0
  40. package/src/index.ts +4 -2
  41. package/src/lsp/DocumentSymbolProvider.ts +110 -28
  42. package/src/model/fqn-computation.ts +8 -8
  43. package/src/model/model-builder.ts +52 -52
  44. package/src/module.ts +56 -9
  45. package/src/protocol.ts +29 -4
  46. package/src/references/scope-computation.ts +35 -35
  47. package/src/validation/dynamic-view-rule.ts +5 -4
  48. package/src/validation/dynamic-view-step.ts +23 -26
  49. package/src/validation/property-checks.ts +11 -10
  50. package/src/validation/specification.ts +38 -38
  51. package/src/validation/view-predicates/element-with.ts +6 -5
  52. package/src/validation/view-predicates/expanded-element.ts +6 -5
  53. package/src/validation/view-predicates/incoming.ts +6 -5
  54. package/src/validation/view-predicates/outgoing.ts +6 -5
  55. package/src/validation/view-predicates/relation-with.ts +6 -5
  56. package/src/validation/view.ts +5 -5
  57. package/src/views/configurable-layouter.ts +65 -0
  58. package/src/views/index.ts +1 -0
  59. package/src/views/likec4-views.ts +139 -0
@@ -1,14 +1,14 @@
1
1
  import type * as c4 from '@likec4/core'
2
2
  import {
3
+ type CustomColorDefinitions,
4
+ type ViewId,
3
5
  compareRelations,
4
6
  computeColorValues,
5
- type CustomColorDefinitions,
6
7
  DeploymentElement,
7
8
  isScopedElementView,
8
9
  LikeC4Model,
9
10
  parentFqn,
10
11
  sortByFqnHierarchically,
11
- type ViewId
12
12
  } from '@likec4/core'
13
13
  import { resolveRulesExtendedViews } from '@likec4/core/compute-view'
14
14
  import { deepEqual as eq } from 'fast-equals'
@@ -34,7 +34,7 @@ import {
34
34
  reduce,
35
35
  reverse,
36
36
  sort,
37
- values
37
+ values,
38
38
  } from 'remeda'
39
39
  import type {
40
40
  ParsedAstDeploymentRelation,
@@ -43,10 +43,10 @@ import type {
43
43
  ParsedAstSpecification,
44
44
  ParsedAstView,
45
45
  ParsedLikeC4LangiumDocument,
46
- ParsedLink
46
+ ParsedLink,
47
47
  } from '../ast'
48
48
  import { isParsedLikeC4LangiumDocument } from '../ast'
49
- import { logError, logger, logWarnError } from '../logger'
49
+ import { logger, logWarnError } from '../logger'
50
50
  import type { LikeC4Services } from '../module'
51
51
  import { assignNavigateTo, resolveRelativePaths } from '../view-utils'
52
52
 
@@ -57,17 +57,17 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
57
57
  deployments: {},
58
58
  elements: {},
59
59
  relationships: {},
60
- colors: {}
60
+ colors: {},
61
61
  }
62
62
  const globals: c4.ModelGlobals = {
63
63
  predicates: {},
64
64
  dynamicPredicates: {},
65
- styles: {}
65
+ styles: {},
66
66
  }
67
67
  for (const doc of docs) {
68
68
  const {
69
69
  c4Specification: spec,
70
- c4Globals
70
+ c4Globals,
71
71
  } = doc
72
72
 
73
73
  spec.tags.forEach(t => c4Specification.tags.add(t))
@@ -89,20 +89,20 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
89
89
  if (relative && relative !== link.url) {
90
90
  return {
91
91
  ...link,
92
- relative
92
+ relative,
93
93
  }
94
94
  }
95
95
  } catch (e) {
96
96
  logWarnError(e)
97
97
  }
98
98
  return link
99
- }
99
+ },
100
100
  )
101
101
  }
102
102
 
103
103
  const customColorDefinitions: CustomColorDefinitions = mapValues(
104
104
  c4Specification.colors,
105
- c => computeColorValues(c.color)
105
+ c => computeColorValues(c.color),
106
106
  )
107
107
 
108
108
  function toModelElement(doc: LangiumDocument) {
@@ -114,14 +114,14 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
114
114
  shape,
115
115
  icon,
116
116
  opacity,
117
- border
117
+ border,
118
118
  },
119
119
  id,
120
120
  kind,
121
121
  title,
122
122
  description,
123
123
  technology,
124
- metadata
124
+ metadata,
125
125
  }: ParsedAstElement): c4.Element | null => {
126
126
  try {
127
127
  const __kind = c4Specification.elements[kind]
@@ -144,7 +144,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
144
144
  ...(__kind.notation && { notation: __kind.notation }),
145
145
  style: {
146
146
  ...(border && { border }),
147
- ...(isNumber(opacity) && { opacity })
147
+ ...(isNumber(opacity) && { opacity }),
148
148
  },
149
149
  links,
150
150
  tags: tags ?? null,
@@ -152,7 +152,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
152
152
  description: description ?? null,
153
153
  title,
154
154
  kind,
155
- id
155
+ id,
156
156
  }
157
157
  } catch (e) {
158
158
  logWarnError(e)
@@ -178,8 +178,8 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
178
178
  acc[el.id] = el
179
179
  return acc
180
180
  },
181
- {} as c4.ParsedLikeC4Model['elements']
182
- )
181
+ {} as c4.ParsedLikeC4Model['elements'],
182
+ ),
183
183
  )
184
184
 
185
185
  function toModelRelation(doc: LangiumDocument) {
@@ -196,7 +196,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
196
196
  logger.warn(
197
197
  `Invalid relation ${id} at ${doc.uri.path} ${astPath}, source: ${source}(${!!elements[
198
198
  source
199
- ]}), target: ${target}(${!!elements[target]})`
199
+ ]}), target: ${target}(${!!elements[target]})`,
200
200
  )
201
201
  return null
202
202
  }
@@ -210,7 +210,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
210
210
  source,
211
211
  target,
212
212
  kind,
213
- id
213
+ id,
214
214
  } satisfies c4.ModelRelation
215
215
  }
216
216
  return {
@@ -218,7 +218,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
218
218
  ...model,
219
219
  source,
220
220
  target,
221
- id
221
+ id,
222
222
  } satisfies c4.ModelRelation
223
223
  }
224
224
  }
@@ -229,7 +229,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
229
229
  filter(isTruthy),
230
230
  sort(compareRelations),
231
231
  reverse(),
232
- indexBy(prop('id'))
232
+ indexBy(prop('id')),
233
233
  )
234
234
 
235
235
  function toDeploymentElement(doc: LangiumDocument) {
@@ -241,7 +241,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
241
241
  const links = resolveLinks(doc, parsed.links)
242
242
  return {
243
243
  ...parsed,
244
- links
244
+ links,
245
245
  }
246
246
  }
247
247
  try {
@@ -254,7 +254,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
254
254
  technology = __kind.technology,
255
255
  notation = __kind.notation,
256
256
  links,
257
- style
257
+ style,
258
258
  } = parsed
259
259
  return {
260
260
  ...parsed,
@@ -264,9 +264,9 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
264
264
  border: 'dashed',
265
265
  opacity: 10,
266
266
  ...__kind.style,
267
- ...style
267
+ ...style,
268
268
  },
269
- links: links ? resolveLinks(doc, links) : null
269
+ links: links ? resolveLinks(doc, links) : null,
270
270
  }
271
271
  } catch (e) {
272
272
  logWarnError(e)
@@ -292,8 +292,8 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
292
292
  acc[el.id] = el
293
293
  return acc
294
294
  },
295
- {} as c4.ParsedLikeC4Model['deployments']['elements']
296
- )
295
+ {} as c4.ParsedLikeC4Model['deployments']['elements'],
296
+ ),
297
297
  )
298
298
 
299
299
  function toDeploymentRelation(doc: LangiumDocument) {
@@ -310,7 +310,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
310
310
  logger.warn(
311
311
  `Invalid deployment relation ${id} at ${doc.uri.path} ${astPath}, source: ${source.id}(${!!deploymentElements[
312
312
  source.id
313
- ]}), target: ${target.id}(${!!deploymentElements[target.id]})`
313
+ ]}), target: ${target.id}(${!!deploymentElements[target.id]})`,
314
314
  )
315
315
  return null
316
316
  }
@@ -324,7 +324,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
324
324
  source,
325
325
  target,
326
326
  kind,
327
- id
327
+ id,
328
328
  } satisfies c4.DeploymentRelation
329
329
  }
330
330
  return {
@@ -332,7 +332,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
332
332
  ...model,
333
333
  source,
334
334
  target,
335
- id
335
+ id,
336
336
  } satisfies c4.DeploymentRelation
337
337
  }
338
338
  }
@@ -350,8 +350,8 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
350
350
  acc[el.id] = el
351
351
  return acc
352
352
  },
353
- {} as c4.ParsedLikeC4Model['deployments']['relations']
354
- )
353
+ {} as c4.ParsedLikeC4Model['deployments']['relations'],
354
+ ),
355
355
  )
356
356
 
357
357
  function toC4View(doc: LangiumDocument) {
@@ -387,7 +387,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
387
387
  docUri,
388
388
  description,
389
389
  title,
390
- id
390
+ id,
391
391
  }
392
392
  }
393
393
  }
@@ -396,7 +396,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
396
396
  docs,
397
397
  flatMap(d => map(d.c4Views, toC4View(d))),
398
398
  // Resolve relative paths and sort by
399
- resolveRelativePaths
399
+ resolveRelativePaths,
400
400
  )
401
401
  // Add index view if not present
402
402
  if (!parsedViews.some(v => v.id === 'index')) {
@@ -412,18 +412,18 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
412
412
  {
413
413
  include: [
414
414
  {
415
- wildcard: true
416
- }
417
- ]
418
- }
419
- ]
415
+ wildcard: true,
416
+ },
417
+ ],
418
+ },
419
+ ],
420
420
  })
421
421
  }
422
422
 
423
423
  const views = pipe(
424
424
  parsedViews,
425
425
  indexBy(prop('id')),
426
- resolveRulesExtendedViews
426
+ resolveRulesExtendedViews,
427
427
  )
428
428
 
429
429
  return {
@@ -431,7 +431,7 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
431
431
  tags: Array.from(c4Specification.tags),
432
432
  elements: c4Specification.elements,
433
433
  relationships: c4Specification.relationships,
434
- deployments: c4Specification.deployments
434
+ deployments: c4Specification.deployments,
435
435
  },
436
436
  elements,
437
437
  relations,
@@ -439,8 +439,8 @@ function buildModel(services: LikeC4Services, docs: ParsedLikeC4LangiumDocument[
439
439
  views,
440
440
  deployments: {
441
441
  elements: deploymentElements,
442
- relations: deploymentRelations
443
- }
442
+ relations: deploymentRelations,
443
+ },
444
444
  }
445
445
  }
446
446
 
@@ -479,7 +479,7 @@ export class LikeC4ModelBuilder {
479
479
  this.notifyListeners(parsed)
480
480
  }
481
481
  return await Promise.resolve()
482
- }
482
+ },
483
483
  )
484
484
  logger.debug(`[ModelBuilder] Created`)
485
485
  }
@@ -552,16 +552,16 @@ export class LikeC4ModelBuilder {
552
552
  'elements',
553
553
  'relations',
554
554
  'globals',
555
- 'deployments'
556
- ])
555
+ 'deployments',
556
+ ]),
557
557
  ),
558
- views
558
+ views,
559
559
  }
560
560
  })
561
561
  }
562
562
 
563
563
  public async buildComputedModel(
564
- cancelToken?: Cancellation.CancellationToken
564
+ cancelToken?: Cancellation.CancellationToken,
565
565
  ): Promise<c4.ComputedLikeC4Model | null> {
566
566
  const cache = this.services.WorkspaceCache as WorkspaceCache<string, c4.ComputedLikeC4Model | null>
567
567
  if (cache.has(CACHE_KEY_COMPUTED_MODEL)) {
@@ -581,7 +581,7 @@ export class LikeC4ModelBuilder {
581
581
 
582
582
  public async computeView(
583
583
  viewId: ViewId,
584
- cancelToken?: Cancellation.CancellationToken
584
+ cancelToken?: Cancellation.CancellationToken,
585
585
  ): Promise<c4.ComputedView | null> {
586
586
  const cache = this.services.WorkspaceCache as WorkspaceCache<string, c4.ComputedView | null>
587
587
  const cacheKey = computedViewKey(viewId)
@@ -601,7 +601,7 @@ export class LikeC4ModelBuilder {
601
601
  }
602
602
  const result = LikeC4Model.makeCompute(model)(view)
603
603
  if (!result.isSuccess) {
604
- logError(result.error)
604
+ logWarnError(result.error)
605
605
  return null
606
606
  }
607
607
  let computedView = result.view
@@ -611,7 +611,7 @@ export class LikeC4ModelBuilder {
611
611
  values(),
612
612
  filter(isScopedElementView),
613
613
  filter(v => v.id !== viewId),
614
- groupBy(v => v.viewOf)
614
+ groupBy(v => v.viewOf),
615
615
  )
616
616
 
617
617
  for (const node of computedView.nodes) {
@@ -654,7 +654,7 @@ export class LikeC4ModelBuilder {
654
654
  try {
655
655
  listener(docs)
656
656
  } catch (e) {
657
- logError(e)
657
+ logWarnError(e)
658
658
  }
659
659
  }
660
660
  }
package/src/module.ts CHANGED
@@ -1,4 +1,11 @@
1
- import { type Module, DocumentCache, EmptyFileSystem, inject, WorkspaceCache } from 'langium'
1
+ import { GraphvizLayouter, GraphvizWasmAdapter } from '@likec4/layouts'
2
+ import {
3
+ type Module,
4
+ DocumentCache,
5
+ EmptyFileSystem,
6
+ inject,
7
+ WorkspaceCache,
8
+ } from 'langium'
2
9
  import {
3
10
  type DefaultSharedModuleContext,
4
11
  type LangiumServices,
@@ -8,9 +15,13 @@ import {
8
15
  createDefaultModule,
9
16
  createDefaultSharedModule,
10
17
  } from 'langium/lsp'
18
+ import { LikeC4DocumentationProvider } from './documentation'
11
19
  import { LikeC4Formatter } from './formatting/LikeC4Formatter'
12
- import { LikeC4GeneratedModule, LikeC4GeneratedSharedModule } from './generated/module'
13
- import { logToLspConnection } from './logger'
20
+ import {
21
+ LikeC4GeneratedModule,
22
+ LikeC4GeneratedSharedModule,
23
+ } from './generated/module'
24
+ import { logger, logToLspConnection } from './logger'
14
25
  import {
15
26
  LikeC4CodeLensProvider,
16
27
  LikeC4CompletionProvider,
@@ -20,12 +31,27 @@ import {
20
31
  LikeC4HoverProvider,
21
32
  LikeC4SemanticTokenProvider,
22
33
  } from './lsp'
23
- import { DeploymentsIndex, FqnIndex, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser } from './model'
34
+ import {
35
+ DeploymentsIndex,
36
+ FqnIndex,
37
+ LikeC4ModelBuilder,
38
+ LikeC4ModelLocator,
39
+ LikeC4ModelParser,
40
+ } from './model'
24
41
  import { LikeC4ModelChanges } from './model-change/ModelChanges'
25
- import { LikeC4NameProvider, LikeC4ScopeComputation, LikeC4ScopeProvider } from './references'
42
+ import {
43
+ LikeC4NameProvider,
44
+ LikeC4ScopeComputation,
45
+ LikeC4ScopeProvider,
46
+ } from './references'
26
47
  import { Rpc } from './Rpc'
27
- import { LikeC4WorkspaceManager, NodeKindProvider, WorkspaceSymbolProvider } from './shared'
48
+ import {
49
+ LikeC4WorkspaceManager,
50
+ NodeKindProvider,
51
+ WorkspaceSymbolProvider,
52
+ } from './shared'
28
53
  import { registerValidationChecks } from './validation'
54
+ import { LikeC4Views } from './views'
29
55
 
30
56
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
57
  type Constructor<T, Arguments extends unknown[] = any[]> = new(...arguments_: Arguments) => T
@@ -59,11 +85,16 @@ const LikeC4SharedModule: Module<
59
85
  * Declaration of custom services - add your own service classes here.
60
86
  */
61
87
  export interface LikeC4AddedServices {
88
+ documentation: {
89
+ DocumentationProvider: LikeC4DocumentationProvider
90
+ }
62
91
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
92
  WorkspaceCache: WorkspaceCache<string, any>
64
93
  DocumentCache: DocumentCache<string, any>
65
94
  Rpc: Rpc
66
95
  likec4: {
96
+ Views: LikeC4Views
97
+ Layouter: GraphvizLayouter
67
98
  DeploymentsIndex: DeploymentsIndex
68
99
  FqnIndex: FqnIndex
69
100
  ModelParser: LikeC4ModelParser
@@ -96,10 +127,18 @@ function bind<T>(Type: Constructor<T, [LikeC4Services]>) {
96
127
  }
97
128
 
98
129
  export const LikeC4Module: Module<LikeC4Services, PartialLangiumServices & LikeC4AddedServices> = {
130
+ documentation: {
131
+ DocumentationProvider: bind(LikeC4DocumentationProvider),
132
+ },
99
133
  WorkspaceCache: (services: LikeC4Services) => new WorkspaceCache(services.shared),
100
134
  DocumentCache: (services: LikeC4Services) => new DocumentCache(services.shared),
101
135
  Rpc: bind(Rpc),
102
136
  likec4: {
137
+ Layouter: (_services: LikeC4Services) => {
138
+ logger.debug('Creating GraphvizLayouter with GraphvizWasmAdapter')
139
+ return new GraphvizLayouter(new GraphvizWasmAdapter())
140
+ },
141
+ Views: bind(LikeC4Views),
103
142
  DeploymentsIndex: bind(DeploymentsIndex),
104
143
  ModelChanges: bind(LikeC4ModelChanges),
105
144
  FqnIndex: bind(FqnIndex),
@@ -129,7 +168,7 @@ export type LanguageServicesContext = Partial<DefaultSharedModuleContext>
129
168
 
130
169
  export function createCustomLanguageServices<I1, I2, I3, I extends I1 & I2 & I3 & LikeC4Services>(
131
170
  context: LanguageServicesContext,
132
- module: Module<I, I1>,
171
+ module?: Module<I, I1>,
133
172
  module2?: Module<I, I2>,
134
173
  module3?: Module<I, I3>,
135
174
  ): { shared: LikeC4SharedServices; likec4: I } {
@@ -179,11 +218,19 @@ export function createLanguageServices(context: LanguageServicesContext = {}): {
179
218
  likec4: LikeC4Services
180
219
  } {
181
220
  const shared = createSharedServices(context)
182
- const likec4 = inject(createDefaultModule({ shared }), LikeC4GeneratedModule, LikeC4Module)
221
+ const likec4 = inject(
222
+ createDefaultModule({ shared }),
223
+ LikeC4GeneratedModule,
224
+ LikeC4Module,
225
+ )
183
226
  shared.ServiceRegistry.register(likec4)
184
227
  registerValidationChecks(likec4)
185
228
 
186
- if (context.connection) {
229
+ if (!context.connection) {
230
+ // We don't run inside a language server
231
+ // Therefore, initialize the configuration provider instantly
232
+ shared.workspace.ConfigurationProvider.initialized({})
233
+ } else {
187
234
  likec4.Rpc.init()
188
235
  }
189
236
 
package/src/protocol.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import type {
2
2
  ComputedLikeC4Model,
3
3
  ComputedView,
4
+ DiagramView,
4
5
  Fqn,
5
6
  ParsedLikeC4Model,
6
7
  RelationId,
7
8
  ViewChange,
8
- ViewId
9
+ ViewId,
9
10
  } from '@likec4/core'
10
11
  import { NotificationType, RequestType, RequestType0 } from 'vscode-jsonrpc'
11
12
  import type { DocumentUri, Location } from 'vscode-languageserver-types'
@@ -16,8 +17,9 @@ export type OnDidChangeModelNotification = typeof onDidChangeModel
16
17
  // #endregion
17
18
 
18
19
  // #region To server
20
+
19
21
  export const fetchModel = new RequestType0<{ model: ParsedLikeC4Model | null }, void>(
20
- 'likec4/fetchModel'
22
+ 'likec4/fetchModel',
21
23
  )
22
24
  export type FetchModelRequest = typeof fetchModel
23
25
 
@@ -26,21 +28,44 @@ export const fetchComputedModel = new RequestType<
26
28
  { model: ComputedLikeC4Model | null },
27
29
  void
28
30
  >(
29
- 'likec4/fetchComputedModel'
31
+ 'likec4/fetchComputedModel',
30
32
  )
31
33
  export type FetchComputedModelRequest = typeof fetchComputedModel
32
34
 
33
35
  export const computeView = new RequestType<{ viewId: ViewId }, { view: ComputedView | null }, void>(
34
- 'likec4/computeView'
36
+ 'likec4/computeView',
35
37
  )
36
38
  export type ComputeViewRequest = typeof computeView
37
39
 
40
+ /**
41
+ * Request to layout a view.
42
+ */
43
+ export const layoutView = new RequestType<
44
+ { viewId: ViewId },
45
+ {
46
+ result:
47
+ | {
48
+ dot: string
49
+ diagram: DiagramView
50
+ }
51
+ | null
52
+ },
53
+ void
54
+ >('likec4/layout-view')
55
+ export type LayoutViewRequest = typeof layoutView
56
+
57
+ /**
58
+ * Request to build documents.
59
+ */
38
60
  export interface BuildDocumentsParams {
39
61
  docs: DocumentUri[]
40
62
  }
41
63
  export const buildDocuments = new RequestType<BuildDocumentsParams, void, void>('likec4/build')
42
64
  export type BuildDocumentsRequest = typeof buildDocuments
43
65
 
66
+ /**
67
+ * Request to locate an element, relation, deployment or view.
68
+ */
44
69
  export type LocateParams =
45
70
  | {
46
71
  element: Fqn