@diagrammo/dgmo 0.14.1 → 0.15.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 (71) hide show
  1. package/README.md +14 -1
  2. package/dist/advanced.cjs +53069 -0
  3. package/dist/advanced.d.cts +4691 -0
  4. package/dist/advanced.d.ts +4691 -0
  5. package/dist/advanced.js +52823 -0
  6. package/dist/auto.cjs +1557 -1295
  7. package/dist/auto.js +132 -713
  8. package/dist/auto.mjs +1553 -1291
  9. package/dist/cli.cjs +173 -150
  10. package/dist/editor.cjs +1 -0
  11. package/dist/editor.js +1 -0
  12. package/dist/highlight.cjs +1 -0
  13. package/dist/highlight.js +1 -0
  14. package/dist/index.cjs +2031 -4722
  15. package/dist/index.d.cts +96 -4464
  16. package/dist/index.d.ts +96 -4464
  17. package/dist/index.js +2024 -4475
  18. package/dist/internal.cjs +51930 -553
  19. package/dist/internal.d.cts +4526 -102
  20. package/dist/internal.d.ts +4526 -102
  21. package/dist/internal.js +51721 -548
  22. package/dist/pert.cjs +1 -1
  23. package/dist/pert.js +1 -1
  24. package/docs/language-reference.md +67 -17
  25. package/package.json +18 -3
  26. package/src/advanced.ts +731 -0
  27. package/src/auto/index.ts +14 -13
  28. package/src/boxes-and-lines/layout.ts +481 -445
  29. package/src/c4/parser.ts +7 -7
  30. package/src/chart-types.ts +0 -5
  31. package/src/class/parser.ts +1 -9
  32. package/src/cli.ts +9 -7
  33. package/src/completion-types.ts +28 -0
  34. package/src/completion.ts +15 -18
  35. package/src/cycle/layout.ts +2 -2
  36. package/src/d3.ts +1455 -1122
  37. package/src/echarts.ts +11 -11
  38. package/src/editor/keywords.ts +1 -0
  39. package/src/er/parser.ts +1 -9
  40. package/src/er/renderer.ts +1 -1
  41. package/src/gantt/calculator.ts +1 -11
  42. package/src/gantt/parser.ts +16 -16
  43. package/src/gantt/renderer.ts +2 -2
  44. package/src/graph/flowchart-parser.ts +1 -1
  45. package/src/graph/flowchart-renderer.ts +1 -1
  46. package/src/graph/state-renderer.ts +1 -1
  47. package/src/index.ts +213 -690
  48. package/src/infra/parser.ts +57 -25
  49. package/src/infra/renderer.ts +2 -2
  50. package/src/internal.ts +11 -17
  51. package/src/kanban/parser.ts +2 -2
  52. package/src/mindmap/layout.ts +1 -1
  53. package/src/mindmap/parser.ts +1 -1
  54. package/src/org/parser.ts +1 -1
  55. package/src/org/renderer.ts +1 -1
  56. package/src/palettes/index.ts +39 -0
  57. package/src/pert/layout.ts +1 -1
  58. package/src/pert/monte-carlo.ts +2 -2
  59. package/src/pert/parser.ts +3 -3
  60. package/src/raci/parser.ts +4 -4
  61. package/src/raci/renderer.ts +1 -1
  62. package/src/render.ts +17 -1
  63. package/src/sequence/renderer.ts +1 -4
  64. package/src/sitemap/parser.ts +1 -1
  65. package/src/tech-radar/interactive.ts +1 -1
  66. package/src/tech-radar/renderer.ts +1 -1
  67. package/src/themes.ts +22 -0
  68. package/src/utils/tag-groups.ts +11 -12
  69. package/src/wireframe/layout.ts +11 -7
  70. package/src/wireframe/parser.ts +2 -2
  71. package/src/wireframe/renderer.ts +5 -2
package/dist/pert.cjs CHANGED
@@ -99,7 +99,7 @@ function sampleBetaPert(o, m, p, rng) {
99
99
  const beta = 1 + 4 * (p - m) / range;
100
100
  return o + sampleBeta(alpha, beta, rng) * range;
101
101
  }
