@openplanr/protocol 0.12.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.
@@ -0,0 +1,457 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openplanr.dev/schemas/v1.21.0/diagram-shape-definition.schema.json",
4
+ "x-openplanr-contract": {
5
+ "id": "diagram-shape-definition",
6
+ "version": "1.21.0"
7
+ },
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "required": [
11
+ "packId",
12
+ "packVersion",
13
+ "shapeId",
14
+ "definitionDigest",
15
+ "name",
16
+ "description",
17
+ "tags",
18
+ "primitives",
19
+ "attachment",
20
+ "textRegion",
21
+ "sizing"
22
+ ],
23
+ "properties": {
24
+ "packId": {
25
+ "type": "string",
26
+ "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$",
27
+ "maxLength": 128
28
+ },
29
+ "packVersion": {
30
+ "type": "string",
31
+ "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$",
32
+ "maxLength": 32
33
+ },
34
+ "shapeId": {
35
+ "type": "string",
36
+ "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$",
37
+ "maxLength": 128
38
+ },
39
+ "definitionDigest": {
40
+ "type": "string",
41
+ "pattern": "^sha256:[a-f0-9]{64}$"
42
+ },
43
+ "name": {
44
+ "type": "string",
45
+ "minLength": 1,
46
+ "maxLength": 128
47
+ },
48
+ "description": {
49
+ "type": "string",
50
+ "maxLength": 1024
51
+ },
52
+ "tags": {
53
+ "type": "array",
54
+ "maxItems": 16,
55
+ "uniqueItems": true,
56
+ "items": {
57
+ "type": "string",
58
+ "minLength": 1,
59
+ "maxLength": 64
60
+ }
61
+ },
62
+ "primitives": {
63
+ "type": "array",
64
+ "minItems": 1,
65
+ "maxItems": 32,
66
+ "items": {
67
+ "oneOf": [
68
+ {
69
+ "type": "object",
70
+ "additionalProperties": false,
71
+ "required": [
72
+ "type",
73
+ "x",
74
+ "y",
75
+ "width",
76
+ "height",
77
+ "radius",
78
+ "fill",
79
+ "stroke"
80
+ ],
81
+ "properties": {
82
+ "type": {
83
+ "const": "rect"
84
+ },
85
+ "x": {
86
+ "type": "number",
87
+ "minimum": 0,
88
+ "maximum": 1
89
+ },
90
+ "y": {
91
+ "type": "number",
92
+ "minimum": 0,
93
+ "maximum": 1
94
+ },
95
+ "width": {
96
+ "type": "number",
97
+ "exclusiveMinimum": 0,
98
+ "maximum": 1
99
+ },
100
+ "height": {
101
+ "type": "number",
102
+ "exclusiveMinimum": 0,
103
+ "maximum": 1
104
+ },
105
+ "radius": {
106
+ "type": "number",
107
+ "minimum": 0,
108
+ "maximum": 1
109
+ },
110
+ "fill": {
111
+ "enum": [
112
+ "fill",
113
+ "none"
114
+ ]
115
+ },
116
+ "stroke": {
117
+ "enum": [
118
+ "stroke",
119
+ "none"
120
+ ]
121
+ }
122
+ }
123
+ },
124
+ {
125
+ "type": "object",
126
+ "additionalProperties": false,
127
+ "required": [
128
+ "type",
129
+ "cx",
130
+ "cy",
131
+ "rx",
132
+ "ry",
133
+ "fill",
134
+ "stroke"
135
+ ],
136
+ "properties": {
137
+ "type": {
138
+ "const": "ellipse"
139
+ },
140
+ "cx": {
141
+ "type": "number",
142
+ "minimum": 0,
143
+ "maximum": 1
144
+ },
145
+ "cy": {
146
+ "type": "number",
147
+ "minimum": 0,
148
+ "maximum": 1
149
+ },
150
+ "rx": {
151
+ "type": "number",
152
+ "exclusiveMinimum": 0,
153
+ "maximum": 1
154
+ },
155
+ "ry": {
156
+ "type": "number",
157
+ "exclusiveMinimum": 0,
158
+ "maximum": 1
159
+ },
160
+ "fill": {
161
+ "enum": [
162
+ "fill",
163
+ "none"
164
+ ]
165
+ },
166
+ "stroke": {
167
+ "enum": [
168
+ "stroke",
169
+ "none"
170
+ ]
171
+ }
172
+ }
173
+ },
174
+ {
175
+ "type": "object",
176
+ "additionalProperties": false,
177
+ "required": [
178
+ "type",
179
+ "points",
180
+ "fill",
181
+ "stroke"
182
+ ],
183
+ "properties": {
184
+ "type": {
185
+ "const": "polygon"
186
+ },
187
+ "points": {
188
+ "type": "array",
189
+ "minItems": 3,
190
+ "maxItems": 32,
191
+ "items": {
192
+ "type": "object",
193
+ "additionalProperties": false,
194
+ "required": [
195
+ "x",
196
+ "y"
197
+ ],
198
+ "properties": {
199
+ "x": {
200
+ "type": "number",
201
+ "minimum": 0,
202
+ "maximum": 1
203
+ },
204
+ "y": {
205
+ "type": "number",
206
+ "minimum": 0,
207
+ "maximum": 1
208
+ }
209
+ }
210
+ }
211
+ },
212
+ "fill": {
213
+ "enum": [
214
+ "fill",
215
+ "none"
216
+ ]
217
+ },
218
+ "stroke": {
219
+ "enum": [
220
+ "stroke",
221
+ "none"
222
+ ]
223
+ }
224
+ }
225
+ },
226
+ {
227
+ "type": "object",
228
+ "additionalProperties": false,
229
+ "required": [
230
+ "type",
231
+ "x1",
232
+ "y1",
233
+ "x2",
234
+ "y2",
235
+ "stroke"
236
+ ],
237
+ "properties": {
238
+ "type": {
239
+ "const": "line"
240
+ },
241
+ "x1": {
242
+ "type": "number",
243
+ "minimum": 0,
244
+ "maximum": 1
245
+ },
246
+ "y1": {
247
+ "type": "number",
248
+ "minimum": 0,
249
+ "maximum": 1
250
+ },
251
+ "x2": {
252
+ "type": "number",
253
+ "minimum": 0,
254
+ "maximum": 1
255
+ },
256
+ "y2": {
257
+ "type": "number",
258
+ "minimum": 0,
259
+ "maximum": 1
260
+ },
261
+ "stroke": {
262
+ "enum": [
263
+ "stroke",
264
+ "none"
265
+ ]
266
+ }
267
+ }
268
+ }
269
+ ]
270
+ }
271
+ },
272
+ "attachment": {
273
+ "oneOf": [
274
+ {
275
+ "type": "object",
276
+ "additionalProperties": false,
277
+ "required": [
278
+ "type",
279
+ "x",
280
+ "y",
281
+ "width",
282
+ "height",
283
+ "radius"
284
+ ],
285
+ "properties": {
286
+ "type": {
287
+ "const": "rect"
288
+ },
289
+ "x": {
290
+ "type": "number",
291
+ "minimum": 0,
292
+ "maximum": 1
293
+ },
294
+ "y": {
295
+ "type": "number",
296
+ "minimum": 0,
297
+ "maximum": 1
298
+ },
299
+ "width": {
300
+ "type": "number",
301
+ "exclusiveMinimum": 0,
302
+ "maximum": 1
303
+ },
304
+ "height": {
305
+ "type": "number",
306
+ "exclusiveMinimum": 0,
307
+ "maximum": 1
308
+ },
309
+ "radius": {
310
+ "type": "number",
311
+ "minimum": 0,
312
+ "maximum": 1
313
+ }
314
+ }
315
+ },
316
+ {
317
+ "type": "object",
318
+ "additionalProperties": false,
319
+ "required": [
320
+ "type",
321
+ "cx",
322
+ "cy",
323
+ "rx",
324
+ "ry"
325
+ ],
326
+ "properties": {
327
+ "type": {
328
+ "const": "ellipse"
329
+ },
330
+ "cx": {
331
+ "type": "number",
332
+ "minimum": 0,
333
+ "maximum": 1
334
+ },
335
+ "cy": {
336
+ "type": "number",
337
+ "minimum": 0,
338
+ "maximum": 1
339
+ },
340
+ "rx": {
341
+ "type": "number",
342
+ "exclusiveMinimum": 0,
343
+ "maximum": 1
344
+ },
345
+ "ry": {
346
+ "type": "number",
347
+ "exclusiveMinimum": 0,
348
+ "maximum": 1
349
+ }
350
+ }
351
+ },
352
+ {
353
+ "type": "object",
354
+ "additionalProperties": false,
355
+ "required": [
356
+ "type",
357
+ "points"
358
+ ],
359
+ "properties": {
360
+ "type": {
361
+ "const": "polygon"
362
+ },
363
+ "points": {
364
+ "type": "array",
365
+ "minItems": 3,
366
+ "maxItems": 32,
367
+ "items": {
368
+ "type": "object",
369
+ "additionalProperties": false,
370
+ "required": [
371
+ "x",
372
+ "y"
373
+ ],
374
+ "properties": {
375
+ "x": {
376
+ "type": "number",
377
+ "minimum": 0,
378
+ "maximum": 1
379
+ },
380
+ "y": {
381
+ "type": "number",
382
+ "minimum": 0,
383
+ "maximum": 1
384
+ }
385
+ }
386
+ }
387
+ }
388
+ }
389
+ }
390
+ ]
391
+ },
392
+ "textRegion": {
393
+ "type": "object",
394
+ "additionalProperties": false,
395
+ "required": [
396
+ "x",
397
+ "y",
398
+ "width",
399
+ "height"
400
+ ],
401
+ "properties": {
402
+ "x": {
403
+ "type": "number",
404
+ "minimum": 0,
405
+ "maximum": 1
406
+ },
407
+ "y": {
408
+ "type": "number",
409
+ "minimum": 0,
410
+ "maximum": 1
411
+ },
412
+ "width": {
413
+ "type": "number",
414
+ "exclusiveMinimum": 0,
415
+ "maximum": 1
416
+ },
417
+ "height": {
418
+ "type": "number",
419
+ "exclusiveMinimum": 0,
420
+ "maximum": 1
421
+ }
422
+ }
423
+ },
424
+ "sizing": {
425
+ "type": "object",
426
+ "additionalProperties": false,
427
+ "required": [
428
+ "width",
429
+ "height",
430
+ "minWidth",
431
+ "minHeight"
432
+ ],
433
+ "properties": {
434
+ "width": {
435
+ "type": "number",
436
+ "minimum": 1,
437
+ "maximum": 10000
438
+ },
439
+ "height": {
440
+ "type": "number",
441
+ "minimum": 1,
442
+ "maximum": 10000
443
+ },
444
+ "minWidth": {
445
+ "type": "number",
446
+ "minimum": 1,
447
+ "maximum": 10000
448
+ },
449
+ "minHeight": {
450
+ "type": "number",
451
+ "minimum": 1,
452
+ "maximum": 10000
453
+ }
454
+ }
455
+ }
456
+ }
457
+ }
@@ -15,7 +15,9 @@ export declare function protocolAssetUrl(
15
15
  | '1.13.0'
16
16
  | '1.15.0'
17
17
  | '1.16.0'
18
- | '1.17.0';
18
+ | '1.17.0'
19
+ | '1.19.0'
20
+ | '1.21.0';
19
21
  },
