@aestheticfunction/dspack-emit 0.5.0 → 0.7.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 +5 -3
- package/dist/targets/a2ui/surface.js +580 -36
- package/dist/transform/mapping.js +21 -7
- package/dist/transform/model.d.ts +94 -1
- package/dist/transform/model.js +25 -4
- package/dist/transform/parse-v2.d.ts +55 -24
- package/dist/transform/parse-v2.js +176 -2
- package/dist/transform/profile-schema-v2.js +224 -46
- package/dist/transform/shadcn-v2-respelling.d.ts +65 -0
- package/dist/transform/shadcn-v2-respelling.js +407 -0
- package/dist/transform/validate-v2.js +39 -3
- package/dist/types.d.ts +5 -1
- package/dist/validate/ajv.d.ts +19 -0
- package/dist/validate/ajv.js +78 -13
- package/package.json +6 -2
- package/src/a0.test.ts +235 -0
- package/src/engine-boundary.test.ts +10 -0
- package/src/eval-fixture.test.ts +27 -14
- package/src/instance-diagnostics.test.ts +194 -0
- package/src/layered-dissolution.test.ts +139 -0
- package/src/profile-v2.test.ts +9 -3
- package/src/review-findings.test.ts +4 -1
- package/src/surface-emit.test.ts +43 -11
- package/src/surface-fidelity.test.ts +12 -0
- package/src/t1.test.ts +370 -0
- package/src/t2.test.ts +222 -0
- package/src/t3.test.ts +304 -0
- package/src/t4.test.ts +278 -0
- package/src/targets/a2ui/surface.ts +747 -72
- package/src/transform/mapping.ts +22 -6
- package/src/transform/model.ts +107 -5
- package/src/transform/parse-v2.ts +228 -17
- package/src/transform/profile-schema-v2.ts +224 -46
- package/src/transform/profile.v2.schema.json +224 -46
- package/src/transform/shadcn-v2-respelling.ts +414 -0
- package/src/transform/validate-v2.ts +39 -3
- package/src/types.ts +13 -1
- package/src/validate/ajv.ts +96 -12
- package/src/validate-v2.test.ts +1 -1
|
@@ -59,3 +59,417 @@ export const SHADCN_V2_SURFACES: Record<string, SurfaceV2> = {
|
|
|
59
59
|
],
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* T1 resolutions for the production v3 contract — the transparent-identity
|
|
65
|
+
* spellings proven by src/t1.test.ts against the named production failure
|
|
66
|
+
* (`card > form > form-field > form-item > form-label + input`). Consumed by
|
|
67
|
+
* the eval fixture builder as committed mapping evidence; the fixture's other
|
|
68
|
+
* unresolved decisions stay deliberately open.
|
|
69
|
+
*/
|
|
70
|
+
export const SHADCN_V3_T1_SURFACES: Record<string, SurfaceV2> = {
|
|
71
|
+
form: {
|
|
72
|
+
transparent: true,
|
|
73
|
+
subs: {
|
|
74
|
+
"form-field": "transparent",
|
|
75
|
+
"form-control": "transparent",
|
|
76
|
+
"form-item": { transparent: { donate: [{ from: "sub(form-label).text", to: "prop:label" }] } },
|
|
77
|
+
"form-description": { asText: "caption" },
|
|
78
|
+
"form-message": { drop: "validation state is runtime data the declarative surface does not carry" },
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* T2 resolutions for the production v3 contract — item-mode collection
|
|
85
|
+
* spellings proven by src/t2.test.ts. `radio-group` collects what each item
|
|
86
|
+
* itself carries ({value: self.id}); its htmlFor-joined sibling labels are
|
|
87
|
+
* the measured T3 frontier, dropped with record until declared joins land.
|
|
88
|
+
* `select` is the pure homogeneous shape ({label: self.text}).
|
|
89
|
+
*
|
|
90
|
+
* Each entry carries the full receiving plan (structural options schema) —
|
|
91
|
+
* unlike T1's transparent plans, a collecting plan IS a catalog component.
|
|
92
|
+
*/
|
|
93
|
+
export const SHADCN_V3_T3_PLANS: Record<string, Record<string, unknown>> = {
|
|
94
|
+
tabs: {
|
|
95
|
+
a2ui: "Tabs",
|
|
96
|
+
dspackId: "tabs",
|
|
97
|
+
commons: ["ComponentCommon"],
|
|
98
|
+
structural: {
|
|
99
|
+
sections: {
|
|
100
|
+
schema: {
|
|
101
|
+
type: "array",
|
|
102
|
+
items: {
|
|
103
|
+
type: "object",
|
|
104
|
+
properties: { title: { type: "string" }, value: { type: "string" }, child: { $ref: "#/$defs/ComponentId" } },
|
|
105
|
+
required: ["title", "child"],
|
|
106
|
+
additionalProperties: false,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
description: "The tab sections: a title and the panel it reveals.",
|
|
110
|
+
synthNote: "A2UI models paired trigger/panel families as one array of {title, child} records (T3 declared join; the worked example keys on ids).",
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
propMap: { defaultValue: { a2ui: "defaultValue", kind: "string" } },
|
|
114
|
+
required: ["sections"],
|
|
115
|
+
surface: {
|
|
116
|
+
collects: [
|
|
117
|
+
{
|
|
118
|
+
of: ["tabs-trigger"],
|
|
119
|
+
into: "prop:sections",
|
|
120
|
+
item: { title: "self.text", value: "self.id" },
|
|
121
|
+
join: { with: ["tabs-content"], on: { left: "self.id", right: "self.id" }, fields: { child: "children" } },
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const SHADCN_V3_T2_PLANS: Record<string, Record<string, unknown>> = {
|
|
129
|
+
"radio-group": {
|
|
130
|
+
a2ui: "RadioGroup",
|
|
131
|
+
dspackId: "radio-group",
|
|
132
|
+
commons: ["ComponentCommon"],
|
|
133
|
+
structural: {
|
|
134
|
+
label: {
|
|
135
|
+
schema: { type: "string" },
|
|
136
|
+
description: "The group-level label naming the choice being made.",
|
|
137
|
+
synthNote: "Sourced by T1 form-label donation when the group sits inside a form field; a group without one relies on context.",
|
|
138
|
+
},
|
|
139
|
+
options: {
|
|
140
|
+
schema: { type: "array", items: { type: "object", properties: { value: { type: "string" }, label: { type: "string" } }, required: ["value"], additionalProperties: false } },
|
|
141
|
+
description: "The selectable options, one record per item.",
|
|
142
|
+
synthNote: "A2UI models repeated options as data on the group; dspack models them as repeated sub-components (T2 item-mode collection).",
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
propMap: {
|
|
146
|
+
name: { a2ui: "name", kind: "string" },
|
|
147
|
+
defaultValue: { a2ui: "defaultValue", kind: "string" },
|
|
148
|
+
},
|
|
149
|
+
required: ["options"],
|
|
150
|
+
// T3: the htmlFor->id join carries each item's sibling label into its
|
|
151
|
+
// record. Value still sources from self.id — a documented limitation:
|
|
152
|
+
// ids are DOM identity, not semantic values ("reimbursement-payroll" vs
|
|
153
|
+
// defaultValue "payroll"); the real shadcn API declares value on the
|
|
154
|
+
// item, and the contract gap is filed upstream.
|
|
155
|
+
surface: {
|
|
156
|
+
collects: [
|
|
157
|
+
{
|
|
158
|
+
of: ["radio-group-item"],
|
|
159
|
+
into: "prop:options",
|
|
160
|
+
item: { value: "self.id" },
|
|
161
|
+
join: { with: ["label"], on: { left: "self.id", right: "self.props.htmlFor" }, fields: { label: "self.text" } },
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
select: {
|
|
167
|
+
a2ui: "Select",
|
|
168
|
+
dspackId: "select",
|
|
169
|
+
commons: ["ComponentCommon"],
|
|
170
|
+
structural: {
|
|
171
|
+
options: {
|
|
172
|
+
schema: { type: "array", items: { type: "object", properties: { label: { type: "string" } }, required: ["label"], additionalProperties: false } },
|
|
173
|
+
description: "The selectable options.",
|
|
174
|
+
synthNote: "A2UI models repeated options as data on the control (T2 item-mode collection).",
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
propMap: { defaultValue: { a2ui: "defaultValue", kind: "string" } },
|
|
178
|
+
required: ["options"],
|
|
179
|
+
surface: {
|
|
180
|
+
collects: [{ of: ["select-item"], into: "prop:options", item: { label: "self.text" } }],
|
|
181
|
+
subs: {
|
|
182
|
+
"select-trigger": { drop: "the trigger renders from the bound value, not authored content" },
|
|
183
|
+
"select-value": { drop: "the visible value is runtime state derived from the selection" },
|
|
184
|
+
"select-label": { drop: "group headings are not carried by the flat options shape" },
|
|
185
|
+
"select-separator": { drop: "visual grouping chrome with no data meaning" },
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* A0 authoring resolutions (the zero-new-capability milestone): production
|
|
193
|
+
* profile judgment for the families the shipped Identity/Routing/Repetition
|
|
194
|
+
* model already supports, proven by src/a0.test.ts. Six compound plans plus
|
|
195
|
+
* label-slot additions on the five controls that appear as a field's single
|
|
196
|
+
* control (the T1 donation destination). No new primitive anywhere.
|
|
197
|
+
*
|
|
198
|
+
* Grounded in measured usage across the 14 worked examples (contract 3.2.0):
|
|
199
|
+
* alert-title 5/5 + alert-description 5/5 carry the content; avatar-fallback
|
|
200
|
+
* carries text while avatar-image is an EMPTY node (the contract declares no
|
|
201
|
+
* src/alt — the dspack#39 class, recorded on the drop); scroll-area's two
|
|
202
|
+
* subs are scrollbar chrome; the field family follows the corrected
|
|
203
|
+
* declaration (dspack#40) with field as its own donating boundary.
|
|
204
|
+
*/
|
|
205
|
+
export const SHADCN_V3_A0_PLANS: Record<string, Record<string, unknown>> = {
|
|
206
|
+
alert: {
|
|
207
|
+
a2ui: "Alert",
|
|
208
|
+
dspackId: "alert",
|
|
209
|
+
commons: ["ComponentCommon"],
|
|
210
|
+
structural: {
|
|
211
|
+
title: {
|
|
212
|
+
schema: { type: "string" },
|
|
213
|
+
description: "The one-line heading naming what happened.",
|
|
214
|
+
synthNote: "Lifted from the alert-title sub (5/5 worked examples carry it there).",
|
|
215
|
+
},
|
|
216
|
+
description: {
|
|
217
|
+
schema: { type: "string" },
|
|
218
|
+
description: "Supporting detail under the title.",
|
|
219
|
+
synthNote: "Lifted from the alert-description sub.",
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
propMap: {
|
|
223
|
+
variant: { a2ui: "variant", kind: "enum", targetEnum: ["default", "destructive"], default: "default" },
|
|
224
|
+
},
|
|
225
|
+
required: ["title"],
|
|
226
|
+
surface: {
|
|
227
|
+
routes: [
|
|
228
|
+
{ from: ["sub(alert-title).text"], to: "prop:title" },
|
|
229
|
+
{ from: ["sub(alert-description).text"], to: "prop:description" },
|
|
230
|
+
],
|
|
231
|
+
subs: {
|
|
232
|
+
"alert-action": {
|
|
233
|
+
drop:
|
|
234
|
+
"an action slot holds component children (a button), and routing a sub's children to a slot is T4's mechanism — dropped WITH RECORD until T4, not approximated (one production instance: ex.import-run-status)",
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
avatar: {
|
|
240
|
+
a2ui: "Avatar",
|
|
241
|
+
dspackId: "avatar",
|
|
242
|
+
commons: ["ComponentCommon"],
|
|
243
|
+
structural: {
|
|
244
|
+
fallback: {
|
|
245
|
+
schema: { type: "string" },
|
|
246
|
+
description: "Initials shown while no image is available.",
|
|
247
|
+
synthNote: "Lifted from the avatar-fallback sub's text.",
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
propMap: { size: { a2ui: "size", kind: "enum", targetEnum: ["sm", "default", "lg"], default: "default" } },
|
|
251
|
+
required: ["fallback"],
|
|
252
|
+
surface: {
|
|
253
|
+
routes: [{ from: ["sub(avatar-fallback).text"], to: "prop:fallback" }],
|
|
254
|
+
subs: {
|
|
255
|
+
"avatar-image": {
|
|
256
|
+
drop: "the contract declares no src/alt on avatar-image — an empty node carries nothing to project (contract-gap class, cf. dspack#39)",
|
|
257
|
+
},
|
|
258
|
+
"avatar-badge": { drop: "no worked example exercises it; no measured shape to project — revisit with usage evidence" },
|
|
259
|
+
"avatar-group": { drop: "no worked example exercises it; a grouped-avatars shape is repetition to be measured, not guessed" },
|
|
260
|
+
"avatar-group-count": { drop: "no worked example exercises it; belongs to the unmeasured avatar-group shape" },
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
"scroll-area": {
|
|
265
|
+
a2ui: "ScrollArea",
|
|
266
|
+
dspackId: "scroll-area",
|
|
267
|
+
commons: ["ComponentCommon"],
|
|
268
|
+
structural: {},
|
|
269
|
+
required: [],
|
|
270
|
+
surface: {
|
|
271
|
+
transparent: true,
|
|
272
|
+
subs: {
|
|
273
|
+
"scroll-area-scrollbar": { drop: "scrollbar chrome: presentation of the scroll container, not content" },
|
|
274
|
+
"scroll-area-thumb": { drop: "the scrollbar's drag indicator: chrome, not content" },
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
field: {
|
|
279
|
+
a2ui: "Field",
|
|
280
|
+
dspackId: "field",
|
|
281
|
+
commons: ["ComponentCommon"],
|
|
282
|
+
structural: {},
|
|
283
|
+
required: [],
|
|
284
|
+
surface: {
|
|
285
|
+
transparent: { donate: [{ from: "sub(field-label).text", to: "prop:label" }] },
|
|
286
|
+
subs: {
|
|
287
|
+
"field-content": "transparent",
|
|
288
|
+
"field-title": { asText: "h4" },
|
|
289
|
+
"field-description": { asText: "caption" },
|
|
290
|
+
"field-error": { drop: "validation state is runtime data the declarative surface does not carry (mirrors form-message)" },
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
"field-set": {
|
|
295
|
+
a2ui: "FieldSet",
|
|
296
|
+
dspackId: "field-set",
|
|
297
|
+
commons: ["ComponentCommon"],
|
|
298
|
+
structural: {},
|
|
299
|
+
required: [],
|
|
300
|
+
surface: {
|
|
301
|
+
transparent: true,
|
|
302
|
+
subs: { "field-legend": { asText: "h4" } },
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
"field-group": {
|
|
306
|
+
a2ui: "FieldGroup",
|
|
307
|
+
dspackId: "field-group",
|
|
308
|
+
commons: ["ComponentCommon"],
|
|
309
|
+
structural: {},
|
|
310
|
+
required: [],
|
|
311
|
+
surface: {
|
|
312
|
+
transparent: true,
|
|
313
|
+
subs: {
|
|
314
|
+
"field-separator": { drop: "a visual section boundary; its optional inline text is presentation of the divider, and no worked example carries one" },
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* A0 label additions: the five controls that appear as a field's (or
|
|
322
|
+
* form-item's) single control across the worked examples — input already
|
|
323
|
+
* declares `label`; these gain the same structural slot so the T1 donation
|
|
324
|
+
* has a declared destination. Merged onto the scaffolded plans (select's T2
|
|
325
|
+
* plan) by the fixture builder; nothing else on those plans changes.
|
|
326
|
+
*/
|
|
327
|
+
export const SHADCN_V3_A0_LABEL_ADDITIONS: Record<string, { description: string; synthNote: string }> = {
|
|
328
|
+
switch: {
|
|
329
|
+
description: "The label naming what the switch turns on or off.",
|
|
330
|
+
synthNote: "Sourced by the T1 field-label/form-label donation; 4/4 worked-example switches sit inside a field.",
|
|
331
|
+
},
|
|
332
|
+
checkbox: {
|
|
333
|
+
description: "The label naming what checking the box asserts.",
|
|
334
|
+
synthNote: "Sourced by the T1 form-label donation (ex.expense-report-form's billable field).",
|
|
335
|
+
},
|
|
336
|
+
textarea: {
|
|
337
|
+
description: "The label naming the long-text entry.",
|
|
338
|
+
synthNote: "Sourced by the T1 field-label/form-label donation, exactly as on input.",
|
|
339
|
+
},
|
|
340
|
+
progress: {
|
|
341
|
+
description: "The label naming what is progressing.",
|
|
342
|
+
synthNote: "Sourced by the T1 field-label donation; 2/2 worked-example progress bars sit inside a field.",
|
|
343
|
+
},
|
|
344
|
+
select: {
|
|
345
|
+
description: "The label naming the choice being made.",
|
|
346
|
+
synthNote: "Sourced by the T1 field-label/form-label donation when the select is a field's control (ex.invite-teammates-dialog).",
|
|
347
|
+
},
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* T4 resolutions: multi-slot compounds, proven by src/t4.test.ts. The new
|
|
352
|
+
* primitive is ONE closed spelling — `sub(x).children -> slot:name` — the
|
|
353
|
+
* region's ordered children emitted as instances, the slot carrying the
|
|
354
|
+
* reference (multi wraps in Column, exactly like T3's joined-children).
|
|
355
|
+
*
|
|
356
|
+
* Measured shapes (contract 3.2.0 worked examples):
|
|
357
|
+
* - dialog/sheet: trigger and close labels are TEXT lifts (the alert-dialog
|
|
358
|
+
* idiom); title/description lift; header dissolves; content minus the
|
|
359
|
+
* claimed regions is the body slot; footer minus close is the footer slot.
|
|
360
|
+
* - popover: same family; its measured body is EMPTY after the header
|
|
361
|
+
* dissolves — the slot stays absent and gate A3 arbitrates. The unused
|
|
362
|
+
* popover-anchor drops pending usage evidence.
|
|
363
|
+
* - dropdown-menu is DATA-shaped, not slot-shaped: its items are a T2
|
|
364
|
+
* item-mode collect and its labels are scalar text routes — resolved with
|
|
365
|
+
* ZERO new primitive. The historic taxonomy called it T4; measurement
|
|
366
|
+
* says otherwise, and the plan follows the measurement.
|
|
367
|
+
*/
|
|
368
|
+
export const SHADCN_V3_T4_PLANS: Record<string, Record<string, unknown>> = {
|
|
369
|
+
dialog: {
|
|
370
|
+
a2ui: "Dialog",
|
|
371
|
+
dspackId: "dialog",
|
|
372
|
+
commons: ["ComponentCommon"],
|
|
373
|
+
structural: {
|
|
374
|
+
title: { schema: { type: "string" }, description: "The dialog's title (aria-labelledby).", synthNote: "Lifted from dialog-title." },
|
|
375
|
+
description: { schema: { type: "string" }, description: "Supporting context under the title.", synthNote: "Lifted from dialog-description." },
|
|
376
|
+
triggerLabel: { schema: { type: "string" }, description: "Label of the control that opens the dialog.", synthNote: "Lifted from the trigger's button label (the alert-dialog idiom)." },
|
|
377
|
+
closeLabel: { schema: { type: "string" }, description: "Label of the explicit close control.", synthNote: "Lifted from dialog-close." },
|
|
378
|
+
child: { schema: { $ref: "#/$defs/ComponentId" }, description: "The dialog body: content minus the claimed regions, Column-wrapped when several.", synthNote: "T4 slot route from dialog-content's children." },
|
|
379
|
+
footer: { schema: { $ref: "#/$defs/ComponentId" }, description: "The action row minus the close control.", synthNote: "T4 slot route from dialog-footer's children." },
|
|
380
|
+
},
|
|
381
|
+
required: ["title"],
|
|
382
|
+
surface: {
|
|
383
|
+
routes: [
|
|
384
|
+
{ from: ["sub(dialog-title).text"], to: "prop:title" },
|
|
385
|
+
{ from: ["sub(dialog-description).text"], to: "prop:description" },
|
|
386
|
+
{ from: ["sub(dialog-trigger).label", "sub(dialog-trigger).firstText"], to: "prop:triggerLabel" },
|
|
387
|
+
{ from: ["sub(dialog-close).text"], to: "prop:closeLabel" },
|
|
388
|
+
{ from: ["sub(dialog-content).children"], to: "slot:child" },
|
|
389
|
+
{ from: ["sub(dialog-footer).children"], to: "slot:footer" },
|
|
390
|
+
],
|
|
391
|
+
subs: { "dialog-header": "transparent" },
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
sheet: {
|
|
395
|
+
a2ui: "Sheet",
|
|
396
|
+
dspackId: "sheet",
|
|
397
|
+
commons: ["ComponentCommon"],
|
|
398
|
+
structural: {
|
|
399
|
+
title: { schema: { type: "string" }, description: "The panel's title.", synthNote: "Lifted from sheet-title." },
|
|
400
|
+
description: { schema: { type: "string" }, description: "Supporting copy beneath the title.", synthNote: "Lifted from sheet-description." },
|
|
401
|
+
triggerLabel: { schema: { type: "string" }, description: "Label of the control that opens the sheet.", synthNote: "Lifted from the trigger's button label." },
|
|
402
|
+
closeLabel: { schema: { type: "string" }, description: "Label of the explicit close control.", synthNote: "Lifted from sheet-close." },
|
|
403
|
+
child: { schema: { $ref: "#/$defs/ComponentId" }, description: "The panel body: content minus the claimed regions, Column-wrapped when several.", synthNote: "T4 slot route from sheet-content's children." },
|
|
404
|
+
footer: { schema: { $ref: "#/$defs/ComponentId" }, description: "The action row minus the close control.", synthNote: "T4 slot route from sheet-footer's children." },
|
|
405
|
+
},
|
|
406
|
+
required: ["title"],
|
|
407
|
+
surface: {
|
|
408
|
+
routes: [
|
|
409
|
+
{ from: ["sub(sheet-title).text"], to: "prop:title" },
|
|
410
|
+
{ from: ["sub(sheet-description).text"], to: "prop:description" },
|
|
411
|
+
{ from: ["sub(sheet-trigger).label", "sub(sheet-trigger).firstText"], to: "prop:triggerLabel" },
|
|
412
|
+
{ from: ["sub(sheet-close).text"], to: "prop:closeLabel" },
|
|
413
|
+
{ from: ["sub(sheet-content).children"], to: "slot:child" },
|
|
414
|
+
{ from: ["sub(sheet-footer).children"], to: "slot:footer" },
|
|
415
|
+
],
|
|
416
|
+
subs: { "sheet-header": "transparent" },
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
popover: {
|
|
420
|
+
a2ui: "Popover",
|
|
421
|
+
dspackId: "popover",
|
|
422
|
+
commons: ["ComponentCommon"],
|
|
423
|
+
structural: {
|
|
424
|
+
title: { schema: { type: "string" }, description: "The panel's visible title.", synthNote: "Lifted from popover-title." },
|
|
425
|
+
description: { schema: { type: "string" }, description: "Supporting copy beneath the title.", synthNote: "Lifted from popover-description." },
|
|
426
|
+
triggerLabel: { schema: { type: "string" }, description: "Label of the control that toggles the popover.", synthNote: "Lifted from the trigger's button label." },
|
|
427
|
+
child: { schema: { $ref: "#/$defs/ComponentId" }, description: "The panel body beyond title and description; absent when the measured body is empty.", synthNote: "T4 slot route from popover-content's children; the worked example's body is empty after the header dissolves." },
|
|
428
|
+
},
|
|
429
|
+
required: ["triggerLabel"],
|
|
430
|
+
surface: {
|
|
431
|
+
routes: [
|
|
432
|
+
{ from: ["sub(popover-title).text"], to: "prop:title" },
|
|
433
|
+
{ from: ["sub(popover-description).text"], to: "prop:description" },
|
|
434
|
+
{ from: ["sub(popover-trigger).label", "sub(popover-trigger).firstText"], to: "prop:triggerLabel" },
|
|
435
|
+
{ from: ["sub(popover-content).children"], to: "slot:child" },
|
|
436
|
+
],
|
|
437
|
+
subs: {
|
|
438
|
+
"popover-header": "transparent",
|
|
439
|
+
"popover-anchor": { drop: "no worked example exercises it; an alternative positioning reference is presentation until measured" },
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
"dropdown-menu": {
|
|
444
|
+
a2ui: "DropdownMenu",
|
|
445
|
+
dspackId: "dropdown-menu",
|
|
446
|
+
commons: ["ComponentCommon"],
|
|
447
|
+
structural: {
|
|
448
|
+
triggerLabel: { schema: { type: "string" }, description: "Label of the element that opens the menu.", synthNote: "Lifted from the trigger's button label." },
|
|
449
|
+
menuLabel: { schema: { type: "string" }, description: "The non-interactive heading above the items.", synthNote: "Lifted from dropdown-menu-label." },
|
|
450
|
+
items: {
|
|
451
|
+
schema: { type: "array", items: { type: "object", properties: { label: { type: "string" } }, required: ["label"], additionalProperties: false } },
|
|
452
|
+
description: "The actionable menu items, in order.",
|
|
453
|
+
synthNote: "T2 item-mode collect — the menu is DATA, not slots; measurement overruled the historic T4 classification.",
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
required: ["items"],
|
|
457
|
+
surface: {
|
|
458
|
+
routes: [
|
|
459
|
+
{ from: ["sub(dropdown-menu-trigger).label", "sub(dropdown-menu-trigger).firstText"], to: "prop:triggerLabel" },
|
|
460
|
+
{ from: ["sub(dropdown-menu-label).text"], to: "prop:menuLabel" },
|
|
461
|
+
],
|
|
462
|
+
collects: [{ of: ["dropdown-menu-item"], into: "prop:items", item: { label: "self.text" } }],
|
|
463
|
+
subs: {
|
|
464
|
+
"dropdown-menu-separator": { drop: "a visual divider between item groups; grouping is not carried by the flat items shape" },
|
|
465
|
+
"dropdown-menu-group": { drop: "grouping chrome; no worked example gives it meaning beyond adjacency" },
|
|
466
|
+
"dropdown-menu-checkbox-item": { drop: "no worked example exercises it; a toggleable item is a different record shape to measure, not guess" },
|
|
467
|
+
"dropdown-menu-radio-group": { drop: "no worked example exercises it" },
|
|
468
|
+
"dropdown-menu-radio-item": { drop: "no worked example exercises it" },
|
|
469
|
+
"dropdown-menu-sub": { drop: "nested menus are unmeasured; representing them is a decision for evidence, not defaults" },
|
|
470
|
+
"dropdown-menu-sub-trigger": { drop: "belongs to the unmeasured nested-menu shape" },
|
|
471
|
+
"dropdown-menu-sub-content": { drop: "belongs to the unmeasured nested-menu shape" },
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
};
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import type { DspackDoc } from "../types.js";
|
|
23
23
|
import type { Profile } from "./profiles.js";
|
|
24
24
|
import { surfaceModelOf } from "./desugar.js";
|
|
25
|
-
import { referencedSubs, unclassifiedSubs, type SurfaceModel } from "./model.js";
|
|
25
|
+
import { describeDestination, referencedSubs, unclassifiedSubs, type Donation, type SurfaceModel } from "./model.js";
|
|
26
26
|
|
|
27
27
|
export interface ProfileContractIssue {
|
|
28
28
|
path: string;
|
|
@@ -93,11 +93,16 @@ export function validateProfileAgainstContract(profile: Profile, doc: DspackDoc)
|
|
|
93
93
|
const declaredProps = new Set(Object.keys(component.props ?? {}));
|
|
94
94
|
const model = surfaceModelOf(plan);
|
|
95
95
|
|
|
96
|
+
// A referenced name resolves against the compound's declared subs OR the
|
|
97
|
+
// contract's top-level components — a T3 join may pair a sub-family with
|
|
98
|
+
// a component family (the production radio-group joins its items to
|
|
99
|
+
// sibling `label` COMPONENTS via htmlFor), and surfaces carry both kinds
|
|
100
|
+
// of node identically.
|
|
96
101
|
for (const sub of namedSubs(model)) {
|
|
97
|
-
if (!declaredSubs.includes(sub)) {
|
|
102
|
+
if (!declaredSubs.includes(sub) && !(sub in components)) {
|
|
98
103
|
issues.push({
|
|
99
104
|
path: at,
|
|
100
|
-
message: `'${sub}' is
|
|
105
|
+
message: `'${sub}' is neither a declared sub-component of '${plan.dspackId}' nor a component of this contract (declared subs: ${declaredSubs.length ? declaredSubs.join(", ") : "none"})`,
|
|
101
106
|
});
|
|
102
107
|
}
|
|
103
108
|
}
|
|
@@ -134,5 +139,36 @@ export function validateProfileAgainstContract(profile: Profile, doc: DspackDoc)
|
|
|
134
139
|
}
|
|
135
140
|
}
|
|
136
141
|
|
|
142
|
+
// T1 donations: every donated destination must be declared by at least one
|
|
143
|
+
// mapped, NON-transparent plan — otherwise no surface could ever satisfy
|
|
144
|
+
// the exactly-one-eligible-control rule and every use would refuse at emit.
|
|
145
|
+
// Checked profile-wide (the eligible control is chosen per surface).
|
|
146
|
+
const receiverProps = new Set<string>();
|
|
147
|
+
for (const plan of [...profile.components, ...profile.synthesized]) {
|
|
148
|
+
const m = surfaceModelOf(plan);
|
|
149
|
+
if (m.transparent) continue;
|
|
150
|
+
for (const k of Object.keys(plan.structural ?? {})) receiverProps.add(k);
|
|
151
|
+
for (const p of Object.values(plan.propMap ?? {})) receiverProps.add(p.a2ui);
|
|
152
|
+
}
|
|
153
|
+
for (const [collection, plans] of collections) {
|
|
154
|
+
for (const [i, plan] of plans.entries()) {
|
|
155
|
+
const m = surfaceModelOf(plan);
|
|
156
|
+
const donations: Array<{ d: Donation; at: string }> = [
|
|
157
|
+
...m.transparentDonate.map((d) => ({ d, at: `/${collection}/${i}/surface/transparent/donate` })),
|
|
158
|
+
...Object.values(m.subIdentity).flatMap((id) =>
|
|
159
|
+
id.kind === "transparent" && id.donate ? id.donate.map((d) => ({ d, at: `/${collection}/${i}/surface/subs` })) : [],
|
|
160
|
+
),
|
|
161
|
+
];
|
|
162
|
+
for (const { d, at } of donations) {
|
|
163
|
+
if (!receiverProps.has(d.to.name)) {
|
|
164
|
+
issues.push({
|
|
165
|
+
path: at,
|
|
166
|
+
message: `donation writes ${describeDestination(d.to)}, but no mapped non-transparent plan declares '${d.to.name}' — no surface could ever satisfy it`,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
137
173
|
if (issues.length > 0) throw new ProfileContractError(issues);
|
|
138
174
|
}
|
package/src/types.ts
CHANGED
|
@@ -124,7 +124,19 @@ export interface SurfaceFidelityEntry {
|
|
|
124
124
|
/** The profile rule that caused it (route/collect origin, propMap key, or synthesis). */
|
|
125
125
|
origin: string;
|
|
126
126
|
/** What happened to the content. */
|
|
127
|
-
kind:
|
|
127
|
+
kind:
|
|
128
|
+
| "projected"
|
|
129
|
+
| "moved"
|
|
130
|
+
| "lifted"
|
|
131
|
+
| "flattened"
|
|
132
|
+
| "synthesized"
|
|
133
|
+
| "wrapped"
|
|
134
|
+
| "dropped"
|
|
135
|
+
| "deduplicated"
|
|
136
|
+
/** T1: a value harvested in a dissolving boundary, written onto its single eligible control. */
|
|
137
|
+
| "donated"
|
|
138
|
+
/** T3: a counterpart's data merged into a collected record via a declared key join. */
|
|
139
|
+
| "joined";
|
|
128
140
|
class: FidelityClass;
|
|
129
141
|
note?: string;
|
|
130
142
|
}
|
package/src/validate/ajv.ts
CHANGED
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
* a2ui-catalog.meta.<ver>.json (the literal "catalog schema" check; this is what
|
|
13
13
|
* makes v0.9.1 vs v1.0 conformance distinct — theme vs surfaceProperties).
|
|
14
14
|
* 3. instance: every component instance in the hand-authored surface validates
|
|
15
|
-
* against the catalog's own #/$defs/anyComponent
|
|
15
|
+
* against the catalog's own #/$defs/anyComponent — checked by manual
|
|
16
|
+
* discrimination (each instance against its own #/components/<name>
|
|
17
|
+
* branch), which is semantically equivalent and keeps every reported
|
|
18
|
+
* error inside the instance's own branch. See the gate 3 body.
|
|
16
19
|
*/
|
|
17
20
|
import Ajv2020 from "ajv/dist/2020.js";
|
|
18
21
|
import addFormats from "ajv-formats";
|
|
@@ -24,6 +27,25 @@ export interface GateResult {
|
|
|
24
27
|
pass: boolean;
|
|
25
28
|
detail: string;
|
|
26
29
|
errors?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Structured per-instance evidence for gate 3 failures (advanced channel
|
|
32
|
+
* for downstream UIs). The strings in `errors` remain the primary
|
|
33
|
+
* user-facing form; this preserves ajv's keyword/params/schemaPath, which
|
|
34
|
+
* the strings deliberately compress.
|
|
35
|
+
*/
|
|
36
|
+
errorDetails?: Array<{
|
|
37
|
+
/** `component#id` — same prefix the string form carries. */
|
|
38
|
+
instance: string;
|
|
39
|
+
component: string;
|
|
40
|
+
id: string;
|
|
41
|
+
errors: Array<{
|
|
42
|
+
instancePath?: string;
|
|
43
|
+
schemaPath?: string;
|
|
44
|
+
keyword?: string;
|
|
45
|
+
params?: unknown;
|
|
46
|
+
message?: string;
|
|
47
|
+
}>;
|
|
48
|
+
}>;
|
|
27
49
|
}
|
|
28
50
|
|
|
29
51
|
export interface ValidationReport {
|
|
@@ -171,20 +193,64 @@ export function validateCatalog(
|
|
|
171
193
|
// Belt and braces: gate 1 has already proven every ref resolves, but a
|
|
172
194
|
// raw ajv throw must never escape this function regardless.
|
|
173
195
|
const failures: string[] = [];
|
|
196
|
+
const errorDetails: NonNullable<GateResult["errorDetails"]> = [];
|
|
174
197
|
let instances: Json[] = [];
|
|
175
198
|
try {
|
|
176
199
|
const ajv = newAjv();
|
|
177
200
|
ajv.addSchema(catalog as unknown as Json, catalog.$id);
|
|
178
|
-
const validateAny = ajv.getSchema(`${catalog.$id}#/$defs/anyComponent`);
|
|
179
201
|
instances = extractInstances(surface);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
202
|
+
// Manual discrimination instead of the flat `#/$defs/anyComponent`
|
|
203
|
+
// oneOf. Semantically equivalent: every branch of the emitted
|
|
204
|
+
// anyComponent is `{$ref: "#/components/<name>"}` and each component
|
|
205
|
+
// schema pins `component: {const: <name>}` inside its allOf (and
|
|
206
|
+
// requires it), so an instance tagged component X can only ever match
|
|
207
|
+
// branch X — validating the instance against ITS OWN branch accepts
|
|
208
|
+
// and rejects exactly the same instances the oneOf does. What changes
|
|
209
|
+
// is the report: allErrors WITHIN the matching branch (rigor
|
|
210
|
+
// preserved, every genuine error surfaced) without echoing every
|
|
211
|
+
// other branch's const/required/unevaluatedProperties noise.
|
|
212
|
+
const admitted = Object.keys(catalog.components ?? {});
|
|
213
|
+
for (const inst of instances) {
|
|
214
|
+
const comp = String(inst.component);
|
|
215
|
+
const id = String(inst.id);
|
|
216
|
+
const where = `${comp}#${id}`;
|
|
217
|
+
if (!admitted.includes(comp)) {
|
|
218
|
+
failures.push(
|
|
219
|
+
`${where}: component '${comp}' is not in this catalog (${admitted.length} components admitted)`,
|
|
220
|
+
);
|
|
221
|
+
errorDetails.push({
|
|
222
|
+
instance: where,
|
|
223
|
+
component: comp,
|
|
224
|
+
id,
|
|
225
|
+
errors: [
|
|
226
|
+
{
|
|
227
|
+
message: `component '${comp}' is not in this catalog`,
|
|
228
|
+
params: { admittedComponents: admitted },
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
});
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const validateBranch = ajv.getSchema(`${catalog.$id}#/components/${comp}`);
|
|
235
|
+
if (!validateBranch) {
|
|
236
|
+
failures.push(`${where}: could not resolve #/components/${comp} from the catalog.`);
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (!validateBranch(inst)) {
|
|
240
|
+
const errs = validateBranch.errors ?? [];
|
|
241
|
+
for (const e of errs) failures.push(`${where}: ${fmtErr(e)}`);
|
|
242
|
+
errorDetails.push({
|
|
243
|
+
instance: where,
|
|
244
|
+
component: comp,
|
|
245
|
+
id,
|
|
246
|
+
errors: errs.map((e) => ({
|
|
247
|
+
instancePath: e.instancePath,
|
|
248
|
+
schemaPath: e.schemaPath,
|
|
249
|
+
keyword: e.keyword,
|
|
250
|
+
params: e.params as unknown,
|
|
251
|
+
message: e.message,
|
|
252
|
+
})),
|
|
253
|
+
});
|
|
188
254
|
}
|
|
189
255
|
}
|
|
190
256
|
} catch (e) {
|
|
@@ -198,6 +264,7 @@ export function validateCatalog(
|
|
|
198
264
|
? `All ${instances.length} surface component instance(s) validate against #/$defs/anyComponent.`
|
|
199
265
|
: `${failures.length} instance validation error(s).`,
|
|
200
266
|
errors: failures.length ? failures : undefined,
|
|
267
|
+
...(errorDetails.length ? { errorDetails } : {}),
|
|
201
268
|
});
|
|
202
269
|
}
|
|
203
270
|
}
|
|
@@ -205,6 +272,23 @@ export function validateCatalog(
|
|
|
205
272
|
return { version, pass: gates.every((g) => g.pass), gates };
|
|
206
273
|
}
|
|
207
274
|
|
|
208
|
-
|
|
209
|
-
|
|
275
|
+
/**
|
|
276
|
+
* One ajv error as a user-facing line: instancePath + message, enriched from
|
|
277
|
+
* the error's params where they carry the actionable detail ajv's message
|
|
278
|
+
* omits — the allowed enum values, the expected const, or the name of the
|
|
279
|
+
* offending unevaluated/additional property.
|
|
280
|
+
*/
|
|
281
|
+
function fmtErr(e: { instancePath?: string; keyword?: string; params?: unknown; message?: string }): string {
|
|
282
|
+
const params = (e.params ?? {}) as Record<string, unknown>;
|
|
283
|
+
let out = `${e.instancePath || "(root)"} ${e.message ?? ""}`.trim();
|
|
284
|
+
if (e.keyword === "enum" && Array.isArray(params.allowedValues)) {
|
|
285
|
+
out += ` (allowed: ${(params.allowedValues as unknown[]).map((v) => String(v)).join(", ")})`;
|
|
286
|
+
} else if (e.keyword === "const" && "allowedValue" in params) {
|
|
287
|
+
out += ` (expected: ${JSON.stringify(params.allowedValue)})`;
|
|
288
|
+
} else if (e.keyword === "unevaluatedProperties" && typeof params.unevaluatedProperty === "string") {
|
|
289
|
+
out += ` ('${params.unevaluatedProperty}')`;
|
|
290
|
+
} else if (e.keyword === "additionalProperties" && typeof params.additionalProperty === "string") {
|
|
291
|
+
out += ` ('${params.additionalProperty}')`;
|
|
292
|
+
}
|
|
293
|
+
return out;
|
|
210
294
|
}
|
package/src/validate-v2.test.ts
CHANGED
|
@@ -102,7 +102,7 @@ describe("v2 contract validation refuses before emission", () => {
|
|
|
102
102
|
...RESOLVED,
|
|
103
103
|
subs: { ...RESOLVED.subs, "card-sidebar": "transparent" },
|
|
104
104
|
});
|
|
105
|
-
expect(out).toContain("'card-sidebar' is
|
|
105
|
+
expect(out).toContain("'card-sidebar' is neither a declared sub-component of 'card' nor a component");
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
it("reading an undeclared prop into a renamed destination refuses; the passthrough shape passes", () => {
|