@aestheticfunction/dspack-emit 0.4.0 → 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 (74) 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 +8 -7
  20. package/dist/transform/profile-load.js +101 -24
  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/profile-schema.d.ts +8 -0
  24. package/dist/transform/profile-schema.js +382 -0
  25. package/dist/transform/profiles.d.ts +31 -1
  26. package/dist/transform/scaffold.d.ts +29 -12
  27. package/dist/transform/scaffold.js +91 -31
  28. package/dist/transform/shadcn-v2-respelling.d.ts +12 -0
  29. package/dist/transform/shadcn-v2-respelling.js +49 -0
  30. package/dist/transform/validate-v2.d.ts +36 -0
  31. package/dist/transform/validate-v2.js +100 -0
  32. package/dist/types.d.ts +19 -0
  33. package/dist/validate/ajv.js +98 -29
  34. package/dist/validate/meta/catalog-meta.d.ts +10 -0
  35. package/dist/validate/meta/catalog-meta.js +157 -0
  36. package/package.json +3 -3
  37. package/src/__snapshots__/byte-neutral.test.ts.snap +66 -0
  38. package/src/browser-boundary.test.ts +47 -0
  39. package/src/byte-neutral.test.ts +246 -0
  40. package/src/cli.ts +60 -0
  41. package/src/dangling-ref.test.ts +118 -0
  42. package/src/desugar.test.ts +162 -0
  43. package/src/engine-boundary.test.ts +248 -0
  44. package/src/eval-fixture.test.ts +89 -0
  45. package/src/functions.test.ts +182 -0
  46. package/src/index.ts +4 -1
  47. package/src/profile-load.test.ts +99 -1
  48. package/src/profile-v2.test.ts +363 -0
  49. package/src/review-findings.test.ts +292 -0
  50. package/src/schema-mirrors.test.ts +35 -0
  51. package/src/surface-fidelity.test.ts +213 -0
  52. package/src/targets/a2ui/diagnostics.ts +136 -0
  53. package/src/targets/a2ui/surface.ts +920 -242
  54. package/src/transform/desugar.ts +194 -0
  55. package/src/transform/emit.ts +65 -0
  56. package/src/transform/index.ts +5 -0
  57. package/src/transform/mapping.ts +42 -0
  58. package/src/transform/model.ts +325 -0
  59. package/src/transform/parse-v2.ts +397 -0
  60. package/src/transform/profile-load.ts +107 -28
  61. package/src/transform/profile-schema-v2.ts +430 -0
  62. package/src/transform/profile-schema.ts +382 -0
  63. package/src/transform/profile.v2.schema.json +422 -0
  64. package/src/transform/profiles.ts +32 -1
  65. package/src/transform/scaffold.ts +124 -47
  66. package/src/transform/shadcn-v2-respelling.ts +61 -0
  67. package/src/transform/validate-v2.ts +138 -0
  68. package/src/types.ts +20 -0
  69. package/src/validate/ajv.ts +91 -32
  70. package/src/validate/meta/catalog-meta.ts +167 -0
  71. package/src/validate-v2.test.ts +173 -0
  72. package/dist/transform/profile.v1.schema.json +0 -153
  73. package/dist/validate/meta/a2ui-catalog.meta.0_9_1.json +0 -39
  74. package/dist/validate/meta/a2ui-catalog.meta.1_0.json +0 -34
