@miragon/team-topologies-schema-model 0.10.0 → 0.11.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.
@@ -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;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,EACA,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,UAAA;AAAA,IACN,KAAA,EAAO,UAAA;AAAA,IACP,WAAA,EACE,oFAAA;AAAA,IACF,KAAA,EAAO,uBAAA;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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N,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"]}
1
+ {"version":3,"sources":["../src/types.ts","../src/notation.ts","../src/ids.ts","../src/schema.ts","../src/foreign.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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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 * The id rules of a Team Topologies document. Besides the elements a document lists, a diagram\n * holds parts it never writes down: the diagram itself and the connector of every annotation. They\n * take ids of their own, so no element may use one of them; otherwise opening the file would fail\n * halfway, with the previous diagram already gone.\n */\n\n/** The id of the diagram itself (the canvas root of the renderer). */\nexport const DIAGRAM_ROOT_ID = \"tt-root\";\n\n/** diagram-js names the roots it creates on its own `__implicitroot_<n>`. */\nconst ENGINE_ROOT_ID_PREFIX = \"__implicitroot\";\n\n/** Connectors are not stored: an annotation's connector derives its id from the annotation. */\nexport function associationId(annotationId: string): string {\n return `assoc_${annotationId}`;\n}\n\nexport interface DocumentIdProblem {\n /** Where the offending id sits, e.g. `[\"nodes\", 2, \"id\"]`. */\n path: (string | number)[];\n message: string;\n}\n\nconst COLLECTIONS = [\"nodes\", \"interactions\", \"flows\", \"annotations\"] as const;\n\ntype DocumentElements = Record<(typeof COLLECTIONS)[number], readonly { id: string }[]>;\n\n/**\n * Every id of the document that would collide on the canvas: a duplicate, the diagram's own id, a\n * diagram-js root id, or the id of an annotation's connector.\n */\nexport function documentIdProblems(doc: DocumentElements): DocumentIdProblem[] {\n const problems: DocumentIdProblem[] = [];\n const connectorIds = new Map(\n doc.annotations.map((annotation) => [associationId(annotation.id), annotation.id]),\n );\n const seen = new Set<string>();\n for (const collection of COLLECTIONS) {\n doc[collection].forEach((element, index) => {\n const path = [collection, index, \"id\"];\n const { id } = element;\n if (seen.has(id)) {\n problems.push({\n path,\n message: `duplicate id \"${id}\"; ids must be unique across nodes, interactions, flows and annotations`,\n });\n }\n seen.add(id);\n if (id === DIAGRAM_ROOT_ID) {\n problems.push({ path, message: `\"${id}\" is reserved for the diagram itself` });\n } else if (id.startsWith(ENGINE_ROOT_ID_PREFIX)) {\n problems.push({\n path,\n message: `ids starting with \"${ENGINE_ROOT_ID_PREFIX}\" are reserved`,\n });\n }\n const annotationId = connectorIds.get(id);\n if (annotationId !== undefined) {\n problems.push({\n path,\n message: `\"${id}\" is reserved for the connector of annotation \"${annotationId}\"`,\n });\n }\n });\n }\n return problems;\n}\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. Fields the schema does not\n * know pass through untouched (see `foreign.ts`), so another tool's data\n * survives a save.\n */\n\nimport { z } from \"zod\";\nimport { documentIdProblems } from \"./ids\";\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.looseObject({\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.looseObject({\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.looseObject({\n id: z.string().min(1),\n label: z.string().optional(),\n position: positionSchema,\n size: sizeSchema,\n});\n\nexport const annotationSchema = z.looseObject({\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\n .looseObject({\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 .superRefine((document, context) => {\n for (const { path, message } of documentIdProblems(document)) {\n context.addIssue({ code: \"custom\", path, message });\n }\n });\n\n/** One reason a document is invalid, at the path of the offending value. */\nexport interface DocumentIssue {\n path: (string | number)[];\n message: string;\n}\n\nexport type ParseResult =\n { ok: true; document: TtDocument } | { ok: false; error: string; issues: DocumentIssue[] };\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, or point at each offending value (`issues`).\n */\nexport function parseDocument(input: unknown): ParseResult {\n const migrated = migrate(input);\n const result = documentSchema.safeParse(migrated);\n if (!result.success) {\n const issues = result.error.issues.map((issue) => ({\n path: issue.path.filter((key): key is string | number => typeof key !== \"symbol\"),\n message: issue.message,\n }));\n return {\n ok: false,\n error: issues.map((i) => `${i.path.join(\".\") || \"(root)\"}: ${i.message}`).join(\"; \"),\n issues,\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 * Fields a document carries that this modeler does not know, such as a vendor's `\"x-vendor\"` on a\n * team. They are kept through open and save, written after the known fields and sorted, so another\n * tool's data survives an edit in the modeler and the output stays deterministic.\n */\n\nexport const DOCUMENT_FIELDS = [\n \"version\",\n \"title\",\n \"nodes\",\n \"interactions\",\n \"flows\",\n \"annotations\",\n] as const;\nexport const TEAM_NODE_FIELDS = [\n \"id\",\n \"type\",\n \"label\",\n \"description\",\n \"position\",\n \"size\",\n \"fill\",\n \"stroke\",\n] as const;\nexport const INTERACTION_FIELDS = [\n \"id\",\n \"mode\",\n \"label\",\n \"position\",\n \"size\",\n \"fill\",\n \"stroke\",\n] as const;\nexport const FLOW_FIELDS = [\"id\", \"label\", \"position\", \"size\"] as const;\nexport const ANNOTATION_FIELDS = [\"id\", \"text\", \"position\", \"size\", \"attachedTo\"] as const;\n\n/** Unknown fields by name, sorted, with their values in canonical form. */\nexport type ForeignFields = Readonly<Record<string, unknown>>;\n\n/** JSON objects have no key order, so nested keys are sorted too: equal data, equal bytes. */\nfunction canonicalValue(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(canonicalValue);\n if (value === null || typeof value !== \"object\") return value;\n const record = value as Record<string, unknown>;\n return Object.fromEntries(\n Object.keys(record)\n .filter((key) => record[key] !== undefined)\n .sort()\n .map((key) => [key, canonicalValue(record[key])]),\n );\n}\n\n/** The fields of `value` outside `knownFields`, or undefined when there are none. */\nexport function foreignFields(\n value: object,\n knownFields: readonly string[],\n): ForeignFields | undefined {\n const record = value as Record<string, unknown>;\n const names = Object.keys(record)\n .filter((name) => !knownFields.includes(name) && record[name] !== undefined)\n .sort();\n if (names.length === 0) return undefined;\n return Object.fromEntries(names.map((name) => [name, canonicalValue(record[name])]));\n}\n\n/**\n * `known` followed by the foreign fields of `source`. Built from entries, never by assignment, so\n * a field named `__proto__` stays a field instead of replacing the prototype.\n */\nexport function withForeignFields<T extends object>(\n known: T,\n source: object | undefined,\n knownFields: readonly string[],\n): T {\n const foreign = source ? foreignFields(source, knownFields) : undefined;\n if (!foreign) return known;\n return Object.fromEntries([...Object.entries(known), ...Object.entries(foreign)]) as T;\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 {\n ANNOTATION_FIELDS,\n DOCUMENT_FIELDS,\n FLOW_FIELDS,\n INTERACTION_FIELDS,\n TEAM_NODE_FIELDS,\n withForeignFields,\n} from \"./foreign\";\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 withForeignFields(out, n, TEAM_NODE_FIELDS);\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 withForeignFields(out, e, INTERACTION_FIELDS);\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 withForeignFields(out, f, FLOW_FIELDS);\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 withForeignFields(out, a, ANNOTATION_FIELDS);\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/**\n * Returns a canonicalised copy of a document (sorted, rounded, version-stamped). Fields the\n * modeler does not know follow the known ones, sorted by name.\n */\nexport function canonicalize(doc: TtDocument): TtDocument {\n return withForeignFields(\n {\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 doc,\n DOCUMENT_FIELDS,\n );\n}\n\n/**\n * Serialises a document to deterministic JSON. An empty `annotations` list is left out, so\n * re-saving a model that has no annotations changes nothing but its version stamp. The pretty\n * form is the file on disk and ends with a line break, like the files editors and Git expect;\n * the compact form (share links, local storage) has none.\n */\nexport function serializeDocument(doc: TtDocument, pretty = true): string {\n const canonical = canonicalize(doc);\n const output =\n canonical.annotations.length > 0\n ? canonical\n : Object.fromEntries(Object.entries(canonical).filter(([key]) => key !== \"annotations\"));\n return pretty ? `${JSON.stringify(output, null, 2)}\\n` : JSON.stringify(output);\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. The stream-aligned teams\n * are stacked as parallel lanes along the flow of change, as in the Team\n * Topologies book: side by side on the flow they would read as hand-offs. Ids are\n * fixed so the 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\nconst LANE_WIDTH = 600;\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: 40, y: 150 },\n size: { width: s.enabling.defaultSize.width, height: 222 },\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: 220, y: 150 },\n size: { width: LANE_WIDTH, height: s[\"stream-aligned\"].defaultSize.height },\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: 220, y: 276 },\n size: { width: LANE_WIDTH, height: s[\"stream-aligned\"].defaultSize.height },\n },\n {\n id: \"team_fulfilment\",\n type: \"stream-aligned\",\n label: \"Order Fulfilment\",\n description: \"Owns delivery, tracking and returns end-to-end.\",\n position: { x: 220, y: 402 },\n size: { width: LANE_WIDTH, height: s[\"stream-aligned\"].defaultSize.height },\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: 880, y: 249 },\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: 220, y: 552 },\n size: { width: LANE_WIDTH, height: 110 },\n },\n ],\n interactions: [\n {\n id: \"int_testing_discovery\",\n mode: \"facilitating\",\n position: { x: 148, y: 156 },\n size: { ...i.facilitating.defaultSize },\n },\n {\n id: \"int_testing_checkout\",\n mode: \"facilitating\",\n position: { x: 148, y: 282 },\n size: { ...i.facilitating.defaultSize },\n },\n {\n id: \"int_checkout_fraud\",\n mode: \"collaboration\",\n label: \"fraud rules\",\n position: { x: 794, y: 288 },\n size: { ...i.collaboration.defaultSize },\n },\n {\n id: \"int_platform_fulfilment\",\n mode: \"x-as-a-service\",\n position: { x: 476, y: 486 },\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: 40, y: 40 },\n size: { width: 1010, 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: 880, y: 423 },\n size: { ...ANNOTATION_SPEC.defaultSize },\n attachedTo: \"int_checkout_fraud\",\n },\n ],\n};\n"]}
package/dist/index.d.cts CHANGED
@@ -182,7 +182,9 @@ declare const ALL_INTERACTION_SPECS: readonly InteractionModeSpec[];
182
182
  *
