@miragon/team-topologies-schema-model 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +428 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +628 -0
- package/dist/index.d.ts +628 -0
- package/dist/index.js +404 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pure (DOM-free) domain types for the Team Topologies model.
|
|
5
|
+
*
|
|
6
|
+
* This module is the canonical representation of a diagram and must never
|
|
7
|
+
* import from the rendering layer (`@xyflow/react`) or touch the DOM, so it
|
|
8
|
+
* can be unit-tested in isolation and reused across views / exporters.
|
|
9
|
+
*/
|
|
10
|
+
/** MIME type used when dragging a team type from the palette onto the canvas. */
|
|
11
|
+
declare const DND_MIME = "application/x-tt-team-type";
|
|
12
|
+
/** The four fundamental team types in Team Topologies. */
|
|
13
|
+
type TeamType = "stream-aligned" | "enabling" | "complicated-subsystem" | "platform";
|
|
14
|
+
declare const TEAM_TYPES: readonly TeamType[];
|
|
15
|
+
/** The three core team interaction modes in Team Topologies. */
|
|
16
|
+
type InteractionMode = "collaboration" | "x-as-a-service" | "facilitating";
|
|
17
|
+
declare const INTERACTION_MODES: readonly InteractionMode[];
|
|
18
|
+
/** Geometric size of a node in canvas units (px). Encodes cognitive load. */
|
|
19
|
+
interface Size {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
}
|
|
23
|
+
/** Position of a node on the canvas in canvas units (px). */
|
|
24
|
+
interface Position {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
}
|
|
28
|
+
/** A team node in the canonical document model. */
|
|
29
|
+
interface TeamNode {
|
|
30
|
+
id: string;
|
|
31
|
+
type: TeamType;
|
|
32
|
+
label: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
position: Position;
|
|
35
|
+
size: Size;
|
|
36
|
+
fill?: string;
|
|
37
|
+
stroke?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* An interaction in the canonical document model.
|
|
41
|
+
*
|
|
42
|
+
* Per the official Team Topologies notation, an interaction is a placed,
|
|
43
|
+
* resizable SHAPE (parallelogram / triangle / circle) overlaid on the boundary
|
|
44
|
+
* between the teams it relates to — not a connecting line. The relationship is
|
|
45
|
+
* therefore spatial (overlap), so there is no source/target reference.
|
|
46
|
+
*/
|
|
47
|
+
interface InteractionShape {
|
|
48
|
+
id: string;
|
|
49
|
+
mode: InteractionMode;
|
|
50
|
+
label?: string;
|
|
51
|
+
position: Position;
|
|
52
|
+
size: Size;
|
|
53
|
+
fill?: string;
|
|
54
|
+
stroke?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A "flow of change" guide: a placed, resizable arrow element. Lets you anchor
|
|
58
|
+
* the implied left-to-right flow, and visualise several team groupings on one
|
|
59
|
+
* canvas.
|
|
60
|
+
*/
|
|
61
|
+
interface FlowShape {
|
|
62
|
+
id: string;
|
|
63
|
+
label?: string;
|
|
64
|
+
position: Position;
|
|
65
|
+
size: Size;
|
|
66
|
+
}
|
|
67
|
+
/** Current document schema version. Bump + add a migration when shape changes. */
|
|
68
|
+
declare const DOCUMENT_VERSION: 2;
|
|
69
|
+
/**
|
|
70
|
+
* A complete Team Topologies diagram. This is what gets serialised to JSON,
|
|
71
|
+
* embedded into exported images, and encoded into share URLs.
|
|
72
|
+
*/
|
|
73
|
+
interface TtDocument {
|
|
74
|
+
version: typeof DOCUMENT_VERSION;
|
|
75
|
+
title: string;
|
|
76
|
+
nodes: TeamNode[];
|
|
77
|
+
interactions: InteractionShape[];
|
|
78
|
+
flows: FlowShape[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The Team Topologies visual notation, encoded as data.
|
|
83
|
+
*
|
|
84
|
+
* Colours, shapes and stroke styles follow the official
|
|
85
|
+
* "Team-Shape-Templates" specification published by Team Topologies
|
|
86
|
+
* (https://github.com/TeamTopologies/Team-Shape-Templates):
|
|
87
|
+
*
|
|
88
|
+
* - Team shapes are SOLID outlines (long-lived structures).
|
|
89
|
+
* - Interaction-mode shapes are 50% transparent with DASHED outlines
|
|
90
|
+
* (short-lived interactions).
|
|
91
|
+
* - Each element is distinguished by SHAPE as well as colour, so the
|
|
92
|
+
* notation stays readable for people with colour-vision deficiency.
|
|
93
|
+
*
|
|
94
|
+
* This module is pure data — it must not import the rendering layer.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
type TeamShape = "rounded-rect-horizontal" | "rounded-rect-vertical" | "octagon" | "rect";
|
|
98
|
+
type InteractionGlyph = "parallelogram" | "triangle" | "circle";
|
|
99
|
+
type StrokeStyle = "solid" | "dashed" | "dotted";
|
|
100
|
+
interface TeamTypeSpec {
|
|
101
|
+
type: TeamType;
|
|
102
|
+
/** Short display name. */
|
|
103
|
+
label: string;
|
|
104
|
+
/** One-line purpose, shown in the palette and inspector. */
|
|
105
|
+
description: string;
|
|
106
|
+
shape: TeamShape;
|
|
107
|
+
fill: string;
|
|
108
|
+
stroke: string;
|
|
109
|
+
strokeStyle: StrokeStyle;
|
|
110
|
+
strokeWidth: number;
|
|
111
|
+
/** Default size when a node of this type is created. */
|
|
112
|
+
defaultSize: Size;
|
|
113
|
+
/** Minimum size enforced by the resizer. */
|
|
114
|
+
minSize: Size;
|
|
115
|
+
}
|
|
116
|
+
interface InteractionModeSpec {
|
|
117
|
+
mode: InteractionMode;
|
|
118
|
+
label: string;
|
|
119
|
+
description: string;
|
|
120
|
+
shape: InteractionGlyph;
|
|
121
|
+
fill: string;
|
|
122
|
+
stroke: string;
|
|
123
|
+
strokeStyle: StrokeStyle;
|
|
124
|
+
strokeWidth: number;
|
|
125
|
+
/** Opacity for the interaction shape (short-lived → translucent). */
|
|
126
|
+
opacity: number;
|
|
127
|
+
/** Whether direction is semantically meaningful (the X-as-a-Service triangle). */
|
|
128
|
+
directional: boolean;
|
|
129
|
+
/** Default size when a shape of this mode is created. */
|
|
130
|
+
defaultSize: Size;
|
|
131
|
+
/** Minimum size enforced by the resizer. */
|
|
132
|
+
minSize: Size;
|
|
133
|
+
}
|
|
134
|
+
/** The left-to-right "flow of change" guide, a placeable annotation element. */
|
|
135
|
+
interface FlowSpec {
|
|
136
|
+
label: string;
|
|
137
|
+
fill: string;
|
|
138
|
+
stroke: string;
|
|
139
|
+
strokeStyle: StrokeStyle;
|
|
140
|
+
strokeWidth: number;
|
|
141
|
+
defaultSize: Size;
|
|
142
|
+
minSize: Size;
|
|
143
|
+
}
|
|
144
|
+
declare const TEAM_TYPE_SPECS: Record<TeamType, TeamTypeSpec>;
|
|
145
|
+
declare const INTERACTION_MODE_SPECS: Record<InteractionMode, InteractionModeSpec>;
|
|
146
|
+
/**
|
|
147
|
+
* The "flow of change" guide — a placeable dashed arrow (left-to-right).
|
|
148
|
+
* Not a team or interaction: a standalone annotation element.
|
|
149
|
+
*/
|
|
150
|
+
declare const FLOW_SPEC: FlowSpec;
|
|
151
|
+
/** Maps a stroke style to an SVG/CSS dash array (empty string = solid). */
|
|
152
|
+
declare function dashArray(style: StrokeStyle, strokeWidth?: number): string;
|
|
153
|
+
declare const ALL_TEAM_SPECS: readonly TeamTypeSpec[];
|
|
154
|
+
declare const ALL_INTERACTION_SPECS: readonly InteractionModeSpec[];
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Runtime validation for the document model using Zod.
|
|
158
|
+
*
|
|
159
|
+
* Anything entering the app from the outside world (imported files, share
|
|
160
|
+
* URLs, localStorage) is parsed through {@link parseDocument} so malformed or
|
|
161
|
+
* tampered data can never corrupt the editor state.
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
declare const teamNodeSchema: z.ZodObject<{
|
|
165
|
+
id: z.ZodString;
|
|
166
|
+
type: z.ZodEnum<[string, ...string[]]>;
|
|
167
|
+
label: z.ZodString;
|
|
168
|
+
description: z.ZodOptional<z.ZodString>;
|
|
169
|
+
position: z.ZodObject<{
|
|
170
|
+
x: z.ZodNumber;
|
|
171
|
+
y: z.ZodNumber;
|
|
172
|
+
}, "strip", z.ZodTypeAny, {
|
|
173
|
+
x: number;
|
|
174
|
+
y: number;
|
|
175
|
+
}, {
|
|
176
|
+
x: number;
|
|
177
|
+
y: number;
|
|
178
|
+
}>;
|
|
179
|
+
size: z.ZodObject<{
|
|
180
|
+
width: z.ZodNumber;
|
|
181
|
+
height: z.ZodNumber;
|
|
182
|
+
}, "strip", z.ZodTypeAny, {
|
|
183
|
+
width: number;
|
|
184
|
+
height: number;
|
|
185
|
+
}, {
|
|
186
|
+
width: number;
|
|
187
|
+
height: number;
|
|
188
|
+
}>;
|
|
189
|
+
fill: z.ZodOptional<z.ZodString>;
|
|
190
|
+
stroke: z.ZodOptional<z.ZodString>;
|
|
191
|
+
}, "strip", z.ZodTypeAny, {
|
|
192
|
+
type: string;
|
|
193
|
+
id: string;
|
|
194
|
+
label: string;
|
|
195
|
+
position: {
|
|
196
|
+
x: number;
|
|
197
|
+
y: number;
|
|
198
|
+
};
|
|
199
|
+
size: {
|
|
200
|
+
width: number;
|
|
201
|
+
height: number;
|
|
202
|
+
};
|
|
203
|
+
fill?: string | undefined;
|
|
204
|
+
description?: string | undefined;
|
|
205
|
+
stroke?: string | undefined;
|
|
206
|
+
}, {
|
|
207
|
+
type: string;
|
|
208
|
+
id: string;
|
|
209
|
+
label: string;
|
|
210
|
+
position: {
|
|
211
|
+
x: number;
|
|
212
|
+
y: number;
|
|
213
|
+
};
|
|
214
|
+
size: {
|
|
215
|
+
width: number;
|
|
216
|
+
height: number;
|
|
217
|
+
};
|
|
218
|
+
fill?: string | undefined;
|
|
219
|
+
description?: string | undefined;
|
|
220
|
+
stroke?: string | undefined;
|
|
221
|
+
}>;
|
|
222
|
+
declare const interactionSchema: z.ZodObject<{
|
|
223
|
+
id: z.ZodString;
|
|
224
|
+
mode: z.ZodEnum<[string, ...string[]]>;
|
|
225
|
+
label: z.ZodOptional<z.ZodString>;
|
|
226
|
+
position: z.ZodObject<{
|
|
227
|
+
x: z.ZodNumber;
|
|
228
|
+
y: z.ZodNumber;
|
|
229
|
+
}, "strip", z.ZodTypeAny, {
|
|
230
|
+
x: number;
|
|
231
|
+
y: number;
|
|
232
|
+
}, {
|
|
233
|
+
x: number;
|
|
234
|
+
y: number;
|
|
235
|
+
}>;
|
|
236
|
+
size: z.ZodObject<{
|
|
237
|
+
width: z.ZodNumber;
|
|
238
|
+
height: z.ZodNumber;
|
|
239
|
+
}, "strip", z.ZodTypeAny, {
|
|
240
|
+
width: number;
|
|
241
|
+
height: number;
|
|
242
|
+
}, {
|
|
243
|
+
width: number;
|
|
244
|
+
height: number;
|
|
245
|
+
}>;
|
|
246
|
+
fill: z.ZodOptional<z.ZodString>;
|
|
247
|
+
stroke: z.ZodOptional<z.ZodString>;
|
|
248
|
+
}, "strip", z.ZodTypeAny, {
|
|
249
|
+
id: string;
|
|
250
|
+
position: {
|
|
251
|
+
x: number;
|
|
252
|
+
y: number;
|
|
253
|
+
};
|
|
254
|
+
size: {
|
|
255
|
+
width: number;
|
|
256
|
+
height: number;
|
|
257
|
+
};
|
|
258
|
+
mode: string;
|
|
259
|
+
fill?: string | undefined;
|
|
260
|
+
label?: string | undefined;
|
|
261
|
+
stroke?: string | undefined;
|
|
262
|
+
}, {
|
|
263
|
+
id: string;
|
|
264
|
+
position: {
|
|
265
|
+
x: number;
|
|
266
|
+
y: number;
|
|
267
|
+
};
|
|
268
|
+
size: {
|
|
269
|
+
width: number;
|
|
270
|
+
height: number;
|
|
271
|
+
};
|
|
272
|
+
mode: string;
|
|
273
|
+
fill?: string | undefined;
|
|
274
|
+
label?: string | undefined;
|
|
275
|
+
stroke?: string | undefined;
|
|
276
|
+
}>;
|
|
277
|
+
declare const flowSchema: z.ZodObject<{
|
|
278
|
+
id: z.ZodString;
|
|
279
|
+
label: z.ZodOptional<z.ZodString>;
|
|
280
|
+
position: z.ZodObject<{
|
|
281
|
+
x: z.ZodNumber;
|
|
282
|
+
y: z.ZodNumber;
|
|
283
|
+
}, "strip", z.ZodTypeAny, {
|
|
284
|
+
x: number;
|
|
285
|
+
y: number;
|
|
286
|
+
}, {
|
|
287
|
+
x: number;
|
|
288
|
+
y: number;
|
|
289
|
+
}>;
|
|
290
|
+
size: z.ZodObject<{
|
|
291
|
+
width: z.ZodNumber;
|
|
292
|
+
height: z.ZodNumber;
|
|
293
|
+
}, "strip", z.ZodTypeAny, {
|
|
294
|
+
width: number;
|
|
295
|
+
height: number;
|
|
296
|
+
}, {
|
|
297
|
+
width: number;
|
|
298
|
+
height: number;
|
|
299
|
+
}>;
|
|
300
|
+
}, "strip", z.ZodTypeAny, {
|
|
301
|
+
id: string;
|
|
302
|
+
position: {
|
|
303
|
+
x: number;
|
|
304
|
+
y: number;
|
|
305
|
+
};
|
|
306
|
+
size: {
|
|
307
|
+
width: number;
|
|
308
|
+
height: number;
|
|
309
|
+
};
|
|
310
|
+
label?: string | undefined;
|
|
311
|
+
}, {
|
|
312
|
+
id: string;
|
|
313
|
+
position: {
|
|
314
|
+
x: number;
|
|
315
|
+
y: number;
|
|
316
|
+
};
|
|
317
|
+
size: {
|
|
318
|
+
width: number;
|
|
319
|
+
height: number;
|
|
320
|
+
};
|
|
321
|
+
label?: string | undefined;
|
|
322
|
+
}>;
|
|
323
|
+
declare const documentSchema: z.ZodObject<{
|
|
324
|
+
version: z.ZodLiteral<2>;
|
|
325
|
+
title: z.ZodString;
|
|
326
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
327
|
+
id: z.ZodString;
|
|
328
|
+
type: z.ZodEnum<[string, ...string[]]>;
|
|
329
|
+
label: z.ZodString;
|
|
330
|
+
description: z.ZodOptional<z.ZodString>;
|
|
331
|
+
position: z.ZodObject<{
|
|
332
|
+
x: z.ZodNumber;
|
|
333
|
+
y: z.ZodNumber;
|
|
334
|
+
}, "strip", z.ZodTypeAny, {
|
|
335
|
+
x: number;
|
|
336
|
+
y: number;
|
|
337
|
+
}, {
|
|
338
|
+
x: number;
|
|
339
|
+
y: number;
|
|
340
|
+
}>;
|
|
341
|
+
size: z.ZodObject<{
|
|
342
|
+
width: z.ZodNumber;
|
|
343
|
+
height: z.ZodNumber;
|
|
344
|
+
}, "strip", z.ZodTypeAny, {
|
|
345
|
+
width: number;
|
|
346
|
+
height: number;
|
|
347
|
+
}, {
|
|
348
|
+
width: number;
|
|
349
|
+
height: number;
|
|
350
|
+
}>;
|
|
351
|
+
fill: z.ZodOptional<z.ZodString>;
|
|
352
|
+
stroke: z.ZodOptional<z.ZodString>;
|
|
353
|
+
}, "strip", z.ZodTypeAny, {
|
|
354
|
+
type: string;
|
|
355
|
+
id: string;
|
|
356
|
+
label: string;
|
|
357
|
+
position: {
|
|
358
|
+
x: number;
|
|
359
|
+
y: number;
|
|
360
|
+
};
|
|
361
|
+
size: {
|
|
362
|
+
width: number;
|
|
363
|
+
height: number;
|
|
364
|
+
};
|
|
365
|
+
fill?: string | undefined;
|
|
366
|
+
description?: string | undefined;
|
|
367
|
+
stroke?: string | undefined;
|
|
368
|
+
}, {
|
|
369
|
+
type: string;
|
|
370
|
+
id: string;
|
|
371
|
+
label: string;
|
|
372
|
+
position: {
|
|
373
|
+
x: number;
|
|
374
|
+
y: number;
|
|
375
|
+
};
|
|
376
|
+
size: {
|
|
377
|
+
width: number;
|
|
378
|
+
height: number;
|
|
379
|
+
};
|
|
380
|
+
fill?: string | undefined;
|
|
381
|
+
description?: string | undefined;
|
|
382
|
+
stroke?: string | undefined;
|
|
383
|
+
}>, "many">;
|
|
384
|
+
interactions: z.ZodArray<z.ZodObject<{
|
|
385
|
+
id: z.ZodString;
|
|
386
|
+
mode: z.ZodEnum<[string, ...string[]]>;
|
|
387
|
+
label: z.ZodOptional<z.ZodString>;
|
|
388
|
+
position: z.ZodObject<{
|
|
389
|
+
x: z.ZodNumber;
|
|
390
|
+
y: z.ZodNumber;
|
|
391
|
+
}, "strip", z.ZodTypeAny, {
|
|
392
|
+
x: number;
|
|
393
|
+
y: number;
|
|
394
|
+
}, {
|
|
395
|
+
x: number;
|
|
396
|
+
y: number;
|
|
397
|
+
}>;
|
|
398
|
+
size: z.ZodObject<{
|
|
399
|
+
width: z.ZodNumber;
|
|
400
|
+
height: z.ZodNumber;
|
|
401
|
+
}, "strip", z.ZodTypeAny, {
|
|
402
|
+
width: number;
|
|
403
|
+
height: number;
|
|
404
|
+
}, {
|
|
405
|
+
width: number;
|
|
406
|
+
height: number;
|
|
407
|
+
}>;
|
|
408
|
+
fill: z.ZodOptional<z.ZodString>;
|
|
409
|
+
stroke: z.ZodOptional<z.ZodString>;
|
|
410
|
+
}, "strip", z.ZodTypeAny, {
|
|
411
|
+
id: string;
|
|
412
|
+
position: {
|
|
413
|
+
x: number;
|
|
414
|
+
y: number;
|
|
415
|
+
};
|
|
416
|
+
size: {
|
|
417
|
+
width: number;
|
|
418
|
+
height: number;
|
|
419
|
+
};
|
|
420
|
+
mode: string;
|
|
421
|
+
fill?: string | undefined;
|
|
422
|
+
label?: string | undefined;
|
|
423
|
+
stroke?: string | undefined;
|
|
424
|
+
}, {
|
|
425
|
+
id: string;
|
|
426
|
+
position: {
|
|
427
|
+
x: number;
|
|
428
|
+
y: number;
|
|
429
|
+
};
|
|
430
|
+
size: {
|
|
431
|
+
width: number;
|
|
432
|
+
height: number;
|
|
433
|
+
};
|
|
434
|
+
mode: string;
|
|
435
|
+
fill?: string | undefined;
|
|
436
|
+
label?: string | undefined;
|
|
437
|
+
stroke?: string | undefined;
|
|
438
|
+
}>, "many">;
|
|
439
|
+
flows: z.ZodArray<z.ZodObject<{
|
|
440
|
+
id: z.ZodString;
|
|
441
|
+
label: z.ZodOptional<z.ZodString>;
|
|
442
|
+
position: z.ZodObject<{
|
|
443
|
+
x: z.ZodNumber;
|
|
444
|
+
y: z.ZodNumber;
|
|
445
|
+
}, "strip", z.ZodTypeAny, {
|
|
446
|
+
x: number;
|
|
447
|
+
y: number;
|
|
448
|
+
}, {
|
|
449
|
+
x: number;
|
|
450
|
+
y: number;
|
|
451
|
+
}>;
|
|
452
|
+
size: z.ZodObject<{
|
|
453
|
+
width: z.ZodNumber;
|
|
454
|
+
height: z.ZodNumber;
|
|
455
|
+
}, "strip", z.ZodTypeAny, {
|
|
456
|
+
width: number;
|
|
457
|
+
height: number;
|
|
458
|
+
}, {
|
|
459
|
+
width: number;
|
|
460
|
+
height: number;
|
|
461
|
+
}>;
|
|
462
|
+
}, "strip", z.ZodTypeAny, {
|
|
463
|
+
id: string;
|
|
464
|
+
position: {
|
|
465
|
+
x: number;
|
|
466
|
+
y: number;
|
|
467
|
+
};
|
|
468
|
+
size: {
|
|
469
|
+
width: number;
|
|
470
|
+
height: number;
|
|
471
|
+
};
|
|
472
|
+
label?: string | undefined;
|
|
473
|
+
}, {
|
|
474
|
+
id: string;
|
|
475
|
+
position: {
|
|
476
|
+
x: number;
|
|
477
|
+
y: number;
|
|
478
|
+
};
|
|
479
|
+
size: {
|
|
480
|
+
width: number;
|
|
481
|
+
height: number;
|
|
482
|
+
};
|
|
483
|
+
label?: string | undefined;
|
|
484
|
+
}>, "many">;
|
|
485
|
+
}, "strip", z.ZodTypeAny, {
|
|
486
|
+
version: 2;
|
|
487
|
+
title: string;
|
|
488
|
+
nodes: {
|
|
489
|
+
type: string;
|
|
490
|
+
id: string;
|
|
491
|
+
label: string;
|
|
492
|
+
position: {
|
|
493
|
+
x: number;
|
|
494
|
+
y: number;
|
|
495
|
+
};
|
|
496
|
+
size: {
|
|
497
|
+
width: number;
|
|
498
|
+
height: number;
|
|
499
|
+
};
|
|
500
|
+
fill?: string | undefined;
|
|
501
|
+
description?: string | undefined;
|
|
502
|
+
stroke?: string | undefined;
|
|
503
|
+
}[];
|
|
504
|
+
interactions: {
|
|
505
|
+
id: string;
|
|
506
|
+
position: {
|
|
507
|
+
x: number;
|
|
508
|
+
y: number;
|
|
509
|
+
};
|
|
510
|
+
size: {
|
|
511
|
+
width: number;
|
|
512
|
+
height: number;
|
|
513
|
+
};
|
|
514
|
+
mode: string;
|
|
515
|
+
fill?: string | undefined;
|
|
516
|
+
label?: string | undefined;
|
|
517
|
+
stroke?: string | undefined;
|
|
518
|
+
}[];
|
|
519
|
+
flows: {
|
|
520
|
+
id: string;
|
|
521
|
+
position: {
|
|
522
|
+
x: number;
|
|
523
|
+
y: number;
|
|
524
|
+
};
|
|
525
|
+
size: {
|
|
526
|
+
width: number;
|
|
527
|
+
height: number;
|
|
528
|
+
};
|
|
529
|
+
label?: string | undefined;
|
|
530
|
+
}[];
|
|
531
|
+
}, {
|
|
532
|
+
version: 2;
|
|
533
|
+
title: string;
|
|
534
|
+
nodes: {
|
|
535
|
+
type: string;
|
|
536
|
+
id: string;
|
|
537
|
+
label: string;
|
|
538
|
+
position: {
|
|
539
|
+
x: number;
|
|
540
|
+
y: number;
|
|
541
|
+
};
|
|
542
|
+
size: {
|
|
543
|
+
width: number;
|
|
544
|
+
height: number;
|
|
545
|
+
};
|
|
546
|
+
fill?: string | undefined;
|
|
547
|
+
description?: string | undefined;
|
|
548
|
+
stroke?: string | undefined;
|
|
549
|
+
}[];
|
|
550
|
+
interactions: {
|
|
551
|
+
id: string;
|
|
552
|
+
position: {
|
|
553
|
+
x: number;
|
|
554
|
+
y: number;
|
|
555
|
+
};
|
|
556
|
+
size: {
|
|
557
|
+
width: number;
|
|
558
|
+
height: number;
|
|
559
|
+
};
|
|
560
|
+
mode: string;
|
|
561
|
+
fill?: string | undefined;
|
|
562
|
+
label?: string | undefined;
|
|
563
|
+
stroke?: string | undefined;
|
|
564
|
+
}[];
|
|
565
|
+
flows: {
|
|
566
|
+
id: string;
|
|
567
|
+
position: {
|
|
568
|
+
x: number;
|
|
569
|
+
y: number;
|
|
570
|
+
};
|
|
571
|
+
size: {
|
|
572
|
+
width: number;
|
|
573
|
+
height: number;
|
|
574
|
+
};
|
|
575
|
+
label?: string | undefined;
|
|
576
|
+
}[];
|
|
577
|
+
}>;
|
|
578
|
+
type ParseResult = {
|
|
579
|
+
ok: true;
|
|
580
|
+
document: TtDocument;
|
|
581
|
+
} | {
|
|
582
|
+
ok: false;
|
|
583
|
+
error: string;
|
|
584
|
+
};
|
|
585
|
+
/**
|
|
586
|
+
* Validates and (if necessary) migrates unknown data into a {@link TtDocument}.
|
|
587
|
+
* Returns a discriminated result rather than throwing so callers can show a
|
|
588
|
+
* friendly message.
|
|
589
|
+
*/
|
|
590
|
+
declare function parseDocument(input: unknown): ParseResult;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Deterministic serialisation of the document model.
|
|
594
|
+
*
|
|
595
|
+
* Producing byte-stable JSON (sorted arrays, fixed key order, rounded
|
|
596
|
+
* coordinates) makes diagrams diff-friendly in version control and gives
|
|
597
|
+
* stable share URLs / embedded payloads.
|
|
598
|
+
*/
|
|
599
|
+
|
|
600
|
+
/** Returns a canonicalised copy of a document (sorted, rounded, version-stamped). */
|
|
601
|
+
declare function canonicalize(doc: TtDocument): TtDocument;
|
|
602
|
+
/** Serialises a document to deterministic, pretty-printed JSON. */
|
|
603
|
+
declare function serializeDocument(doc: TtDocument, pretty?: boolean): string;
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Factory helpers for constructing well-formed model objects with the correct
|
|
607
|
+
* notation defaults (sizes, labels). Kept DOM-free.
|
|
608
|
+
*/
|
|
609
|
+
|
|
610
|
+
declare function newId(prefix: string): string;
|
|
611
|
+
/** Creates a team node of the given type at a position, with notation defaults. */
|
|
612
|
+
declare function createTeamNode(type: TeamType, position: Position, overrides?: Partial<Omit<TeamNode, "id" | "type">>): TeamNode;
|
|
613
|
+
/** Creates a placed interaction shape of the given mode, with notation defaults. */
|
|
614
|
+
declare function createInteractionShape(mode: InteractionMode, position: Position, overrides?: Partial<Omit<InteractionShape, "id" | "mode" | "position">>): InteractionShape;
|
|
615
|
+
/** Creates a placed "flow of change" arrow, with notation defaults. */
|
|
616
|
+
declare function createFlowShape(position: Position, overrides?: Partial<Omit<FlowShape, "id" | "position">>): FlowShape;
|
|
617
|
+
/** An empty document with sensible defaults. */
|
|
618
|
+
declare function emptyDocument(title?: string): TtDocument;
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* A small but complete example diagram exercising all four team types, all three
|
|
622
|
+
* interaction modes (as placed shapes overlaying the team boundaries) and a
|
|
623
|
+
* flow-of-change element. Ids are fixed so the fixture serialises stably.
|
|
624
|
+
*/
|
|
625
|
+
|
|
626
|
+
declare const SAMPLE_DOCUMENT: TtDocument;
|
|
627
|
+
|
|
628
|
+
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 };
|