@formicoidea/labre-framework-ddd-context-map 0.59.0 → 0.61.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/dist/actions.d.ts +8 -4
- package/dist/actions.js +13 -24
- package/dist/background.js +2 -2
- package/dist/commands.d.ts +2 -12
- package/dist/commands.js +5 -19
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/interchange-headless.d.ts +10 -0
- package/dist/interchange-headless.js +10 -0
- package/dist/roles.d.ts +1 -1
- package/dist/roles.js +1 -1
- package/dist/seeds.d.ts +16 -0
- package/dist/seeds.js +21 -0
- package/dist/toolbox.d.ts +37 -0
- package/dist/toolbox.js +125 -0
- package/package.json +7 -3
package/dist/actions.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { GfxController } from '@formicoidea/labre-core/std/gfx';
|
|
2
2
|
import { type ContextMapPatternKind } from './roles.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creation / activation actions for the Context Map toolbox — the BEHAVIOUR
|
|
5
|
+
* layer, depending on nothing but the {@link GfxController}.
|
|
6
|
+
*
|
|
7
|
+
* They emit no telemetry: since PF3 the single emission point is the command
|
|
8
|
+
* registry's `runCommand` (`docs/adr/0008`).
|
|
9
|
+
*/
|
|
3
10
|
/** Create the board at the viewport centre, select it, return to the default tool. */
|
|
4
11
|
export declare function createContextMapBoard(gfx: GfxController): void;
|
|
5
12
|
/**
|
|
@@ -32,7 +39,4 @@ export declare function createContextMapBoard(gfx: GfxController): void;
|
|
|
32
39
|
* `ConnectorToolOptions.label`, which was cut from v1 — the pattern reads from
|
|
33
40
|
* the hover reveal (M2) and the toolbar until it lands.
|
|
34
41
|
*/
|
|
35
|
-
export declare function activateContextMapRelationship(gfx: GfxController, kind: ContextMapPatternKind
|
|
36
|
-
upDown: boolean;
|
|
37
|
-
dashed: boolean;
|
|
38
|
-
}): void;
|
|
42
|
+
export declare function activateContextMapRelationship(gfx: GfxController, kind: ContextMapPatternKind): void;
|
package/dist/actions.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { backgroundSize, DefaultTool } from '@formicoidea/labre-core/blocks/surface';
|
|
2
2
|
import { ConnectorTool } from '@formicoidea/labre-core/gfx/connector';
|
|
3
|
-
import {
|
|
4
|
-
import { ConnectorMode, PointStyle, StrokeStyle } from '@formicoidea/labre-core/model';
|
|
5
|
-
import { Bound } from '@formicoidea/labre-core/global/gfx';
|
|
3
|
+
import { ConnectorMode } from '@formicoidea/labre-core/model';
|
|
6
4
|
import { CONTEXT_MAP_BACKGROUND } from './background.js';
|
|
7
5
|
import { CM_PATTERN_ROLE } from './roles.js';
|
|
6
|
+
import { contextMapBoardElement, contextMapRelationshipStyle } from './toolbox.js';
|
|
8
7
|
/**
|
|
9
8
|
* Creation / activation actions for the Context Map toolbox — the BEHAVIOUR
|
|
10
9
|
* layer, depending on nothing but the {@link GfxController}.
|
|
@@ -12,22 +11,19 @@ import { CM_PATTERN_ROLE } from './roles.js';
|
|
|
12
11
|
* They emit no telemetry: since PF3 the single emission point is the command
|
|
13
12
|
* registry's `runCommand` (`docs/adr/0008`).
|
|
14
13
|
*/
|
|
15
|
-
const RELATIONSHIP_STROKE_WIDTH = 2;
|
|
16
14
|
/** Create the board at the viewport centre, select it, return to the default tool. */
|
|
17
15
|
export function createContextMapBoard(gfx) {
|
|
18
16
|
if (!gfx.surface)
|
|
19
17
|
return;
|
|
20
18
|
const { width, height } = backgroundSize(CONTEXT_MAP_BACKGROUND);
|
|
21
19
|
const { centerX, centerY } = gfx.viewport;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
role: CONTEXT_MAP_BACKGROUND.role,
|
|
28
|
-
resizeEnabled: CONTEXT_MAP_BACKGROUND.geometry.resizable,
|
|
29
|
-
xywh: new Bound(centerX - width / 2, centerY - height / 2, width, height).serialize(),
|
|
20
|
+
// The board's props come from the toolbox (`docs/adr/0045`), the one
|
|
21
|
+
// assembly a host with no editor also calls; the viewport centre is ours.
|
|
22
|
+
const { id: _local, ...props } = contextMapBoardElement({
|
|
23
|
+
x: centerX - width / 2,
|
|
24
|
+
y: centerY - height / 2,
|
|
30
25
|
});
|
|
26
|
+
const id = gfx.surface.addElement(props);
|
|
31
27
|
gfx.doc.captureSync();
|
|
32
28
|
gfx.tool.setTool(DefaultTool);
|
|
33
29
|
gfx.selection.set({ elements: [id], editing: false });
|
|
@@ -62,22 +58,15 @@ export function createContextMapBoard(gfx) {
|
|
|
62
58
|
* `ConnectorToolOptions.label`, which was cut from v1 — the pattern reads from
|
|
63
59
|
* the hover reveal (M2) and the toolbar until it lands.
|
|
64
60
|
*/
|
|
65
|
-
export function activateContextMapRelationship(gfx, kind
|
|
61
|
+
export function activateContextMapRelationship(gfx, kind) {
|
|
66
62
|
gfx.tool.setTool(ConnectorTool, {
|
|
67
63
|
mode: ConnectorMode.Straight,
|
|
68
64
|
role: CM_PATTERN_ROLE[kind],
|
|
69
65
|
// The look rides on the activation, never through the last-props store:
|
|
70
|
-
// the plain connector tool must keep the user's own style (#144 M1).
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
strokeWidth: RELATIONSHIP_STROKE_WIDTH,
|
|
75
|
-
frontEndpointStyle: PointStyle.None,
|
|
76
|
-
// The arrow points at the DOWNSTREAM end, which is the target: the
|
|
77
|
-
// role's verb is "is upstream of", so the source is the upstream
|
|
78
|
-
// context.
|
|
79
|
-
rearEndpointStyle: style.upDown ? PointStyle.Arrow : PointStyle.None,
|
|
80
|
-
},
|
|
66
|
+
// the plain connector tool must keep the user's own style (#144 M1). It is
|
|
67
|
+
// the toolbox's (`contextMapRelationshipStyle`, `docs/adr/0045`), so a
|
|
68
|
+
// relationship drawn here and one built by a host look the same.
|
|
69
|
+
style: contextMapRelationshipStyle(kind),
|
|
81
70
|
});
|
|
82
71
|
// The Context Map palette stays open (native sub-menu behaviour): it only
|
|
83
72
|
// closes on re-click of the senior button, another senior tool, or Escape.
|
package/dist/background.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CLOUD, CM_BUBBLE, FONT_FAMILY } from '@formicoidea/labre-ddd-shared';
|
|
2
|
-
import { NOTATION_NEUTRALS } from '@formicoidea/labre-core/shared/
|
|
1
|
+
import { CLOUD, CM_BUBBLE, FONT_FAMILY, } from '@formicoidea/labre-ddd-shared/headless';
|
|
2
|
+
import { NOTATION_NEUTRALS } from '@formicoidea/labre-core/shared/headless';
|
|
3
3
|
import { CONTEXT_MAP_ROLE } from './roles.js';
|
|
4
4
|
/**
|
|
5
5
|
* The Context Map board, DECLARED (the `FrameworkBackgroundDef` primitive).
|
package/dist/commands.d.ts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { type ChromeWording } from '@formicoidea/labre-core/shared/services';
|
|
2
2
|
import type { CommandDescriptor } from '@formicoidea/labre-core/std';
|
|
3
3
|
import { type TemplateResult } from 'lit';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* default caption, and the general-purpose cloud's. The nine relationship
|
|
7
|
-
* patterns carry no seed of their own — since WS2 the palette ARMS the
|
|
8
|
-
* connector tool rather than dropping a labelled group, so no word is
|
|
9
|
-
* written into the document for them any more
|
|
10
|
-
* (`activateContextMapRelationship`). Declared here, beside the commands that
|
|
11
|
-
* write them, and imported by `translations.ts` — never the other way, which
|
|
12
|
-
* would cycle back into `contextMapCommands`.
|
|
13
|
-
*/
|
|
14
|
-
export declare const CONTEXT_MAP_SEED_BOUNDED_CONTEXT: ChromeWording;
|
|
15
|
-
export declare const CONTEXT_MAP_SEED_CLOUD: ChromeWording;
|
|
4
|
+
import { CONTEXT_MAP_SEED_BOUNDED_CONTEXT, CONTEXT_MAP_SEED_CLOUD } from './seeds.js';
|
|
5
|
+
export { CONTEXT_MAP_SEED_BOUNDED_CONTEXT, CONTEXT_MAP_SEED_CLOUD };
|
|
16
6
|
/**
|
|
17
7
|
* The automatic legend's own section titles — text stamped onto the board the
|
|
18
8
|
* moment the legend is built, like any other seed, and declared HERE because
|
package/dist/commands.js
CHANGED
|
@@ -5,24 +5,10 @@ import { GfxControllerIdentifier } from '@formicoidea/labre-core/std/gfx';
|
|
|
5
5
|
import { svg } from 'lit';
|
|
6
6
|
import { activateContextMapRelationship, createContextMapBoard, } from './actions.js';
|
|
7
7
|
import { CM_PATTERN_ROLE, CONTEXT_MAP_ROLE } from './roles.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* connector tool rather than dropping a labelled group, so no word is
|
|
13
|
-
* written into the document for them any more
|
|
14
|
-
* (`activateContextMapRelationship`). Declared here, beside the commands that
|
|
15
|
-
* write them, and imported by `translations.ts` — never the other way, which
|
|
16
|
-
* would cycle back into `contextMapCommands`.
|
|
17
|
-
*/
|
|
18
|
-
export const CONTEXT_MAP_SEED_BOUNDED_CONTEXT = [
|
|
19
|
-
'com.labre.ddd-context-map.seed.bounded-context',
|
|
20
|
-
'Bounded Context',
|
|
21
|
-
];
|
|
22
|
-
export const CONTEXT_MAP_SEED_CLOUD = [
|
|
23
|
-
'com.labre.ddd-context-map.seed.cloud',
|
|
24
|
-
'System',
|
|
25
|
-
];
|
|
8
|
+
import { CONTEXT_MAP_SEED_BOUNDED_CONTEXT, CONTEXT_MAP_SEED_CLOUD, } from './seeds.js';
|
|
9
|
+
// Declared in `seeds.ts` (editor-free, for the toolbox) and re-exported here,
|
|
10
|
+
// where `translations.ts` has always read them.
|
|
11
|
+
export { CONTEXT_MAP_SEED_BOUNDED_CONTEXT, CONTEXT_MAP_SEED_CLOUD };
|
|
26
12
|
/**
|
|
27
13
|
* The automatic legend's own section titles — text stamped onto the board the
|
|
28
14
|
* moment the legend is built, like any other seed, and declared HERE because
|
|
@@ -126,7 +112,7 @@ const SPECS = [
|
|
|
126
112
|
// user DRAWS the relation between two contexts. See
|
|
127
113
|
// `activateContextMapRelationship` for why the free-floating group had to
|
|
128
114
|
// go. The telemetry `element` value is untouched.
|
|
129
|
-
run: std => activateContextMapRelationship(std.get(GfxControllerIdentifier), preset.kind
|
|
115
|
+
run: std => activateContextMapRelationship(std.get(GfxControllerIdentifier), preset.kind),
|
|
130
116
|
// One row per PATTERN, not one for `context-map:relationship`: a legend
|
|
131
117
|
// that said "Relationship" would document nothing a reader could use. Both
|
|
132
118
|
// the row and the command come out of the same preset, so the dashed
|
package/dist/index.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export { contextMapSeniorTool } from './toolbar/senior-tool.js';
|
|
|
10
10
|
export { EdgelessDddContextMapSeniorButton } from './toolbar/senior-button.js';
|
|
11
11
|
export { DddContextMapRenderViewExtension, DddContextMapViewExtension, } from './view.js';
|
|
12
12
|
export { CONTEXT_MAP_READING } from './reading.js';
|
|
13
|
+
export { CONTEXT_MAP_TOOLBOX, contextMapBoardElement, contextMapContextElement, contextMapRelationshipElement, contextMapRelationshipStyle, contextMapSystemElements, } from './toolbox.js';
|
package/dist/index.js
CHANGED
|
@@ -10,3 +10,5 @@ export { contextMapSeniorTool } from './toolbar/senior-tool.js';
|
|
|
10
10
|
export { EdgelessDddContextMapSeniorButton } from './toolbar/senior-button.js';
|
|
11
11
|
export { DddContextMapRenderViewExtension, DddContextMapViewExtension, } from './view.js';
|
|
12
12
|
export { CONTEXT_MAP_READING } from './reading.js';
|
|
13
|
+
// The toolbar as pure builders (`docs/adr/0045`), also on `./interchange`.
|
|
14
|
+
export { CONTEXT_MAP_TOOLBOX, contextMapBoardElement, contextMapContextElement, contextMapRelationshipElement, contextMapRelationshipStyle, contextMapSystemElements, } from './toolbox.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `./interchange` — the Context Map with no editor behind it (ADR 0012, P3 as
|
|
3
|
+
* amended 2026-10-14): its toolbar as pure builders (`docs/adr/0045`), so a
|
|
4
|
+
* host with no editor (the Labre workspace connector, labre-mcp) places the
|
|
5
|
+
* very board, bounded contexts, clouds and relationships a user places from
|
|
6
|
+
* the toolbar. Held by `interchange-headless.unit.spec.ts` in
|
|
7
|
+
* `packages/affine/all`, which bundles this entry and fails on any editor
|
|
8
|
+
* module in its graph.
|
|
9
|
+
*/
|
|
10
|
+
export { CONTEXT_MAP_TOOLBOX, contextMapBoardElement, contextMapContextElement, contextMapRelationshipElement, contextMapRelationshipStyle, contextMapSystemElements, } from './toolbox.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `./interchange` — the Context Map with no editor behind it (ADR 0012, P3 as
|
|
3
|
+
* amended 2026-10-14): its toolbar as pure builders (`docs/adr/0045`), so a
|
|
4
|
+
* host with no editor (the Labre workspace connector, labre-mcp) places the
|
|
5
|
+
* very board, bounded contexts, clouds and relationships a user places from
|
|
6
|
+
* the toolbar. Held by `interchange-headless.unit.spec.ts` in
|
|
7
|
+
* `packages/affine/all`, which bundles this entry and fails on any editor
|
|
8
|
+
* module in its graph.
|
|
9
|
+
*/
|
|
10
|
+
export { CONTEXT_MAP_TOOLBOX, contextMapBoardElement, contextMapContextElement, contextMapRelationshipElement, contextMapRelationshipStyle, contextMapSystemElements, } from './toolbox.js';
|
package/dist/roles.d.ts
CHANGED
package/dist/roles.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CM_RELATIONSHIPS } from '@formicoidea/labre-ddd-shared';
|
|
1
|
+
import { CM_RELATIONSHIPS } from '@formicoidea/labre-ddd-shared/headless';
|
|
2
2
|
/**
|
|
3
3
|
* Role id per pattern kind, DERIVED from the shared preset table rather than
|
|
4
4
|
* restated: the kinds are camelCase (`sharedKernel`) and the role ids are
|
package/dist/seeds.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ChromeWording } from '@formicoidea/labre-core/shared/services';
|
|
2
|
+
/**
|
|
3
|
+
* The seeds baked into a placed artefact: the bounded-context bubble's
|
|
4
|
+
* default caption, and the general-purpose cloud's. The nine relationship
|
|
5
|
+
* patterns carry no seed of their own — since WS2 the palette ARMS the
|
|
6
|
+
* connector tool rather than dropping a labelled group, so no word is
|
|
7
|
+
* written into the document for them any more
|
|
8
|
+
* (`activateContextMapRelationship`).
|
|
9
|
+
*
|
|
10
|
+
* Their own module, editor-free, so the toolbox (`toolbox.ts`,
|
|
11
|
+
* `docs/adr/0045`) seeds a host's bubble and cloud with the same English
|
|
12
|
+
* words; `commands.ts` re-exports them unchanged and resolves them through the
|
|
13
|
+
* host's catalogue at placement (ADR 0023).
|
|
14
|
+
*/
|
|
15
|
+
export declare const CONTEXT_MAP_SEED_BOUNDED_CONTEXT: ChromeWording;
|
|
16
|
+
export declare const CONTEXT_MAP_SEED_CLOUD: ChromeWording;
|
package/dist/seeds.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seeds baked into a placed artefact: the bounded-context bubble's
|
|
3
|
+
* default caption, and the general-purpose cloud's. The nine relationship
|
|
4
|
+
* patterns carry no seed of their own — since WS2 the palette ARMS the
|
|
5
|
+
* connector tool rather than dropping a labelled group, so no word is
|
|
6
|
+
* written into the document for them any more
|
|
7
|
+
* (`activateContextMapRelationship`).
|
|
8
|
+
*
|
|
9
|
+
* Their own module, editor-free, so the toolbox (`toolbox.ts`,
|
|
10
|
+
* `docs/adr/0045`) seeds a host's bubble and cloud with the same English
|
|
11
|
+
* words; `commands.ts` re-exports them unchanged and resolves them through the
|
|
12
|
+
* host's catalogue at placement (ADR 0023).
|
|
13
|
+
*/
|
|
14
|
+
export const CONTEXT_MAP_SEED_BOUNDED_CONTEXT = [
|
|
15
|
+
'com.labre.ddd-context-map.seed.bounded-context',
|
|
16
|
+
'Bounded Context',
|
|
17
|
+
];
|
|
18
|
+
export const CONTEXT_MAP_SEED_CLOUD = [
|
|
19
|
+
'com.labre.ddd-context-map.seed.cloud',
|
|
20
|
+
'System',
|
|
21
|
+
];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type FrameworkToolbox, type SerializedElementProps, type ToolboxPoint } from '@formicoidea/labre-core/interchange';
|
|
2
|
+
import { PointStyle, StrokeStyle } from '@formicoidea/labre-core/model/headless';
|
|
3
|
+
import { type ContextMapPatternKind } from './roles.js';
|
|
4
|
+
/**
|
|
5
|
+
* How a pattern is drawn: presentation only, the meaning is the role. Dashed
|
|
6
|
+
* for the two "no real integration" patterns (Separate Ways, Big Ball of
|
|
7
|
+
* Mud), a rear arrowhead for the five upstream/downstream ones: the arrow
|
|
8
|
+
* points at the DOWNSTREAM end, which is the target, since the role's verb is
|
|
9
|
+
* "is upstream of".
|
|
10
|
+
*/
|
|
11
|
+
export declare function contextMapRelationshipStyle(kind: ContextMapPatternKind): {
|
|
12
|
+
stroke: string;
|
|
13
|
+
strokeStyle: StrokeStyle;
|
|
14
|
+
strokeWidth: number;
|
|
15
|
+
frontEndpointStyle: PointStyle;
|
|
16
|
+
rearEndpointStyle: PointStyle;
|
|
17
|
+
};
|
|
18
|
+
/** The board a context map is drawn on, at `at`. */
|
|
19
|
+
export declare function contextMapBoardElement(at: ToolboxPoint, local?: string): SerializedElementProps;
|
|
20
|
+
/**
|
|
21
|
+
* A bounded context at `at`, named `name` or the toolbar's English seed. The
|
|
22
|
+
* role is what makes the pill a bounded CONTEXT every rule reads.
|
|
23
|
+
*/
|
|
24
|
+
export declare function contextMapContextElement(at: ToolboxPoint, name?: string, local?: string): SerializedElementProps;
|
|
25
|
+
/**
|
|
26
|
+
* A cloud (an outside system, a Big Ball of Mud) at `at`: the polygon carrying
|
|
27
|
+
* `context-map:system`, its name and their group.
|
|
28
|
+
*/
|
|
29
|
+
export declare function contextMapSystemElements(at: ToolboxPoint, name?: string, local?: string): SerializedElementProps[];
|
|
30
|
+
/**
|
|
31
|
+
* A relationship of one pattern between two elements: the connector the
|
|
32
|
+
* pattern's palette entry arms the tool with. Its source is the upstream
|
|
33
|
+
* context for the five upstream/downstream patterns.
|
|
34
|
+
*/
|
|
35
|
+
export declare function contextMapRelationshipElement(kind: ContextMapPatternKind, from: string, to: string, label?: string): SerializedElementProps;
|
|
36
|
+
/** Every item of the Context Map toolbar, in the toolbar's order. */
|
|
37
|
+
export declare const CONTEXT_MAP_TOOLBOX: FrameworkToolbox;
|
package/dist/toolbox.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { backgroundSize, } from '@formicoidea/labre-core/interchange';
|
|
2
|
+
import { bubbleElement, CLOUD, CM_BUBBLE, CM_RELATIONSHIPS, cloudElements, LABEL_COLOR, } from '@formicoidea/labre-ddd-shared/headless';
|
|
3
|
+
import { ConnectorMode, PointStyle, StrokeStyle, } from '@formicoidea/labre-core/model/headless';
|
|
4
|
+
import { Bound } from '@formicoidea/labre-core/global/gfx';
|
|
5
|
+
import { CONTEXT_MAP_BACKGROUND } from './background.js';
|
|
6
|
+
import { contextMapCommandsManifest } from './commands-manifest.js';
|
|
7
|
+
import { CM_PATTERN_ROLE, CONTEXT_MAP_ROLE, } from './roles.js';
|
|
8
|
+
import { CONTEXT_MAP_SEED_BOUNDED_CONTEXT, CONTEXT_MAP_SEED_CLOUD, } from './seeds.js';
|
|
9
|
+
/**
|
|
10
|
+
* The Context Map toolbar as pure builders (`docs/adr/0045`): the board, the
|
|
11
|
+
* bounded context, the cloud and the nine relationship patterns, with no
|
|
12
|
+
* editor behind them. The bubble and the cloud are the very builders the
|
|
13
|
+
* palette's prefabs write (`@labre/affine-gfx-ddd-shared/headless`), and
|
|
14
|
+
* `createContextMapBoard` and `activateContextMapRelationship` read the board
|
|
15
|
+
* and the pattern style from here, so a context drawn by a host and one
|
|
16
|
+
* placed from the toolbar are the same element.
|
|
17
|
+
*/
|
|
18
|
+
/** Every relationship is drawn this wide, whatever its pattern. */
|
|
19
|
+
const RELATIONSHIP_STROKE_WIDTH = 2;
|
|
20
|
+
/**
|
|
21
|
+
* How a pattern is drawn: presentation only, the meaning is the role. Dashed
|
|
22
|
+
* for the two "no real integration" patterns (Separate Ways, Big Ball of
|
|
23
|
+
* Mud), a rear arrowhead for the five upstream/downstream ones: the arrow
|
|
24
|
+
* points at the DOWNSTREAM end, which is the target, since the role's verb is
|
|
25
|
+
* "is upstream of".
|
|
26
|
+
*/
|
|
27
|
+
export function contextMapRelationshipStyle(kind) {
|
|
28
|
+
const preset = CM_RELATIONSHIPS.find(p => p.kind === kind);
|
|
29
|
+
return {
|
|
30
|
+
stroke: LABEL_COLOR,
|
|
31
|
+
strokeStyle: preset?.dashed ? StrokeStyle.Dash : StrokeStyle.Solid,
|
|
32
|
+
strokeWidth: RELATIONSHIP_STROKE_WIDTH,
|
|
33
|
+
frontEndpointStyle: PointStyle.None,
|
|
34
|
+
rearEndpointStyle: preset?.upDown ? PointStyle.Arrow : PointStyle.None,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** The board a context map is drawn on, at `at`. */
|
|
38
|
+
export function contextMapBoardElement(at, local = 'board') {
|
|
39
|
+
const { width, height } = backgroundSize(CONTEXT_MAP_BACKGROUND);
|
|
40
|
+
return {
|
|
41
|
+
type: CONTEXT_MAP_BACKGROUND.type,
|
|
42
|
+
id: local,
|
|
43
|
+
// The board is a first-class role: rules frame contexts against
|
|
44
|
+
// `context-map:board`, never against the `contextMap` element type.
|
|
45
|
+
role: CONTEXT_MAP_BACKGROUND.role,
|
|
46
|
+
resizeEnabled: CONTEXT_MAP_BACKGROUND.geometry.resizable,
|
|
47
|
+
xywh: new Bound(at.x, at.y, width, height).serialize(),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A bounded context at `at`, named `name` or the toolbar's English seed. The
|
|
52
|
+
* role is what makes the pill a bounded CONTEXT every rule reads.
|
|
53
|
+
*/
|
|
54
|
+
export function contextMapContextElement(at, name, local = 'bounded-context') {
|
|
55
|
+
return bubbleElement(at, name?.trim() || CONTEXT_MAP_SEED_BOUNDED_CONTEXT[1], CONTEXT_MAP_ROLE.context, local);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A cloud (an outside system, a Big Ball of Mud) at `at`: the polygon carrying
|
|
59
|
+
* `context-map:system`, its name and their group.
|
|
60
|
+
*/
|
|
61
|
+
export function contextMapSystemElements(at, name, local = 'system') {
|
|
62
|
+
return cloudElements(at, name?.trim() || CONTEXT_MAP_SEED_CLOUD[1], CONTEXT_MAP_ROLE.system, local);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A relationship of one pattern between two elements: the connector the
|
|
66
|
+
* pattern's palette entry arms the tool with. Its source is the upstream
|
|
67
|
+
* context for the five upstream/downstream patterns.
|
|
68
|
+
*/
|
|
69
|
+
export function contextMapRelationshipElement(kind, from, to, label) {
|
|
70
|
+
return {
|
|
71
|
+
type: 'connector',
|
|
72
|
+
role: CM_PATTERN_ROLE[kind],
|
|
73
|
+
mode: ConnectorMode.Straight,
|
|
74
|
+
...contextMapRelationshipStyle(kind),
|
|
75
|
+
source: { id: from },
|
|
76
|
+
target: { id: to },
|
|
77
|
+
...(label?.trim() ? { text: label.trim() } : {}),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** The toolbar command's label, so a host names an item as the toolbar does. */
|
|
81
|
+
function label(command) {
|
|
82
|
+
const id = `ddd-context-map.${command}`;
|
|
83
|
+
const row = contextMapCommandsManifest.find(r => r.id === id);
|
|
84
|
+
return {
|
|
85
|
+
labelKey: row?.labelKey ?? id,
|
|
86
|
+
labelFallback: row?.labelFallback ?? id,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const kebab = (kind) => kind.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);
|
|
90
|
+
const relationship = (kind) => ({
|
|
91
|
+
id: kebab(kind),
|
|
92
|
+
...label(`add${kind[0]?.toUpperCase()}${kind.slice(1)}`),
|
|
93
|
+
build: (from, to, text) => contextMapRelationshipElement(kind, from, to, text),
|
|
94
|
+
});
|
|
95
|
+
const BOARD_SIZE = backgroundSize(CONTEXT_MAP_BACKGROUND);
|
|
96
|
+
/** Every item of the Context Map toolbar, in the toolbar's order. */
|
|
97
|
+
export const CONTEXT_MAP_TOOLBOX = {
|
|
98
|
+
framework: 'ddd-context-map',
|
|
99
|
+
items: [
|
|
100
|
+
{
|
|
101
|
+
id: 'board',
|
|
102
|
+
...label('addBoard'),
|
|
103
|
+
texts: [],
|
|
104
|
+
size: { w: BOARD_SIZE.width, h: BOARD_SIZE.height },
|
|
105
|
+
build: (at, _texts, local) => [contextMapBoardElement(at, local)],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: 'bounded-context',
|
|
109
|
+
...label('addBoundedContext'),
|
|
110
|
+
texts: ['name'],
|
|
111
|
+
size: { w: CM_BUBBLE.w, h: CM_BUBBLE.h },
|
|
112
|
+
build: (at, texts, local) => [
|
|
113
|
+
contextMapContextElement(at, texts?.name, local),
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: 'system',
|
|
118
|
+
...label('addCloud'),
|
|
119
|
+
texts: ['name'],
|
|
120
|
+
size: { w: CLOUD.w, h: CLOUD.h },
|
|
121
|
+
build: (at, texts, local) => contextMapSystemElements(at, texts?.name, local),
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
links: CM_RELATIONSHIPS.map(preset => relationship(preset.kind)),
|
|
125
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formicoidea/labre-framework-ddd-context-map",
|
|
3
3
|
"description": "Labre ddd-context-map framework for @formicoidea/labre-core.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.61.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "lajola",
|
|
@@ -25,14 +25,18 @@
|
|
|
25
25
|
"./commands-manifest": {
|
|
26
26
|
"types": "./dist/commands-manifest.d.ts",
|
|
27
27
|
"import": "./dist/commands-manifest.js"
|
|
28
|
+
},
|
|
29
|
+
"./interchange": {
|
|
30
|
+
"types": "./dist/interchange-headless.d.ts",
|
|
31
|
+
"import": "./dist/interchange-headless.js"
|
|
28
32
|
}
|
|
29
33
|
},
|
|
30
34
|
"files": [
|
|
31
35
|
"dist"
|
|
32
36
|
],
|
|
33
37
|
"dependencies": {
|
|
34
|
-
"@formicoidea/labre-core": "0.
|
|
35
|
-
"@formicoidea/labre-ddd-shared": "0.
|
|
38
|
+
"@formicoidea/labre-core": "0.61.0",
|
|
39
|
+
"@formicoidea/labre-ddd-shared": "0.61.0",
|
|
36
40
|
"lit": "^3.2.0"
|
|
37
41
|
}
|
|
38
42
|
}
|