183
183
  * Anything entering the app from the outside world (imported files, share
184
184
  * URLs, localStorage) is parsed through {@link parseDocument} so malformed or
185
- * tampered data can never corrupt the editor state.
185
+ * tampered data can never corrupt the editor state. Fields the schema does not
186
+ * know pass through untouched (see `foreign.ts`), so another tool's data
187
+ * survives a save.
186
188
  */
187
189
 
188
190
  declare const teamNodeSchema: z.ZodObject<{
@@ -202,7 +204,7 @@ declare const teamNodeSchema: z.ZodObject<{
202
204
  }, z.core.$strip>;
203
205
  fill: z.ZodOptional<z.ZodString>;
204
206
  stroke: z.ZodOptional<z.ZodString>;
205
- }, z.core.$strip>;
207
+ }, z.core.$loose>;
206
208
  declare const interactionSchema: z.ZodObject<{
207
209
  id: z.ZodString;
208
210
  mode: z.ZodEnum<{
@@ -219,7 +221,7 @@ declare const interactionSchema: z.ZodObject<{
219
221
  }, z.core.$strip>;
220
222
  fill: z.ZodOptional<z.ZodString>;
221
223
  stroke: z.ZodOptional<z.ZodString>;
222
- }, z.core.$strip>;
224
+ }, z.core.$loose>;
223
225
  declare const flowSchema: z.ZodObject<{
224
226
  id: z.ZodString;
225
227
  label: z.ZodOptional<z.ZodString>;
@@ -231,7 +233,7 @@ declare const flowSchema: z.ZodObject<{
231
233
  width: z.ZodNumber;
232
234
  height: z.ZodNumber;
233
235
  }, z.core.$strip>;
234
- }, z.core.$strip>;
236
+ }, z.core.$loose>;
235
237
  declare const annotationSchema: z.ZodObject<{
236
238
  id: z.ZodString;
237
239
  text: z.ZodString;
@@ -244,7 +246,7 @@ declare const annotationSchema: z.ZodObject<{
244
246
  height: z.ZodNumber;
245
247
  }, z.core.$strip>;
246
248
  attachedTo: z.ZodOptional<z.ZodString>;
247
- }, z.core.$strip>;
249
+ }, z.core.$loose>;
248
250
  declare const documentSchema: z.ZodObject<{
249
251
  version: z.ZodLiteral<3>;
250
252
  title: z.ZodString;
@@ -265,7 +267,7 @@ declare const documentSchema: z.ZodObject<{
265
267
  }, z.core.$strip>;
266
268
  fill: z.ZodOptional<z.ZodString>;
267
269
  stroke: z.ZodOptional<z.ZodString>;
268
- }, z.core.$strip>>;
270
+ }, z.core.$loose>>;
269
271
  interactions: z.ZodArray<z.ZodObject<{
270
272
  id: z.ZodString;
271
273
  mode: z.ZodEnum<{
@@ -282,7 +284,7 @@ declare const documentSchema: z.ZodObject<{
282
284
  }, z.core.$strip>;
283
285
  fill: z.ZodOptional<z.ZodString>;
284
286
  stroke: z.ZodOptional<z.ZodString>;
285
- }, z.core.$strip>>;
287
+ }, z.core.$loose>>;
286
288
  flows: z.ZodArray<z.ZodObject<{
287
289
  id: z.ZodString;
288
290
  label: z.ZodOptional<z.ZodString>;
@@ -294,7 +296,7 @@ declare const documentSchema: z.ZodObject<{
294
296
  width: z.ZodNumber;
295
297
  height: z.ZodNumber;
296
298
  }, z.core.$strip>;
297
- }, z.core.$strip>>;
299
+ }, z.core.$loose>>;
298
300
  annotations: z.ZodArray<z.ZodObject<{
299
301
  id: z.ZodString;
300
302
  text: z.ZodString;
@@ -307,19 +309,25 @@ declare const documentSchema: z.ZodObject<{
307
309
  height: z.ZodNumber;
308
310
  }, z.core.$strip>;
309
311
  attachedTo: z.ZodOptional<z.ZodString>;
310
- }, z.core.$strip>>;
311
- }, z.core.$strip>;
312
+ }, z.core.$loose>>;
313
+ }, z.core.$loose>;
314
+ /** One reason a document is invalid, at the path of the offending value. */
315
+ interface DocumentIssue {
316
+ path: (string | number)[];
317
+ message: string;
318
+ }
312
319
  type ParseResult = {
313
320
  ok: true;
314
321
  document: TtDocument;
315
322
  } | {
316
323
  ok: false;
317
324
  error: string;
325
+ issues: DocumentIssue[];
318
326
  };
