@openplanr/protocol 0.13.0 → 0.15.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.
Files changed (34) hide show
  1. package/README.md +23 -0
  2. package/package.json +6 -2
  3. package/registries/commands.json +12 -12
  4. package/registries/roles.json +43 -133
  5. package/registries/skills.json +14 -14
  6. package/registries/task-kinds.json +2 -2
  7. package/schemas/v1.20.0/design-document.schema.json +379 -0
  8. package/schemas/v1.20.0/design-review-bundle.schema.json +692 -0
  9. package/schemas/v1.21.0/diagram-authoring-bundle.schema.json +1609 -0
  10. package/schemas/v1.21.0/diagram-edit-transaction.schema.json +4369 -0
  11. package/schemas/v1.21.0/diagram-review-bundle.schema.json +4047 -0
  12. package/schemas/v1.21.0/diagram-shape-definition.schema.json +457 -0
  13. package/schemas/v1.22.0/design-document.schema.json +506 -0
  14. package/schemas/v1.22.0/design-review-bundle.schema.json +822 -0
  15. package/schemas/v1.5.0/role-registry.schema.json +4 -1
  16. package/src/browser-contracts.d.mts +5 -1
  17. package/src/browser-contracts.mjs +27 -0
  18. package/src/contracts.mjs +39 -6
  19. package/src/design-contracts.d.mts +40 -2
  20. package/src/design-contracts.mjs +258 -17
  21. package/src/design-publication-contracts.mjs +3 -1
  22. package/src/diagram-authoring-contracts.d.mts +2 -0
  23. package/src/generated/canonical-registries.mjs +71 -161
  24. package/src/index.d.mts +7 -0
  25. package/src/index.mjs +7 -0
  26. package/src/json-schema.mjs +4 -0
  27. package/src/registries.mjs +20 -4
  28. package/src/review-experience-contracts.d.mts +2 -0
  29. package/src/review-experience-contracts.mjs +77 -5
  30. package/src/shape-library-contracts.d.mts +57 -0
  31. package/src/shape-library-contracts.mjs +266 -0
  32. package/src/studio-presentation-contracts.d.mts +50 -2
  33. package/src/studio-presentation-contracts.mjs +285 -4
  34. package/src/workspace-contracts.mjs +3 -3
@@ -1,5 +1,11 @@
1
1
  // @ts-check
2
+
2
3
  import { canonicalizeJson, sha256Hex } from './canonical-json.mjs';
4
+ import {
5
+ DESIGN_DOCUMENT_SCHEMA,
6
+ DESIGN_DOCUMENT_V120_SCHEMA,
7
+ validateDesignProps,
8
+ } from './design-contracts.mjs';
3
9
  import { validateJson } from './json-schema.mjs';
4
10
  import { DESIGN_REVIEW_BUNDLE_SCHEMA } from './workspace-contracts.mjs';
5
11
 
