@aestheticfunction/dspack-emit 0.4.1 → 0.6.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 (72) 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 +1004 -222
  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 +66 -2
  15. package/dist/transform/model.d.ts +368 -0
  16. package/dist/transform/model.js +169 -0
  17. package/dist/transform/parse-v2.d.ts +109 -0
  18. package/dist/transform/parse-v2.js +479 -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 +608 -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 +77 -0
  27. package/dist/transform/shadcn-v2-respelling.js +456 -0
  28. package/dist/transform/validate-v2.d.ts +36 -0
  29. package/dist/transform/validate-v2.js +136 -0
  30. package/dist/types.d.ts +23 -0
  31. package/dist/validate/ajv.js +96 -25
  32. package/dist/validate/meta/a2ui-catalog.meta.0_9_1.json +39 -0
  33. package/dist/validate/meta/a2ui-catalog.meta.1_0.json +34 -0
  34. package/package.json +2 -2
  35. package/src/__snapshots__/byte-neutral.test.ts.snap +66 -0
  36. package/src/a0.test.ts +235 -0
  37. package/src/byte-neutral.test.ts +246 -0
  38. package/src/cli.ts +60 -0
  39. package/src/dangling-ref.test.ts +118 -0
  40. package/src/desugar.test.ts +162 -0
  41. package/src/engine-boundary.test.ts +248 -0
  42. package/src/eval-fixture.test.ts +102 -0
  43. package/src/functions.test.ts +182 -0
  44. package/src/index.ts +4 -1
  45. package/src/layered-dissolution.test.ts +139 -0
  46. package/src/profile-load.test.ts +99 -1
  47. package/src/profile-v2.test.ts +369 -0
  48. package/src/review-findings.test.ts +292 -0
  49. package/src/schema-mirrors.test.ts +5 -0
  50. package/src/surface-fidelity.test.ts +213 -0
  51. package/src/t1.test.ts +369 -0
  52. package/src/t2.test.ts +222 -0
  53. package/src/t3.test.ts +304 -0
  54. package/src/t4.test.ts +278 -0
  55. package/src/targets/a2ui/diagnostics.ts +136 -0
  56. package/src/targets/a2ui/surface.ts +1468 -235
  57. package/src/transform/desugar.ts +194 -0
  58. package/src/transform/emit.ts +65 -0
  59. package/src/transform/index.ts +5 -0
  60. package/src/transform/mapping.ts +60 -2
  61. package/src/transform/model.ts +427 -0
  62. package/src/transform/parse-v2.ts +608 -0
  63. package/src/transform/profile-load.ts +104 -22
  64. package/src/transform/profile-schema-v2.ts +608 -0
  65. package/src/transform/profile.v2.schema.json +600 -0
  66. package/src/transform/profiles.ts +32 -1
  67. package/src/transform/scaffold.ts +124 -47
  68. package/src/transform/shadcn-v2-respelling.ts +475 -0
  69. package/src/transform/validate-v2.ts +174 -0
  70. package/src/types.ts +32 -0
  71. package/src/validate/ajv.ts +89 -26
  72. package/src/validate-v2.test.ts +173 -0
