@diagrammo/dgmo 0.3.1 → 0.4.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/README.md +11 -14
- package/dist/cli.cjs +150 -151
- package/dist/index.cjs +460 -901
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +459 -901
- package/dist/index.js.map +1 -1
- package/docs/language-reference.md +18 -19
- package/package.json +1 -1
- package/src/chart.ts +8 -39
- package/src/cli.ts +6 -6
- package/src/d3.ts +299 -715
- package/src/dgmo-router.ts +21 -42
- package/src/echarts.ts +134 -241
- package/src/index.ts +1 -0
- package/src/sequence/parser.ts +55 -106
- package/src/sequence/renderer.ts +4 -60
- package/src/utils/arrows.ts +43 -18
- package/src/utils/parsing.ts +43 -0
|
@@ -367,10 +367,10 @@ Options: `scale` (`on`/`off`), `sort` (`time`/`group`), `swimlanes` (`on`/`off`)
|
|
|
367
367
|
Minimal example:
|
|
368
368
|
|
|
369
369
|
```
|
|
370
|
-
User -> API
|
|
371
|
-
API -> DB
|
|
372
|
-
|
|
373
|
-
|
|
370
|
+
User -login-> API
|
|
371
|
+
API -findUser-> DB
|
|
372
|
+
API <-user- DB
|
|
373
|
+
User <-token- API
|
|
374
374
|
```
|
|
375
375
|
|
|
376
376
|
Full example:
|
|
@@ -387,23 +387,23 @@ NotifyQueue is a queue aka Notifications
|
|
|
387
387
|
|
|
388
388
|
User -Login request-> API
|
|
389
389
|
API -Find user by email-> DB
|
|
390
|
-
|
|
390
|
+
API <-user record- DB
|
|
391
391
|
note on DB:
|
|
392
392
|
Indexed lookup on email column
|
|
393
393
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
394
|
+
if credentials valid
|
|
395
|
+
API -Create session-> DB
|
|
396
|
+
API <-session token- DB
|
|
397
|
+
API ~session.created~> NotifyQueue
|
|
398
|
+
User <-200 OK + token- API
|
|
399
|
+
else
|
|
400
|
+
User <-401 Unauthorized- API
|
|
401
401
|
|
|
402
402
|
== Logout ==
|
|
403
403
|
|
|
404
404
|
User -Logout-> API
|
|
405
405
|
API -Delete session-> DB
|
|
406
|
-
|
|
406
|
+
User <-200 OK- API
|
|
407
407
|
```
|
|
408
408
|
|
|
409
409
|
**Participants**: Auto-inferred from message names. Declare explicitly for type/positioning:
|
|
@@ -412,11 +412,10 @@ API -> User: <- 200 OK
|
|
|
412
412
|
- `Name at position 2` — manual left-to-right ordering (0-based; negative from right)
|
|
413
413
|
|
|
414
414
|
**Messages**:
|
|
415
|
-
- Sync: `A -> B
|
|
416
|
-
- Async: `A ~> B
|
|
417
|
-
-
|
|
418
|
-
-
|
|
419
|
-
- Bidirectional async: `A <~> B: label` or `A <~label~> B`
|
|
415
|
+
- Sync call: `A -label-> B` or `A -> B` (unlabeled)
|
|
416
|
+
- Async call: `A ~label~> B` or `A ~> B` (unlabeled)
|
|
417
|
+
- Sync return: `A <-label- B` or `A <- B` (unlabeled) — dashed arrow from B to A
|
|
418
|
+
- Async return: `A <~label~ B` or `A <~ B` (unlabeled)
|
|
420
419
|
|
|
421
420
|
**Blocks** (indentation-scoped):
|
|
422
421
|
- `if condition` ... `else` ... (no explicit `end` needed — indentation closes blocks)
|
|
@@ -801,7 +800,7 @@ Assign to elements via pipe metadata: `Element Name | priority: High, t: Fronten
|
|
|
801
800
|
**Common mistakes to avoid:**
|
|
802
801
|
|
|
803
802
|
- `# comment` — wrong. Use `// comment`
|
|
804
|
-
- `async A -> B: msg` — wrong. Use `A
|
|
803
|
+
- `async A -> B: msg` — wrong. Use `A ~msg~> B`
|
|
805
804
|
- `parallel else` — not supported. Use separate `parallel` blocks
|
|
806
805
|
- Hex colors in sections `== Foo(#ff0000) ==` — wrong. Use named colors: `== Foo(red) ==`
|
|
807
806
|
- `->` inside labeled arrows `A -routes to /api-> B` — ambiguous. Rephrase the label
|
package/package.json
CHANGED
package/src/chart.ts
CHANGED
|
@@ -47,7 +47,7 @@ export interface ParsedChart {
|
|
|
47
47
|
import { resolveColor } from './colors';
|
|
48
48
|
import type { PaletteColors } from './palettes';
|
|
49
49
|
import { makeDgmoError, formatDgmoError, suggest } from './diagnostics';
|
|
50
|
-
import {
|
|
50
|
+
import { extractColor, parseSeriesNames } from './utils/parsing';
|
|
51
51
|
|
|
52
52
|
// ============================================================
|
|
53
53
|
// Parser
|
|
@@ -182,37 +182,13 @@ export function parseChart(
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
if (key === 'series') {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
} else {
|
|
191
|
-
const collected = collectIndentedValues(lines, i);
|
|
192
|
-
i = collected.newIndex;
|
|
193
|
-
rawNames = collected.values;
|
|
194
|
-
result.series = rawNames.join(', ');
|
|
195
|
-
}
|
|
196
|
-
const names: string[] = [];
|
|
197
|
-
const nameColors: (string | undefined)[] = [];
|
|
198
|
-
for (const raw of rawNames) {
|
|
199
|
-
const colorMatch = raw.match(/\(([^)]+)\)\s*$/);
|
|
200
|
-
if (colorMatch) {
|
|
201
|
-
const resolved = resolveColor(colorMatch[1].trim(), palette);
|
|
202
|
-
nameColors.push(resolved);
|
|
203
|
-
names.push(raw.substring(0, colorMatch.index!).trim());
|
|
204
|
-
} else {
|
|
205
|
-
nameColors.push(undefined);
|
|
206
|
-
names.push(raw);
|
|
207
|
-
}
|
|
185
|
+
const parsed = parseSeriesNames(value, lines, i, palette);
|
|
186
|
+
i = parsed.newIndex;
|
|
187
|
+
result.series = parsed.series;
|
|
188
|
+
if (parsed.names.length > 1) {
|
|
189
|
+
result.seriesNames = parsed.names;
|
|
208
190
|
}
|
|
209
|
-
if (
|
|
210
|
-
result.series = names[0];
|
|
211
|
-
}
|
|
212
|
-
if (names.length > 1) {
|
|
213
|
-
result.seriesNames = names;
|
|
214
|
-
}
|
|
215
|
-
if (nameColors.some(Boolean)) result.seriesNameColors = nameColors;
|
|
191
|
+
if (parsed.nameColors.some(Boolean)) result.seriesNameColors = parsed.nameColors;
|
|
216
192
|
continue;
|
|
217
193
|
}
|
|
218
194
|
|
|
@@ -220,14 +196,7 @@ export function parseChart(
|
|
|
220
196
|
const parts = value.split(',').map((s) => s.trim());
|
|
221
197
|
const numValue = parseFloat(parts[0]);
|
|
222
198
|
if (!isNaN(numValue)) {
|
|
223
|
-
|
|
224
|
-
let pointColor: string | undefined;
|
|
225
|
-
const colorMatch = rawLabel.match(/\(([^)]+)\)\s*$/);
|
|
226
|
-
if (colorMatch) {
|
|
227
|
-
const resolved = resolveColor(colorMatch[1].trim(), palette);
|
|
228
|
-
pointColor = resolved;
|
|
229
|
-
rawLabel = rawLabel.substring(0, colorMatch.index!).trim();
|
|
230
|
-
}
|
|
199
|
+
const { label: rawLabel, color: pointColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
|
|
231
200
|
const extra = parts
|
|
232
201
|
.slice(1)
|
|
233
202
|
.map((s) => parseFloat(s))
|
package/src/cli.ts
CHANGED
|
@@ -230,12 +230,12 @@ function noInput(): never {
|
|
|
230
230
|
'chart: sequence',
|
|
231
231
|
'activations: off',
|
|
232
232
|
'',
|
|
233
|
-
'
|
|
234
|
-
' API -> Auth
|
|
235
|
-
'
|
|
236
|
-
'
|
|
237
|
-
'
|
|
238
|
-
'
|
|
233
|
+
'Client -POST /login-> API',
|
|
234
|
+
' API -validate credentials-> Auth',
|
|
235
|
+
' Auth -SELECT user-> DB',
|
|
236
|
+
' Auth <-user record- DB',
|
|
237
|
+
' API <-JWT token- Auth',
|
|
238
|
+
'Client <-200 OK- API',
|
|
239
239
|
'',
|
|
240
240
|
].join('\n'),
|
|
241
241
|
'utf-8'
|