@diagrammo/dgmo 0.3.2 → 0.4.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.
@@ -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: login
371
- API -> DB: findUser
372
- DB -> API: <- user
373
- API -> User: <- token
370
+ User -login-> API
371
+ API -findUser-> DB
372
+ DB -user-> API
373
+ API -token-> User
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
- DB -> API: <- user record
390
+ DB -user record-> API
391
391
  note on DB:
392
392
  Indexed lookup on email column
393
393
 
394
- if credentials valid
395
- API -Create session-> DB
396
- DB -> API: <- session token
397
- API -> User: <- 200 OK + token
398
- API ~session.created~> NotifyQueue
399
- else
400
- API -> User: <- 401 Unauthorized
394
+ if credentials valid
395
+ API -Create session-> DB
396
+ DB -session token-> API
397
+ API ~session.created~> NotifyQueue
398
+ API -200 OK + token-> User
399
+ else
400
+ API -401 Unauthorized-> User
401
401
 
402
402
  == Logout ==
403
403
 
404
404
  User -Logout-> API
405
405
  API -Delete session-> DB
406
- API -> User: <- 200 OK
406
+ API -200 OK-> User
407
407
  ```
408
408
 
409
409
  **Participants**: Auto-inferred from message names. Declare explicitly for type/positioning:
@@ -412,11 +412,8 @@ 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: label` or `A -label-> B`
416
- - Async: `A ~> B: label` or `A ~label~> B`
417
- - Return: `B -> A: <- response` (on the calling line) or separate line
418
- - Bidirectional: `A <-> B: label` or `A <-label-> B`
419
- - Bidirectional async: `A <~> B: label` or `A <~label~> B`
415
+ - Sync call: `A -label-> B` or `A -> B` (unlabeled) — always left-to-right
416
+ - Async call: `A ~label~> B` or `A ~> B` (unlabeled)
420
417
 
421
418
  **Blocks** (indentation-scoped):
422
419
  - `if condition` ... `else` ... (no explicit `end` needed — indentation closes blocks)
@@ -801,7 +798,7 @@ Assign to elements via pipe metadata: `Element Name | priority: High, t: Fronten
801
798
  **Common mistakes to avoid:**
802
799
 
803
800
  - `# comment` — wrong. Use `// comment`
804
- - `async A -> B: msg` — wrong. Use `A ~> B: msg` or `A ~msg~> B`
801
+ - `async A -> B: msg` — wrong. Use `A ~msg~> B`
805
802
  - `parallel else` — not supported. Use separate `parallel` blocks
806
803
  - Hex colors in sections `== Foo(#ff0000) ==` — wrong. Use named colors: `== Foo(red) ==`
807
804
  - `->` inside labeled arrows `A -routes to /api-> B` — ambiguous. Rephrase the label
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagrammo/dgmo",
3
- "version": "0.3.2",
3
+ "version": "0.4.1",
4
4
  "description": "DGMO diagram markup language — parser, renderer, and color system",
5
5
  "license": "MIT",
6
6
  "type": "module",
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 { collectIndentedValues } from './utils/parsing';
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
- // Parse series names comma-separated on one line, or indented multi-line
186
- let rawNames: string[];
187
- if (value) {
188
- result.series = value;
189
- rawNames = value.split(',').map((s) => s.trim()).filter(Boolean);
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 (names.length === 1) {
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
- let rawLabel = trimmed.substring(0, colonIndex).trim();
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
- ' Client -> API: POST /login',
234
- ' API -> Auth: validate credentials',
235
- ' Auth -> DB: SELECT user',
236
- ' DB -> Auth: user record',
237
- ' Auth -> API: JWT token',
238
- ' API -> Client: 200 OK { token }',
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'