@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,49 @@
1
+ export const SHADCN_V2_SURFACES = {
2
+ button: {
3
+ routes: [
4
+ { from: ["self.text"], to: "textChild:child", overwrite: true },
5
+ { from: ["synthesized.action"], to: "action:action" },
6
+ ],
7
+ },
8
+ card: {
9
+ routes: [{ from: ["children"], to: "slot:child" }],
10
+ subs: {
11
+ "card-header": "transparent",
12
+ "card-content": "transparent",
13
+ "card-footer": "transparent",
14
+ "card-title": { asText: "h3" },
15
+ "card-description": { asText: "caption" },
16
+ },
17
+ },
18
+ input: {
19
+ routes: [{ from: ["self.text"], to: "prop:label", overwrite: true }],
20
+ },
21
+ badge: {
22
+ routes: [{ from: ["self.text"], to: "prop:label", overwrite: true }],
23
+ },
24
+ table: {
25
+ routes: [
26
+ { from: ["self.props.caption"], to: "prop:caption" },
27
+ { from: ["self.props.columns"], to: "prop:columns" },
28
+ { from: ["self.props.rows"], to: "prop:rows" },
29
+ { from: ["sub(table-caption).subtreeText"], to: "prop:caption" },
30
+ ],
31
+ collects: [
32
+ { of: ["table-header"], into: "prop:columns", shape: "flat", row: ["table-row"], cells: ["table-cell", "table-head"] },
33
+ { of: ["table-body"], into: "prop:rows", shape: "records", field: "cells", row: ["table-row"], cells: ["table-cell", "table-head"] },
34
+ ],
35
+ subs: {
36
+ "table-footer": { drop: "summary rows have no slot in the synthesized caption/columns/rows shape" },
37
+ },
38
+ },
39
+ "alert-dialog": {
40
+ routes: [
41
+ { from: ["sub(alert-dialog-title).text"], to: "prop:title" },
42
+ { from: ["sub(alert-dialog-description).text"], to: "prop:description" },
43
+ { from: ["sub(alert-dialog-cancel).text"], to: "prop:cancelLabel" },
44
+ { from: ["sub(alert-dialog-action).text"], to: "prop:confirmLabel" },
45
+ { from: ["sub(alert-dialog-trigger).label", "sub(alert-dialog-trigger).firstText"], to: "prop:triggerLabel" },
46
+ { from: ["synthesized.action"], to: "action:action" },
47
+ ],
48
+ },
49
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Contract-facing validation for v2 profiles.
3
+ *
4
+ * parse-v2.ts checks everything a plan can be wrong about ON ITS OWN — grammar
5
+ * closure, declared destinations, write conflicts. This module checks what a
6
+ * plan can only be wrong about AGAINST A CONTRACT, and it runs at every entry
7
+ * that has one in hand (transform, emitSurface), before any emission:
8
+ *
9
+ * - every `sub(x)` a route, collect, or disposition names must be a declared
10
+ * sub-component of the plan's contract component;
11
+ * - every `self.props.X` must be declared — by the contract as an ordinary
12
+ * prop, or by the plan's own structural block as a same-named passthrough;
13
+ * - derived sub-component coverage must be COMPLETE: every declared sub is
14
+ * routed, collected, absorbed, transparent, re-identified, or explicitly
15
+ * dropped — anything else is an unresolved authoring decision, and v2
16
+ * fails closed on it with a finding per sub.
17
+ *
18
+ * v1 is deliberately not gated here: its behaviour is frozen, and its
19
+ * coverage story stays report-plus-`--strict-coverage`. The split is the
20
+ * compatibility policy in one sentence — v2 refuses what v1 merely reports.
21
+ */
22
+ import type { DspackDoc } from "../types.js";
23
+ import type { Profile } from "./profiles.js";
24
+ export interface ProfileContractIssue {
25
+ path: string;
26
+ message: string;
27
+ }
28
+ export declare class ProfileContractError extends Error {
29
+ readonly issues: ProfileContractIssue[];
30
+ constructor(issues: ProfileContractIssue[]);
31
+ }
32
+ /**
33
+ * Validate a v2 profile against the contract it is about to project. A no-op
34
+ * for v1 profiles (language undefined): their behaviour is frozen.
35
+ */
36
+ export declare function validateProfileAgainstContract(profile: Profile, doc: DspackDoc): void;
@@ -0,0 +1,100 @@
1
+ import { surfaceModelOf } from "./desugar.js";
2
+ import { referencedSubs, unclassifiedSubs } from "./model.js";
3
+ export class ProfileContractError extends Error {
4
+ issues;
5
+ constructor(issues) {
6
+ super(`profile does not fit this contract (${issues.length} issue${issues.length === 1 ? "" : "s"}): ` +
7
+ issues
8
+ .slice(0, 3)
9
+ .map((i) => `${i.path || "$"}: ${i.message}`)
10
+ .join("; ") +
11
+ (issues.length > 3 ? "; …" : ""));
12
+ this.issues = issues;
13
+ this.name = "ProfileContractError";
14
+ }
15
+ }
16
+ /** Every sub-component id a model's selectors, collects, and subs name. */
17
+ function namedSubs(model) {
18
+ const out = new Set(referencedSubs(model).keys());
19
+ return out;
20
+ }
21
+ /** Every `self.props.X` a model reads, with the destination reading it. */
22
+ function namedSelfProps(model) {
23
+ const out = [];
24
+ for (const r of model.routes) {
25
+ for (const s of r.from)
26
+ if (s.kind === "self-prop")
27
+ out.push({ prop: s.prop, to: r.to.name });
28
+ }
29
+ return out;
30
+ }
31
+ /**
32
+ * Validate a v2 profile against the contract it is about to project. A no-op
33
+ * for v1 profiles (language undefined): their behaviour is frozen.
34
+ */
35
+ export function validateProfileAgainstContract(profile, doc) {
36
+ if (profile.language !== "v2")
37
+ return;
38
+ const issues = [];
39
+ const components = (doc.components ?? {});
40
+ // Both collections: mapping.ts counts any synthesized plan with a dspackId
41
+ // as mapped, so the gate must see exactly what the mapper sees. And a plan
42
+ // with NO surface block validates against the empty model — for a compound,
43
+ // that means every declared sub is unresolved and refuses, identically to
44
+ // `surface: {}`. Presence of an empty key must never flip the gate.
45
+ const collections = [
46
+ ["components", profile.components],
47
+ ["synthesized", profile.synthesized],
48
+ ];
49
+ for (const [collection, plans] of collections) {
50
+ for (const [i, plan] of plans.entries()) {
51
+ if (!plan.dspackId)
52
+ continue;
53
+ const at = `/${collection}/${i}/surface`;
54
+ const component = components[plan.dspackId];
55
+ if (!component)
56
+ continue; // mapping.ts already warns on unknown dspackIds
57
+ const declaredSubs = (component.composition?.subComponents ?? []).map((s) => s.id);
58
+ const declaredProps = new Set(Object.keys(component.props ?? {}));
59
+ const model = surfaceModelOf(plan);
60
+ for (const sub of namedSubs(model)) {
61
+ if (!declaredSubs.includes(sub)) {
62
+ issues.push({
63
+ path: at,
64
+ message: `'${sub}' is not a declared sub-component of '${plan.dspackId}' in this contract (declared: ${declaredSubs.length ? declaredSubs.join(", ") : "none"})`,
65
+ });
66
+ }
67
+ }
68
+ // A self-prop read is declared either by the CONTRACT (an ordinary prop)
69
+ // or by the PLAN's own structural block when source and destination share
70
+ // its name — the passthrough shape, where an A2UI structural slot may be
71
+ // authored directly on the surface node (v1's structuralPassthrough, and
72
+ // the reason the Table's caption/columns/rows are legal without the
73
+ // contract declaring them). Reading an undeclared prop into a
74
+ // DIFFERENTLY-named destination declares nothing anywhere, and refuses.
75
+ for (const { prop, to } of namedSelfProps(model)) {
76
+ const contractDeclared = declaredProps.has(prop);
77
+ const passthroughShaped = to === prop && prop in (plan.structural ?? {});
78
+ if (!contractDeclared && !passthroughShaped) {
79
+ issues.push({
80
+ path: at,
81
+ message: `self.props.${prop} reads a prop '${plan.dspackId}' does not declare in this contract, and it is not a same-named structural passthrough`,
82
+ });
83
+ }
84
+ }
85
+ // Derived coverage, enforced. The measured gates behind making this fatal:
86
+ // pinned shadcn v2.3.0, astryx and acme all derive zero-unresolved, and
87
+ // the production v3 pair's single finding (radio-group -> radio-group-item)
88
+ // is the known T2 gap — see scripts/sub-coverage-report.mjs and the
89
+ // 2aac076 measurement record.
90
+ for (const sub of unclassifiedSubs(model, declaredSubs)) {
91
+ issues.push({
92
+ path: at,
93
+ message: `sub-component '${sub}' of '${plan.dspackId}' is unresolved: no route consumes it, no collect gathers it, no disposition dissolves or drops it. Decide it — route, collect, transparent, asText, or drop with a reason.`,
94
+ });
95
+ }
96
+ }
97
+ }
98
+ if (issues.length > 0)
99
+ throw new ProfileContractError(issues);
100
+ }
package/dist/types.d.ts CHANGED
@@ -84,6 +84,25 @@ export interface A2uiCatalog extends Json {
84
84
  $defs: Record<string, Json>;
85
85
  }
86
86
  export type A2uiVersion = "0.9.1" | "1.0";
87
+ /**
88
+ * What one surface transformation DID — the per-emission ledger, distinct
89
+ * from the catalog-level FidelityEntry below (which describes what a profile
90
+ * can carry in principle; this describes what one surface actually lost or
91
+ * gained). Additive channel: messages and warnings are byte-frozen for v1,
92
+ * so fidelity rides alongside them on EmitSurfaceResult, never inside them.
93
+ */
94
+ export interface SurfaceFidelityEntry {
95
+ /** Where in the surface the content came from (JSON path, plus selector). */
96
+ source: string;
97
+ /** Where on the emitted instance it landed, or "(discarded)". */
98
+ destination: string;
99
+ /** The profile rule that caused it (route/collect origin, propMap key, or synthesis). */
100
+ origin: string;
101
+ /** What happened to the content. */
102
+ kind: "projected" | "moved" | "lifted" | "flattened" | "synthesized" | "wrapped" | "dropped" | "deduplicated";
103
+ class: FidelityClass;
104
+ note?: string;
105
+ }
87
106
  export type FidelityClass = "maps-cleanly" | "synthesis-defaults" | "lossy" | "cannot-represent";
88
107
  export interface FidelityEntry {
89
108
  source: string;
@@ -3,20 +3,20 @@
3
3
  * approach A2UI uses in specification/scripts/validate.py
4
4
  * (draft 2020-12, strict:false, ajv-formats):
5
5
  *
6
- * 1. schema-compile + no-external-ref: ajv compiles the catalog AS a JSON Schema.
7
- * Compilation fails on any unresolved `$ref`, proving the catalog is a valid,
8
- * fully self-contained schema with zero external references.
6
+ * 1. schema-compile + no-external-ref: ajv compiles the catalog AS a JSON
7
+ * Schema, no `$ref` points outside it, and — because ajv defers ref
8
+ * resolution past compile() — every internal `$ref` is resolved by this
9
+ * gate itself, so a dangling pointer is a pathed finding here rather than
10
+ * a silent pass or a raw MissingRefError out of gate 3.
9
11
  * 2. catalog-shape: the catalog validates against the version-specific
10
12
  * a2ui-catalog.meta.<ver>.json (the literal "catalog schema" check; this is what
11
13
  * makes v0.9.1 vs v1.0 conformance distinct — theme vs surfaceProperties).
12
14
  * 3. instance: every component instance in the hand-authored surface validates
13
15
  * against the catalog's own #/$defs/anyComponent.
14
16
  */
15
- import { readFileSync } from "node:fs";
16
- import { fileURLToPath } from "node:url";
17
17
  import Ajv2020 from "ajv/dist/2020.js";
18
18
  import addFormats from "ajv-formats";
19
- const metaPath = (ver) => fileURLToPath(new URL(`./meta/a2ui-catalog.meta.${ver === "0.9.1" ? "0_9_1" : "1_0"}.json`, import.meta.url));
19
+ import { catalogMetaSchemas } from "./meta/catalog-meta.js";
20
20
  function newAjv() {
21
21
  const ajv = new Ajv2020({ strict: false, allErrors: true, validateFormats: true });
22
22
  addFormats(ajv);
@@ -38,6 +38,61 @@ function externalRefs(node, acc = []) {
38
38
  }
39
39
  return acc;
40
40
  }
41
+ /**
42
+ * Collect every INTERNAL `$ref` that does not resolve inside the catalog
43
+ * document, with the JSON path of the offending `$ref` keyword.
44
+ *
45
+ * This is what makes gate 1's documented guarantee true. ajv defers ref
46
+ * resolution past `compile()`, so a structural slot schema (or any other
47
+ * authored-schema channel) carrying `{$ref: "#/$defs/DoesNotExist"}` used to
48
+ * produce either all-gates-PASS (no instances checked) or a raw
49
+ * MissingRefError thrown out of gate 3 — pass-or-crash, never a finding.
50
+ * Resolving the pointers ourselves turns the whole class into a pathed gate
51
+ * failure at one boundary, for every channel at once.
52
+ */
53
+ function danglingInternalRefs(root) {
54
+ const bad = [];
55
+ const resolves = (pointer) => {
56
+ if (pointer === "#" || pointer === "#/")
57
+ return true;
58
+ if (!pointer.startsWith("#/"))
59
+ return false; // #foo anchors are not used in our catalogs
60
+ let node = root;
61
+ for (const raw of pointer.slice(2).split("/")) {
62
+ const key = decodeURIComponent(raw).replaceAll("~1", "/").replaceAll("~0", "~");
63
+ if (Array.isArray(node)) {
64
+ const i = Number(key);
65
+ if (!Number.isInteger(i) || i < 0 || i >= node.length)
66
+ return false;
67
+ node = node[i];
68
+ }
69
+ else if (node && typeof node === "object" && key in node) {
70
+ node = node[key];
71
+ }
72
+ else {
73
+ return false;
74
+ }
75
+ }
76
+ return true;
77
+ };
78
+ const walk = (node, at) => {
79
+ if (Array.isArray(node)) {
80
+ node.forEach((n, i) => walk(n, `${at}/${i}`));
81
+ }
82
+ else if (node && typeof node === "object") {
83
+ for (const [k, v] of Object.entries(node)) {
84
+ if (k === "$ref" && typeof v === "string" && v.startsWith("#") && !resolves(v)) {
85
+ bad.push(`${at}/$ref: '${v}' does not resolve inside this catalog`);
86
+ }
87
+ else {
88
+ walk(v, `${at}/${k}`);
89
+ }
90
+ }
91
+ }
92
+ };
93
+ walk(root, "");
94
+ return bad;
95
+ }
41
96
  /** Pull every component instance (object with string `component` + `id`) from a surface. */
42
97
  export function extractInstances(surface, acc = []) {
43
98
  if (Array.isArray(surface)) {
@@ -55,8 +110,9 @@ export function extractInstances(surface, acc = []) {
55
110
  }
56
111
  export function validateCatalog(catalog, version, surface) {
57
112
  const gates = [];
58
- // Gate 1 — schema compile + no external $ref.
113
+ // Gate 1 — schema compile + no external $ref + every internal $ref resolves.
59
114
  const exts = externalRefs(catalog);
115
+ const dangling = danglingInternalRefs(catalog);
60
116
  let compiled = false;
61
117
  let compileErr = "";
62
118
  try {
@@ -66,18 +122,21 @@ export function validateCatalog(catalog, version, surface) {
66
122
  catch (e) {
67
123
  compileErr = e instanceof Error ? e.message : String(e);
68
124
  }
125
+ const selfContained = compiled && exts.length === 0 && dangling.length === 0;
69
126
  gates.push({
70
127
  name: "schema-compile + no-external-ref",
71
- pass: compiled && exts.length === 0,
72
- detail: compiled && exts.length === 0
73
- ? "Catalog compiles as a draft-2020-12 JSON Schema with only internal $refs."
128
+ pass: selfContained,
129
+ detail: selfContained
130
+ ? "Catalog compiles as a draft-2020-12 JSON Schema; every $ref is internal and resolves."
74
131
  : !compiled
75
132
  ? `ajv failed to compile the catalog as a schema: ${compileErr}`
76
- : `Catalog contains external $refs: ${[...new Set(exts)].join(", ")}`,
77
- errors: exts.length ? [...new Set(exts)] : undefined,
133
+ : exts.length
134
+ ? `Catalog contains external $refs: ${[...new Set(exts)].join(", ")}`
135
+ : `Catalog is not self-contained: ${dangling.length} internal $ref(s) do not resolve.`,
136
+ errors: exts.length ? [...new Set(exts)] : dangling.length ? dangling : undefined,
78
137
  });
79
138
  // Gate 2 — catalog shape.
80
- const meta = JSON.parse(readFileSync(metaPath(version), "utf8"));
139
+ const meta = catalogMetaSchemas[version];
81
140
  const validateShape = newAjv().compile(meta);
82
141
  const shapeOk = validateShape(catalog);
83
142
  gates.push({
@@ -88,33 +147,43 @@ export function validateCatalog(catalog, version, surface) {
88
147
  : `Catalog violates the v${version} catalog-shape meta-schema.`,
89
148
  errors: shapeOk ? undefined : (validateShape.errors ?? []).map(fmtErr),
90
149
  });
91
- // Gate 3 — instances (only if compilable and a surface was supplied).
150
+ // Gate 3 — instances (only if the catalog is usable and a surface was supplied).
92
151
  if (surface !== undefined) {
93
- if (!compiled) {
152
+ if (!compiled || dangling.length > 0) {
94
153
  gates.push({
95
154
  name: "instance",
96
155
  pass: false,
97
- detail: "Skipped: catalog did not compile, so instances cannot be checked.",
156
+ detail: !compiled
157
+ ? "Skipped: catalog did not compile, so instances cannot be checked."
158
+ : "Skipped: catalog is not self-contained (gate 1 lists the dangling $refs), so instances cannot be checked.",
98
159
  });
99
160
  }
100
161
  else {
101
- const ajv = newAjv();
102
- ajv.addSchema(catalog, catalog.$id);
103
- const validateAny = ajv.getSchema(`${catalog.$id}#/$defs/anyComponent`);
104
- const instances = extractInstances(surface);
162
+ // Belt and braces: gate 1 has already proven every ref resolves, but a
163
+ // raw ajv throw must never escape this function regardless.
105
164
  const failures = [];
106
- if (!validateAny) {
107
- failures.push("Could not resolve #/$defs/anyComponent from the catalog.");
108
- }
109
- else {
110
- for (const inst of instances) {
111
- if (!validateAny(inst)) {
112
- const where = `${inst.component}#${inst.id}`;
113
- for (const e of validateAny.errors ?? [])
114
- failures.push(`${where}: ${fmtErr(e)}`);
165
+ let instances = [];
166
+ try {
167
+ const ajv = newAjv();
168
+ ajv.addSchema(catalog, catalog.$id);
169
+ const validateAny = ajv.getSchema(`${catalog.$id}#/$defs/anyComponent`);
170
+ instances = extractInstances(surface);
171
+ if (!validateAny) {
172
+ failures.push("Could not resolve #/$defs/anyComponent from the catalog.");
173
+ }
174
+ else {
175
+ for (const inst of instances) {
176
+ if (!validateAny(inst)) {
177
+ const where = `${inst.component}#${inst.id}`;
178
+ for (const e of validateAny.errors ?? [])
179
+ failures.push(`${where}: ${fmtErr(e)}`);
180
+ }
115
181
  }
116
182
  }
117
183
  }
184
+ catch (e) {
185
+ failures.push(`instance validation could not run: ${e instanceof Error ? e.message : String(e)}`);
186
+ }
118
187
  gates.push({
119
188
  name: "instance",
120
189
  pass: failures.length === 0,
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Runtime mirrors of the catalog-shape meta-schemas. The .json files beside
3
+ * this module stay the reviewable documents (README points reviewers at
4
+ * src/validate/meta/); these constants exist because validateCatalog must run
5
+ * in a browser bundle (dspack-studio composer), where readFileSync is not
6
+ * available. src/schema-mirrors.test.ts asserts mirror and JSON stay
7
+ * identical — edit both together.
8
+ */
9
+ import type { A2uiVersion, Json } from "../../types.js";
10
+ export declare const catalogMetaSchemas: Record<A2uiVersion, Json>;
@@ -0,0 +1,157 @@
1
+ export const catalogMetaSchemas = {
2
+ "0.9.1": {
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "$id": "https://rdombrowski.dev/meta/a2ui-catalog.v0_9_1.json",
5
+ "title": "A2UI catalog shape (v0.9.1)",
6
+ "description": "Structural invariants an A2UI v0.9.1 catalog must satisfy, derived from the checked-in basic catalog fixture. The version-distinguishing requirement is $defs.theme (with primaryColor).",
7
+ "type": "object",
8
+ "required": [
9
+ "$schema",
10
+ "$id",
11
+ "catalogId",
12
+ "title",
13
+ "description",
14
+ "components",
15
+ "$defs"
16
+ ],
17
+ "properties": {
18
+ "catalogId": {
19
+ "type": "string",
20
+ "format": "uri"
21
+ },
22
+ "$id": {
23
+ "type": "string",
24
+ "format": "uri"
25
+ },
26
+ "components": {
27
+ "type": "object",
28
+ "minProperties": 1,
29
+ "additionalProperties": {
30
+ "type": "object",
31
+ "required": [
32
+ "allOf",
33
+ "unevaluatedProperties"
34
+ ],
35
+ "properties": {
36
+ "allOf": {
37
+ "type": "array",
38
+ "minItems": 1
39
+ },
40
+ "unevaluatedProperties": {
41
+ "const": false
42
+ }
43
+ }
44
+ }
45
+ },
46
+ "$defs": {
47
+ "type": "object",
48
+ "required": [
49
+ "anyComponent",
50
+ "theme"
51
+ ],
52
+ "not": {
53
+ "required": [
54
+ "surfaceProperties"
55
+ ]
56
+ },
57
+ "properties": {
58
+ "anyComponent": {
59
+ "type": "object",
60
+ "required": [
61
+ "oneOf"
62
+ ]
63
+ },
64
+ "theme": {
65
+ "type": "object",
66
+ "required": [
67
+ "properties"
68
+ ],
69
+ "properties": {
70
+ "properties": {
71
+ "type": "object",
72
+ "required": [
73
+ "primaryColor"
74
+ ]
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ },
82
+ "1.0": {
83
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
84
+ "$id": "https://rdombrowski.dev/meta/a2ui-catalog.v1_0.json",
85
+ "title": "A2UI catalog shape (v1.0)",
86
+ "description": "Structural invariants an A2UI v1.0 catalog must satisfy, derived from the checked-in basic catalog fixture. The version-distinguishing requirement is $defs.surfaceProperties (and the absence of $defs.theme).",
87
+ "type": "object",
88
+ "required": [
89
+ "$schema",
90
+ "$id",
91
+ "catalogId",
92
+ "title",
93
+ "description",
94
+ "components",
95
+ "$defs"
96
+ ],
97
+ "properties": {
98
+ "catalogId": {
99
+ "type": "string",
100
+ "format": "uri"
101
+ },
102
+ "$id": {
103
+ "type": "string",
104
+ "format": "uri"
105
+ },
106
+ "instructions": {
107
+ "type": "string"
108
+ },
109
+ "components": {
110
+ "type": "object",
111
+ "minProperties": 1,
112
+ "additionalProperties": {
113
+ "type": "object",
114
+ "required": [
115
+ "allOf",
116
+ "unevaluatedProperties"
117
+ ],
118
+ "properties": {
119
+ "allOf": {
120
+ "type": "array",
121
+ "minItems": 1
122
+ },
123
+ "unevaluatedProperties": {
124
+ "const": false
125
+ }
126
+ }
127
+ }
128
+ },
129
+ "$defs": {
130
+ "type": "object",
131
+ "required": [
132
+ "anyComponent",
133
+ "surfaceProperties"
134
+ ],
135
+ "not": {
136
+ "required": [
137
+ "theme"
138
+ ]
139
+ },
140
+ "properties": {
141
+ "anyComponent": {
142
+ "type": "object",
143
+ "required": [
144
+ "oneOf"
145
+ ]
146
+ },
147
+ "surfaceProperties": {
148
+ "type": "object",
149
+ "required": [
150
+ "properties"
151
+ ]
152
+ }
153
+ }
154
+ }
155
+ }
156
+ },
157
+ };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@aestheticfunction/dspack-emit",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
- "description": "dspack emitters: compile a dspack design-system contract and dspack surfaces into protocol targets — an A2UI catalog + surface messages (gates A1-A3) and json-render catalog/registry modules + specs (gates J1-J3).",
5
+ "description": "dspack emitters: compile a dspack design-system contract and dspack surfaces into protocol targets \u2014 an A2UI catalog + surface messages (gates A1-A3) and json-render catalog/registry modules + specs (gates J1-J3).",
6
6
  "license": "Apache-2.0",
7
7
  "exports": {
8
8
  ".": {
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "scripts": {
20
20
  "transform": "tsx src/cli.ts",
21
- "build": "tsc -p tsconfig.json && mkdir -p dist/validate/meta && cp src/validate/meta/*.json dist/validate/meta/ && cp src/transform/profile.v1.schema.json dist/transform/",
21
+ "build": "tsc -p tsconfig.json",
22
22
  "prepare": "npm run build",
23
23
  "build:catalogs": "tsx src/cli.ts --in input/shadcn-ui.dspack.json --a2ui-version 0.9.1 --out out && tsx src/cli.ts --in input/shadcn-ui.dspack.json --a2ui-version 1.0 --out out",
24
24
  "test": "vitest run",
@@ -0,0 +1,66 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`every v1 surface-plan directive is byte-pinned > childProp with >1 children (synthesized Column wrap) 1`] = `
4
+ {
5
+ "messages": "8b8cab6d6a82a062",
6
+ "warnings": "e7ecf1c3b9ae9c67",
7
+ }
8
+ `;
9
+
10
+ exports[`every v1 surface-plan directive is byte-pinned > id deduplication (two nodes claiming one id) 1`] = `
11
+ {
12
+ "messages": "84c3037cea1b345f",
13
+ "warnings": "2388dab748ca28c0",
14
+ }
15
+ `;
16
+
17
+ exports[`every v1 surface-plan directive is byte-pinned > subFlatten.transparent + asText (card sub-family) 1`] = `
18
+ {
19
+ "messages": "21c9f2503a3c6804",
20
+ "warnings": "9a339e10a151128b",
21
+ }
22
+ `;
23
+
24
+ exports[`every v1 surface-plan directive is byte-pinned > subTable (table sub-family, header + body + caption) 1`] = `
25
+ {
26
+ "messages": "de1e3b6ace2afe42",
27
+ "warnings": "ac28b69e6cc4143b",
28
+ }
29
+ `;
30
+
31
+ exports[`every v1 surface-plan directive is byte-pinned > subText + subButtonText + actionProp (alert-dialog) 1`] = `
32
+ {
33
+ "messages": "d8a53f6c7f146d20",
34
+ "warnings": "374a173b5dac258b",
35
+ }
36
+ `;
37
+
38
+ exports[`every v1 surface-plan directive is byte-pinned > textChildProp + actionProp (button) 1`] = `
39
+ {
40
+ "messages": "d9112d8d356f5490",
41
+ "warnings": "9100e3b4d5c37463",
42
+ }
43
+ `;
44
+
45
+ exports[`every v1 surface-plan directive is byte-pinned > textProp (input, badge) 1`] = `
46
+ {
47
+ "messages": "198c8534091323c8",
48
+ "warnings": "3268fc387e176c20",
49
+ }
50
+ `;
51
+
52
+ exports[`surface emission is byte-stable > ex.delete-account-confirmation — messages and warnings 1`] = `
53
+ {
54
+ "id": "ex.delete-account-confirmation",
55
+ "messages": "f56b32c2b3b41df5",
56
+ "warnings": "fe908f24a7685bc7",
57
+ }
58
+ `;
59
+
60
+ exports[`surface emission is byte-stable > ex.support-ticket-queue — messages and warnings 1`] = `
61
+ {
62
+ "id": "ex.support-ticket-queue",
63
+ "messages": "4545981a34db4240",
64
+ "warnings": "5c4de60aeae6c75a",
65
+ }
66
+ `;