The @object-ui/core package (also published as @object-ui/protocol) provides the foundational type definitions and schemas for Object UI.
npm install @object-ui/protocolimport type {
BaseSchema,
PageSchema,
FormSchema,
ViewSchema,
ComponentSchema
} from '@object-ui/protocol'All schemas extend from BaseSchema:
interface BaseSchema {
type: string
id?: string
name?: string
className?: string
style?: React.CSSProperties
visible?: boolean
visibleOn?: string
}interface PageSchema extends BaseSchema {
type: 'page'
title: string
description?: string
body: ComponentSchema | ComponentSchema[]
}interface FormSchema extends BaseSchema {
type: 'form'
title?: string
body: FieldSchema[]
actions?: ActionSchema[]
onSubmit?: string
}interface InputSchema extends BaseSchema {
type: 'input'
name: string
label: string
placeholder?: string
required?: boolean
disabled?: boolean
inputType?: 'text' | 'email' | 'password' | 'number'
}import { PageSchema } from '@object-ui/protocol'
import { z } from 'zod'
const pageValidator = z.object({
type: z.literal('page'),
title: z.string(),
body: z.any()
})
// Validate
const result = pageValidator.safeParse(mySchema)import { isPageSchema, isFormSchema } from '@object-ui/protocol'
if (isPageSchema(schema)) {
// TypeScript knows schema is PageSchema
console.log(schema.title)
}Full API documentation coming soon.
For now, see: