-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(1624): first draft, prototype of context map grammar and diagram #5353
Draft
AngeloChecked
wants to merge
2
commits into
mermaid-js:develop
Choose a base branch
from
AngeloChecked:feature/1624_Context-Map-Diagram-Prototype
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<title>Context Map Language Quick Test Page</title> | ||
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" /> | ||
<style> | ||
div.mermaid { | ||
/* font-family: 'trebuchet ms', verdana, arial; */ | ||
font-family: 'Courier New', Courier, monospace !important; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>Context Map demo</h1> | ||
<pre class="mermaid"> | ||
ContextMap DDDSampleMap { | ||
contains CargoBookingContext | ||
contains VoyagePlanningContext | ||
contains LocationContext | ||
|
||
CargoBookingContext [SK]<->[SK] VoyagePlanningContext | ||
CargoBookingContext [D]<-[U,OHS,PL] LocationContext | ||
VoyagePlanningContext [D]<-[U,OHS,PL] LocationContext | ||
} | ||
</pre | ||
> | ||
|
||
<pre class="mermaid"> | ||
ContextMap InsuranceContextMap { | ||
contains CustomerManagementContext | ||
contains CustomerSelfServiceContext | ||
contains PrintingContext | ||
contains PolicyManagementContext | ||
contains RiskManagementContext | ||
contains DebtCollection | ||
|
||
CustomerSelfServiceContext [D,C]<-[U,S] CustomerManagementContext | ||
CustomerManagementContext [D,ACL]<-[U,OHS,PL] PrintingContext | ||
PrintingContext [U,OHS,PL]->[D,ACL] PolicyManagementContext | ||
RiskManagementContext [P]<->[P] PolicyManagementContext | ||
PolicyManagementContext [D,CF]<-[U,OHS,PL] CustomerManagementContext | ||
DebtCollection [D,ACL]<-[U,OHS,PL] PrintingContext | ||
PolicyManagementContext [SK]<->[SK] DebtCollection | ||
} | ||
|
||
|
||
</pre | ||
> | ||
|
||
<script type="module"> | ||
import mermaid from './mermaid.esm.mjs'; | ||
|
||
mermaid.parseError = function (err, hash) { | ||
// console.error('Mermaid error: ', err); | ||
}; | ||
mermaid.initialize({ | ||
theme: 'base', | ||
startOnLoad: true, | ||
logLevel: 0, | ||
useMaxWidth: false, | ||
}); | ||
function callback() { | ||
alert('It worked'); | ||
} | ||
mermaid.parseError = function (err, hash) { | ||
console.error('In parse error:'); | ||
console.error(err); | ||
}; | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/mermaid/src/diagrams/context-map/contextMap-definition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @ts-ignore: JISON doesn't support types | ||
import contextMapParser from './parser/contextMap.jison'; | ||
import * as contextMapDb from './contextMapDb.js'; | ||
import contextMapRenderer from './contextMapRenderer.js'; | ||
|
||
export const diagram = { | ||
db: contextMapDb, | ||
renderer: contextMapRenderer, | ||
parser: contextMapParser, | ||
styles: undefined, | ||
}; |
116 changes: 116 additions & 0 deletions
116
packages/mermaid/src/diagrams/context-map/contextMap.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { describe, test, expect } from 'vitest'; | ||
import type { Link, RawLink } from './contextMap.js'; | ||
import { mapEdgeLabels } from './contextMap.js'; | ||
|
||
describe('graph construction', () => { | ||
test.each([ | ||
{ | ||
rawLink: { | ||
source: { id: 'CargoBookingContext', type: ['SK'] }, | ||
target: { | ||
id: 'VoyagePlanningContextVoyagePlanningContextVoyagePlanningContext', | ||
type: ['SK'], | ||
}, | ||
arrow: ['left', 'right'], | ||
}, | ||
link: { | ||
source: { id: 'CargoBookingContext', boxText: undefined, bodyText: undefined }, | ||
target: { | ||
id: 'VoyagePlanningContextVoyagePlanningContextVoyagePlanningContext', | ||
boxText: undefined, | ||
bodyText: undefined, | ||
}, | ||
middleText: 'Shared Kernel', | ||
}, | ||
}, | ||
{ | ||
rawLink: { | ||
source: { id: 'CustomerSelfServiceContext', type: ['D', 'C'] }, | ||
target: { id: 'CustomerManagementContext', type: ['U', 'S'] }, | ||
arrow: ['right'], | ||
}, | ||
link: { | ||
source: { id: 'CustomerSelfServiceContext', boxText: 'D', bodyText: undefined }, | ||
target: { id: 'CustomerManagementContext', boxText: 'U', bodyText: undefined }, | ||
middleText: 'Customer/Supplier', | ||
}, | ||
}, | ||
{ | ||
rawLink: { | ||
source: { id: 'CustomerManagementContext', type: ['D', 'ACL'] }, | ||
target: { id: 'PrintingContext', type: ['U', 'OHS', 'PL'] }, | ||
arrow: ['right'], | ||
}, | ||
link: { | ||
source: { id: 'CustomerManagementContext', boxText: 'D', bodyText: 'ACL' }, | ||
target: { id: 'PrintingContext', boxText: 'U', bodyText: 'OHS, PL' }, | ||
middleText: undefined, | ||
}, | ||
}, | ||
{ | ||
rawLink: { | ||
source: { id: 'PrintingContext', type: ['U', 'OHS', 'PL'] }, | ||
target: { id: 'PolicyManagementContext', type: ['D', 'ACL'] }, | ||
arrow: ['right'], | ||
}, | ||
link: { | ||
source: { id: 'PrintingContext', boxText: 'U', bodyText: 'OHS, PL' }, | ||
target: { id: 'PolicyManagementContext', boxText: 'D', bodyText: 'ACL' }, | ||
middleText: undefined, | ||
}, | ||
}, | ||
{ | ||
rawLink: { | ||
source: { id: 'RiskManagementContext', type: ['P'] }, | ||
target: { id: 'PolicyManagementContext', type: ['P'] }, | ||
arrow: ['left', 'right'], | ||
}, | ||
link: { | ||
source: { id: 'RiskManagementContext', boxText: undefined, bodyText: undefined }, | ||
target: { id: 'PolicyManagementContext', boxText: undefined, bodyText: undefined }, | ||
middleText: 'Partnership', | ||
}, | ||
}, | ||
{ | ||
rawLink: { | ||
source: { id: 'PolicyManagementContext', type: ['D', 'CF'] }, | ||
target: { id: 'CustomerManagementContext', type: ['U', 'OHS', 'PL'] }, | ||
arrow: ['right'], | ||
}, | ||
link: { | ||
source: { id: 'PolicyManagementContext', boxText: 'D', bodyText: 'CF' }, | ||
target: { id: 'CustomerManagementContext', boxText: 'U', bodyText: 'OHS, PL' }, | ||
middleText: undefined, | ||
}, | ||
}, | ||
{ | ||
rawLink: { | ||
source: { id: 'DebtCollection', type: ['D', 'ACL'] }, | ||
target: { id: 'PrintingContext', type: ['U', 'OHS', 'PL'] }, | ||
arrow: ['right'], | ||
}, | ||
link: { | ||
source: { id: 'DebtCollection', boxText: 'D', bodyText: 'ACL' }, | ||
target: { id: 'PrintingContext', boxText: 'U', bodyText: 'OHS, PL' }, | ||
middleText: undefined, | ||
}, | ||
}, | ||
{ | ||
rawLink: { | ||
source: { id: 'CustomersBackofficeTeam', type: ['U', 'S'] }, | ||
target: { id: 'CustomersFrontofficeTeam', type: ['D', 'C'] }, | ||
arrow: ['right'], | ||
}, | ||
link: { | ||
source: { id: 'CustomersBackofficeTeam', boxText: 'U', bodyText: undefined }, | ||
target: { id: 'CustomersFrontofficeTeam', boxText: 'D', bodyText: undefined }, | ||
middleText: 'Customer/Supplier', | ||
}, | ||
}, | ||
] as { rawLink: RawLink; link: Link }[])( | ||
'map labels for source: $rawLink.source.type, and target: $rawLink.target.type', | ||
({ rawLink, link }: { rawLink: RawLink; link: Link }) => { | ||
expect(mapEdgeLabels(rawLink)).toStrictEqual(link); | ||
} | ||
); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why using
Mini
prefix since everywhere in the code it is simply ContextMap?Why using
Language
part as well?Keep it uniform