-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(1624): first draft, prototype of context map grammar and diagram
- Loading branch information
Angelo Ceccato
authored and
Angelo Ceccato
committed
Mar 2, 2024
1 parent
2ac4e08
commit 70cd285
Showing
21 changed files
with
1,579 additions
and
1 deletion.
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.