@domainlang/language 0.11.0 → 0.13.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/out/ast-augmentation.d.ts +7 -2
- package/out/diagram/context-map-diagram-generator.d.ts +72 -0
- package/out/diagram/context-map-diagram-generator.js +405 -0
- package/out/diagram/context-map-diagram-generator.js.map +1 -0
- package/out/diagram/context-map-layout-configurator.d.ts +15 -0
- package/out/diagram/context-map-layout-configurator.js +39 -0
- package/out/diagram/context-map-layout-configurator.js.map +1 -0
- package/out/diagram/elk-layout-factory.d.ts +43 -0
- package/out/diagram/elk-layout-factory.js +64 -0
- package/out/diagram/elk-layout-factory.js.map +1 -0
- package/out/domain-lang-module.d.ts +7 -0
- package/out/domain-lang-module.js +11 -2
- package/out/domain-lang-module.js.map +1 -1
- package/out/generated/ast.d.ts +323 -51
- package/out/generated/ast.js +194 -33
- package/out/generated/ast.js.map +1 -1
- package/out/generated/grammar.js +418 -172
- package/out/generated/grammar.js.map +1 -1
- package/out/index.d.ts +3 -0
- package/out/index.js +4 -0
- package/out/index.js.map +1 -1
- package/out/lsp/domain-lang-code-lens-provider.d.ts +8 -0
- package/out/lsp/domain-lang-code-lens-provider.js +48 -0
- package/out/lsp/domain-lang-code-lens-provider.js.map +1 -0
- package/out/lsp/domain-lang-completion.js +39 -15
- package/out/lsp/domain-lang-completion.js.map +1 -1
- package/out/lsp/domain-lang-document-symbol-provider.js +5 -5
- package/out/lsp/domain-lang-document-symbol-provider.js.map +1 -1
- package/out/lsp/domain-lang-formatter.js +32 -0
- package/out/lsp/domain-lang-formatter.js.map +1 -1
- package/out/lsp/domain-lang-index-manager.d.ts +2 -3
- package/out/lsp/domain-lang-index-manager.js +5 -8
- package/out/lsp/domain-lang-index-manager.js.map +1 -1
- package/out/lsp/domain-lang-workspace-manager.d.ts +1 -1
- package/out/lsp/domain-lang-workspace-manager.js +2 -26
- package/out/lsp/domain-lang-workspace-manager.js.map +1 -1
- package/out/lsp/explain.js +9 -3
- package/out/lsp/explain.js.map +1 -1
- package/out/lsp/hover/domain-lang-hover.js +13 -11
- package/out/lsp/hover/domain-lang-hover.js.map +1 -1
- package/out/lsp/hover/domain-lang-keywords.js +29 -26
- package/out/lsp/hover/domain-lang-keywords.js.map +1 -1
- package/out/lsp/tool-handlers.js +63 -57
- package/out/lsp/tool-handlers.js.map +1 -1
- package/out/sdk/ast-augmentation.d.ts +29 -21
- package/out/sdk/ast-augmentation.js +11 -7
- package/out/sdk/ast-augmentation.js.map +1 -1
- package/out/sdk/index.d.ts +2 -2
- package/out/sdk/index.js +1 -1
- package/out/sdk/index.js.map +1 -1
- package/out/sdk/loader-node.js +2 -2
- package/out/sdk/loader-node.js.map +1 -1
- package/out/sdk/patterns.d.ts +50 -61
- package/out/sdk/patterns.js +92 -62
- package/out/sdk/patterns.js.map +1 -1
- package/out/sdk/query.js +54 -43
- package/out/sdk/query.js.map +1 -1
- package/out/sdk/serializers.js +20 -7
- package/out/sdk/serializers.js.map +1 -1
- package/out/sdk/types.d.ts +87 -18
- package/out/sdk/types.js.map +1 -1
- package/out/sdk/validator.js +48 -64
- package/out/sdk/validator.js.map +1 -1
- package/out/services/performance-optimizer.d.ts +3 -3
- package/out/services/performance-optimizer.js +1 -3
- package/out/services/performance-optimizer.js.map +1 -1
- package/out/services/relationship-inference.d.ts +4 -4
- package/out/services/relationship-inference.js +34 -46
- package/out/services/relationship-inference.js.map +1 -1
- package/out/syntaxes/domain-lang.monarch.js +1 -1
- package/out/syntaxes/domain-lang.monarch.js.map +1 -1
- package/out/utils/import-utils.d.ts +6 -20
- package/out/utils/import-utils.js +3 -63
- package/out/utils/import-utils.js.map +1 -1
- package/out/validation/constants.d.ts +23 -6
- package/out/validation/constants.js +24 -7
- package/out/validation/constants.js.map +1 -1
- package/out/validation/maps.js +10 -4
- package/out/validation/maps.js.map +1 -1
- package/out/validation/relationships.d.ts +4 -8
- package/out/validation/relationships.js +96 -48
- package/out/validation/relationships.js.map +1 -1
- package/package.json +5 -2
- package/src/ast-augmentation.ts +7 -2
- package/src/diagram/context-map-diagram-generator.ts +513 -0
- package/src/diagram/context-map-layout-configurator.ts +43 -0
- package/src/diagram/elk-layout-factory.ts +83 -0
- package/src/domain-lang-module.ts +19 -2
- package/src/domain-lang.langium +62 -26
- package/src/generated/ast.ts +413 -63
- package/src/generated/grammar.ts +418 -172
- package/src/index.ts +5 -0
- package/src/lsp/domain-lang-code-lens-provider.ts +54 -0
- package/src/lsp/domain-lang-completion.ts +42 -15
- package/src/lsp/domain-lang-document-symbol-provider.ts +5 -5
- package/src/lsp/domain-lang-formatter.ts +34 -0
- package/src/lsp/domain-lang-index-manager.ts +6 -9
- package/src/lsp/domain-lang-workspace-manager.ts +3 -29
- package/src/lsp/explain.ts +10 -2
- package/src/lsp/hover/domain-lang-hover.ts +10 -8
- package/src/lsp/hover/domain-lang-keywords.ts +27 -24
- package/src/lsp/tool-handlers.ts +61 -47
- package/src/sdk/ast-augmentation.ts +30 -21
- package/src/sdk/index.ts +11 -1
- package/src/sdk/loader-node.ts +2 -2
- package/src/sdk/patterns.ts +114 -76
- package/src/sdk/query.ts +57 -48
- package/src/sdk/serializers.ts +20 -7
- package/src/sdk/types.ts +92 -17
- package/src/sdk/validator.ts +52 -69
- package/src/services/performance-optimizer.ts +4 -6
- package/src/services/relationship-inference.ts +43 -54
- package/src/utils/import-utils.ts +9 -74
- package/src/validation/constants.ts +32 -9
- package/src/validation/maps.ts +12 -4
- package/src/validation/relationships.ts +150 -71
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ELK layout engine factory for DomainLang diagrams.
|
|
3
|
+
*
|
|
4
|
+
* Encapsulates the ELK construction, factory wiring, and Sprotty-ELK layout
|
|
5
|
+
* engine instantiation so that both the VS Code extension (via the LSP server
|
|
6
|
+
* DI module) and the CLI (for standalone diagram export) can reuse the same
|
|
7
|
+
* layout logic without embedding the setup inline.
|
|
8
|
+
*
|
|
9
|
+
* @module diagram/elk-layout-factory
|
|
10
|
+
*/
|
|
11
|
+
import * as ElkBundled from 'elkjs/lib/elk.bundled.js';
|
|
12
|
+
import type { ELK } from 'elkjs/lib/elk-api.js';
|
|
13
|
+
import {
|
|
14
|
+
DefaultElementFilter,
|
|
15
|
+
ElkLayoutEngine,
|
|
16
|
+
type ElkFactory,
|
|
17
|
+
type IElementFilter,
|
|
18
|
+
type ILayoutConfigurator,
|
|
19
|
+
} from 'sprotty-elk/lib/elk-layout.js';
|
|
20
|
+
import type { IModelLayoutEngine } from 'sprotty-protocol';
|
|
21
|
+
import { ContextMapLayoutConfigurator } from './context-map-layout-configurator.js';
|
|
22
|
+
|
|
23
|
+
/** @internal Handles the dual ESM/CJS export shape of the bundled ELK module. */
|
|
24
|
+
type ElkConstructor = new (args?: { algorithms?: string[] }) => ELK;
|
|
25
|
+
const _elkConstructor: ElkConstructor = (
|
|
26
|
+
(ElkBundled as unknown as { default?: ElkConstructor }).default
|
|
27
|
+
?? (ElkBundled as unknown as ElkConstructor)
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Creates an {@link ElkFactory} that produces a new bundled ELK instance
|
|
32
|
+
* pre-configured for the `layered` algorithm.
|
|
33
|
+
*
|
|
34
|
+
* Use this in Langium's DI module (`layout.ElkFactory`) or directly in the
|
|
35
|
+
* CLI when running the layout engine standalone.
|
|
36
|
+
*/
|
|
37
|
+
export function createElkFactory(): ElkFactory {
|
|
38
|
+
return () => new _elkConstructor({ algorithms: ['layered'] });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates the full set of objects required to run the ELK layout engine for
|
|
43
|
+
* DomainLang context-map diagrams.
|
|
44
|
+
*
|
|
45
|
+
* Returns the three collaborators that together constitute a complete
|
|
46
|
+
* `IModelLayoutEngine`:
|
|
47
|
+
* - `elkFactory` — produces the ELK worker instance
|
|
48
|
+
* - `elementFilter` — controls which model elements are laid out
|
|
49
|
+
* - `layoutConfigurator` — supplies algorithm-specific ELK options
|
|
50
|
+
*
|
|
51
|
+
* Callers that use Langium DI should register these individually via the
|
|
52
|
+
* `layout` service group. Callers that operate outside of DI (e.g. the CLI)
|
|
53
|
+
* can call {@link createElkLayoutEngine} for a fully assembled engine.
|
|
54
|
+
*/
|
|
55
|
+
export function createElkLayoutComponents(): {
|
|
56
|
+
elkFactory: ElkFactory;
|
|
57
|
+
elementFilter: IElementFilter;
|
|
58
|
+
layoutConfigurator: ILayoutConfigurator;
|
|
59
|
+
} {
|
|
60
|
+
return {
|
|
61
|
+
elkFactory: createElkFactory(),
|
|
62
|
+
elementFilter: new DefaultElementFilter(),
|
|
63
|
+
layoutConfigurator: new ContextMapLayoutConfigurator(),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Creates a fully assembled {@link IModelLayoutEngine} for DomainLang
|
|
69
|
+
* context-map diagrams using the bundled ELK engine.
|
|
70
|
+
*
|
|
71
|
+
* Intended for use outside of Langium's DI container — for example, in the
|
|
72
|
+
* CLI when generating standalone SVG or image exports.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const layoutEngine = createElkLayoutEngine();
|
|
77
|
+
* const laidOutModel = await layoutEngine.layout(rootModel);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export function createElkLayoutEngine(): IModelLayoutEngine {
|
|
81
|
+
const { elkFactory, elementFilter, layoutConfigurator } = createElkLayoutComponents();
|
|
82
|
+
return new ElkLayoutEngine(elkFactory, elementFilter, layoutConfigurator) as IModelLayoutEngine;
|
|
83
|
+
}
|
|
@@ -16,13 +16,18 @@ import { DomainLangFormatter } from './lsp/domain-lang-formatter.js';
|
|
|
16
16
|
import { DomainLangHoverProvider } from './lsp/hover/domain-lang-hover.js';
|
|
17
17
|
import { DomainLangCompletionProvider } from './lsp/domain-lang-completion.js';
|
|
18
18
|
import { DomainLangCodeActionProvider } from './lsp/domain-lang-code-actions.js';
|
|
19
|
+
import { DomainLangCodeLensProvider } from './lsp/domain-lang-code-lens-provider.js';
|
|
19
20
|
import { DomainLangNodeKindProvider } from './lsp/domain-lang-node-kind-provider.js';
|
|
20
21
|
import { DomainLangDocumentSymbolProvider } from './lsp/domain-lang-document-symbol-provider.js';
|
|
22
|
+
import { SprottyDefaultModule, SprottySharedModule } from 'langium-sprotty';
|
|
23
|
+
import type { IDiagramGenerator, IModelLayoutEngine } from 'sprotty-protocol';
|
|
21
24
|
import { ImportResolver } from './services/import-resolver.js';
|
|
22
25
|
import { ManifestManager } from './services/workspace-manager.js';
|
|
23
26
|
import { PackageBoundaryDetector } from './services/package-boundary-detector.js';
|
|
24
27
|
import { DomainLangWorkspaceManager } from './lsp/domain-lang-workspace-manager.js';
|
|
25
28
|
import { DomainLangIndexManager } from './lsp/domain-lang-index-manager.js';
|
|
29
|
+
import { DomainLangContextMapDiagramGenerator } from './diagram/context-map-diagram-generator.js';
|
|
30
|
+
import { createElkLayoutEngine } from './diagram/elk-layout-factory.js';
|
|
26
31
|
|
|
27
32
|
/**
|
|
28
33
|
* Declaration of custom services - add your own service classes here.
|
|
@@ -40,8 +45,13 @@ export type DomainLangAddedServices = {
|
|
|
40
45
|
Formatter: DomainLangFormatter,
|
|
41
46
|
HoverProvider: DomainLangHoverProvider,
|
|
42
47
|
CompletionProvider: DomainLangCompletionProvider,
|
|
48
|
+
CodeLensProvider: DomainLangCodeLensProvider,
|
|
43
49
|
CodeActionProvider: DomainLangCodeActionProvider
|
|
44
|
-
}
|
|
50
|
+
},
|
|
51
|
+
diagram: {
|
|
52
|
+
DiagramGenerator: IDiagramGenerator,
|
|
53
|
+
ModelLayoutEngine: IModelLayoutEngine
|
|
54
|
+
},
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
/**
|
|
@@ -80,9 +90,14 @@ export const DomainLangModule: Module<DomainLangServices, PartialLangiumServices
|
|
|
80
90
|
Formatter: () => new DomainLangFormatter(),
|
|
81
91
|
HoverProvider: (services) => new DomainLangHoverProvider(services),
|
|
82
92
|
CompletionProvider: (services) => new DomainLangCompletionProvider(services),
|
|
93
|
+
CodeLensProvider: () => new DomainLangCodeLensProvider(),
|
|
83
94
|
CodeActionProvider: () => new DomainLangCodeActionProvider(),
|
|
84
95
|
DocumentSymbolProvider: (services) => new DomainLangDocumentSymbolProvider(services)
|
|
85
96
|
},
|
|
97
|
+
diagram: {
|
|
98
|
+
DiagramGenerator: (services) => new DomainLangContextMapDiagramGenerator(services as never),
|
|
99
|
+
ModelLayoutEngine: () => createElkLayoutEngine(),
|
|
100
|
+
},
|
|
86
101
|
};
|
|
87
102
|
|
|
88
103
|
/**
|
|
@@ -107,11 +122,13 @@ export function createDomainLangServices(context: DefaultSharedModuleContext): {
|
|
|
107
122
|
const shared = inject(
|
|
108
123
|
createDefaultSharedModule(context),
|
|
109
124
|
DomainLangGeneratedSharedModule,
|
|
110
|
-
DomainLangSharedModule
|
|
125
|
+
DomainLangSharedModule,
|
|
126
|
+
SprottySharedModule as never
|
|
111
127
|
);
|
|
112
128
|
const DomainLang = inject(
|
|
113
129
|
createDefaultModule({ shared }),
|
|
114
130
|
DomainLangGeneratedModule,
|
|
131
|
+
SprottyDefaultModule as never,
|
|
115
132
|
DomainLangModule
|
|
116
133
|
);
|
|
117
134
|
shared.ServiceRegistry.register(DomainLang);
|
package/src/domain-lang.langium
CHANGED
|
@@ -204,17 +204,53 @@ DomainMap:
|
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
206
|
* Relationship - Connection between two Bounded Contexts.
|
|
207
|
-
*
|
|
207
|
+
* Uses entity–relationship–entity structure where the relationship expression
|
|
208
|
+
* (type, arrow, side annotations) sits between the two entity references.
|
|
209
|
+
*
|
|
210
|
+
* Forms:
|
|
211
|
+
* Directional: Orders [OHS] -> [CF] Payments
|
|
212
|
+
* Symmetric: CardManagement [SK] AccountManagement
|
|
213
|
+
* Separate Ways arrow: Orders >< Payments
|
|
208
214
|
*
|
|
209
215
|
* [Read more on domainlang.net](https://domainlang.net/reference/language#relationships)
|
|
210
216
|
*/
|
|
211
217
|
Relationship:
|
|
212
|
-
|
|
218
|
+
DirectionalRelationship | SymmetricRelationship
|
|
219
|
+
;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Directional relationship - upstream/downstream with optional side patterns.
|
|
223
|
+
*
|
|
224
|
+
* Examples:
|
|
225
|
+
* Orders [OHS] -> [CF] Payments
|
|
226
|
+
* Orders [S] -> [C] Payments
|
|
227
|
+
* Orders -> Payments
|
|
228
|
+
* Orders [OHS] <-> [CF] Payments
|
|
229
|
+
*/
|
|
230
|
+
DirectionalRelationship:
|
|
231
|
+
left=BoundedContextRef
|
|
232
|
+
('[' leftPatterns+=SidePattern (',' leftPatterns+=SidePattern)* ']')?
|
|
233
|
+
arrow=DirectionalArrow
|
|
234
|
+
('[' rightPatterns+=SidePattern (',' rightPatterns+=SidePattern)* ']')?
|
|
235
|
+
right=BoundedContextRef
|
|
236
|
+
;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Symmetric relationship - mutual pattern between two contexts, no directionality.
|
|
240
|
+
*
|
|
241
|
+
* Examples:
|
|
242
|
+
* CardManagement [SK] AccountManagement
|
|
243
|
+
* Orders [P] Payments
|
|
244
|
+
* Orders >< Payments
|
|
245
|
+
* Orders [SW] Payments
|
|
246
|
+
*/
|
|
247
|
+
SymmetricRelationship:
|
|
213
248
|
left=BoundedContextRef
|
|
214
|
-
|
|
215
|
-
|
|
249
|
+
(
|
|
250
|
+
'[' pattern=SymmetricPattern ']'
|
|
251
|
+
| arrow='><'
|
|
252
|
+
)
|
|
216
253
|
right=BoundedContextRef
|
|
217
|
-
(Assignment type=RelationshipType)?
|
|
218
254
|
;
|
|
219
255
|
|
|
220
256
|
/**
|
|
@@ -225,40 +261,40 @@ BoundedContextRef:
|
|
|
225
261
|
;
|
|
226
262
|
|
|
227
263
|
/**
|
|
228
|
-
*
|
|
264
|
+
* Directional relationship arrows.
|
|
229
265
|
*
|
|
230
266
|
* Arrow semantics:
|
|
231
267
|
* -> Upstream to downstream (left provides, right consumes)
|
|
232
268
|
* <- Downstream to upstream (right provides, left consumes)
|
|
233
|
-
* <-> Bidirectional
|
|
234
|
-
* >< Separate Ways (no integration, teams go their own way)
|
|
269
|
+
* <-> Bidirectional (mutual data flow with explicit patterns)
|
|
235
270
|
*/
|
|
236
|
-
|
|
237
|
-
'<->' | '->' | '<-'
|
|
271
|
+
DirectionalArrow returns string:
|
|
272
|
+
'<->' | '->' | '<-'
|
|
238
273
|
;
|
|
239
274
|
|
|
240
275
|
/**
|
|
241
|
-
* DDD
|
|
276
|
+
* DDD Side Patterns - describe one side's role in a directional relationship.
|
|
277
|
+
* Each pattern produces a distinct AST node type via {infer} actions.
|
|
278
|
+
* Short and long forms parse to the same node type.
|
|
242
279
|
*/
|
|
243
|
-
|
|
244
|
-
'
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
280
|
+
SidePattern:
|
|
281
|
+
{infer OpenHostService} ('OHS' | 'OpenHostService')
|
|
282
|
+
| {infer PublishedLanguage} ('PL' | 'PublishedLanguage')
|
|
283
|
+
| {infer Conformist} ('CF' | 'Conformist')
|
|
284
|
+
| {infer AntiCorruptionLayer} ('ACL' | 'AntiCorruptionLayer')
|
|
285
|
+
| {infer Supplier} ('S' | 'Supplier')
|
|
286
|
+
| {infer Customer} ('C' | 'Customer')
|
|
287
|
+
| {infer BigBallOfMud} ('BBoM'| 'BigBallOfMud')
|
|
251
288
|
;
|
|
252
289
|
|
|
253
290
|
/**
|
|
254
|
-
* DDD
|
|
291
|
+
* DDD Symmetric Patterns - describe the relationship between two contexts.
|
|
292
|
+
* These are mutual/shared patterns, not directional.
|
|
255
293
|
*/
|
|
256
|
-
|
|
257
|
-
'
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
| 'UpstreamDownstream'
|
|
261
|
-
| 'SeparateWays'
|
|
294
|
+
SymmetricPattern:
|
|
295
|
+
{infer SharedKernel} ('SK' | 'SharedKernel')
|
|
296
|
+
| {infer Partnership} ('P' | 'Partnership')
|
|
297
|
+
| {infer SeparateWays} ('SW' | 'SeparateWays')
|
|
262
298
|
;
|
|
263
299
|
|
|
264
300
|
// ============================================================================
|