@@ -0,0 +1,608 @@
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: Record<string, unknown> = {
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
+ "transparent": {
304
+ "oneOf": [
305
+ {
306
+ "const": true
307
+ },
308
+ {
309
+ "type": "object",
310
+ "additionalProperties": false,
311
+ "required": [
312
+ "donate"
313
+ ],
314
+ "properties": {
315
+ "donate": {
316
+ "type": "array",
317
+ "minItems": 1,
318
+ "items": {
319
+ "type": "object",
320
+ "additionalProperties": false,
321
+ "required": [
322
+ "from",
323
+ "to"
324
+ ],
325
+ "properties": {
326
+ "from": {
327
+ "type": "string",
328
+ "pattern": "^(self\\.text|sub\\([a-z][a-z0-9-]*(\\|[a-z][a-z0-9-]*)*\\)\\.text)$"
329
+ },
330
+ "to": {
331
+ "type": "string",
332
+ "pattern": "^prop:[A-Za-z][A-Za-z0-9]*$"
333
+ }
334
+ }
335
+ }
336
+ }
337
+ }
338
+ }
339
+ ]
340
+ },
341
+ "routes": {
342
+ "type": "array",
343
+ "items": {
344
+ "type": "object",
345
+ "additionalProperties": false,
346
+ "required": [
347
+ "from",
348
+ "to"
349
+ ],
350
+ "properties": {
351
+ "from": {
352
+ "type": "array",
353
+ "minItems": 1,
354
+ "description": "Ordered fallback chain; the first selector that yields a value wins.",
355
+ "items": {
356
+ "type": "string",
357
+ "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)|children|synthesized\\.action)$"
358
+ }
359
+ },
360
+ "to": {
361
+ "type": "string",
362
+ "pattern": "^(prop|textChild|slot|slots|action):[A-Za-z][A-Za-z0-9]*$"
363
+ },
364
+ "overwrite": {
365
+ "type": "boolean"
366
+ }
367
+ }
368
+ }
369
+ },
370
+ "collects": {
371
+ "type": "array",
372
+ "items": {
373
+ "oneOf": [
374
+ {
375
+ "type": "object",
376
+ "additionalProperties": false,
377
+ "required": [
378
+ "of",
379
+ "into",
380
+ "item"
381
+ ],
382
+ "properties": {
383
+ "of": {
384
+ "type": "array",
385
+ "minItems": 1,
386
+ "items": {
387
+ "type": "string",
388
+ "pattern": "^[a-z][a-z0-9-]*$"
389
+ }
390
+ },
391
+ "into": {
392
+ "type": "string",
393
+ "pattern": "^prop:[A-Za-z][A-Za-z0-9]*$"
394
+ },
395
+ "item": {
396
+ "type": "object",
397
+ "minProperties": 1,
398
+ "propertyNames": {
399
+ "pattern": "^[A-Za-z][A-Za-z0-9]*$"
400
+ },
401
+ "additionalProperties": {
402
+ "type": "string",
403
+ "pattern": "^(self\\.text|self\\.id|self\\.props\\.[A-Za-z][A-Za-z0-9]*)$"
404
+ },
405
+ "description": "T2 item-mode: one record per matching descendant; fields resolve on the item's own node (self.text, self.props.<prop>, self.id). Joins and sibling reads are T3."
406
+ },
407
+ "join": {
408
+ "type": "object",
409
+ "additionalProperties": false,
410
+ "required": [
411
+ "with",
412
+ "on",
413
+ "fields"
414
+ ],
415
+ "properties": {
416
+ "with": {
417
+ "type": "array",
418
+ "minItems": 1,
419
+ "items": {
420
+ "type": "string",
421
+ "pattern": "^[a-z][a-z0-9-]*$"
422
+ }
423
+ },
424
+ "on": {
425
+ "type": "object",
426
+ "additionalProperties": false,
427
+ "required": [
428
+ "left",
429
+ "right"
430
+ ],
431
+ "properties": {
432
+ "left": {
433
+ "type": "string",
434
+ "pattern": "^(self\\.text|self\\.id|self\\.props\\.[A-Za-z][A-Za-z0-9]*)$"
435
+ },
436
+ "right": {
437
+ "type": "string",
438
+ "pattern": "^(self\\.text|self\\.id|self\\.props\\.[A-Za-z][A-Za-z0-9]*)$"
439
+ }
440
+ }
441
+ },
442
+ "fields": {
443
+ "type": "object",
444
+ "minProperties": 1,
445
+ "propertyNames": {
446
+ "pattern": "^[A-Za-z][A-Za-z0-9]*$"
447
+ },
448
+ "additionalProperties": {
449
+ "type": "string",
450
+ "pattern": "^(children|self\\.text|self\\.id|self\\.props\\.[A-Za-z][A-Za-z0-9]*)$"
451
+ },
452
+ "description": "Record fields sourced from the JOINED side \u2014 item-local selectors, or the literal \"children\" for the slot-valued field (the counterpart's children emit as instances; the record carries the reference)."
453
+ },
454
+ "optional": {
455
+ "type": "boolean",
456
+ "description": "0..1 counterparts allowed when true; exactly one required otherwise."
457
+ }
458
+ },
459
+ "description": "T3 declared key join onto a sibling sub-family. The profile names the relation; the emitter never infers one \u2014 no positional pairing, no nearest-sibling, no similarity."
460
+ }
461
+ }
462
+ },
463
+ {
464
+ "type": "object",
465
+ "additionalProperties": false,
466
+ "required": [
467
+ "of",
468
+ "into",
469
+ "shape",
470
+ "row",
471
+ "cells"
472
+ ],
473
+ "properties": {
474
+ "of": {
475
+ "type": "array",
476
+ "minItems": 1,
477
+ "items": {
478
+ "type": "string",
479
+ "pattern": "^[a-z][a-z0-9-]*$"
480
+ }
481
+ },
482
+ "into": {
483
+ "type": "string",
484
+ "pattern": "^prop:[A-Za-z][A-Za-z0-9]*$"
485
+ },
486
+ "shape": {
487
+ "enum": [
488
+ "flat",
489
+ "records"
490
+ ]
491
+ },
492
+ "field": {
493
+ "type": "string",
494
+ "pattern": "^[A-Za-z][A-Za-z0-9]*$"
495
+ },
496
+ "row": {
497
+ "type": "array",
498
+ "minItems": 1,
499
+ "items": {
500
+ "type": "string",
501
+ "pattern": "^[a-z][a-z0-9-]*$"
502
+ }
503
+ },
504
+ "cells": {
505
+ "type": "array",
506
+ "minItems": 1,
507
+ "items": {
508
+ "type": "string",
509
+ "pattern": "^[a-z][a-z0-9-]*$"
510
+ }
511
+ }
512
+ }
513
+ }
514
+ ]
515
+ }
516
+ },
517
+ "subs": {
518
+ "type": "object",
519
+ "propertyNames": {
520
+ "pattern": "^[a-z][a-z0-9-]*$"
521
+ },
522
+ "additionalProperties": {
523
+ "oneOf": [
524
+ {
525
+ "const": "transparent"
526
+ },
527
+ {
528
+ "type": "object",
529
+ "additionalProperties": false,
530
+ "required": [
531
+ "transparent"
532
+ ],
533
+ "properties": {
534
+ "transparent": {
535
+ "oneOf": [
536
+ {
537
+ "const": true
538
+ },
539
+ {
540
+ "type": "object",
541
+ "additionalProperties": false,
542
+ "required": [
543
+ "donate"
544
+ ],
545
+ "properties": {
546
+ "donate": {
547
+ "type": "array",
548
+ "minItems": 1,
549
+ "items": {
550
+ "type": "object",
551
+ "additionalProperties": false,
552
+ "required": [
553
+ "from",
554
+ "to"
555
+ ],
556
+ "properties": {
557
+ "from": {
558
+ "type": "string",
559
+ "pattern": "^(self\\.text|sub\\([a-z][a-z0-9-]*(\\|[a-z][a-z0-9-]*)*\\)\\.text)$"
560
+ },
561
+ "to": {
562
+ "type": "string",
563
+ "pattern": "^prop:[A-Za-z][A-Za-z0-9]*$"
564
+ }
565
+ }
566
+ }
567
+ }
568
+ }
569
+ }
570
+ ]
571
+ }
572
+ }
573
+ },
574
+ {
575
+ "type": "object",
576
+ "additionalProperties": false,
577
+ "required": [
578
+ "asText"
579
+ ],
580
+ "properties": {
581
+ "asText": {
582
+ "type": "string",
583
+ "minLength": 1
584
+ }
585
+ }
586
+ },
587
+ {
588
+ "type": "object",
589
+ "additionalProperties": false,
590
+ "required": [
591
+ "drop"
592
+ ],
593
+ "properties": {
594
+ "drop": {
595
+ "type": "string",
596
+ "minLength": 1
597
+ }
598
+ }
599
+ }
600
+ ]
601
+ }
602
+ }
603
+ }
604
+ }
605
+ }
606
+ }
607
+ }
608
+ };