@bestagentkits/render 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.
Files changed (140) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +166 -0
  4. package/dist/cli.d.ts +18 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +336 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/diagnostics.d.ts +45 -0
  9. package/dist/diagnostics.d.ts.map +1 -0
  10. package/dist/diagnostics.js +57 -0
  11. package/dist/diagnostics.js.map +1 -0
  12. package/dist/diagram/adapter.d.ts +71 -0
  13. package/dist/diagram/adapter.d.ts.map +1 -0
  14. package/dist/diagram/adapter.js +87 -0
  15. package/dist/diagram/adapter.js.map +1 -0
  16. package/dist/errors.d.ts +37 -0
  17. package/dist/errors.d.ts.map +1 -0
  18. package/dist/errors.js +42 -0
  19. package/dist/errors.js.map +1 -0
  20. package/dist/hash.d.ts +14 -0
  21. package/dist/hash.d.ts.map +1 -0
  22. package/dist/hash.js +27 -0
  23. package/dist/hash.js.map +1 -0
  24. package/dist/index.d.ts +43 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +25 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/internal/yaml-error.d.ts +14 -0
  29. package/dist/internal/yaml-error.d.ts.map +1 -0
  30. package/dist/internal/yaml-error.js +12 -0
  31. package/dist/internal/yaml-error.js.map +1 -0
  32. package/dist/ir.d.ts +77 -0
  33. package/dist/ir.d.ts.map +1 -0
  34. package/dist/ir.js +20 -0
  35. package/dist/ir.js.map +1 -0
  36. package/dist/json.d.ts +23 -0
  37. package/dist/json.d.ts.map +1 -0
  38. package/dist/json.js +47 -0
  39. package/dist/json.js.map +1 -0
  40. package/dist/registry/actions.d.ts +48 -0
  41. package/dist/registry/actions.d.ts.map +1 -0
  42. package/dist/registry/actions.js +274 -0
  43. package/dist/registry/actions.js.map +1 -0
  44. package/dist/registry/prop-schema.d.ts +108 -0
  45. package/dist/registry/prop-schema.d.ts.map +1 -0
  46. package/dist/registry/prop-schema.js +400 -0
  47. package/dist/registry/prop-schema.js.map +1 -0
  48. package/dist/registry/registry.d.ts +47 -0
  49. package/dist/registry/registry.d.ts.map +1 -0
  50. package/dist/registry/registry.js +201 -0
  51. package/dist/registry/registry.js.map +1 -0
  52. package/dist/registry/roster.d.ts +53 -0
  53. package/dist/registry/roster.d.ts.map +1 -0
  54. package/dist/registry/roster.js +692 -0
  55. package/dist/registry/roster.js.map +1 -0
  56. package/dist/render/blocks.d.ts +41 -0
  57. package/dist/render/blocks.d.ts.map +1 -0
  58. package/dist/render/blocks.js +749 -0
  59. package/dist/render/blocks.js.map +1 -0
  60. package/dist/render/charts.d.ts +29 -0
  61. package/dist/render/charts.d.ts.map +1 -0
  62. package/dist/render/charts.js +235 -0
  63. package/dist/render/charts.js.map +1 -0
  64. package/dist/render/document.d.ts +40 -0
  65. package/dist/render/document.d.ts.map +1 -0
  66. package/dist/render/document.js +90 -0
  67. package/dist/render/document.js.map +1 -0
  68. package/dist/render/escape.d.ts +46 -0
  69. package/dist/render/escape.d.ts.map +1 -0
  70. package/dist/render/escape.js +108 -0
  71. package/dist/render/escape.js.map +1 -0
  72. package/dist/render/render.d.ts +52 -0
  73. package/dist/render/render.d.ts.map +1 -0
  74. package/dist/render/render.js +216 -0
  75. package/dist/render/render.js.map +1 -0
  76. package/dist/render/runtime.d.ts +25 -0
  77. package/dist/render/runtime.d.ts.map +1 -0
  78. package/dist/render/runtime.js +451 -0
  79. package/dist/render/runtime.js.map +1 -0
  80. package/dist/render/styles.d.ts +15 -0
  81. package/dist/render/styles.d.ts.map +1 -0
  82. package/dist/render/styles.js +163 -0
  83. package/dist/render/styles.js.map +1 -0
  84. package/dist/render/verify.d.ts +25 -0
  85. package/dist/render/verify.d.ts.map +1 -0
  86. package/dist/render/verify.js +168 -0
  87. package/dist/render/verify.js.map +1 -0
  88. package/dist/spec/bindings.d.ts +19 -0
  89. package/dist/spec/bindings.d.ts.map +1 -0
  90. package/dist/spec/bindings.js +51 -0
  91. package/dist/spec/bindings.js.map +1 -0
  92. package/dist/spec/bounds.d.ts +43 -0
  93. package/dist/spec/bounds.d.ts.map +1 -0
  94. package/dist/spec/bounds.js +144 -0
  95. package/dist/spec/bounds.js.map +1 -0
  96. package/dist/spec/forbidden.d.ts +27 -0
  97. package/dist/spec/forbidden.d.ts.map +1 -0
  98. package/dist/spec/forbidden.js +91 -0
  99. package/dist/spec/forbidden.js.map +1 -0
  100. package/dist/spec/migrate.d.ts +33 -0
  101. package/dist/spec/migrate.d.ts.map +1 -0
  102. package/dist/spec/migrate.js +113 -0
  103. package/dist/spec/migrate.js.map +1 -0
  104. package/dist/spec/normalize.d.ts +29 -0
  105. package/dist/spec/normalize.d.ts.map +1 -0
  106. package/dist/spec/normalize.js +649 -0
  107. package/dist/spec/normalize.js.map +1 -0
  108. package/dist/spec/parse.d.ts +22 -0
  109. package/dist/spec/parse.d.ts.map +1 -0
  110. package/dist/spec/parse.js +62 -0
  111. package/dist/spec/parse.js.map +1 -0
  112. package/dist/spec/providers.d.ts +30 -0
  113. package/dist/spec/providers.d.ts.map +1 -0
  114. package/dist/spec/providers.js +64 -0
  115. package/dist/spec/providers.js.map +1 -0
  116. package/dist/spec/validate.d.ts +28 -0
  117. package/dist/spec/validate.d.ts.map +1 -0
  118. package/dist/spec/validate.js +68 -0
  119. package/dist/spec/validate.js.map +1 -0
  120. package/dist/theme/load-theme.d.ts +55 -0
  121. package/dist/theme/load-theme.d.ts.map +1 -0
  122. package/dist/theme/load-theme.js +219 -0
  123. package/dist/theme/load-theme.js.map +1 -0
  124. package/dist/theme/presets.d.ts +50 -0
  125. package/dist/theme/presets.d.ts.map +1 -0
  126. package/dist/theme/presets.js +304 -0
  127. package/dist/theme/presets.js.map +1 -0
  128. package/dist/theme/theme-catalog.d.ts +68 -0
  129. package/dist/theme/theme-catalog.d.ts.map +1 -0
  130. package/dist/theme/theme-catalog.js +198 -0
  131. package/dist/theme/theme-catalog.js.map +1 -0
  132. package/dist/theme/tokens.d.ts +38 -0
  133. package/dist/theme/tokens.d.ts.map +1 -0
  134. package/dist/theme/tokens.js +190 -0
  135. package/dist/theme/tokens.js.map +1 -0
  136. package/dist/version.d.ts +12 -0
  137. package/dist/version.d.ts.map +1 -0
  138. package/dist/version.js +12 -0
  139. package/dist/version.js.map +1 -0
  140. package/package.json +80 -0