319
327
  /**
320
328
  * Validates and (if necessary) migrates unknown data into a {@link TtDocument}.
321
329
  * Returns a discriminated result rather than throwing so callers can show a
322
- * friendly message.
330
+ * friendly message, or point at each offending value (`issues`).
323
331
  */
324
332
  declare function parseDocument(input: unknown): ParseResult;
325
333
 
@@ -331,15 +339,64 @@ declare function parseDocument(input: unknown): ParseResult;
331
339
  * stable share URLs / embedded payloads.
332
340
  */
333
341
 
334
- /** Returns a canonicalised copy of a document (sorted, rounded, version-stamped). */
342
+ /**
343
+ * Returns a canonicalised copy of a document (sorted, rounded, version-stamped). Fields the
344
+ * modeler does not know follow the known ones, sorted by name.
345
+ */
335
346
  declare function canonicalize(doc: TtDocument): TtDocument;
336
347
  /**
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.
348
+ * Serialises a document to deterministic JSON. An empty `annotations` list is left out, so
349
+ * re-saving a model that has no annotations changes nothing but its version stamp. The pretty
350
+ * form is the file on disk and ends with a line break, like the files editors and Git expect;
351
+ * the compact form (share links, local storage) has none.
340
352
  */
341
353
  declare function serializeDocument(doc: TtDocument, pretty?: boolean): string;