20
22
  ): URL;
21
23
  export declare const PROTOCOL_V113_CONTRACTS: Readonly<Record<string, string>>;
@@ -36,3 +38,5 @@ export declare function validateEnterpriseJourneyArtifact(
36
38
  kind: string,
37
39
  value: unknown,
38
40
  ): { path: string; rule: string; detail: string }[];
41
+
42
+ export declare const PROTOCOL_V121_CONTRACTS: Readonly<Record<string, string>>;
@@ -1,3 +1,4 @@
1
+ import { assertVersionedDiagramReviewBundle } from './studio-presentation-contracts.mjs';
1
2
  // @ts-check
2
3
 
3
4
  import { DESIGN_HANDOFF_CONTRACT_FILES } from './design-handoff-contracts.mjs';
@@ -61,6 +62,20 @@ export const PROTOCOL_V115_CONTRACTS = Object.freeze(
61
62
  * @type {typeof import('./browser-contracts.d.mts').validateDiagramReviewArtifact}
62
63
  */
63
64
  export function validateDiagramReviewArtifact(kind, value, { protocolVersion = '1.15.0' } = {}) {
65
+ if (kind === 'diagram-review-bundle' && ['1.17.0', '1.21.0'].includes(protocolVersion)) {
66
+ try {
67
+ assertVersionedDiagramReviewBundle(value);
68
+ return [];
69
+ } catch (error) {
70
+ return [
71
+ {
72
+ path: '$',
73
+ rule: 'diagram-review-contract',
74
+ detail: error instanceof Error ? error.message : 'Invalid diagram review data.',
75
+ },
76
+ ];
77
+ }
78
+ }
64
79
  if (protocolVersion !== '1.15.0' || !Object.hasOwn(DIAGRAM_REVIEW_SCHEMAS, kind))
65
80
  throw new RangeError(`Unknown diagram review Protocol contract: ${kind}@${protocolVersion}`);
66
81
  try {
@@ -112,6 +127,17 @@ export function validateEnterpriseJourneyArtifact(kind, value) {
112
127
  }
113
128
  }
114
129
 
130
+ export const PROTOCOL_V121_CONTRACTS = Object.freeze(
131
+ Object.fromEntries(
132
+ [
133
+ 'diagram-authoring-bundle',
134
+ 'diagram-edit-transaction',
135
+ 'diagram-review-bundle',
136
+ 'diagram-shape-definition',
137
+ ].map((kind) => [kind, `${kind}.schema.json`]),
138
+ ),
139
+ );
140
+
115
141
  const PROTOCOL_CONTRACTS_BY_VERSION = Object.freeze({
116
142
  '1.5.0': PROTOCOL_V15_CONTRACTS,
117
143
  '1.6.0': PROTOCOL_V16_CONTRACTS,
@@ -123,6 +149,7 @@ const PROTOCOL_CONTRACTS_BY_VERSION = Object.freeze({
123
149
  '1.16.0': PROTOCOL_V116_CONTRACTS,
124
150
  '1.17.0': PROTOCOL_V117_CONTRACTS,
125
151
  '1.19.0': PROTOCOL_V119_CONTRACTS,
152
+ '1.21.0': PROTOCOL_V121_CONTRACTS,
126
153
  });
127
154
 
128
155
  /**
package/src/contracts.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { assertShapeDefinition } from './shape-library-contracts.mjs';
1
2
  // @ts-check
2
3
  /**
3
4
  * Protocol artifact schema registry and validation: resolves each kind and version to its packaged
@@ -43,9 +44,9 @@ import {
43
44
  } from './skill-source-contracts.mjs';
44
45
  import {
45
46
  assertDiagramPresentation,
46
- assertDiagramReviewBundleV11,
47
47
  assertVersionedDiagramAuthoringBundle,
48
48
  assertVersionedDiagramEditTransaction,
49
+ assertVersionedDiagramReviewBundle,
49
50
  } from './studio-presentation-contracts.mjs';
50
51
 
51
52
  const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
@@ -56,6 +57,12 @@ const v16Schema = (kind) => `schemas/v1.6.0/${PROTOCOL_V16_CONTRACT_FILES[kind]}
56
57
  const v17Schema = (kind) => `schemas/v1.7.0/${PROTOCOL_V17_CONTRACT_FILES[kind]}`;
57
58
  const v18Schema = (kind) => `schemas/v1.8.0/${PROTOCOL_V18_CONTRACT_FILES[kind]}`;
58
59
 
60
+ const shapeContractKinds = [
61
+ 'diagram-authoring-bundle',
62
+ 'diagram-edit-transaction',
63
+ 'diagram-review-bundle',
64
+ 'diagram-shape-definition',
65
+ ];
59
66
  const foundationPaths = {
60
67
  ...Object.fromEntries(
61
68
  Object.keys(LARGE_OBJECT_SCHEMAS).map((name) => [
@@ -74,7 +81,10 @@ const foundationPaths = {
74
81
  },
75
82
  ]),
76
83
  ),
77
- 'design-document': { '1.9.0': 'schemas/v1.9.0/design-document.schema.json' },
84
+ 'design-document': {
85
+ '1.9.0': 'schemas/v1.9.0/design-document.schema.json',
86
+ '1.20.0': 'schemas/v1.20.0/design-document.schema.json',
87
+ },
78
88
  'design-review-workspace': { '1.9.0': 'schemas/v1.9.0/design-review-workspace.schema.json' },
79
89
  'design-workspace-create': { '1.9.0': 'schemas/v1.9.0/design-workspace-create.schema.json' },
80
90
  'design-workspace-revision': { '1.9.0': 'schemas/v1.9.0/design-workspace-revision.schema.json' },
@@ -83,6 +93,7 @@ const foundationPaths = {
83
93
  '1.9.0': 'schemas/v1.9.0/design-review-bundle.schema.json',
84
94
  '1.10.0': 'schemas/v1.10.0/design-review-bundle.schema.json',
85
95
  '1.16.0': 'schemas/v1.16.0/design-review-bundle.schema.json',
96
+ '1.20.0': 'schemas/v1.20.0/design-review-bundle.schema.json',
86
97
  },
87
98
  'design-review-context': { '1.10.0': 'schemas/v1.10.0/design-review-context.schema.json' },
88
99
  'design-review-handoff': { '1.10.0': 'schemas/v1.10.0/design-review-handoff.schema.json' },
@@ -269,6 +280,12 @@ const foundationPaths = {
269
280
  };
270
281
 
271
282
  // Authoring successors are additive; preserve every legacy diagram registration.
283
+ for (const kind of shapeContractKinds)
284
+ foundationPaths[kind] = {
285
+ ...foundationPaths[kind],
286
+ '1.21.0': `schemas/v1.21.0/${kind}.schema.json`,
287
+ };
288
+
272
289
  for (const kind of Object.keys(ENTERPRISE_JOURNEY_SCHEMAS)) {
273
290
  foundationPaths[kind] = {
274
291
  ...foundationPaths[kind],
@@ -1248,8 +1265,8 @@ function guidedQuestionnaireCompatibilityErrors(value) {
1248
1265
  export function validateProtocolArtifact(kind, value, { protocolVersion } = {}) {
1249
1266
  const journeyErrors = validateCompanyJourneyArtifact(kind, value, protocolVersion);
1250
1267
  if (journeyErrors) return journeyErrors;
1251
- const studioKind = Object.hasOwn(LARGE_OBJECT_SCHEMAS, kind);
1252
- if (studioKind && protocolVersion === '1.17.0') {
1268
+ const studioKind = Object.hasOwn(LARGE_OBJECT_SCHEMAS, kind) || shapeContractKinds.includes(kind);
1269
+ if (studioKind && ['1.17.0', '1.21.0'].includes(protocolVersion)) {
1253
1270
  return validateStudioArtifact(kind, value, sharedProtocolSchema(kind, protocolVersion));
1254
1271
  }
1255
1272
  if (Object.hasOwn(PROTOCOL_V115_CONTRACTS, kind)) {
@@ -1292,7 +1309,7 @@ export function validateProtocolArtifact(kind, value, { protocolVersion } = {})
1292
1309
  versionInput = { protocolVersion: descriptor?.value };
1293
1310
  }
1294
1311
  const version = inferredVersion(kind, versionInput, protocolVersion);
1295
- if (studioKind && version === '1.17.0') {
1312
+ if (studioKind && ['1.17.0', '1.21.0'].includes(version)) {
1296
1313
  return validateStudioArtifact(kind, value, sharedProtocolSchema(kind, version));
1297
1314
  }
1298
1315
  if (version === '1.13.0' && authoringKind) {
@@ -1347,7 +1364,8 @@ function validateStudioArtifact(kind, value, resolved) {
1347
1364
  if (Object.hasOwn(SHARING_SECURITY_SCHEMAS, kind)) assertSharingSecurityContract(value, kind);
1348
1365
  else if (kind === 'diagram-authoring-bundle') assertVersionedDiagramAuthoringBundle(value);
1349
1366
  else if (kind === 'diagram-edit-transaction') assertVersionedDiagramEditTransaction(value);
1350
- else if (kind === 'diagram-review-bundle') assertDiagramReviewBundleV11(value);
1367
+ else if (kind === 'diagram-review-bundle') assertVersionedDiagramReviewBundle(value);
1368
+ else if (kind === 'diagram-shape-definition') assertShapeDefinition(value);
1351
1369
  else if (kind === 'diagram-presentation') assertDiagramPresentation(value);
1352
1370
  else assertLargeObjectContract(value, kind);
1353
1371
  return [];
@@ -11,7 +11,7 @@ export interface DesignFrame {
11
11
  id: string;
12
12
  label: string;
13
13
  width: number;
14
- height: number;
14
+ height: number | 'auto';
15
15
  }
16
16
 
17
17
  export interface DesignScreen {
@@ -34,6 +34,26 @@ export interface DesignVariant {
34
34
  sources?: Record<string, DesignSource>;
35
35
  }
36
36
 
37
+ export interface DesignBoardPosition {
38
+ x: number;
39
+ y: number;
40
+ title?: string;
41
+ }
42
+
43
+ export interface DesignSection {
44
+ id: string;
45
+ x: number;
46
+ y: number;
47
+ text: string;
48
+ maxW?: number;
49
+ }
50
+
51
+ export interface DesignLayout {
52
+ /** Keys identify a screen, screen/frame or screen/frame/variant. */
53
+ boards?: Record<string, DesignBoardPosition>;
54
+ sections?: DesignSection[];
55
+ }
56
+
37
57
  export interface DesignDocument {
38
58
  kind: 'openplanr-design-document';
39
59
  schemaVersion: '1.0.0';
@@ -47,6 +67,7 @@ export interface DesignDocument {
47
67
  };
48
68
  designSystem?: { path?: string; tokens?: string; spacing?: number[] };
49
69
  assets?: string[];
70
+ layout?: DesignLayout;
50
71
  frames: DesignFrame[];
51
72
  screens: DesignScreen[];
52
73
  screenOrder: string[];
@@ -57,6 +78,9 @@ export interface DesignDocument {
57
78
  }
58
79
 
59
80
  export declare const DESIGN_DOCUMENT_VERSION: '1.0.0';
81
+ export declare const DESIGN_DOCUMENT_V1_SCHEMA: Readonly<Record<string, unknown>>;
60
82
  export declare const DESIGN_DOCUMENT_SCHEMA: Readonly<Record<string, unknown>>;
61
83
  export declare function validateDesignDocument(value: unknown): { ok: boolean; errors: string[] };
62
84
  export declare function assertDesignDocument(value: unknown): DesignDocument;
85
+
86
+ export declare function initialFrameHeight(document: Pick<DesignDocument, 'frames'>): number;