@aestheticfunction/dspack-emit 0.3.2 → 0.4.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 +29 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +34 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/targets/a2ui/surface.js +7 -0
- package/dist/transform/profile-load.d.ts +19 -0
- package/dist/transform/profile-load.js +58 -0
- package/dist/transform/profile.v1.schema.json +153 -0
- package/dist/transform/scaffold.d.ts +40 -0
- package/dist/transform/scaffold.js +171 -0
- package/package.json +5 -2
- package/src/cli.ts +35 -9
- package/src/index.ts +2 -0
- package/src/profile-load.test.ts +144 -0
- package/src/targets/a2ui/surface.ts +10 -0
- package/src/transform/profile-load.ts +73 -0
- package/src/transform/profile.v1.schema.json +153 -0
- package/src/transform/scaffold.ts +229 -0
package/src/cli.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* dspack-emit CLI.
|
|
3
|
+
* dspack-emit CLI (also installed as the `dspack-emit` bin).
|
|
4
4
|
*
|
|
5
5
|
* tsx src/cli.ts --in <dspack.json> --a2ui-version <0.9.1|1.0> --out <dir> [--surface <surface.json>]
|
|
6
|
-
* [--emit-surface <surface.dsurface.json>]
|
|
6
|
+
* [--profile <profile.json>] [--emit-surface <surface.dsurface.json>]
|
|
7
7
|
* tsx src/cli.ts --target json-render --in <dspack.json> --out <dir>
|
|
8
8
|
* [--emit-surface <surface.dsurface.json>]
|
|
9
9
|
*
|
|
10
|
+
* --profile loads a JSON mapping profile (validated against
|
|
11
|
+
* profile.v1.schema.json via loadProfile) instead of the built-in shadcn
|
|
12
|
+
* profile — the flag that makes out-of-repo contracts emittable from CI.
|
|
13
|
+
* When --profile is given and --surface is not, the sample-surface default
|
|
14
|
+
* (a repo-relative fixture) is skipped and gate A3 runs on --emit-surface
|
|
15
|
+
* output only.
|
|
16
|
+
*
|
|
10
17
|
* Default target (a2ui): emits a versioned A2UI catalog + a
|
|
11
18
|
* validation/fidelity report. Exits non-zero if the hard gate (catalog schema
|
|
12
19
|
* validation) fails, so it is CI-friendly. With --emit-surface, additionally
|
|
@@ -25,6 +32,8 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
25
32
|
import { basename, join, resolve } from "node:path";
|
|
26
33
|
import type { A2uiVersion, DspackDoc, DspackSurface } from "./types.js";
|
|
27
34
|
import { transform } from "./transform/index.js";
|
|
35
|
+
import { shadcnProfile, type Profile } from "./transform/profiles.js";
|
|
36
|
+
import { loadProfile, ProfileLoadError } from "./transform/profile-load.js";
|
|
28
37
|
import { emitSurface, EmitSurfaceError } from "./targets/a2ui/surface.js";
|
|
29
38
|
import { generateJsonRenderModules } from "./targets/json-render/codegen.js";
|
|
30
39
|
import { emitJsonRenderSpec, EmitJsonRenderError, validateSpecAgainstModel } from "./targets/json-render/emit.js";
|
|
@@ -34,7 +43,8 @@ interface Args {
|
|
|
34
43
|
in: string;
|
|
35
44
|
version: A2uiVersion;
|
|
36
45
|
out: string;
|
|
37
|
-
surface
|
|
46
|
+
surface?: string;
|
|
47
|
+
profile?: string;
|
|
38
48
|
emitSurface?: string;
|
|
39
49
|
strictCoverage: boolean;
|
|
40
50
|
}
|
|
@@ -73,12 +83,16 @@ function parseArgs(argv: string[]): Args {
|
|
|
73
83
|
}
|
|
74
84
|
const input = m.get("in");
|
|
75
85
|
if (!input) fail("--in <dspack.json> is required");
|
|
86
|
+
const profile = m.get("profile");
|
|
76
87
|
return {
|
|
77
88
|
target,
|
|
78
89
|
in: input!,
|
|
79
90
|
version: (version ?? "0.9.1") as A2uiVersion,
|
|
80
91
|
out: m.get("out") ?? "out",
|
|
81
|
-
|
|
92
|
+
// The sample-surface default is a repo-relative fixture; external callers
|
|
93
|
+
// (--profile) get a vacuous A3 unless they pass --surface/--emit-surface.
|
|
94
|
+
surface: m.get("surface") ?? (profile ? undefined : "surface/settings-card.surface.json"),
|
|
95
|
+
profile,
|
|
82
96
|
emitSurface: m.get("emit-surface"),
|
|
83
97
|
strictCoverage: m.get("strict-coverage") === "true",
|
|
84
98
|
};
|
|
@@ -141,9 +155,21 @@ function main(): void {
|
|
|
141
155
|
jsonRenderMain(args, doc);
|
|
142
156
|
return;
|
|
143
157
|
}
|
|
144
|
-
|
|
158
|
+
let profile: Profile = shadcnProfile;
|
|
159
|
+
if (args.profile) {
|
|
160
|
+
try {
|
|
161
|
+
profile = loadProfile(JSON.parse(readFileSync(resolve(args.profile), "utf8")));
|
|
162
|
+
} catch (e) {
|
|
163
|
+
if (e instanceof ProfileLoadError) {
|
|
164
|
+
console.error(`error: --profile ${args.profile}: ${e.message}`);
|
|
165
|
+
process.exit(2);
|
|
166
|
+
}
|
|
167
|
+
throw e;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const surface = args.surface ? JSON.parse(readFileSync(resolve(args.surface), "utf8")) : { messages: [] };
|
|
145
171
|
|
|
146
|
-
const { catalog, mapping, validation, report } = transform(doc, args.version, surface);
|
|
172
|
+
const { catalog, mapping, validation, report } = transform(doc, args.version, surface, profile);
|
|
147
173
|
|
|
148
174
|
mkdirSync(resolve(args.out), { recursive: true });
|
|
149
175
|
const base = resolve(args.out);
|
|
@@ -169,7 +195,7 @@ function main(): void {
|
|
|
169
195
|
const csr = JSON.parse(readFileSync(resolve(args.emitSurface), "utf8")) as DspackSurface;
|
|
170
196
|
let emitted;
|
|
171
197
|
try {
|
|
172
|
-
emitted = emitSurface(csr, doc);
|
|
198
|
+
emitted = emitSurface(csr, doc, { profile });
|
|
173
199
|
} catch (e) {
|
|
174
200
|
if (e instanceof EmitSurfaceError) {
|
|
175
201
|
console.error(`${tag} EMIT-SURFACE FAILED: ${e.message}`);
|
|
@@ -183,7 +209,7 @@ function main(): void {
|
|
|
183
209
|
for (const w of emitted.warnings) console.log(`${tag} note ${w.code}: ${w.message}`);
|
|
184
210
|
// Gate A3 over the emitted surface: its instances must validate against the
|
|
185
211
|
// catalog generated in this same run.
|
|
186
|
-
const check = transform(doc, args.version, { messages: emitted.messages });
|
|
212
|
+
const check = transform(doc, args.version, { messages: emitted.messages }, profile);
|
|
187
213
|
const instanceGate = check.validation.gates.find((g) => g.name === "instance");
|
|
188
214
|
console.log(`${tag} emitted surface -> ${outPath}`);
|
|
189
215
|
console.log(`${tag} ${instanceGate?.pass ? "PASS" : "FAIL"} instance (emitted surface vs generated catalog)`);
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { transform, transformFromJson, type TransformOutput } from "./transform/index.js";
|
|
9
9
|
export { shadcnProfile, type Profile, type ComponentPlan, type SurfacePlanDirectives } from "./transform/profiles.js";
|
|
10
|
+
export { loadProfile, profileSchema, ProfileLoadError, type ProfileLoadIssue } from "./transform/profile-load.js";
|
|
11
|
+
export { scaffoldProfile, type ScaffoldOptions, type ScaffoldResult, type ScaffoldNote } from "./transform/scaffold.js";
|
|
10
12
|
export { validateCatalog, extractInstances, type ValidationReport, type GateResult } from "./validate/ajv.js";
|
|
11
13
|
export {
|
|
12
14
|
emitSurface,
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile-as-data (PR: profile JSON schema + loadProfile + scaffoldProfile).
|
|
3
|
+
*
|
|
4
|
+
* The center-of-gravity contract for the catalog composer: a Profile expressed
|
|
5
|
+
* as JSON, validated at runtime against schema/profile.v1.schema.json, must
|
|
6
|
+
* drive the engine byte-identically to the same Profile expressed as the
|
|
7
|
+
* in-repo TypeScript object. Judgment stays with the author; the loader only
|
|
8
|
+
* gates shape.
|
|
9
|
+
*/
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
import { readFileSync } from "node:fs";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { loadProfile, ProfileLoadError } from "./transform/profile-load.js";
|
|
14
|
+
import { scaffoldProfile } from "./transform/scaffold.js";
|
|
15
|
+
import { shadcnProfile } from "./transform/profiles.js";
|
|
16
|
+
import { transformFromJson } from "./transform/index.js";
|
|
17
|
+
import { emitSurface, EmitSurfaceError } from "./targets/a2ui/surface.js";
|
|
18
|
+
import type { DspackDoc, DspackSurface } from "./types.js";
|
|
19
|
+
|
|
20
|
+
const repo = (p: string) => fileURLToPath(new URL(`../${p}`, import.meta.url));
|
|
21
|
+
const load = (p: string) => JSON.parse(readFileSync(repo(p), "utf8"));
|
|
22
|
+
|
|
23
|
+
const shadcnDoc = load("input/shadcn-ui.dspack.json") as DspackDoc;
|
|
24
|
+
const astryxDoc = load("input/astryx.dspack.json") as DspackDoc;
|
|
25
|
+
|
|
26
|
+
/** The TS profile, round-tripped through JSON exactly as a user file would be. */
|
|
27
|
+
const shadcnProfileJson = () => ({ profileVersion: "1", ...structuredClone(shadcnProfile) });
|
|
28
|
+
|
|
29
|
+
describe("loadProfile", () => {
|
|
30
|
+
it("accepts the canonical shadcn profile expressed as JSON", () => {
|
|
31
|
+
const profile = loadProfile(shadcnProfileJson());
|
|
32
|
+
expect(profile.catalogTitle).toBe(shadcnProfile.catalogTitle);
|
|
33
|
+
// profileVersion is loader envelope, not engine input.
|
|
34
|
+
expect((profile as Record<string, unknown>).profileVersion).toBeUndefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("drives the engine byte-identically to the TypeScript profile", () => {
|
|
38
|
+
const fromTs = transformFromJson(shadcnDoc, { profile: shadcnProfile });
|
|
39
|
+
const fromJson = transformFromJson(shadcnDoc, { profile: loadProfile(shadcnProfileJson()) });
|
|
40
|
+
expect(JSON.stringify(fromJson.catalog)).toBe(JSON.stringify(fromTs.catalog));
|
|
41
|
+
expect(fromJson.validation.pass).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("rejects a malformed profile with typed, pathed findings", () => {
|
|
45
|
+
const bad = shadcnProfileJson() as any;
|
|
46
|
+
bad.components[0].propMap.variant.kind = "vibes";
|
|
47
|
+
expect(() => loadProfile(bad)).toThrowError(ProfileLoadError);
|
|
48
|
+
try {
|
|
49
|
+
loadProfile(bad);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
const issues = (e as ProfileLoadError).issues;
|
|
52
|
+
expect(issues.length).toBeGreaterThan(0);
|
|
53
|
+
expect(issues.some((i) => i.path.includes("propMap"))).toBe(true);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("rejects a non-https catalogIdBase", () => {
|
|
58
|
+
const bad = shadcnProfileJson() as any;
|
|
59
|
+
bad.catalogIdBase = "http://insecure.example/catalog";
|
|
60
|
+
expect(() => loadProfile(bad)).toThrowError(ProfileLoadError);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("rejects a missing profileVersion", () => {
|
|
64
|
+
const { profileVersion: _dropped, ...bare } = shadcnProfileJson();
|
|
65
|
+
expect(() => loadProfile(bare)).toThrowError(ProfileLoadError);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("fails closed on unknown keys — x-* is the only extension surface (dspack convention)", () => {
|
|
69
|
+
const topLevel = shadcnProfileJson() as Record<string, unknown>;
|
|
70
|
+
topLevel.customBehavior = true;
|
|
71
|
+
expect(() => loadProfile(topLevel)).toThrowError(ProfileLoadError);
|
|
72
|
+
|
|
73
|
+
const inPlan = shadcnProfileJson() as any;
|
|
74
|
+
inPlan.components[0].renderHint = "fancy";
|
|
75
|
+
expect(() => loadProfile(inPlan)).toThrowError(ProfileLoadError);
|
|
76
|
+
|
|
77
|
+
// The sanctioned extension slot passes and is preserved for tools.
|
|
78
|
+
const extended = shadcnProfileJson() as Record<string, unknown>;
|
|
79
|
+
extended["x-composer"] = { note: "authored in the studio composer" };
|
|
80
|
+
const profile = loadProfile(extended) as unknown as Record<string, unknown>;
|
|
81
|
+
expect(profile["x-composer"]).toEqual({ note: "authored in the studio composer" });
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe("casualty refusal cites the authored reason", () => {
|
|
86
|
+
it("names the declared casualty and its reason when a surface uses it", () => {
|
|
87
|
+
const surface: DspackSurface = {
|
|
88
|
+
dspackSurface: "0.1",
|
|
89
|
+
system: shadcnDoc.name as string,
|
|
90
|
+
intent: "destructive-action",
|
|
91
|
+
root: { component: "dropdown-menu", props: {} },
|
|
92
|
+
} as DspackSurface;
|
|
93
|
+
try {
|
|
94
|
+
emitSurface(surface, shadcnDoc, { profile: shadcnProfile });
|
|
95
|
+
expect.unreachable("surface using a casualty component must refuse");
|
|
96
|
+
} catch (e) {
|
|
97
|
+
expect(e).toBeInstanceOf(EmitSurfaceError);
|
|
98
|
+
const msg = (e as EmitSurfaceError).message;
|
|
99
|
+
// The profile's authored reason, not just "unknown component".
|
|
100
|
+
expect(msg).toContain("declared casualty");
|
|
101
|
+
expect(msg).toContain("dropdown menu");
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe("scaffoldProfile", () => {
|
|
107
|
+
it("produces a loadProfile-valid profile from a bare contract", () => {
|
|
108
|
+
const { profile } = scaffoldProfile(astryxDoc, {
|
|
109
|
+
catalogIdBase: "https://example.test/catalogs/astryx-scaffold",
|
|
110
|
+
});
|
|
111
|
+
// The scaffold is itself a valid v1 profile document.
|
|
112
|
+
const loaded = loadProfile(profile);
|
|
113
|
+
expect(loaded.catalogIdBase).toBe("https://example.test/catalogs/astryx-scaffold");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("maps every contract component (full coverage, no judgment invented)", () => {
|
|
117
|
+
const { profile, notes } = scaffoldProfile(astryxDoc, {
|
|
118
|
+
catalogIdBase: "https://example.test/catalogs/astryx-scaffold",
|
|
119
|
+
});
|
|
120
|
+
const loaded = loadProfile(profile);
|
|
121
|
+
const out = transformFromJson(astryxDoc, { profile: loaded });
|
|
122
|
+
expect(out.validation.gates.find((g) => g.name === "schema-compile + no-external-ref")?.pass).toBe(true);
|
|
123
|
+
expect(out.validation.gates.find((g) => g.name === "catalog-shape")?.pass).toBe(true);
|
|
124
|
+
const unclassified = out.mapping.coverage.filter((c) => c.disposition === "unclassified");
|
|
125
|
+
expect(unclassified).toEqual([]);
|
|
126
|
+
// Mechanical means mechanical: no casualties invented, judgment flagged in notes.
|
|
127
|
+
expect(loaded.casualtyComponents).toEqual([]);
|
|
128
|
+
expect(notes.length).toBeGreaterThan(0);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("seeds enum props verbatim (identity projection, no valueMap)", () => {
|
|
132
|
+
const { profile } = scaffoldProfile(shadcnDoc, {
|
|
133
|
+
catalogIdBase: "https://example.test/catalogs/shadcn-scaffold",
|
|
134
|
+
});
|
|
135
|
+
const loaded = loadProfile(profile);
|
|
136
|
+
const button = loaded.components.find((c) => c.dspackId === "button");
|
|
137
|
+
expect(button).toBeDefined();
|
|
138
|
+
const variant = button?.propMap?.variant;
|
|
139
|
+
expect(variant?.kind).toBe("enum");
|
|
140
|
+
// Verbatim contract vocabulary, not the hand-tuned lossy projection.
|
|
141
|
+
expect(variant?.targetEnum).toEqual(["default", "destructive", "outline", "secondary", "ghost", "link"]);
|
|
142
|
+
expect(variant?.valueMap).toBeUndefined();
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -131,6 +131,16 @@ class SurfaceEmitter {
|
|
|
131
131
|
emitNode(node: SurfaceNode, path: string): string {
|
|
132
132
|
const plan = this.byDspackId.get(node.component);
|
|
133
133
|
if (!plan) {
|
|
134
|
+
// A declared casualty refuses with its authored reason — the refusal is
|
|
135
|
+
// the profile author's decision, and the message should say so.
|
|
136
|
+
const casualty = this.profile.casualtyComponents.find((c) => c.dspackId === node.component);
|
|
137
|
+
if (casualty) {
|
|
138
|
+
throw new EmitSurfaceError(
|
|
139
|
+
`component '${node.component}' is a declared casualty (${casualty.class}) of the ` +
|
|
140
|
+
`'${this.profile.catalogTitle}' profile: ${casualty.reason}`,
|
|
141
|
+
path,
|
|
142
|
+
);
|
|
143
|
+
}
|
|
134
144
|
throw new EmitSurfaceError(
|
|
135
145
|
`unknown component '${node.component}': not a mapped component of the '${this.profile.catalogTitle}' profile ` +
|
|
136
146
|
`(sub-components are consumed by their compound parent and cannot be emitted standalone)`,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile-as-data: load a mapping Profile from JSON.
|
|
3
|
+
*
|
|
4
|
+
* The Profile has always been pure data (profiles.ts); this module makes it
|
|
5
|
+
* *reachable* as data. `loadProfile` validates an untrusted JSON value against
|
|
6
|
+
* schema `profile.v1.schema.json` (a one-to-one mirror of the TypeScript
|
|
7
|
+
* `Profile` interface plus a `profileVersion` envelope const) and returns the
|
|
8
|
+
* engine-ready `Profile`. Validation gates shape only — every judgment call
|
|
9
|
+
* (valueMaps, casualties, surface plans) stays with the profile's author.
|
|
10
|
+
*
|
|
11
|
+
* Toolchain: ajv draft 2020-12, `strict: false`, ajv-formats — the same
|
|
12
|
+
* convention as the catalog gates (src/validate/ajv.ts) and the dspack
|
|
13
|
+
* harness.
|
|
14
|
+
*/
|
|
15
|
+
import { readFileSync } from "node:fs";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
import Ajv2020, { type ValidateFunction } from "ajv/dist/2020.js";
|
|
18
|
+
import addFormats from "ajv-formats";
|
|
19
|
+
import type { Profile } from "./profiles.js";
|
|
20
|
+
|
|
21
|
+
export interface ProfileLoadIssue {
|
|
22
|
+
/** JSON path into the offending document (ajv instancePath). */
|
|
23
|
+
path: string;
|
|
24
|
+
message: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class ProfileLoadError extends Error {
|
|
28
|
+
constructor(readonly issues: ProfileLoadIssue[]) {
|
|
29
|
+
super(
|
|
30
|
+
`profile does not conform to profile.v1.schema.json (${issues.length} issue${issues.length === 1 ? "" : "s"}): ` +
|
|
31
|
+
issues
|
|
32
|
+
.slice(0, 3)
|
|
33
|
+
.map((i) => `${i.path || "$"}: ${i.message}`)
|
|
34
|
+
.join("; ") +
|
|
35
|
+
(issues.length > 3 ? "; …" : ""),
|
|
36
|
+
);
|
|
37
|
+
this.name = "ProfileLoadError";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const schemaPath = fileURLToPath(new URL("./profile.v1.schema.json", import.meta.url));
|
|
42
|
+
|
|
43
|
+
/** The profile schema, as shipped (also exported for hosts that surface it in UI). */
|
|
44
|
+
export const profileSchema: Record<string, unknown> = JSON.parse(readFileSync(schemaPath, "utf8"));
|
|
45
|
+
|
|
46
|
+
let compiled: ValidateFunction | undefined;
|
|
47
|
+
|
|
48
|
+
function validator(): ValidateFunction {
|
|
49
|
+
if (!compiled) {
|
|
50
|
+
const ajv = new Ajv2020({ strict: false, allErrors: true, validateFormats: true });
|
|
51
|
+
addFormats(ajv);
|
|
52
|
+
compiled = ajv.compile(profileSchema);
|
|
53
|
+
}
|
|
54
|
+
return compiled;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Validate `json` as a v1 profile document and return the engine-ready
|
|
59
|
+
* `Profile`. The `profileVersion` envelope field is stripped — it belongs to
|
|
60
|
+
* the document format, not the engine. Top-level `x-` extension keys are
|
|
61
|
+
* preserved (the engine ignores them; provenance tools may not).
|
|
62
|
+
*/
|
|
63
|
+
export function loadProfile(json: unknown): Profile {
|
|
64
|
+
const validate = validator();
|
|
65
|
+
if (!validate(json)) {
|
|
66
|
+
const errors = (validate.errors ?? []) as Array<{ instancePath?: string; message?: string }>;
|
|
67
|
+
throw new ProfileLoadError(
|
|
68
|
+
errors.map((e) => ({ path: e.instancePath ?? "", message: e.message ?? "invalid" })),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
const { profileVersion: _envelope, ...profile } = json as Record<string, unknown> & { profileVersion: string };
|
|
72
|
+
return profile as unknown as Profile;
|
|
73
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://aestheticfunction.github.io/dspack-emit/schema/profile.v1.schema.json",
|
|
4
|
+
"title": "dspack-emit a2ui Profile v1",
|
|
5
|
+
"description": "JSON form of the a2ui target's mapping Profile. Mirrors the TypeScript Profile interface in src/transform/profiles.ts one to one; loadProfile() validates against this schema before the engine runs.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"patternProperties": { "^x-": {} },
|
|
9
|
+
"required": [
|
|
10
|
+
"profileVersion",
|
|
11
|
+
"catalogTitle",
|
|
12
|
+
"catalogDescription",
|
|
13
|
+
"catalogIdBase",
|
|
14
|
+
"instructions",
|
|
15
|
+
"primaryColorToken",
|
|
16
|
+
"components",
|
|
17
|
+
"synthesized",
|
|
18
|
+
"casualtyComponents",
|
|
19
|
+
"surfaceSynthesis"
|
|
20
|
+
],
|
|
21
|
+
"properties": {
|
|
22
|
+
"profileVersion": { "const": "1" },
|
|
23
|
+
"catalogTitle": { "type": "string", "minLength": 1 },
|
|
24
|
+
"catalogDescription": { "type": "string", "minLength": 1 },
|
|
25
|
+
"catalogIdBase": { "type": "string", "format": "uri", "pattern": "^https://" },
|
|
26
|
+
"instructions": { "type": "string" },
|
|
27
|
+
"primaryColorToken": {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"additionalProperties": false,
|
|
30
|
+
"required": ["category", "name"],
|
|
31
|
+
"properties": {
|
|
32
|
+
"category": { "type": "string", "minLength": 1 },
|
|
33
|
+
"name": { "type": "string", "minLength": 1 }
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"components": { "type": "array", "items": { "$ref": "#/$defs/componentPlan" } },
|
|
37
|
+
"synthesized": { "type": "array", "items": { "$ref": "#/$defs/componentPlan" } },
|
|
38
|
+
"casualtyComponents": {
|
|
39
|
+
"type": "array",
|
|
40
|
+
"items": {
|
|
41
|
+
"type": "object",
|
|
42
|
+
"additionalProperties": false,
|
|
43
|
+
"patternProperties": { "^x-": {} },
|
|
44
|
+
"required": ["dspackId", "attempted", "class", "reason"],
|
|
45
|
+
"properties": {
|
|
46
|
+
"dspackId": { "$ref": "#/$defs/dspackId" },
|
|
47
|
+
"attempted": { "type": "string", "minLength": 1 },
|
|
48
|
+
"class": { "enum": ["maps-cleanly", "synthesis-defaults", "lossy", "cannot-represent"] },
|
|
49
|
+
"reason": { "type": "string", "minLength": 1 }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"intentionallyOmitted": { "type": "array", "items": { "$ref": "#/$defs/dspackId" } },
|
|
54
|
+
"surfaceSynthesis": {
|
|
55
|
+
"type": "object",
|
|
56
|
+
"additionalProperties": false,
|
|
57
|
+
"required": ["textComponent", "textProp", "wrapComponent", "wrapChildrenProp"],
|
|
58
|
+
"properties": {
|
|
59
|
+
"textComponent": { "$ref": "#/$defs/a2uiName" },
|
|
60
|
+
"textProp": { "type": "string", "minLength": 1 },
|
|
61
|
+
"wrapComponent": { "$ref": "#/$defs/a2uiName" },
|
|
62
|
+
"wrapChildrenProp": { "type": "string", "minLength": 1 }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"$defs": {
|
|
67
|
+
"dspackId": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
|
|
68
|
+
"a2uiName": { "type": "string", "pattern": "^[A-Z][A-Za-z0-9]*$" },
|
|
69
|
+
"componentPlan": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"additionalProperties": false,
|
|
72
|
+
"patternProperties": { "^x-": {} },
|
|
73
|
+
"required": ["a2ui", "commons", "structural", "required"],
|
|
74
|
+
"properties": {
|
|
75
|
+
"a2ui": { "$ref": "#/$defs/a2uiName" },
|
|
76
|
+
"dspackId": { "$ref": "#/$defs/dspackId" },
|
|
77
|
+
"description": { "type": "string" },
|
|
78
|
+
"commons": { "type": "array", "items": { "type": "string", "minLength": 1 } },
|
|
79
|
+
"structural": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"additionalProperties": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"additionalProperties": false,
|
|
84
|
+
"required": ["schema", "description", "synthNote"],
|
|
85
|
+
"properties": {
|
|
86
|
+
"schema": {},
|
|
87
|
+
"description": { "type": "string", "minLength": 1 },
|
|
88
|
+
"synthNote": { "type": "string", "minLength": 1 }
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"propMap": {
|
|
93
|
+
"type": "object",
|
|
94
|
+
"additionalProperties": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"additionalProperties": false,
|
|
97
|
+
"required": ["a2ui", "kind"],
|
|
98
|
+
"properties": {
|
|
99
|
+
"a2ui": { "type": "string", "minLength": 1 },
|
|
100
|
+
"kind": { "enum": ["enum", "string", "boolean", "number"] },
|
|
101
|
+
"targetEnum": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
|
|
102
|
+
"valueMap": { "type": "object", "additionalProperties": { "type": "string" } },
|
|
103
|
+
"default": { "type": "string" },
|
|
104
|
+
"description": { "type": "string" }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"required": { "type": "array", "items": { "type": "string" } },
|
|
109
|
+
"surfacePlan": {
|
|
110
|
+
"type": "object",
|
|
111
|
+
"additionalProperties": false,
|
|
112
|
+
"properties": {
|
|
113
|
+
"subText": { "type": "object", "additionalProperties": { "type": "string" } },
|
|
114
|
+
"subButtonText": { "type": "object", "additionalProperties": { "type": "string" } },
|
|
115
|
+
"actionProp": { "type": "string" },
|
|
116
|
+
"textChildProp": { "type": "string" },
|
|
117
|
+
"textProp": { "type": "string" },
|
|
118
|
+
"childProp": { "type": "string" },
|
|
119
|
+
"childrenProp": { "type": "string" },
|
|
120
|
+
"structuralPassthrough": { "type": "array", "items": { "type": "string" } },
|
|
121
|
+
"subTable": {
|
|
122
|
+
"type": "object",
|
|
123
|
+
"additionalProperties": false,
|
|
124
|
+
"required": ["caption", "header", "headerCell", "body", "row", "cell", "targetCaption", "targetColumns", "targetRows", "drops"],
|
|
125
|
+
"properties": {
|
|
126
|
+
"caption": { "type": "string" },
|
|
127
|
+
"header": { "type": "string" },
|
|
128
|
+
"headerCell": { "type": "string" },
|
|
129
|
+
"body": { "type": "string" },
|
|
130
|
+
"row": { "type": "string" },
|
|
131
|
+
"cell": { "type": "string" },
|
|
132
|
+
"targetCaption": { "type": "string" },
|
|
133
|
+
"targetColumns": { "type": "string" },
|
|
134
|
+
"targetRows": { "type": "string" },
|
|
135
|
+
"drops": { "type": "object", "additionalProperties": { "type": "string" } }
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"subFlatten": {
|
|
139
|
+
"type": "object",
|
|
140
|
+
"additionalProperties": false,
|
|
141
|
+
"required": ["transparent", "asText"],
|
|
142
|
+
"properties": {
|
|
143
|
+
"transparent": { "type": "array", "items": { "$ref": "#/$defs/dspackId" } },
|
|
144
|
+
"asText": { "type": "object", "additionalProperties": { "type": "string" } }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"subCoverage": { "type": "object", "additionalProperties": { "type": "string" } }
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|