342
354
 
355
+ /**
356
+ * Fields a document carries that this modeler does not know, such as a vendor's `"x-vendor"` on a
357
+ * team. They are kept through open and save, written after the known fields and sorted, so another
358
+ * tool's data survives an edit in the modeler and the output stays deterministic.
359
+ */
360
+ declare const DOCUMENT_FIELDS: readonly ["version", "title", "nodes", "interactions", "flows", "annotations"];
361
+ declare const TEAM_NODE_FIELDS: readonly ["id", "type", "label", "description", "position", "size", "fill", "stroke"];
362
+ declare const INTERACTION_FIELDS: readonly ["id", "mode", "label", "position", "size", "fill", "stroke"];
363
+ declare const FLOW_FIELDS: readonly ["id", "label", "position", "size"];
364
+ declare const ANNOTATION_FIELDS: readonly ["id", "text", "position", "size", "attachedTo"];
365
+ /** Unknown fields by name, sorted, with their values in canonical form. */
366
+ type ForeignFields = Readonly<Record<string, unknown>>;
367
+ /** The fields of `value` outside `knownFields`, or undefined when there are none. */
368
+ declare function foreignFields(value: object, knownFields: readonly string[]): ForeignFields | undefined;
369
+ /**
370
+ * `known` followed by the foreign fields of `source`. Built from entries, never by assignment, so
371
+ * a field named `__proto__` stays a field instead of replacing the prototype.
372
+ */
373
+ declare function withForeignFields<T extends object>(known: T, source: object | undefined, knownFields: readonly string[]): T;
374
+
375
+ /**
376
+ * The id rules of a Team Topologies document. Besides the elements a document lists, a diagram
377
+ * holds parts it never writes down: the diagram itself and the connector of every annotation. They
378
+ * take ids of their own, so no element may use one of them; otherwise opening the file would fail
379
+ * halfway, with the previous diagram already gone.
380
+ */
381
+ /** The id of the diagram itself (the canvas root of the renderer). */
382
+ declare const DIAGRAM_ROOT_ID = "tt-root";
383
+ /** Connectors are not stored: an annotation's connector derives its id from the annotation. */
384
+ declare function associationId(annotationId: string): string;
385
+ interface DocumentIdProblem {
386
+ /** Where the offending id sits, e.g. `["nodes", 2, "id"]`. */
387
+ path: (string | number)[];
388
+ message: string;
389
+ }
390
+ declare const COLLECTIONS: readonly ["nodes", "interactions", "flows", "annotations"];
391
+ type DocumentElements = Record<(typeof COLLECTIONS)[number], readonly {
392
+ id: string;
393
+ }[]>;
394
+ /**
395
+ * Every id of the document that would collide on the canvas: a duplicate, the diagram's own id, a
396
+ * diagram-js root id, or the id of an annotation's connector.
397
+ */
398
+ declare function documentIdProblems(doc: DocumentElements): DocumentIdProblem[];
399
+
343
400
  /**
344
401
  * Factory helpers for constructing well-formed model objects with the correct
345
402
  * notation defaults (sizes, labels). Kept DOM-free.
@@ -360,10 +417,12 @@ declare function emptyDocument(title?: string): TtDocument;
360
417
  /**
361
418
  * A small but complete example diagram exercising all four team types, all three
362
419
  * 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.
420
+ * flow-of-change element and an attached annotation. The stream-aligned teams
421
+ * are stacked as parallel lanes along the flow of change, as in the Team
422
+ * Topologies book: side by side on the flow they would read as hand-offs. Ids are
423
+ * fixed so the fixture serialises stably.
365
424
  */
