@aestheticfunction/dspack-emit 0.4.1 → 0.5.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 (64) hide show
  1. package/README.md +16 -6
  2. package/dist/cli.js +56 -0
  3. package/dist/index.d.ts +4 -1
  4. package/dist/index.js +3 -1
  5. package/dist/targets/a2ui/diagnostics.d.ts +110 -0
  6. package/dist/targets/a2ui/diagnostics.js +94 -0
  7. package/dist/targets/a2ui/surface.d.ts +28 -9
  8. package/dist/targets/a2ui/surface.js +566 -224
  9. package/dist/transform/desugar.d.ts +32 -0
  10. package/dist/transform/desugar.js +156 -0
  11. package/dist/transform/emit.js +59 -0
  12. package/dist/transform/index.js +4 -0
  13. package/dist/transform/mapping.d.ts +0 -6
  14. package/dist/transform/mapping.js +50 -0
  15. package/dist/transform/model.d.ts +275 -0
  16. package/dist/transform/model.js +148 -0
  17. package/dist/transform/parse-v2.d.ts +78 -0
  18. package/dist/transform/parse-v2.js +305 -0
  19. package/dist/transform/profile-load.d.ts +7 -6
  20. package/dist/transform/profile-load.js +99 -20
  21. package/dist/transform/profile-schema-v2.d.ts +9 -0
  22. package/dist/transform/profile-schema-v2.js +430 -0
  23. package/dist/transform/profiles.d.ts +31 -1
  24. package/dist/transform/scaffold.d.ts +29 -12
  25. package/dist/transform/scaffold.js +91 -31
  26. package/dist/transform/shadcn-v2-respelling.d.ts +12 -0
  27. package/dist/transform/shadcn-v2-respelling.js +49 -0
  28. package/dist/transform/validate-v2.d.ts +36 -0
  29. package/dist/transform/validate-v2.js +100 -0
  30. package/dist/types.d.ts +19 -0
  31. package/dist/validate/ajv.js +96 -25
  32. package/package.json +2 -2
  33. package/src/__snapshots__/byte-neutral.test.ts.snap +66 -0
  34. package/src/byte-neutral.test.ts +246 -0
  35. package/src/cli.ts +60 -0
  36. package/src/dangling-ref.test.ts +118 -0
  37. package/src/desugar.test.ts +162 -0
  38. package/src/engine-boundary.test.ts +248 -0
  39. package/src/eval-fixture.test.ts +89 -0
  40. package/src/functions.test.ts +182 -0
  41. package/src/index.ts +4 -1
  42. package/src/profile-load.test.ts +99 -1
  43. package/src/profile-v2.test.ts +363 -0
  44. package/src/review-findings.test.ts +292 -0
  45. package/src/schema-mirrors.test.ts +5 -0
  46. package/src/surface-fidelity.test.ts +213 -0
  47. package/src/targets/a2ui/diagnostics.ts +136 -0
  48. package/src/targets/a2ui/surface.ts +920 -242
  49. package/src/transform/desugar.ts +194 -0
  50. package/src/transform/emit.ts +65 -0
  51. package/src/transform/index.ts +5 -0
  52. package/src/transform/mapping.ts +42 -0
  53. package/src/transform/model.ts +325 -0
  54. package/src/transform/parse-v2.ts +397 -0
  55. package/src/transform/profile-load.ts +104 -22
  56. package/src/transform/profile-schema-v2.ts +430 -0
  57. package/src/transform/profile.v2.schema.json +422 -0
  58. package/src/transform/profiles.ts +32 -1
  59. package/src/transform/scaffold.ts +124 -47
  60. package/src/transform/shadcn-v2-respelling.ts +61 -0
  61. package/src/transform/validate-v2.ts +138 -0
  62. package/src/types.ts +20 -0
  63. package/src/validate/ajv.ts +89 -26
  64. package/src/validate-v2.test.ts +173 -0
