agentic-mermaid 0.1.1 → 0.2.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/AGENT_NATIVE.md +155 -91
- package/CHANGELOG.md +163 -4
- package/Instructions_for_agents.md +10 -10
- package/LICENSES/Apache-2.0.txt +202 -0
- package/README.md +31 -38
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/assets/hero.png +0 -0
- package/dist/agent-core.d.ts +463 -0
- package/dist/agent-core.js +397 -0
- package/dist/agent.d.ts +73 -1868
- package/dist/agent.js +336 -37325
- package/dist/agentic-mermaid-mcp.js +7 -38399
- package/dist/am.js +33626 -40446
- package/dist/chunk-2P5FKUQC.js +3485 -0
- package/dist/chunk-2S3VSS6I.js +149 -0
- package/dist/chunk-2SILJDW2.js +37 -0
- package/dist/chunk-BJYMBT4I.js +61963 -0
- package/dist/chunk-FDM43XU7.js +615 -0
- package/dist/chunk-MYPDVZCO.js +4702 -0
- package/dist/index-DWPa2MJs.d.ts +6780 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +310 -33014
- package/dist/mcp-cli-5J47WEY3.js +17 -0
- package/docs/README.md +39 -31
- package/docs/agent-api-cookbook.md +44 -35
- package/docs/agent-mutation-policy.md +1 -1
- package/docs/agent-workflow-examples.md +2 -2
- package/docs/api.md +284 -77
- package/docs/ascii.md +26 -16
- package/docs/code-mode-impact.md +214 -0
- package/docs/comparison.md +23 -11
- package/docs/computational-aesthetics-prototype-plan.md +252 -0
- package/docs/config.md +26 -10
- package/docs/custom-fonts.md +265 -0
- package/docs/custom-style-cookbook.md +130 -9
- package/docs/diagram-families.md +48 -23
- package/docs/features.md +59 -52
- package/docs/fork-differences.md +6 -3
- package/docs/getting-started.md +23 -16
- package/docs/issue-derived-test-cases.md +29 -22
- package/docs/mcp-code-mode-rationale.md +13 -6
- package/docs/mcp-http-transport.md +20 -13
- package/docs/mermaid-layout-complaints.md +66 -52
- package/docs/mutation-testing.md +145 -66
- package/docs/quality.md +23 -14
- package/docs/react.md +2 -2
- package/docs/schemas/style-spec.schema.json +1221 -30
- package/docs/style-authoring.md +241 -38
- package/docs/svg-semantic-contract.md +49 -0
- package/docs/testing-strategy.md +166 -58
- package/docs/theming.md +19 -32
- package/examples/styles/catalog.json +54 -0
- package/examples/styles/cloudflare-workers-inspired-prototype.mmd +9 -0
- package/examples/styles/cloudflare-workers-inspired-prototype.style.json +110 -0
- package/examples/styles/cupertino-prototype.mmd +10 -0
- package/examples/styles/cupertino-prototype.style.json +63 -0
- package/examples/styles/mid-century-report.style.json +2 -2
- package/examples/styles/star-chart-atlas.style.json +2 -1
- package/examples/styles/transit-route-map.style.json +2 -2
- package/examples/styles/vercel-inspired-prototype.mmd +6 -0
- package/examples/styles/vercel-inspired-prototype.style.json +87 -0
- package/package.json +85 -45
- package/server.json +2 -2
- package/skills/agentic-mermaid-diagram-workflow/SKILL.md +17 -36
- package/skills/agentic-mermaid-diagram-workflow/references/cli.md +4 -5
- package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +15 -31
- package/skills/agentic-mermaid-diagram-workflow/references/sequence.md +10 -14
- package/skills/agentic-mermaid-live-editor/SKILL.md +100 -206
- package/TODO.md +0 -684
- package/dist/index-wjRjbsP-.d.ts +0 -1102
- package/docs/assets/improvements/box-start-connector.png +0 -0
- package/docs/assets/improvements/comment-dropped-lint.png +0 -0
- package/docs/assets/improvements/er-content-loss.png +0 -0
- package/docs/assets/improvements/fan-in-trunks.png +0 -0
- package/docs/assets/improvements/gantt-family.png +0 -0
- package/docs/assets/improvements/gantt-milestone-clamp.png +0 -0
- package/docs/assets/improvements/gantt-verify-seam.png +0 -0
- package/docs/assets/improvements/subgraph-container-edges.png +0 -0
- package/docs/assets/improvements/wrapper-frontmatter.png +0 -0
- package/docs/assets/improvements/wrapper-init-directive.png +0 -0
- package/docs/assets/improvements/wrapper-leading-comment.png +0 -0
- package/docs/assets/style-cookbook/mid-century-report.png +0 -0
- package/docs/assets/style-cookbook/star-chart-atlas.png +0 -0
- package/docs/assets/style-cookbook/transit-route-map.png +0 -0
- package/docs/contributing/adding-diagram-types.md +0 -144
- package/docs/contributing/diagram-family-citizenship.matrix.json +0 -2127
- package/docs/contributing/diagram-family-citizenship.md +0 -82
- package/docs/contributing/harvesting-upstream-tests.md +0 -126
- package/docs/contributing/lessons-learned.md +0 -276
- package/docs/contributing/releasing.md +0 -82
- package/docs/contributing/visual-review-evidence.md +0 -53
- package/docs/design/families/README.md +0 -26
- package/docs/design/families/architecture-beta.md +0 -48
- package/docs/design/families/flowchart-parser-conformance.md +0 -22
- package/docs/design/families/gantt-research.md +0 -137
- package/docs/design/families/gantt.md +0 -329
- package/docs/design/families/journey-agentic-cards-before.png +0 -0
- package/docs/design/families/journey-experience-curve-implementation.png +0 -0
- package/docs/design/families/journey-mermaid-classic-implementation.png +0 -0
- package/docs/design/families/journey-mermaid-classic-prototype.png +0 -0
- package/docs/design/families/journey-mermaid-classic-prototype.svg +0 -163
- package/docs/design/families/journey-mermaid-classic-prototype.svg.png +0 -0
- package/docs/design/families/journey-migration-parity.md +0 -439
- package/docs/design/families/journey-section-overlap-after.png +0 -0
- package/docs/design/families/journey-section-overlap-before.png +0 -0
- package/docs/design/families/journey-usage-research.md +0 -423
- package/docs/design/families/journey.md +0 -153
- package/docs/design/families/xychart.md +0 -85
- package/docs/design/system/README.md +0 -45
- package/docs/design/system/abstraction-audit.md +0 -224
- package/docs/design/system/abstraction-recommendations.md +0 -655
- package/docs/design/system/architecture.mmd +0 -29
- package/docs/design/system/architecture.svg +0 -137
- package/docs/design/system/layout-guarantees-and-robustness.md +0 -351
- package/docs/design/system/layout-rubric.md +0 -138
- package/docs/design/system/route-contracts.md +0 -848
- package/docs/design/system/source-preservation-ladder.md +0 -52
- package/docs/design/system/styles-rollout.md +0 -216
- package/docs/design/system/ugly-layouts.md +0 -119
- package/docs/layout-characterization/README.md +0 -245
- package/docs/layout-characterization/contact-sheet-families.md +0 -498
- package/docs/layout-characterization/contact-sheet.md +0 -638
- package/docs/layout-characterization/properties.md +0 -281
- package/docs/layout-characterization/visual-quality.md +0 -160
- package/docs/layout-characterization/visual-snapshots/architecture.svg +0 -79
- package/docs/layout-characterization/visual-snapshots/class.svg +0 -60
- package/docs/layout-characterization/visual-snapshots/er.svg +0 -61
- package/docs/layout-characterization/visual-snapshots/flowchart.svg +0 -58
- package/docs/layout-characterization/visual-snapshots/gantt.svg +0 -52
- package/docs/layout-characterization/visual-snapshots/journey.svg +0 -98
- package/docs/layout-characterization/visual-snapshots/pie.svg +0 -36
- package/docs/layout-characterization/visual-snapshots/quadrant.svg +0 -47
- package/docs/layout-characterization/visual-snapshots/sequence.svg +0 -59
- package/docs/layout-characterization/visual-snapshots/state.svg +0 -52
- package/docs/layout-characterization/visual-snapshots/timeline.svg +0 -64
- package/docs/layout-characterization/visual-snapshots/xychart.svg +0 -97
- package/docs/project/divergences.md +0 -98
- package/docs/project/dogfooding-docs-strategy.md +0 -66
- package/docs/project/hosted-mcp-cloudflare-plan.md +0 -338
- package/docs/project/lessons-learned.md +0 -1019
- package/docs/project/remove-role-styling-plan.md +0 -176
- package/examples/agent-improve-auth-flow.ts +0 -206
- package/examples/agent-loop.ts +0 -53
- package/examples/mcp-vs-cli-complex-diagrams.ts +0 -133
- package/llms.txt +0 -104
- package/skill-evals/README.md +0 -77
- package/skill-evals/fixtures/architecture-cache/input.mmd +0 -5
- package/skill-evals/fixtures/class-payment/input.mmd +0 -4
- package/skill-evals/fixtures/er-orders/input.mmd +0 -10
- package/skill-evals/fixtures/flowchart-cache/input.mmd +0 -3
- package/skill-evals/fixtures/gantt-release/input.mmd +0 -7
- package/skill-evals/fixtures/journey-checkout/input.mmd +0 -6
- package/skill-evals/fixtures/pie-exports/input.mmd +0 -5
- package/skill-evals/fixtures/quadrant-priorities/input.mmd +0 -11
- package/skill-evals/fixtures/sequence-retry/input.mmd +0 -8
- package/skill-evals/fixtures/state-lifecycle/input.mmd +0 -5
- package/skill-evals/fixtures/timeline-release/input.mmd +0 -6
- package/skill-evals/fixtures/xychart-growth/input.mmd +0 -5
- package/skill-evals/shared-benchmark.json +0 -510
- package/src/agent/analyze.ts +0 -157
- package/src/agent/apply.ts +0 -146
- package/src/agent/architecture-body.ts +0 -458
- package/src/agent/certificates.ts +0 -110
- package/src/agent/class-body.ts +0 -319
- package/src/agent/core.ts +0 -207
- package/src/agent/create.ts +0 -106
- package/src/agent/describe.ts +0 -368
- package/src/agent/er-body.ts +0 -224
- package/src/agent/facts.ts +0 -360
- package/src/agent/families-builtin.ts +0 -920
- package/src/agent/families.ts +0 -232
- package/src/agent/family-layouts.ts +0 -832
- package/src/agent/flowchart-body.ts +0 -372
- package/src/agent/flowchart-unsupported.ts +0 -243
- package/src/agent/font-coverage.ts +0 -288
- package/src/agent/gantt-body.ts +0 -495
- package/src/agent/index.ts +0 -10
- package/src/agent/journey-body.ts +0 -374
- package/src/agent/label-metrics.ts +0 -28
- package/src/agent/layout-to-rendered.ts +0 -63
- package/src/agent/mutate.ts +0 -97
- package/src/agent/mutation-ops.ts +0 -51
- package/src/agent/op-schema.ts +0 -443
- package/src/agent/parse.ts +0 -223
- package/src/agent/pie-body.ts +0 -270
- package/src/agent/png.ts +0 -171
- package/src/agent/quadrant-body.ts +0 -336
- package/src/agent/quality.ts +0 -363
- package/src/agent/readability-audit.ts +0 -92
- package/src/agent/rendered-route-audit.ts +0 -61
- package/src/agent/sequence-body.ts +0 -345
- package/src/agent/serialize.ts +0 -214
- package/src/agent/state-body.ts +0 -589
- package/src/agent/structural-count.ts +0 -150
- package/src/agent/timeline-body.ts +0 -280
- package/src/agent/trace-log.ts +0 -43
- package/src/agent/types.ts +0 -995
- package/src/agent/verify.ts +0 -603
- package/src/agent/xychart-body.ts +0 -472
- package/src/architecture/config.ts +0 -282
- package/src/architecture/layout.ts +0 -496
- package/src/architecture/parser.ts +0 -375
- package/src/architecture/renderer.ts +0 -611
- package/src/architecture/types.ts +0 -113
- package/src/ascii/ansi.ts +0 -423
- package/src/ascii/architecture.ts +0 -210
- package/src/ascii/canvas.ts +0 -443
- package/src/ascii/class-diagram.ts +0 -697
- package/src/ascii/converter.ts +0 -475
- package/src/ascii/draw.ts +0 -1693
- package/src/ascii/edge-bundling.ts +0 -328
- package/src/ascii/edge-routing.ts +0 -330
- package/src/ascii/er-diagram.ts +0 -439
- package/src/ascii/gantt.ts +0 -276
- package/src/ascii/grid.ts +0 -747
- package/src/ascii/index.ts +0 -196
- package/src/ascii/journey.ts +0 -169
- package/src/ascii/meta.ts +0 -244
- package/src/ascii/multiline-utils.ts +0 -80
- package/src/ascii/pathfinder.ts +0 -301
- package/src/ascii/pie.ts +0 -67
- package/src/ascii/quadrant.ts +0 -158
- package/src/ascii/reverse.ts +0 -216
- package/src/ascii/sequence.ts +0 -499
- package/src/ascii/shapes/circle.ts +0 -27
- package/src/ascii/shapes/corners.ts +0 -143
- package/src/ascii/shapes/diamond.ts +0 -27
- package/src/ascii/shapes/hexagon.ts +0 -27
- package/src/ascii/shapes/index.ts +0 -106
- package/src/ascii/shapes/rectangle.ts +0 -168
- package/src/ascii/shapes/rounded.ts +0 -27
- package/src/ascii/shapes/special.ts +0 -332
- package/src/ascii/shapes/stadium.ts +0 -110
- package/src/ascii/shapes/state.ts +0 -192
- package/src/ascii/shapes/types.ts +0 -73
- package/src/ascii/timeline.ts +0 -141
- package/src/ascii/types.ts +0 -312
- package/src/ascii/validate.ts +0 -120
- package/src/ascii/width.ts +0 -81
- package/src/ascii/wrap.ts +0 -131
- package/src/ascii/xychart.ts +0 -919
- package/src/browser.ts +0 -29
- package/src/class/layout.ts +0 -240
- package/src/class/parser.ts +0 -332
- package/src/class/renderer.ts +0 -638
- package/src/class/types.ts +0 -129
- package/src/cli/agent-instructions.ts +0 -1
- package/src/cli/am-bin.ts +0 -6
- package/src/cli/exit-codes.ts +0 -18
- package/src/cli/index.ts +0 -1132
- package/src/cli/init-agent.ts +0 -147
- package/src/cli/run-entrypoint.ts +0 -10
- package/src/color-resolver.ts +0 -152
- package/src/elk-instance.ts +0 -114
- package/src/er/layout.ts +0 -187
- package/src/er/parser.ts +0 -226
- package/src/er/renderer.ts +0 -792
- package/src/er/types.ts +0 -99
- package/src/family-rubric.ts +0 -425
- package/src/font-manifest.ts +0 -31
- package/src/gantt/layout.ts +0 -365
- package/src/gantt/parser.ts +0 -282
- package/src/gantt/pipeline.ts +0 -27
- package/src/gantt/renderer.ts +0 -414
- package/src/gantt/schedule.ts +0 -513
- package/src/gantt/types.ts +0 -255
- package/src/index.ts +0 -368
- package/src/journey/layout.ts +0 -554
- package/src/journey/parse-core.ts +0 -251
- package/src/journey/parser.ts +0 -101
- package/src/journey/renderer.ts +0 -917
- package/src/journey/types.ts +0 -144
- package/src/layout/geometry.ts +0 -182
- package/src/layout/pass.ts +0 -142
- package/src/layout/passes/index.ts +0 -3916
- package/src/layout-engine.ts +0 -1565
- package/src/layout-rubric.ts +0 -659
- package/src/mcp/artifacts.ts +0 -137
- package/src/mcp/dynamic-harness.ts +0 -31
- package/src/mcp/dynamic-modules.d.ts +0 -7
- package/src/mcp/facade.ts +0 -608
- package/src/mcp/harness-runtime.ts +0 -203
- package/src/mcp/hosted-server.ts +0 -468
- package/src/mcp/mcp-bin.ts +0 -3
- package/src/mcp/mcp-cli.ts +0 -82
- package/src/mcp/protocol.ts +0 -13
- package/src/mcp/sandbox.ts +0 -195
- package/src/mcp/sdk-decl.ts +0 -391
- package/src/mcp/server.ts +0 -362
- package/src/mcp/tool-surface.ts +0 -146
- package/src/mermaid-source.ts +0 -655
- package/src/multiline-utils.ts +0 -228
- package/src/parser.ts +0 -1031
- package/src/pie/layout.ts +0 -168
- package/src/pie/parser.ts +0 -136
- package/src/pie/renderer.ts +0 -234
- package/src/pie/types.ts +0 -82
- package/src/quadrant/layout.ts +0 -191
- package/src/quadrant/parser.ts +0 -183
- package/src/quadrant/renderer.ts +0 -322
- package/src/quadrant/types.ts +0 -113
- package/src/render-family-hooks.ts +0 -244
- package/src/renderer.ts +0 -1099
- package/src/route-contracts.ts +0 -2723
- package/src/scene/backend.ts +0 -76
- package/src/scene/fidelity.ts +0 -183
- package/src/scene/hybrid-backend.ts +0 -174
- package/src/scene/ir.ts +0 -181
- package/src/scene/marks.ts +0 -127
- package/src/scene/rough-backend.ts +0 -378
- package/src/scene/seed.ts +0 -46
- package/src/scene/style-registry.ts +0 -556
- package/src/sequence/layout.ts +0 -456
- package/src/sequence/parser.ts +0 -255
- package/src/sequence/renderer.ts +0 -604
- package/src/sequence/types.ts +0 -154
- package/src/shape-clipping.ts +0 -351
- package/src/shared/accessibility-directives.ts +0 -22
- package/src/shared/batched.ts +0 -61
- package/src/shared/color-math.ts +0 -93
- package/src/shared/svg-a11y.ts +0 -29
- package/src/shared/syntax-error.ts +0 -17
- package/src/shared/unicode-ranges.ts +0 -135
- package/src/styles.ts +0 -318
- package/src/svg-paths.ts +0 -28
- package/src/text-metrics.ts +0 -248
- package/src/theme.ts +0 -710
- package/src/timeline/layout.ts +0 -381
- package/src/timeline/parser.ts +0 -215
- package/src/timeline/renderer.ts +0 -538
- package/src/timeline/types.ts +0 -105
- package/src/types.ts +0 -462
- package/src/website-worker-modules.d.ts +0 -18
- package/src/xychart/axis-utils.ts +0 -109
- package/src/xychart/colors.ts +0 -124
- package/src/xychart/config.ts +0 -88
- package/src/xychart/layout.ts +0 -656
- package/src/xychart/parser.ts +0 -504
- package/src/xychart/renderer.ts +0 -640
- package/src/xychart/types.ts +0 -282
package/src/agent/types.ts
DELETED
|
@@ -1,995 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Agentic Mermaid — IR and verb types (v4)
|
|
3
|
-
//
|
|
4
|
-
// v4 removes the seed/RNG/clock/font-metric apparatus that the empirical
|
|
5
|
-
// probe proved was theater (ELK is already deterministic; seeding changed
|
|
6
|
-
// nothing). The only verify knob is labelCharCap. See AGENT_NATIVE.md § (1).
|
|
7
|
-
// ============================================================================
|
|
8
|
-
|
|
9
|
-
import type { MermaidGraph, NodeShape, EdgeStyle, EdgeRouteCertificate, RegionContainmentCertificate, RouteCertificate, RouteClass } from '../types.ts'
|
|
10
|
-
import type { MermaidFrontmatterMap, MermaidConfigMap } from '../mermaid-source.ts'
|
|
11
|
-
|
|
12
|
-
// ---- Result ---------------------------------------------------------------
|
|
13
|
-
|
|
14
|
-
export type Result<T, E> = { ok: true; value: T } | { ok: false; error: E }
|
|
15
|
-
export function ok<T, E = never>(value: T): Result<T, E> { return { ok: true, value } }
|
|
16
|
-
export function err<E, T = never>(error: E): Result<T, E> { return { ok: false, error } }
|
|
17
|
-
|
|
18
|
-
// ---- Families -------------------------------------------------------------
|
|
19
|
-
|
|
20
|
-
export type DiagramKind =
|
|
21
|
-
| 'flowchart' | 'state' | 'sequence' | 'class' | 'er'
|
|
22
|
-
| 'timeline' | 'journey' | 'xychart' | 'architecture' | 'pie' | 'quadrant' | 'gantt'
|
|
23
|
-
|
|
24
|
-
// ---- Sequence body --------------------------------------------------------
|
|
25
|
-
|
|
26
|
-
export interface SequenceParticipant {
|
|
27
|
-
id: string
|
|
28
|
-
label: string
|
|
29
|
-
kind: 'participant' | 'actor'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type SequenceMessageStyle =
|
|
33
|
-
| 'sync' // ->>
|
|
34
|
-
| 'reply' // -->>
|
|
35
|
-
| 'async' // ->
|
|
36
|
-
| 'async-dashed' // -->
|
|
37
|
-
| 'lost' // -x
|
|
38
|
-
| 'lost-dashed' // --x
|
|
39
|
-
|
|
40
|
-
export interface SequenceMessage {
|
|
41
|
-
from: string
|
|
42
|
-
to: string
|
|
43
|
-
text: string
|
|
44
|
-
style: SequenceMessageStyle
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// BUILD-18: ordered statement list. Refs index into the participants/messages
|
|
48
|
-
// arrays (which remain the canonical views the SDK declaration, synthesize
|
|
49
|
-
// payloads, describe, verify, and tests consume). Opaque-block segments carry
|
|
50
|
-
// unmodeled lines (Note/alt/loop/par/activate/autonumber/title…) VERBATIM so
|
|
51
|
-
// they ride along in their original position. Messages/participants INSIDE an
|
|
52
|
-
// opaque-block are invisible to mutation ops and the messages/participants
|
|
53
|
-
// arrays — only top-level structured statements are addressable.
|
|
54
|
-
export type SequenceStatement =
|
|
55
|
-
| { kind: 'participant'; ref: number } // index into participants
|
|
56
|
-
| { kind: 'message'; ref: number } // index into messages
|
|
57
|
-
| { kind: 'opaque-block'; lines: string[] }
|
|
58
|
-
|
|
59
|
-
export interface SequenceBody {
|
|
60
|
-
kind: 'sequence'
|
|
61
|
-
participants: SequenceParticipant[]
|
|
62
|
-
messages: SequenceMessage[]
|
|
63
|
-
// Optional for back-compat: synthesizeFromGraph payloads and hand-built
|
|
64
|
-
// bodies may omit it; the serializer falls back to participants-then-messages
|
|
65
|
-
// ordering when absent. Parsed bodies always populate it.
|
|
66
|
-
statements?: SequenceStatement[]
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ---- Timeline body --------------------------------------------------------
|
|
70
|
-
|
|
71
|
-
export interface TimelineEvent {
|
|
72
|
-
/** Stable within one parse; recomputed each parse. Not a durable identifier. */
|
|
73
|
-
id: string
|
|
74
|
-
text: string
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface TimelinePeriod {
|
|
78
|
-
id: string
|
|
79
|
-
/** The temporal label (e.g., "2020", "Q1 2024"). */
|
|
80
|
-
label: string
|
|
81
|
-
events: TimelineEvent[]
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface TimelineSection {
|
|
85
|
-
id: string
|
|
86
|
-
/** Undefined = implicit/ungrouped section. */
|
|
87
|
-
label?: string
|
|
88
|
-
periods: TimelinePeriod[]
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface TimelineBody {
|
|
92
|
-
kind: 'timeline'
|
|
93
|
-
title?: string
|
|
94
|
-
sections: TimelineSection[]
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// ---- Journey body ----------------------------------------------------------
|
|
98
|
-
|
|
99
|
-
export interface JourneyTask {
|
|
100
|
-
/** Stable within one parse; recomputed each parse. Not a durable identifier. */
|
|
101
|
-
id: string
|
|
102
|
-
text: string
|
|
103
|
-
/** Satisfaction score, integer 1..5 (Mermaid journey convention). */
|
|
104
|
-
score: number
|
|
105
|
-
actors: string[]
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface JourneySection {
|
|
109
|
-
id: string
|
|
110
|
-
/** Undefined = implicit/ungrouped section. */
|
|
111
|
-
label?: string
|
|
112
|
-
tasks: JourneyTask[]
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface JourneyBody {
|
|
116
|
-
kind: 'journey'
|
|
117
|
-
title?: string
|
|
118
|
-
/** Optional accessibility title from Mermaid accTitle. */
|
|
119
|
-
accessibilityTitle?: string
|
|
120
|
-
/** Optional accessibility description from Mermaid accDescr. */
|
|
121
|
-
accessibilityDescription?: string
|
|
122
|
-
sections: JourneySection[]
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// ---- Class diagram body ---------------------------------------------------
|
|
126
|
-
|
|
127
|
-
export type ClassRelationKind =
|
|
128
|
-
| 'inheritance' // <|--
|
|
129
|
-
| 'composition' // *--
|
|
130
|
-
| 'aggregation' // o--
|
|
131
|
-
| 'association' // --> (or --)
|
|
132
|
-
| 'dependency' // ..>
|
|
133
|
-
| 'realization' // ..|>
|
|
134
|
-
| 'link-solid' // --
|
|
135
|
-
| 'link-dashed' // ..
|
|
136
|
-
|
|
137
|
-
export interface ClassNode {
|
|
138
|
-
/** The bare class name (e.g., 'Animal'). */
|
|
139
|
-
id: string
|
|
140
|
-
/** Optional display label (e.g., from `class X["My Label"]` or `class X as "..."`). */
|
|
141
|
-
label?: string
|
|
142
|
-
/** Members, each as the raw source string ('+String name', '+eat()', '<<interface>>'). */
|
|
143
|
-
members: string[]
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export interface ClassRelation {
|
|
147
|
-
from: string
|
|
148
|
-
to: string
|
|
149
|
-
kind: ClassRelationKind
|
|
150
|
-
/** Optional relationship label, e.g., from `A --> B : uses`. */
|
|
151
|
-
label?: string
|
|
152
|
-
/** Optional cardinality on the `from` side (e.g., '"1"'). */
|
|
153
|
-
fromCardinality?: string
|
|
154
|
-
/** Optional cardinality on the `to` side. */
|
|
155
|
-
toCardinality?: string
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export interface ClassNote {
|
|
159
|
-
text: string
|
|
160
|
-
/** Class id the note is attached to (undefined = freestanding). */
|
|
161
|
-
for?: string
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export interface ClassBody {
|
|
165
|
-
kind: 'class'
|
|
166
|
-
title?: string
|
|
167
|
-
classes: ClassNode[]
|
|
168
|
-
relations: ClassRelation[]
|
|
169
|
-
notes: ClassNote[]
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// ---- ER body --------------------------------------------------------------
|
|
173
|
-
|
|
174
|
-
export type ErCardinality =
|
|
175
|
-
| 'one-only' // ||
|
|
176
|
-
| 'zero-or-one' // |o or o|
|
|
177
|
-
| 'zero-or-many' // }o or o{
|
|
178
|
-
| 'one-or-many' // }| or |{
|
|
179
|
-
|
|
180
|
-
export interface ErAttribute {
|
|
181
|
-
/** The full source line (e.g., 'string name PK "comment"'). */
|
|
182
|
-
text: string
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export interface ErEntity {
|
|
186
|
-
id: string
|
|
187
|
-
attributes: ErAttribute[]
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface ErRelation {
|
|
191
|
-
from: string
|
|
192
|
-
to: string
|
|
193
|
-
leftCard: ErCardinality
|
|
194
|
-
rightCard: ErCardinality
|
|
195
|
-
/** Solid (--) or dashed (..) line. */
|
|
196
|
-
dashed: boolean
|
|
197
|
-
label?: string
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export interface ErBody {
|
|
201
|
-
kind: 'er'
|
|
202
|
-
entities: ErEntity[]
|
|
203
|
-
relations: ErRelation[]
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// ---- Architecture body -----------------------------------------------------
|
|
207
|
-
|
|
208
|
-
export type ArchitectureSide = 'L' | 'R' | 'T' | 'B'
|
|
209
|
-
|
|
210
|
-
export interface ArchitectureGroup {
|
|
211
|
-
id: string
|
|
212
|
-
label: string
|
|
213
|
-
icon?: string
|
|
214
|
-
/** Undefined = root (not nested in another group). */
|
|
215
|
-
parentId?: string
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export interface ArchitectureService {
|
|
219
|
-
id: string
|
|
220
|
-
label: string
|
|
221
|
-
icon?: string
|
|
222
|
-
/** Undefined = ungrouped (not inside a group). */
|
|
223
|
-
parentId?: string
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export interface ArchitectureJunction {
|
|
227
|
-
id: string
|
|
228
|
-
parentId?: string
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export interface ArchitectureEndpoint {
|
|
232
|
-
id: string
|
|
233
|
-
side: ArchitectureSide
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export interface ArchitectureEdge {
|
|
237
|
-
source: ArchitectureEndpoint
|
|
238
|
-
target: ArchitectureEndpoint
|
|
239
|
-
label?: string
|
|
240
|
-
hasArrowStart: boolean
|
|
241
|
-
hasArrowEnd: boolean
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export interface ArchitectureBody {
|
|
245
|
-
kind: 'architecture'
|
|
246
|
-
groups: ArchitectureGroup[]
|
|
247
|
-
services: ArchitectureService[]
|
|
248
|
-
junctions: ArchitectureJunction[]
|
|
249
|
-
edges: ArchitectureEdge[]
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// ---- XY chart body ---------------------------------------------------------
|
|
253
|
-
|
|
254
|
-
/** A single chart axis: an optional bare-text name plus EITHER categorical
|
|
255
|
-
* labels (x-axis only) OR a numeric range. All three fields are optional;
|
|
256
|
-
* a structured axis carries at least one of them. */
|
|
257
|
-
export interface XyChartAxis {
|
|
258
|
-
/** Optional bare-text axis name/title. */
|
|
259
|
-
name?: string
|
|
260
|
-
/** Categorical labels (x-axis only) — mutually exclusive with range. */
|
|
261
|
-
categories?: string[]
|
|
262
|
-
/** Numeric range — mutually exclusive with categories. */
|
|
263
|
-
range?: { min: number; max: number }
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export interface XyChartSeries {
|
|
267
|
-
/** Stable within one parse; recomputed each parse. Not a durable identifier. */
|
|
268
|
-
id: string
|
|
269
|
-
kind: 'bar' | 'line'
|
|
270
|
-
/** Optional bare-text series name. */
|
|
271
|
-
name?: string
|
|
272
|
-
/** Data values; all finite. */
|
|
273
|
-
values: number[]
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export interface XyChartBody {
|
|
277
|
-
kind: 'xychart'
|
|
278
|
-
title?: string
|
|
279
|
-
/** Header orientation suffix: `xychart-beta horizontal`. Default vertical. */
|
|
280
|
-
horizontal?: boolean
|
|
281
|
-
xAxis?: XyChartAxis
|
|
282
|
-
yAxis?: XyChartAxis
|
|
283
|
-
series: XyChartSeries[]
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// ---- Pie body ---------------------------------------------------------------
|
|
287
|
-
|
|
288
|
-
export interface PieSlice {
|
|
289
|
-
/** Stable within one parse; recomputed each parse. Not a durable identifier. */
|
|
290
|
-
id: string
|
|
291
|
-
/** The slice label (contents of the `"..."` quotes). */
|
|
292
|
-
label: string
|
|
293
|
-
/** The slice value — a positive finite number. */
|
|
294
|
-
value: number
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export interface PieBody {
|
|
298
|
-
kind: 'pie'
|
|
299
|
-
title?: string
|
|
300
|
-
/** When true (`pie showData`), the legend shows each slice's numeric value. */
|
|
301
|
-
showData: boolean
|
|
302
|
-
/** Slices in source order (drawn clockwise). */
|
|
303
|
-
slices: PieSlice[]
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// ---- Quadrant body ----------------------------------------------------------
|
|
307
|
-
|
|
308
|
-
/** Axis label pair. The "far" side is optional in the grammar. */
|
|
309
|
-
export interface QuadrantAxis {
|
|
310
|
-
/** x-axis: left label / y-axis: bottom label. */
|
|
311
|
-
near: string
|
|
312
|
-
/** x-axis: right label / y-axis: top label. Optional. */
|
|
313
|
-
far?: string
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
export interface QuadrantPoint {
|
|
317
|
-
label: string
|
|
318
|
-
/** Normalized x in [0, 1] (0 = left, 1 = right). */
|
|
319
|
-
x: number
|
|
320
|
-
/** Normalized y in [0, 1] (0 = bottom, 1 = top). */
|
|
321
|
-
y: number
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
export interface QuadrantBody {
|
|
325
|
-
kind: 'quadrant'
|
|
326
|
-
title?: string
|
|
327
|
-
xAxis?: QuadrantAxis
|
|
328
|
-
yAxis?: QuadrantAxis
|
|
329
|
-
/**
|
|
330
|
-
* Quadrant region labels indexed 1..4 by Mermaid's numbering:
|
|
331
|
-
* 1 = top-right, 2 = top-left, 3 = bottom-left, 4 = bottom-right.
|
|
332
|
-
* Stored 0-based where index `n-1` holds quadrant-`n`.
|
|
333
|
-
*/
|
|
334
|
-
quadrants: [string?, string?, string?, string?]
|
|
335
|
-
/** Plotted points in source order. */
|
|
336
|
-
points: QuadrantPoint[]
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// ---- Gantt body --------------------------------------------------------------
|
|
340
|
-
|
|
341
|
-
export type GanttBodyTaskTag = 'active' | 'done' | 'crit' | 'milestone' | 'vert'
|
|
342
|
-
|
|
343
|
-
export interface GanttBodyTask {
|
|
344
|
-
/** Stable within one parse; recomputed each parse. Not a durable identifier. */
|
|
345
|
-
id: string
|
|
346
|
-
/** Mermaid task id from `:id, start, end` — referenced by after/until/click. */
|
|
347
|
-
taskId?: string
|
|
348
|
-
label: string
|
|
349
|
-
/** Status/shape tags in canonical order (active/done/crit/milestone/vert). */
|
|
350
|
-
tags: GanttBodyTaskTag[]
|
|
351
|
-
/** Raw start expression: a date in the diagram's dateFormat or `after id…`.
|
|
352
|
-
* Undefined = starts when the previous task ends (Mermaid default). */
|
|
353
|
-
start?: string
|
|
354
|
-
/** Raw end expression: a date, a duration token (`3d`), or `until id…`. */
|
|
355
|
-
end: string
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
export interface GanttBodySection {
|
|
359
|
-
id: string
|
|
360
|
-
/** Undefined = implicit/ungrouped section. */
|
|
361
|
-
label?: string
|
|
362
|
-
tasks: GanttBodyTask[]
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Segment-preserving statement list (the sequence-body pattern): typed ops see
|
|
367
|
-
* sections/tasks/title; calendar directives (dateFormat, excludes, weekend…),
|
|
368
|
-
* click lines, comments, and markers ride along VERBATIM as opaque-block
|
|
369
|
-
* segments — never dropped, edited at the source level only.
|
|
370
|
-
*/
|
|
371
|
-
export type GanttStatement =
|
|
372
|
-
| { kind: 'title' }
|
|
373
|
-
| { kind: 'section'; ref: number } // index into sections
|
|
374
|
-
| { kind: 'task'; section: number; ref: number } // section + task index
|
|
375
|
-
| { kind: 'opaque-block'; lines: string[] }
|
|
376
|
-
|
|
377
|
-
export interface GanttBody {
|
|
378
|
-
kind: 'gantt'
|
|
379
|
-
title?: string
|
|
380
|
-
sections: GanttBodySection[]
|
|
381
|
-
/** Optional for synthesized payloads; parsed bodies always populate it. */
|
|
382
|
-
statements?: GanttStatement[]
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// ---- State diagram body -----------------------------------------------------
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* A state node. Simple states carry an optional display label; composite states
|
|
389
|
-
* additionally carry their own nested `states` + `transitions` (and an optional
|
|
390
|
-
* per-composite `direction`). The reserved pseudostate `[*]` is NOT a StateNode
|
|
391
|
-
* — it is modeled contextually as the endpoint id '[*]' on transitions (source
|
|
392
|
-
* = start pseudostate, target = end pseudostate), scoped per composite level.
|
|
393
|
-
*/
|
|
394
|
-
export interface StateNode {
|
|
395
|
-
id: string
|
|
396
|
-
/** Optional display label (`state "Label" as id` / `id : Label`). */
|
|
397
|
-
label?: string
|
|
398
|
-
/** Composite children — present iff this is a composite state. */
|
|
399
|
-
states?: StateNode[]
|
|
400
|
-
/** Composite-internal transitions — present iff this is a composite state. */
|
|
401
|
-
transitions?: StateTransition[]
|
|
402
|
-
/** Optional per-composite layout direction. */
|
|
403
|
-
direction?: import('../types.ts').Direction
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
export interface StateTransition {
|
|
407
|
-
/** Source state id, or '[*]' for a start pseudostate. */
|
|
408
|
-
from: string
|
|
409
|
-
/** Target state id, or '[*]' for an end pseudostate. */
|
|
410
|
-
to: string
|
|
411
|
-
label?: string
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
export interface StateBody {
|
|
415
|
-
kind: 'state'
|
|
416
|
-
states: StateNode[]
|
|
417
|
-
transitions: StateTransition[]
|
|
418
|
-
/** Optional top-level layout direction. */
|
|
419
|
-
direction?: import('../types.ts').Direction
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// ---- Meta + IR ------------------------------------------------------------
|
|
423
|
-
|
|
424
|
-
export interface SourceComment { text: string; line: number }
|
|
425
|
-
export interface InitDirective { raw: string; parsed: MermaidConfigMap }
|
|
426
|
-
export interface Accessibility { title?: string; descr?: string }
|
|
427
|
-
|
|
428
|
-
export interface ValidDiagramMeta {
|
|
429
|
-
frontmatter?: MermaidFrontmatterMap
|
|
430
|
-
initDirectives: InitDirective[]
|
|
431
|
-
comments: SourceComment[]
|
|
432
|
-
accessibility: Accessibility
|
|
433
|
-
/**
|
|
434
|
-
* The leading source wrapper (frontmatter block, `%%{init}%%` directives,
|
|
435
|
-
* `%%` comments, and blank lines before the diagram header), preserved
|
|
436
|
-
* byte-verbatim. serializeMermaid re-emits it untouched by default;
|
|
437
|
-
* canonical wrapper synthesis is opt-in via `{ wrapper: 'canonical' }`.
|
|
438
|
-
* Absent on diagrams synthesized from JSON payloads, which fall back to
|
|
439
|
-
* canonical synthesis.
|
|
440
|
-
*/
|
|
441
|
-
wrapperSource?: string
|
|
442
|
-
/**
|
|
443
|
-
* In-body `%%` comments that structured serialization does not preserve,
|
|
444
|
-
* computed at parse time by diffing against the canonical serialization.
|
|
445
|
-
* Surfaced by verify as the Tier 3 `COMMENT_DROPPED` lint. Opaque bodies
|
|
446
|
-
* preserve comments verbatim and never set this.
|
|
447
|
-
*/
|
|
448
|
-
droppedComments?: SourceComment[]
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
export interface SourceLocation { line: number; col: number }
|
|
452
|
-
|
|
453
|
-
export interface SourceMap {
|
|
454
|
-
nodes: Map<string, SourceLocation>
|
|
455
|
-
edges: Map<string, SourceLocation>
|
|
456
|
-
groups: Map<string, SourceLocation>
|
|
457
|
-
/** Stable label spans where known: `node:<id>`, `edge#<i>:<from>-><to>`, `group:<id>`. */
|
|
458
|
-
labels: Map<string, SourceLocation>
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
export type DiagramActionKind = 'href' | 'call' | 'callback'
|
|
462
|
-
export type DiagramActionSecurity = 'safe' | 'unsafe' | 'source-only' | 'unsupported'
|
|
463
|
-
|
|
464
|
-
export interface DiagramActionRecord {
|
|
465
|
-
/** Stable source-side action id (`action:<family>:<target>:<n>`). */
|
|
466
|
-
id?: string
|
|
467
|
-
/** Region id this action attaches to when a rendered layout exposes regions. */
|
|
468
|
-
regionId?: string
|
|
469
|
-
family: DiagramKind
|
|
470
|
-
target: string
|
|
471
|
-
action: DiagramActionKind
|
|
472
|
-
/** Original action payload after the target id; never executed by analysis. */
|
|
473
|
-
raw: string
|
|
474
|
-
line?: number
|
|
475
|
-
href?: string
|
|
476
|
-
security: DiagramActionSecurity
|
|
477
|
-
executable: false
|
|
478
|
-
message?: string
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
export interface FeedbackEdgeAnalysis {
|
|
482
|
-
edgeIndex: number
|
|
483
|
-
from: NodeId
|
|
484
|
-
to: NodeId
|
|
485
|
-
label?: string
|
|
486
|
-
routeClass: RouteClass
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
export interface GanttScheduleAnalysisSummary {
|
|
490
|
-
criticalPathTaskIds: string[]
|
|
491
|
-
slackByTaskId: Record<string, number>
|
|
492
|
-
projectStart: number
|
|
493
|
-
projectEnd: number
|
|
494
|
-
entryTaskIds: string[]
|
|
495
|
-
sinkTaskIds: string[]
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
export interface DiagramAnalysis {
|
|
499
|
-
kind: DiagramKind
|
|
500
|
-
feedbackEdges: FeedbackEdgeAnalysis[]
|
|
501
|
-
actions: DiagramActionRecord[]
|
|
502
|
-
gantt?: GanttScheduleAnalysisSummary
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
export type DiagramBody =
|
|
506
|
-
| { kind: 'flowchart'; graph: MermaidGraph }
|
|
507
|
-
| StateBody
|
|
508
|
-
| SequenceBody
|
|
509
|
-
| TimelineBody
|
|
510
|
-
| ClassBody
|
|
511
|
-
| ErBody
|
|
512
|
-
| JourneyBody
|
|
513
|
-
| ArchitectureBody
|
|
514
|
-
| XyChartBody
|
|
515
|
-
| PieBody
|
|
516
|
-
| QuadrantBody
|
|
517
|
-
| GanttBody
|
|
518
|
-
/**
|
|
519
|
-
* Opaque body — the parser understood the family header but encountered
|
|
520
|
-
* unmodeled syntax. `source` is the ORIGINAL body with indentation, blank
|
|
521
|
-
* lines, and comments PRESERVED (per the Loop 5 Phase A fix), so the
|
|
522
|
-
* serializer can re-emit byte-for-byte. Distinct from `ValidDiagram.canonicalSource`,
|
|
523
|
-
* which for structured bodies is the rebuilt canonical form.
|
|
524
|
-
*/
|
|
525
|
-
| { kind: 'opaque'; family: DiagramKind; source: string }
|
|
526
|
-
|
|
527
|
-
export interface ValidDiagram {
|
|
528
|
-
readonly kind: DiagramKind
|
|
529
|
-
readonly meta: ValidDiagramMeta
|
|
530
|
-
readonly body: DiagramBody
|
|
531
|
-
readonly source: SourceMap
|
|
532
|
-
/**
|
|
533
|
-
* Load-bearing round-trip pillar. See AGENT_NATIVE.md § (3).
|
|
534
|
-
*
|
|
535
|
-
* For STRUCTURED bodies, `canonicalSource` is the normalized text
|
|
536
|
-
* (`normalized.text` from `mermaid-source.ts`) — used by `renderMermaidSVG`
|
|
537
|
-
* + the legacy parser for the flowchart pathway. After `serializeMermaid`,
|
|
538
|
-
* the re-emitted source is rebuilt from the structured body.
|
|
539
|
-
*
|
|
540
|
-
* For OPAQUE bodies, the serializer emits `body.source` directly (NOT
|
|
541
|
-
* `canonicalSource`) so original indentation and blank lines round-trip
|
|
542
|
-
* byte-for-byte. `canonicalSource` is still set, but it's the normalized
|
|
543
|
-
* (line-trimmed) form — useful for layout / rendering, not for fidelity.
|
|
544
|
-
*
|
|
545
|
-
* This split exists because the legacy flowchart parser needs trimmed
|
|
546
|
-
* lines, but opaque-fallback round-trip needs the original. Treat
|
|
547
|
-
* `body.source` as the source of truth for opaque-body fidelity.
|
|
548
|
-
*/
|
|
549
|
-
readonly canonicalSource: string
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
export type FlowchartValidDiagram = ValidDiagram & { body: { kind: 'flowchart'; graph: MermaidGraph } }
|
|
553
|
-
export type StateValidDiagram = ValidDiagram & { body: StateBody }
|
|
554
|
-
export type SequenceValidDiagram = ValidDiagram & { body: SequenceBody }
|
|
555
|
-
export type TimelineValidDiagram = ValidDiagram & { body: TimelineBody }
|
|
556
|
-
export type ClassValidDiagram = ValidDiagram & { body: ClassBody }
|
|
557
|
-
export type ErValidDiagram = ValidDiagram & { body: ErBody }
|
|
558
|
-
export type JourneyValidDiagram = ValidDiagram & { body: JourneyBody }
|
|
559
|
-
export type ArchitectureValidDiagram = ValidDiagram & { body: ArchitectureBody }
|
|
560
|
-
export type XyChartValidDiagram = ValidDiagram & { body: XyChartBody }
|
|
561
|
-
export type PieValidDiagram = ValidDiagram & { body: PieBody }
|
|
562
|
-
export type QuadrantValidDiagram = ValidDiagram & { body: QuadrantBody }
|
|
563
|
-
export type GanttValidDiagram = ValidDiagram & { body: GanttBody }
|
|
564
|
-
export type MutableValidDiagram = FlowchartValidDiagram | StateValidDiagram | SequenceValidDiagram | TimelineValidDiagram | ClassValidDiagram | ErValidDiagram | JourneyValidDiagram | ArchitectureValidDiagram | XyChartValidDiagram | PieValidDiagram | QuadrantValidDiagram | GanttValidDiagram
|
|
565
|
-
|
|
566
|
-
export function asFlowchart(d: ValidDiagram): FlowchartValidDiagram | null {
|
|
567
|
-
return d.body.kind === 'flowchart' ? (d as FlowchartValidDiagram) : null
|
|
568
|
-
}
|
|
569
|
-
export function asState(d: ValidDiagram): StateValidDiagram | null {
|
|
570
|
-
return d.body.kind === 'state' ? (d as StateValidDiagram) : null
|
|
571
|
-
}
|
|
572
|
-
export function asSequence(d: ValidDiagram): SequenceValidDiagram | null {
|
|
573
|
-
return d.body.kind === 'sequence' ? (d as SequenceValidDiagram) : null
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
export function asTimeline(d: ValidDiagram): TimelineValidDiagram | null {
|
|
577
|
-
return d.body.kind === 'timeline' ? (d as TimelineValidDiagram) : null
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
export function asClass(d: ValidDiagram): ClassValidDiagram | null {
|
|
581
|
-
return d.body.kind === 'class' ? (d as ClassValidDiagram) : null
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
export function asEr(d: ValidDiagram): ErValidDiagram | null {
|
|
585
|
-
return d.body.kind === 'er' ? (d as ErValidDiagram) : null
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
export function asJourney(d: ValidDiagram): JourneyValidDiagram | null {
|
|
589
|
-
return d.body.kind === 'journey' ? (d as JourneyValidDiagram) : null
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
export function asArchitecture(d: ValidDiagram): ArchitectureValidDiagram | null {
|
|
593
|
-
return d.body.kind === 'architecture' ? (d as ArchitectureValidDiagram) : null
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
export function asXyChart(d: ValidDiagram): XyChartValidDiagram | null {
|
|
597
|
-
return d.body.kind === 'xychart' ? (d as XyChartValidDiagram) : null
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
export function asPie(d: ValidDiagram): PieValidDiagram | null {
|
|
601
|
-
return d.body.kind === 'pie' ? (d as PieValidDiagram) : null
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
export function asQuadrant(d: ValidDiagram): QuadrantValidDiagram | null {
|
|
605
|
-
return d.body.kind === 'quadrant' ? (d as QuadrantValidDiagram) : null
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
export function asGantt(d: ValidDiagram): GanttValidDiagram | null {
|
|
609
|
-
return d.body.kind === 'gantt' ? (d as GanttValidDiagram) : null
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
// ---- Errors ---------------------------------------------------------------
|
|
613
|
-
|
|
614
|
-
export interface ParseError { code: string; message: string; line?: number; col?: number }
|
|
615
|
-
|
|
616
|
-
export interface MutationError {
|
|
617
|
-
code:
|
|
618
|
-
| 'NODE_NOT_FOUND' | 'EDGE_NOT_FOUND'
|
|
619
|
-
| 'PARTICIPANT_NOT_FOUND' | 'MESSAGE_NOT_FOUND'
|
|
620
|
-
| 'SECTION_NOT_FOUND' | 'PERIOD_NOT_FOUND' | 'EVENT_NOT_FOUND'
|
|
621
|
-
| 'TASK_NOT_FOUND' | 'ACTOR_NOT_FOUND'
|
|
622
|
-
| 'CLASS_NOT_FOUND' | 'MEMBER_NOT_FOUND' | 'RELATION_NOT_FOUND' | 'NOTE_NOT_FOUND'
|
|
623
|
-
| 'ENTITY_NOT_FOUND' | 'ATTRIBUTE_NOT_FOUND'
|
|
624
|
-
| 'SERVICE_NOT_FOUND' | 'GROUP_NOT_FOUND'
|
|
625
|
-
| 'SERIES_NOT_FOUND'
|
|
626
|
-
| 'SLICE_NOT_FOUND' | 'POINT_NOT_FOUND'
|
|
627
|
-
| 'STATE_NOT_FOUND' | 'TRANSITION_NOT_FOUND'
|
|
628
|
-
| 'DUPLICATE_NODE' | 'DUPLICATE_PARTICIPANT' | 'DUPLICATE_CLASS' | 'DUPLICATE_ENTITY' | 'DUPLICATE_STATE' | 'DUPLICATE_TASK'
|
|
629
|
-
| 'INVALID_OP'
|
|
630
|
-
message: string
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
// ---- MutationOp -----------------------------------------------------------
|
|
634
|
-
|
|
635
|
-
export type NodeId = string
|
|
636
|
-
export type EdgeId = string
|
|
637
|
-
export type GroupId = string
|
|
638
|
-
export type ParticipantId = string
|
|
639
|
-
|
|
640
|
-
export type FlowchartMutationOp =
|
|
641
|
-
| { kind: 'add_node'; id: NodeId; label: string; shape?: NodeShape; parent?: GroupId }
|
|
642
|
-
| { kind: 'remove_node'; id: NodeId }
|
|
643
|
-
| { kind: 'rename_node'; from: NodeId; to: NodeId }
|
|
644
|
-
| { kind: 'set_label'; target: NodeId | EdgeId; label: string }
|
|
645
|
-
| { kind: 'add_edge'; from: NodeId; to: NodeId; label?: string; style?: EdgeStyle }
|
|
646
|
-
| { kind: 'remove_edge'; id: EdgeId }
|
|
647
|
-
|
|
648
|
-
export type SequenceMutationOp =
|
|
649
|
-
| { kind: 'add_participant'; id: ParticipantId; label?: string; participantKind?: 'participant' | 'actor' }
|
|
650
|
-
| { kind: 'remove_participant'; id: ParticipantId }
|
|
651
|
-
| { kind: 'add_message'; from: ParticipantId; to: ParticipantId; text: string; style?: SequenceMessageStyle }
|
|
652
|
-
| { kind: 'remove_message'; index: number }
|
|
653
|
-
| { kind: 'set_message_text'; index: number; text: string }
|
|
654
|
-
|
|
655
|
-
export type TimelineMutationOp =
|
|
656
|
-
| { kind: 'set_title'; title: string | null }
|
|
657
|
-
| { kind: 'add_section'; label: string }
|
|
658
|
-
| { kind: 'remove_section'; index: number }
|
|
659
|
-
| { kind: 'set_section_label'; index: number; label: string }
|
|
660
|
-
| { kind: 'add_period'; sectionIndex: number; label: string; events?: string[] }
|
|
661
|
-
| { kind: 'remove_period'; sectionIndex: number; periodIndex: number }
|
|
662
|
-
| { kind: 'set_period_label'; sectionIndex: number; periodIndex: number; label: string }
|
|
663
|
-
| { kind: 'add_event'; sectionIndex: number; periodIndex: number; text: string }
|
|
664
|
-
| { kind: 'remove_event'; sectionIndex: number; periodIndex: number; eventIndex: number }
|
|
665
|
-
| { kind: 'set_event_text'; sectionIndex: number; periodIndex: number; eventIndex: number; text: string }
|
|
666
|
-
|
|
667
|
-
export type ClassMutationOp =
|
|
668
|
-
| { kind: 'set_title'; title: string | null }
|
|
669
|
-
| { kind: 'add_class'; id: string; label?: string; members?: string[] }
|
|
670
|
-
| { kind: 'remove_class'; id: string }
|
|
671
|
-
| { kind: 'rename_class'; from: string; to: string }
|
|
672
|
-
| { kind: 'add_member'; class: string; text: string }
|
|
673
|
-
| { kind: 'remove_member'; class: string; index: number }
|
|
674
|
-
| { kind: 'add_relation'; from: string; to: string; relKind: ClassRelationKind; label?: string }
|
|
675
|
-
| { kind: 'remove_relation'; index: number }
|
|
676
|
-
| { kind: 'add_note'; text: string; for?: string }
|
|
677
|
-
| { kind: 'remove_note'; index: number }
|
|
678
|
-
|
|
679
|
-
export type ErMutationOp =
|
|
680
|
-
| { kind: 'add_entity'; id: string; attributes?: string[] }
|
|
681
|
-
| { kind: 'remove_entity'; id: string }
|
|
682
|
-
| { kind: 'rename_entity'; from: string; to: string }
|
|
683
|
-
| { kind: 'add_attribute'; entity: string; text: string }
|
|
684
|
-
| { kind: 'remove_attribute'; entity: string; index: number }
|
|
685
|
-
| { kind: 'add_relation'; from: string; to: string; leftCard: ErCardinality; rightCard: ErCardinality; dashed?: boolean; label?: string }
|
|
686
|
-
| { kind: 'remove_relation'; index: number }
|
|
687
|
-
|
|
688
|
-
export type JourneyMutationOp =
|
|
689
|
-
| { kind: 'set_title'; title: string | null }
|
|
690
|
-
| { kind: 'add_section'; label: string; index?: number }
|
|
691
|
-
| { kind: 'remove_section'; index: number }
|
|
692
|
-
| { kind: 'set_section_label'; index: number; label: string }
|
|
693
|
-
| { kind: 'add_task'; sectionIndex: number; text: string; score: number; actors?: string[]; index?: number }
|
|
694
|
-
| { kind: 'remove_task'; sectionIndex: number; taskIndex: number }
|
|
695
|
-
| { kind: 'set_task_text'; sectionIndex: number; taskIndex: number; text: string }
|
|
696
|
-
| { kind: 'set_task_score'; sectionIndex: number; taskIndex: number; score: number }
|
|
697
|
-
| { kind: 'set_task_actors'; sectionIndex: number; taskIndex: number; actors: string[] }
|
|
698
|
-
| { kind: 'rename_actor'; from: string; to: string }
|
|
699
|
-
// Journey order IS the timeline, so ordering is a first-class edit rather
|
|
700
|
-
// than a remove+re-add dance with shifting indices (every other ordered
|
|
701
|
-
// family already carries its reorder op).
|
|
702
|
-
| { kind: 'move_task'; fromSection: number; fromIndex: number; toSection: number; toIndex: number }
|
|
703
|
-
| { kind: 'move_section'; from: number; to: number }
|
|
704
|
-
| { kind: 'set_accessibility_title'; title: string | null }
|
|
705
|
-
| { kind: 'set_accessibility_description'; description: string | null }
|
|
706
|
-
|
|
707
|
-
export type ArchitectureMutationOp =
|
|
708
|
-
| { kind: 'add_service'; id: string; label?: string; icon?: string | null; group?: string | null }
|
|
709
|
-
| { kind: 'remove_service'; id: string }
|
|
710
|
-
| { kind: 'rename_service'; from: string; to: string }
|
|
711
|
-
| { kind: 'set_service_label'; id: string; label: string }
|
|
712
|
-
| { kind: 'set_service_icon'; id: string; icon: string | null }
|
|
713
|
-
| { kind: 'move_service'; id: string; group: string | null }
|
|
714
|
-
| { kind: 'add_group'; id: string; label?: string; icon?: string | null; parent?: string | null }
|
|
715
|
-
| { kind: 'remove_group'; id: string }
|
|
716
|
-
| { kind: 'add_edge'; from: string; to: string; fromSide: ArchitectureSide; toSide: ArchitectureSide; label?: string | null; hasArrowStart?: boolean; hasArrowEnd?: boolean }
|
|
717
|
-
| { kind: 'remove_edge'; index?: number; id?: string }
|
|
718
|
-
|
|
719
|
-
export type StateMutationOp =
|
|
720
|
-
| { kind: 'add_state'; id: string; label?: string | null; parent?: string | null }
|
|
721
|
-
| { kind: 'remove_state'; id: string }
|
|
722
|
-
| { kind: 'rename_state'; from: string; to: string }
|
|
723
|
-
| { kind: 'set_state_label'; id: string; label: string | null }
|
|
724
|
-
| { kind: 'add_transition'; from: string; to: string; label?: string | null; parent?: string | null }
|
|
725
|
-
| { kind: 'remove_transition'; index?: number; from?: string; to?: string; parent?: string | null }
|
|
726
|
-
| { kind: 'set_transition_label'; index?: number; from?: string; to?: string; label: string | null; parent?: string | null }
|
|
727
|
-
| { kind: 'make_composite'; id: string; members: string[]; label?: string | null }
|
|
728
|
-
|
|
729
|
-
export type XyChartAxisSpec = { name?: string | null; categories?: string[]; range?: { min: number; max: number } }
|
|
730
|
-
|
|
731
|
-
export type XyChartMutationOp =
|
|
732
|
-
| { kind: 'set_title'; title: string | null }
|
|
733
|
-
| { kind: 'set_x_axis'; axis: XyChartAxisSpec | null }
|
|
734
|
-
| { kind: 'set_y_axis'; axis: XyChartAxisSpec | null }
|
|
735
|
-
| { kind: 'add_series'; kind2: 'bar' | 'line'; name?: string | null; values: number[] }
|
|
736
|
-
| { kind: 'remove_series'; index: number }
|
|
737
|
-
| { kind: 'set_series_values'; index: number; values: number[] }
|
|
738
|
-
| { kind: 'set_series_name'; index: number; name: string | null }
|
|
739
|
-
| { kind: 'reorder_series'; from: number; to: number }
|
|
740
|
-
|
|
741
|
-
export type PieMutationOp =
|
|
742
|
-
| { kind: 'set_title'; title: string | null }
|
|
743
|
-
| { kind: 'set_show_data'; showData: boolean }
|
|
744
|
-
| { kind: 'add_slice'; label: string; value: number }
|
|
745
|
-
| { kind: 'remove_slice'; label: string }
|
|
746
|
-
| { kind: 'rename_slice'; from: string; to: string }
|
|
747
|
-
| { kind: 'set_slice_value'; label: string; value: number }
|
|
748
|
-
| { kind: 'reorder_slice'; from: number; to: number }
|
|
749
|
-
|
|
750
|
-
export type QuadrantMutationOp =
|
|
751
|
-
| { kind: 'set_title'; title: string | null }
|
|
752
|
-
| { kind: 'set_axis_labels'; axis: 'x' | 'y'; near: string | null; far?: string | null }
|
|
753
|
-
| { kind: 'set_quadrant_label'; quadrant: number; label: string | null }
|
|
754
|
-
| { kind: 'add_point'; label: string; x: number; y: number }
|
|
755
|
-
| { kind: 'remove_point'; label: string }
|
|
756
|
-
| { kind: 'move_point'; label: string; x: number; y: number }
|
|
757
|
-
| { kind: 'rename_point'; from: string; to: string }
|
|
758
|
-
|
|
759
|
-
export type GanttMutationOp =
|
|
760
|
-
| { kind: 'set_title'; title: string | null }
|
|
761
|
-
| { kind: 'add_section'; label: string }
|
|
762
|
-
| { kind: 'rename_section'; index: number; label: string }
|
|
763
|
-
| { kind: 'remove_section'; index: number }
|
|
764
|
-
| { kind: 'add_task'; sectionIndex: number; label: string; taskId?: string; tags?: GanttBodyTaskTag[]; start?: string; end: string }
|
|
765
|
-
| { kind: 'remove_task'; sectionIndex: number; taskIndex: number }
|
|
766
|
-
| { kind: 'rename_task'; sectionIndex: number; taskIndex: number; label: string }
|
|
767
|
-
| { kind: 'set_task_status'; sectionIndex: number; taskIndex: number; status: 'active' | 'done' | 'crit' | null }
|
|
768
|
-
| { kind: 'set_task_dates'; sectionIndex: number; taskIndex: number; start?: string | null; end?: string }
|
|
769
|
-
|
|
770
|
-
export type AnyMutationOp = FlowchartMutationOp | StateMutationOp | SequenceMutationOp | TimelineMutationOp | ClassMutationOp | ErMutationOp | JourneyMutationOp | ArchitectureMutationOp | XyChartMutationOp | PieMutationOp | QuadrantMutationOp | GanttMutationOp
|
|
771
|
-
export type MutationOp = FlowchartMutationOp // legacy alias
|
|
772
|
-
|
|
773
|
-
// ---- Branded Finite -------------------------------------------------------
|
|
774
|
-
|
|
775
|
-
declare const FINITE_BRAND: unique symbol
|
|
776
|
-
export type Finite = number & { readonly [FINITE_BRAND]: true }
|
|
777
|
-
|
|
778
|
-
export function toFinite(n: number): Finite {
|
|
779
|
-
if (!Number.isFinite(n)) throw new RangeError(`expected a finite number, got ${String(n)}`)
|
|
780
|
-
return n as Finite
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
// ---- Verify ---------------------------------------------------------------
|
|
784
|
-
|
|
785
|
-
export type WarningSeverity = 'error' | 'warning'
|
|
786
|
-
export type WarningTier = 'structural' | 'geometric' | 'lint'
|
|
787
|
-
|
|
788
|
-
export type Tier1WarningCode =
|
|
789
|
-
| 'EMPTY_DIAGRAM' | 'EDGE_MISANCHORED' | 'OFF_CANVAS'
|
|
790
|
-
| 'GROUP_BREACH' | 'UNKNOWN_SHAPE' | 'LABEL_OVERFLOW' | 'UNRESOLVABLE_SCHEDULE'
|
|
791
|
-
| 'RENDER_FAILED'
|
|
792
|
-
export type Tier2WarningCode =
|
|
793
|
-
| 'NODE_OVERLAP' | 'ROUTE_SELF_CROSS' | 'ROUTE_HITCH'
|
|
794
|
-
| 'ROUTE_UNEXPLAINED_BEND' | 'ROUTE_LABEL_ON_SHARED_TRUNK'
|
|
795
|
-
| 'ROUTE_CONTAINER_MISANCHOR' | 'ROUTE_SHAPE_MISANCHOR' | 'ROUTE_STALE_AFTER_NODE_MOVE'
|
|
796
|
-
/**
|
|
797
|
-
* Tier 3 (advisory lint). Family-specific quality hints for common agent
|
|
798
|
-
* mistakes that still parse and render. Lint warnings never flip verify.ok.
|
|
799
|
-
*/
|
|
800
|
-
export type Tier3WarningCode = 'DUPLICATE_EDGE' | 'UNREACHABLE_NODE' | 'DECISION_BRANCH_UNLABELED' | 'COMMENT_DROPPED' | 'UNSUPPORTED_SYNTAX' | 'CONTENT_DROPPED_ON_ROUNDTRIP' | 'INEFFECTIVE_CONFIG'
|
|
801
|
-
export type WarningCode = Tier1WarningCode | Tier2WarningCode | Tier3WarningCode
|
|
802
|
-
|
|
803
|
-
export type LayoutWarning =
|
|
804
|
-
| { code: 'EMPTY_DIAGRAM' }
|
|
805
|
-
| { code: 'EDGE_MISANCHORED'; edge: EdgeId; from?: NodeId; to?: NodeId }
|
|
806
|
-
| { code: 'OFF_CANVAS'; target: NodeId | EdgeId; axis: 'x' | 'y' }
|
|
807
|
-
| { code: 'GROUP_BREACH'; group: GroupId; member: NodeId }
|
|
808
|
-
| { code: 'UNKNOWN_SHAPE'; node: NodeId; shape: string }
|
|
809
|
-
| { code: 'LABEL_OVERFLOW'; target: NodeId | EdgeId; charCount: number; limit: number }
|
|
810
|
-
/**
|
|
811
|
-
* The diagram parses (and round-trips) but its semantics cannot resolve, so
|
|
812
|
-
* rendering will fail loudly — e.g. a Gantt whose schedule hits a bad
|
|
813
|
-
* calendar date, a dependency cycle, or an everything-excluded calendar.
|
|
814
|
-
* `reason` carries the named renderer error (GANTT_*…). Closes the
|
|
815
|
-
* "verify ok but render throws" seam for structured gantt bodies.
|
|
816
|
-
*/
|
|
817
|
-
| { code: 'UNRESOLVABLE_SCHEDULE'; reason: string }
|
|
818
|
-
/**
|
|
819
|
-
* The diagram parses on the agent side (possibly with unmodeled syntax
|
|
820
|
-
* preserved verbatim) but the STRICT render parser throws on its canonical
|
|
821
|
-
* source — `am render` would exit 4. Generalizes UNRESOLVABLE_SCHEDULE's
|
|
822
|
-
* "verify ok but render throws" seam-closing to every family: found live
|
|
823
|
-
* when onboarding agents followed verify-before-commit and still shipped
|
|
824
|
-
* unrenderable quadrant/architecture diagrams. `reason` carries the
|
|
825
|
-
* renderer's error message.
|
|
826
|
-
*/
|
|
827
|
-
| { code: 'RENDER_FAILED'; reason: string }
|
|
828
|
-
| { code: 'NODE_OVERLAP'; a: NodeId; b: NodeId; areaPx: number }
|
|
829
|
-
| { code: 'ROUTE_SELF_CROSS'; edge: EdgeId; count: number }
|
|
830
|
-
| { code: 'ROUTE_HITCH'; edge: EdgeId; deviationPx: number }
|
|
831
|
-
| { code: 'ROUTE_UNEXPLAINED_BEND'; edge: EdgeId }
|
|
832
|
-
| { code: 'ROUTE_LABEL_ON_SHARED_TRUNK'; edge: EdgeId; sharedWith: EdgeId }
|
|
833
|
-
| { code: 'ROUTE_CONTAINER_MISANCHOR'; edge: EdgeId; container: GroupId }
|
|
834
|
-
| { code: 'ROUTE_SHAPE_MISANCHOR'; edge: EdgeId; node: NodeId }
|
|
835
|
-
| { code: 'ROUTE_STALE_AFTER_NODE_MOVE'; edge: EdgeId; node: NodeId }
|
|
836
|
-
| { code: 'DUPLICATE_EDGE'; edge: EdgeId; duplicateOf: EdgeId; from: NodeId; to: NodeId; label?: string }
|
|
837
|
-
| { code: 'UNREACHABLE_NODE'; node: NodeId }
|
|
838
|
-
| { code: 'DECISION_BRANCH_UNLABELED'; node: NodeId; edge: EdgeId }
|
|
839
|
-
| { code: 'COMMENT_DROPPED'; count: number; lines: number[] }
|
|
840
|
-
| { code: 'UNSUPPORTED_SYNTAX'; line?: number; syntax: string; message: string }
|
|
841
|
-
/**
|
|
842
|
-
* Structured content was lost across a parse → serialize → re-parse cycle:
|
|
843
|
-
* the {nodes, edges, groups} tally changed, so canonical serialization is
|
|
844
|
-
* silently dropping (or duplicating) a node/edge/group even though the bytes
|
|
845
|
-
* may re-parse. The faithfulness analogue of COMMENT_DROPPED — "100% parse
|
|
846
|
-
* success is not faithfulness" (Loop 17). Lint, never flips verify.ok.
|
|
847
|
-
*/
|
|
848
|
-
| { code: 'CONTENT_DROPPED_ON_ROUNDTRIP'; before: { nodes: number; edges: number; groups: number }; after: { nodes: number; edges: number; groups: number } }
|
|
849
|
-
/**
|
|
850
|
-
* A Mermaid config field was accepted (for config-shape compatibility) but
|
|
851
|
-
* has no effect on this family's geometry or paint — e.g. Journey's
|
|
852
|
-
* sequence-era fields. Accepting-and-ignoring silently misleads migrating
|
|
853
|
-
* users; this lint says so. Never flips verify.ok.
|
|
854
|
-
*/
|
|
855
|
-
| { code: 'INEFFECTIVE_CONFIG'; field: string; message: string }
|
|
856
|
-
|
|
857
|
-
export const WARNING_SEVERITY: Record<WarningCode, WarningSeverity> = {
|
|
858
|
-
EMPTY_DIAGRAM: 'error',
|
|
859
|
-
UNRESOLVABLE_SCHEDULE: 'error',
|
|
860
|
-
RENDER_FAILED: 'error',
|
|
861
|
-
EDGE_MISANCHORED: 'error',
|
|
862
|
-
OFF_CANVAS: 'error',
|
|
863
|
-
GROUP_BREACH: 'error',
|
|
864
|
-
UNKNOWN_SHAPE: 'warning',
|
|
865
|
-
LABEL_OVERFLOW: 'warning',
|
|
866
|
-
NODE_OVERLAP: 'warning',
|
|
867
|
-
ROUTE_SELF_CROSS: 'warning',
|
|
868
|
-
ROUTE_HITCH: 'warning',
|
|
869
|
-
ROUTE_UNEXPLAINED_BEND: 'warning',
|
|
870
|
-
ROUTE_LABEL_ON_SHARED_TRUNK: 'warning',
|
|
871
|
-
ROUTE_CONTAINER_MISANCHOR: 'warning',
|
|
872
|
-
ROUTE_SHAPE_MISANCHOR: 'warning',
|
|
873
|
-
ROUTE_STALE_AFTER_NODE_MOVE: 'warning',
|
|
874
|
-
DUPLICATE_EDGE: 'warning',
|
|
875
|
-
UNREACHABLE_NODE: 'warning',
|
|
876
|
-
DECISION_BRANCH_UNLABELED: 'warning',
|
|
877
|
-
COMMENT_DROPPED: 'warning',
|
|
878
|
-
UNSUPPORTED_SYNTAX: 'warning',
|
|
879
|
-
CONTENT_DROPPED_ON_ROUNDTRIP: 'warning',
|
|
880
|
-
INEFFECTIVE_CONFIG: 'warning',
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
export const WARNING_TIER: Record<WarningCode, WarningTier> = {
|
|
884
|
-
EMPTY_DIAGRAM: 'structural',
|
|
885
|
-
UNRESOLVABLE_SCHEDULE: 'structural',
|
|
886
|
-
RENDER_FAILED: 'structural',
|
|
887
|
-
EDGE_MISANCHORED: 'structural',
|
|
888
|
-
OFF_CANVAS: 'structural',
|
|
889
|
-
GROUP_BREACH: 'structural',
|
|
890
|
-
UNKNOWN_SHAPE: 'structural',
|
|
891
|
-
LABEL_OVERFLOW: 'structural',
|
|
892
|
-
NODE_OVERLAP: 'geometric',
|
|
893
|
-
ROUTE_SELF_CROSS: 'geometric',
|
|
894
|
-
ROUTE_HITCH: 'geometric',
|
|
895
|
-
ROUTE_UNEXPLAINED_BEND: 'geometric',
|
|
896
|
-
ROUTE_LABEL_ON_SHARED_TRUNK: 'geometric',
|
|
897
|
-
ROUTE_CONTAINER_MISANCHOR: 'geometric',
|
|
898
|
-
ROUTE_SHAPE_MISANCHOR: 'geometric',
|
|
899
|
-
ROUTE_STALE_AFTER_NODE_MOVE: 'geometric',
|
|
900
|
-
DUPLICATE_EDGE: 'lint',
|
|
901
|
-
UNREACHABLE_NODE: 'lint',
|
|
902
|
-
DECISION_BRANCH_UNLABELED: 'lint',
|
|
903
|
-
COMMENT_DROPPED: 'lint',
|
|
904
|
-
UNSUPPORTED_SYNTAX: 'lint',
|
|
905
|
-
CONTENT_DROPPED_ON_ROUNDTRIP: 'lint',
|
|
906
|
-
INEFFECTIVE_CONFIG: 'lint',
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
export const DEFAULT_LABEL_CHAR_CAP = 40
|
|
910
|
-
|
|
911
|
-
export interface VerifyOptions {
|
|
912
|
-
suppress?: WarningCode[]
|
|
913
|
-
labelCharCap?: number
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
export type RenderedRegionKind = 'node' | 'edge' | 'label' | 'group' | 'canvas'
|
|
917
|
-
|
|
918
|
-
export interface RenderedRegion {
|
|
919
|
-
id: string
|
|
920
|
-
kind: RenderedRegionKind
|
|
921
|
-
elementId?: string
|
|
922
|
-
parentId?: string
|
|
923
|
-
bounds: { x: Finite; y: Finite; w: Finite; h: Finite }
|
|
924
|
-
sourceLine?: number
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
export interface RenderedLayoutNode {
|
|
928
|
-
id: NodeId; x: Finite; y: Finite; w: Finite; h: Finite; shape: string; label?: string
|
|
929
|
-
}
|
|
930
|
-
export interface RenderedLayoutEdge {
|
|
931
|
-
id: EdgeId; from: NodeId; to: NodeId; path: [Finite, Finite][]
|
|
932
|
-
label?: { x: Finite; y: Finite; text: string }
|
|
933
|
-
/** Edge route certificate; present only under layoutMermaid(d, { debug: true }) for families with an edge certificate model. */
|
|
934
|
-
route?: EdgeRouteCertificate
|
|
935
|
-
}
|
|
936
|
-
export interface RenderedLayoutGroup {
|
|
937
|
-
id: GroupId; x: Finite; y: Finite; w: Finite; h: Finite; members: NodeId[]; label?: string
|
|
938
|
-
/** Parent group id for flattened region-tree consumers; undefined means root-level group. */
|
|
939
|
-
parentId?: GroupId
|
|
940
|
-
}
|
|
941
|
-
export interface RenderedLayout {
|
|
942
|
-
version: 1
|
|
943
|
-
kind: DiagramKind
|
|
944
|
-
nodes: RenderedLayoutNode[]
|
|
945
|
-
edges: RenderedLayoutEdge[]
|
|
946
|
-
groups: RenderedLayoutGroup[]
|
|
947
|
-
/** Region-containment certificates for non-edge invariants; present only under layoutMermaid(d, { debug: true }). */
|
|
948
|
-
certificates?: RegionContainmentCertificate[]
|
|
949
|
-
/** Optional region sidecar for renderer/action alignment; debug-only in layoutMermaid V1. */
|
|
950
|
-
regions?: RenderedRegion[]
|
|
951
|
-
/** Optional source-only actions aligned to region ids; debug-only in layoutMermaid V1. */
|
|
952
|
-
actions?: DiagramActionRecord[]
|
|
953
|
-
bounds: { w: Finite; h: Finite }
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
export interface VerifyResult {
|
|
957
|
-
ok: boolean
|
|
958
|
-
warnings: LayoutWarning[]
|
|
959
|
-
layout: RenderedLayout
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
// ---- synthesizeFromGraph payload -----------------------------------------
|
|
963
|
-
|
|
964
|
-
export interface SerializedFlowchartGraph {
|
|
965
|
-
direction: import('../types.ts').Direction
|
|
966
|
-
nodes: Record<string, import('../types.ts').MermaidNode> | Array<[string, import('../types.ts').MermaidNode]>
|
|
967
|
-
edges?: import('../types.ts').MermaidEdge[]
|
|
968
|
-
// Loose by design: payloads built from the SDK-declared shape may omit
|
|
969
|
-
// `children`/`direction` on subgraphs, or styling maps entirely.
|
|
970
|
-
// synthesizeFromGraph normalizes all of these defensively.
|
|
971
|
-
subgraphs?: unknown
|
|
972
|
-
classDefs?: unknown
|
|
973
|
-
classAssignments?: unknown
|
|
974
|
-
nodeStyles?: unknown
|
|
975
|
-
linkStyles?: unknown
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
export interface ValidDiagramPayload {
|
|
979
|
-
kind: DiagramKind
|
|
980
|
-
meta?: Partial<ValidDiagramMeta>
|
|
981
|
-
body:
|
|
982
|
-
| { kind: 'flowchart'; graph: SerializedFlowchartGraph }
|
|
983
|
-
| StateBody
|
|
984
|
-
| SequenceBody
|
|
985
|
-
| TimelineBody
|
|
986
|
-
| ClassBody
|
|
987
|
-
| ErBody
|
|
988
|
-
| JourneyBody
|
|
989
|
-
| ArchitectureBody
|
|
990
|
-
| XyChartBody
|
|
991
|
-
| PieBody
|
|
992
|
-
| QuadrantBody
|
|
993
|
-
| GanttBody
|
|
994
|
-
| { kind: 'opaque'; family: DiagramKind; source: string }
|
|
995
|
-
}
|