366
425
 
367
426
  declare const SAMPLE_DOCUMENT: TtDocument;
368
427
 
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 };
428
+ export { ALL_INTERACTION_SPECS, ALL_TEAM_SPECS, ANNOTATION_FIELDS, ANNOTATION_SPEC, type AnnotationSpec, DIAGRAM_ROOT_ID, DND_MIME, DOCUMENT_FIELDS, DOCUMENT_VERSION, type DocumentIdProblem, type DocumentIssue, FLOW_FIELDS, FLOW_SPEC, type FlowShape, type FlowSpec, type ForeignFields, INTERACTION_FIELDS, INTERACTION_MODES, INTERACTION_MODE_SPECS, type InteractionGlyph, type InteractionMode, type InteractionModeSpec, type InteractionShape, type ParseResult, type Position, SAMPLE_DOCUMENT, type Size, type StrokeStyle, TEAM_NODE_FIELDS, TEAM_TYPES, TEAM_TYPE_SPECS, type TeamNode, type TeamShape, type TeamType, type TeamTypeSpec, type TextAnnotation, type TtDocument, annotationSchema, associationId, canonicalize, createFlowShape, createInteractionShape, createTeamNode, createTextAnnotation, dashArray, documentIdProblems, documentSchema, emptyDocument, flowSchema, foreignFields, interactionSchema, newId, parseDocument, serializeDocument, teamNodeSchema, withForeignFields };
package/dist/index.d.ts CHANGED
@@ -182,7 +182,9 @@ declare const ALL_INTERACTION_SPECS: readonly InteractionModeSpec[];
182
182
  *
