@openplanr/protocol 0.7.2 → 0.8.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/README.md +13 -0
- package/package.json +5 -1
- package/registries/commands.json +5 -5
- package/registries/skills.json +4 -4
- package/schemas/v1.15.0/diagram-review-bundle.schema.json +1280 -0
- package/schemas/v1.15.0/diagram-review-feedback.schema.json +157 -0
- package/schemas/v1.15.0/diagram-review-workspace.schema.json +108 -0
- package/schemas/v1.15.0/diagram-workspace-create.schema.json +170 -0
- package/schemas/v1.15.0/diagram-workspace-event.schema.json +97 -0
- package/schemas/v1.15.0/diagram-workspace-revision.schema.json +56 -0
- package/src/browser-contracts.d.mts +10 -1
- package/src/browser-contracts.mjs +36 -0
- package/src/contracts.d.mts +1 -0
- package/src/contracts.mjs +16 -3
- package/src/diagram-review-contracts.d.mts +73 -0
- package/src/diagram-review-contracts.mjs +250 -0
- package/src/generated/canonical-registries.mjs +9 -9
- package/src/index.d.mts +1 -0
- package/src/index.mjs +3 -0
package/src/contracts.mjs
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { readFileSync } from 'node:fs';
|
|
12
12
|
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import { PROTOCOL_V115_CONTRACTS, validateDiagramReviewArtifact } from './browser-contracts.mjs';
|
|
14
15
|
import { deepFreeze } from './canonical-json.mjs';
|
|
15
16
|
import { DESIGN_HANDOFF_CONTRACT_FILES } from './design-handoff-contracts.mjs';
|
|
16
17
|
import {
|
|
@@ -233,6 +234,10 @@ for (const [kind, filename] of Object.entries(DIAGRAM_AUTHORING_CONTRACT_FILES))
|
|
|
233
234
|
foundationPaths[kind] = { ...foundationPaths[kind], '1.13.0': `schemas/v1.13.0/${filename}` };
|
|
234
235
|
}
|
|
235
236
|
|
|
237
|
+
for (const [kind, filename] of Object.entries(PROTOCOL_V115_CONTRACTS)) {
|
|
238
|
+
foundationPaths[kind] = { ...foundationPaths[kind], '1.15.0': `schemas/v1.15.0/${filename}` };
|
|
239
|
+
}
|
|
240
|
+
|
|
236
241
|
function compiledOperatePaths() {
|
|
237
242
|
const catalog = OPERATE_CONTRACT_CATALOG_V2;
|
|
238
243
|
if (
|
|
@@ -1193,6 +1198,13 @@ function guidedQuestionnaireCompatibilityErrors(value) {
|
|
|
1193
1198
|
|
|
1194
1199
|
/** @type {typeof import('./contracts.d.mts').validateProtocolArtifact} */
|
|
1195
1200
|
export function validateProtocolArtifact(kind, value, { protocolVersion } = {}) {
|
|
1201
|
+
if (Object.hasOwn(PROTOCOL_V115_CONTRACTS, kind)) {
|
|
1202
|
+
// Review transport envelopes do not carry a Protocol version. Do not read
|
|
1203
|
+
// arbitrary input properties while selecting the dedicated safety preflight.
|
|
1204
|
+
const version = inferredVersion(kind, {}, protocolVersion);
|
|
1205
|
+
sharedProtocolSchema(kind, version);
|
|
1206
|
+
return validateDiagramReviewArtifact(kind, value, { protocolVersion: version });
|
|
1207
|
+
}
|
|
1196
1208
|
const authoringKind = Object.hasOwn(DIAGRAM_AUTHORING_CONTRACT_FILES, kind);
|
|
1197
1209
|
let versionInput = value;
|
|
1198
1210
|
if (authoringKind && (!protocolVersion || protocolVersion === '1.13.0')) {
|
|
@@ -1215,11 +1227,12 @@ export function validateProtocolArtifact(kind, value, { protocolVersion } = {})
|
|
|
1215
1227
|
if (version === '1.13.0' && authoringKind) {
|
|
1216
1228
|
return validateDiagramAuthoringArtifact(kind, value);
|
|
1217
1229
|
}
|
|
1218
|
-
|
|
1230
|
+
return validateGenericArtifact(kind, value, sharedProtocolSchema(kind, version));
|
|
1231
|
+
}
|
|
1232
|
+
function validateGenericArtifact(kind, value, resolved) {
|
|
1219
1233
|
const errors = validateResolvedArtifact(value, resolved);
|
|
1220
|
-
if (kind === 'guided-questionnaire' &&
|
|
1234
|
+
if (kind === 'guided-questionnaire' && resolved.protocolVersion === '1.2.0')
|
|
1221
1235
|
errors.push(...guidedQuestionnaireCompatibilityErrors(value));
|
|
1222
|
-
}
|
|
1223
1236
|
return errors;
|
|
1224
1237
|
}
|
|
1225
1238
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { DiagramAuthoringBundle } from './diagram-authoring-contracts.mjs';
|
|
2
|
+
export interface DiagramReviewItem {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
kind: string;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}
|
|
9
|
+
export interface DiagramReviewRelation {
|
|
10
|
+
id: string;
|
|
11
|
+
from: string;
|
|
12
|
+
to: string;
|
|
13
|
+
label: string;
|
|
14
|
+
kind: string;
|
|
15
|
+
}
|
|
16
|
+
export interface DiagramReviewBundle {
|
|
17
|
+
kind: 'openplanr-diagram-review-bundle';
|
|
18
|
+
schemaVersion: '1.0.0';
|
|
19
|
+
diagramId: string;
|
|
20
|
+
title: string;
|
|
21
|
+
source: { kind: 'manifest' | 'authoring'; digest: string };
|
|
22
|
+
rendering: { id: string; version: string; fontFamily: 'Inter' };
|
|
23
|
+
summary?: string;
|
|
24
|
+
grammar?: string;
|
|
25
|
+
colorScheme?: 'light' | 'dark';
|
|
26
|
+
scene: {
|
|
27
|
+
svg: string;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
items: DiagramReviewItem[];
|
|
31
|
+
relations: DiagramReviewRelation[];
|
|
32
|
+
};
|
|
33
|
+
authored?: DiagramAuthoringBundle;
|
|
34
|
+
}
|
|
35
|
+
export interface DiagramReviewTarget {
|
|
36
|
+
elementId?: string;
|
|
37
|
+
x?: number;
|
|
38
|
+
y?: number;
|
|
39
|
+
}
|
|
40
|
+
interface FeedbackBase {
|
|
41
|
+
author: string;
|
|
42
|
+
reviewOf: string;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
commentId: string;
|
|
45
|
+
}
|
|
46
|
+
export type DiagramReviewFeedback = FeedbackBase &
|
|
47
|
+
(
|
|
48
|
+
| { kind: 'comment'; body: string; target: DiagramReviewTarget }
|
|
49
|
+
| { kind: 'reply'; body: string; parentId: string }
|
|
50
|
+
| { kind: 'resolve'; resolved: boolean }
|
|
51
|
+
);
|
|
52
|
+
export declare const DIAGRAM_REVIEW_VERSION: '1.0.0';
|
|
53
|
+
export declare const DIAGRAM_WORKSPACE_VERSION: '1.0.0';
|
|
54
|
+
export declare const DIAGRAM_WORKSPACE_API: '/api/v1/diagram-workspaces';
|
|
55
|
+
export declare const DIAGRAM_WORKSPACE_MAX_BYTES: number;
|
|
56
|
+
export declare const DIAGRAM_WORKSPACE_MAX_EVENT_BYTES: number;
|
|
57
|
+
export declare const DIAGRAM_WORKSPACE_ID_PATTERN: string;
|
|
58
|
+
export declare const DIAGRAM_REVIEW_BUNDLE_SCHEMA: Readonly<Record<string, unknown>>;
|
|
59
|
+
export declare const DIAGRAM_REVIEW_FEEDBACK_SCHEMA: Readonly<Record<string, unknown>>;
|
|
60
|
+
export declare const DIAGRAM_WORKSPACE_SCHEMA: Readonly<Record<string, unknown>>;
|
|
61
|
+
export declare const DIAGRAM_WORKSPACE_CREATE_SCHEMA: Readonly<Record<string, unknown>>;
|
|
62
|
+
export declare const DIAGRAM_WORKSPACE_REVISION_SCHEMA: Readonly<Record<string, unknown>>;
|
|
63
|
+
export declare const DIAGRAM_WORKSPACE_EVENT_SCHEMA: Readonly<Record<string, unknown>>;
|
|
64
|
+
export declare const DIAGRAM_REVIEW_SCHEMAS: Readonly<
|
|
65
|
+
Record<string, Readonly<Record<string, unknown>>>
|
|
66
|
+
>;
|
|
67
|
+
export declare function assertDiagramReviewBundle(value: unknown): DiagramReviewBundle;
|
|
68
|
+
export declare function assertDiagramReviewFeedback(value: unknown): DiagramReviewFeedback;
|
|
69
|
+
export declare function diagramReviewBundleDigest(value: unknown): string;
|
|
70
|
+
export declare function assertDiagramWorkspaceContract<T>(
|
|
71
|
+
value: T,
|
|
72
|
+
schema: string | Readonly<Record<string, unknown>>,
|
|
73
|
+
): T;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { canonicalizeJson, sha256Hex } from './canonical-json.mjs';
|
|
3
|
+
import {
|
|
4
|
+
DIAGRAM_AUTHORING_SCHEMAS,
|
|
5
|
+
validateDiagramAuthoringBundle,
|
|
6
|
+
} from './diagram-authoring-contracts.mjs';
|
|
7
|
+
import { validateJson } from './json-schema.mjs';
|
|
8
|
+
import { DESIGN_WORKSPACE_ID_PATTERN, DESIGN_WORKSPACE_SCHEMAS } from './workspace-contracts.mjs';
|
|
9
|
+
|
|
10
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_REVIEW_VERSION} */
|
|
11
|
+
export const DIAGRAM_REVIEW_VERSION = '1.0.0';
|
|
12
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_WORKSPACE_VERSION} */
|
|
13
|
+
export const DIAGRAM_WORKSPACE_VERSION = '1.0.0';
|
|
14
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_WORKSPACE_API} */
|
|
15
|
+
export const DIAGRAM_WORKSPACE_API = '/api/v1/diagram-workspaces';
|
|
16
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_WORKSPACE_MAX_BYTES} */
|
|
17
|
+
export const DIAGRAM_WORKSPACE_MAX_BYTES = 5 * 1024 * 1024;
|
|
18
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_WORKSPACE_MAX_EVENT_BYTES} */
|
|
19
|
+
export const DIAGRAM_WORKSPACE_MAX_EVENT_BYTES = 256 * 1024;
|
|
20
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_WORKSPACE_ID_PATTERN} */
|
|
21
|
+
export const DIAGRAM_WORKSPACE_ID_PATTERN = DESIGN_WORKSPACE_ID_PATTERN;
|
|
22
|
+
const text = { type: 'string', maxLength: 8192 };
|
|
23
|
+
const id = { type: 'string', minLength: 1, maxLength: 160 };
|
|
24
|
+
const digest = { type: 'string', pattern: '^[a-f0-9]{64}$' };
|
|
25
|
+
const shaDigest = { type: 'string', pattern: '^sha256:[a-f0-9]{64}$' };
|
|
26
|
+
const coord = { type: 'number', minimum: 0, maximum: 1 };
|
|
27
|
+
const closed = (properties, required = Object.keys(properties)) => ({
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties,
|
|
30
|
+
required,
|
|
31
|
+
additionalProperties: false,
|
|
32
|
+
});
|
|
33
|
+
const list = (items, maxItems = 10000) => ({ type: 'array', items, maxItems });
|
|
34
|
+
const contract = (name, shape) => ({
|
|
35
|
+
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
36
|
+
$id: `https://openplanr.dev/schemas/v1.15.0/${name}.schema.json`,
|
|
37
|
+
'x-openplanr-contract': { id: name, version: '1.15.0' },
|
|
38
|
+
...shape,
|
|
39
|
+
});
|
|
40
|
+
const item = closed({ id, label: text, kind: id, x: { type: 'number' }, y: { type: 'number' } });
|
|
41
|
+
const relation = closed({ id, from: id, to: id, label: text, kind: id });
|
|
42
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_REVIEW_BUNDLE_SCHEMA} */
|
|
43
|
+
export const DIAGRAM_REVIEW_BUNDLE_SCHEMA = contract(
|
|
44
|
+
'diagram-review-bundle',
|
|
45
|
+
closed(
|
|
46
|
+
{
|
|
47
|
+
kind: { const: 'openplanr-diagram-review-bundle' },
|
|
48
|
+
schemaVersion: { const: '1.0.0' },
|
|
49
|
+
diagramId: id,
|
|
50
|
+
title: text,
|
|
51
|
+
source: closed({ kind: { enum: ['manifest', 'authoring'] }, digest: shaDigest }),
|
|
52
|
+
rendering: closed({ id, version: id, fontFamily: { const: 'Inter' } }),
|
|
53
|
+
summary: text,
|
|
54
|
+
grammar: id,
|
|
55
|
+
colorScheme: { enum: ['light', 'dark'] },
|
|
56
|
+
scene: closed({
|
|
57
|
+
svg: { type: 'string', minLength: 1, maxLength: 5 * 1024 * 1024 },
|
|
58
|
+
width: { type: 'number', exclusiveMinimum: 0, maximum: 16384 },
|
|
59
|
+
height: { type: 'number', exclusiveMinimum: 0, maximum: 16384 },
|
|
60
|
+
items: list(item),
|
|
61
|
+
relations: list(relation),
|
|
62
|
+
}),
|
|
63
|
+
authored: DIAGRAM_AUTHORING_SCHEMAS['diagram-authoring-bundle'],
|
|
64
|
+
},
|
|
65
|
+
['kind', 'schemaVersion', 'diagramId', 'title', 'source', 'rendering', 'scene'],
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
const feedbackBase = {
|
|
69
|
+
kind: { enum: ['comment', 'reply', 'resolve'] },
|
|
70
|
+
author: { ...id, maxLength: 160 },
|
|
71
|
+
reviewOf: digest,
|
|
72
|
+
createdAt: { type: 'string', format: 'date-time' },
|
|
73
|
+
commentId: id,
|
|
74
|
+
};
|
|
75
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_REVIEW_FEEDBACK_SCHEMA} */
|
|
76
|
+
export const DIAGRAM_REVIEW_FEEDBACK_SCHEMA = contract('diagram-review-feedback', {
|
|
77
|
+
oneOf: [
|
|
78
|
+
closed({
|
|
79
|
+
...feedbackBase,
|
|
80
|
+
kind: { const: 'comment' },
|
|
81
|
+
body: { ...text, minLength: 1 },
|
|
82
|
+
target: closed({ elementId: id, x: coord, y: coord }, []),
|
|
83
|
+
}),
|
|
84
|
+
closed({
|
|
85
|
+
...feedbackBase,
|
|
86
|
+
kind: { const: 'reply' },
|
|
87
|
+
body: { ...text, minLength: 1 },
|
|
88
|
+
parentId: id,
|
|
89
|
+
}),
|
|
90
|
+
closed({ ...feedbackBase, kind: { const: 'resolve' }, resolved: { type: 'boolean' } }),
|
|
91
|
+
],
|
|
92
|
+
});
|
|
93
|
+
function workspaceSchema(name, original) {
|
|
94
|
+
return contract(name, {
|
|
95
|
+
...structuredClone(original),
|
|
96
|
+
$id: `https://openplanr.dev/schemas/v1.15.0/${name}.schema.json`,
|
|
97
|
+
'x-openplanr-contract': { id: name, version: '1.15.0' },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_WORKSPACE_SCHEMA} */
|
|
101
|
+
export const DIAGRAM_WORKSPACE_SCHEMA = workspaceSchema(
|
|
102
|
+
'diagram-review-workspace',
|
|
103
|
+
DESIGN_WORKSPACE_SCHEMAS['design-review-workspace'],
|
|
104
|
+
);
|
|
105
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_WORKSPACE_CREATE_SCHEMA} */
|
|
106
|
+
export const DIAGRAM_WORKSPACE_CREATE_SCHEMA = workspaceSchema(
|
|
107
|
+
'diagram-workspace-create',
|
|
108
|
+
DESIGN_WORKSPACE_SCHEMAS['design-workspace-create'],
|
|
109
|
+
);
|
|
110
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_WORKSPACE_REVISION_SCHEMA} */
|
|
111
|
+
export const DIAGRAM_WORKSPACE_REVISION_SCHEMA = workspaceSchema(
|
|
112
|
+
'diagram-workspace-revision',
|
|
113
|
+
DESIGN_WORKSPACE_SCHEMAS['design-workspace-revision'],
|
|
114
|
+
);
|
|
115
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_WORKSPACE_EVENT_SCHEMA} */
|
|
116
|
+
export const DIAGRAM_WORKSPACE_EVENT_SCHEMA = workspaceSchema(
|
|
117
|
+
'diagram-workspace-event',
|
|
118
|
+
DESIGN_WORKSPACE_SCHEMAS['design-workspace-event'],
|
|
119
|
+
);
|
|
120
|
+
/** @type {typeof import('./diagram-review-contracts.d.mts').DIAGRAM_REVIEW_SCHEMAS} */
|
|
121
|
+
export const DIAGRAM_REVIEW_SCHEMAS = Object.freeze({
|
|
122
|
+
'diagram-review-bundle': DIAGRAM_REVIEW_BUNDLE_SCHEMA,
|
|
123
|
+
'diagram-review-feedback': DIAGRAM_REVIEW_FEEDBACK_SCHEMA,
|
|
124
|
+
'diagram-review-workspace': DIAGRAM_WORKSPACE_SCHEMA,
|
|
125
|
+
'diagram-workspace-create': DIAGRAM_WORKSPACE_CREATE_SCHEMA,
|
|
126
|
+
'diagram-workspace-revision': DIAGRAM_WORKSPACE_REVISION_SCHEMA,
|
|
127
|
+
'diagram-workspace-event': DIAGRAM_WORKSPACE_EVENT_SCHEMA,
|
|
128
|
+
});
|
|
129
|
+
function inert(value) {
|
|
130
|
+
const seen = new Set();
|
|
131
|
+
let values = 0;
|
|
132
|
+
let chars = 0;
|
|
133
|
+
function visit(v, depth) {
|
|
134
|
+
if (++values > 200000 || depth > 64)
|
|
135
|
+
throw new Error('Review data exceeds its structural limit.');
|
|
136
|
+
if (typeof v === 'string') {
|
|
137
|
+
chars += v.length;
|
|
138
|
+
if (chars > 8 * 1024 * 1024) throw new Error('Review data exceeds its text limit.');
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (v === null || typeof v === 'boolean') return;
|
|
142
|
+
if (typeof v === 'number' && Number.isFinite(v)) return;
|
|
143
|
+
if (typeof v !== 'object' || seen.has(v)) throw new Error('Review data must be inert JSON.');
|
|
144
|
+
const proto = Object.getPrototypeOf(v);
|
|
145
|
+
if (Array.isArray(v) ? proto !== Array.prototype : proto !== Object.prototype && proto !== null)
|
|
146
|
+
throw new Error('Custom objects are not review data.');
|
|
147
|
+
seen.add(v);
|
|
148
|
+
const descriptors = Object.getOwnPropertyDescriptors(v);
|
|
149
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
150
|
+
if (typeof key !== 'string') throw new Error('Symbol keys are not review data.');
|
|
151
|
+
const d = descriptors[key];
|
|
152
|
+
if (
|
|
153
|
+
typeof key !== 'string' ||
|
|
154
|
+
!Object.hasOwn(d, 'value') ||
|
|
155
|
+
['__proto__', 'constructor', 'prototype'].includes(key)
|
|
156
|
+
)
|
|
157
|
+
throw new Error('Accessors and unsafe keys are not review data.');
|
|
158
|
+
if (Array.isArray(v) && key === 'length') continue;
|
|
159
|
+
if (!d.enumerable || (Array.isArray(v) && !/^(0|[1-9][0-9]*)$/u.test(key)))
|
|
160
|
+
throw new Error('Review data must contain JSON properties only.');
|
|
161
|
+
visit(d.value, depth + 1);
|
|
162
|
+
}
|
|
163
|
+
if (Array.isArray(v) && Object.keys(descriptors).length !== v.length + 1)
|
|
164
|
+
throw new Error('Sparse arrays are not review data.');
|
|
165
|
+
seen.delete(v);
|
|
166
|
+
}
|
|
167
|
+
visit(value, 0);
|
|
168
|
+
}
|
|
169
|
+
function assert(value, schema) {
|
|
170
|
+
try {
|
|
171
|
+
inert(value);
|
|
172
|
+
const issues = validateJson(value, schema);
|
|
173
|
+
if (issues.length)
|
|
174
|
+
throw new Error(issues.map((issue) => issue.detail ?? issue.path).join('; '));
|
|
175
|
+
return value;
|
|
176
|
+
} catch (cause) {
|
|
177
|
+
const error = Object.assign(
|
|
178
|
+
new Error(
|
|
179
|
+
`Invalid diagram review data: ${cause instanceof Error ? cause.message : 'Invalid value.'}`,
|
|
180
|
+
),
|
|
181
|
+
{ code: 'E_DIAGRAM_REVIEW_CONTRACT' },
|
|
182
|
+
);
|
|
183
|
+
error.name = 'E_DIAGRAM_REVIEW_CONTRACT';
|
|
184
|
+
error.code = 'E_DIAGRAM_REVIEW_CONTRACT';
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** @param {unknown} input @returns {import('./diagram-review-contracts.d.mts').DiagramReviewBundle} */
|
|
189
|
+
export function assertDiagramReviewBundle(input) {
|
|
190
|
+
const value = /** @type {import('./diagram-review-contracts.d.mts').DiagramReviewBundle} */ (
|
|
191
|
+
input
|
|
192
|
+
);
|
|
193
|
+
assert(value, DIAGRAM_REVIEW_BUNDLE_SCHEMA);
|
|
194
|
+
const ids = new Set();
|
|
195
|
+
for (const item of value.scene.items) {
|
|
196
|
+
if (ids.has(item.id)) throw new Error('Diagram review element IDs must be unique.');
|
|
197
|
+
ids.add(item.id);
|
|
198
|
+
}
|
|
199
|
+
const relations = new Set();
|
|
200
|
+
for (const relation of value.scene.relations) {
|
|
201
|
+
if (relations.has(relation.id) || !ids.has(relation.from) || !ids.has(relation.to))
|
|
202
|
+
throw new Error('Diagram review relations must target this scene.');
|
|
203
|
+
relations.add(relation.id);
|
|
204
|
+
}
|
|
205
|
+
if (value.source.kind === 'manifest' && value.authored)
|
|
206
|
+
throw new Error('A manifest review cannot contain an authored projection.');
|
|
207
|
+
if (value.source.kind === 'authoring' && !value.authored)
|
|
208
|
+
throw new Error('An authored review needs its read-only projection.');
|
|
209
|
+
if (value.authored) {
|
|
210
|
+
if (
|
|
211
|
+
value.authored.originalSource !== null ||
|
|
212
|
+
value.authored.sourceMap !== null ||
|
|
213
|
+
value.authored.diagramId !== value.diagramId ||
|
|
214
|
+
value.authored.document.title !== value.title ||
|
|
215
|
+
validateDiagramAuthoringBundle(value.authored).length
|
|
216
|
+
)
|
|
217
|
+
throw new Error('The authored review projection is invalid or contains source material.');
|
|
218
|
+
}
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
/** @param {unknown} input @returns {import('./diagram-review-contracts.d.mts').DiagramReviewFeedback} */
|
|
222
|
+
export function assertDiagramReviewFeedback(input) {
|
|
223
|
+
const value = /** @type {import('./diagram-review-contracts.d.mts').DiagramReviewFeedback} */ (
|
|
224
|
+
input
|
|
225
|
+
);
|
|
226
|
+
assert(value, DIAGRAM_REVIEW_FEEDBACK_SCHEMA);
|
|
227
|
+
if (
|
|
228
|
+
!value.author.trim() ||
|
|
229
|
+
('body' in value && !value.body.trim()) ||
|
|
230
|
+
!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/u.test(value.createdAt) ||
|
|
231
|
+
!Number.isFinite(Date.parse(value.createdAt))
|
|
232
|
+
)
|
|
233
|
+
throw new Error('Feedback needs an author, nonempty body and an ISO UTC timestamp.');
|
|
234
|
+
if (
|
|
235
|
+
value.kind === 'comment' &&
|
|
236
|
+
Object.hasOwn(value.target, 'x') !== Object.hasOwn(value.target, 'y')
|
|
237
|
+
)
|
|
238
|
+
throw new Error('Diagram coordinates must be supplied as a pair.');
|
|
239
|
+
return value;
|
|
240
|
+
}
|
|
241
|
+
/** @param {unknown} value @returns {string} */
|
|
242
|
+
export function diagramReviewBundleDigest(value) {
|
|
243
|
+
return sha256Hex(canonicalizeJson(assertDiagramReviewBundle(value)));
|
|
244
|
+
}
|
|
245
|
+
/** @template T @param {T} value @param {string|Readonly<Record<string,unknown>>} schema @returns {T} */
|
|
246
|
+
export function assertDiagramWorkspaceContract(value, schema) {
|
|
247
|
+
const descriptor = typeof schema === 'string' ? DIAGRAM_REVIEW_SCHEMAS[schema] : schema;
|
|
248
|
+
if (!descriptor) throw new Error('Unknown diagram workspace contract.');
|
|
249
|
+
return assert(value, descriptor);
|
|
250
|
+
}
|
|
@@ -1339,7 +1339,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
|
|
|
1339
1339
|
"ownerPackage": "openplanr",
|
|
1340
1340
|
"source": {
|
|
1341
1341
|
"path": "packages/cli/src/cli/commands/artifact.ts",
|
|
1342
|
-
"digest": "sha256:
|
|
1342
|
+
"digest": "sha256:628b64e8a1efda1f0e4899cdc3144c256dce5ce4bcff3c1f6d9a25c3d9a4cbe7"
|
|
1343
1343
|
},
|
|
1344
1344
|
"authorityClass": "workflow",
|
|
1345
1345
|
"machineJson": false,
|
|
@@ -1885,7 +1885,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
|
|
|
1885
1885
|
"ownerPackage": "openplanr",
|
|
1886
1886
|
"source": {
|
|
1887
1887
|
"path": "packages/cli/src/cli/commands/runtime.ts",
|
|
1888
|
-
"digest": "sha256:
|
|
1888
|
+
"digest": "sha256:1f0beee91f53b0372ba6165ffb883f9c91569eaad3a69d5891182067466d9227"
|
|
1889
1889
|
},
|
|
1890
1890
|
"authorityClass": "workflow",
|
|
1891
1891
|
"machineJson": false,
|
|
@@ -1927,7 +1927,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
|
|
|
1927
1927
|
"ownerPackage": "openplanr",
|
|
1928
1928
|
"source": {
|
|
1929
1929
|
"path": "packages/cli/src/cli/commands/setup.ts",
|
|
1930
|
-
"digest": "sha256:
|
|
1930
|
+
"digest": "sha256:22b9a95849234b00b3b8c6586e98dfceeb7c0d2db7bea37829486b3aa3c0c824"
|
|
1931
1931
|
},
|
|
1932
1932
|
"authorityClass": "workflow",
|
|
1933
1933
|
"machineJson": false,
|
|
@@ -2116,7 +2116,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
|
|
|
2116
2116
|
"ownerPackage": "openplanr",
|
|
2117
2117
|
"source": {
|
|
2118
2118
|
"path": "packages/cli/src/cli/commands/upgrade.ts",
|
|
2119
|
-
"digest": "sha256:
|
|
2119
|
+
"digest": "sha256:641600a879a283773c8ba8df811b2c746b577e002d11c60ea9cf096550b9733b"
|
|
2120
2120
|
},
|
|
2121
2121
|
"authorityClass": "workflow",
|
|
2122
2122
|
"machineJson": false,
|
|
@@ -3099,7 +3099,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
|
|
|
3099
3099
|
]
|
|
3100
3100
|
}
|
|
3101
3101
|
],
|
|
3102
|
-
"documentDigest": "sha256:
|
|
3102
|
+
"documentDigest": "sha256:9f34ed8942c28ac6d0cd4bfd3234c50ea8a4d72954a89df6e3596f3cc8e56be2"
|
|
3103
3103
|
},
|
|
3104
3104
|
"skills.json": {
|
|
3105
3105
|
"kind": "skill-catalog",
|
|
@@ -3113,11 +3113,11 @@ export const CANONICAL_REGISTRIES = deepFreeze({
|
|
|
3113
3113
|
{
|
|
3114
3114
|
"skillId": "planr-artifact",
|
|
3115
3115
|
"skillVersion": "1.0.0",
|
|
3116
|
-
"description": "Open, share, import, or export an OpenPlanr HTML artifact review. Use when feedback must move between a local artifact and its review board.",
|
|
3116
|
+
"description": "Open, share, import, or export an OpenPlanr diagram, design, or HTML artifact review. Use when feedback must move between a local artifact and its review board.",
|
|
3117
3117
|
"lifecycle": "active",
|
|
3118
3118
|
"authorityClass": "read-only-view",
|
|
3119
3119
|
"source": "skills/planr-artifact/openplanr.skill.json",
|
|
3120
|
-
"sourceDigest": "sha256:
|
|
3120
|
+
"sourceDigest": "sha256:2df9ace1397aedb3beaec79f822f16aac84cdf7f7ffe3cccabf3cd10bffbb352",
|
|
3121
3121
|
"triggerPolicy": {
|
|
3122
3122
|
"include": [
|
|
3123
3123
|
"Open or share an HTML artifact review",
|
|
@@ -3910,7 +3910,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
|
|
|
3910
3910
|
"lifecycle": "active",
|
|
3911
3911
|
"authorityClass": "artifact-authoring",
|
|
3912
3912
|
"source": "skills/planr-diagram/openplanr.skill.json",
|
|
3913
|
-
"sourceDigest": "sha256:
|
|
3913
|
+
"sourceDigest": "sha256:806f3c53d56199e00cfa19d27eaf9a8a0ca397692de46948313b7da1f728dd47",
|
|
3914
3914
|
"triggerPolicy": {
|
|
3915
3915
|
"include": [
|
|
3916
3916
|
"Create a professional diagram from English intent or Mermaid",
|
|
@@ -4767,7 +4767,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
|
|
|
4767
4767
|
}
|
|
4768
4768
|
],
|
|
4769
4769
|
"compatibilityAliases": [],
|
|
4770
|
-
"documentDigest": "sha256:
|
|
4770
|
+
"documentDigest": "sha256:e3f61d71a05a268294055de033e2ec2d44bfb7b05a95a18b6607ded3eb61e37b"
|
|
4771
4771
|
},
|
|
4772
4772
|
"outputs.json": {
|
|
4773
4773
|
"kind": "output-catalog",
|
package/src/index.d.mts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './design-handoff-contracts.mjs';
|
|
|
4
4
|
export * from './design-publication-contracts.mjs';
|
|
5
5
|
export * from './diagram-authoring-contracts.mjs';
|
|
6
6
|
export * from './diagram-contracts.mjs';
|
|
7
|
+
export * from './diagram-review-contracts.mjs';
|
|
7
8
|
export * from './enterprise-contracts.mjs';
|
|
8
9
|
export * from './errors.mjs';
|
|
9
10
|
export * from './json-schema.mjs';
|
package/src/index.mjs
CHANGED
|
@@ -6,7 +6,9 @@ export {
|
|
|
6
6
|
PROTOCOL_V18_CONTRACTS,
|
|
7
7
|
PROTOCOL_V111_CONTRACTS,
|
|
8
8
|
PROTOCOL_V113_CONTRACTS,
|
|
9
|
+
PROTOCOL_V115_CONTRACTS,
|
|
9
10
|
protocolAssetUrl,
|
|
11
|
+
validateDiagramReviewArtifact,
|
|
10
12
|
} from './browser-contracts.mjs';
|
|
11
13
|
export {
|
|
12
14
|
canonicalizeJson,
|
|
@@ -25,6 +27,7 @@ export {
|
|
|
25
27
|
diagramContractUrl,
|
|
26
28
|
getDiagramGrammar,
|
|
27
29
|
} from './diagram-contracts.mjs';
|
|
30
|
+
export * from './diagram-review-contracts.mjs';
|
|
28
31
|
export * from './enterprise-contracts.mjs';
|
|
29
32
|
export {
|
|
30
33
|
ARTIFACT_ERROR_CODES,
|