@domainlang/language 0.1.81 → 0.1.82

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 (2) hide show
  1. package/README.md +147 -16
  2. package/package.json +18 -7
package/README.md CHANGED
@@ -1,32 +1,163 @@
1
- # domain-lang-language
1
+ # @domainlang/language
2
2
 
3
- This package contains the DomainLang grammar, language services (parsing, linking, validation), and the Model Query SDK.
3
+ [![npm version](https://img.shields.io/npm/v/@domainlang/language.svg)](https://www.npmjs.com/package/@domainlang/language)
4
+ [![License](https://img.shields.io/npm/l/@domainlang/language.svg)](https://github.com/larsbaunwall/DomainLang/blob/main/LICENSE)
4
5
 
5
- ## Key paths
6
+ Core language library for [DomainLang](https://github.com/larsbaunwall/DomainLang) - a Domain-Driven Design modeling language built with [Langium](https://langium.org/).
6
7
 
7
- - src/domain-lang.langium: grammar
8
- - src/generated/: generated output from Langium (do not edit)
9
- - src/validation/: semantic validation rules
10
- - src/lsp/: LSP features (hover, completion, formatting)
11
- - src/sdk/README.md: Model Query SDK documentation
8
+ ## Features
12
9
 
13
- ## Common workflows
10
+ - 🔤 **Parser** - Full DomainLang grammar with error recovery
11
+ - ✅ **Validation** - Semantic validation for DDD best practices
12
+ - 🔗 **Linking** - Cross-reference resolution across files and packages
13
+ - 🔍 **Model Query SDK** - Programmatic access to DDD models with fluent queries
14
+ - 🌐 **Browser Support** - Works in Node.js and browser environments
14
15
 
15
- From the workspace root (dsl/domain-lang/):
16
+ ## Installation
16
17
 
17
18
  ```bash
18
- # After editing packages/language/src/domain-lang.langium
19
+ npm install @domainlang/language
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ### Parse and Query Models
25
+
26
+ ```typescript
27
+ import { loadModelFromText } from '@domainlang/language/sdk';
28
+
29
+ const { query } = await loadModelFromText(`
30
+ Domain Sales {
31
+ vision: "Enable seamless commerce"
32
+ }
33
+
34
+ bc OrderContext for Sales as Core by SalesTeam {
35
+ description: "Handles order lifecycle"
36
+ }
37
+ `);
38
+
39
+ // Query bounded contexts
40
+ const coreContexts = query.boundedContexts()
41
+ .withRole('Core')
42
+ .toArray();
43
+
44
+ console.log(coreContexts[0].name); // 'OrderContext'
45
+ ```
46
+
47
+ ### Load from File (Node.js)
48
+
49
+ ```typescript
50
+ import { loadModel } from '@domainlang/language/sdk/loader-node';
51
+
52
+ const { model, query } = await loadModel('./my-model.dlang');
53
+
54
+ // Access domains
55
+ for (const domain of query.domains()) {
56
+ console.log(`${domain.name}: ${domain.vision}`);
57
+ }
58
+ ```
59
+
60
+ ## API Overview
61
+
62
+ ### Entry Points
63
+
64
+ | Function | Environment | Use Case |
65
+ | -------- | ----------- | -------- |
66
+ | `loadModelFromText(text)` | Browser & Node | Parse inline DSL text |
67
+ | `loadModel(file)` | Node.js only | Load from file system |
68
+ | `fromDocument(doc)` | LSP integration | Zero-copy from Langium document |
69
+ | `fromModel(model)` | Advanced | Direct AST wrapping |
70
+
71
+ ### Query Builder
72
+
73
+ The SDK provides fluent query builders with lazy evaluation:
74
+
75
+ ```typescript
76
+ // Find all bounded contexts owned by a team
77
+ const teamContexts = query.boundedContexts()
78
+ .withTeam('PaymentsTeam')
79
+ .toArray();
80
+
81
+ // Get context maps containing specific contexts
82
+ const maps = query.contextMaps()
83
+ .containing('OrderContext')
84
+ .toArray();
85
+ ```
86
+
87
+ ### Direct Property Access
88
+
89
+ ```typescript
90
+ // Direct AST properties
91
+ const desc = boundedContext.description;
92
+ const vision = domain.vision;
93
+
94
+ // SDK-augmented properties (with precedence resolution)
95
+ const role = boundedContext.effectiveRole; // Header 'as' wins over body 'role:'
96
+ const team = boundedContext.effectiveTeam; // Header 'by' wins over body 'team:'
97
+ ```
98
+
99
+ ## DomainLang Syntax
100
+
101
+ DomainLang models Domain-Driven Design concepts:
102
+
103
+ ```dlang
104
+ // Define domains with vision
105
+ Domain Sales {
106
+ vision: "Drive revenue through great customer experience"
107
+ }
108
+
109
+ // Bounded contexts with ownership
110
+ bc OrderContext for Sales as Core by SalesTeam {
111
+ description: "Order lifecycle management"
112
+ }
113
+
114
+ bc PaymentContext for Sales as Supporting by PaymentsTeam
115
+
116
+ // Context maps showing integrations
117
+ ContextMap SalesIntegration {
118
+ contains OrderContext, PaymentContext
119
+
120
+ [OHS,PL] OrderContext -> [CF] PaymentContext
121
+ }
122
+ ```
123
+
124
+ ## Package Structure
125
+
126
+ | Path | Purpose |
127
+ | ---- | ------- |
128
+ | `src/domain-lang.langium` | Grammar definition |
129
+ | `src/generated/` | Auto-generated AST (do not edit) |
130
+ | `src/validation/` | Semantic validation rules |
131
+ | `src/lsp/` | LSP features (hover, completion, formatting) |
132
+ | `src/sdk/` | Model Query SDK |
133
+
134
+ ## Related Packages
135
+
136
+ - [@domainlang/cli](https://www.npmjs.com/package/@domainlang/cli) - Command-line interface
137
+ - [DomainLang VS Code Extension](https://marketplace.visualstudio.com/items?itemName=thinkability.domain-lang) - IDE support
138
+
139
+ ## Documentation
140
+
141
+ - [Getting Started](https://github.com/larsbaunwall/DomainLang/blob/main/dsl/domain-lang/docs/getting-started.md)
142
+ - [Language Reference](https://github.com/larsbaunwall/DomainLang/blob/main/dsl/domain-lang/docs/language.md)
143
+ - [Quick Reference](https://github.com/larsbaunwall/DomainLang/blob/main/dsl/domain-lang/docs/quick-reference.md)
144
+ - [SDK Documentation](https://github.com/larsbaunwall/DomainLang/blob/main/dsl/domain-lang/packages/language/src/sdk/README.md)
145
+
146
+ ## Development
147
+
148
+ From the workspace root (`dsl/domain-lang/`):
149
+
150
+ ```bash
151
+ # After editing the grammar
19
152
  npm run langium:generate
20
153
 
21
- # Build just this package
154
+ # Build this package
22
155
  npm run build --workspace packages/language
23
156
 
24
157
  # Run tests
25
158
  npm test --workspace packages/language
26
159
  ```
27
160
 
28
- ## Testing
29
-
30
- Tests live in test/ and cover parsing, linking, validation, scoping, and services.
161
+ ## License
31
162
 
32
- If you change the grammar or validation behavior, add or update tests alongside the change.
163
+ Apache-2.0
package/package.json CHANGED
@@ -1,22 +1,33 @@
1
1
  {
2
2
  "name": "@domainlang/language",
3
- "version": "0.1.81",
4
- "displayName": "DomainLang",
5
- "description": "A DSL for Domain-Driven Design",
6
- "publisher": "thinkability",
3
+ "version": "0.1.82",
4
+ "displayName": "DomainLang Language",
5
+ "description": "Core language library for DomainLang - parse, validate, and query Domain-Driven Design models programmatically",
7
6
  "author": "larsbaunwall",
8
- "license": "Apache License 2.0",
7
+ "license": "Apache-2.0",
9
8
  "icon": "images/icon.png",
10
9
  "keywords": [
11
10
  "ddd",
12
11
  "domain-driven design",
13
12
  "langium",
14
13
  "dlang",
15
- "domainlang"
14
+ "domainlang",
15
+ "bounded-context",
16
+ "context-map",
17
+ "aggregate",
18
+ "ubiquitous-language",
19
+ "dsl",
20
+ "modeling",
21
+ "architecture",
22
+ "strategic-design",
23
+ "parser",
24
+ "sdk"
16
25
  ],
26
+ "homepage": "https://github.com/larsbaunwall/DomainLang#readme",
17
27
  "repository": {
18
28
  "type": "git",
19
- "url": "https://github.com/larsbaunwall/DomainLang"
29
+ "url": "https://github.com/larsbaunwall/DomainLang",
30
+ "directory": "dsl/domain-lang/packages/language"
20
31
  },
21
32
  "bugs": {
22
33
  "url": "https://github.com/larsbaunwall/DomainLang/issues"