183
183
  * Anything entering the app from the outside world (imported files, share
184
184
  * URLs, localStorage) is parsed through {@link parseDocument} so malformed or
185
- * tampered data can never corrupt the editor state.
185
+ * tampered data can never corrupt the editor state. Fields the schema does not
186
+ * know pass through untouched (see `foreign.ts`), so another tool's data
187
+ * survives a save.
186
188
  */
187
189
 
188
190
  declare const teamNodeSchema: z.ZodObject<{
@@ -202,7 +204,7 @@ declare const teamNodeSchema: z.ZodObject<{
202
204
  }, z.core.$strip>;
203
205
  fill: z.ZodOptional<z.ZodString>;
204
206
  stroke: z.ZodOptional<z.ZodString>;
205
- }, z.core.$strip>;
207
+ }, z.core.$loose>;
206
208
  declare const interactionSchema: z.ZodObject<{
207
209
  id: z.ZodString;
208
210
  mode: z.ZodEnum<{
@@ -219,7 +221,7 @@ declare const interactionSchema: z.ZodObject<{
219
221
  }, z.core.$strip>;
220
222
  fill: z.ZodOptional<z.ZodString>;
221
223
  stroke: z.ZodOptional<z.ZodString>;
222
- }, z.core.$strip>;
224
+ }, z.core.$loose>;
223
225
  declare const flowSchema: z.ZodObject<{
224
226
  id: z.ZodString;
225
227
  label: z.ZodOptional<z.ZodString>;
@@ -231,7 +233,7 @@ declare const flowSchema: z.ZodObject<{
231
233
  width: z.ZodNumber;
232
234
  height: z.ZodNumber;
233
235
  }, z.core.$strip>;
234
- }, z.core.$strip>;
236
+ }, z.core.$loose>;
235
237
  declare const annotationSchema: z.ZodObject<{
236
238
  id: z.ZodString;
237
239
  text: z.ZodString;
@@ -244,7 +246,7 @@ declare const annotationSchema: z.ZodObject<{
244
246
  height: z.ZodNumber;
245
247
  }, z.core.$strip>;
246
248
  attachedTo: z.ZodOptional<z.ZodString>;
247
- }, z.core.$strip>;
249
+ }, z.core.$loose>;
248
250
  declare const documentSchema: z.ZodObject<{
249
251
  version: z.ZodLiteral<3>;
250
252
  title: z.ZodString;
@@ -265,7 +267,7 @@ declare const documentSchema: z.ZodObject<{
265
267
  }, z.core.$strip>;
266
268
  fill: z.ZodOptional<z.ZodString>;
267
269
  stroke: z.ZodOptional<z.ZodString>;
268
- }, z.core.$strip>>;
270
+ }, z.core.$loose>>;
269
271
  interactions: z.ZodArray<z.ZodObject<{
270
272
  id: z.ZodString;
271
273
  mode: z.ZodEnum<{
@@ -282,7 +284,7 @@ declare const documentSchema: z.ZodObject<{
282
284
  }, z.core.$strip>;
283
285
  fill: z.ZodOptional<z.ZodString>;
284
286
  stroke: z.ZodOptional<z.ZodString>;
285
- }, z.core.$strip>>;
287
+ }, z.core.$loose>>;
286
288
  flows: z.ZodArray<z.ZodObject<{
287
289
  id: z.ZodString;
288
290
  label: z.ZodOptional<z.ZodString>;
@@ -294,7 +296,7 @@ declare const documentSchema: z.ZodObject<{
294
296
  width: z.ZodNumber;
295
297
  height: z.ZodNumber;
296
298
  }, z.core.$strip>;
297
- }, z.core.$strip>>;
299
+ }, z.core.$loose>>;
298
300
  annotations: z.ZodArray<z.ZodObject<{
299
301
  id: z.ZodString;
300
302
  text: z.ZodString;
@@ -307,19 +309,25 @@ declare const documentSchema: z.ZodObject<{
307
309
  height: z.ZodNumber;
308
310
  }, z.core.$strip>;
309
311
  attachedTo: z.ZodOptional<z.ZodString>;
310
- }, z.core.$strip>>;
311
- }, z.core.$strip>;
312
+ }, z.core.$loose>>;
313
+ }, z.core.$loose>;
314
+ /** One reason a document is invalid, at the path of the offending value. */
315
+ interface DocumentIssue {
316
+ path: (string | number)[];
317
+ message: string;
318
+ }
312
319
  type ParseResult = {
313
320
  ok: true;
314
321
  document: TtDocument;
315
322
  } | {
316
323
  ok: false;
317
324
  error: string;
325
+ issues: DocumentIssue[];
318
326
  };
