@miragon/team-topologies-schema-model 0.7.1 → 0.9.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/README.md CHANGED
@@ -25,7 +25,7 @@ npm install @miragon/team-topologies-schema-model
25
25
  - **The notation spec** — the four team types and three interaction modes, with their official
26
26
  shapes, colours and stroke styles as plain data you can read and render against.
27
27
  - **The document model** — a small, stable shape (`TtDocument`) with `version`, `title`, `nodes`,
28
- `interactions` and `flows`.
28
+ `interactions`, `flows` and `annotations`.
29
29
  - **Runtime validation** — Zod schemas + `parseDocument()` for everything that comes from a file, a
30
30
  URL or `localStorage`.
31
31
  - **Forward migrations** — `parseDocument()` migrates older documents up to the current version
@@ -42,14 +42,14 @@ relate to (spatial overlap, the Team Topologies convention) — there is no sour
42
42
 
43
43
  ```jsonc
44
44
  {
45
- "version": 2,
46
- "title": "Online retail — team topology",
45
+ "version": 3,
46
+ "title": "Online shop — team topology",
47
47
  "nodes": [
48
48
  {
49
49
  "id": "team_checkout",
50
50
  "type": "stream-aligned",
51
- "label": "Checkout Stream",
52
- "position": { "x": 320, "y": 110 },
51
+ "label": "Checkout & Payments",
52
+ "position": { "x": 560, "y": 202 },
53
53
  "size": { "width": 240, "height": 96 },
54
54
  },
55
55
  ],
@@ -57,21 +57,31 @@ relate to (spatial overlap, the Team Topologies convention) — there is no sour
57
57
  {
58
58
  "id": "int_platform_checkout",
59
59
  "mode": "x-as-a-service",
60
- "position": { "x": 384, "y": 396 },
61
- "size": { "width": 96, "height": 96 },
60
+ "position": { "x": 636, "y": 286 },
61
+ "size": { "width": 88, "height": 78 },
62
62
  },
63
63
  ],
64
64
  "flows": [],
65
+ "annotations": [
66
+ {
67
+ "id": "ann_checkout_split",
68
+ "text": "Splits into two stream-aligned teams in Q3",
69
+ "position": { "x": 560, "y": 110 },
70
+ "size": { "width": 200, "height": 64 },
71
+ "attachedTo": "team_checkout",
72
+ },
73
+ ],
65
74
  }
66
75
  ```
67
76
 
68
- | Field | Type | Notes |
69
- | -------------- | -------------------- | ------------------------------------------------------------------------------------ |
70
- | `version` | `2` | `DOCUMENT_VERSION`; older versions are migrated up on parse. |
71
- | `title` | `string` | Diagram name. |
72
- | `nodes` | `TeamNode[]` | A team: `type`, `label`, `position`, `size`, optional `description`/`fill`/`stroke`. |
73
- | `interactions` | `InteractionShape[]` | A placed interaction: `mode`, `position`, `size`, optional `label`/`fill`/`stroke`. |
74
- | `flows` | `FlowShape[]` | A flow-of-change band: `position`, `size`, optional `label`. |
77
+ | Field | Type | Notes |
78
+ | -------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
79
+ | `version` | `3` | `DOCUMENT_VERSION`; older versions are migrated up on parse. |
80
+ | `title` | `string` | Diagram name. |
81
+ | `nodes` | `TeamNode[]` | A team: `type`, `label`, `position`, `size`, optional `description`/`fill`/`stroke`. |
82
+ | `interactions` | `InteractionShape[]` | A placed interaction: `mode`, `position`, `size`, optional `label`/`fill`/`stroke`. |
83
+ | `flows` | `FlowShape[]` | A flow-of-change band: `position`, `size`, optional `label`. |
84
+ | `annotations` | `TextAnnotation[]` | A free-text note: `text`, `position`, `size`, optional `attachedTo` (a team/interaction/flow id). Left out of the JSON when empty. |
75
85
 
76
86
  ## Notation
77
87
 
@@ -98,7 +108,9 @@ printing. Team shapes are **solid** (long-lived); interaction shapes are **dashe
98
108
  | `x-as-a-service` | X-as-a-Service | triangle (points provider → consumer) | `#B4B4B4` / `#999696` |
99
109
  | `facilitating` | Facilitating | circle | `#C9DFBE` / `#78996B` |
100
110
 
101
- The **flow of change** is described separately by `FLOW_SPEC` (a left-to-right dashed band).
111
+ The **flow of change** is described separately by `FLOW_SPEC` (a left-to-right dashed band), and
112
+ text annotations by `ANNOTATION_SPEC` (default and minimum size — they are not part of the official
113
+ notation, so they carry no notation colours).
102
114
 
103
115
  ## Usage
104
116
 
@@ -113,9 +125,9 @@ import {
113
125
  } from "@miragon/team-topologies-schema-model";
114
126
 
115
127
  // Build a document with the factories (notation defaults applied automatically)
116
- const doc = emptyDocument("Online retail");
117
- doc.nodes.push(createTeamNode("stream-aligned", { x: 320, y: 110 }));
118
- doc.interactions.push(createInteractionShape("x-as-a-service", { x: 384, y: 396 }));
128
+ const doc = emptyDocument("Online shop");
129
+ doc.nodes.push(createTeamNode("stream-aligned", { x: 560, y: 202 }));
130
+ doc.interactions.push(createInteractionShape("x-as-a-service", { x: 636, y: 286 }));
119
131
 
120
132
  // Serialize deterministically (sorted, rounded, version-stamped) — diff- and URL-stable
121
133
  const json = serializeDocument(doc);
@@ -134,17 +146,17 @@ console.log(SAMPLE_DOCUMENT.title);
134
146
 
135
147
  ### API surface
136
148
 
137
- | Export | Purpose |
138
- | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
139
- | `TtDocument`, `TeamNode`, `InteractionShape`, `FlowShape`, `Position`, `Size` | The document model types. |
140
- | `TeamType`, `InteractionMode`, `TEAM_TYPES`, `INTERACTION_MODES` | The notation's discriminator unions + their value lists. |
141
- | `TEAM_TYPE_SPECS`, `INTERACTION_MODE_SPECS`, `FLOW_SPEC`, `dashArray()` | The visual notation spec (shapes, colours, strokes) as data. |
142
- | `documentSchema`, `teamNodeSchema`, `interactionSchema`, `flowSchema` | Zod schemas for each shape. |
143
- | `parseDocument()`, `ParseResult` | Validate **and migrate** unknown input into a `TtDocument`. |
144
- | `serializeDocument()`, `canonicalize()` | Deterministic JSON serialization (sorted, rounded, fixed key order). |
145
- | `emptyDocument()`, `createTeamNode()`, `createInteractionShape()`, `createFlowShape()`, `newId()` | Factories with notation defaults + id generation. |
146
- | `SAMPLE_DOCUMENT` | A complete example topology. |
147
- | `DOCUMENT_VERSION` | The current document version (`2`). |
149
+ | Export | Purpose |
150
+ | --------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
151
+ | `TtDocument`, `TeamNode`, `InteractionShape`, `FlowShape`, `TextAnnotation`, `Position`, `Size` | The document model types. |
152
+ | `TeamType`, `InteractionMode`, `TEAM_TYPES`, `INTERACTION_MODES` | The notation's discriminator unions + their value lists. |
153
+ | `TEAM_TYPE_SPECS`, `INTERACTION_MODE_SPECS`, `FLOW_SPEC`, `ANNOTATION_SPEC`, `dashArray()` | The visual notation spec (shapes, colours, strokes) as data. |
154
+ | `documentSchema`, `teamNodeSchema`, `interactionSchema`, `flowSchema`, `annotationSchema` | Zod schemas for each shape. |
155
+ | `parseDocument()`, `ParseResult` | Validate **and migrate** unknown input into a `TtDocument`. |
156
+ | `serializeDocument()`, `canonicalize()` | Deterministic JSON serialization (sorted, rounded, fixed key order). |
157
+ | `emptyDocument()`, `createTeamNode()`, `createInteractionShape()`, `createFlowShape()`, `createTextAnnotation()`, `newId()` | Factories with notation defaults + id generation. |
158
+ | `SAMPLE_DOCUMENT` | A complete example topology. |
159
+ | `DOCUMENT_VERSION` | The current document version (`3`). |
148
160
 
149
161
  ## Determinism & migrations
150
162
 
@@ -154,7 +166,9 @@ console.log(SAMPLE_DOCUMENT.title);
154
166
  what makes Git diffs small and share URLs stable.
155
167
  - **Migrations** — `parseDocument()` upgrades older documents before validating (keyed by `version`).
156
168
  The `1 → 2` step drops the legacy `showFlowOfChange` flag and the old edge-based interactions,
157
- keeping only interactions that carry geometry (the placed-shape model).
169
+ keeping only interactions that carry geometry (the placed-shape model). The `2 → 3` step adds an
170
+ empty `annotations` list — and because an empty list is not written back, re-saving a v2 file
171
+ changes nothing but its `version`.
158
172
 
159
173
  ## Development
160
174
 
package/dist/index.cjs CHANGED
@@ -16,7 +16,7 @@ var INTERACTION_MODES = [
16
16
  "x-as-a-service",
17
17
  "facilitating"
18
18
  ];
19
- var DOCUMENT_VERSION = 2;
19
+ var DOCUMENT_VERSION = 3;
20
20
 
21
21
  // src/notation.ts
