@openplanr/protocol 0.13.0 → 0.14.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.
@@ -7,6 +7,16 @@ import { validateJson } from './json-schema.mjs';
7
7
  */
8
8
  export const DESIGN_DOCUMENT_VERSION = '1.0.0';
9
9
 
10
+ /** Initial viewport height for content-sized frames.
11
+ * @type {typeof import('./design-contracts.d.mts').initialFrameHeight}
12
+ */
13
+ export function initialFrameHeight(document) {
14
+ const fixed = document.frames.flatMap(({ height }) =>
15
+ typeof height === 'number' && Number.isInteger(height) ? [height] : [],
16
+ );
17
+ return fixed.length ? Math.max(...fixed) : 900;
18
+ }
19
+
10
20
  const freeze = (value) => {
11
21
  if (value && typeof value === 'object') {
12
22
  for (const nested of Object.values(value)) freeze(nested);
@@ -15,12 +25,28 @@ const freeze = (value) => {
15
25
  return value;
16
26
  };
17
27
 
28
+ const FRAME_SCHEMA = {
29
+ type: 'array',
30
+ minItems: 1,
31
+ items: {
32
+ type: 'object',
33
+ additionalProperties: false,
34
+ required: ['id', 'label', 'width', 'height'],
35
+ properties: {
36
+ id: { $ref: '#/$defs/id' },
37
+ label: { $ref: '#/$defs/text' },
38
+ width: { type: 'integer', minimum: 1, maximum: 16384 },
39
+ height: { type: 'integer', minimum: 1, maximum: 16384 },
40
+ },
41
+ },
42
+ };
43
+
18
44
  /**
19
45
  * Portable source of truth for the packaged Protocol 1.9 schema. Rendering,
20
46
  * file existence, symlink containment and revisions belong to the design domain.
21
- * @type {typeof import('./design-contracts.d.mts').DESIGN_DOCUMENT_SCHEMA}
47
+ * @type {typeof import('./design-contracts.d.mts').DESIGN_DOCUMENT_V1_SCHEMA}
22
48
  */
23
- export const DESIGN_DOCUMENT_SCHEMA = freeze({
49
+ export const DESIGN_DOCUMENT_V1_SCHEMA = freeze({
24
50
  $schema: 'https://json-schema.org/draft/2020-12/schema',
25
51
  $id: 'https://openplanr.dev/schemas/v1.9.0/design-document.schema.json',
26
52
  'x-openplanr-contract': { id: 'design-document', version: '1.9.0' },
@@ -71,21 +97,7 @@ export const DESIGN_DOCUMENT_SCHEMA = freeze({
71
97
  },
72
98
  },
73
99
  assets: { $ref: '#/$defs/paths' },
74
- frames: {
75
- type: 'array',
76
- minItems: 1,
77
- items: {
78
- type: 'object',
79
- additionalProperties: false,
80
- required: ['id', 'label', 'width', 'height'],
81
- properties: {
82
- id: { $ref: '#/$defs/id' },
83
- label: { $ref: '#/$defs/text' },
84
- width: { type: 'integer', minimum: 1, maximum: 16384 },
85
- height: { type: 'integer', minimum: 1, maximum: 16384 },
86
- },
87
- },
88
- },
100
+ frames: FRAME_SCHEMA,
89
101
  screens: {
90
102
  type: 'array',
91
103
  minItems: 1,
@@ -163,6 +175,66 @@ export const DESIGN_DOCUMENT_SCHEMA = freeze({
163
175
  },
164
176
  });
165
177
 
178
+ /** @type {typeof import('./design-contracts.d.mts').DESIGN_DOCUMENT_SCHEMA} */
179
+ export const DESIGN_DOCUMENT_SCHEMA = freeze({
180
+ ...DESIGN_DOCUMENT_V1_SCHEMA,
181
+ $id: 'https://openplanr.dev/schemas/v1.20.0/design-document.schema.json',
182
+ 'x-openplanr-contract': { id: 'design-document', version: '1.20.0' },
183
+ properties: {
184
+ .../** @type {Record<string, unknown>} */ (DESIGN_DOCUMENT_V1_SCHEMA.properties),
185
+ frames: {
186
+ ...FRAME_SCHEMA,
187
+ items: {
188
+ ...FRAME_SCHEMA.items,
189
+ properties: {
190
+ ...FRAME_SCHEMA.items.properties,
191
+ height: { anyOf: [{ type: 'integer', minimum: 1, maximum: 16384 }, { const: 'auto' }] },
192
+ },
193
+ },
194
+ },
195
+ layout: {
196
+ type: 'object',
197
+ additionalProperties: false,
198
+ properties: {
199
+ boards: {
200
+ type: 'object',
201
+ description:
202
+ 'Keys are screenId, screenId/frameId or screenId/frameId/variantId; each ID must exist in the document.',
203
+ additionalProperties: {
204
+ type: 'object',
205
+ additionalProperties: false,
206
+ required: ['x', 'y'],
207
+ properties: {
208
+ x: { $ref: '#/$defs/coordinate' },
209
+ y: { $ref: '#/$defs/coordinate' },
210
+ title: { $ref: '#/$defs/text' },
211
+ },
212
+ },
213
+ },
214
+ sections: {
215
+ type: 'array',
216
+ items: {
217
+ type: 'object',
218
+ additionalProperties: false,
219
+ required: ['id', 'x', 'y', 'text'],
220
+ properties: {
221
+ id: { $ref: '#/$defs/id' },
222
+ x: { $ref: '#/$defs/coordinate' },
223
+ y: { $ref: '#/$defs/coordinate' },
224
+ text: { $ref: '#/$defs/text' },
225
+ maxW: { type: 'integer', minimum: 1, maximum: 16384 },
226
+ },
227
+ },
228
+ },
229
+ },
230
+ },
231
+ },
232
+ $defs: {
233
+ .../** @type {Record<string, unknown>} */ (DESIGN_DOCUMENT_V1_SCHEMA.$defs),
234
+ coordinate: { type: 'number', minimum: -1e7, maximum: 1e7 },
235
+ },
236
+ });
237
+
166
238
  /**
167
239
  * Validate structure plus stable identity and cross-reference constraints.
168
240
  * @returns {ReturnType<typeof import('./design-contracts.d.mts').validateDesignDocument>}
@@ -200,6 +272,36 @@ export function validateDesignDocument(value) {
200
272
  if (!screenIds.has(id)) errors.push(`$.variants[${index}].sources: unknown screen '${id}'`);
201
273
  }
202
274
  }
275
+ const frameIds = new Set(value.frames.map(({ id }) => id));
276
+ const variantIds = new Set(value.variants.map(({ id }) => id));
277
+ for (const [key, position] of Object.entries(value.layout?.boards ?? {})) {
278
+ const parts = key.split('/');
279
+ const path = `$.layout.boards['${key}']`;
280
+ if (parts.length > 3 || parts.some((id) => !/^[A-Za-z][A-Za-z0-9_-]{0,127}$/.test(id))) {
281
+ errors.push(`${path}: expected screenId, screenId/frameId or screenId/frameId/variantId`);
282
+ } else {
283
+ const [screenId, frameId, variantId] = parts;
284
+ if (!screenIds.has(screenId)) errors.push(`${path}: unknown screen '${screenId}'`);
285
+ if (frameId !== undefined && !frameIds.has(frameId))
286
+ errors.push(`${path}: unknown frame '${frameId}'`);
287
+ if (variantId !== undefined && !variantIds.has(variantId))
288
+ errors.push(`${path}: unknown variant '${variantId}'`);
289
+ }
290
+ for (const axis of ['x', 'y']) {
291
+ if (!Number.isFinite(position[axis]))
292
+ errors.push(`${path}.${axis}: expected a finite coordinate`);
293
+ }
294
+ }
295
+ const sectionIds = new Set();
296
+ for (const [index, section] of (value.layout?.sections ?? []).entries()) {
297
+ if (sectionIds.has(section.id))
298
+ errors.push(`$.layout.sections[${index}].id: duplicate identity '${section.id}'`);
299
+ sectionIds.add(section.id);
300
+ for (const axis of ['x', 'y']) {
301
+ if (!Number.isFinite(section[axis]))
302
+ errors.push(`$.layout.sections[${index}].${axis}: expected a finite coordinate`);
303
+ }
304
+ }
203
305
  const selected = value.variants.find(({ id }) => id === value.selectedVariant);
204
306
  if (!selected) errors.push(`$.selectedVariant: unknown variant '${value.selectedVariant}'`);
205
307
  else if (selected.status !== 'ready')
@@ -2,6 +2,7 @@
2
2
  /** Company publication constraints over the existing, compatible review bundle. */
3
3
 
4
4
  import { canonicalizeJson, sha256Hex } from './canonical-json.mjs';
5
+ import { initialFrameHeight } from './design-contracts.mjs';
5
6
  import { assertDesignReviewBundle } from './review-experience-contracts.mjs';
6
7
 
7
8
  /** @type {typeof import('./design-publication-contracts.d.mts').COMPANY_DESIGN_MAX_BYTES} */
@@ -120,7 +121,8 @@ export function assertCompanyDesignBundle(value) {
120
121
  fail('entries must uniquely map artboards to artifacts.');
121
122
  usedArtifacts.add(entry.artifactId);
122
123
  combinations.add(key);
123
- if (artifact.viewport.width !== frame.width || artifact.viewport.height !== frame.height)
124
+ const height = frame.height === 'auto' ? initialFrameHeight(design) : frame.height;
125
+ if (artifact.viewport.width !== frame.width || artifact.viewport.height !== height)
124
126
  fail('artifact viewport must match its declared frame.');
125
127
  }
126
128
  closed(envelope.viewer, ['mode', 'activeArtifactId', 'presentation'], 'viewer');
@@ -1,3 +1,4 @@
1
+ import type { ShapeReference } from './shape-library-contracts.mjs';
1
2
  export type DiagramAuthoringDigest = `sha256:${string}`;
2
3
  export type DiagramAuthoringProfile = 'flowchart' | 'process' | 'swimlane' | 'architecture';
3
4
  export type DiagramAuthoringNodeKind =
@@ -110,6 +111,7 @@ export interface DiagramRoute {
110
111
  points: Array<{ x: number; y: number }>;
111
112
  }
112
113
  export interface DiagramAppearance {
114
+ shapeRef?: ShapeReference;
113
115
  shape:
114
116
  | 'rectangle'
115
117
  | 'rounded-rectangle'
@@ -1465,7 +1465,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
1465
1465
  "ownerPackage": "openplanr",
1466
1466
  "source": {
1467
1467
  "path": "packages/cli/src/cli/commands/doctor.ts",
1468
- "digest": "sha256:11a1b5732b15ab42862719f0924c57cd6c07b925b10bbe49a3b1c6356c7a3f8d"
1468
+ "digest": "sha256:cdb7e033ae890130d47d06936d0e5b10f38a4b803c39f62abef72add38160e1e"
1469
1469
  },
1470
1470
  "authorityClass": "workflow",
1471
1471
  "machineJson": false,
@@ -1507,7 +1507,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
1507
1507
  "ownerPackage": "openplanr",
1508
1508
  "source": {
1509
1509
  "path": "skills/planr-plan/SKILL.md",
1510
- "digest": "sha256:71ab2272efa19f817af597de0bf5aee163bcb1cd17418998107f21a412e91996"
1510
+ "digest": "sha256:ee27dc8136cada6ffed75baa68ebdfd12c4d6414b069d4c89e627e4ec8beb68e"
1511
1511
  },
1512
1512
  "authorityClass": "workflow",
1513
1513
  "machineJson": false,
@@ -1528,7 +1528,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
1528
1528
  "ownerPackage": "openplanr",
1529
1529
  "source": {
1530
1530
  "path": "docs/generated/utility-command-catalog.json",
1531
- "digest": "sha256:af86a0898b4fe76e08a4078c7afe8f70094efdcd63e642a0d61ec02709d680b0"
1531
+ "digest": "sha256:70f33f5d875899bb2c2b861b6c880aebda58c071d9c11abd3712362318974f15"
1532
1532
  },
1533
1533
  "authorityClass": "workflow",
1534
1534
  "machineJson": false,
@@ -1717,7 +1717,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
1717
1717
  "ownerPackage": "openplanr",
1718
1718
  "source": {
1719
1719
  "path": "docs/generated/utility-command-catalog.json",
1720
- "digest": "sha256:af86a0898b4fe76e08a4078c7afe8f70094efdcd63e642a0d61ec02709d680b0"
1720
+ "digest": "sha256:70f33f5d875899bb2c2b861b6c880aebda58c071d9c11abd3712362318974f15"
1721
1721
  },
1722
1722
  "authorityClass": "workflow",
1723
1723
  "machineJson": true,
@@ -1738,7 +1738,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
1738
1738
  "ownerPackage": "openplanr",
1739
1739
  "source": {
1740
1740
  "path": "skills/planr-plan/SKILL.md",
1741
- "digest": "sha256:71ab2272efa19f817af597de0bf5aee163bcb1cd17418998107f21a412e91996"
1741
+ "digest": "sha256:ee27dc8136cada6ffed75baa68ebdfd12c4d6414b069d4c89e627e4ec8beb68e"
1742
1742
  },
1743
1743
  "authorityClass": "workflow",
1744
1744
  "machineJson": false,
@@ -2179,7 +2179,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
2179
2179
  "ownerPackage": "planr-pipeline",
2180
2180
  "source": {
2181
2181
  "path": "skills/planr-design/SKILL.md",
2182
- "digest": "sha256:234ec0b1c7a983590982462a59df017647ed8d76e45727417534e483e2f5ab5b"
2182
+ "digest": "sha256:d4f027660fe2cc6e2a1bce254916fe65d01d0ad484f96eebb13f4711685143b8"
2183
2183
  },
2184
2184
  "authorityClass": "compatibility-router",
2185
2185
  "machineJson": false,
@@ -2242,7 +2242,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
2242
2242
  "ownerPackage": "planr-pipeline",
2243
2243
  "source": {
2244
2244
  "path": "skills/planr-plan/SKILL.md",
2245
- "digest": "sha256:71ab2272efa19f817af597de0bf5aee163bcb1cd17418998107f21a412e91996"
2245
+ "digest": "sha256:ee27dc8136cada6ffed75baa68ebdfd12c4d6414b069d4c89e627e4ec8beb68e"
2246
2246
  },
2247
2247
  "authorityClass": "compatibility-router",
2248
2248
  "machineJson": false,
@@ -2263,7 +2263,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
2263
2263
  "ownerPackage": "planr-pipeline",
2264
2264
  "source": {
2265
2265
  "path": "skills/planr-ship/SKILL.md",
2266
- "digest": "sha256:828f3b7a6bd1b6c42d257315bc3fcfc29a5db5ac478c797bb26d2a7553d010b1"
2266
+ "digest": "sha256:a1f65ddec4596070d9627e40d3cb4a1b59470bc1dd97ed68b1962aa30224b6ad"
2267
2267
  },
2268
2268
  "authorityClass": "compatibility-router",
2269
2269
  "machineJson": false,
@@ -3099,7 +3099,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
3099
3099
  ]
3100
3100
  }
3101
3101
  ],
3102
- "documentDigest": "sha256:0845b4b4bcc6cd45122ba6531c0c8793f05334012f18cfb58fb704940d3d9488"
3102
+ "documentDigest": "sha256:7f82307cddbb39e34a8c2399a6fbb950f0e1a293756201cc46896e7dc59a0edc"
3103
3103
  },
3104
3104
  "skills.json": {
3105
3105
  "kind": "skill-catalog",
@@ -3858,7 +3858,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
3858
3858
  "lifecycle": "active",
3859
3859
  "authorityClass": "planning-write",
3860
3860
  "source": "skills/planr-design/openplanr.skill.json",
3861
- "sourceDigest": "sha256:9572439c52794f550ec50012ca7b1ab695b39bd3cf7c1ec43a6606751133df43",
3861
+ "sourceDigest": "sha256:99baa3d561a0e0e603c8617e1ccce8e0cab27c6cd1304e47f6fd57379076bb95",
3862
3862
  "triggerPolicy": {
3863
3863
  "include": [
3864
3864
  "Create an initial product design direction",
@@ -3919,7 +3919,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
3919
3919
  "lifecycle": "active",
3920
3920
  "authorityClass": "planning-write",
3921
3921
  "source": "skills/planr-design-loop/openplanr.skill.json",
3922
- "sourceDigest": "sha256:c86d4ca6988fd5c1471d7dc99188929ea7d2d695d15df43adb2340198895fc27",
3922
+ "sourceDigest": "sha256:a1c876dc9bd9770ea7d5c43c8696f3be2e252dd52d084e9411b1d4842f25e636",
3923
3923
  "triggerPolicy": {
3924
3924
  "include": [
3925
3925
  "Explore multiple design directions or variants",
@@ -3980,7 +3980,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
3980
3980
  "lifecycle": "active",
3981
3981
  "authorityClass": "review-evidence",
3982
3982
  "source": "skills/planr-design-review/openplanr.skill.json",
3983
- "sourceDigest": "sha256:4a12e9dd2ae9a7246a6abb094623aa112591f58422e2632060a71564939ad592",
3983
+ "sourceDigest": "sha256:96d799efff004279b4726b0a285d42b660e3aff5527aa8e2a7ddf8fcee1a67c4",
3984
3984
  "triggerPolicy": {
3985
3985
  "include": [
3986
3986
  "Review or critique an existing OpenPlanr design",
@@ -4168,7 +4168,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
4168
4168
  "lifecycle": "active",
4169
4169
  "authorityClass": "diagnostic",
4170
4170
  "source": "skills/planr-investigate/openplanr.skill.json",
4171
- "sourceDigest": "sha256:7b594b78a18409eb195a7bb8a2c189c06cf9e8022361a82a2f7e344abb9e5f95",
4171
+ "sourceDigest": "sha256:ad1422ac497f638b739d362a93af8eddc9cd0634c8a737a2c408023bd5cb9797",
4172
4172
  "triggerPolicy": {
4173
4173
  "include": [
4174
4174
  "Investigate a bug, regression, error, or unexplained behavior",
@@ -4656,7 +4656,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
4656
4656
  "lifecycle": "active",
4657
4657
  "authorityClass": "implementation",
4658
4658
  "source": "skills/planr-ship/openplanr.skill.json",
4659
- "sourceDigest": "sha256:548373bee9817aa5649f53c6964b8911666c29aa9a55b5e6a7288ef12482179b",
4659
+ "sourceDigest": "sha256:2fe2353469bb1fbb77029334fcc51b94240bb3baf56c69c5829b47908e2d7d33",
4660
4660
  "triggerPolicy": {
4661
4661
  "include": [
4662
4662
  "Implement a plan, specification, task, fix, or clearly stated local request",
@@ -4967,7 +4967,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
4967
4967
  }
4968
4968
  ],
4969
4969
  "compatibilityAliases": [],
4970
- "documentDigest": "sha256:5db46f86c838f03bdf20e17067463b4281465a286a0c8ad276e05e3f0fefda93"
4970
+ "documentDigest": "sha256:7201c5ca3f0b6820214e18c4f6a5268e30b9b5be897ff092bb95e196230dbf0b"
4971
4971
  },
4972
4972
  "outputs.json": {
4973
4973
  "kind": "output-catalog",
package/src/index.d.mts CHANGED
@@ -13,6 +13,7 @@ export * from './json-schema.mjs';
13
13
  export * from './large-object-contracts.mjs';
14
14
  export * from './planning-contracts.mjs';
15
15
  export * from './registries.mjs';
16
+ export * from './shape-library-contracts.mjs';
16
17
  export * from './sharing-security-contracts.mjs';
17
18
  export {
18
19
  assertDiagramPresentation as assertDiagramReviewPresentation,
@@ -21,11 +22,17 @@ export {
21
22
  assertVersionedDiagramEditTransaction,
22
23
  assertVersionedDiagramReviewBundle,
23
24
  DIAGRAM_AUTHORING_BUNDLE_V11_SCHEMA,
25
+ DIAGRAM_AUTHORING_BUNDLE_V12_SCHEMA,
24
26
  DIAGRAM_EDIT_TRANSACTION_V11_SCHEMA,
27
+ DIAGRAM_EDIT_TRANSACTION_V12_SCHEMA,
25
28
  DIAGRAM_PRESENTATION_SCHEMA,
26
29
  DIAGRAM_REVIEW_BUNDLE_V11_SCHEMA,
30
+ DIAGRAM_REVIEW_BUNDLE_V12_SCHEMA,
31
+ diagramAuthoringVersionFields,
27
32
  legacyDiagramAuthoringProjection,
28
33
  normalizeDiagramPresentation,
34
+ supportsDiagramShapeLibrary,
35
+ supportsDiagramStudioPresentation,
29
36
  validateVersionedDiagramAuthoringBundle,
30
37
  validateVersionedDiagramEditTransaction,
31
38
  versionedDiagramAuthoringBundleDigest,
package/src/index.mjs CHANGED
@@ -58,6 +58,7 @@ export {
58
58
  routeLegacyTask,
59
59
  validateCanonicalRegistries,
60
60
  } from './registries.mjs';
61
+ export * from './shape-library-contracts.mjs';
61
62
  export * from './sharing-security-contracts.mjs';
62
63
  export {
63
64
  assertDiagramPresentation as assertDiagramReviewPresentation,
@@ -66,11 +67,17 @@ export {
66
67
  assertVersionedDiagramEditTransaction,
67
68
  assertVersionedDiagramReviewBundle,
68
69
  DIAGRAM_AUTHORING_BUNDLE_V11_SCHEMA,
70
+ DIAGRAM_AUTHORING_BUNDLE_V12_SCHEMA,
69
71
  DIAGRAM_EDIT_TRANSACTION_V11_SCHEMA,
72
+ DIAGRAM_EDIT_TRANSACTION_V12_SCHEMA,
70
73
  DIAGRAM_PRESENTATION_SCHEMA,
71
74
  DIAGRAM_REVIEW_BUNDLE_V11_SCHEMA,
75
+ DIAGRAM_REVIEW_BUNDLE_V12_SCHEMA,
76
+ diagramAuthoringVersionFields,
72
77
  legacyDiagramAuthoringProjection,
73
78
  normalizeDiagramPresentation,
79
+ supportsDiagramShapeLibrary,
80
+ supportsDiagramStudioPresentation,
74
81
  validateVersionedDiagramAuthoringBundle,
75
82
  validateVersionedDiagramEditTransaction,
76
83
  versionedDiagramAuthoringBundleDigest,
@@ -1,3 +1,4 @@
1
+ export declare const DESIGN_REVIEW_BUNDLE_CURRENT_SCHEMA: Readonly<Record<string, unknown>>;
1
2
  export declare const DESIGN_REVIEW_CONTEXT_SCHEMA: Readonly<Record<string, unknown>>;
2
3
  export declare const DESIGN_FINGERPRINT_SCHEMA: Readonly<Record<string, unknown>>;
3
4
  export declare const DESIGN_REVIEW_BUNDLE_V12_SCHEMA: Readonly<Record<string, unknown>>;
@@ -1,5 +1,7 @@
1
1
  // @ts-check
2
+
2
3
  import { canonicalizeJson, sha256Hex } from './canonical-json.mjs';
4
+ import { DESIGN_DOCUMENT_SCHEMA } from './design-contracts.mjs';
3
5
  import { validateJson } from './json-schema.mjs';
4
6
  import { DESIGN_REVIEW_BUNDLE_SCHEMA } from './workspace-contracts.mjs';
5
7
 
@@ -103,6 +105,30 @@ Object.assign(bundleV12.properties, {
103
105
  /** @type {typeof import('./review-experience-contracts.d.mts').DESIGN_REVIEW_BUNDLE_V12_SCHEMA} */
104
106
  export const DESIGN_REVIEW_BUNDLE_V12_SCHEMA = bundleV12;
105
107
 
108
+ const bundleCurrent = /** @type {MutableSchema} */ (structuredClone(bundleV12));
109
+ bundleCurrent.$id = 'https://openplanr.dev/schemas/v1.20.0/design-review-bundle.schema.json';
110
+ bundleCurrent['x-openplanr-contract'] = { id: 'design-review-bundle', version: '1.20.0' };
111
+ bundleCurrent.properties.schemaVersion = { enum: ['1.1.0', '1.2.0'] };
112
+ bundleCurrent.properties.envelope = bundleV11.properties.envelope;
113
+ bundleCurrent.allOf = [
114
+ {
115
+ if: { properties: { schemaVersion: { const: '1.2.0' } } },
116
+ then: { properties: { envelope: bundleV12.properties.envelope } },
117
+ },
118
+ ];
119
+ const currentDesign = /** @type {MutableSchema} */ (bundleCurrent.properties.design);
120
+ for (const key of ['frames', 'layout'])
121
+ currentDesign.properties[key] = /** @type {Record<string, unknown>} */ (
122
+ DESIGN_DOCUMENT_SCHEMA.properties
123
+ )[key];
124
+ bundleCurrent.$defs = structuredClone(DESIGN_DOCUMENT_SCHEMA.$defs);
125
+ const currentEntries = /** @type {{ items: { properties: Record<string, unknown> } }} */ (
126
+ bundleCurrent.properties.entries
127
+ );
128
+ currentEntries.items.properties.height = { const: 'auto' };
129
+ /** @type {typeof import('./review-experience-contracts.d.mts').DESIGN_REVIEW_BUNDLE_CURRENT_SCHEMA} */
130
+ export const DESIGN_REVIEW_BUNDLE_CURRENT_SCHEMA = bundleCurrent;
131
+
106
132
  const item = closed(
107
133
  {
108
134
  pinId: id,
@@ -237,11 +263,15 @@ export function assertDesignReviewMetadata(value) {
237
263
  export function assertDesignReviewBundle(value) {
238
264
  assertReviewExperience(
239
265
  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,
266
+ value?.design?.layout !== undefined ||
267
+ (Array.isArray(value?.design?.frames) &&
268
+ value.design.frames.some(({ height }) => height === 'auto'))
269
+ ? DESIGN_REVIEW_BUNDLE_CURRENT_SCHEMA
270
+ : value?.schemaVersion === '1.2.0'
271
+ ? DESIGN_REVIEW_BUNDLE_V12_SCHEMA
272
+ : value?.schemaVersion === '1.1.0'
273
+ ? DESIGN_REVIEW_BUNDLE_V11_SCHEMA
274
+ : DESIGN_REVIEW_BUNDLE_SCHEMA,
245
275
  );
246
276
  if (['1.1.0', '1.2.0'].includes(value.schemaVersion)) {
247
277
  if (
@@ -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;