@@ -2,11 +2,23 @@
2
2
  * Profile-as-data: load a mapping Profile from JSON.
3
3
  *
4
4
  * The Profile has always been pure data (profiles.ts); this module makes it
5
- * *reachable* as data. `loadProfile` validates an untrusted JSON value against
6
- * schema `profile.v1.schema.json` (a one-to-one mirror of the TypeScript
7
- * `Profile` interface plus a `profileVersion` envelope const) and returns the
8
- * engine-ready `Profile`. Validation gates shape only — every judgment call
9
- * (valueMaps, casualties, surface plans) stays with the profile's author.
5
+ * *reachable* as data. `loadProfile` dispatches EXPLICITLY on the document's
6
+ * `profileVersion`:
7
+ *
8
+ * "1" — the original surface-plan directive language, validated against
9
+ * profile.v1.schema.json. Frozen: v1 documents keep loading and
10
+ * emitting byte-identically, indefinitely.
11
+ * "2" — the primitive language, validated against profile.v2.schema.json,
12
+ * then every plan's `surface` block is parsed and statically checked
13
+ * (parse-v2.ts) so that a v2 profile that loads is a profile the
14
+ * engine can emit. The returned Profile is stamped `language: "v2"`,
15
+ * which is what keys the transform layer's fail-closed contract
16
+ * validation — no document is ever silently interpreted under the
17
+ * wrong version.
18
+ *
19
+ * Anything else refuses with a pathed finding naming the supported versions.
20
+ * Validation gates shape and coherence only — every judgment call (valueMaps,
21
+ * casualties, routes) stays with the profile's author.
10
22
  *
11
23
  * Toolchain: ajv draft 2020-12, `strict: false`, ajv-formats — the same
12
24
  * convention as the catalog gates (src/validate/ajv.ts) and the dspack
@@ -15,12 +27,15 @@
15
27
  import Ajv2020 from "ajv/dist/2020.js";
16
28
  import addFormats from "ajv-formats";
17
29
  import { profileSchema } from "./profile-schema.js";
18
- /** The profile schema, as shipped (also exported for hosts that surface it in UI). */
30
+ import { profileSchemaV2 } from "./profile-schema-v2.js";
31
+ import { ProfileParseError, parseSurfaceV2 } from "./parse-v2.js";
32
+ /** The profile schemas, as shipped (also exported for hosts that surface them in UI). */
19
33
  export { profileSchema } from "./profile-schema.js";