22
22
  var TEAM_TYPE_SPECS = {
@@ -122,6 +122,11 @@ var FLOW_SPEC = {
122
122
  defaultSize: { width: 520, height: 64 },
123
123
  minSize: { width: 160, height: 36 }
124
124
  };
125
+ var ANNOTATION_SPEC = {
126
+ label: "Annotation",
127
+ defaultSize: { width: 200, height: 64 },
128
+ minSize: { width: 60, height: 30 }
129
+ };
125
130
  function dashArray(style, strokeWidth = 2) {
126
131
  switch (style) {
127
132
  case "dashed":
@@ -171,12 +176,20 @@ var flowSchema = zod.z.object({
171
176
  position: positionSchema,
172
177
  size: sizeSchema
173
178
  });
179
+ var annotationSchema = zod.z.object({
180
+ id: zod.z.string().min(1),
181
+ text: zod.z.string(),
182
+ position: positionSchema,
183
+ size: sizeSchema,
184
+ attachedTo: zod.z.string().min(1).optional()
185
+ });
174
186
  var documentSchema = zod.z.object({
175
187
  version: zod.z.literal(DOCUMENT_VERSION),
176
188
  title: zod.z.string(),
177
189
  nodes: zod.z.array(teamNodeSchema),
178
190
  interactions: zod.z.array(interactionSchema),
179
- flows: zod.z.array(flowSchema)
191
+ flows: zod.z.array(flowSchema),
192
+ annotations: zod.z.array(annotationSchema)
180
193
  });
181
194
  function parseDocument(input) {
182
195
  const migrated = migrate(input);
@@ -201,6 +214,7 @@ function migrate(input) {
201
214
  (e) => e != null && typeof e === "object" && "position" in e && "size" in e
202
215
  ) : [];
203
216
  if (!Array.isArray(next.flows)) next.flows = [];
217
+ if (!Array.isArray(next.annotations)) next.annotations = [];
204
218
  return next;
205
219
  }
206
220
 
@@ -248,6 +262,16 @@ function normFlow(f) {
248
262
  if (f.label) out.label = f.label;
249
263
  return out;
250
264
  }
265
+ function normAnnotation(a) {
266
+ const out = {
267
+ id: a.id,
268
+ text: a.text,
269
+ position: normPosition(a.position),
270
+ size: normSize(a.size)
271
+ };
272
+ if (a.attachedTo) out.attachedTo = a.attachedTo;
273
+ return out;
274
+ }
251
275
  var byId = (a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
252
276
  function canonicalize(doc) {
253
277
  return {
@@ -255,12 +279,14 @@ function canonicalize(doc) {
255
279
  title: doc.title,
256
280
  nodes: [...doc.nodes].map(normNode).sort(byId),
257
281
  interactions: [...doc.interactions].map(normInteraction).sort(byId),
258
- flows: [...doc.flows].map(normFlow).sort(byId)
282
+ flows: [...doc.flows].map(normFlow).sort(byId),
283
+ annotations: [...doc.annotations].map(normAnnotation).sort(byId)
259
284
  };
260
285
  }
261
286
  function serializeDocument(doc, pretty = true) {
262
- const canonical = canonicalize(doc);
263
- return JSON.stringify(canonical, null, pretty ? 2 : 0);
287
+ const { annotations, ...canonical } = canonicalize(doc);
288
+ const output = annotations.length > 0 ? { ...canonical, annotations } : canonical;
289
+ return JSON.stringify(output, null, pretty ? 2 : 0);
264
290
  }
265
291
  function newId(prefix) {
266
292
  return `${prefix}_${nanoid.nanoid(8)}`;
@@ -298,13 +324,23 @@ function createFlowShape(position, overrides = {}) {
298
324
  label: overrides.label ?? FLOW_SPEC.label
299
325
  };
300
326
  }
327
+ function createTextAnnotation(position, overrides = {}) {
328
+ return {
329
+ id: newId("ann"),
330
+ text: overrides.text ?? "",
331
+ position,
332
+ size: overrides.size ?? { ...ANNOTATION_SPEC.defaultSize },
333
+ attachedTo: overrides.attachedTo
334
+ };
335
+ }
301
336
  function emptyDocument(title = "Untitled team topology") {
302
337
  return {
303
338
  version: DOCUMENT_VERSION,
304
339
  title,
305
340
  nodes: [],
306
341
  interactions: [],
307
- flows: []
342
+ flows: [],
343
+ annotations: []
308
344
  };
309
345
  }
310
346
 
@@ -313,81 +349,73 @@ var s = TEAM_TYPE_SPECS;
313
349
  var i = INTERACTION_MODE_SPECS;
314
350
  var SAMPLE_DOCUMENT = {
315
351
  version: DOCUMENT_VERSION,
316
- title: "Online retail \u2014 team topology",
352
+ title: "Online shop \u2014 team topology",
317
353
  nodes: [
318
354
  {
319
- id: "team_enabling",
355
+ id: "team_test_automation",
320
356
  type: "enabling",
321
- label: "Agile Enablement",
322
- description: "Coaches teams on testing and continuous delivery practices.",
357
+ label: "Test Automation",
358
+ description: "Coaches stream-aligned teams in test automation, then steps back.",
323
359
  position: { x: 60, y: 150 },
324
360
  size: { ...s.enabling.defaultSize }
325
361
  },
326
362
  {
327
- id: "team_checkout",
363
+ id: "team_discovery",
328
364
  type: "stream-aligned",
329
- label: "Checkout Stream",
330
- description: "Owns the end-to-end checkout & payments journey.",
331
- position: { x: 320, y: 110 },
365
+ label: "Product Discovery",
366
+ description: "Owns search, browsing and product pages end-to-end.",
367
+ position: { x: 240, y: 202 },
332
368
  size: { ...s["stream-aligned"].defaultSize }
333
369
  },
334
370
  {
335
- id: "team_mobile",
371
+ id: "team_checkout",
336
372
  type: "stream-aligned",
337
- label: "Mobile Experience",
338
- description: "Owns the native mobile shopping experience.",
339
- position: { x: 700, y: 110 },
373
+ label: "Checkout & Payments",
374
+ description: "Owns the checkout and payment journey end-to-end.",
375
+ position: { x: 560, y: 202 },
340
376
  size: { ...s["stream-aligned"].defaultSize }
341
377
  },
342
378
  {
343
379
  id: "team_fraud",
344
380
  type: "complicated-subsystem",
345
- label: "Risk & Fraud Engine",
346
- description: "Specialist ML team owning real-time fraud scoring.",
347
- position: { x: 740, y: 320 },
381
+ label: "Fraud Detection",
382
+ description: "Specialists for the real-time fraud scoring model.",
383
+ position: { x: 870, y: 175 },
348
384
  size: { ...s["complicated-subsystem"].defaultSize }
349
385
  },
350
386
  {
351
387
  id: "team_platform",
352
388
  type: "platform",
353
- label: "Internal Developer Platform",
354
- description: "Self-service CI/CD, observability and runtime for all streams.",
355
- position: { x: 300, y: 540 },
356
- size: { ...s.platform.defaultSize }
389
+ label: "Cloud Platform",
390
+ description: "Self-service CI/CD, runtime and observability for all teams.",
391
+ position: { x: 240, y: 352 },
392
+ size: { width: 560, height: 110 }
357
393
  }
358
394
  ],
359
395
  interactions: [
360
396
  {
361
- id: "int_enable_checkout",
397
+ id: "int_testing_discovery",
362
398
  mode: "facilitating",
363
- label: "test automation",
364
- position: { x: 212, y: 158 },
399
+ position: { x: 168, y: 208 },
365
400
  size: { ...i.facilitating.defaultSize }
366
401
  },
367
402
  {
368
403
  id: "int_checkout_fraud",
369
404
  mode: "collaboration",
370
- label: "fraud rules discovery",
371
- position: { x: 566, y: 232 },
405
+ label: "fraud rules",
406
+ position: { x: 779, y: 214 },
372
407
  size: { ...i.collaboration.defaultSize }
373
408
  },
374
409
  {
375
- id: "int_platform_checkout",
376
- mode: "x-as-a-service",
377
- position: { x: 384, y: 396 },
378
- size: { ...i["x-as-a-service"].defaultSize }
379
- },
380
- {
381
- id: "int_platform_mobile",
410
+ id: "int_platform_discovery",
382
411
  mode: "x-as-a-service",
383
- position: { x: 612, y: 396 },
412
+ position: { x: 316, y: 286 },
384
413
  size: { ...i["x-as-a-service"].defaultSize }
385
414
  },
386
415
  {
387
- id: "int_fraud_mobile",
416
+ id: "int_platform_checkout",
388
417
  mode: "x-as-a-service",
389
- label: "risk scoring API",
390
- position: { x: 800, y: 238 },
418
+ position: { x: 636, y: 286 },
391
419
  size: { ...i["x-as-a-service"].defaultSize }
392
420
  }
393
421
  ],
@@ -395,14 +423,24 @@ var SAMPLE_DOCUMENT = {
395
423
  {
396
424
  id: "flow_main",
397
425
  label: "Flow of change",
398
- position: { x: 60, y: 712 },
399
- size: { width: 880, height: 60 }
426
+ position: { x: 60, y: 60 },
427
+ size: { width: 980, height: 56 }
428
+ }
429
+ ],
430
+ annotations: [
431
+ {
432
+ id: "ann_fraud_handover",
433
+ text: "Collaboration until the fraud rules are stable (Q3), then X-as-a-Service",
434
+ position: { x: 830, y: 350 },
435
+ size: { ...ANNOTATION_SPEC.defaultSize },
436
+ attachedTo: "int_checkout_fraud"
400
437
  }
401
438
  ]
402
439
  };
403
440
 
404
441
  exports.ALL_INTERACTION_SPECS = ALL_INTERACTION_SPECS;
405
442
  exports.ALL_TEAM_SPECS = ALL_TEAM_SPECS;
443
+ exports.ANNOTATION_SPEC = ANNOTATION_SPEC;
406
444
  exports.DND_MIME = DND_MIME;
407
445
  exports.DOCUMENT_VERSION = DOCUMENT_VERSION;
408
446
  exports.FLOW_SPEC = FLOW_SPEC;
@@ -411,10 +449,12 @@ exports.INTERACTION_MODE_SPECS = INTERACTION_MODE_SPECS;
411
449
  exports.SAMPLE_DOCUMENT = SAMPLE_DOCUMENT;
412
450
  exports.TEAM_TYPES = TEAM_TYPES;
413
451
  exports.TEAM_TYPE_SPECS = TEAM_TYPE_SPECS;
452
+ exports.annotationSchema = annotationSchema;
414
453
  exports.canonicalize = canonicalize;
415
454
  exports.createFlowShape = createFlowShape;
416
455
  exports.createInteractionShape = createInteractionShape;
417
456
  exports.createTeamNode = createTeamNode;
457
+ exports.createTextAnnotation = createTextAnnotation;
418
458
  exports.dashArray = dashArray;
419
459
  exports.documentSchema = documentSchema;
420
460
  exports.emptyDocument = emptyDocument;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts","../src/notation.ts","../src/schema.ts","../src/serialize.ts","../src/factory.ts","../src/sample.ts"],"names":["z","i","s","nanoid"],"mappings":";;;;;;AASO,IAAM,QAAA,GAAW;AAKjB,IAAM,UAAA,GAAkC;AAAA,EAC7C,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACF;AAKO,IAAM,iBAAA,GAAgD;AAAA,EAC3D,eAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF;AAyDO,IAAM,gBAAA,GAAmB;;;ACdzB,IAAM,eAAA,GAAkD;AAAA,EAC7D,gBAAA,EAAkB;AAAA,IAChB,IAAA,EAAM,gBAAA;AAAA,IACN,KAAA,EAAO,gBAAA;AAAA,IACP,WAAA,EAAa,mEAAA;AAAA,IACb,KAAA,EAAO,yBAAA;AAAA,IACP,IAAA,EAAM,SAAA;AAAA,IACN,MAAA,EAAQ,SAAA;AAAA,IACR,WAAA,EAAa,OAAA;AAAA,IACb,WAAA,EAAa,CAAA;AAAA,IACb,WAAA,EAAa,EAAE,KAAA,EAAO,GAAA,EAAK,QAAQ,EAAA,EAAG;AAAA,IACtC,OAAA,EAAS,EAAE,KAAA,EAAO,GAAA,EAAK,QAAQ,EAAA;AAAG,GACpC;AAAA,EACA,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,UAAA;AA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B,EAAE,WAAA;AAAY,KAC7C;AAAA,IACA;AAAA,MACE,EAAA,EAAI,kBAAA;AAAA,MACJ,IAAA,EAAM,gBAAA;AAAA,MACN,KAAA,EAAO,kBAAA;AAAA,MACP,QAAA,EAAU,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAI;AAAA,MAC3B,MAAM,EAAE,GAAG,CAAA,CAAE,gBAAgB,EAAE,WAAA;AAAY;AAC7C,GACF;AAAA,EACA,KAAA,EAAO;AAAA,IACL;AAAA,MACE,EAAA,EAAI,WAAA;AAAA,MACJ,KAAA,EAAO,gBAAA;AAAA,MACP,QAAA,EAAU,EAAE,CAAA,EAAG,EAAA,EAAI,GAAG,GAAA,EAAI;AAAA,MAC1B,IAAA,EAAM,EAAE,KAAA,EAAO,GAAA,EAAK,QAAQ,EAAA;AAAG;AACjC;AAEJ","file":"index.cjs","sourcesContent":["/**\n * Pure (DOM-free) domain types for the Team Topologies model.\n *\n * This module is the canonical representation of a diagram and must never\n * import from the rendering layer (`@xyflow/react`) or touch the DOM, so it\n * can be unit-tested in isolation and reused across views / exporters.\n */\n\n/** MIME type used when dragging a team type from the palette onto the canvas. */\nexport const DND_MIME = \"application/x-tt-team-type\";\n\n/** The four fundamental team types in Team Topologies. */\nexport type TeamType = \"stream-aligned\" | \"enabling\" | \"complicated-subsystem\" | \"platform\";\n\nexport const TEAM_TYPES: readonly TeamType[] = [\n \"stream-aligned\",\n \"enabling\",\n \"complicated-subsystem\",\n \"platform\",\n] as const;\n\n/** The three core team interaction modes in Team Topologies. */\nexport type InteractionMode = \"collaboration\" | \"x-as-a-service\" | \"facilitating\";\n\nexport const INTERACTION_MODES: readonly InteractionMode[] = [\n \"collaboration\",\n \"x-as-a-service\",\n \"facilitating\",\n] as const;\n\n/** Geometric size of a node in canvas units (px). Encodes cognitive load. */\nexport interface Size {\n width: number;\n height: number;\n}\n\n/** Position of a node on the canvas in canvas units (px). */\nexport interface Position {\n x: number;\n y: number;\n}\n\n/** A team node in the canonical document model. */\nexport interface TeamNode {\n id: string;\n type: TeamType;\n label: string;\n description?: string;\n position: Position;\n size: Size;\n fill?: string;\n stroke?: string;\n}\n\n/**\n * An interaction in the canonical document model.\n *\n * Per the official Team Topologies notation, an interaction is a placed,\n * resizable SHAPE (parallelogram / triangle / circle) overlaid on the boundary\n * between the teams it relates to — not a connecting line. The relationship is\n * therefore spatial (overlap), so there is no source/target reference.\n */\nexport interface InteractionShape {\n id: string;\n mode: InteractionMode;\n label?: string;\n position: Position;\n size: Size;\n fill?: string;\n stroke?: string;\n}\n\n/**\n * A \"flow of change\" guide: a placed, resizable arrow element. Lets you anchor\n * the implied left-to-right flow, and visualise several team groupings on one\n * canvas.\n */\nexport interface FlowShape {\n id: string;\n label?: string;\n position: Position;\n size: Size;\n}\n\n/** Current document schema version. Bump + add a migration when shape changes. */\nexport const DOCUMENT_VERSION = 2 as const;\n\n/**\n * A complete Team Topologies diagram. This is what gets serialised to JSON,\n * embedded into exported images, and encoded into share URLs.\n */\nexport interface TtDocument {\n version: typeof DOCUMENT_VERSION;\n title: string;\n nodes: TeamNode[];\n interactions: InteractionShape[];\n flows: FlowShape[];\n}\n","/**\n * The Team Topologies visual notation, encoded as data.\n *\n * Colours, shapes and stroke styles follow the official\n * \"Team-Shape-Templates\" specification published by Team Topologies\n * (https://github.com/TeamTopologies/Team-Shape-Templates):\n *\n * - Team shapes are SOLID outlines (long-lived structures).\n * - Interaction-mode shapes are 50% transparent with DASHED outlines\n * (short-lived interactions).\n * - Each element is distinguished by SHAPE as well as colour, so the\n * notation stays readable for people with colour-vision deficiency.\n *\n * This module is pure data — it must not import the rendering layer.\n */\n\nimport type { InteractionMode, Size, TeamType } from \"./types\";\n\nexport type TeamShape = \"rounded-rect-horizontal\" | \"rounded-rect-vertical\" | \"octagon\" | \"rect\";\n\nexport type InteractionGlyph = \"parallelogram\" | \"triangle\" | \"circle\";\n\nexport type StrokeStyle = \"solid\" | \"dashed\" | \"dotted\";\n\nexport interface TeamTypeSpec {\n type: TeamType;\n /** Short display name. */\n label: string;\n /** One-line purpose, shown in the palette and inspector. */\n description: string;\n shape: TeamShape;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n /** Default size when a node of this type is created. */\n defaultSize: Size;\n /** Minimum size enforced by the resizer. */\n minSize: Size;\n}\n\nexport interface InteractionModeSpec {\n mode: InteractionMode;\n label: string;\n description: string;\n shape: InteractionGlyph;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n /** Opacity for the interaction shape (short-lived → translucent). */\n opacity: number;\n /** Whether direction is semantically meaningful (the X-as-a-Service triangle). */\n directional: boolean;\n /** Default size when a shape of this mode is created. */\n defaultSize: Size;\n /** Minimum size enforced by the resizer. */\n minSize: Size;\n}\n\n/** The left-to-right \"flow of change\" guide, a placeable annotation element. */\nexport interface FlowSpec {\n label: string;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n defaultSize: Size;\n minSize: Size;\n}\n\nexport const TEAM_TYPE_SPECS: Record<TeamType, TeamTypeSpec> = {\n \"stream-aligned\": {\n type: \"stream-aligned\",\n label: \"Stream-aligned\",\n description: \"Aligned to a single, valuable stream of work; owns it end-to-end.\",\n shape: \"rounded-rect-horizontal\",\n fill: \"#FFEDB8\",\n stroke: \"#FFD966\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 240, height: 96 },\n minSize: { width: 140, height: 64 },\n },\n enabling: {\n type: \"enabling\",\n label: \"Enabling\",\n description:\n \"Helps stream-aligned teams acquire missing capabilities; coaches, then steps back.\",\n shape: \"rounded-rect-vertical\",\n fill: \"#DFBDCF\",\n stroke: \"#D09CB7\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 120, height: 200 },\n minSize: { width: 80, height: 120 },\n },\n \"complicated-subsystem\": {\n type: \"complicated-subsystem\",\n label: \"Complicated Subsystem\",\n description:\n \"Owns a part of the system needing deep specialist knowledge, reducing others' cognitive load.\",\n shape: \"octagon\",\n fill: \"#FFC08B\",\n stroke: \"#E88814\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 170, height: 150 },\n minSize: { width: 110, height: 100 },\n },\n platform: {\n type: \"platform\",\n label: \"Platform\",\n description:\n \"Provides internal self-service capabilities to reduce cognitive load for stream-aligned teams.\",\n shape: \"rect\",\n fill: \"#B7CDF1\",\n stroke: \"#6D9EEB\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 380, height: 130 },\n minSize: { width: 200, height: 90 },\n },\n};\n\nexport const INTERACTION_MODE_SPECS: Record<InteractionMode, InteractionModeSpec> = {\n collaboration: {\n mode: \"collaboration\",\n label: \"Collaboration\",\n description:\n \"Two teams work closely together for a defined period; high overhead, high discovery.\",\n shape: \"parallelogram\",\n fill: \"#C6BEDF\",\n stroke: \"#967EE2\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: false,\n defaultSize: { width: 112, height: 72 },\n minSize: { width: 60, height: 44 },\n },\n \"x-as-a-service\": {\n mode: \"x-as-a-service\",\n label: \"X-as-a-Service\",\n description:\n \"One team consumes something the other provides 'as a service'; minimal collaboration.\",\n shape: \"triangle\",\n fill: \"#B4B4B4\",\n stroke: \"#999696\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: true,\n defaultSize: { width: 88, height: 78 },\n minSize: { width: 54, height: 48 },\n },\n facilitating: {\n mode: \"facilitating\",\n label: \"Facilitating\",\n description:\n \"One team helps/coaches another to clear impediments and learn; sensing and discovery.\",\n shape: \"circle\",\n fill: \"#C9DFBE\",\n stroke: \"#78996B\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: false,\n defaultSize: { width: 84, height: 84 },\n minSize: { width: 48, height: 48 },\n },\n};\n\n/**\n * The \"flow of change\" guide — a placeable dashed arrow (left-to-right).\n * Not a team or interaction: a standalone annotation element.\n */\nexport const FLOW_SPEC: FlowSpec = {\n label: \"Flow of change\",\n fill: \"transparent\",\n stroke: \"#6b6459\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n defaultSize: { width: 520, height: 64 },\n minSize: { width: 160, height: 36 },\n};\n\n/** Maps a stroke style to an SVG/CSS dash array (empty string = solid). */\nexport function dashArray(style: StrokeStyle, strokeWidth = 2): string {\n switch (style) {\n case \"dashed\":\n return `${strokeWidth * 3} ${strokeWidth * 2}`;\n case \"dotted\":\n return `${strokeWidth} ${strokeWidth * 1.5}`;\n case \"solid\":\n default:\n return \"\";\n }\n}\n\nexport const ALL_TEAM_SPECS: readonly TeamTypeSpec[] = Object.values(TEAM_TYPE_SPECS);\nexport const ALL_INTERACTION_SPECS: readonly InteractionModeSpec[] =\n Object.values(INTERACTION_MODE_SPECS);\n","/**\n * Runtime validation for the document model using Zod.\n *\n * Anything entering the app from the outside world (imported files, share\n * URLs, localStorage) is parsed through {@link parseDocument} so malformed or\n * tampered data can never corrupt the editor state.\n */\n\nimport { z } from \"zod\";\nimport { DOCUMENT_VERSION, INTERACTION_MODES, TEAM_TYPES } from \"./types\";\nimport type { TtDocument } from \"./types\";\n\nconst teamTypeSchema = z.enum(TEAM_TYPES as unknown as [string, ...string[]]);\nconst interactionModeSchema = z.enum(INTERACTION_MODES as unknown as [string, ...string[]]);\n\nconst sizeSchema = z.object({\n width: z.number().finite().positive(),\n height: z.number().finite().positive(),\n});\n\nconst positionSchema = z.object({\n x: z.number().finite(),\n y: z.number().finite(),\n});\n\nconst hexColor = z.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, \"expected a hex colour\");\n\nexport const teamNodeSchema = z.object({\n id: z.string().min(1),\n type: teamTypeSchema,\n label: z.string(),\n description: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n fill: hexColor.optional(),\n stroke: hexColor.optional(),\n});\n\nexport const interactionSchema = z.object({\n id: z.string().min(1),\n mode: interactionModeSchema,\n label: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n fill: hexColor.optional(),\n stroke: hexColor.optional(),\n});\n\nexport const flowSchema = z.object({\n id: z.string().min(1),\n label: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n});\n\nexport const documentSchema = z.object({\n version: z.literal(DOCUMENT_VERSION),\n title: z.string(),\n nodes: z.array(teamNodeSchema),\n interactions: z.array(interactionSchema),\n flows: z.array(flowSchema),\n});\n\nexport type ParseResult = { ok: true; document: TtDocument } | { ok: false; error: string };\n\n/**\n * Validates and (if necessary) migrates unknown data into a {@link TtDocument}.\n * Returns a discriminated result rather than throwing so callers can show a\n * friendly message.\n */\nexport function parseDocument(input: unknown): ParseResult {\n const migrated = migrate(input);\n const result = documentSchema.safeParse(migrated);\n if (!result.success) {\n return {\n ok: false,\n error: result.error.issues\n .map((i) => `${i.path.join(\".\") || \"(root)\"}: ${i.message}`)\n .join(\"; \"),\n };\n }\n return { ok: true, document: result.data as TtDocument };\n}\n\n/**\n * Forward-migrates older document shapes to the current version. v1 modelled\n * interactions as edges (source/target, no geometry) and carried a\n * `showFlowOfChange` flag; v2 makes interactions placed shapes and adds `flows`.\n * Legacy edge-interactions can't be placed meaningfully, so they're dropped.\n */\nfunction migrate(input: unknown): unknown {\n if (input == null || typeof input !== \"object\") return input;\n const doc = input as Record<string, unknown>;\n const next: Record<string, unknown> = { ...doc };\n delete next.showFlowOfChange; // v1 flag, gone in v2\n next.version = DOCUMENT_VERSION;\n if (typeof next.title !== \"string\") next.title = \"Untitled team topology\";\n if (!Array.isArray(next.nodes)) next.nodes = [];\n // Keep only placed interaction shapes; drop legacy edges (no position/size).\n next.interactions = Array.isArray(next.interactions)\n ? next.interactions.filter(\n (e) => e != null && typeof e === \"object\" && \"position\" in e && \"size\" in e,\n )\n : [];\n if (!Array.isArray(next.flows)) next.flows = [];\n return next;\n}\n","/**\n * Deterministic serialisation of the document model.\n *\n * Producing byte-stable JSON (sorted arrays, fixed key order, rounded\n * coordinates) makes diagrams diff-friendly in version control and gives\n * stable share URLs / embedded payloads.\n */\n\nimport { DOCUMENT_VERSION } from \"./types\";\nimport type { FlowShape, InteractionShape, Position, Size, TeamNode, TtDocument } from \"./types\";\n\n/** Round to 2 decimals to strip floating-point drift from drag operations. */\nfunction round(n: number): number {\n return Math.round(n * 100) / 100;\n}\n\nfunction normPosition(p: Position): Position {\n return { x: round(p.x), y: round(p.y) };\n}\n\nfunction normSize(s: Size): Size {\n return { width: round(s.width), height: round(s.height) };\n}\n\n/** Drops undefined fields and applies a fixed key order to a node. */\nfunction normNode(n: TeamNode): TeamNode {\n const out: TeamNode = {\n id: n.id,\n type: n.type,\n label: n.label,\n position: normPosition(n.position),\n size: normSize(n.size),\n };\n if (n.description) out.description = n.description;\n if (n.fill) out.fill = n.fill;\n if (n.stroke) out.stroke = n.stroke;\n return out;\n}\n\nfunction normInteraction(e: InteractionShape): InteractionShape {\n const out: InteractionShape = {\n id: e.id,\n mode: e.mode,\n position: normPosition(e.position),\n size: normSize(e.size),\n };\n if (e.label) out.label = e.label;\n if (e.fill) out.fill = e.fill;\n if (e.stroke) out.stroke = e.stroke;\n return out;\n}\n\nfunction normFlow(f: FlowShape): FlowShape {\n const out: FlowShape = {\n id: f.id,\n position: normPosition(f.position),\n size: normSize(f.size),\n };\n if (f.label) out.label = f.label;\n return out;\n}\n\nconst byId = (a: { id: string }, b: { id: string }): number =>\n a.id < b.id ? -1 : a.id > b.id ? 1 : 0;\n\n/** Returns a canonicalised copy of a document (sorted, rounded, version-stamped). */\nexport function canonicalize(doc: TtDocument): TtDocument {\n return {\n version: DOCUMENT_VERSION,\n title: doc.title,\n nodes: [...doc.nodes].map(normNode).sort(byId),\n interactions: [...doc.interactions].map(normInteraction).sort(byId),\n flows: [...doc.flows].map(normFlow).sort(byId),\n };\n}\n\n/** Serialises a document to deterministic, pretty-printed JSON. */\nexport function serializeDocument(doc: TtDocument, pretty = true): string {\n const canonical = canonicalize(doc);\n return JSON.stringify(canonical, null, pretty ? 2 : 0);\n}\n","/**\n * Factory helpers for constructing well-formed model objects with the correct\n * notation defaults (sizes, labels). Kept DOM-free.\n */\n\nimport { nanoid } from \"nanoid\";\nimport { FLOW_SPEC, INTERACTION_MODE_SPECS, TEAM_TYPE_SPECS } from \"./notation\";\nimport type {\n FlowShape,\n InteractionMode,\n InteractionShape,\n Position,\n TeamNode,\n TeamType,\n TtDocument,\n} from \"./types\";\nimport { DOCUMENT_VERSION } from \"./types\";\n\nexport function newId(prefix: string): string {\n return `${prefix}_${nanoid(8)}`;\n}\n\n/** Creates a team node of the given type at a position, with notation defaults. */\nexport function createTeamNode(\n type: TeamType,\n position: Position,\n overrides: Partial<Omit<TeamNode, \"id\" | \"type\">> = {},\n): TeamNode {\n const spec = TEAM_TYPE_SPECS[type];\n return {\n id: newId(\"team\"),\n type,\n label: overrides.label ?? spec.label,\n description: overrides.description,\n position,\n size: overrides.size ?? { ...spec.defaultSize },\n fill: overrides.fill,\n stroke: overrides.stroke,\n };\n}\n\n/** Creates a placed interaction shape of the given mode, with notation defaults. */\nexport function createInteractionShape(\n mode: InteractionMode,\n position: Position,\n overrides: Partial<Omit<InteractionShape, \"id\" | \"mode\" | \"position\">> = {},\n): InteractionShape {\n const spec = INTERACTION_MODE_SPECS[mode];\n return {\n id: newId(\"int\"),\n mode,\n position,\n size: overrides.size ?? { ...spec.defaultSize },\n label: overrides.label,\n fill: overrides.fill,\n stroke: overrides.stroke,\n };\n}\n\n/** Creates a placed \"flow of change\" arrow, with notation defaults. */\nexport function createFlowShape(\n position: Position,\n overrides: Partial<Omit<FlowShape, \"id\" | \"position\">> = {},\n): FlowShape {\n return {\n id: newId(\"flow\"),\n position,\n size: overrides.size ?? { ...FLOW_SPEC.defaultSize },\n label: overrides.label ?? FLOW_SPEC.label,\n };\n}\n\n/** An empty document with sensible defaults. */\nexport function emptyDocument(title = \"Untitled team topology\"): TtDocument {\n return {\n version: DOCUMENT_VERSION,\n title,\n nodes: [],\n interactions: [],\n flows: [],\n };\n}\n","/**\n * A small but complete example diagram exercising all four team types, all three\n * interaction modes (as placed shapes overlaying the team boundaries) and a\n * flow-of-change element. Ids are fixed so the fixture serialises stably.\n */\n\nimport { DOCUMENT_VERSION } from \"./types\";\nimport type { TtDocument } from \"./types\";\nimport { INTERACTION_MODE_SPECS, TEAM_TYPE_SPECS } from \"./notation\";\n\nconst s = TEAM_TYPE_SPECS;\nconst i = INTERACTION_MODE_SPECS;\n\nexport const SAMPLE_DOCUMENT: TtDocument = {\n version: DOCUMENT_VERSION,\n title: \"Online retail — team topology\",\n nodes: [\n {\n id: \"team_enabling\",\n type: \"enabling\",\n label: \"Agile Enablement\",\n description: \"Coaches teams on testing and continuous delivery practices.\",\n position: { x: 60, y: 150 },\n size: { ...s.enabling.defaultSize },\n },\n {\n id: \"team_checkout\",\n type: \"stream-aligned\",\n label: \"Checkout Stream\",\n description: \"Owns the end-to-end checkout & payments journey.\",\n position: { x: 320, y: 110 },\n size: { ...s[\"stream-aligned\"].defaultSize },\n },\n {\n id: \"team_mobile\",\n type: \"stream-aligned\",\n label: \"Mobile Experience\",\n description: \"Owns the native mobile shopping experience.\",\n position: { x: 700, y: 110 },\n size: { ...s[\"stream-aligned\"].defaultSize },\n },\n {\n id: \"team_fraud\",\n type: \"complicated-subsystem\",\n label: \"Risk & Fraud Engine\",\n description: \"Specialist ML team owning real-time fraud scoring.\",\n position: { x: 740, y: 320 },\n size: { ...s[\"complicated-subsystem\"].defaultSize },\n },\n {\n id: \"team_platform\",\n type: \"platform\",\n label: \"Internal Developer Platform\",\n description: \"Self-service CI/CD, observability and runtime for all streams.\",\n position: { x: 300, y: 540 },\n size: { ...s.platform.defaultSize },\n },\n ],\n interactions: [\n {\n id: \"int_enable_checkout\",\n mode: \"facilitating\",\n label: \"test automation\",\n position: { x: 212, y: 158 },\n size: { ...i.facilitating.defaultSize },\n },\n {\n id: \"int_checkout_fraud\",\n mode: \"collaboration\",\n label: \"fraud rules discovery\",\n position: { x: 566, y: 232 },\n size: { ...i.collaboration.defaultSize },\n },\n {\n id: \"int_platform_checkout\",\n mode: \"x-as-a-service\",\n position: { x: 384, y: 396 },\n size: { ...i[\"x-as-a-service\"].defaultSize },\n },\n {\n id: \"int_platform_mobile\",\n mode: \"x-as-a-service\",\n position: { x: 612, y: 396 },\n size: { ...i[\"x-as-a-service\"].defaultSize },\n },\n {\n id: \"int_fraud_mobile\",\n mode: \"x-as-a-service\",\n label: \"risk scoring API\",\n position: { x: 800, y: 238 },\n size: { ...i[\"x-as-a-service\"].defaultSize },\n },\n ],\n flows: [\n {\n id: \"flow_main\",\n label: \"Flow of change\",\n position: { x: 60, y: 712 },\n size: { width: 880, height: 60 },\n },\n ],\n};\n"]}
1
+ {"version":3,"sources":["../src/types.ts","../src/notation.ts","../src/schema.ts","../src/serialize.ts","../src/factory.ts","../src/sample.ts"],"names":["z","i","s","nanoid"],"mappings":";;;;;;AASO,IAAM,QAAA,GAAW;AAKjB,IAAM,UAAA,GAAkC;AAAA,EAC7C,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACF;AAKO,IAAM,iBAAA,GAAgD;AAAA,EAC3D,eAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF;AAuEO,IAAM,gBAAA,GAAmB;;;AC5BzB,IAAM,eAAA,GAAkD;AAAA,EAC7D,gBAAA,EAAkB;AAAA,IAChB,IAAA,EAAM,gBAAA;AAAA,IACN,KAAA,EAAO,gBAAA;AAAA,IACP,WAAA,EAAa,mEAAA;AAAA,IACb,KAAA,EAAO,yBAAA;AAAA,IACP,IAAA,EAAM,SAAA;AAAA,IACN,MAAA,EAAQ,SAAA;AAAA,IACR,WAAA,EAAa,OAAA;AAAA,IACb,WAAA,EAAa,CAAA;AAAA,IACb,WAAA,EAAa,EAAE,KAAA,EAAO,GAAA,EAAK,QAAQ,EAAA,EAAG;AAAA,IACtC,OAAA,EAAS,EAAE,KAAA,EAAO,GAAA,EAAK,QAAQ,EAAA;AAAG,GACpC;AAAA,E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AAAA,IACA;AAAA,MACE,EAAA,EAAI,wBAAA;AAAA,MACJ,IAAA,EAAM,gBAAA;AAAA,MACN,QAAA,EAAU,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAI;AAAA,MAC3B,MAAM,EAAE,GAAG,CAAA,CAAE,gBAAgB,EAAE,WAAA;AAAY,KAC7C;AAAA,IACA;AAAA,MACE,EAAA,EAAI,uBAAA;AAAA,MACJ,IAAA,EAAM,gBAAA;AAAA,MACN,QAAA,EAAU,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAI;AAAA,MAC3B,MAAM,EAAE,GAAG,CAAA,CAAE,gBAAgB,EAAE,WAAA;AAAY;AAC7C,GACF;AAAA,EACA,KAAA,EAAO;AAAA,IACL;AAAA,MACE,EAAA,EAAI,WAAA;AAAA,MACJ,KAAA,EAAO,gBAAA;AAAA,MACP,QAAA,EAAU,EAAE,CAAA,EAAG,EAAA,EAAI,GAAG,EAAA,EAAG;AAAA,MACzB,IAAA,EAAM,EAAE,KAAA,EAAO,GAAA,EAAK,QAAQ,EAAA;AAAG;AACjC,GACF;AAAA,EACA,WAAA,EAAa;AAAA,IACX;AAAA,MACE,EAAA,EAAI,oBAAA;AAAA,MACJ,IAAA,EAAM,0EAAA;AAAA,MACN,QAAA,EAAU,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAI;AAAA,MAC3B,IAAA,EAAM,EAAE,GAAG,eAAA,CAAgB,WAAA,EAAY;AAAA,MACvC,UAAA,EAAY;AAAA;AACd;AAEJ","file":"index.cjs","sourcesContent":["/**\n * Pure (DOM-free) domain types for the Team Topologies model.\n *\n * This module is the canonical representation of a diagram and must never\n * import from the rendering layer (`@xyflow/react`) or touch the DOM, so it\n * can be unit-tested in isolation and reused across views / exporters.\n */\n\n/** MIME type used when dragging a team type from the palette onto the canvas. */\nexport const DND_MIME = \"application/x-tt-team-type\";\n\n/** The four fundamental team types in Team Topologies. */\nexport type TeamType = \"stream-aligned\" | \"enabling\" | \"complicated-subsystem\" | \"platform\";\n\nexport const TEAM_TYPES: readonly TeamType[] = [\n \"stream-aligned\",\n \"enabling\",\n \"complicated-subsystem\",\n \"platform\",\n] as const;\n\n/** The three core team interaction modes in Team Topologies. */\nexport type InteractionMode = \"collaboration\" | \"x-as-a-service\" | \"facilitating\";\n\nexport const INTERACTION_MODES: readonly InteractionMode[] = [\n \"collaboration\",\n \"x-as-a-service\",\n \"facilitating\",\n] as const;\n\n/** Geometric size of a node in canvas units (px). Encodes cognitive load. */\nexport interface Size {\n width: number;\n height: number;\n}\n\n/** Position of a node on the canvas in canvas units (px). */\nexport interface Position {\n x: number;\n y: number;\n}\n\n/** A team node in the canonical document model. */\nexport interface TeamNode {\n id: string;\n type: TeamType;\n label: string;\n description?: string;\n position: Position;\n size: Size;\n fill?: string;\n stroke?: string;\n}\n\n/**\n * An interaction in the canonical document model.\n *\n * Per the official Team Topologies notation, an interaction is a placed,\n * resizable SHAPE (parallelogram / triangle / circle) overlaid on the boundary\n * between the teams it relates to — not a connecting line. The relationship is\n * therefore spatial (overlap), so there is no source/target reference.\n */\nexport interface InteractionShape {\n id: string;\n mode: InteractionMode;\n label?: string;\n position: Position;\n size: Size;\n fill?: string;\n stroke?: string;\n}\n\n/**\n * A \"flow of change\" guide: a placed, resizable arrow element. Lets you anchor\n * the implied left-to-right flow, and visualise several team groupings on one\n * canvas.\n */\nexport interface FlowShape {\n id: string;\n label?: string;\n position: Position;\n size: Size;\n}\n\n/**\n * A free-text note beside the diagram (like a BPMN text annotation). It either\n * stands alone or is attached to exactly one team, interaction or flow, which\n * its dashed connector points at.\n */\nexport interface TextAnnotation {\n id: string;\n text: string;\n position: Position;\n size: Size;\n /** Id of the team, interaction or flow this annotation is attached to. */\n attachedTo?: string;\n}\n\n/** Current document schema version. Bump + add a migration when shape changes. */\nexport const DOCUMENT_VERSION = 3 as const;\n\n/**\n * A complete Team Topologies diagram. This is what gets serialised to JSON,\n * embedded into exported images, and encoded into share URLs.\n */\nexport interface TtDocument {\n version: typeof DOCUMENT_VERSION;\n title: string;\n nodes: TeamNode[];\n interactions: InteractionShape[];\n flows: FlowShape[];\n annotations: TextAnnotation[];\n}\n","/**\n * The Team Topologies visual notation, encoded as data.\n *\n * Colours, shapes and stroke styles follow the official\n * \"Team-Shape-Templates\" specification published by Team Topologies\n * (https://github.com/TeamTopologies/Team-Shape-Templates):\n *\n * - Team shapes are SOLID outlines (long-lived structures).\n * - Interaction-mode shapes are 50% transparent with DASHED outlines\n * (short-lived interactions).\n * - Each element is distinguished by SHAPE as well as colour, so the\n * notation stays readable for people with colour-vision deficiency.\n *\n * This module is pure data — it must not import the rendering layer.\n */\n\nimport type { InteractionMode, Size, TeamType } from \"./types\";\n\nexport type TeamShape = \"rounded-rect-horizontal\" | \"rounded-rect-vertical\" | \"octagon\" | \"rect\";\n\nexport type InteractionGlyph = \"parallelogram\" | \"triangle\" | \"circle\";\n\nexport type StrokeStyle = \"solid\" | \"dashed\" | \"dotted\";\n\nexport interface TeamTypeSpec {\n type: TeamType;\n /** Short display name. */\n label: string;\n /** One-line purpose, shown in the palette and inspector. */\n description: string;\n shape: TeamShape;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n /** Default size when a node of this type is created. */\n defaultSize: Size;\n /** Minimum size enforced by the resizer. */\n minSize: Size;\n}\n\nexport interface InteractionModeSpec {\n mode: InteractionMode;\n label: string;\n description: string;\n shape: InteractionGlyph;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n /** Opacity for the interaction shape (short-lived → translucent). */\n opacity: number;\n /** Whether direction is semantically meaningful (the X-as-a-Service triangle). */\n directional: boolean;\n /** Default size when a shape of this mode is created. */\n defaultSize: Size;\n /** Minimum size enforced by the resizer. */\n minSize: Size;\n}\n\n/** The left-to-right \"flow of change\" guide, a placeable annotation element. */\nexport interface FlowSpec {\n label: string;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n defaultSize: Size;\n minSize: Size;\n}\n\nexport const TEAM_TYPE_SPECS: Record<TeamType, TeamTypeSpec> = {\n \"stream-aligned\": {\n type: \"stream-aligned\",\n label: \"Stream-aligned\",\n description: \"Aligned to a single, valuable stream of work; owns it end-to-end.\",\n shape: \"rounded-rect-horizontal\",\n fill: \"#FFEDB8\",\n stroke: \"#FFD966\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 240, height: 96 },\n minSize: { width: 140, height: 64 },\n },\n enabling: {\n type: \"enabling\",\n label: \"Enabling\",\n description:\n \"Helps stream-aligned teams acquire missing capabilities; coaches, then steps back.\",\n shape: \"rounded-rect-vertical\",\n fill: \"#DFBDCF\",\n stroke: \"#D09CB7\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 120, height: 200 },\n minSize: { width: 80, height: 120 },\n },\n \"complicated-subsystem\": {\n type: \"complicated-subsystem\",\n label: \"Complicated Subsystem\",\n description:\n \"Owns a part of the system needing deep specialist knowledge, reducing others' cognitive load.\",\n shape: \"octagon\",\n fill: \"#FFC08B\",\n stroke: \"#E88814\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 170, height: 150 },\n minSize: { width: 110, height: 100 },\n },\n platform: {\n type: \"platform\",\n label: \"Platform\",\n description:\n \"Provides internal self-service capabilities to reduce cognitive load for stream-aligned teams.\",\n shape: \"rect\",\n fill: \"#B7CDF1\",\n stroke: \"#6D9EEB\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 380, height: 130 },\n minSize: { width: 200, height: 90 },\n },\n};\n\nexport const INTERACTION_MODE_SPECS: Record<InteractionMode, InteractionModeSpec> = {\n collaboration: {\n mode: \"collaboration\",\n label: \"Collaboration\",\n description:\n \"Two teams work closely together for a defined period; high overhead, high discovery.\",\n shape: \"parallelogram\",\n fill: \"#C6BEDF\",\n stroke: \"#967EE2\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: false,\n defaultSize: { width: 112, height: 72 },\n minSize: { width: 60, height: 44 },\n },\n \"x-as-a-service\": {\n mode: \"x-as-a-service\",\n label: \"X-as-a-Service\",\n description:\n \"One team consumes something the other provides 'as a service'; minimal collaboration.\",\n shape: \"triangle\",\n fill: \"#B4B4B4\",\n stroke: \"#999696\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: true,\n defaultSize: { width: 88, height: 78 },\n minSize: { width: 54, height: 48 },\n },\n facilitating: {\n mode: \"facilitating\",\n label: \"Facilitating\",\n description:\n \"One team helps/coaches another to clear impediments and learn; sensing and discovery.\",\n shape: \"circle\",\n fill: \"#C9DFBE\",\n stroke: \"#78996B\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: false,\n defaultSize: { width: 84, height: 84 },\n minSize: { width: 48, height: 48 },\n },\n};\n\n/**\n * The \"flow of change\" guide — a placeable dashed arrow (left-to-right).\n * Not a team or interaction: a standalone annotation element.\n */\nexport const FLOW_SPEC: FlowSpec = {\n label: \"Flow of change\",\n fill: \"transparent\",\n stroke: \"#6b6459\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n defaultSize: { width: 520, height: 64 },\n minSize: { width: 160, height: 36 },\n};\n\n/**\n * A text annotation — not part of the Team Topologies notation, so it carries\n * no colours here; the renderer draws it in the neutral brand ink.\n */\nexport interface AnnotationSpec {\n label: string;\n defaultSize: Size;\n minSize: Size;\n}\n\nexport const ANNOTATION_SPEC: AnnotationSpec = {\n label: \"Annotation\",\n defaultSize: { width: 200, height: 64 },\n minSize: { width: 60, height: 30 },\n};\n\n/** Maps a stroke style to an SVG/CSS dash array (empty string = solid). */\nexport function dashArray(style: StrokeStyle, strokeWidth = 2): string {\n switch (style) {\n case \"dashed\":\n return `${strokeWidth * 3} ${strokeWidth * 2}`;\n case \"dotted\":\n return `${strokeWidth} ${strokeWidth * 1.5}`;\n case \"solid\":\n default:\n return \"\";\n }\n}\n\nexport const ALL_TEAM_SPECS: readonly TeamTypeSpec[] = Object.values(TEAM_TYPE_SPECS);\nexport const ALL_INTERACTION_SPECS: readonly InteractionModeSpec[] =\n Object.values(INTERACTION_MODE_SPECS);\n","/**\n * Runtime validation for the document model using Zod.\n *\n * Anything entering the app from the outside world (imported files, share\n * URLs, localStorage) is parsed through {@link parseDocument} so malformed or\n * tampered data can never corrupt the editor state.\n */\n\nimport { z } from \"zod\";\nimport { DOCUMENT_VERSION, INTERACTION_MODES, TEAM_TYPES } from \"./types\";\nimport type { TtDocument } from \"./types\";\n\nconst teamTypeSchema = z.enum(TEAM_TYPES as unknown as [string, ...string[]]);\nconst interactionModeSchema = z.enum(INTERACTION_MODES as unknown as [string, ...string[]]);\n\nconst sizeSchema = z.object({\n width: z.number().finite().positive(),\n height: z.number().finite().positive(),\n});\n\nconst positionSchema = z.object({\n x: z.number().finite(),\n y: z.number().finite(),\n});\n\nconst hexColor = z.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, \"expected a hex colour\");\n\nexport const teamNodeSchema = z.object({\n id: z.string().min(1),\n type: teamTypeSchema,\n label: z.string(),\n description: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n fill: hexColor.optional(),\n stroke: hexColor.optional(),\n});\n\nexport const interactionSchema = z.object({\n id: z.string().min(1),\n mode: interactionModeSchema,\n label: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n fill: hexColor.optional(),\n stroke: hexColor.optional(),\n});\n\nexport const flowSchema = z.object({\n id: z.string().min(1),\n label: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n});\n\nexport const annotationSchema = z.object({\n id: z.string().min(1),\n text: z.string(),\n position: positionSchema,\n size: sizeSchema,\n attachedTo: z.string().min(1).optional(),\n});\n\nexport const documentSchema = z.object({\n version: z.literal(DOCUMENT_VERSION),\n title: z.string(),\n nodes: z.array(teamNodeSchema),\n interactions: z.array(interactionSchema),\n flows: z.array(flowSchema),\n annotations: z.array(annotationSchema),\n});\n\nexport type ParseResult = { ok: true; document: TtDocument } | { ok: false; error: string };\n\n/**\n * Validates and (if necessary) migrates unknown data into a {@link TtDocument}.\n * Returns a discriminated result rather than throwing so callers can show a\n * friendly message.\n */\nexport function parseDocument(input: unknown): ParseResult {\n const migrated = migrate(input);\n const result = documentSchema.safeParse(migrated);\n if (!result.success) {\n return {\n ok: false,\n error: result.error.issues\n .map((i) => `${i.path.join(\".\") || \"(root)\"}: ${i.message}`)\n .join(\"; \"),\n };\n }\n return { ok: true, document: result.data as TtDocument };\n}\n\n/**\n * Forward-migrates older document shapes to the current version. v1 modelled\n * interactions as edges (source/target, no geometry) and carried a\n * `showFlowOfChange` flag; v2 makes interactions placed shapes and adds `flows`;\n * v3 adds `annotations`. Legacy edge-interactions can't be placed meaningfully,\n * so they're dropped.\n */\nfunction migrate(input: unknown): unknown {\n if (input == null || typeof input !== \"object\") return input;\n const doc = input as Record<string, unknown>;\n const next: Record<string, unknown> = { ...doc };\n delete next.showFlowOfChange; // v1 flag, gone in v2\n next.version = DOCUMENT_VERSION;\n if (typeof next.title !== \"string\") next.title = \"Untitled team topology\";\n if (!Array.isArray(next.nodes)) next.nodes = [];\n // Keep only placed interaction shapes; drop legacy edges (no position/size).\n next.interactions = Array.isArray(next.interactions)\n ? next.interactions.filter(\n (e) => e != null && typeof e === \"object\" && \"position\" in e && \"size\" in e,\n )\n : [];\n if (!Array.isArray(next.flows)) next.flows = [];\n if (!Array.isArray(next.annotations)) next.annotations = [];\n return next;\n}\n","/**\n * Deterministic serialisation of the document model.\n *\n * Producing byte-stable JSON (sorted arrays, fixed key order, rounded\n * coordinates) makes diagrams diff-friendly in version control and gives\n * stable share URLs / embedded payloads.\n */\n\nimport { DOCUMENT_VERSION } from \"./types\";\nimport type {\n FlowShape,\n InteractionShape,\n Position,\n Size,\n TeamNode,\n TextAnnotation,\n TtDocument,\n} from \"./types\";\n\n/** Round to 2 decimals to strip floating-point drift from drag operations. */\nfunction round(n: number): number {\n return Math.round(n * 100) / 100;\n}\n\nfunction normPosition(p: Position): Position {\n return { x: round(p.x), y: round(p.y) };\n}\n\nfunction normSize(s: Size): Size {\n return { width: round(s.width), height: round(s.height) };\n}\n\n/** Drops undefined fields and applies a fixed key order to a node. */\nfunction normNode(n: TeamNode): TeamNode {\n const out: TeamNode = {\n id: n.id,\n type: n.type,\n label: n.label,\n position: normPosition(n.position),\n size: normSize(n.size),\n };\n if (n.description) out.description = n.description;\n if (n.fill) out.fill = n.fill;\n if (n.stroke) out.stroke = n.stroke;\n return out;\n}\n\nfunction normInteraction(e: InteractionShape): InteractionShape {\n const out: InteractionShape = {\n id: e.id,\n mode: e.mode,\n position: normPosition(e.position),\n size: normSize(e.size),\n };\n if (e.label) out.label = e.label;\n if (e.fill) out.fill = e.fill;\n if (e.stroke) out.stroke = e.stroke;\n return out;\n}\n\nfunction normFlow(f: FlowShape): FlowShape {\n const out: FlowShape = {\n id: f.id,\n position: normPosition(f.position),\n size: normSize(f.size),\n };\n if (f.label) out.label = f.label;\n return out;\n}\n\nfunction normAnnotation(a: TextAnnotation): TextAnnotation {\n const out: TextAnnotation = {\n id: a.id,\n text: a.text,\n position: normPosition(a.position),\n size: normSize(a.size),\n };\n if (a.attachedTo) out.attachedTo = a.attachedTo;\n return out;\n}\n\nconst byId = (a: { id: string }, b: { id: string }): number =>\n a.id < b.id ? -1 : a.id > b.id ? 1 : 0;\n\n/** Returns a canonicalised copy of a document (sorted, rounded, version-stamped). */\nexport function canonicalize(doc: TtDocument): TtDocument {\n return {\n version: DOCUMENT_VERSION,\n title: doc.title,\n nodes: [...doc.nodes].map(normNode).sort(byId),\n interactions: [...doc.interactions].map(normInteraction).sort(byId),\n flows: [...doc.flows].map(normFlow).sort(byId),\n annotations: [...doc.annotations].map(normAnnotation).sort(byId),\n };\n}\n\n/**\n * Serialises a document to deterministic, pretty-printed JSON. An empty\n * `annotations` list is left out, so re-saving a model that has no annotations\n * changes nothing but its version stamp.\n */\nexport function serializeDocument(doc: TtDocument, pretty = true): string {\n const { annotations, ...canonical } = canonicalize(doc);\n const output = annotations.length > 0 ? { ...canonical, annotations } : canonical;\n return JSON.stringify(output, null, pretty ? 2 : 0);\n}\n","/**\n * Factory helpers for constructing well-formed model objects with the correct\n * notation defaults (sizes, labels). Kept DOM-free.\n */\n\nimport { nanoid } from \"nanoid\";\nimport { ANNOTATION_SPEC, FLOW_SPEC, INTERACTION_MODE_SPECS, TEAM_TYPE_SPECS } from \"./notation\";\nimport type {\n FlowShape,\n InteractionMode,\n InteractionShape,\n Position,\n TeamNode,\n TeamType,\n TextAnnotation,\n TtDocument,\n} from \"./types\";\nimport { DOCUMENT_VERSION } from \"./types\";\n\nexport function newId(prefix: string): string {\n return `${prefix}_${nanoid(8)}`;\n}\n\n/** Creates a team node of the given type at a position, with notation defaults. */\nexport function createTeamNode(\n type: TeamType,\n position: Position,\n overrides: Partial<Omit<TeamNode, \"id\" | \"type\">> = {},\n): TeamNode {\n const spec = TEAM_TYPE_SPECS[type];\n return {\n id: newId(\"team\"),\n type,\n label: overrides.label ?? spec.label,\n description: overrides.description,\n position,\n size: overrides.size ?? { ...spec.defaultSize },\n fill: overrides.fill,\n stroke: overrides.stroke,\n };\n}\n\n/** Creates a placed interaction shape of the given mode, with notation defaults. */\nexport function createInteractionShape(\n mode: InteractionMode,\n position: Position,\n overrides: Partial<Omit<InteractionShape, \"id\" | \"mode\" | \"position\">> = {},\n): InteractionShape {\n const spec = INTERACTION_MODE_SPECS[mode];\n return {\n id: newId(\"int\"),\n mode,\n position,\n size: overrides.size ?? { ...spec.defaultSize },\n label: overrides.label,\n fill: overrides.fill,\n stroke: overrides.stroke,\n };\n}\n\n/** Creates a placed \"flow of change\" arrow, with notation defaults. */\nexport function createFlowShape(\n position: Position,\n overrides: Partial<Omit<FlowShape, \"id\" | \"position\">> = {},\n): FlowShape {\n return {\n id: newId(\"flow\"),\n position,\n size: overrides.size ?? { ...FLOW_SPEC.defaultSize },\n label: overrides.label ?? FLOW_SPEC.label,\n };\n}\n\n/** Creates a text annotation, optionally attached to a team, interaction or flow. */\nexport function createTextAnnotation(\n position: Position,\n overrides: Partial<Omit<TextAnnotation, \"id\" | \"position\">> = {},\n): TextAnnotation {\n return {\n id: newId(\"ann\"),\n text: overrides.text ?? \"\",\n position,\n size: overrides.size ?? { ...ANNOTATION_SPEC.defaultSize },\n attachedTo: overrides.attachedTo,\n };\n}\n\n/** An empty document with sensible defaults. */\nexport function emptyDocument(title = \"Untitled team topology\"): TtDocument {\n return {\n version: DOCUMENT_VERSION,\n title,\n nodes: [],\n interactions: [],\n flows: [],\n annotations: [],\n };\n}\n","/**\n * A small but complete example diagram exercising all four team types, all three\n * interaction modes (as placed shapes overlaying the team boundaries), a\n * flow-of-change element and an attached annotation. Ids are fixed so the\n * fixture serialises stably.\n */\n\nimport { DOCUMENT_VERSION } from \"./types\";\nimport type { TtDocument } from \"./types\";\nimport { ANNOTATION_SPEC, INTERACTION_MODE_SPECS, TEAM_TYPE_SPECS } from \"./notation\";\n\nconst s = TEAM_TYPE_SPECS;\nconst i = INTERACTION_MODE_SPECS;\n\nexport const SAMPLE_DOCUMENT: TtDocument = {\n version: DOCUMENT_VERSION,\n title: \"Online shop — team topology\",\n nodes: [\n {\n id: \"team_test_automation\",\n type: \"enabling\",\n label: \"Test Automation\",\n description: \"Coaches stream-aligned teams in test automation, then steps back.\",\n position: { x: 60, y: 150 },\n size: { ...s.enabling.defaultSize },\n },\n {\n id: \"team_discovery\",\n type: \"stream-aligned\",\n label: \"Product Discovery\",\n description: \"Owns search, browsing and product pages end-to-end.\",\n position: { x: 240, y: 202 },\n size: { ...s[\"stream-aligned\"].defaultSize },\n },\n {\n id: \"team_checkout\",\n type: \"stream-aligned\",\n label: \"Checkout & Payments\",\n description: \"Owns the checkout and payment journey end-to-end.\",\n position: { x: 560, y: 202 },\n size: { ...s[\"stream-aligned\"].defaultSize },\n },\n {\n id: \"team_fraud\",\n type: \"complicated-subsystem\",\n label: \"Fraud Detection\",\n description: \"Specialists for the real-time fraud scoring model.\",\n position: { x: 870, y: 175 },\n size: { ...s[\"complicated-subsystem\"].defaultSize },\n },\n {\n id: \"team_platform\",\n type: \"platform\",\n label: \"Cloud Platform\",\n description: \"Self-service CI/CD, runtime and observability for all teams.\",\n position: { x: 240, y: 352 },\n size: { width: 560, height: 110 },\n },\n ],\n interactions: [\n {\n id: \"int_testing_discovery\",\n mode: \"facilitating\",\n position: { x: 168, y: 208 },\n size: { ...i.facilitating.defaultSize },\n },\n {\n id: \"int_checkout_fraud\",\n mode: \"collaboration\",\n label: \"fraud rules\",\n position: { x: 779, y: 214 },\n size: { ...i.collaboration.defaultSize },\n },\n {\n id: \"int_platform_discovery\",\n mode: \"x-as-a-service\",\n position: { x: 316, y: 286 },\n size: { ...i[\"x-as-a-service\"].defaultSize },\n },\n {\n id: \"int_platform_checkout\",\n mode: \"x-as-a-service\",\n position: { x: 636, y: 286 },\n size: { ...i[\"x-as-a-service\"].defaultSize },\n },\n ],\n flows: [\n {\n id: \"flow_main\",\n label: \"Flow of change\",\n position: { x: 60, y: 60 },\n size: { width: 980, height: 56 },\n },\n ],\n annotations: [\n {\n id: \"ann_fraud_handover\",\n text: \"Collaboration until the fraud rules are stable (Q3), then X-as-a-Service\",\n position: { x: 830, y: 350 },\n size: { ...ANNOTATION_SPEC.defaultSize },\n attachedTo: \"int_checkout_fraud\",\n },\n ],\n};\n"]}
package/dist/index.d.cts CHANGED
@@ -64,8 +64,21 @@ interface FlowShape {
64
64
  position: Position;
65
65
  size: Size;
66
66
  }
67
+ /**
68
+ * A free-text note beside the diagram (like a BPMN text annotation). It either
69
+ * stands alone or is attached to exactly one team, interaction or flow, which
70
+ * its dashed connector points at.
71
+ */
72
+ interface TextAnnotation {
73
+ id: string;
74
+ text: string;
75
+ position: Position;
76
+ size: Size;
77
+ /** Id of the team, interaction or flow this annotation is attached to. */
78
+ attachedTo?: string;
79
+ }
67
80
  /** Current document schema version. Bump + add a migration when shape changes. */
68
- declare const DOCUMENT_VERSION: 2;
81
+ declare const DOCUMENT_VERSION: 3;
69
82
  /**
70
83
  * A complete Team Topologies diagram. This is what gets serialised to JSON,
71
84
  * embedded into exported images, and encoded into share URLs.
@@ -76,6 +89,7 @@ interface TtDocument {
76
89
  nodes: TeamNode[];
77
90
  interactions: InteractionShape[];
78
91
  flows: FlowShape[];
92
+ annotations: TextAnnotation[];
79
93
  }
80
94
 
81
95
  /**
@@ -148,6 +162,16 @@ declare const INTERACTION_MODE_SPECS: Record<InteractionMode, InteractionModeSpe
148
162
  * Not a team or interaction: a standalone annotation element.
149
163
  */
150
164
  declare const FLOW_SPEC: FlowSpec;
165
+ /**
166
+ * A text annotation — not part of the Team Topologies notation, so it carries
167
+ * no colours here; the renderer draws it in the neutral brand ink.
168
+ */
169
+ interface AnnotationSpec {
170
+ label: string;
171
+ defaultSize: Size;
172
+ minSize: Size;
173
+ }
174
+ declare const ANNOTATION_SPEC: AnnotationSpec;
151
175
  /** Maps a stroke style to an SVG/CSS dash array (empty string = solid). */
152
176
  declare function dashArray(style: StrokeStyle, strokeWidth?: number): string;
153
177
  declare const ALL_TEAM_SPECS: readonly TeamTypeSpec[];
@@ -208,8 +232,21 @@ declare const flowSchema: z.ZodObject<{
208
232
  height: z.ZodNumber;
209
233
  }, z.core.$strip>;
210
234
  }, z.core.$strip>;
235
+ declare const annotationSchema: z.ZodObject<{
236
+ id: z.ZodString;
237
+ text: z.ZodString;
238
+ position: z.ZodObject<{
239
+ x: z.ZodNumber;
240
+ y: z.ZodNumber;
241
+ }, z.core.$strip>;
242
+ size: z.ZodObject<{
243
+ width: z.ZodNumber;
244
+ height: z.ZodNumber;
245
+ }, z.core.$strip>;
246
+ attachedTo: z.ZodOptional<z.ZodString>;
247
+ }, z.core.$strip>;
211
248
  declare const documentSchema: z.ZodObject<{
212
- version: z.ZodLiteral<2>;
249
+ version: z.ZodLiteral<3>;
213
250
  title: z.ZodString;
214
251
  nodes: z.ZodArray<z.ZodObject<{
215
252
  id: z.ZodString;
@@ -258,6 +295,19 @@ declare const documentSchema: z.ZodObject<{
258
295
  height: z.ZodNumber;
259
296
  }, z.core.$strip>;
260
297
  }, z.core.$strip>>;
298
+ annotations: z.ZodArray<z.ZodObject<{
299
+ id: z.ZodString;
300
+ text: z.ZodString;
301
+ position: z.ZodObject<{
302
+ x: z.ZodNumber;
303
+ y: z.ZodNumber;
304
+ }, z.core.$strip>;
305
+ size: z.ZodObject<{
306
+ width: z.ZodNumber;
307
+ height: z.ZodNumber;
308
+ }, z.core.$strip>;
309
+ attachedTo: z.ZodOptional<z.ZodString>;
310
+ }, z.core.$strip>>;
261
311
  }, z.core.$strip>;
262
312
  type ParseResult = {
263
313
  ok: true;
@@ -283,7 +333,11 @@ declare function parseDocument(input: unknown): ParseResult;
283
333
 
284
334
  /** Returns a canonicalised copy of a document (sorted, rounded, version-stamped). */
285
335
  declare function canonicalize(doc: TtDocument): TtDocument;
286
- /** Serialises a document to deterministic, pretty-printed JSON. */
336
+ /**
337
+ * Serialises a document to deterministic, pretty-printed JSON. An empty
338
+ * `annotations` list is left out, so re-saving a model that has no annotations
339
+ * changes nothing but its version stamp.
340
+ */
287
341
  declare function serializeDocument(doc: TtDocument, pretty?: boolean): string;
288
342
 
289
343
  /**
@@ -298,15 +352,18 @@ declare function createTeamNode(type: TeamType, position: Position, overrides?:
298
352
  declare function createInteractionShape(mode: InteractionMode, position: Position, overrides?: Partial<Omit<InteractionShape, "id" | "mode" | "position">>): InteractionShape;
299
353
  /** Creates a placed "flow of change" arrow, with notation defaults. */
300
354
  declare function createFlowShape(position: Position, overrides?: Partial<Omit<FlowShape, "id" | "position">>): FlowShape;
355
+ /** Creates a text annotation, optionally attached to a team, interaction or flow. */
356
+ declare function createTextAnnotation(position: Position, overrides?: Partial<Omit<TextAnnotation, "id" | "position">>): TextAnnotation;
301
357
  /** An empty document with sensible defaults. */
302
358
  declare function emptyDocument(title?: string): TtDocument;
303
359
 
304
360
  /**
305
361
  * A small but complete example diagram exercising all four team types, all three
306
- * interaction modes (as placed shapes overlaying the team boundaries) and a
307
- * flow-of-change element. Ids are fixed so the fixture serialises stably.
362
+ * interaction modes (as placed shapes overlaying the team boundaries), a
363
+ * flow-of-change element and an attached annotation. Ids are fixed so the
364
+ * fixture serialises stably.
308
365
  */
309
366
 
310
367
  declare const SAMPLE_DOCUMENT: TtDocument;
311
368
 
312
- export { ALL_INTERACTION_SPECS, ALL_TEAM_SPECS, DND_MIME, DOCUMENT_VERSION, FLOW_SPEC, type FlowShape, type FlowSpec, INTERACTION_MODES, INTERACTION_MODE_SPECS, type InteractionGlyph, type InteractionMode, type InteractionModeSpec, type InteractionShape, type ParseResult, type Position, SAMPLE_DOCUMENT, type Size, type StrokeStyle, TEAM_TYPES, TEAM_TYPE_SPECS, type TeamNode, type TeamShape, type TeamType, type TeamTypeSpec, type TtDocument, canonicalize, createFlowShape, createInteractionShape, createTeamNode, dashArray, documentSchema, emptyDocument, flowSchema, interactionSchema, newId, parseDocument, serializeDocument, teamNodeSchema };
369
+ export { ALL_INTERACTION_SPECS, ALL_TEAM_SPECS, ANNOTATION_SPEC, type AnnotationSpec, DND_MIME, DOCUMENT_VERSION, FLOW_SPEC, type FlowShape, type FlowSpec, INTERACTION_MODES, INTERACTION_MODE_SPECS, type InteractionGlyph, type InteractionMode, type InteractionModeSpec, type InteractionShape, type ParseResult, type Position, SAMPLE_DOCUMENT, type Size, type StrokeStyle, TEAM_TYPES, TEAM_TYPE_SPECS, type TeamNode, type TeamShape, type TeamType, type TeamTypeSpec, type TextAnnotation, type TtDocument, annotationSchema, canonicalize, createFlowShape, createInteractionShape, createTeamNode, createTextAnnotation, dashArray, documentSchema, emptyDocument, flowSchema, interactionSchema, newId, parseDocument, serializeDocument, teamNodeSchema };
package/dist/index.d.ts CHANGED
@@ -64,8 +64,21 @@ interface FlowShape {
64
64
  position: Position;
65
65
  size: Size;
66
66
  }
67
+ /**
68
+ * A free-text note beside the diagram (like a BPMN text annotation). It either
69
+ * stands alone or is attached to exactly one team, interaction or flow, which
70
+ * its dashed connector points at.
71
+ */
72
+ interface TextAnnotation {
73
+ id: string;
74
+ text: string;
75
+ position: Position;
76
+ size: Size;
77
+ /** Id of the team, interaction or flow this annotation is attached to. */
78
+ attachedTo?: string;
79
+ }
67
80
  /** Current document schema version. Bump + add a migration when shape changes. */
68
- declare const DOCUMENT_VERSION: 2;
81
+ declare const DOCUMENT_VERSION: 3;
69
82
  /**
70
83
  * A complete Team Topologies diagram. This is what gets serialised to JSON,
71
84
  * embedded into exported images, and encoded into share URLs.
@@ -76,6 +89,7 @@ interface TtDocument {
76
89
  nodes: TeamNode[];
77
90
  interactions: InteractionShape[];
78
91
  flows: FlowShape[];
92
+ annotations: TextAnnotation[];
79
93
  }
80
94
 
81
95
  /**
@@ -148,6 +162,16 @@ declare const INTERACTION_MODE_SPECS: Record<InteractionMode, InteractionModeSpe
148
162
  * Not a team or interaction: a standalone annotation element.
149
163
  */
150
164
  declare const FLOW_SPEC: FlowSpec;
165
+ /**
166
+ * A text annotation — not part of the Team Topologies notation, so it carries
167
+ * no colours here; the renderer draws it in the neutral brand ink.
168
+ */
169
+ interface AnnotationSpec {
170
+ label: string;
171
+ defaultSize: Size;
172
+ minSize: Size;
173
+ }
174
+ declare const ANNOTATION_SPEC: AnnotationSpec;
151
175
  /** Maps a stroke style to an SVG/CSS dash array (empty string = solid). */
152
176
  declare function dashArray(style: StrokeStyle, strokeWidth?: number): string;
153
177
  declare const ALL_TEAM_SPECS: readonly TeamTypeSpec[];
@@ -208,8 +232,21 @@ declare const flowSchema: z.ZodObject<{
208
232
  height: z.ZodNumber;
209
233
  }, z.core.$strip>;
210
234
  }, z.core.$strip>;
235
+ declare const annotationSchema: z.ZodObject<{
236
+ id: z.ZodString;
237
+ text: z.ZodString;
238
+ position: z.ZodObject<{
239
+ x: z.ZodNumber;
240
+ y: z.ZodNumber;
241
+ }, z.core.$strip>;
242
+ size: z.ZodObject<{
243
+ width: z.ZodNumber;
244
+ height: z.ZodNumber;
245
+ }, z.core.$strip>;
246
+ attachedTo: z.ZodOptional<z.ZodString>;
247
+ }, z.core.$strip>;
211
248
  declare const documentSchema: z.ZodObject<{
212
- version: z.ZodLiteral<2>;
249
+ version: z.ZodLiteral<3>;
213
250
  title: z.ZodString;
214
251
  nodes: z.ZodArray<z.ZodObject<{
215
252
  id: z.ZodString;
@@ -258,6 +295,19 @@ declare const documentSchema: z.ZodObject<{
258
295
  height: z.ZodNumber;
259
296
  }, z.core.$strip>;
260
297
  }, z.core.$strip>>;
298
+ annotations: z.ZodArray<z.ZodObject<{
299
+ id: z.ZodString;
300
+ text: z.ZodString;
301
+ position: z.ZodObject<{
302
+ x: z.ZodNumber;
303
+ y: z.ZodNumber;
304
+ }, z.core.$strip>;
305
+ size: z.ZodObject<{
306
+ width: z.ZodNumber;
307
+ height: z.ZodNumber;
308
+ }, z.core.$strip>;
309
+ attachedTo: z.ZodOptional<z.ZodString>;
310
+ }, z.core.$strip>>;
261
311
  }, z.core.$strip>;
262
312
  type ParseResult = {
263
313
  ok: true;
@@ -283,7 +333,11 @@ declare function parseDocument(input: unknown): ParseResult;
283
333
 
284
334
  /** Returns a canonicalised copy of a document (sorted, rounded, version-stamped). */
285
335
  declare function canonicalize(doc: TtDocument): TtDocument;
286
- /** Serialises a document to deterministic, pretty-printed JSON. */
336
+ /**
337
+ * Serialises a document to deterministic, pretty-printed JSON. An empty
338
+ * `annotations` list is left out, so re-saving a model that has no annotations
339
+ * changes nothing but its version stamp.
340
+ */
287
341
  declare function serializeDocument(doc: TtDocument, pretty?: boolean): string;
288
342
 
289
343
  /**
@@ -298,15 +352,18 @@ declare function createTeamNode(type: TeamType, position: Position, overrides?:
298
352
  declare function createInteractionShape(mode: InteractionMode, position: Position, overrides?: Partial<Omit<InteractionShape, "id" | "mode" | "position">>): InteractionShape;
299
353
  /** Creates a placed "flow of change" arrow, with notation defaults. */
300
354
  declare function createFlowShape(position: Position, overrides?: Partial<Omit<FlowShape, "id" | "position">>): FlowShape;
355
+ /** Creates a text annotation, optionally attached to a team, interaction or flow. */
356
+ declare function createTextAnnotation(position: Position, overrides?: Partial<Omit<TextAnnotation, "id" | "position">>): TextAnnotation;
301
357
  /** An empty document with sensible defaults. */
302
358
  declare function emptyDocument(title?: string): TtDocument;
303
359
 
304
360
  /**
305
361
  * A small but complete example diagram exercising all four team types, all three
306
- * interaction modes (as placed shapes overlaying the team boundaries) and a
307
- * flow-of-change element. Ids are fixed so the fixture serialises stably.
362
+ * interaction modes (as placed shapes overlaying the team boundaries), a
363
+ * flow-of-change element and an attached annotation. Ids are fixed so the
364
+ * fixture serialises stably.
308
365
  */
309
366
 
310
367
  declare const SAMPLE_DOCUMENT: TtDocument;
311
368
 
312
- export { ALL_INTERACTION_SPECS, ALL_TEAM_SPECS, DND_MIME, DOCUMENT_VERSION, FLOW_SPEC, type FlowShape, type FlowSpec, INTERACTION_MODES, INTERACTION_MODE_SPECS, type InteractionGlyph, type InteractionMode, type InteractionModeSpec, type InteractionShape, type ParseResult, type Position, SAMPLE_DOCUMENT, type Size, type StrokeStyle, TEAM_TYPES, TEAM_TYPE_SPECS, type TeamNode, type TeamShape, type TeamType, type TeamTypeSpec, type TtDocument, canonicalize, createFlowShape, createInteractionShape, createTeamNode, dashArray, documentSchema, emptyDocument, flowSchema, interactionSchema, newId, parseDocument, serializeDocument, teamNodeSchema };
369
+ export { ALL_INTERACTION_SPECS, ALL_TEAM_SPECS, ANNOTATION_SPEC, type AnnotationSpec, DND_MIME, DOCUMENT_VERSION, FLOW_SPEC, type FlowShape, type FlowSpec, INTERACTION_MODES, INTERACTION_MODE_SPECS, type InteractionGlyph, type InteractionMode, type InteractionModeSpec, type InteractionShape, type ParseResult, type Position, SAMPLE_DOCUMENT, type Size, type StrokeStyle, TEAM_TYPES, TEAM_TYPE_SPECS, type TeamNode, type TeamShape, type TeamType, type TeamTypeSpec, type TextAnnotation, type TtDocument, annotationSchema, canonicalize, createFlowShape, createInteractionShape, createTeamNode, createTextAnnotation, dashArray, documentSchema, emptyDocument, flowSchema, interactionSchema, newId, parseDocument, serializeDocument, teamNodeSchema };
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var INTERACTION_MODES = [
14
14
  "x-as-a-service",
15
15
  "facilitating"
16
16
  ];
17
- var DOCUMENT_VERSION = 2;
17
+ var DOCUMENT_VERSION = 3;
18
18
 
19
19
  // src/notation.ts
20
20
  var TEAM_TYPE_SPECS = {
@@ -120,6 +120,11 @@ var FLOW_SPEC = {
120
120
  defaultSize: { width: 520, height: 64 },
121
121
  minSize: { width: 160, height: 36 }
122
122
  };
123
+ var ANNOTATION_SPEC = {
124
+ label: "Annotation",
125
+ defaultSize: { width: 200, height: 64 },
126
+ minSize: { width: 60, height: 30 }
127
+ };
123
128
  function dashArray(style, strokeWidth = 2) {
124
129
  switch (style) {
125
130
  case "dashed":
@@ -169,12 +174,20 @@ var flowSchema = z.object({
169
174
  position: positionSchema,
170
175
  size: sizeSchema
171
176
  });
177
+ var annotationSchema = z.object({
178
+ id: z.string().min(1),
179
+ text: z.string(),
180
+ position: positionSchema,
181
+ size: sizeSchema,
182
+ attachedTo: z.string().min(1).optional()
183
+ });
172
184
  var documentSchema = z.object({
173
185
  version: z.literal(DOCUMENT_VERSION),
174
186
  title: z.string(),
175
187
  nodes: z.array(teamNodeSchema),
176
188
  interactions: z.array(interactionSchema),
177
- flows: z.array(flowSchema)
189
+ flows: z.array(flowSchema),
190
+ annotations: z.array(annotationSchema)
178
191
  });
179
192
  function parseDocument(input) {
180
193
  const migrated = migrate(input);
@@ -199,6 +212,7 @@ function migrate(input) {
199
212
  (e) => e != null && typeof e === "object" && "position" in e && "size" in e
200
213
  ) : [];
201
214
  if (!Array.isArray(next.flows)) next.flows = [];
215
+ if (!Array.isArray(next.annotations)) next.annotations = [];
202
216
  return next;
203
217
  }
204
218
 
@@ -246,6 +260,16 @@ function normFlow(f) {
246
260
  if (f.label) out.label = f.label;
247
261
  return out;
248
262
  }
263
+ function normAnnotation(a) {
264
+ const out = {
265
+ id: a.id,
266
+ text: a.text,
267
+ position: normPosition(a.position),
268
+ size: normSize(a.size)
269
+ };
270
+ if (a.attachedTo) out.attachedTo = a.attachedTo;
271
+ return out;
272
+ }
249
273
  var byId = (a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
250
274
  function canonicalize(doc) {
251
275
  return {
@@ -253,12 +277,14 @@ function canonicalize(doc) {
253
277
  title: doc.title,
254
278
  nodes: [...doc.nodes].map(normNode).sort(byId),
255
279
  interactions: [...doc.interactions].map(normInteraction).sort(byId),
256
- flows: [...doc.flows].map(normFlow).sort(byId)
280
+ flows: [...doc.flows].map(normFlow).sort(byId),
281
+ annotations: [...doc.annotations].map(normAnnotation).sort(byId)
257
282
  };
258
283
  }
259
284
  function serializeDocument(doc, pretty = true) {
260
- const canonical = canonicalize(doc);
261
- return JSON.stringify(canonical, null, pretty ? 2 : 0);
285
+ const { annotations, ...canonical } = canonicalize(doc);
286
+ const output = annotations.length > 0 ? { ...canonical, annotations } : canonical;
287
+ return JSON.stringify(output, null, pretty ? 2 : 0);
262
288
  }
263
289
  function newId(prefix) {
264
290
  return `${prefix}_${nanoid(8)}`;
@@ -296,13 +322,23 @@ function createFlowShape(position, overrides = {}) {
296
322
  label: overrides.label ?? FLOW_SPEC.label
297
323
  };
298
324
  }
325
+ function createTextAnnotation(position, overrides = {}) {
326
+ return {
327
+ id: newId("ann"),
328
+ text: overrides.text ?? "",
329
+ position,
330
+ size: overrides.size ?? { ...ANNOTATION_SPEC.defaultSize },
331
+ attachedTo: overrides.attachedTo
332
+ };
333
+ }
299
334
  function emptyDocument(title = "Untitled team topology") {
300
335
  return {
301
336
  version: DOCUMENT_VERSION,
302
337
  title,
303
338
  nodes: [],
304
339
  interactions: [],
305
- flows: []
340
+ flows: [],
341
+ annotations: []
306
342
  };
307
343
  }
308
344
 
@@ -311,81 +347,73 @@ var s = TEAM_TYPE_SPECS;
311
347
  var i = INTERACTION_MODE_SPECS;
312
348
  var SAMPLE_DOCUMENT = {
313
349
  version: DOCUMENT_VERSION,
314
- title: "Online retail \u2014 team topology",
350
+ title: "Online shop \u2014 team topology",
315
351
  nodes: [
316
352
  {
317
- id: "team_enabling",
353
+ id: "team_test_automation",
318
354
  type: "enabling",
319
- label: "Agile Enablement",
320
- description: "Coaches teams on testing and continuous delivery practices.",
355
+ label: "Test Automation",
356
+ description: "Coaches stream-aligned teams in test automation, then steps back.",
321
357
  position: { x: 60, y: 150 },
322
358
  size: { ...s.enabling.defaultSize }
323
359
  },
324
360
  {
325
- id: "team_checkout",
361
+ id: "team_discovery",
326
362
  type: "stream-aligned",
327
- label: "Checkout Stream",
328
- description: "Owns the end-to-end checkout & payments journey.",
329
- position: { x: 320, y: 110 },
363
+ label: "Product Discovery",
364
+ description: "Owns search, browsing and product pages end-to-end.",
365
+ position: { x: 240, y: 202 },
330
366
  size: { ...s["stream-aligned"].defaultSize }
331
367
  },
332
368
  {
333
- id: "team_mobile",
369
+ id: "team_checkout",
334
370
  type: "stream-aligned",
335
- label: "Mobile Experience",
336
- description: "Owns the native mobile shopping experience.",
337
- position: { x: 700, y: 110 },
371
+ label: "Checkout & Payments",
372
+ description: "Owns the checkout and payment journey end-to-end.",
373
+ position: { x: 560, y: 202 },
338
374
  size: { ...s["stream-aligned"].defaultSize }
339
375
  },
340
376
  {
341
377
  id: "team_fraud",
342
378
  type: "complicated-subsystem",
343
- label: "Risk & Fraud Engine",
344
- description: "Specialist ML team owning real-time fraud scoring.",
345
- position: { x: 740, y: 320 },
379
+ label: "Fraud Detection",
380
+ description: "Specialists for the real-time fraud scoring model.",
381
+ position: { x: 870, y: 175 },
346
382
  size: { ...s["complicated-subsystem"].defaultSize }
347
383
  },
348
384
  {
349
385
  id: "team_platform",
350
386
  type: "platform",
351
- label: "Internal Developer Platform",
352
- description: "Self-service CI/CD, observability and runtime for all streams.",
353
- position: { x: 300, y: 540 },
354
- size: { ...s.platform.defaultSize }
387
+ label: "Cloud Platform",
388
+ description: "Self-service CI/CD, runtime and observability for all teams.",
389
+ position: { x: 240, y: 352 },
390
+ size: { width: 560, height: 110 }
355
391
  }
356
392
  ],
357
393
  interactions: [
358
394
  {
359
- id: "int_enable_checkout",
395
+ id: "int_testing_discovery",
360
396
  mode: "facilitating",
361
- label: "test automation",
362
- position: { x: 212, y: 158 },
397
+ position: { x: 168, y: 208 },
363
398
  size: { ...i.facilitating.defaultSize }
364
399
  },
365
400
  {
366
401
  id: "int_checkout_fraud",
367
402
  mode: "collaboration",
368
- label: "fraud rules discovery",
369
- position: { x: 566, y: 232 },
403
+ label: "fraud rules",
404
+ position: { x: 779, y: 214 },
370
405
  size: { ...i.collaboration.defaultSize }
371
406
  },
372
407
  {
373
- id: "int_platform_checkout",
374
- mode: "x-as-a-service",
375
- position: { x: 384, y: 396 },
376
- size: { ...i["x-as-a-service"].defaultSize }
377
- },
378
- {
379
- id: "int_platform_mobile",
408
+ id: "int_platform_discovery",
380
409
  mode: "x-as-a-service",
381
- position: { x: 612, y: 396 },
410
+ position: { x: 316, y: 286 },
382
411
  size: { ...i["x-as-a-service"].defaultSize }
383
412
  },
384
413
  {
385
- id: "int_fraud_mobile",
414
+ id: "int_platform_checkout",
386
415
  mode: "x-as-a-service",
387
- label: "risk scoring API",
388
- position: { x: 800, y: 238 },
416
+ position: { x: 636, y: 286 },
389
417
  size: { ...i["x-as-a-service"].defaultSize }
390
418
  }
391
419
  ],
@@ -393,12 +421,21 @@ var SAMPLE_DOCUMENT = {
393
421
  {
394
422
  id: "flow_main",
395
423
  label: "Flow of change",
396
- position: { x: 60, y: 712 },
397
- size: { width: 880, height: 60 }
424
+ position: { x: 60, y: 60 },
425
+ size: { width: 980, height: 56 }
426
+ }
427
+ ],
428
+ annotations: [
429
+ {
430
+ id: "ann_fraud_handover",
431
+ text: "Collaboration until the fraud rules are stable (Q3), then X-as-a-Service",
432
+ position: { x: 830, y: 350 },
433
+ size: { ...ANNOTATION_SPEC.defaultSize },
434
+ attachedTo: "int_checkout_fraud"
398
435
  }
399
436
  ]
400
437
  };
401
438
 
402
- export { ALL_INTERACTION_SPECS, ALL_TEAM_SPECS, DND_MIME, DOCUMENT_VERSION, FLOW_SPEC, INTERACTION_MODES, INTERACTION_MODE_SPECS, SAMPLE_DOCUMENT, TEAM_TYPES, TEAM_TYPE_SPECS, canonicalize, createFlowShape, createInteractionShape, createTeamNode, dashArray, documentSchema, emptyDocument, flowSchema, interactionSchema, newId, parseDocument, serializeDocument, teamNodeSchema };
439
+ export { ALL_INTERACTION_SPECS, ALL_TEAM_SPECS, ANNOTATION_SPEC, DND_MIME, DOCUMENT_VERSION, FLOW_SPEC, INTERACTION_MODES, INTERACTION_MODE_SPECS, SAMPLE_DOCUMENT, TEAM_TYPES, TEAM_TYPE_SPECS, annotationSchema, canonicalize, createFlowShape, createInteractionShape, createTeamNode, createTextAnnotation, dashArray, documentSchema, emptyDocument, flowSchema, interactionSchema, newId, parseDocument, serializeDocument, teamNodeSchema };
403
440
  //# sourceMappingURL=index.js.map
404
441
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts","../src/notation.ts","../src/schema.ts","../src/serialize.ts","../src/factory.ts","../src/sample.ts"],"names":["i","s"],"mappings":";;;;AASO,IAAM,QAAA,GAAW;AAKjB,IAAM,UAAA,GAAkC;AAAA,EAC7C,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACF;AAKO,IAAM,iBAAA,GAAgD;AAAA,EAC3D,eAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF;AAyDO,IAAM,gBAAA,GAAmB;;;ACdzB,IAAM,eAAA,GAAkD;AAAA,EAC7D,gBAAA,EAAkB;AAAA,IAChB,IAAA,EAAM,gBAAA;AAAA,IACN,KAAA,EAAO,gBAAA;AAAA,IACP,WAAA,EAAa,mEAAA;AAAA,IACb,KAAA,EAAO,yBAAA;AAAA,IACP,IAAA,EAAM,SAAA;AAAA,IACN,MAAA,EA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,GAAG,CAAA,CAAE,gBAAgB,EAAE,WAAA;AAAY,KAC7C;AAAA,IACA;AAAA,MACE,EAAA,EAAI,qBAAA;AAAA,MACJ,IAAA,EAAM,gBAAA;AAAA,MACN,QAAA,EAAU,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAI;AAAA,MAC3B,MAAM,EAAE,GAAG,CAAA,CAAE,gBAAgB,EAAE,WAAA;AAAY,KAC7C;AAAA,IACA;AAAA,MACE,EAAA,EAAI,kBAAA;AAAA,MACJ,IAAA,EAAM,gBAAA;AAAA,MACN,KAAA,EAAO,kBAAA;AAAA,MACP,QAAA,EAAU,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAI;AAAA,MAC3B,MAAM,EAAE,GAAG,CAAA,CAAE,gBAAgB,EAAE,WAAA;AAAY;AAC7C,GACF;AAAA,EACA,KAAA,EAAO;AAAA,IACL;AAAA,MACE,EAAA,EAAI,WAAA;AAAA,MACJ,KAAA,EAAO,gBAAA;AAAA,MACP,QAAA,EAAU,EAAE,CAAA,EAAG,EAAA,EAAI,GAAG,GAAA,EAAI;AAAA,MAC1B,IAAA,EAAM,EAAE,KAAA,EAAO,GAAA,EAAK,QAAQ,EAAA;AAAG;AACjC;AAEJ","file":"index.js","sourcesContent":["/**\n * Pure (DOM-free) domain types for the Team Topologies model.\n *\n * This module is the canonical representation of a diagram and must never\n * import from the rendering layer (`@xyflow/react`) or touch the DOM, so it\n * can be unit-tested in isolation and reused across views / exporters.\n */\n\n/** MIME type used when dragging a team type from the palette onto the canvas. */\nexport const DND_MIME = \"application/x-tt-team-type\";\n\n/** The four fundamental team types in Team Topologies. */\nexport type TeamType = \"stream-aligned\" | \"enabling\" | \"complicated-subsystem\" | \"platform\";\n\nexport const TEAM_TYPES: readonly TeamType[] = [\n \"stream-aligned\",\n \"enabling\",\n \"complicated-subsystem\",\n \"platform\",\n] as const;\n\n/** The three core team interaction modes in Team Topologies. */\nexport type InteractionMode = \"collaboration\" | \"x-as-a-service\" | \"facilitating\";\n\nexport const INTERACTION_MODES: readonly InteractionMode[] = [\n \"collaboration\",\n \"x-as-a-service\",\n \"facilitating\",\n] as const;\n\n/** Geometric size of a node in canvas units (px). Encodes cognitive load. */\nexport interface Size {\n width: number;\n height: number;\n}\n\n/** Position of a node on the canvas in canvas units (px). */\nexport interface Position {\n x: number;\n y: number;\n}\n\n/** A team node in the canonical document model. */\nexport interface TeamNode {\n id: string;\n type: TeamType;\n label: string;\n description?: string;\n position: Position;\n size: Size;\n fill?: string;\n stroke?: string;\n}\n\n/**\n * An interaction in the canonical document model.\n *\n * Per the official Team Topologies notation, an interaction is a placed,\n * resizable SHAPE (parallelogram / triangle / circle) overlaid on the boundary\n * between the teams it relates to — not a connecting line. The relationship is\n * therefore spatial (overlap), so there is no source/target reference.\n */\nexport interface InteractionShape {\n id: string;\n mode: InteractionMode;\n label?: string;\n position: Position;\n size: Size;\n fill?: string;\n stroke?: string;\n}\n\n/**\n * A \"flow of change\" guide: a placed, resizable arrow element. Lets you anchor\n * the implied left-to-right flow, and visualise several team groupings on one\n * canvas.\n */\nexport interface FlowShape {\n id: string;\n label?: string;\n position: Position;\n size: Size;\n}\n\n/** Current document schema version. Bump + add a migration when shape changes. */\nexport const DOCUMENT_VERSION = 2 as const;\n\n/**\n * A complete Team Topologies diagram. This is what gets serialised to JSON,\n * embedded into exported images, and encoded into share URLs.\n */\nexport interface TtDocument {\n version: typeof DOCUMENT_VERSION;\n title: string;\n nodes: TeamNode[];\n interactions: InteractionShape[];\n flows: FlowShape[];\n}\n","/**\n * The Team Topologies visual notation, encoded as data.\n *\n * Colours, shapes and stroke styles follow the official\n * \"Team-Shape-Templates\" specification published by Team Topologies\n * (https://github.com/TeamTopologies/Team-Shape-Templates):\n *\n * - Team shapes are SOLID outlines (long-lived structures).\n * - Interaction-mode shapes are 50% transparent with DASHED outlines\n * (short-lived interactions).\n * - Each element is distinguished by SHAPE as well as colour, so the\n * notation stays readable for people with colour-vision deficiency.\n *\n * This module is pure data — it must not import the rendering layer.\n */\n\nimport type { InteractionMode, Size, TeamType } from \"./types\";\n\nexport type TeamShape = \"rounded-rect-horizontal\" | \"rounded-rect-vertical\" | \"octagon\" | \"rect\";\n\nexport type InteractionGlyph = \"parallelogram\" | \"triangle\" | \"circle\";\n\nexport type StrokeStyle = \"solid\" | \"dashed\" | \"dotted\";\n\nexport interface TeamTypeSpec {\n type: TeamType;\n /** Short display name. */\n label: string;\n /** One-line purpose, shown in the palette and inspector. */\n description: string;\n shape: TeamShape;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n /** Default size when a node of this type is created. */\n defaultSize: Size;\n /** Minimum size enforced by the resizer. */\n minSize: Size;\n}\n\nexport interface InteractionModeSpec {\n mode: InteractionMode;\n label: string;\n description: string;\n shape: InteractionGlyph;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n /** Opacity for the interaction shape (short-lived → translucent). */\n opacity: number;\n /** Whether direction is semantically meaningful (the X-as-a-Service triangle). */\n directional: boolean;\n /** Default size when a shape of this mode is created. */\n defaultSize: Size;\n /** Minimum size enforced by the resizer. */\n minSize: Size;\n}\n\n/** The left-to-right \"flow of change\" guide, a placeable annotation element. */\nexport interface FlowSpec {\n label: string;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n defaultSize: Size;\n minSize: Size;\n}\n\nexport const TEAM_TYPE_SPECS: Record<TeamType, TeamTypeSpec> = {\n \"stream-aligned\": {\n type: \"stream-aligned\",\n label: \"Stream-aligned\",\n description: \"Aligned to a single, valuable stream of work; owns it end-to-end.\",\n shape: \"rounded-rect-horizontal\",\n fill: \"#FFEDB8\",\n stroke: \"#FFD966\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 240, height: 96 },\n minSize: { width: 140, height: 64 },\n },\n enabling: {\n type: \"enabling\",\n label: \"Enabling\",\n description:\n \"Helps stream-aligned teams acquire missing capabilities; coaches, then steps back.\",\n shape: \"rounded-rect-vertical\",\n fill: \"#DFBDCF\",\n stroke: \"#D09CB7\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 120, height: 200 },\n minSize: { width: 80, height: 120 },\n },\n \"complicated-subsystem\": {\n type: \"complicated-subsystem\",\n label: \"Complicated Subsystem\",\n description:\n \"Owns a part of the system needing deep specialist knowledge, reducing others' cognitive load.\",\n shape: \"octagon\",\n fill: \"#FFC08B\",\n stroke: \"#E88814\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 170, height: 150 },\n minSize: { width: 110, height: 100 },\n },\n platform: {\n type: \"platform\",\n label: \"Platform\",\n description:\n \"Provides internal self-service capabilities to reduce cognitive load for stream-aligned teams.\",\n shape: \"rect\",\n fill: \"#B7CDF1\",\n stroke: \"#6D9EEB\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 380, height: 130 },\n minSize: { width: 200, height: 90 },\n },\n};\n\nexport const INTERACTION_MODE_SPECS: Record<InteractionMode, InteractionModeSpec> = {\n collaboration: {\n mode: \"collaboration\",\n label: \"Collaboration\",\n description:\n \"Two teams work closely together for a defined period; high overhead, high discovery.\",\n shape: \"parallelogram\",\n fill: \"#C6BEDF\",\n stroke: \"#967EE2\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: false,\n defaultSize: { width: 112, height: 72 },\n minSize: { width: 60, height: 44 },\n },\n \"x-as-a-service\": {\n mode: \"x-as-a-service\",\n label: \"X-as-a-Service\",\n description:\n \"One team consumes something the other provides 'as a service'; minimal collaboration.\",\n shape: \"triangle\",\n fill: \"#B4B4B4\",\n stroke: \"#999696\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: true,\n defaultSize: { width: 88, height: 78 },\n minSize: { width: 54, height: 48 },\n },\n facilitating: {\n mode: \"facilitating\",\n label: \"Facilitating\",\n description:\n \"One team helps/coaches another to clear impediments and learn; sensing and discovery.\",\n shape: \"circle\",\n fill: \"#C9DFBE\",\n stroke: \"#78996B\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: false,\n defaultSize: { width: 84, height: 84 },\n minSize: { width: 48, height: 48 },\n },\n};\n\n/**\n * The \"flow of change\" guide — a placeable dashed arrow (left-to-right).\n * Not a team or interaction: a standalone annotation element.\n */\nexport const FLOW_SPEC: FlowSpec = {\n label: \"Flow of change\",\n fill: \"transparent\",\n stroke: \"#6b6459\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n defaultSize: { width: 520, height: 64 },\n minSize: { width: 160, height: 36 },\n};\n\n/** Maps a stroke style to an SVG/CSS dash array (empty string = solid). */\nexport function dashArray(style: StrokeStyle, strokeWidth = 2): string {\n switch (style) {\n case \"dashed\":\n return `${strokeWidth * 3} ${strokeWidth * 2}`;\n case \"dotted\":\n return `${strokeWidth} ${strokeWidth * 1.5}`;\n case \"solid\":\n default:\n return \"\";\n }\n}\n\nexport const ALL_TEAM_SPECS: readonly TeamTypeSpec[] = Object.values(TEAM_TYPE_SPECS);\nexport const ALL_INTERACTION_SPECS: readonly InteractionModeSpec[] =\n Object.values(INTERACTION_MODE_SPECS);\n","/**\n * Runtime validation for the document model using Zod.\n *\n * Anything entering the app from the outside world (imported files, share\n * URLs, localStorage) is parsed through {@link parseDocument} so malformed or\n * tampered data can never corrupt the editor state.\n */\n\nimport { z } from \"zod\";\nimport { DOCUMENT_VERSION, INTERACTION_MODES, TEAM_TYPES } from \"./types\";\nimport type { TtDocument } from \"./types\";\n\nconst teamTypeSchema = z.enum(TEAM_TYPES as unknown as [string, ...string[]]);\nconst interactionModeSchema = z.enum(INTERACTION_MODES as unknown as [string, ...string[]]);\n\nconst sizeSchema = z.object({\n width: z.number().finite().positive(),\n height: z.number().finite().positive(),\n});\n\nconst positionSchema = z.object({\n x: z.number().finite(),\n y: z.number().finite(),\n});\n\nconst hexColor = z.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, \"expected a hex colour\");\n\nexport const teamNodeSchema = z.object({\n id: z.string().min(1),\n type: teamTypeSchema,\n label: z.string(),\n description: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n fill: hexColor.optional(),\n stroke: hexColor.optional(),\n});\n\nexport const interactionSchema = z.object({\n id: z.string().min(1),\n mode: interactionModeSchema,\n label: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n fill: hexColor.optional(),\n stroke: hexColor.optional(),\n});\n\nexport const flowSchema = z.object({\n id: z.string().min(1),\n label: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n});\n\nexport const documentSchema = z.object({\n version: z.literal(DOCUMENT_VERSION),\n title: z.string(),\n nodes: z.array(teamNodeSchema),\n interactions: z.array(interactionSchema),\n flows: z.array(flowSchema),\n});\n\nexport type ParseResult = { ok: true; document: TtDocument } | { ok: false; error: string };\n\n/**\n * Validates and (if necessary) migrates unknown data into a {@link TtDocument}.\n * Returns a discriminated result rather than throwing so callers can show a\n * friendly message.\n */\nexport function parseDocument(input: unknown): ParseResult {\n const migrated = migrate(input);\n const result = documentSchema.safeParse(migrated);\n if (!result.success) {\n return {\n ok: false,\n error: result.error.issues\n .map((i) => `${i.path.join(\".\") || \"(root)\"}: ${i.message}`)\n .join(\"; \"),\n };\n }\n return { ok: true, document: result.data as TtDocument };\n}\n\n/**\n * Forward-migrates older document shapes to the current version. v1 modelled\n * interactions as edges (source/target, no geometry) and carried a\n * `showFlowOfChange` flag; v2 makes interactions placed shapes and adds `flows`.\n * Legacy edge-interactions can't be placed meaningfully, so they're dropped.\n */\nfunction migrate(input: unknown): unknown {\n if (input == null || typeof input !== \"object\") return input;\n const doc = input as Record<string, unknown>;\n const next: Record<string, unknown> = { ...doc };\n delete next.showFlowOfChange; // v1 flag, gone in v2\n next.version = DOCUMENT_VERSION;\n if (typeof next.title !== \"string\") next.title = \"Untitled team topology\";\n if (!Array.isArray(next.nodes)) next.nodes = [];\n // Keep only placed interaction shapes; drop legacy edges (no position/size).\n next.interactions = Array.isArray(next.interactions)\n ? next.interactions.filter(\n (e) => e != null && typeof e === \"object\" && \"position\" in e && \"size\" in e,\n )\n : [];\n if (!Array.isArray(next.flows)) next.flows = [];\n return next;\n}\n","/**\n * Deterministic serialisation of the document model.\n *\n * Producing byte-stable JSON (sorted arrays, fixed key order, rounded\n * coordinates) makes diagrams diff-friendly in version control and gives\n * stable share URLs / embedded payloads.\n */\n\nimport { DOCUMENT_VERSION } from \"./types\";\nimport type { FlowShape, InteractionShape, Position, Size, TeamNode, TtDocument } from \"./types\";\n\n/** Round to 2 decimals to strip floating-point drift from drag operations. */\nfunction round(n: number): number {\n return Math.round(n * 100) / 100;\n}\n\nfunction normPosition(p: Position): Position {\n return { x: round(p.x), y: round(p.y) };\n}\n\nfunction normSize(s: Size): Size {\n return { width: round(s.width), height: round(s.height) };\n}\n\n/** Drops undefined fields and applies a fixed key order to a node. */\nfunction normNode(n: TeamNode): TeamNode {\n const out: TeamNode = {\n id: n.id,\n type: n.type,\n label: n.label,\n position: normPosition(n.position),\n size: normSize(n.size),\n };\n if (n.description) out.description = n.description;\n if (n.fill) out.fill = n.fill;\n if (n.stroke) out.stroke = n.stroke;\n return out;\n}\n\nfunction normInteraction(e: InteractionShape): InteractionShape {\n const out: InteractionShape = {\n id: e.id,\n mode: e.mode,\n position: normPosition(e.position),\n size: normSize(e.size),\n };\n if (e.label) out.label = e.label;\n if (e.fill) out.fill = e.fill;\n if (e.stroke) out.stroke = e.stroke;\n return out;\n}\n\nfunction normFlow(f: FlowShape): FlowShape {\n const out: FlowShape = {\n id: f.id,\n position: normPosition(f.position),\n size: normSize(f.size),\n };\n if (f.label) out.label = f.label;\n return out;\n}\n\nconst byId = (a: { id: string }, b: { id: string }): number =>\n a.id < b.id ? -1 : a.id > b.id ? 1 : 0;\n\n/** Returns a canonicalised copy of a document (sorted, rounded, version-stamped). */\nexport function canonicalize(doc: TtDocument): TtDocument {\n return {\n version: DOCUMENT_VERSION,\n title: doc.title,\n nodes: [...doc.nodes].map(normNode).sort(byId),\n interactions: [...doc.interactions].map(normInteraction).sort(byId),\n flows: [...doc.flows].map(normFlow).sort(byId),\n };\n}\n\n/** Serialises a document to deterministic, pretty-printed JSON. */\nexport function serializeDocument(doc: TtDocument, pretty = true): string {\n const canonical = canonicalize(doc);\n return JSON.stringify(canonical, null, pretty ? 2 : 0);\n}\n","/**\n * Factory helpers for constructing well-formed model objects with the correct\n * notation defaults (sizes, labels). Kept DOM-free.\n */\n\nimport { nanoid } from \"nanoid\";\nimport { FLOW_SPEC, INTERACTION_MODE_SPECS, TEAM_TYPE_SPECS } from \"./notation\";\nimport type {\n FlowShape,\n InteractionMode,\n InteractionShape,\n Position,\n TeamNode,\n TeamType,\n TtDocument,\n} from \"./types\";\nimport { DOCUMENT_VERSION } from \"./types\";\n\nexport function newId(prefix: string): string {\n return `${prefix}_${nanoid(8)}`;\n}\n\n/** Creates a team node of the given type at a position, with notation defaults. */\nexport function createTeamNode(\n type: TeamType,\n position: Position,\n overrides: Partial<Omit<TeamNode, \"id\" | \"type\">> = {},\n): TeamNode {\n const spec = TEAM_TYPE_SPECS[type];\n return {\n id: newId(\"team\"),\n type,\n label: overrides.label ?? spec.label,\n description: overrides.description,\n position,\n size: overrides.size ?? { ...spec.defaultSize },\n fill: overrides.fill,\n stroke: overrides.stroke,\n };\n}\n\n/** Creates a placed interaction shape of the given mode, with notation defaults. */\nexport function createInteractionShape(\n mode: InteractionMode,\n position: Position,\n overrides: Partial<Omit<InteractionShape, \"id\" | \"mode\" | \"position\">> = {},\n): InteractionShape {\n const spec = INTERACTION_MODE_SPECS[mode];\n return {\n id: newId(\"int\"),\n mode,\n position,\n size: overrides.size ?? { ...spec.defaultSize },\n label: overrides.label,\n fill: overrides.fill,\n stroke: overrides.stroke,\n };\n}\n\n/** Creates a placed \"flow of change\" arrow, with notation defaults. */\nexport function createFlowShape(\n position: Position,\n overrides: Partial<Omit<FlowShape, \"id\" | \"position\">> = {},\n): FlowShape {\n return {\n id: newId(\"flow\"),\n position,\n size: overrides.size ?? { ...FLOW_SPEC.defaultSize },\n label: overrides.label ?? FLOW_SPEC.label,\n };\n}\n\n/** An empty document with sensible defaults. */\nexport function emptyDocument(title = \"Untitled team topology\"): TtDocument {\n return {\n version: DOCUMENT_VERSION,\n title,\n nodes: [],\n interactions: [],\n flows: [],\n };\n}\n","/**\n * A small but complete example diagram exercising all four team types, all three\n * interaction modes (as placed shapes overlaying the team boundaries) and a\n * flow-of-change element. Ids are fixed so the fixture serialises stably.\n */\n\nimport { DOCUMENT_VERSION } from \"./types\";\nimport type { TtDocument } from \"./types\";\nimport { INTERACTION_MODE_SPECS, TEAM_TYPE_SPECS } from \"./notation\";\n\nconst s = TEAM_TYPE_SPECS;\nconst i = INTERACTION_MODE_SPECS;\n\nexport const SAMPLE_DOCUMENT: TtDocument = {\n version: DOCUMENT_VERSION,\n title: \"Online retail — team topology\",\n nodes: [\n {\n id: \"team_enabling\",\n type: \"enabling\",\n label: \"Agile Enablement\",\n description: \"Coaches teams on testing and continuous delivery practices.\",\n position: { x: 60, y: 150 },\n size: { ...s.enabling.defaultSize },\n },\n {\n id: \"team_checkout\",\n type: \"stream-aligned\",\n label: \"Checkout Stream\",\n description: \"Owns the end-to-end checkout & payments journey.\",\n position: { x: 320, y: 110 },\n size: { ...s[\"stream-aligned\"].defaultSize },\n },\n {\n id: \"team_mobile\",\n type: \"stream-aligned\",\n label: \"Mobile Experience\",\n description: \"Owns the native mobile shopping experience.\",\n position: { x: 700, y: 110 },\n size: { ...s[\"stream-aligned\"].defaultSize },\n },\n {\n id: \"team_fraud\",\n type: \"complicated-subsystem\",\n label: \"Risk & Fraud Engine\",\n description: \"Specialist ML team owning real-time fraud scoring.\",\n position: { x: 740, y: 320 },\n size: { ...s[\"complicated-subsystem\"].defaultSize },\n },\n {\n id: \"team_platform\",\n type: \"platform\",\n label: \"Internal Developer Platform\",\n description: \"Self-service CI/CD, observability and runtime for all streams.\",\n position: { x: 300, y: 540 },\n size: { ...s.platform.defaultSize },\n },\n ],\n interactions: [\n {\n id: \"int_enable_checkout\",\n mode: \"facilitating\",\n label: \"test automation\",\n position: { x: 212, y: 158 },\n size: { ...i.facilitating.defaultSize },\n },\n {\n id: \"int_checkout_fraud\",\n mode: \"collaboration\",\n label: \"fraud rules discovery\",\n position: { x: 566, y: 232 },\n size: { ...i.collaboration.defaultSize },\n },\n {\n id: \"int_platform_checkout\",\n mode: \"x-as-a-service\",\n position: { x: 384, y: 396 },\n size: { ...i[\"x-as-a-service\"].defaultSize },\n },\n {\n id: \"int_platform_mobile\",\n mode: \"x-as-a-service\",\n position: { x: 612, y: 396 },\n size: { ...i[\"x-as-a-service\"].defaultSize },\n },\n {\n id: \"int_fraud_mobile\",\n mode: \"x-as-a-service\",\n label: \"risk scoring API\",\n position: { x: 800, y: 238 },\n size: { ...i[\"x-as-a-service\"].defaultSize },\n },\n ],\n flows: [\n {\n id: \"flow_main\",\n label: \"Flow of change\",\n position: { x: 60, y: 712 },\n size: { width: 880, height: 60 },\n },\n ],\n};\n"]}
1
+ {"version":3,"sources":["../src/types.ts","../src/notation.ts","../src/schema.ts","../src/serialize.ts","../src/factory.ts","../src/sample.ts"],"names":["i","s"],"mappings":";;;;AASO,IAAM,QAAA,GAAW;AAKjB,IAAM,UAAA,GAAkC;AAAA,EAC7C,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACF;AAKO,IAAM,iBAAA,GAAgD;AAAA,EAC3D,eAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF;AAuEO,IAAM,gBAAA,GAAmB;;;AC5BzB,IAAM,eAAA,GAAkD;AAAA,EAC7D,gBAAA,EAAkB;AAAA,IAChB,IAAA,EAAM,gBAAA;AAAA,IACN,KAAA,EAAO,gBAAA;AAAA,IACP,WAAA,EAAa,mEAAA;AAAA,IACb,KAAA,EAAO,yBAAA;AAAA,IACP,IAAA,EAAM,SAAA;AAAA,IACN,MAA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MACJ,IAAA,EAAM,eAAA;AAAA,MACN,KAAA,EAAO,aAAA;AAAA,MACP,QAAA,EAAU,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAI;AAAA,MAC3B,IAAA,EAAM,EAAE,GAAG,CAAA,CAAE,cAAc,WAAA;AAAY,KACzC;AAAA,IACA;AAAA,MACE,EAAA,EAAI,wBAAA;AAAA,MACJ,IAAA,EAAM,gBAAA;AAAA,MACN,QAAA,EAAU,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAI;AAAA,MAC3B,MAAM,EAAE,GAAG,CAAA,CAAE,gBAAgB,EAAE,WAAA;AAAY,KAC7C;AAAA,IACA;AAAA,MACE,EAAA,EAAI,uBAAA;AAAA,MACJ,IAAA,EAAM,gBAAA;AAAA,MACN,QAAA,EAAU,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAI;AAAA,MAC3B,MAAM,EAAE,GAAG,CAAA,CAAE,gBAAgB,EAAE,WAAA;AAAY;AAC7C,GACF;AAAA,EACA,KAAA,EAAO;AAAA,IACL;AAAA,MACE,EAAA,EAAI,WAAA;AAAA,MACJ,KAAA,EAAO,gBAAA;AAAA,MACP,QAAA,EAAU,EAAE,CAAA,EAAG,EAAA,EAAI,GAAG,EAAA,EAAG;AAAA,MACzB,IAAA,EAAM,EAAE,KAAA,EAAO,GAAA,EAAK,QAAQ,EAAA;AAAG;AACjC,GACF;AAAA,EACA,WAAA,EAAa;AAAA,IACX;AAAA,MACE,EAAA,EAAI,oBAAA;AAAA,MACJ,IAAA,EAAM,0EAAA;AAAA,MACN,QAAA,EAAU,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAI;AAAA,MAC3B,IAAA,EAAM,EAAE,GAAG,eAAA,CAAgB,WAAA,EAAY;AAAA,MACvC,UAAA,EAAY;AAAA;AACd;AAEJ","file":"index.js","sourcesContent":["/**\n * Pure (DOM-free) domain types for the Team Topologies model.\n *\n * This module is the canonical representation of a diagram and must never\n * import from the rendering layer (`@xyflow/react`) or touch the DOM, so it\n * can be unit-tested in isolation and reused across views / exporters.\n */\n\n/** MIME type used when dragging a team type from the palette onto the canvas. */\nexport const DND_MIME = \"application/x-tt-team-type\";\n\n/** The four fundamental team types in Team Topologies. */\nexport type TeamType = \"stream-aligned\" | \"enabling\" | \"complicated-subsystem\" | \"platform\";\n\nexport const TEAM_TYPES: readonly TeamType[] = [\n \"stream-aligned\",\n \"enabling\",\n \"complicated-subsystem\",\n \"platform\",\n] as const;\n\n/** The three core team interaction modes in Team Topologies. */\nexport type InteractionMode = \"collaboration\" | \"x-as-a-service\" | \"facilitating\";\n\nexport const INTERACTION_MODES: readonly InteractionMode[] = [\n \"collaboration\",\n \"x-as-a-service\",\n \"facilitating\",\n] as const;\n\n/** Geometric size of a node in canvas units (px). Encodes cognitive load. */\nexport interface Size {\n width: number;\n height: number;\n}\n\n/** Position of a node on the canvas in canvas units (px). */\nexport interface Position {\n x: number;\n y: number;\n}\n\n/** A team node in the canonical document model. */\nexport interface TeamNode {\n id: string;\n type: TeamType;\n label: string;\n description?: string;\n position: Position;\n size: Size;\n fill?: string;\n stroke?: string;\n}\n\n/**\n * An interaction in the canonical document model.\n *\n * Per the official Team Topologies notation, an interaction is a placed,\n * resizable SHAPE (parallelogram / triangle / circle) overlaid on the boundary\n * between the teams it relates to — not a connecting line. The relationship is\n * therefore spatial (overlap), so there is no source/target reference.\n */\nexport interface InteractionShape {\n id: string;\n mode: InteractionMode;\n label?: string;\n position: Position;\n size: Size;\n fill?: string;\n stroke?: string;\n}\n\n/**\n * A \"flow of change\" guide: a placed, resizable arrow element. Lets you anchor\n * the implied left-to-right flow, and visualise several team groupings on one\n * canvas.\n */\nexport interface FlowShape {\n id: string;\n label?: string;\n position: Position;\n size: Size;\n}\n\n/**\n * A free-text note beside the diagram (like a BPMN text annotation). It either\n * stands alone or is attached to exactly one team, interaction or flow, which\n * its dashed connector points at.\n */\nexport interface TextAnnotation {\n id: string;\n text: string;\n position: Position;\n size: Size;\n /** Id of the team, interaction or flow this annotation is attached to. */\n attachedTo?: string;\n}\n\n/** Current document schema version. Bump + add a migration when shape changes. */\nexport const DOCUMENT_VERSION = 3 as const;\n\n/**\n * A complete Team Topologies diagram. This is what gets serialised to JSON,\n * embedded into exported images, and encoded into share URLs.\n */\nexport interface TtDocument {\n version: typeof DOCUMENT_VERSION;\n title: string;\n nodes: TeamNode[];\n interactions: InteractionShape[];\n flows: FlowShape[];\n annotations: TextAnnotation[];\n}\n","/**\n * The Team Topologies visual notation, encoded as data.\n *\n * Colours, shapes and stroke styles follow the official\n * \"Team-Shape-Templates\" specification published by Team Topologies\n * (https://github.com/TeamTopologies/Team-Shape-Templates):\n *\n * - Team shapes are SOLID outlines (long-lived structures).\n * - Interaction-mode shapes are 50% transparent with DASHED outlines\n * (short-lived interactions).\n * - Each element is distinguished by SHAPE as well as colour, so the\n * notation stays readable for people with colour-vision deficiency.\n *\n * This module is pure data — it must not import the rendering layer.\n */\n\nimport type { InteractionMode, Size, TeamType } from \"./types\";\n\nexport type TeamShape = \"rounded-rect-horizontal\" | \"rounded-rect-vertical\" | \"octagon\" | \"rect\";\n\nexport type InteractionGlyph = \"parallelogram\" | \"triangle\" | \"circle\";\n\nexport type StrokeStyle = \"solid\" | \"dashed\" | \"dotted\";\n\nexport interface TeamTypeSpec {\n type: TeamType;\n /** Short display name. */\n label: string;\n /** One-line purpose, shown in the palette and inspector. */\n description: string;\n shape: TeamShape;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n /** Default size when a node of this type is created. */\n defaultSize: Size;\n /** Minimum size enforced by the resizer. */\n minSize: Size;\n}\n\nexport interface InteractionModeSpec {\n mode: InteractionMode;\n label: string;\n description: string;\n shape: InteractionGlyph;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n /** Opacity for the interaction shape (short-lived → translucent). */\n opacity: number;\n /** Whether direction is semantically meaningful (the X-as-a-Service triangle). */\n directional: boolean;\n /** Default size when a shape of this mode is created. */\n defaultSize: Size;\n /** Minimum size enforced by the resizer. */\n minSize: Size;\n}\n\n/** The left-to-right \"flow of change\" guide, a placeable annotation element. */\nexport interface FlowSpec {\n label: string;\n fill: string;\n stroke: string;\n strokeStyle: StrokeStyle;\n strokeWidth: number;\n defaultSize: Size;\n minSize: Size;\n}\n\nexport const TEAM_TYPE_SPECS: Record<TeamType, TeamTypeSpec> = {\n \"stream-aligned\": {\n type: \"stream-aligned\",\n label: \"Stream-aligned\",\n description: \"Aligned to a single, valuable stream of work; owns it end-to-end.\",\n shape: \"rounded-rect-horizontal\",\n fill: \"#FFEDB8\",\n stroke: \"#FFD966\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 240, height: 96 },\n minSize: { width: 140, height: 64 },\n },\n enabling: {\n type: \"enabling\",\n label: \"Enabling\",\n description:\n \"Helps stream-aligned teams acquire missing capabilities; coaches, then steps back.\",\n shape: \"rounded-rect-vertical\",\n fill: \"#DFBDCF\",\n stroke: \"#D09CB7\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 120, height: 200 },\n minSize: { width: 80, height: 120 },\n },\n \"complicated-subsystem\": {\n type: \"complicated-subsystem\",\n label: \"Complicated Subsystem\",\n description:\n \"Owns a part of the system needing deep specialist knowledge, reducing others' cognitive load.\",\n shape: \"octagon\",\n fill: \"#FFC08B\",\n stroke: \"#E88814\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 170, height: 150 },\n minSize: { width: 110, height: 100 },\n },\n platform: {\n type: \"platform\",\n label: \"Platform\",\n description:\n \"Provides internal self-service capabilities to reduce cognitive load for stream-aligned teams.\",\n shape: \"rect\",\n fill: \"#B7CDF1\",\n stroke: \"#6D9EEB\",\n strokeStyle: \"solid\",\n strokeWidth: 2,\n defaultSize: { width: 380, height: 130 },\n minSize: { width: 200, height: 90 },\n },\n};\n\nexport const INTERACTION_MODE_SPECS: Record<InteractionMode, InteractionModeSpec> = {\n collaboration: {\n mode: \"collaboration\",\n label: \"Collaboration\",\n description:\n \"Two teams work closely together for a defined period; high overhead, high discovery.\",\n shape: \"parallelogram\",\n fill: \"#C6BEDF\",\n stroke: \"#967EE2\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: false,\n defaultSize: { width: 112, height: 72 },\n minSize: { width: 60, height: 44 },\n },\n \"x-as-a-service\": {\n mode: \"x-as-a-service\",\n label: \"X-as-a-Service\",\n description:\n \"One team consumes something the other provides 'as a service'; minimal collaboration.\",\n shape: \"triangle\",\n fill: \"#B4B4B4\",\n stroke: \"#999696\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: true,\n defaultSize: { width: 88, height: 78 },\n minSize: { width: 54, height: 48 },\n },\n facilitating: {\n mode: \"facilitating\",\n label: \"Facilitating\",\n description:\n \"One team helps/coaches another to clear impediments and learn; sensing and discovery.\",\n shape: \"circle\",\n fill: \"#C9DFBE\",\n stroke: \"#78996B\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n opacity: 0.5,\n directional: false,\n defaultSize: { width: 84, height: 84 },\n minSize: { width: 48, height: 48 },\n },\n};\n\n/**\n * The \"flow of change\" guide — a placeable dashed arrow (left-to-right).\n * Not a team or interaction: a standalone annotation element.\n */\nexport const FLOW_SPEC: FlowSpec = {\n label: \"Flow of change\",\n fill: \"transparent\",\n stroke: \"#6b6459\",\n strokeStyle: \"dashed\",\n strokeWidth: 2,\n defaultSize: { width: 520, height: 64 },\n minSize: { width: 160, height: 36 },\n};\n\n/**\n * A text annotation — not part of the Team Topologies notation, so it carries\n * no colours here; the renderer draws it in the neutral brand ink.\n */\nexport interface AnnotationSpec {\n label: string;\n defaultSize: Size;\n minSize: Size;\n}\n\nexport const ANNOTATION_SPEC: AnnotationSpec = {\n label: \"Annotation\",\n defaultSize: { width: 200, height: 64 },\n minSize: { width: 60, height: 30 },\n};\n\n/** Maps a stroke style to an SVG/CSS dash array (empty string = solid). */\nexport function dashArray(style: StrokeStyle, strokeWidth = 2): string {\n switch (style) {\n case \"dashed\":\n return `${strokeWidth * 3} ${strokeWidth * 2}`;\n case \"dotted\":\n return `${strokeWidth} ${strokeWidth * 1.5}`;\n case \"solid\":\n default:\n return \"\";\n }\n}\n\nexport const ALL_TEAM_SPECS: readonly TeamTypeSpec[] = Object.values(TEAM_TYPE_SPECS);\nexport const ALL_INTERACTION_SPECS: readonly InteractionModeSpec[] =\n Object.values(INTERACTION_MODE_SPECS);\n","/**\n * Runtime validation for the document model using Zod.\n *\n * Anything entering the app from the outside world (imported files, share\n * URLs, localStorage) is parsed through {@link parseDocument} so malformed or\n * tampered data can never corrupt the editor state.\n */\n\nimport { z } from \"zod\";\nimport { DOCUMENT_VERSION, INTERACTION_MODES, TEAM_TYPES } from \"./types\";\nimport type { TtDocument } from \"./types\";\n\nconst teamTypeSchema = z.enum(TEAM_TYPES as unknown as [string, ...string[]]);\nconst interactionModeSchema = z.enum(INTERACTION_MODES as unknown as [string, ...string[]]);\n\nconst sizeSchema = z.object({\n width: z.number().finite().positive(),\n height: z.number().finite().positive(),\n});\n\nconst positionSchema = z.object({\n x: z.number().finite(),\n y: z.number().finite(),\n});\n\nconst hexColor = z.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, \"expected a hex colour\");\n\nexport const teamNodeSchema = z.object({\n id: z.string().min(1),\n type: teamTypeSchema,\n label: z.string(),\n description: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n fill: hexColor.optional(),\n stroke: hexColor.optional(),\n});\n\nexport const interactionSchema = z.object({\n id: z.string().min(1),\n mode: interactionModeSchema,\n label: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n fill: hexColor.optional(),\n stroke: hexColor.optional(),\n});\n\nexport const flowSchema = z.object({\n id: z.string().min(1),\n label: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n});\n\nexport const annotationSchema = z.object({\n id: z.string().min(1),\n text: z.string(),\n position: positionSchema,\n size: sizeSchema,\n attachedTo: z.string().min(1).optional(),\n});\n\nexport const documentSchema = z.object({\n version: z.literal(DOCUMENT_VERSION),\n title: z.string(),\n nodes: z.array(teamNodeSchema),\n interactions: z.array(interactionSchema),\n flows: z.array(flowSchema),\n annotations: z.array(annotationSchema),\n});\n\nexport type ParseResult = { ok: true; document: TtDocument } | { ok: false; error: string };\n\n/**\n * Validates and (if necessary) migrates unknown data into a {@link TtDocument}.\n * Returns a discriminated result rather than throwing so callers can show a\n * friendly message.\n */\nexport function parseDocument(input: unknown): ParseResult {\n const migrated = migrate(input);\n const result = documentSchema.safeParse(migrated);\n if (!result.success) {\n return {\n ok: false,\n error: result.error.issues\n .map((i) => `${i.path.join(\".\") || \"(root)\"}: ${i.message}`)\n .join(\"; \"),\n };\n }\n return { ok: true, document: result.data as TtDocument };\n}\n\n/**\n * Forward-migrates older document shapes to the current version. v1 modelled\n * interactions as edges (source/target, no geometry) and carried a\n * `showFlowOfChange` flag; v2 makes interactions placed shapes and adds `flows`;\n * v3 adds `annotations`. Legacy edge-interactions can't be placed meaningfully,\n * so they're dropped.\n */\nfunction migrate(input: unknown): unknown {\n if (input == null || typeof input !== \"object\") return input;\n const doc = input as Record<string, unknown>;\n const next: Record<string, unknown> = { ...doc };\n delete next.showFlowOfChange; // v1 flag, gone in v2\n next.version = DOCUMENT_VERSION;\n if (typeof next.title !== \"string\") next.title = \"Untitled team topology\";\n if (!Array.isArray(next.nodes)) next.nodes = [];\n // Keep only placed interaction shapes; drop legacy edges (no position/size).\n next.interactions = Array.isArray(next.interactions)\n ? next.interactions.filter(\n (e) => e != null && typeof e === \"object\" && \"position\" in e && \"size\" in e,\n )\n : [];\n if (!Array.isArray(next.flows)) next.flows = [];\n if (!Array.isArray(next.annotations)) next.annotations = [];\n return next;\n}\n","/**\n * Deterministic serialisation of the document model.\n *\n * Producing byte-stable JSON (sorted arrays, fixed key order, rounded\n * coordinates) makes diagrams diff-friendly in version control and gives\n * stable share URLs / embedded payloads.\n */\n\nimport { DOCUMENT_VERSION } from \"./types\";\nimport type {\n FlowShape,\n InteractionShape,\n Position,\n Size,\n TeamNode,\n TextAnnotation,\n TtDocument,\n} from \"./types\";\n\n/** Round to 2 decimals to strip floating-point drift from drag operations. */\nfunction round(n: number): number {\n return Math.round(n * 100) / 100;\n}\n\nfunction normPosition(p: Position): Position {\n return { x: round(p.x), y: round(p.y) };\n}\n\nfunction normSize(s: Size): Size {\n return { width: round(s.width), height: round(s.height) };\n}\n\n/** Drops undefined fields and applies a fixed key order to a node. */\nfunction normNode(n: TeamNode): TeamNode {\n const out: TeamNode = {\n id: n.id,\n type: n.type,\n label: n.label,\n position: normPosition(n.position),\n size: normSize(n.size),\n };\n if (n.description) out.description = n.description;\n if (n.fill) out.fill = n.fill;\n if (n.stroke) out.stroke = n.stroke;\n return out;\n}\n\nfunction normInteraction(e: InteractionShape): InteractionShape {\n const out: InteractionShape = {\n id: e.id,\n mode: e.mode,\n position: normPosition(e.position),\n size: normSize(e.size),\n };\n if (e.label) out.label = e.label;\n if (e.fill) out.fill = e.fill;\n if (e.stroke) out.stroke = e.stroke;\n return out;\n}\n\nfunction normFlow(f: FlowShape): FlowShape {\n const out: FlowShape = {\n id: f.id,\n position: normPosition(f.position),\n size: normSize(f.size),\n };\n if (f.label) out.label = f.label;\n return out;\n}\n\nfunction normAnnotation(a: TextAnnotation): TextAnnotation {\n const out: TextAnnotation = {\n id: a.id,\n text: a.text,\n position: normPosition(a.position),\n size: normSize(a.size),\n };\n if (a.attachedTo) out.attachedTo = a.attachedTo;\n return out;\n}\n\nconst byId = (a: { id: string }, b: { id: string }): number =>\n a.id < b.id ? -1 : a.id > b.id ? 1 : 0;\n\n/** Returns a canonicalised copy of a document (sorted, rounded, version-stamped). */\nexport function canonicalize(doc: TtDocument): TtDocument {\n return {\n version: DOCUMENT_VERSION,\n title: doc.title,\n nodes: [...doc.nodes].map(normNode).sort(byId),\n interactions: [...doc.interactions].map(normInteraction).sort(byId),\n flows: [...doc.flows].map(normFlow).sort(byId),\n annotations: [...doc.annotations].map(normAnnotation).sort(byId),\n };\n}\n\n/**\n * Serialises a document to deterministic, pretty-printed JSON. An empty\n * `annotations` list is left out, so re-saving a model that has no annotations\n * changes nothing but its version stamp.\n */\nexport function serializeDocument(doc: TtDocument, pretty = true): string {\n const { annotations, ...canonical } = canonicalize(doc);\n const output = annotations.length > 0 ? { ...canonical, annotations } : canonical;\n return JSON.stringify(output, null, pretty ? 2 : 0);\n}\n","/**\n * Factory helpers for constructing well-formed model objects with the correct\n * notation defaults (sizes, labels). Kept DOM-free.\n */\n\nimport { nanoid } from \"nanoid\";\nimport { ANNOTATION_SPEC, FLOW_SPEC, INTERACTION_MODE_SPECS, TEAM_TYPE_SPECS } from \"./notation\";\nimport type {\n FlowShape,\n InteractionMode,\n InteractionShape,\n Position,\n TeamNode,\n TeamType,\n TextAnnotation,\n TtDocument,\n} from \"./types\";\nimport { DOCUMENT_VERSION } from \"./types\";\n\nexport function newId(prefix: string): string {\n return `${prefix}_${nanoid(8)}`;\n}\n\n/** Creates a team node of the given type at a position, with notation defaults. */\nexport function createTeamNode(\n type: TeamType,\n position: Position,\n overrides: Partial<Omit<TeamNode, \"id\" | \"type\">> = {},\n): TeamNode {\n const spec = TEAM_TYPE_SPECS[type];\n return {\n id: newId(\"team\"),\n type,\n label: overrides.label ?? spec.label,\n description: overrides.description,\n position,\n size: overrides.size ?? { ...spec.defaultSize },\n fill: overrides.fill,\n stroke: overrides.stroke,\n };\n}\n\n/** Creates a placed interaction shape of the given mode, with notation defaults. */\nexport function createInteractionShape(\n mode: InteractionMode,\n position: Position,\n overrides: Partial<Omit<InteractionShape, \"id\" | \"mode\" | \"position\">> = {},\n): InteractionShape {\n const spec = INTERACTION_MODE_SPECS[mode];\n return {\n id: newId(\"int\"),\n mode,\n position,\n size: overrides.size ?? { ...spec.defaultSize },\n label: overrides.label,\n fill: overrides.fill,\n stroke: overrides.stroke,\n };\n}\n\n/** Creates a placed \"flow of change\" arrow, with notation defaults. */\nexport function createFlowShape(\n position: Position,\n overrides: Partial<Omit<FlowShape, \"id\" | \"position\">> = {},\n): FlowShape {\n return {\n id: newId(\"flow\"),\n position,\n size: overrides.size ?? { ...FLOW_SPEC.defaultSize },\n label: overrides.label ?? FLOW_SPEC.label,\n };\n}\n\n/** Creates a text annotation, optionally attached to a team, interaction or flow. */\nexport function createTextAnnotation(\n position: Position,\n overrides: Partial<Omit<TextAnnotation, \"id\" | \"position\">> = {},\n): TextAnnotation {\n return {\n id: newId(\"ann\"),\n text: overrides.text ?? \"\",\n position,\n size: overrides.size ?? { ...ANNOTATION_SPEC.defaultSize },\n attachedTo: overrides.attachedTo,\n };\n}\n\n/** An empty document with sensible defaults. */\nexport function emptyDocument(title = \"Untitled team topology\"): TtDocument {\n return {\n version: DOCUMENT_VERSION,\n title,\n nodes: [],\n interactions: [],\n flows: [],\n annotations: [],\n };\n}\n","/**\n * A small but complete example diagram exercising all four team types, all three\n * interaction modes (as placed shapes overlaying the team boundaries), a\n * flow-of-change element and an attached annotation. Ids are fixed so the\n * fixture serialises stably.\n */\n\nimport { DOCUMENT_VERSION } from \"./types\";\nimport type { TtDocument } from \"./types\";\nimport { ANNOTATION_SPEC, INTERACTION_MODE_SPECS, TEAM_TYPE_SPECS } from \"./notation\";\n\nconst s = TEAM_TYPE_SPECS;\nconst i = INTERACTION_MODE_SPECS;\n\nexport const SAMPLE_DOCUMENT: TtDocument = {\n version: DOCUMENT_VERSION,\n title: \"Online shop — team topology\",\n nodes: [\n {\n id: \"team_test_automation\",\n type: \"enabling\",\n label: \"Test Automation\",\n description: \"Coaches stream-aligned teams in test automation, then steps back.\",\n position: { x: 60, y: 150 },\n size: { ...s.enabling.defaultSize },\n },\n {\n id: \"team_discovery\",\n type: \"stream-aligned\",\n label: \"Product Discovery\",\n description: \"Owns search, browsing and product pages end-to-end.\",\n position: { x: 240, y: 202 },\n size: { ...s[\"stream-aligned\"].defaultSize },\n },\n {\n id: \"team_checkout\",\n type: \"stream-aligned\",\n label: \"Checkout & Payments\",\n description: \"Owns the checkout and payment journey end-to-end.\",\n position: { x: 560, y: 202 },\n size: { ...s[\"stream-aligned\"].defaultSize },\n },\n {\n id: \"team_fraud\",\n type: \"complicated-subsystem\",\n label: \"Fraud Detection\",\n description: \"Specialists for the real-time fraud scoring model.\",\n position: { x: 870, y: 175 },\n size: { ...s[\"complicated-subsystem\"].defaultSize },\n },\n {\n id: \"team_platform\",\n type: \"platform\",\n label: \"Cloud Platform\",\n description: \"Self-service CI/CD, runtime and observability for all teams.\",\n position: { x: 240, y: 352 },\n size: { width: 560, height: 110 },\n },\n ],\n interactions: [\n {\n id: \"int_testing_discovery\",\n mode: \"facilitating\",\n position: { x: 168, y: 208 },\n size: { ...i.facilitating.defaultSize },\n },\n {\n id: \"int_checkout_fraud\",\n mode: \"collaboration\",\n label: \"fraud rules\",\n position: { x: 779, y: 214 },\n size: { ...i.collaboration.defaultSize },\n },\n {\n id: \"int_platform_discovery\",\n mode: \"x-as-a-service\",\n position: { x: 316, y: 286 },\n size: { ...i[\"x-as-a-service\"].defaultSize },\n },\n {\n id: \"int_platform_checkout\",\n mode: \"x-as-a-service\",\n position: { x: 636, y: 286 },\n size: { ...i[\"x-as-a-service\"].defaultSize },\n },\n ],\n flows: [\n {\n id: \"flow_main\",\n label: \"Flow of change\",\n position: { x: 60, y: 60 },\n size: { width: 980, height: 56 },\n },\n ],\n annotations: [\n {\n id: \"ann_fraud_handover\",\n text: \"Collaboration until the fraud rules are stable (Q3), then X-as-a-Service\",\n position: { x: 830, y: 350 },\n size: { ...ANNOTATION_SPEC.defaultSize },\n attachedTo: \"int_checkout_fraud\",\n },\n ],\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miragon/team-topologies-schema-model",
3
- "version": "0.7.1",
3
+ "version": "0.9.0",
4
4
  "description": "The Team Topologies data model with types, the notation specification, runtime validation, migrations and deterministic JSON serialization.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -42,7 +42,7 @@
42
42
  "devDependencies": {
43
43
  "tsup": "8.5.1",
44
44
  "typescript": "6.0.3",
45
- "vitest": "5.0.1",
45
+ "vitest": "5.0.2",
46
46
  "zod": "4.6.5"
47
47
  }
48
48
  }