Merge pull request #166 from johndoe6345789/codex/update-pageconfig-to-support-json-pages

Support JSON pages in page config (discriminator + schemaPath)
This commit is contained in:
2026-01-18 17:25:40 +00:00
committed by GitHub
6 changed files with 93 additions and 14 deletions

View File

@@ -245,6 +245,17 @@
"type": "single"
}
},
{
"id": "json-ui-schema",
"title": "JSON UI (Schema)",
"description": "Render JSON UI from a schema file",
"icon": "Code",
"type": "json",
"schemaPath": "json-ui-page.json",
"layout": {
"type": "single"
}
},
{
"id": "sass",
"title": "Sass Styles",

View File

@@ -20,14 +20,10 @@ export interface ResizableConfig {
}
}
export interface PageConfig {
export interface BasePageConfig {
id: string
title: string
icon: string
component?: string
type?: 'json' | 'component'
schemaPath?: string
schema?: PageSchema
enabled: boolean
isRoot?: boolean
toggleKey?: string
@@ -38,6 +34,22 @@ export interface PageConfig {
resizableConfig?: ResizableConfig
}
export interface ComponentPageConfig extends BasePageConfig {
type?: 'component'
component: string
schemaPath?: undefined
schema?: undefined
}
export interface JsonPageConfig extends BasePageConfig {
type: 'json'
component?: undefined
schemaPath?: string
schema?: PageSchema
}
export type PageConfig = ComponentPageConfig | JsonPageConfig
export interface PagesConfig {
pages: PageConfig[]
}

View File

@@ -18,11 +18,10 @@ export const ResizableConfigSchema = z.object({
rightPanel: ResizablePanelConfigSchema,
})
export const SimplePageConfigSchema = z.object({
const SimplePageConfigBaseSchema = z.object({
id: z.string(),
title: z.string(),
icon: z.string(),
component: z.string(),
enabled: z.boolean(),
toggleKey: z.string().optional(),
shortcut: z.string().optional(),
@@ -32,6 +31,21 @@ export const SimplePageConfigSchema = z.object({
resizableConfig: ResizableConfigSchema.optional(),
})
const SimpleComponentPageConfigSchema = SimplePageConfigBaseSchema.extend({
type: z.literal('component').optional(),
component: z.string(),
})
const SimpleJsonPageConfigSchema = SimplePageConfigBaseSchema.extend({
type: z.literal('json'),
schemaPath: z.string(),
})
export const SimplePageConfigSchema = z.union([
SimpleComponentPageConfigSchema,
SimpleJsonPageConfigSchema,
])
export const SimplePagesConfigSchema = z.object({
pages: z.array(SimplePageConfigSchema),
})
@@ -65,18 +79,32 @@ export const FeatureConfigSchema = z.object({
config: z.record(z.string(), z.any()).optional(),
})
export const PageConfigSchema = z.object({
const PageConfigBaseSchema = z.object({
id: z.string(),
title: z.string(),
description: z.string(),
icon: z.string(),
component: z.string(),
layout: LayoutConfigSchema,
features: z.array(FeatureConfigSchema).optional(),
permissions: z.array(z.string()).optional(),
shortcuts: z.array(KeyboardShortcutSchema).optional(),
})
const ComponentPageConfigSchema = PageConfigBaseSchema.extend({
type: z.literal('component').optional(),
component: z.string(),
})
const JsonPageConfigSchema = PageConfigBaseSchema.extend({
type: z.literal('json'),
schemaPath: z.string(),
})
export const PageConfigSchema = z.union([
ComponentPageConfigSchema,
JsonPageConfigSchema,
])
export const PageRegistrySchema = z.object({
pages: z.array(PageConfigSchema),
})

View File

@@ -365,6 +365,16 @@
"order": 22,
"props": {}
},
{
"id": "json-ui-schema",
"title": "JSON UI (Schema)",
"icon": "Code",
"type": "json",
"schemaPath": "json-ui-page.json",
"enabled": true,
"order": 22.2,
"props": {}
},
{
"id": "json-conversion-showcase",
"title": "JSON Conversion Showcase",

View File

@@ -78,6 +78,12 @@ export class RoutePreloadManager {
return
}
if (page.type === 'json' || page.schemaPath) {
console.log(`[PRELOAD_MGR] 🧾 Skipping preload for JSON page: ${pageId}`)
this.preloadedRoutes.add(pageId)
return
}
try {
const componentName = page.component as ComponentName
console.log(`[PRELOAD_MGR] 🚀 Preloading ${pageId}${componentName}`)

View File

@@ -2,14 +2,10 @@ import { PageSchema } from './json-ui'
import { PropConfig } from './prop-config'
import { ResizableConfig } from './resizable-config'
export interface PageConfig {
export interface BasePageConfig {
id: string
title: string
icon: string
component?: string
type?: 'json' | 'component'
schemaPath?: string
schema?: PageSchema
enabled: boolean
isRoot?: boolean
toggleKey?: string
@@ -19,3 +15,19 @@ export interface PageConfig {
props?: PropConfig
resizableConfig?: ResizableConfig
}
export interface ComponentPageConfig extends BasePageConfig {
type?: 'component'
component: string
schemaPath?: undefined
schema?: undefined
}
export interface JsonPageConfig extends BasePageConfig {
type: 'json'
component?: undefined
schemaPath?: string
schema?: PageSchema
}
export type PageConfig = ComponentPageConfig | JsonPageConfig