@@ -0,0 +1,422 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://aestheticfunction.github.io/dspack-emit/schema/profile.v2.schema.json",
4
+ "title": "dspack-emit a2ui Profile v2",
5
+ "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.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "patternProperties": {
9
+ "^x-": {}
10
+ },
11
+ "required": [
12
+ "profileVersion",
13
+ "catalogTitle",
14
+ "catalogDescription",
15
+ "catalogIdBase",
16
+ "instructions",
17
+ "primaryColorToken",
18
+ "components",
19
+ "synthesized",
20
+ "casualtyComponents",
21
+ "surfaceSynthesis"
22
+ ],
23
+ "properties": {
24
+ "profileVersion": {
25
+ "const": "2"
26
+ },
27
+ "catalogTitle": {
28
+ "type": "string",
29
+ "minLength": 1
30
+ },
31
+ "catalogDescription": {
32
+ "type": "string",
33
+ "minLength": 1
34
+ },
35
+ "catalogIdBase": {
36
+ "type": "string",
37
+ "format": "uri",
38
+ "pattern": "^https://"
39
+ },
40
+ "instructions": {
41
+ "type": "string"
42
+ },
43
+ "primaryColorToken": {
44
+ "type": "object",
45
+ "additionalProperties": false,
46
+ "required": [
47
+ "category",
48
+ "name"
49
+ ],
50
+ "properties": {
51
+ "category": {
52
+ "type": "string",
53
+ "minLength": 1
54
+ },
55
+ "name": {
56
+ "type": "string",
57
+ "minLength": 1
58
+ }
59
+ }
60
+ },
61
+ "components": {
62
+ "type": "array",
63
+ "items": {
64
+ "$ref": "#/$defs/componentPlan"
65
+ }
66
+ },
67
+ "synthesized": {
68
+ "type": "array",
69
+ "items": {
70
+ "$ref": "#/$defs/componentPlan"
71
+ }
72
+ },
73
+ "casualtyComponents": {
74
+ "type": "array",
75
+ "items": {
76
+ "type": "object",
77
+ "additionalProperties": false,
78
+ "patternProperties": {
79
+ "^x-": {}
80
+ },
81
+ "required": [
82
+ "dspackId",
83
+ "attempted",
84
+ "class",
85
+ "reason"
86
+ ],
87
+ "properties": {
88
+ "dspackId": {
89
+ "$ref": "#/$defs/dspackId"
90
+ },
91
+ "attempted": {
92
+ "type": "string",
93
+ "minLength": 1
94
+ },
95
+ "class": {
96
+ "enum": [
97
+ "maps-cleanly",
98
+ "synthesis-defaults",
99
+ "lossy",
100
+ "cannot-represent"
101
+ ]
102
+ },
103
+ "reason": {
104
+ "type": "string",
105
+ "minLength": 1
106
+ }
107
+ }
108
+ }
109
+ },
110
+ "intentionallyOmitted": {
111
+ "type": "array",
112
+ "items": {
113
+ "$ref": "#/$defs/dspackId"
114
+ }
115
+ },
116
+ "surfaceSynthesis": {
117
+ "type": "object",
118
+ "additionalProperties": false,
119
+ "required": [
120
+ "textComponent",
121
+ "textProp",
122
+ "wrapComponent",
123
+ "wrapChildrenProp"
124
+ ],
125
+ "properties": {
126
+ "textComponent": {
127
+ "$ref": "#/$defs/a2uiName"
128
+ },
129
+ "textProp": {
130
+ "type": "string",
131
+ "minLength": 1
132
+ },
133
+ "wrapComponent": {
134
+ "$ref": "#/$defs/a2uiName"
135
+ },
136
+ "wrapChildrenProp": {
137
+ "type": "string",
138
+ "minLength": 1
139
+ }
140
+ }
141
+ },
142
+ "functions": {
143
+ "type": "object",
144
+ "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.",
145
+ "propertyNames": {
146
+ "pattern": "^[a-z][A-Za-z0-9]*$"
147
+ },
148
+ "additionalProperties": {
149
+ "type": "object",
150
+ "additionalProperties": false,
151
+ "required": [
152
+ "description",
153
+ "returns"
154
+ ],
155
+ "properties": {
156
+ "description": {
157
+ "type": "string",
158
+ "minLength": 1
159
+ },
160
+ "returns": {
161
+ "enum": [
162
+ "string",
163
+ "number",
164
+ "boolean",
165
+ "array",
166
+ "object"
167
+ ]
168
+ },
169
+ "args": {
170
+ "type": "object",
171
+ "description": "JSON Schema (object form) validating the call's args object; omit for arg-less functions."
172
+ }
173
+ }
174
+ }
175
+ }
176
+ },
177
+ "$defs": {
178
+ "dspackId": {
179
+ "type": "string",
180
+ "pattern": "^[a-z][a-z0-9-]*$"
181
+ },
182
+ "a2uiName": {
183
+ "type": "string",
184
+ "pattern": "^[A-Z][A-Za-z0-9]*$"
185
+ },
186
+ "componentPlan": {
187
+ "type": "object",
188
+ "additionalProperties": false,
189
+ "patternProperties": {
190
+ "^x-": {}
191
+ },
192
+ "required": [
193
+ "a2ui",
194
+ "commons",
195
+ "structural",
196
+ "required"
197
+ ],
198
+ "properties": {
199
+ "a2ui": {
200
+ "$ref": "#/$defs/a2uiName"
201
+ },
202
+ "dspackId": {
203
+ "$ref": "#/$defs/dspackId"
204
+ },
205
+ "description": {
206
+ "type": "string"
207
+ },
208
+ "commons": {
209
+ "type": "array",
210
+ "items": {
211
+ "type": "string",
212
+ "minLength": 1
213
+ }
214
+ },
215
+ "structural": {
216
+ "type": "object",
217
+ "additionalProperties": {
218
+ "type": "object",
219
+ "additionalProperties": false,
220
+ "required": [
221
+ "schema",
222
+ "description",
223
+ "synthNote"
224
+ ],
225
+ "properties": {
226
+ "schema": {},
227
+ "description": {
228
+ "type": "string",
229
+ "minLength": 1
230
+ },
231
+ "synthNote": {
232
+ "type": "string",
233
+ "minLength": 1
234
+ }
235
+ }
236
+ }
237
+ },
238
+ "propMap": {
239
+ "type": "object",
240
+ "additionalProperties": {
241
+ "type": "object",
242
+ "additionalProperties": false,
243
+ "required": [
244
+ "a2ui",
245
+ "kind"
246
+ ],
247
+ "properties": {
248
+ "a2ui": {
249
+ "type": "string",
250
+ "minLength": 1
251
+ },
252
+ "kind": {
253
+ "enum": [
254
+ "enum",
255
+ "string",
256
+ "boolean",
257
+ "number"
258
+ ]
259
+ },
260
+ "targetEnum": {
261
+ "type": "array",
262
+ "items": {
263
+ "type": "string"
264
+ },
265
+ "minItems": 1
266
+ },
267
+ "valueMap": {
268
+ "type": "object",
269
+ "additionalProperties": {
270
+ "type": "string"
271
+ }
272
+ },
273
+ "default": {
274
+ "type": "string"
275
+ },
276
+ "description": {
277
+ "type": "string"
278
+ }
279
+ }
280
+ }
281
+ },
282
+ "required": {
283
+ "type": "array",
284
+ "items": {
285
+ "type": "string"
286
+ }
287
+ },
288
+ "surface": {
289
+ "type": "object",
290
+ "additionalProperties": false,
291
+ "patternProperties": {
292
+ "^x-": {}
293
+ },
294
+ "properties": {
295
+ "routes": {
296
+ "type": "array",
297
+ "items": {
298
+ "type": "object",
299
+ "additionalProperties": false,
300
+ "required": [
301
+ "from",
302
+ "to"
303
+ ],
304
+ "properties": {
305
+ "from": {
306
+ "type": "array",
307
+ "minItems": 1,
308
+ "description": "Ordered fallback chain; the first selector that yields a value wins.",
309
+ "items": {
310
+ "type": "string",
311
+ "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)$"
312
+ }
313
+ },
314
+ "to": {
315
+ "type": "string",
316
+ "pattern": "^(prop|textChild|slot|slots|action):[A-Za-z][A-Za-z0-9]*$"
317
+ },
318
+ "overwrite": {
319
+ "type": "boolean"
320
+ }
321
+ }
322
+ }
323
+ },
324
+ "collects": {
325
+ "type": "array",
326
+ "items": {
327
+ "type": "object",
328
+ "additionalProperties": false,
329
+ "required": [
330
+ "of",
331
+ "into",
332
+ "shape",
333
+ "row",
334
+ "cells"
335
+ ],
336
+ "properties": {
337
+ "of": {
338
+ "type": "array",
339
+ "minItems": 1,
340
+ "items": {
341
+ "type": "string",
342
+ "pattern": "^[a-z][a-z0-9-]*$"
343
+ }
344
+ },
345
+ "into": {
346
+ "type": "string",
347
+ "pattern": "^prop:[A-Za-z][A-Za-z0-9]*$"
348
+ },
349
+ "shape": {
350
+ "enum": [
351
+ "flat",
352
+ "records"
353
+ ]
354
+ },
355
+ "field": {
356
+ "type": "string",
357
+ "pattern": "^[A-Za-z][A-Za-z0-9]*$"
358
+ },
359
+ "row": {
360
+ "type": "array",
361
+ "minItems": 1,
362
+ "items": {
363
+ "type": "string",
364
+ "pattern": "^[a-z][a-z0-9-]*$"
365
+ }
366
+ },
367
+ "cells": {
368
+ "type": "array",
369
+ "minItems": 1,
370
+ "items": {
371
+ "type": "string",
372
+ "pattern": "^[a-z][a-z0-9-]*$"
373
+ }
374
+ }
375
+ }
376
+ }
377
+ },
378
+ "subs": {
379
+ "type": "object",
380
+ "propertyNames": {
381
+ "pattern": "^[a-z][a-z0-9-]*$"
382
+ },
383
+ "additionalProperties": {
384
+ "oneOf": [
385
+ {
386
+ "const": "transparent"
387
+ },
388
+ {
389
+ "type": "object",
390
+ "additionalProperties": false,
391
+ "required": [
392
+ "asText"
393
+ ],
394
+ "properties": {
395
+ "asText": {
396
+ "type": "string",
397
+ "minLength": 1
398
+ }
399
+ }
400
+ },
401
+ {
402
+ "type": "object",
403
+ "additionalProperties": false,
404
+ "required": [
405
+ "drop"
406
+ ],
407
+ "properties": {
408
+ "drop": {
409
+ "type": "string",
410
+ "minLength": 1
411
+ }
412
+ }
413
+ }
414
+ ]
415
+ }
416
+ }
417
+ }
418
+ }
419
+ }
420
+ }
421
+ }
422
+ }
@@ -44,6 +44,30 @@ export interface Profile {
44
44
  wrapComponent: string;
45
45
  wrapChildrenProp: string;
46
46
  };