319
327
  /**
320
328
  * Validates and (if necessary) migrates unknown data into a {@link TtDocument}.
321
329
  * Returns a discriminated result rather than throwing so callers can show a
322
- * friendly message.
330
+ * friendly message, or point at each offending value (`issues`).
323
331
  */
324
332
  declare function parseDocument(input: unknown): ParseResult;
325
333
 
@@ -331,15 +339,64 @@ declare function parseDocument(input: unknown): ParseResult;
331
339
  * stable share URLs / embedded payloads.
332
340
  */
333
341
 
334
- /** Returns a canonicalised copy of a document (sorted, rounded, version-stamped). */
342
+ /**
343
+ * Returns a canonicalised copy of a document (sorted, rounded, version-stamped). Fields the
344
+ * modeler does not know follow the known ones, sorted by name.
345
+ */
335
346
  declare function canonicalize(doc: TtDocument): TtDocument;
336
347
  /**
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.
348
+ * Serialises a document to deterministic JSON. An empty `annotations` list is left out, so
349
+ * re-saving a model that has no annotations changes nothing but its version stamp. The pretty
350
+ * form is the file on disk and ends with a line break, like the files editors and Git expect;
351
+ * the compact form (share links, local storage) has none.
340
352
  */
341
353
  declare function serializeDocument(doc: TtDocument, pretty?: boolean): string;
342
354
 
