Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions apps/web/app/(main)/docs/openapi/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,9 @@ export const openapiCatalog = createCatalog({
}

interface SpecElement {
key: string;
type: string;
props: Record<string, unknown>;
children: string[];
parentKey: string;
}

function schemaToSpec(
Expand All @@ -295,7 +293,6 @@ function schemaToSpec(

if (schema.enum) {
elements.set(key, {
key,
type: 'EnumField',
props: {
name,
Expand All @@ -306,11 +303,9 @@ function schemaToSpec(
defaultValue: schema.default as string,
},
children: [],
parentKey,
});
} else if (schema.type === 'string') {
elements.set(key, {
key,
type: 'StringField',
props: {
name,
Expand All @@ -323,11 +318,9 @@ function schemaToSpec(
defaultValue: schema.default as string,
},
children: [],
parentKey,
});
} else if (schema.type === 'integer' || schema.type === 'number') {
elements.set(key, {
key,
type: 'NumberField',
props: {
name,
Expand All @@ -340,11 +333,9 @@ function schemaToSpec(
defaultValue: schema.default as number,
},
children: [],
parentKey,
});
} else if (schema.type === 'boolean') {
elements.set(key, {
key,
type: 'BooleanField',
props: {
name,
Expand All @@ -353,23 +344,20 @@ function schemaToSpec(
defaultValue: schema.default as boolean,
},
children: [],
parentKey,
});
} else if (schema.type === 'array' && schema.items) {
const childKeys: string[] = [];
const itemKey = schemaToSpec(schema.items, 'item', [], key, elements);
childKeys.push(itemKey);

elements.set(key, {
key,
type: 'ArrayField',
props: {
name,
label,
description: schema.description,
},
children: childKeys,
parentKey,
});
} else if (schema.type === 'object' && schema.properties) {
const childKeys: string[] = [];
Expand All @@ -386,15 +374,13 @@ function schemaToSpec(
}

elements.set(key, {
key,
type: 'ObjectField',
props: {
name,
label,
description: schema.description,
},
children: childKeys,
parentKey,
});
}

Expand Down Expand Up @@ -428,7 +414,6 @@ export function operationToSpec(
}

elements.set(rootKey, {
key: rootKey,
type: 'Form',
props: {
operationId,
Expand All @@ -438,7 +423,6 @@ export function operationToSpec(
description,
},
children: childKeys,
parentKey: '',
});

return {
Expand Down
18 changes: 4 additions & 14 deletions apps/web/app/(main)/docs/schemas/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,19 @@ export default function SchemasPage() {
"root": "card-1",
"elements": {
"card-1": {
"key": "card-1",
"type": "Card",
"props": { "title": "Dashboard" },
"children": ["text-1", "button-1"],
"parentKey": ""
"children": ["text-1", "button-1"]
},
"text-1": {
"key": "text-1",
"type": "Text",
"props": { "content": "Welcome, $data.user.name" },
"children": [],
"parentKey": "card-1"
"children": []
},
"button-1": {
"key": "button-1",
"type": "Button",
"props": { "label": "Click me" },
"children": [],
"parentKey": "card-1"
"children": []
}
}
}`}</Code>
Expand All @@ -129,11 +123,9 @@ export default function SchemasPage() {
structure:
</p>
<Code lang="typescript">{`interface Element {
key: string; // Unique identifier
type: string; // Component type from catalog
props: Record<string, any>; // Component properties
children: string[]; // Array of child element keys
parentKey: string; // Parent element key (empty for root)
visible?: VisibilityRule; // Conditional display
}`}</Code>

Expand All @@ -143,14 +135,12 @@ export default function SchemasPage() {
<code className="text-foreground">$data</code> prefix in props:
</p>
<Code lang="json">{`{
"key": "greeting",
"type": "Text",
"props": {
"content": "$data.user.name",
"count": "$data.items.length"
},
"children": [],
"parentKey": "card-1"
"children": []
}`}</Code>

<h3 className="text-lg font-medium mt-8 mb-3">Action Format</h3>
Expand Down
90 changes: 20 additions & 70 deletions apps/web/app/(main)/docs/specs/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,14 @@ export default function SpecsPage() {
"root": "card-1",
"elements": {
"card-1": {
"key": "card-1",
"type": "Card",
"props": { "title": "Welcome" },
"children": ["text-1"],
"parentKey": ""
"children": ["text-1"]
},
"text-1": {
"key": "text-1",
"type": "Text",
"props": { "content": "Hello, $data.user.name!" },
"children": [],
"parentKey": "card-1"
"children": []
}
}
}`}</Code>
Expand All @@ -74,53 +70,39 @@ export default function SpecsPage() {
"root": "card-1",
"elements": {
"card-1": {
"key": "card-1",
"type": "Card",
"props": { "title": "User Profile", "padding": "md" },
"children": ["row-1", "button-1"],
"parentKey": ""
"children": ["row-1", "button-1"]
},
"row-1": {
"key": "row-1",
"type": "Row",
"props": { "gap": "md" },
"children": ["avatar-1", "stack-1"],
"parentKey": "card-1"
"children": ["avatar-1", "stack-1"]
},
"avatar-1": {
"key": "avatar-1",
"type": "Avatar",
"props": { "src": "$data.user.avatar", "alt": "$data.user.name" },
"children": [],
"parentKey": "row-1"
"children": []
},
"stack-1": {
"key": "stack-1",
"type": "Stack",
"props": { "gap": "sm" },
"children": ["name-text", "email-text"],
"parentKey": "row-1"
"children": ["name-text", "email-text"]
},
"name-text": {
"key": "name-text",
"type": "Text",
"props": { "content": "$data.user.name", "variant": "heading" },
"children": [],
"parentKey": "stack-1"
"children": []
},
"email-text": {
"key": "email-text",
"type": "Text",
"props": { "content": "$data.user.email", "variant": "caption" },
"children": [],
"parentKey": "stack-1"
"children": []
},
"button-1": {
"key": "button-1",
"type": "Button",
"props": { "label": "Edit Profile" },
"children": [],
"parentKey": "card-1"
"children": []
}
}
}`}</Code>
Expand All @@ -133,65 +115,49 @@ export default function SpecsPage() {
"root": "page",
"elements": {
"page": {
"key": "page",
"type": "Page",
"props": {},
"children": ["header", "hero", "features", "footer"],
"parentKey": ""
"children": ["header", "hero", "features", "footer"]
},
"header": {
"key": "header",
"type": "Header",
"props": { "logo": "/logo.svg", "navItems": ["Products", "Pricing", "Docs"] },
"children": [],
"parentKey": "page"
"children": []
},
"hero": {
"key": "hero",
"type": "Hero",
"props": {
"title": "Build UIs with JSON",
"subtitle": "Let AI generate your interfaces",
"ctaLabel": "Get Started",
"ctaHref": "/docs"
},
"children": [],
"parentKey": "page"
"children": []
},
"features": {
"key": "features",
"type": "Features",
"props": { "columns": 3 },
"children": ["feature-1", "feature-2", "feature-3"],
"parentKey": "page"
"children": ["feature-1", "feature-2", "feature-3"]
},
"feature-1": {
"key": "feature-1",
"type": "Feature",
"props": { "icon": "zap", "title": "Fast", "description": "Render UIs in milliseconds" },
"children": [],
"parentKey": "features"
"children": []
},
"feature-2": {
"key": "feature-2",
"type": "Feature",
"props": { "icon": "shield", "title": "Secure", "description": "Validate all specs against your catalog" },
"children": [],
"parentKey": "features"
"children": []
},
"feature-3": {
"key": "feature-3",
"type": "Feature",
"props": { "icon": "sparkles", "title": "AI-Ready", "description": "Generate prompts from your catalog" },
"children": [],
"parentKey": "features"
"children": []
},
"footer": {
"key": "footer",
"type": "Footer",
"props": { "copyright": "2025 Acme Inc", "links": ["Privacy", "Terms", "Contact"] },
"children": [],
"parentKey": "page"
"children": []
}
}
}`}</Code>
Expand All @@ -209,11 +175,9 @@ export default function SpecsPage() {
"root": "card-1",
"elements": {
"card-1": {
"key": "card-1",
"type": "Card",
"props": { "title": "My Card" },
"children": ["text-1"],
"parentKey": ""
"children": ["text-1"]
},
"text-1": { ... }
}
Expand All @@ -224,17 +188,11 @@ export default function SpecsPage() {
Each element in the map has a consistent shape:
</p>
<Code lang="json">{`{
"key": "unique-id",
"type": "ComponentName",
"props": { "label": "Hello" },
"children": ["child-1", "child-2"],
"parentKey": "parent-id"
"children": ["child-1", "child-2"]
}`}</Code>
<ul className="list-disc list-inside text-sm text-muted-foreground space-y-1 mt-3 mb-4">
<li>
<code className="text-foreground">key</code> — Unique identifier for
this element
</li>
<li>
<code className="text-foreground">type</code> — Component type from
your catalog
Expand All @@ -246,10 +204,6 @@ export default function SpecsPage() {
<code className="text-foreground">children</code> — Array of child
element keys
</li>
<li>
<code className="text-foreground">parentKey</code> — Key of parent
element (empty string for root)
</li>
</ul>

<h3 className="text-lg font-medium mt-8 mb-3">Dynamic Data</h3>
Expand All @@ -258,15 +212,13 @@ export default function SpecsPage() {
<code className="text-foreground">$data</code> paths:
</p>
<Code lang="json">{`{
"key": "metric-1",
"type": "Metric",
"props": {
"label": "Total Revenue",
"value": "$data.metrics.revenue",
"change": "$data.metrics.revenueChange"
},
"children": [],
"parentKey": "dashboard"
"children": []
}`}</Code>

<h3 className="text-lg font-medium mt-8 mb-3">Conditional Visibility</h3>
Expand All @@ -275,13 +227,11 @@ export default function SpecsPage() {
<code className="text-foreground">visible</code> property:
</p>
<Code lang="json">{`{
"key": "alert-1",
"type": "Alert",
"props": {
"message": "You have unsaved changes"
},
"children": [],
"parentKey": "form",
"visible": {
"path": "$data.form.isDirty",
"operator": "eq",
Expand Down
Loading