102
- function simulate(resolved, expanded, predecessors, successors, topo, terminals, poisoned, opts) {
102
+ function simulate(resolved, expanded, _predecessors, _successors, topo, terminals, poisoned, opts) {
103
103
  const rng = mulberry32(opts.seed);
104
104
  const expById = /* @__PURE__ */ new Map();
105
105
  for (const e of expanded) expById.set(e.id, e);
package/dist/pert.js CHANGED
@@ -69,7 +69,7 @@ function sampleBetaPert(o, m, p, rng) {
69
69
  const beta = 1 + 4 * (p - m) / range;
70
70
  return o + sampleBeta(alpha, beta, rng) * range;
71
71
  }
72
- function simulate(resolved, expanded, predecessors, successors, topo, terminals, poisoned, opts) {
72
+ function simulate(resolved, expanded, _predecessors, _successors, topo, terminals, poisoned, opts) {
73
73
  const rng = mulberry32(opts.seed);
74
74
  const expById = /* @__PURE__ */ new Map();
75
75
  for (const e of expanded) expById.set(e.id, e);
@@ -482,22 +482,27 @@ parallel label
482
482
 
483
483
  ## 4. Infrastructure Diagrams
484
484
 
485
- ### 3.1 Declaration
485
+ ### 4.1 Declaration
486
486
 
487
487
  ```
488
488
  infra [Title]
489
489
  ```
490
490
 
491
- ### 3.2 Nodes
491
+ ### 4.2 Nodes
492
492
 
493
493
  ```
494
494
  NodeName
495
495
  NodeName | key: value
496
+ NodeName as alias
497
+ "Node name with spaces or | reserved chars"
496
498
  ```
497
499
 
498
- Nodes are plain names. Capabilities come from properties (see 3.3), not type declarations.
500
+ Nodes are plain names. Capabilities come from properties (see §4.3), not type declarations.
501
+
502
+ - **Aliases** (§2A): `NodeName as alias` binds a short alias used by edges and group references. Alias must start with a letter/underscore and be ≤12 chars.
503
+ - **Quoted names**: wrap the label in double quotes when it contains spaces followed by reserved chars (`|`, `:`, `(`).
499
504
 
500
- ### 3.3 Node Properties (Indented, Space-Separated, NO Colon)
505
+ ### 4.3 Node Properties (Indented, Space-Separated, NO Colon)
501
506
 
502
507
  ```
503
508
  NodeName
@@ -519,12 +524,12 @@ Properties use a known schema with space-separated values:
519
524
  | `ratelimit-rps` | Rate limiter | Max RPS passed through |
520
525
  | `latency-ms` | Latency | Adds to path latency |
521
526
  | `uptime` | Availability | Multiplied along path for SLO |
522
- | `instances` | Horizontal scaling | Multiplies capacity |
527
+ | `instances` | Horizontal scaling | Multiplies capacity (number or `min-max` range) |
523
528
  | `max-rps` | Capacity ceiling | Max RPS node handles |
524
529
  | `cb-error-threshold` | Circuit breaker | Error rate trip threshold |
525
530
  | `cb-latency-threshold-ms` | Circuit breaker | Latency trip threshold |
526
- | `concurrency` | Concurrency limit | Max concurrent requests |
527
- | `duration-ms` | Processing time | Time spent processing |
531
+ | `concurrency` | Concurrency limit | Max concurrent requests (serverless) |
532
+ | `duration-ms` | Processing time | Time spent processing (serverless) |
528
533
  | `cold-start-ms` | Serverless | Cold start penalty |
529
534
  | `buffer` | Queue | Buffer size |
530
535
  | `drain-rate` | Queue | Consumption rate |
@@ -532,7 +537,9 @@ Properties use a known schema with space-separated values:
532
537
  | `partitions` | Queue | Partition count |
533
538
  | `description` | Display | Description text |
534
539
 
535
- ### 3.4 Connections
540
+ **Mutually exclusive:** `concurrency` ≠ `instances` ≠ `max-rps`; `buffer` ≠ `max-rps`. A node is serverless, traditional, or a queue — not two at once.
541
+
542
+ ### 4.4 Connections
536
543
 
537
544
  | Type | Syntax |
538
545
  |------|--------|
@@ -543,35 +550,78 @@ Properties use a known schema with space-separated values:
543
550
 
544
551
  - Connection metadata: `| split: 50%, fanout: 3` (colons in pipe metadata)
545
552
  - Indented under source node
553
+ - Async edges (`~>`) render with a wiggle pattern
554
+ - Target may be a node id, an alias, or a group ref `[Group Name]`
546
555
 
547
- ### 3.5 Groups
556
+ ### 4.5 Fanout
557
+
558
+ ```
559
+ SearchAPI
560
+ -> SearchShards | fanout: 6
561
+ ```
562
+
563
+ `fanout: N` multiplies the per-edge RPS delivered to the target by `N` (request amplification — scatter-gather, shard fanout, pub/sub).
564
+
565
+ - Effect: `target_rps = source_post_behavior_rps × fanout` (then split-distributed across declared targets)
566
+ - Combine with `split`: `-> Target | split: 50%, fanout: 3`
567
+ - `N` must be ≥ 1; sub-1 values are warned and clamped
568
+ - Sources with at least one `fanout > 1` outgoing edge gain the **Fan-Out** capability badge
569
+ - The legacy `xN` suffix (e.g. `... -> Target x5`) is removed — use `| fanout: N`
570
+
571
+ ### 4.6 Groups
548
572
 
549
573
  ```
550
574
  [Group Name]
551
- [Group Name](color)
575
+ [Group Name] as alias
552
576
  [Group Name] | key: value
553
577
  ```
554
578
 
555
- Bracket syntax only. Optional color and pipe metadata.
579
+ - Bracket syntax only. Group coloring via tags.
580
+ - Optional `as <alias>` postfix and pipe metadata.
581
+ - **No nesting.** A group cannot contain another `[...]` group; only indented components.
582
+ - Group properties (indented under the bracket line):
583
+ - `instances N` or `instances N-M` — capacity multiplier on children (auto-scaling)
584
+ - `collapsed true` — start collapsed; renders as a single node showing the worst child health
556
585
 
557
- ### 3.6 Infra Options (Space-Separated, NO Colon)
586
+ ### 4.7 Infra Options (Space-Separated, NO Colon)
558
587
 
559
588
  - `direction-tb` (boolean; default is LR)
560
589
  - `default-latency-ms N`
561
- - `default-rps N`
590
+ - `default-rps N` — fallback edge RPS when no `rps` is declared on the edge node
562
591
  - `default-uptime DECIMAL`
563
- - `slo-availability DECIMAL`
564
- - `slo-p90-latency-ms N`
592
+ - `slo-availability DECIMAL` — target availability for SLO compliance highlighting
593
+ - `slo-p90-latency-ms N` — target p90 for SLO compliance highlighting
594
+ - `slo-warning-margin DECIMAL` — margin below SLO that triggers warning state
565
595
  - `animate` / `no-animate`
596
+ - `active-tag GroupName` / `active-tag none` — pre-select a tag filter on render
597
+
598
+ The universal options `solid-fill` and `no-title` also apply.
566
599
 
567
- ### 3.7 Edge Nodes
600
+ ### 4.8 Edge Nodes
568
601
 
569
602
  ```
570
603
  edge
571
604
  internet
572
605
  ```
573
606
 
574
- Special top-level entry points. `internet` only accepts `rps` property.
607
+ Special top-level entry points. Either name works; `internet` only accepts `rps` and the `description` is silently ignored on entry-point nodes.
608
+
609
+ ### 4.9 Node Descriptions
610
+
611
+ ```
612
+ API Gateway
613
+ description Handles routing and auth
614
+ description Supports rate limiting
615
+ latency-ms 50
616
+ max-rps 8000
617
+ ```
618
+
619
+ - `description` keyword followed by text (NO colon)
620
+ - Multiple `description` lines accumulate into a multi-line description
621
+ - **Keywordless form:** indented prose lines that don't match a known property key or numeric value are treated as descriptions automatically
622
+ - Supports inline markdown: `**bold**`, `*italic*`, `` `code` ``, `[links](url)`
623
+ - `- bullet text` renders as `• bullet text`
624
+ - Descriptions are ignored on `edge` and `internet` nodes
575
625
 
576
626
  ---
577
627
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagrammo/dgmo",
3
- "version": "0.14.1",
3
+ "version": "0.15.1",
4
4
  "description": "DGMO diagram markup language — parser, renderer, and color system",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -9,6 +9,9 @@
9
9
  },
10
10
  "homepage": "https://github.com/diagrammo/dgmo#readme",
11
11
  "type": "module",
12
+ "engines": {
13
+ "node": ">=20.6"
14
+ },
12
15
  "bin": {
13
16
  "dgmo": "dist/cli.cjs"
14
17
  },
@@ -46,6 +49,16 @@
46
49
  "default": "./dist/highlight.cjs"
47
50
  }
48
51
  },
52
+ "./advanced": {
53
+ "import": {
54
+ "types": "./dist/advanced.d.ts",
55
+ "default": "./dist/advanced.js"
56
+ },
57
+ "require": {
58
+ "types": "./dist/advanced.d.cts",
59
+ "default": "./dist/advanced.cjs"
60
+ }
61
+ },
49
62
  "./internal": {
50
63
  "import": {
51
64
  "types": "./dist/internal.d.ts",
@@ -106,7 +119,7 @@
106
119
  "typecheck": "tsc --noEmit",
107
120
  "dev": "tsup --watch",
108
121
  "pretest": "pnpm codegen",
109
- "test": "vitest run",
122
+ "test": "vitest run --coverage",
110
123
  "test:watch": "vitest",
111
124
  "test:auto": "pnpm build && vitest run tests/auto.test.ts tests/safe-href.test.ts",
112
125
  "sri": "node scripts/sri.mjs",
@@ -121,7 +134,7 @@
121
134
  "check:deadcode": "knip",
122
135
  "check:spelling": "cspell \"src/**/*.ts\" \"tests/**/*.ts\"",
123
136
  "check:all": "pnpm check:deadcode && pnpm check:spelling && pnpm check:duplication && pnpm check:circular && pnpm check:deps && pnpm check:security && pnpm build && pnpm check:publish && pnpm check:types",
124
- "check:circular": "madge --circular --extensions ts src/ --json | node -e \"const c=JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')); const n=c.length; if(n>10){console.error('New circular deps found ('+n+' > 10 known type-only cycles)');process.exit(1)}else if(n>0){console.log(n+' known type-only/dynamic cycles (safe)')}else{console.log('No circular dependencies')}\"",
137
+ "check:circular": "madge --circular --extensions ts src/ --json | node -e \"const c=JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')); const n=c.length; if(n>4){console.error('New circular deps found ('+n+' > 4 known type-only cycles)');process.exit(1)}else if(n>0){console.log(n+' known type-only/dynamic cycles (safe)')}else{console.log('No circular dependencies')}\"",
125
138
  "check:deps": "depcheck --ignores='@codemirror/language,@lezer/*,husky,lint-staged,tsup,axe-core'",
126
139
  "check:security": "pnpm audit --prod",
127
140
  "check:publish": "publint",
@@ -140,6 +153,7 @@
140
153
  "d3-selection": "^3.0.0",
141
154
  "d3-shape": "^3.2.0",
142
155
  "echarts": "^6.0.0",
156
+ "elkjs": "^0.11.1",
143
157
  "jsdom": "^29.0.2",
144
158
  "lz-string": "^1.5.0"
145
159
  },
@@ -155,6 +169,7 @@
155
169
  "@types/d3-selection": "^3.0.11",
156
170
  "@types/d3-shape": "^3.1.8",
157
171
  "@types/jsdom": "^28.0.1",
172
+ "@vitest/coverage-v8": "^4.1.6",
158
173
  "axe-core": "^4.10.0",
159
174
  "cspell": "^10.0.0",
160
175
  "depcheck": "^1.4.7",