47
+ /**
48
+ * A2UI catalog functions this profile declares (v2 language only), keyed by
49
+ * call name. Emitted into the catalog's `functions` section and enforced on
50
+ * every FunctionCall an instance makes: calling an undeclared function fails
51
+ * gate A3. Definitions are declarative schemas for the call's args — the
52
+ * implementations live in renderers, exactly as A2UI intends; nothing
53
+ * executable can be expressed here.
54
+ */
55
+ functions?: Record<string, FunctionPlan>;
56
+ /**
57
+ * Which profile language this Profile was loaded from. Stamped by
58
+ * loadProfile ("v2" only); absent for v1 documents and TS-authored
59
+ * profiles. The transform layer keys fail-closed contract validation on it —
60
+ * v1 behaviour is frozen, v2 refuses what v1 merely warned about.
61
+ */
62
+ language?: "v2";
63
+ }
64
+
65
+ /** One declared A2UI catalog function: the schema of its wire-level call. */
66
+ export interface FunctionPlan {
67
+ description: string;
68
+ returns: "string" | "number" | "boolean" | "array" | "object";
69
+ /** JSON Schema (object form) validating the call's `args`; omit when arg-less. */
70
+ args?: Record<string, unknown>;
47
71
  }
48
72
 
49
73
  export interface ComponentPlan {
@@ -60,8 +84,15 @@ export interface ComponentPlan {
60
84
  propMap?: Record<string, PropPlan>;
61
85
  /** A2UI required property names (the `component` const is added automatically). */
62
86
  required: string[];
63
- /** 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). */
64
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;
65
96
  /**
66
97
  * Explicit per-sub-component disposition for compound components: every
67
98
  * contract sub id -> one line naming how the surface emitter treats it