355
+ /**
356
+ * Fields a document carries that this modeler does not know, such as a vendor's `"x-vendor"` on a
357
+ * team. They are kept through open and save, written after the known fields and sorted, so another
358
+ * tool's data survives an edit in the modeler and the output stays deterministic.
359
+ */
360
+ declare const DOCUMENT_FIELDS: readonly ["version", "title", "nodes", "interactions", "flows", "annotations"];
361
+ declare const TEAM_NODE_FIELDS: readonly ["id", "type", "label", "description", "position", "size", "fill", "stroke"];
362
+ declare const INTERACTION_FIELDS: readonly ["id", "mode", "label", "position", "size", "fill", "stroke"];
363
+ declare const FLOW_FIELDS: readonly ["id", "label", "position", "size"];
364
+ declare const ANNOTATION_FIELDS: readonly ["id", "text", "position", "size", "attachedTo"];
365
+ /** Unknown fields by name, sorted, with their values in canonical form. */
366
+ type ForeignFields = Readonly<Record<string, unknown>>;
367
+ /** The fields of `value` outside `knownFields`, or undefined when there are none. */
368
+ declare function foreignFields(value: object, knownFields: readonly string[]): ForeignFields | undefined;
369
+ /**
370
+ * `known` followed by the foreign fields of `source`. Built from entries, never by assignment, so
371
+ * a field named `__proto__` stays a field instead of replacing the prototype.
372
+ */
373
+ declare function withForeignFields<T extends object>(known: T, source: object | undefined, knownFields: readonly string[]): T;
374
+
375
+ /**
376
+ * The id rules of a Team Topologies document. Besides the elements a document lists, a diagram
377
+ * holds parts it never writes down: the diagram itself and the connector of every annotation. They
378
+ * take ids of their own, so no element may use one of them; otherwise opening the file would fail
379
+ * halfway, with the previous diagram already gone.
380
+ */
381
+ /** The id of the diagram itself (the canvas root of the renderer). */
382
+ declare const DIAGRAM_ROOT_ID = "tt-root";
383
+ /** Connectors are not stored: an annotation's connector derives its id from the annotation. */
384
+ declare function associationId(annotationId: string): string;
385
+ interface DocumentIdProblem {
386
+ /** Where the offending id sits, e.g. `["nodes", 2, "id"]`. */
387
+ path: (string | number)[];
388
+ message: string;
389
+ }
390
+ declare const COLLECTIONS: readonly ["nodes", "interactions", "flows", "annotations"];
391
+ type DocumentElements = Record<(typeof COLLECTIONS)[number], readonly {
392
+ id: string;
393
+ }[]>;
394
+ /**
395
+ * Every id of the document that would collide on the canvas: a duplicate, the diagram's own id, a
396
+ * diagram-js root id, or the id of an annotation's connector.
397
+ */
398
+ declare function documentIdProblems(doc: DocumentElements): DocumentIdProblem[];
399
+
343
400
  /**
344
401
  * Factory helpers for constructing well-formed model objects with the correct
345
402
  * notation defaults (sizes, labels). Kept DOM-free.
@@ -360,10 +417,12 @@ declare function emptyDocument(title?: string): TtDocument;
360
417
  /**
361
418
  * A small but complete example diagram exercising all four team types, all three
362
419
  * 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.
420
+ * flow-of-change element and an attached annotation. The stream-aligned teams
421
+ * are stacked as parallel lanes along the flow of change, as in the Team
422
+ * Topologies book: side by side on the flow they would read as hand-offs. Ids are
423
+ * fixed so the fixture serialises stably.
365
424
  */
366
425
 
367
426
  declare const SAMPLE_DOCUMENT: TtDocument;
368
427
 
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 };
428
+ export { ALL_INTERACTION_SPECS, ALL_TEAM_SPECS, ANNOTATION_FIELDS, ANNOTATION_SPEC, type AnnotationSpec, DIAGRAM_ROOT_ID, DND_MIME, DOCUMENT_FIELDS, DOCUMENT_VERSION, type DocumentIdProblem, type DocumentIssue, FLOW_FIELDS, FLOW_SPEC, type FlowShape, type FlowSpec, type ForeignFields, INTERACTION_FIELDS, INTERACTION_MODES, INTERACTION_MODE_SPECS, type InteractionGlyph, type InteractionMode, type InteractionModeSpec, type InteractionShape, type ParseResult, type Position, SAMPLE_DOCUMENT, type Size, type StrokeStyle, TEAM_NODE_FIELDS, TEAM_TYPES, TEAM_TYPE_SPECS, type TeamNode, type TeamShape, type TeamType, type TeamTypeSpec, type TextAnnotation, type TtDocument, annotationSchema, associationId, canonicalize, createFlowShape, createInteractionShape, createTeamNode, createTextAnnotation, dashArray, documentIdProblems, documentSchema, emptyDocument, flowSchema, foreignFields, interactionSchema, newId, parseDocument, serializeDocument, teamNodeSchema, withForeignFields };