package/dist/json.js ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * JSON value model and canonical serialization.
3
+ *
4
+ * Canonical serialization is a determinism primitive: stable node IDs and
5
+ * determinism hashes are derived from it, so key order must not depend on how a
6
+ * document happened to be written.
7
+ */
8
+ /** True for a plain object (not an array, not null). */
9
+ export function isPlainObject(value) {
10
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
11
+ }
12
+ /** True for any JSON-serializable value. */
13
+ export function isJsonValue(value) {
14
+ if (value === null)
15
+ return true;
16
+ const type = typeof value;
17
+ if (type === 'string' || type === 'boolean')
18
+ return true;
19
+ if (type === 'number')
20
+ return Number.isFinite(value);
21
+ if (Array.isArray(value))
22
+ return value.every(isJsonValue);
23
+ if (isPlainObject(value))
24
+ return Object.values(value).every(isJsonValue);
25
+ return false;
26
+ }
27
+ /**
28
+ * Serialize a JSON value with object keys sorted lexicographically.
29
+ *
30
+ * Used for content hashes, never for emitted HTML: emitted output uses the
31
+ * spec's own ordering where ordering is meaningful to a reader.
32
+ */
33
+ export function canonicalStringify(value) {
34
+ if (value === null)
35
+ return 'null';
36
+ if (Array.isArray(value)) {
37
+ return `[${value.map((item) => canonicalStringify(item)).join(',')}]`;
38
+ }
39
+ if (typeof value === 'object') {
40
+ const entries = Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
41
+ return `{${entries
42
+ .map(([key, item]) => `${JSON.stringify(key)}:${canonicalStringify(item)}`)
43
+ .join(',')}}`;
44
+ }
45
+ return JSON.stringify(value);
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,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAC7D,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACzC,CAAC;QACF,OAAO,IAAI,OAAO;aACf,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;aAC1E,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The closed action vocabulary.
3
+ *
4
+ * A Page Spec can request behavior, never author it. There is no expression
5
+ * language, no selector language, and no handler body: an action is a record
6
+ * with a known `action` value and validated parameters. The runtime owns how
7
+ * each action is performed, including focus, keyboard, and ARIA updates.
8
+ */
9
+ import { type DiagnosticBag } from '../diagnostics.js';
10
+ import { type JsonValue } from '../json.js';
11
+ import { type PropSchema, type PropValues } from './prop-schema.js';
12
+ export type ActionType = 'copy' | 'open-url' | 'toggle' | 'set-value' | 'next' | 'previous' | 'select-tab' | 'expand' | 'collapse' | 'filter' | 'theme' | 'download';
13
+ export interface ActionDefinition {
14
+ type: ActionType;
15
+ summary: string;
16
+ params: Record<string, PropSchema>;
17
+ }
18
+ /** Events a block may bind to. Anything else is a validation error. */
19
+ export declare const ALLOWED_EVENTS: readonly ["click", "change", "input", "select", "filter", "open", "close"];
20
+ export type ActionEvent = (typeof ALLOWED_EVENTS)[number];
21
+ export declare const ACTION_DEFINITIONS: readonly ActionDefinition[];
22
+ export declare function getAction(type: string): ActionDefinition | undefined;
23
+ export declare function listActionTypes(): ActionType[];
24
+ export interface ValidatedActions {
25
+ /** event name -> validated action records */
26
+ bindings: Record<string, PropValues[]>;
27
+ }
28
+ /**
29
+ * Validate an `on` binding map.
30
+ *
31
+ * Accepts either a single action object or a list of action objects per event.
32
+ * `path` points at the `on` key so diagnostics land on the author's input.
33
+ */
34
+ export declare function validateActionMap(value: unknown, path: string, bag: DiagnosticBag): ValidatedActions;
35
+ /** Validate a single action record against the closed vocabulary. */
36
+ export declare function validateAction(value: unknown, path: string, bag: DiagnosticBag): PropValues | undefined;
37
+ /** True when a string is a plain `state.` dotted key path. */
38
+ export declare function isSafeStatePath(value: string): boolean;
39
+ /** Collect every action record from a validated binding map. */
40
+ export declare function bindingActions(bindings: Record<string, PropValues[]>): PropValues[];
41
+ /** JSON-safe view of the vocabulary for `catalog()`. */
42
+ export declare function actionsCatalog(): {
43
+ type: ActionType;
44
+ summary: string;
45
+ }[];
46
+ /** Exported for tests and docs: the raw `action` value of a binding. */
47
+ export declare function actionTypeOf(action: JsonValue): string | undefined;
48
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/registry/actions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAW,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAmB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAiB,MAAM,kBAAkB,CAAC;AAEpG,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,UAAU,GACV,QAAQ,GACR,WAAW,GACX,MAAM,GACN,UAAU,GACV,YAAY,GACZ,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,OAAO,GACP,UAAU,CAAC;AAEf,MAAM,WAAW,gB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S,CAIlE"}
@@ -0,0 +1,274 @@
1
+ /**
2
+ * The closed action vocabulary.
3
+ *
4
+ * A Page Spec can request behavior, never author it. There is no expression
5
+ * language, no selector language, and no handler body: an action is a record
6
+ * with a known `action` value and validated parameters. The runtime owns how
7
+ * each action is performed, including focus, keyboard, and ARIA updates.
8
+ */
9
+ import { pathKey } from '../diagnostics.js';
10
+ import { isPlainObject } from '../json.js';
11
+ import { NODE_ID_PATTERN, validateProps } from './prop-schema.js';
12
+ const idRef = (description) => ({
13
+ kind: 'string',
14
+ id: true,
15
+ required: true,
16
+ description,
17
+ });
18
+ const statePath = {
19
+ kind: 'string',
20
+ required: true,
21
+ maxLength: 128,
22
+ description: 'State path of the form `state.<key>[.<key>...]`.',
23
+ };
24
+ /** Events a block may bind to. Anything else is a validation error. */
25
+ export const ALLOWED_EVENTS = [
26
+ 'click',
27
+ 'change',
28
+ 'input',
29
+ 'select',
30
+ 'filter',
31
+ 'open',
32
+ 'close',
33
+ ];
34
+ export const ACTION_DEFINITIONS = [
35
+ {
36
+ type: 'copy',
37
+ summary: 'Copy the text content of the target node to the clipboard.',
38
+ params: { target: idRef('Node whose text is copied.') },
39
+ },
40
+ {
41
+ type: 'open-url',
42
+ summary: 'Open an allowlisted URL in a new tab.',
43
+ params: {
44
+ url: { kind: 'url', required: true, description: 'Destination URL.' },
45
+ label: { kind: 'string', maxLength: 120, description: 'Accessible label for the link.' },
46
+ },
47
+ },
48
+ {
49
+ type: 'toggle',
50
+ summary: 'Toggle the expanded, open, or active state of the target node.',
51
+ params: { target: idRef('Node to toggle.') },
52
+ },
53
+ {
54
+ type: 'set-value',
55
+ summary: 'Set a page state value without an expression.',
56
+ params: {
57
+ path: statePath,
58
+ value: {
59
+ kind: 'json',
60
+ description: 'Literal value assigned to the state path.',
61
+ maxBytes: 4_096,
62
+ },
63
+ },
64
+ },
65
+ {
66
+ type: 'next',
67
+ summary: 'Advance a carousel, slideshow, or step sequence to the next item.',
68
+ params: { target: { kind: 'string', id: true, description: 'Block to advance.' } },
69
+ },
70
+ {
71
+ type: 'previous',
72
+ summary: 'Move a carousel, slideshow, or step sequence to the previous item.',
73
+ params: { target: { kind: 'string', id: true, description: 'Block to rewind.' } },
74
+ },
75
+ {
76
+ type: 'select-tab',
77
+ summary: 'Select a tab by index or id inside a tabs block.',
78
+ params: {
79
+ target: idRef('Tabs block to update.'),
80
+ index: {
81
+ kind: 'number',
82
+ integer: true,
83
+ min: 0,
84
+ max: 200,
85
+ description: 'Zero-based tab index.',
86
+ },
87
+ tabId: { kind: 'string', id: true, description: 'Tab id, as an alternative to index.' },
88
+ },
89
+ },
90
+ {
91
+ type: 'expand',
92
+ summary: 'Expand a disclosure or accordion section.',
93
+ params: { target: idRef('Section to expand.') },
94
+ },
95
+ {
96
+ type: 'collapse',
97
+ summary: 'Collapse a disclosure or accordion section.',
98
+ params: { target: idRef('Section to collapse.') },
99
+ },
100
+ {
101
+ type: 'filter',
102
+ summary: 'Filter a collection by the current search input value.',
103
+ params: {
104
+ target: idRef('Collection to filter.'),
105
+ match: {
106
+ kind: 'string',
107
+ enum: ['text', 'label', 'value'],
108
+ description: 'Which part of each item is matched.',
109
+ },
110
+ query: {
111
+ kind: 'string',
112
+ maxLength: 200,
113
+ description: 'Static query when no input is bound.',
114
+ },
115
+ },
116
+ },
117
+ {
118
+ type: 'theme',
119
+ summary: 'Switch the page theme.',
120
+ params: {
121
+ value: {
122
+ kind: 'string',
123
+ enum: ['toggle', 'light', 'dark', 'system'],
124
+ description: 'Target theme, or `toggle` to flip the current one.',
125
+ },
126
+ },
127
+ },
128
+ {
129
+ type: 'download',
130
+ summary: 'Download the target node content as a file.',
131
+ params: {
132
+ target: idRef('Node whose text is downloaded.'),
133
+ filename: {
134
+ kind: 'string',
135
+ maxLength: 120,
136
+ description: 'Suggested filename; sanitized before use.',
137
+ },
138
+ },
139
+ },
140
+ ];
141
+ const BY_TYPE = new Map(ACTION_DEFINITIONS.map((definition) => [definition.type, definition]));
142
+ export function getAction(type) {
143
+ return BY_TYPE.get(type);
144
+ }
145
+ export function listActionTypes() {
146
+ return ACTION_DEFINITIONS.map((definition) => definition.type);
147
+ }
148
+ /**
149
+ * Validate an `on` binding map.
150
+ *
151
+ * Accepts either a single action object or a list of action objects per event.
152
+ * `path` points at the `on` key so diagnostics land on the author's input.
153
+ */
154
+ export function validateActionMap(value, path, bag) {
155
+ const bindings = {};
156
+ if (value === undefined)
157
+ return { bindings };
158
+ if (!isPlainObject(value)) {
159
+ bag.add({ code: 'SPEC_VALIDATION_ERROR', path, message: 'expected an event map object' });
160
+ return { bindings };
161
+ }
162
+ for (const [event, binding] of Object.entries(value)) {
163
+ const eventPath = pathKey(path, event);
164
+ if (!ALLOWED_EVENTS.includes(event)) {
165
+ bag.add({
166
+ code: 'SPEC_VALIDATION_ERROR',
167
+ path: eventPath,
168
+ message: `unknown event "${event}"`,
169
+ details: { allowed: [...ALLOWED_EVENTS] },
170
+ });
171
+ continue;
172
+ }
173
+ const candidates = Array.isArray(binding) ? binding : [binding];
174
+ if (candidates.length > 8) {
175
+ bag.add({
176
+ code: 'SPEC_BOUNDS_ERROR',
177
+ path: eventPath,
178
+ message: `event binds ${candidates.length} actions, limit is 8`,
179
+ });
180
+ continue;
181
+ }
182
+ const validated = [];
183
+ for (let index = 0; index < candidates.length; index += 1) {
184
+ const candidatePath = Array.isArray(binding) ? `${eventPath}[${index}]` : eventPath;
185
+ const action = validateAction(candidates[index], candidatePath, bag);
186
+ if (action !== undefined)
187
+ validated.push(action);
188
+ }
189
+ if (validated.length > 0)
190
+ bindings[event] = validated;
191
+ }
192
+ return { bindings };
193
+ }
194
+ /** Validate a single action record against the closed vocabulary. */
195
+ export function validateAction(value, path, bag) {
196
+ if (!isPlainObject(value)) {
197
+ bag.add({ code: 'SPEC_VALIDATION_ERROR', path, message: 'expected an action object' });
198
+ return undefined;
199
+ }
200
+ for (const key of Object.keys(value)) {
201
+ if (key !== 'action' && /^on[A-Z]/.test(key)) {
202
+ bag.add({
203
+ code: 'POLICY_VIOLATION',
204
+ path: pathKey(path, key),
205
+ message: 'inline event-handler source is not accepted',
206
+ });
207
+ }
208
+ }
209
+ const actionType = value.action;
210
+ if (typeof actionType !== 'string') {
211
+ bag.add({
212
+ code: 'SPEC_VALIDATION_ERROR',
213
+ path: pathKey(path, 'action'),
214
+ message: 'action requires an "action" key',
215
+ });
216
+ return undefined;
217
+ }
218
+ const definition = BY_TYPE.get(actionType);
219
+ if (definition === undefined) {
220
+ bag.add({
221
+ code: 'SPEC_VALIDATION_ERROR',
222
+ path: pathKey(path, 'action'),
223
+ message: `unknown action "${actionType}"`,
224
+ details: { allowed: listActionTypes() },
225
+ });
226
+ return undefined;
227
+ }
228
+ const { action: _ignored, ...rest } = value;
229
+ const params = validateProps(definition.params, rest, path, bag);
230
+ // A state path is the only dynamic indirection allowed, and it is a plain
231
+ // dotted key path — never an expression.
232
+ const statePathValue = params.path;
233
+ if (typeof statePathValue === 'string' && !isSafeStatePath(statePathValue)) {
234
+ bag.add({
235
+ code: 'POLICY_VIOLATION',
236
+ path: pathKey(path, 'path'),
237
+ message: `"${statePathValue}" is not a state path of the form state.<key>[.<key>...]`,
238
+ });
239
+ return undefined;
240
+ }
241
+ const target = params.target;
242
+ if (typeof target === 'string' && !NODE_ID_PATTERN.test(target)) {
243
+ bag.add({
244
+ code: 'SPEC_VALIDATION_ERROR',
245
+ path: pathKey(path, 'target'),
246
+ message: `"${target}" is not a valid node id`,
247
+ });
248
+ return undefined;
249
+ }
250
+ return { action: actionType, ...params };
251
+ }
252
+ /** True when a string is a plain `state.` dotted key path. */
253
+ export function isSafeStatePath(value) {
254
+ return /^state\.[a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*$/.test(value);
255
+ }
256
+ /** Collect every action record from a validated binding map. */
257
+ export function bindingActions(bindings) {
258
+ return Object.values(bindings).flat();
259
+ }
260
+ /** JSON-safe view of the vocabulary for `catalog()`. */
261
+ export function actionsCatalog() {
262
+ return ACTION_DEFINITIONS.map((definition) => ({
263
+ type: definition.type,
264
+ summary: definition.summary,
265
+ }));
266
+ }
267
+ /** Exported for tests and docs: the raw `action` value of a binding. */
268
+ export function actionTypeOf(action) {
269
+ if (!isPlainObject(action))
270
+ return undefined;
271
+ const value = action.action;
272
+ return typeof value === 'string' ? value : undefined;
273
+ }
274
+ //# sourceMappingURL=actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/registry/actions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAsB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAkB,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAoC,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAsBpG,MAAM,KAAK,GAAG,CAAC,WAAmB,EAAc,EAAE,CAAC,CAAC;IAClD,IAAI,EAAE,QAAQ;IACd,EAAE,EAAE,IAAI;IACR,QAAQ,EAAE,IAAI;IACd,WAAW;CACZ,CAAC,CAAC;AAEH,MAAM,SAAS,GAAe;IAC5B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,GAAG;IACd,WAAW,EAAE,kDAAkD;CAChE,CAAC;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO;IACP,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;CACC,CAAC;AAGX,MAAM,CAAC,MAAM,kBAAkB,GAAgC;IAC7D;QACE,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,4DAA4D;QACrE,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,4BAA4B,CAAC,EAAE;KACxD;IACD;QACE,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,uCAAuC;QAChD,MAAM,EAAE;YACN,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE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CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Declarative property schemas.
3
+ *
4
+ * One source of truth serves three consumers: runtime validation (with stable
5
+ * JSON paths), the published JSON Schema, and the compact `catalog()` /
6
+ * `describe()` contracts. Keeping them derived from one definition is what
7
+ * stops the documentation from drifting away from the validator.
8
+ */
9
+ import { DiagnosticBag } from '../diagnostics.js';
10
+ import { type JsonValue } from '../json.js';
11
+ export type PropSchema = StringPropSchema | TextPropSchema | NumberPropSchema | BooleanPropSchema | UrlPropSchema | ListPropSchema | ObjectPropSchema | RecordPropSchema | OneOfPropSchema | JsonPropSchema;
12
+ interface PropSchemaBase {
13
+ /** Reject the document when the property is absent. */
14
+ required?: boolean;
15
+ description?: string;
16
+ }
17
+ export interface StringPropSchema extends PropSchemaBase {
18
+ kind: 'string';
19
+ default?: string;
20
+ enum?: readonly string[];
21
+ maxLength?: number;
22
+ /** Validate as a node-safe identifier (`^[a-z0-9][a-z0-9-]{0,63}$`). */
23
+ id?: boolean;
24
+ }
25
+ /** Long-form single-line or multi-line text. Escaped at emission. */
26
+ export interface TextPropSchema extends PropSchemaBase {
27
+ kind: 'text';
28
+ default?: string;
29
+ maxLength?: number;
30
+ }
31
+ export interface NumberPropSchema extends PropSchemaBase {
32
+ kind: 'number';
33
+ default?: number;
34
+ min?: number;
35
+ max?: number;
36
+ integer?: boolean;
37
+ }
38
+ export interface BooleanPropSchema extends PropSchemaBase {
39
+ kind: 'boolean';
40
+ default?: boolean;
41
+ }
42
+ /**
43
+ * A link or asset reference. A relative path stays local; an absolute URL must
44
+ * use an allowlisted scheme. `data:` and `javascript:` are never accepted.
45
+ */
46
+ export interface UrlPropSchema extends PropSchemaBase {
47
+ kind: 'url';
48
+ default?: string;
49
+ schemes?: readonly string[];
50
+ }
51
+ export interface ListPropSchema extends PropSchemaBase {
52
+ kind: 'list';
53
+ of: PropSchema;
54
+ minItems?: number;
55
+ maxItems?: number;
56
+ }
57
+ export interface ObjectPropSchema extends PropSchemaBase {
58
+ kind: 'object';
59
+ fields: Record<string, PropSchema>;
60
+ }
61
+ /** An open-keyed map, e.g. `state` or key/value lists. */
62
+ export interface RecordPropSchema extends PropSchemaBase {
63
+ kind: 'record';
64
+ of: PropSchema;
65
+ maxKeys?: number;
66
+ }
67
+ export interface OneOfPropSchema extends PropSchemaBase {
68
+ kind: 'oneOf';
69
+ options: readonly PropSchema[];
70
+ }
71
+ /**
72
+ * A bounded, structurally-opaque JSON value validated by a capability adapter
73
+ * (for example an `ak:diagram` typed IR payload). It is still size-bounded and
74
+ * still scanned for forbidden keys.
75
+ */
76
+ export interface JsonPropSchema extends PropSchemaBase {
77
+ kind: 'json';
78
+ description: string;
79
+ maxBytes?: number;
80
+ /** JSON Schema `$ref` used when projecting this prop into the spec schema. */
81
+ schemaRef?: string;
82
+ }
83
+ export declare const DEFAULT_URL_SCHEMES: readonly ["https", "http", "mailto"];
84
+ export declare const NODE_ID_PATTERN: RegExp;
85
+ export type PropValues = Record<string, JsonValue>;
86
+ export interface PropValidationResult {
87
+ /** Validated values with defaults applied, in schema key order. */
88
+ values: PropValues;
89
+ /** Node-safe author IDs discovered in this subtree, mapped to their paths. */
90
+ authorIds: {
91
+ id: string;
92
+ path: string;
93
+ }[];
94
+ }
95
+ /**
96
+ * Validate one property value against its schema, appending diagnostics and
97
+ * returning the normalized value (or `undefined` when absent/optional).
98
+ */
99
+ export declare function validateProp(schema: PropSchema, value: unknown, path: string, bag: DiagnosticBag): JsonValue | undefined;
100
+ /**
101
+ * Validate a props object against a block's property schema. Unknown keys are
102
+ * errors: a silently ignored prop is a silent authoring mistake.
103
+ */
104
+ export declare function validateProps(fields: Record<string, PropSchema>, value: unknown, path: string, bag: DiagnosticBag): PropValues;
105
+ /** Project a prop schema into JSON Schema for the published spec contract. */
106
+ export declare function propSchemaToJsonSchema(schema: PropSchema): Record<string, unknown>;
107
+ export {};
108
+ //# sourceMappingURL=prop-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prop-schema.d.ts","sourceRoot":"","sources":["../../src/registry/prop-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAsB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,MAAM,UAAU,GAClB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAChB,iBAAiB,GACjB,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,cAAc,CAAC;AAEnB,UAAU,cAAc;IACtB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,EAAE,CAAC,EAAE,OAAO,CAAC;CACd;AAED,qEAAqE;AACrE,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAA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