34
+ export { profileSchemaV2 } from "./profile-schema-v2.js";
20
35
  export class ProfileLoadError extends Error {
21
36
  issues;
22
- constructor(issues) {
23
- super(`profile does not conform to profile.v1.schema.json (${issues.length} issue${issues.length === 1 ? "" : "s"}): ` +
37
+ constructor(issues, schemaName = "profile.v1.schema.json") {
38
+ super(`profile does not conform to ${schemaName} (${issues.length} issue${issues.length === 1 ? "" : "s"}): ` +
24
39
  issues
25
40
  .slice(0, 3)
26
41
  .map((i) => `${i.path || "$"}: ${i.message}`)
@@ -30,27 +45,91 @@ export class ProfileLoadError extends Error {
30
45
  this.name = "ProfileLoadError";
31
46
  }
32
47
  }
33
- let compiled;
34
- function validator() {
35
- if (!compiled) {
48
+ const compiled = new Map();
49
+ function validator(version) {
50
+ let v = compiled.get(version);
51
+ if (!v) {
36
52
  const ajv = new Ajv2020({ strict: false, allErrors: true, validateFormats: true });
37
53
  addFormats(ajv);
38
- compiled = ajv.compile(profileSchema);
54
+ v = ajv.compile(version === "1" ? profileSchema : profileSchemaV2);
55
+ compiled.set(version, v);
39
56
  }
40
- return compiled;
57
+ return v;
58
+ }
59
+ function ajvIssues(validate) {
60
+ const errors = (validate.errors ?? []);
61
+ return errors.map((e) => ({ path: e.instancePath ?? "", message: e.message ?? "invalid" }));
41
62
  }
42
63
  /**
43
- * Validate `json` as a v1 profile document and return the engine-ready
44
- * `Profile`. The `profileVersion` envelope field is stripped — it belongs to
45
- * the document format, not the engine. Top-level `x-` extension keys are
46
- * preserved (the engine ignores them; provenance tools may not).
64
+ * Validate `json` as a profile document and return the engine-ready `Profile`.
65
+ * The `profileVersion` envelope field is stripped — it belongs to the document
66
+ * format, not the engine. Top-level `x-` extension keys are preserved (the
67
+ * engine ignores them; provenance tools may not).
47
68
  */
48
69
  export function loadProfile(json) {
49
- const validate = validator();
70
+ const version = json?.profileVersion;
71
+ if (version !== "1" && version !== "2") {
72
+ throw new ProfileLoadError([
73
+ {
74
+ path: "/profileVersion",
75
+ message: `unknown profile version ${JSON.stringify(version)} — this loader speaks "1" (surface-plan directives) and "2" (the primitive language)`,
76
+ },
77
+ ], "any supported profile schema");
78
+ }
79
+ const validate = validator(version);
50
80
  if (!validate(json)) {
51
- const errors = (validate.errors ?? []);
52
- throw new ProfileLoadError(errors.map((e) => ({ path: e.instancePath ?? "", message: e.message ?? "invalid" })));
81
+ throw new ProfileLoadError(ajvIssues(validate), `profile.v${version}.schema.json`);
53
82
  }
54
83
  const { profileVersion: _envelope, ...profile } = json;
84
+ if (version === "2") {
85
+ // Declared function args must be SELF-CONTAINED schemas. A $ref inside
86
+ // them couples the function's signature to emit internals at best and, at
87
+ // worst, is a dangling reference that ajv defers past gate A1's compile
88
+ // and then throws raw out of gate A3 — pass-or-crash, never a finding.
89
+ // Refuse the whole class at load, with the path.
90
+ const functions = profile.functions ?? {};
91
+ const refIssues = [];
92
+ const findRefs = (value, at) => {
93
+ if (Array.isArray(value))
94
+ value.forEach((v, i) => findRefs(v, `${at}/${i}`));
95
+ else if (value && typeof value === "object") {
96
+ for (const [k, v] of Object.entries(value)) {
97
+ if (k === "$ref")
98
+ refIssues.push({ path: at, message: `function args must be self-contained schemas; '$ref' is refused (found ${JSON.stringify(v)})` });
99
+ else
100
+ findRefs(v, `${at}/${k}`);
101
+ }
102
+ }
103
+ };
104
+ for (const [name, fn] of Object.entries(functions)) {
105
+ if (fn?.args)
106
+ findRefs(fn.args, `/functions/${name}/args`);
107
+ }
108
+ if (refIssues.length > 0)
109
+ throw new ProfileLoadError(refIssues, "profile.v2.schema.json (functions)");
110
+ // Parse every plan's surface block now, so a v2 profile that LOADS is a
111
+ // profile the engine can EMIT — grammar errors surface at load with
112
+ // pathed findings, not mid-emission.
113
+ const collections = [
114
+ ["components", profile.components ?? []],
115
+ ["synthesized", profile.synthesized ?? []],
116
+ ];
117
+ for (const [key, plans] of collections) {
118
+ for (const [i, plan] of plans.entries()) {
119
+ if (!plan.surface)
120
+ continue;
121
+ try {
122
+ parseSurfaceV2(plan.surface, plan, `/${key}/${i}/surface`);
123
+ }
124
+ catch (e) {
125
+ if (e instanceof ProfileParseError) {
126
+ throw new ProfileLoadError(e.issues, "profile.v2.schema.json (surface syntax)");
127
+ }
128
+ throw e;
129
+ }
130
+ }
131
+ }
132
+ profile.language = "v2";
133
+ }
55
134
  return profile;
56
135
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Runtime mirror of profile.v2.schema.json — same convention as
3
+ * profile-schema.ts: the .json file stays the reviewable schema document,
4
+ * this constant is what loadProfile imports so the loader bundles for the
5
+ * browser (dspack-studio composer) without filesystem access.
6
+ * src/schema-mirrors.test.ts asserts mirror and JSON stay identical — edit
7
+ * both together.
8
+ */
9
+ export declare const profileSchemaV2: Record<string, unknown>;
@@ -0,0 +1,430 @@
1
+ /**
2
+ * Runtime mirror of profile.v2.schema.json — same convention as
3
+ * profile-schema.ts: the .json file stays the reviewable schema document,
4
+ * this constant is what loadProfile imports so the loader bundles for the
5
+ * browser (dspack-studio composer) without filesystem access.
6
+ * src/schema-mirrors.test.ts asserts mirror and JSON stay identical — edit
7
+ * both together.
8
+ */
9
+ export const profileSchemaV2 = {
10
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
11
+ "$id": "https://aestheticfunction.github.io/dspack-emit/schema/profile.v2.schema.json",
12
+ "title": "dspack-emit a2ui Profile v2",
13
+ "description": "JSON form of the a2ui target's mapping Profile, second language. A v2 plan authors the internal transformation model directly \u2014 Identity / Route / Collect in a closed string syntax \u2014 instead of the v1 surface-plan directives. One profile language per document: this schema refuses `surfacePlan` and `subCoverage`; profile.v1.schema.json refuses `surface` and `functions`. loadProfile() dispatches on `profileVersion` and validates against exactly one of the two.",
14
+ "type": "object",
15
+ "additionalProperties": false,
16
+ "patternProperties": {
17
+ "^x-": {}
18
+ },
19
+ "required": [
20
+ "profileVersion",
21
+ "catalogTitle",
22
+ "catalogDescription",
23
+ "catalogIdBase",
24
+ "instructions",
25
+ "primaryColorToken",
26
+ "components",
27
+ "synthesized",
28
+ "casualtyComponents",
29
+ "surfaceSynthesis"
30
+ ],
31
+ "properties": {
32
+ "profileVersion": {
33
+ "const": "2"
34
+ },
35
+ "catalogTitle": {
36
+ "type": "string",
37
+ "minLength": 1
38
+ },
39
+ "catalogDescription": {
40
+ "type": "string",
41
+ "minLength": 1
42
+ },
43
+ "catalogIdBase": {
44
+ "type": "string",
45
+ "format": "uri",
46
+ "pattern": "^https://"
47
+ },
48
+ "instructions": {
49
+ "type": "string"
50
+ },
51
+ "primaryColorToken": {
52
+ "type": "object",
53
+ "additionalProperties": false,
54
+ "required": [
55
+ "category",
56
+ "name"
57
+ ],
58
+ "properties": {
59
+ "category": {
60
+ "type": "string",
61
+ "minLength": 1
62
+ },
63
+ "name": {
64
+ "type": "string",
65
+ "minLength": 1
66
+ }
67
+ }
68
+ },
69
+ "components": {
70
+ "type": "array",
71
+ "items": {
72
+ "$ref": "#/$defs/componentPlan"
73
+ }
74
+ },
75
+ "synthesized": {
76
+ "type": "array",
77
+ "items": {
78
+ "$ref": "#/$defs/componentPlan"
79
+ }
80
+ },
81
+ "casualtyComponents": {
82
+ "type": "array",
83
+ "items": {
84
+ "type": "object",
85
+ "additionalProperties": false,
86
+ "patternProperties": {
87
+ "^x-": {}
88
+ },
89
+ "required": [
90
+ "dspackId",
91
+ "attempted",
92
+ "class",
93
+ "reason"
94
+ ],
95
+ "properties": {
96
+ "dspackId": {
97
+ "$ref": "#/$defs/dspackId"
98
+ },
99
+ "attempted": {
100
+ "type": "string",
101
+ "minLength": 1
102
+ },
103
+ "class": {
104
+ "enum": [
105
+ "maps-cleanly",
106
+ "synthesis-defaults",
107
+ "lossy",
108
+ "cannot-represent"
109
+ ]
110
+ },
111
+ "reason": {
112
+ "type": "string",
113
+ "minLength": 1
114
+ }
115
+ }
116
+ }
117
+ },
118
+ "intentionallyOmitted": {
119
+ "type": "array",
120
+ "items": {
121
+ "$ref": "#/$defs/dspackId"
122
+ }
123
+ },
124
+ "surfaceSynthesis": {
125
+ "type": "object",
126
+ "additionalProperties": false,
127
+ "required": [
128
+ "textComponent",
129
+ "textProp",
130
+ "wrapComponent",
131
+ "wrapChildrenProp"
132
+ ],
133
+ "properties": {
134
+ "textComponent": {
135
+ "$ref": "#/$defs/a2uiName"
136
+ },
137
+ "textProp": {
138
+ "type": "string",
139
+ "minLength": 1
140
+ },
141
+ "wrapComponent": {
142
+ "$ref": "#/$defs/a2uiName"
143
+ },
144
+ "wrapChildrenProp": {
145
+ "type": "string",
146
+ "minLength": 1
147
+ }
148
+ }
149
+ },
150
+ "functions": {
151
+ "type": "object",
152
+ "description": "A2UI catalog functions this profile declares, keyed by call name. Emitted into the catalog's functions section and enforced on every FunctionCall: an instance calling an undeclared function fails gate A3. Definitions are declarative schemas for the call's args \u2014 never executable code.",
153
+ "propertyNames": {
154
+ "pattern": "^[a-z][A-Za-z0-9]*$"
155
+ },
156
+ "additionalProperties": {
157
+ "type": "object",
158
+ "additionalProperties": false,
159
+ "required": [
160
+ "description",
161
+ "returns"
162
+ ],
163
+ "properties": {
164
+ "description": {
165
+ "type": "string",
166
+ "minLength": 1
167
+ },
168
+ "returns": {
169
+ "enum": [
170
+ "string",
171
+ "number",
172
+ "boolean",
173
+ "array",
174
+ "object"
175
+ ]
176
+ },
177
+ "args": {
178
+ "type": "object",
179
+ "description": "JSON Schema (object form) validating the call's args object; omit for arg-less functions."
180
+ }
181
+ }
182
+ }
183
+ }
184
+ },
185
+ "$defs": {
186
+ "dspackId": {
187
+ "type": "string",
188
+ "pattern": "^[a-z][a-z0-9-]*$"
189
+ },
190
+ "a2uiName": {
191
+ "type": "string",
192
+ "pattern": "^[A-Z][A-Za-z0-9]*$"
193
+ },
194
+ "componentPlan": {
195
+ "type": "object",
196
+ "additionalProperties": false,
197
+ "patternProperties": {
198
+ "^x-": {}
199
+ },
200
+ "required": [
201
+ "a2ui",
202
+ "commons",
203
+ "structural",
204
+ "required"
205
+ ],
206
+ "properties": {
207
+ "a2ui": {
208
+ "$ref": "#/$defs/a2uiName"
209
+ },
210
+ "dspackId": {
211
+ "$ref": "#/$defs/dspackId"
212
+ },
213
+ "description": {
214
+ "type": "string"
215
+ },
216
+ "commons": {
217
+ "type": "array",
218
+ "items": {
219
+ "type": "string",
220
+ "minLength": 1
221
+ }
222
+ },
223
+ "structural": {
224
+ "type": "object",
225
+ "additionalProperties": {
226
+ "type": "object",
227
+ "additionalProperties": false,
228
+ "required": [
229
+ "schema",
230
+ "description",
231
+ "synthNote"
232
+ ],
233
+ "properties": {
234
+ "schema": {},
235
+ "description": {
236
+ "type": "string",
237
+ "minLength": 1
238
+ },
239
+ "synthNote": {
240
+ "type": "string",
241
+ "minLength": 1
242
+ }
243
+ }
244
+ }
245
+ },
246
+ "propMap": {
247
+ "type": "object",
248
+ "additionalProperties": {
249
+ "type": "object",
250
+ "additionalProperties": false,
251
+ "required": [
252
+ "a2ui",
253
+ "kind"
254
+ ],
255
+ "properties": {
256
+ "a2ui": {
257
+ "type": "string",
258
+ "minLength": 1
259
+ },
260
+ "kind": {
261
+ "enum": [
262
+ "enum",
263
+ "string",
264
+ "boolean",
265
+ "number"
266
+ ]
267
+ },
268
+ "targetEnum": {
269
+ "type": "array",
270
+ "items": {
271
+ "type": "string"
272
+ },
273
+ "minItems": 1
274
+ },
275
+ "valueMap": {
276
+ "type": "object",
277
+ "additionalProperties": {
278
+ "type": "string"
279
+ }
280
+ },
281
+ "default": {
282
+ "type": "string"
283
+ },
284
+ "description": {
285
+ "type": "string"
286
+ }
287
+ }
288
+ }
289
+ },
290
+ "required": {
291
+ "type": "array",
292
+ "items": {
293
+ "type": "string"
294
+ }
295
+ },
296
+ "surface": {
297
+ "type": "object",
298
+ "additionalProperties": false,
299
+ "patternProperties": {
300
+ "^x-": {}
301
+ },
302
+ "properties": {
303
+ "routes": {
304
+ "type": "array",
305
+ "items": {
306
+ "type": "object",
307
+ "additionalProperties": false,
308
+ "required": [
309
+ "from",
310
+ "to"
311
+ ],
312
+ "properties": {
313
+ "from": {
314
+ "type": "array",
315
+ "minItems": 1,
316
+ "description": "Ordered fallback chain; the first selector that yields a value wins.",
317
+ "items": {
318
+ "type": "string",
319
+ "pattern": "^(self\\.text|self\\.props\\.[A-Za-z][A-Za-z0-9]*|sub\\([a-z][a-z0-9-]*(\\|[a-z][a-z0-9-]*)*\\)\\.(text|label|firstText|subtreeText)|children|synthesized\\.action)$"
320
+ }
321
+ },
322
+ "to": {
323
+ "type": "string",
324
+ "pattern": "^(prop|textChild|slot|slots|action):[A-Za-z][A-Za-z0-9]*$"
325
+ },
326
+ "overwrite": {
327
+ "type": "boolean"
328
+ }
329
+ }
330
+ }
331
+ },
332
+ "collects": {
333
+ "type": "array",
334
+ "items": {
335
+ "type": "object",
336
+ "additionalProperties": false,
337
+ "required": [
338
+ "of",
339
+ "into",
340
+ "shape",
341
+ "row",
342
+ "cells"
343
+ ],
344
+ "properties": {
345
+ "of": {
346
+ "type": "array",
347
+ "minItems": 1,
348
+ "items": {
349
+ "type": "string",
350
+ "pattern": "^[a-z][a-z0-9-]*$"
351
+ }
352
+ },
353
+ "into": {
354
+ "type": "string",
355
+ "pattern": "^prop:[A-Za-z][A-Za-z0-9]*$"
356
+ },
357
+ "shape": {
358
+ "enum": [
359
+ "flat",
360
+ "records"
361
+ ]
362
+ },
363
+ "field": {
364
+ "type": "string",
365
+ "pattern": "^[A-Za-z][A-Za-z0-9]*$"
366
+ },
367
+ "row": {
368
+ "type": "array",
369
+ "minItems": 1,
370
+ "items": {
371
+ "type": "string",
372
+ "pattern": "^[a-z][a-z0-9-]*$"
373
+ }
374
+ },
375
+ "cells": {
376
+ "type": "array",
377
+ "minItems": 1,
378
+ "items": {
379
+ "type": "string",
380
+ "pattern": "^[a-z][a-z0-9-]*$"
381
+ }
382
+ }
383
+ }
384
+ }
385
+ },
386
+ "subs": {
387
+ "type": "object",
388
+ "propertyNames": {
389
+ "pattern": "^[a-z][a-z0-9-]*$"
390
+ },
391
+ "additionalProperties": {
392
+ "oneOf": [
393
+ {
394
+ "const": "transparent"
395
+ },
396
+ {
397
+ "type": "object",
398
+ "additionalProperties": false,
399
+ "required": [
400
+ "asText"
401
+ ],
402
+ "properties": {
403
+ "asText": {
404
+ "type": "string",
405
+ "minLength": 1
406
+ }
407
+ }
408
+ },
409
+ {
410
+ "type": "object",
411
+ "additionalProperties": false,
412
+ "required": [
413
+ "drop"
414
+ ],
415
+ "properties": {
416
+ "drop": {
417
+ "type": "string",
418
+ "minLength": 1
419
+ }
420
+ }
421
+ }
422
+ ]
423
+ }
424
+ }
425
+ }
426
+ }
427
+ }
428
+ }
429
+ }
430
+ };
@@ -46,6 +46,29 @@ export interface Profile {
46
46
  wrapComponent: string;
47
47
  wrapChildrenProp: string;
48
48
  };
49
+ /**
50
+ * A2UI catalog functions this profile declares (v2 language only), keyed by
51
+ * call name. Emitted into the catalog's `functions` section and enforced on
52
+ * every FunctionCall an instance makes: calling an undeclared function fails
53
+ * gate A3. Definitions are declarative schemas for the call's args — the
54
+ * implementations live in renderers, exactly as A2UI intends; nothing
55
+ * executable can be expressed here.
56
+ */
57
+ functions?: Record<string, FunctionPlan>;
58
+ /**
59
+ * Which profile language this Profile was loaded from. Stamped by
60
+ * loadProfile ("v2" only); absent for v1 documents and TS-authored
61
+ * profiles. The transform layer keys fail-closed contract validation on it —
62
+ * v1 behaviour is frozen, v2 refuses what v1 merely warned about.
63
+ */
64
+ language?: "v2";
65
+ }
66
+ /** One declared A2UI catalog function: the schema of its wire-level call. */
67
+ export interface FunctionPlan {
68
+ description: string;
69
+ returns: "string" | "number" | "boolean" | "array" | "object";
70
+ /** JSON Schema (object form) validating the call's `args`; omit when arg-less. */
71
+ args?: Record<string, unknown>;
49
72
  }
50
73
  export interface ComponentPlan {
51
74
  a2ui: string;
@@ -61,8 +84,15 @@ export interface ComponentPlan {
61
84
  propMap?: Record<string, PropPlan>;
62
85
  /** A2UI required property names (the `component` const is added automatically). */
63
86
  required: string[];
64
- /** How the surface emitter projects a dspack-surface node onto this component. */
87
+ /** How the surface emitter projects a dspack-surface node onto this component (v1 language). */
65
88
  surfacePlan?: SurfacePlanDirectives;
89
+ /**
90
+ * The v2 spelling of the same question, authored in the internal
91
+ * Identity / Route / Collect vocabulary (see parse-v2.ts). A plan carries
92
+ * one language or the other, never both — the schemas enforce it per
93
+ * document, and surfaceModelOf dispatches on which is present.
94
+ */
95
+ surface?: import("./parse-v2.js").SurfaceV2;
66
96
  /**
67
97
  * Explicit per-sub-component disposition for compound components: every
68
98
  * contract sub id -> one line naming how the surface emitter treats it