@@ -103,6 +109,51 @@ Object.assign(bundleV12.properties, {
103
109
  /** @type {typeof import('./review-experience-contracts.d.mts').DESIGN_REVIEW_BUNDLE_V12_SCHEMA} */
104
110
  export const DESIGN_REVIEW_BUNDLE_V12_SCHEMA = bundleV12;
105
111
 
112
+ const bundleCurrent = /** @type {MutableSchema} */ (structuredClone(bundleV12));
113
+ bundleCurrent.$id = 'https://openplanr.dev/schemas/v1.20.0/design-review-bundle.schema.json';
114
+ bundleCurrent['x-openplanr-contract'] = { id: 'design-review-bundle', version: '1.20.0' };
115
+ bundleCurrent.properties.schemaVersion = { enum: ['1.1.0', '1.2.0'] };
116
+ bundleCurrent.properties.envelope = bundleV11.properties.envelope;
117
+ bundleCurrent.allOf = [
118
+ {
119
+ if: { properties: { schemaVersion: { const: '1.2.0' } } },
120
+ then: { properties: { envelope: bundleV12.properties.envelope } },
121
+ },
122
+ ];
123
+ const currentDesign = /** @type {MutableSchema} */ (bundleCurrent.properties.design);
124
+ for (const key of ['frames', 'layout'])
125
+ currentDesign.properties[key] = /** @type {Record<string, unknown>} */ (
126
+ DESIGN_DOCUMENT_V120_SCHEMA.properties
127
+ )[key];
128
+ bundleCurrent.$defs = structuredClone(DESIGN_DOCUMENT_V120_SCHEMA.$defs);
129
+ const currentEntries = /** @type {{ items: { properties: Record<string, unknown> } }} */ (
130
+ bundleCurrent.properties.entries
131
+ );
132
+ currentEntries.items.properties.height = { const: 'auto' };
133
+ /** @type {typeof import('./review-experience-contracts.d.mts').DESIGN_REVIEW_BUNDLE_V120_SCHEMA} */
134
+ export const DESIGN_REVIEW_BUNDLE_V120_SCHEMA = bundleCurrent;
135
+
136
+ const bundleProps = /** @type {MutableSchema} */ (structuredClone(bundleCurrent));
137
+ bundleProps.$id = 'https://openplanr.dev/schemas/v1.22.0/design-review-bundle.schema.json';
138
+ bundleProps['x-openplanr-contract'] = { id: 'design-review-bundle', version: '1.22.0' };
139
+ const propsDesign = /** @type {MutableSchema} */ (bundleProps.properties.design);
140
+ const authoredProperties = /** @type {Record<string, unknown>} */ (
141
+ DESIGN_DOCUMENT_SCHEMA.properties
142
+ );
143
+ propsDesign.properties.schemaVersion = authoredProperties.schemaVersion;
144
+ for (const key of ['screens', 'variants']) {
145
+ const projected = /** @type {{ items: { properties: Record<string, unknown> } }} */ (
146
+ propsDesign.properties[key]
147
+ );
148
+ const authored = /** @type {{ items: { properties: Record<string, unknown> } }} */ (
149
+ authoredProperties[key]
150
+ );
151
+ projected.items.properties.props = authored.items.properties.props;
152
+ }
153
+ propsDesign.allOf = structuredClone(DESIGN_DOCUMENT_SCHEMA.allOf);
154
+ /** @type {typeof import('./review-experience-contracts.d.mts').DESIGN_REVIEW_BUNDLE_CURRENT_SCHEMA} */
155
+ export const DESIGN_REVIEW_BUNDLE_CURRENT_SCHEMA = bundleProps;
156
+
106
157
  const item = closed(
107
158
  {
108
159
  pinId: id,
@@ -235,14 +286,35 @@ export function assertDesignReviewMetadata(value) {
235
286
  }
236
287
  /** @returns {ReturnType<typeof import('./review-experience-contracts.d.mts').assertDesignReviewBundle>} */
237
288
  export function assertDesignReviewBundle(value) {
289
+ if (
290
+ value?.design?.schemaVersion !== '1.1.0' &&
291
+ ['screens', 'variants'].some(
292
+ (field) =>
293
+ Array.isArray(value?.design?.[field]) &&
294
+ value.design[field].some((item) => item && Object.hasOwn(item, 'props')),
295
+ )
296
+ )
297
+ throw new TypeError('Invalid design props: props require design.schemaVersion "1.1.0"');
238
298
  assertReviewExperience(
239
299
  value,
240
- value?.schemaVersion === '1.2.0'
241
- ? DESIGN_REVIEW_BUNDLE_V12_SCHEMA
242
- : value?.schemaVersion === '1.1.0'
243
- ? DESIGN_REVIEW_BUNDLE_V11_SCHEMA
244
- : DESIGN_REVIEW_BUNDLE_SCHEMA,
300
+ value?.design?.schemaVersion !== undefined ||
301
+ ['screens', 'variants'].some(
302
+ (field) =>
303
+ Array.isArray(value?.design?.[field]) &&
304
+ value.design[field].some((item) => item && Object.hasOwn(item, 'props')),
305
+ ) ||
306
+ value?.design?.layout !== undefined ||
307
+ (Array.isArray(value?.design?.frames) &&
308
+ value.design.frames.some(({ height }) => height === 'auto'))
309
+ ? DESIGN_REVIEW_BUNDLE_CURRENT_SCHEMA
310
+ : value?.schemaVersion === '1.2.0'
311
+ ? DESIGN_REVIEW_BUNDLE_V12_SCHEMA
312
+ : value?.schemaVersion === '1.1.0'
313
+ ? DESIGN_REVIEW_BUNDLE_V11_SCHEMA
314
+ : DESIGN_REVIEW_BUNDLE_SCHEMA,
245
315
  );
316
+ const propErrors = validateDesignProps(value.design);
317
+ if (propErrors.length) throw new TypeError(`Invalid design props:\n${propErrors.join('\n')}`);
246
318
  if (['1.1.0', '1.2.0'].includes(value.schemaVersion)) {
247
319
  if (
248
320
  value.reviewContext.designId !== value.design.id ||
@@ -0,0 +1,57 @@
1
+ export interface ShapeReference {
2
+ packId: string;
3
+ packVersion: string;
4
+ shapeId: string;
5
+ definitionDigest: string;
6
+ }
7
+ export type DiagramShapeReference = ShapeReference;
8
+ export interface ShapePoint {
9
+ x: number;
10
+ y: number;
11
+ }
12
+ export interface ShapeRect {
13
+ type: 'rect';
14
+ x: number;
15
+ y: number;
16
+ width: number;
17
+ height: number;
18
+ radius: number;
19
+ }
20
+ export interface ShapeEllipse {
21
+ type: 'ellipse';
22
+ cx: number;
23
+ cy: number;
24
+ rx: number;
25
+ ry: number;
26
+ }
27
+ export interface ShapePolygon {
28
+ type: 'polygon';
29
+ points: ShapePoint[];
30
+ }
31
+ export type ShapeOutline = ShapeRect | ShapeEllipse | ShapePolygon;
32
+ export type ShapePrimitive =
33
+ | (ShapeOutline & { fill: 'fill' | 'none'; stroke: 'stroke' | 'none' })
34
+ | { type: 'line'; x1: number; y1: number; x2: number; y2: number; stroke: 'stroke' | 'none' };
35
+ export interface ShapeDefinition extends ShapeReference {
36
+ name: string;
37
+ description: string;
38
+ tags: string[];
39
+ primitives: ShapePrimitive[];
40
+ attachment: ShapeOutline;
41
+ textRegion: { x: number; y: number; width: number; height: number };
42
+ sizing: { width: number; height: number; minWidth: number; minHeight: number };
43
+ }
44
+ export type DiagramShapeDefinition = ShapeDefinition;
45
+ export declare const SHAPE_REFERENCE_SCHEMA: Record<string, unknown>;
46
+ export declare const SHAPE_DEFINITION_SCHEMA: Record<string, unknown>;
47
+ export declare const SHAPE_LIBRARY_SCHEMA: Record<string, unknown>;
48
+ export declare function shapeReferenceKey(value: ShapeReference): string;
49
+ export declare function shapeDefinitionDigest(
50
+ value: Omit<ShapeDefinition, 'definitionDigest'> | ShapeDefinition,
51
+ ): string;
52
+ export declare function assertShapeDefinition<T>(value: T): T;
53
+ export declare function assertShapeLibrary<T>(value: T): T;
54
+ export declare function assertShapeReference(
55
+ value: ShapeReference,
56
+ library: ShapeDefinition[] | null | undefined,
57
+ ): ShapeDefinition;
@@ -0,0 +1,266 @@
1
+ import { canonicalizeJson, sha256Hex } from './canonical-json.mjs';
2
+ import { assertDiagramData } from './diagram-authoring-contracts.mjs';
3
+ import { validateJson } from './json-schema.mjs';
4
+
5
+ const closed = (properties) => ({
6
+ type: 'object',
7
+ additionalProperties: false,
8
+ required: Object.keys(properties),
9
+ properties,
10
+ });
11
+ const unit = { type: 'number', minimum: 0, maximum: 1 };
12
+ const extent = { type: 'number', exclusiveMinimum: 0, maximum: 1 };
13
+ const point = closed({ x: unit, y: unit });
14
+ const identifier = { type: 'string', pattern: '^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$', maxLength: 128 };
15
+ const version = { type: 'string', pattern: '^[0-9]+\\.[0-9]+\\.[0-9]+$', maxLength: 32 };
16
+ const digest = { type: 'string', pattern: '^sha256:[a-f0-9]{64}$' };
17
+ const rect = {
18
+ type: { const: 'rect' },
19
+ x: unit,
20
+ y: unit,
21
+ width: extent,
22
+ height: extent,
23
+ radius: unit,
24
+ };
25
+ const ellipse = { type: { const: 'ellipse' }, cx: unit, cy: unit, rx: extent, ry: extent };
26
+ const polygon = {
27
+ type: { const: 'polygon' },
28
+ points: { type: 'array', minItems: 3, maxItems: 32, items: point },
29
+ };
30
+ const paint = { fill: { enum: ['fill', 'none'] }, stroke: { enum: ['stroke', 'none'] } };
31
+ const pixels = { type: 'number', minimum: 1, maximum: 10000 };
32
+
33
+ export const SHAPE_REFERENCE_SCHEMA = closed({
34
+ packId: identifier,
35
+ packVersion: version,
36
+ shapeId: identifier,
37
+ definitionDigest: digest,
38
+ });
39
+ export const SHAPE_DEFINITION_SCHEMA = {
40
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
41
+ $id: 'https://openplanr.dev/schemas/v1.21.0/diagram-shape-definition.schema.json',
42
+ 'x-openplanr-contract': { id: 'diagram-shape-definition', version: '1.21.0' },
43
+ ...closed({
44
+ ...SHAPE_REFERENCE_SCHEMA.properties,
45
+ name: { type: 'string', minLength: 1, maxLength: 128 },
46
+ description: { type: 'string', maxLength: 1024 },
47
+ tags: {
48
+ type: 'array',
49
+ maxItems: 16,
50
+ uniqueItems: true,
51
+ items: { type: 'string', minLength: 1, maxLength: 64 },
52
+ },
53
+ primitives: {
54
+ type: 'array',
55
+ minItems: 1,
56
+ maxItems: 32,
57
+ items: {
58
+ oneOf: [
59
+ closed({ ...rect, ...paint }),
60
+ closed({ ...ellipse, ...paint }),
61
+ closed({ ...polygon, ...paint }),
62
+ closed({
63
+ type: { const: 'line' },
64
+ x1: unit,
65
+ y1: unit,
66
+ x2: unit,
67
+ y2: unit,
68
+ stroke: paint.stroke,
69
+ }),
70
+ ],
71
+ },
72
+ },
73
+ attachment: { oneOf: [closed(rect), closed(ellipse), closed(polygon)] },
74
+ textRegion: closed({ x: unit, y: unit, width: extent, height: extent }),
75
+ sizing: closed({ width: pixels, height: pixels, minWidth: pixels, minHeight: pixels }),
76
+ }),
77
+ };
78
+ export const SHAPE_LIBRARY_SCHEMA = {
79
+ type: 'array',
80
+ maxItems: 512,
81
+ items: SHAPE_DEFINITION_SCHEMA,
82
+ };
83
+
84
+ export function shapeReferenceKey(value) {
85
+ return `${value.packId}@${value.packVersion}/${value.shapeId}`;
86
+ }
87
+
88
+ export function shapeDefinitionDigest(value) {
89
+ assertDiagramData(value);
90
+ const { definitionDigest: _digest, ...definition } = value;
91
+ return `sha256:${sha256Hex(canonicalizeJson(definition))}`;
92
+ }
93
+
94
+ function assertConvexPolygon(points, label) {
95
+ let orientation = 0;
96
+ for (let index = 0; index < points.length; index += 1) {
97
+ const a = points[index];
98
+ const b = points[(index + 1) % points.length];
99
+ const c = points[(index + 2) % points.length];
100
+ const cross = (b.x - a.x) * (c.y - b.y) - (b.y - a.y) * (c.x - b.x);
101
+ if (a.x === b.x && a.y === b.y)
102
+ throw new TypeError(`${label}: polygon has duplicate adjacent points.`);
103
+ if (cross !== 0) {
104
+ if (orientation !== 0 && Math.sign(cross) !== orientation)
105
+ throw new TypeError(`${label}: polygon must be convex.`);
106
+ orientation = Math.sign(cross);
107
+ }
108
+ }
109
+ if (orientation === 0) throw new TypeError(`${label}: polygon has no area.`);
110
+ // Every other vertex must lie on the same side of each edge, excluding self intersections.
111
+ for (let index = 0; index < points.length; index += 1) {
112
+ const a = points[index];
113
+ const b = points[(index + 1) % points.length];
114
+ for (const c of points) {
115
+ const cross = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
116
+ if (cross * orientation < -1e-10)
117
+ throw new TypeError(`${label}: polygon must be simple and convex.`);
118
+ }
119
+ }
120
+ }
121
+
122
+ function assertGeometry(value, label) {
123
+ if (value.type === 'ellipse') {
124
+ if (
125
+ value.cx - value.rx < 0 ||
126
+ value.cy - value.ry < 0 ||
127
+ value.cx + value.rx > 1 ||
128
+ value.cy + value.ry > 1
129
+ )
130
+ throw new TypeError(`${label}: ellipse exceeds normalized bounds.`);
131
+ } else if (value.type === 'polygon') {
132
+ assertConvexPolygon(value.points, label);
133
+ } else if (value.type !== 'line') {
134
+ if (
135
+ value.x + value.width > 1 ||
136
+ value.y + value.height > 1 ||
137
+ (value.radius ?? 0) > Math.min(value.width, value.height) / 2
138
+ )
139
+ throw new TypeError(`${label}: rectangle exceeds normalized bounds or radius.`);
140
+ }
141
+ }
142
+
143
+ // Normalized geometry only needs allowance for floating-point roundoff.
144
+ const GEOMETRY_ROUNDOFF = Number.EPSILON * 32;
145
+ function primitiveVertices(primitive) {
146
+ if (primitive.type === 'polygon') return primitive.points;
147
+ if (primitive.type === 'line')
148
+ return [
149
+ { x: primitive.x1, y: primitive.y1 },
150
+ { x: primitive.x2, y: primitive.y2 },
151
+ ];
152
+ const x = primitive.type === 'ellipse' ? primitive.cx - primitive.rx : primitive.x;
153
+ const y = primitive.type === 'ellipse' ? primitive.cy - primitive.ry : primitive.y;
154
+ const width = primitive.type === 'ellipse' ? primitive.rx * 2 : primitive.width;
155
+ const height = primitive.type === 'ellipse' ? primitive.ry * 2 : primitive.height;
156
+ return [
157
+ { x, y },
158
+ { x: x + width, y },
159
+ { x: x + width, y: y + height },
160
+ { x, y: y + height },
161
+ ];
162
+ }
163
+ function primitiveSupport(primitive, nx, ny) {
164
+ if (primitive.type === 'ellipse')
165
+ return primitive.cx * nx + primitive.cy * ny + Math.hypot(primitive.rx * nx, primitive.ry * ny);
166
+ // Rounded corners scale uniformly, so only the rectangle envelope survives every aspect ratio.
167
+ return Math.max(...primitiveVertices(primitive).map(({ x, y }) => x * nx + y * ny));
168
+ }
169
+ function containsPoint(outline, point) {
170
+ if (outline.type === 'ellipse')
171
+ return (
172
+ Math.hypot((point.x - outline.cx) / outline.rx, (point.y - outline.cy) / outline.ry) <=
173
+ 1 + GEOMETRY_ROUNDOFF
174
+ );
175
+ const dx = Math.max(
176
+ outline.x + outline.radius - point.x,
177
+ point.x - (outline.x + outline.width - outline.radius),
178
+ 0,
179
+ );
180
+ const dy = Math.max(
181
+ outline.y + outline.radius - point.y,
182
+ point.y - (outline.y + outline.height - outline.radius),
183
+ 0,
184
+ );
185
+ return Math.hypot(dx, dy) <= outline.radius + GEOMETRY_ROUNDOFF;
186
+ }
187
+ function assertPrimitiveContainment(primitive, outline, label) {
188
+ const { fill: _fill, stroke: _stroke, ...geometry } = primitive;
189
+ if (canonicalizeJson(geometry) === canonicalizeJson(outline)) return;
190
+ if (outline.type === 'polygon') {
191
+ const points = outline.points;
192
+ let sign = 0;
193
+ for (let index = 0; index < points.length && sign === 0; index += 1) {
194
+ const a = points[index],
195
+ b = points[(index + 1) % points.length],
196
+ c = points[(index + 2) % points.length];
197
+ sign = Math.sign((b.x - a.x) * (c.y - b.y) - (b.y - a.y) * (c.x - b.x));
198
+ }
199
+ for (let index = 0; index < points.length; index += 1) {
200
+ const a = points[index],
201
+ b = points[(index + 1) % points.length];
202
+ const length = Math.hypot(b.x - a.x, b.y - a.y);
203
+ const nx = (sign * (b.y - a.y)) / length,
204
+ ny = (sign * (a.x - b.x)) / length;
205
+ if (primitiveSupport(primitive, nx, ny) > a.x * nx + a.y * ny + GEOMETRY_ROUNDOFF)
206
+ throw new TypeError(
207
+ `${label}: primitive exceeds its attachment outline; keep decoration geometry and rounded-rectangle bounds inside the declared boundary.`,
208
+ );
209
+ }
210
+ return;
211
+ }
212
+ if (!primitiveVertices(primitive).every((point) => containsPoint(outline, point)))
213
+ throw new TypeError(
214
+ `${label}: primitive envelope exceeds its attachment outline; curved decorations require their axis-aligned bounds inside the declared boundary.`,
215
+ );
216
+ }
217
+
218
+ export function assertShapeDefinition(value) {
219
+ assertDiagramData(value);
220
+ const failures = validateJson(value, SHAPE_DEFINITION_SCHEMA);
221
+ if (failures.length)
222
+ throw new TypeError(
223
+ `Invalid shape definition: ${failures[0].path} ${failures[0].detail ?? failures[0].rule}.`,
224
+ );
225
+ const key = shapeReferenceKey(value);
226
+ if (shapeDefinitionDigest(value) !== value.definitionDigest)
227
+ throw new TypeError(`Shape ${key}: definition digest does not match.`);
228
+ for (const primitive of value.primitives) assertGeometry(primitive, `Shape ${key}`);
229
+ assertGeometry(value.attachment, `Shape ${key} attachment`);
230
+ const { fill: _fill, stroke: _stroke, ...outline } = value.primitives[0];
231
+ if (canonicalizeJson(outline) !== canonicalizeJson(value.attachment))
232
+ throw new TypeError(`Shape ${key}: first primitive must match its attachment outline.`);
233
+ for (const [index, primitive] of value.primitives.entries())
234
+ assertPrimitiveContainment(primitive, value.attachment, `Shape ${key} primitive ${index}`);
235
+ assertGeometry(value.textRegion, `Shape ${key} text region`);
236
+ if (value.sizing.width < value.sizing.minWidth || value.sizing.height < value.sizing.minHeight)
237
+ throw new TypeError(`Shape ${key}: default size is below its minimum size.`);
238
+ return value;
239
+ }
240
+
241
+ export function assertShapeLibrary(value) {
242
+ assertDiagramData(value);
243
+ if (validateJson(value, SHAPE_LIBRARY_SCHEMA).length)
244
+ throw new TypeError('Invalid shape library: expected at most 512 inert shape definitions.');
245
+ const keys = new Set();
246
+ for (const definition of value) {
247
+ assertShapeDefinition(definition);
248
+ const key = shapeReferenceKey(definition);
249
+ if (keys.has(key)) throw new TypeError(`Shape library contains duplicate identity ${key}.`);
250
+ keys.add(key);
251
+ }
252
+ return value;
253
+ }
254
+
255
+ export function assertShapeReference(value, library) {
256
+ assertDiagramData(value);
257
+ if (validateJson(value, SHAPE_REFERENCE_SCHEMA).length)
258
+ throw new TypeError('Invalid shape reference.');
259
+ const key = shapeReferenceKey(value);
260
+ const definition = library?.find((entry) => shapeReferenceKey(entry) === key);
261
+ if (!definition)
262
+ throw new TypeError(`Shape ${key}: definition is missing from the document library.`);
263
+ if (definition.definitionDigest !== value.definitionDigest)
264
+ throw new TypeError(`Shape ${key}: reference digest does not match its definition.`);
265
+ return definition;
266
+ }
@@ -4,6 +4,7 @@ import type {
4
4
  DiagramEditTransaction,
5
5
  } from './diagram-authoring-contracts.mjs';
6
6
  import type { DiagramReviewBundle } from './diagram-review-contracts.mjs';
7
+ import type { ShapeDefinition } from './shape-library-contracts.mjs';
7
8
  export interface DiagramPresentation {
8
9
  kind: 'openplanr-diagram-presentation';
9
10
  schemaVersion: '2.0.0';
@@ -53,7 +54,19 @@ export type DiagramAuthoringBundleV11 = Omit<
53
54
  DiagramAuthoringBundle,
54
55
  'schemaVersion' | 'protocolVersion'
55
56
  > & { schemaVersion: '1.1.0'; protocolVersion: '1.17.0'; studioPresentation: DiagramPresentation };
56
- export type VersionedDiagramAuthoringBundle = DiagramAuthoringBundle | DiagramAuthoringBundleV11;
57
+ export type DiagramAuthoringBundleV12 = Omit<
58
+ DiagramAuthoringBundle,
59
+ 'schemaVersion' | 'protocolVersion'
60
+ > & {
61
+ schemaVersion: '1.2.0';
62
+ protocolVersion: '1.21.0';
63
+ shapeLibrary: ShapeDefinition[];
64
+ studioPresentation?: DiagramPresentation;
65
+ };
66
+ export type VersionedDiagramAuthoringBundle =
67
+ | (DiagramAuthoringBundle & { studioPresentation?: never; shapeLibrary?: never })
68
+ | (DiagramAuthoringBundleV11 & { shapeLibrary?: never })
69
+ | DiagramAuthoringBundleV12;
57
70
  export interface SetStudioPresentationOperation {
58
71
  type: 'set-studio-presentation';
59
72
  before: DiagramPresentation | null;
@@ -67,7 +80,42 @@ export type DiagramEditTransactionV11 = Omit<
67
80
  protocolVersion: '1.17.0';
68
81
  operations: Array<DiagramEditOperation | SetStudioPresentationOperation>;
69
82
  };
70
- export type VersionedDiagramEditTransaction = DiagramEditTransaction | DiagramEditTransactionV11;
83
+ export interface SetShapeLibraryOperation {
84
+ type: 'set-shape-library';
85
+ before: ShapeDefinition[] | null;
86
+ after: ShapeDefinition[] | null;
87
+ }
88
+ export type DiagramEditTransactionV12 = Omit<
89
+ DiagramEditTransaction,
90
+ 'schemaVersion' | 'protocolVersion' | 'operations'
91
+ > & {
92
+ schemaVersion: '1.2.0';
93
+ protocolVersion: '1.21.0';
94
+ operations: Array<
95
+ DiagramEditOperation | SetStudioPresentationOperation | SetShapeLibraryOperation
96
+ >;
97
+ };
98
+ export type VersionedDiagramEditTransaction =
99
+ | DiagramEditTransaction
100
+ | DiagramEditTransactionV11
101
+ | DiagramEditTransactionV12;
102
+ export declare const DIAGRAM_AUTHORING_BUNDLE_V12_SCHEMA: Record<string, unknown>;
103
+ export declare const DIAGRAM_EDIT_TRANSACTION_V12_SCHEMA: Record<string, unknown>;
104
+ export declare const DIAGRAM_REVIEW_BUNDLE_V12_SCHEMA: Record<string, unknown>;
105
+ export type DiagramReviewBundleV12 = Omit<DiagramReviewBundle, 'schemaVersion' | 'authored'> & {
106
+ schemaVersion: '1.2.0';
107
+ presentation?: DiagramPresentation;
108
+ authored?: VersionedDiagramAuthoringBundle;
109
+ };
110
+ export declare function supportsDiagramShapeLibrary(value: unknown): boolean;
111
+ export declare function supportsDiagramStudioPresentation(value: unknown): boolean;
112
+ export declare function diagramAuthoringVersionFields(value: {
113
+ shapeLibrary?: ShapeDefinition[];
114
+ studioPresentation?: DiagramPresentation | null;
115
+ }):
116
+ | { schemaVersion: '1.2.0'; protocolVersion: '1.21.0' }
117
+ | { schemaVersion: '1.1.0'; protocolVersion: '1.17.0' }
118
+ | { schemaVersion: '1.0.0'; protocolVersion: '1.13.0' };
71
119
 
72
120
  export declare function validateVersionedDiagramAuthoringArtifact(
73
121
  kind: string,