@burojs/field-types
v0.2.0
Published
Buro: default field types (string, number, ref, ...)
Readme
@burojs/field-types
The default field-type set for buro — the f.* builder you use inside defineResource.
Install
pnpm add @burojs/field-types @burojs/coreUsage
import { defineResource } from '@burojs/field-types';
defineResource(
'document',
{
fields: (f) => ({
id: f.number({ system: true }),
title: f.string({ label: 'Title', required: true }),
status: f.enum(['draft', 'published'], { label: 'Status' }),
author: f.ref('user', { label: 'Author' }),
tags: f.refMany('tag', { label: 'Tags' }),
published_at: f.dateTime({ label: 'Published' }),
config: f.code({ language: 'yaml' }),
is_active: f.boolean({ label: 'Active' }),
}),
},
);Each field carries its own label, visibility predicate, validation and UI hints, so the list, show and form surfaces are all derived from one declaration.
Main exports
defineResource— the canonical resource factory, already bound to the complete default field builder.fieldBuilder/FieldBuilder/extendFieldBuilder— compose a custom builder and pass it once to core'screateResourceFactory; includesstring,number,boolean,date,dateTime,enum,ref,refMany,code,richText,json,childrenand friends.fieldTypesPlugin— registers the set with adefineAppinstance.fromSchema/FromSchemaFieldDef— derive fields from an existing schema instead of hand-writing them.isStandardSchema— detects a Standard Schema validator, so Zod/Valibot/ArkType can be passed to a field'svalidatewith no runtime dependency on any of them.
License
MIT
