Primitive Builders
bd is the compact alias of fields. Both names reference the same builder
namespace:
import { bd, fields } from '@businessdash/sdk'
bd.text() === fields.text() // true
Choose a builder for the stored value first. Modifiers and form elements come later in the chain.
Scalar and collection builders
| Builder | Stored type | Typical value |
|---|---|---|
bd.text() | TEXT | Short or long text |
bd.number() | NUMBER | General numbers |
bd.numeric() | NUMERIC | Precision-oriented numbers |
bd.boolean() | BOOLEAN | true / false |
bd.date() | DATE | Calendar date |
bd.dateTime() | DATE_TIME | Date and time |
bd.uuid() | UUID | UUID string |
bd.url() | TEXT | URL input intent |
bd.email() | EMAILS | Email value |
bd.phone() | PHONES | Phone value |
bd.richText() | RICH_TEXT | Rich content |
bd.json() | RAW_JSON | Unstructured JSON |
bd.array() | ARRAY | Array value |
bd.enum(values) | SELECT | One fixed choice |
bd.multiEnum(values) | MULTI_SELECT | Several fixed choices |
bd.reference(target) | RELATION | Short one-to-many reference |
bd.relation() | RELATION | Fluent relation chain |
const projects = collection('projects', {
fields: {
title: bd.text(),
budget: bd.number(),
active: bd.boolean(),
dueAt: bd.dateTime(),
labels: bd.array(),
},
})
Structured builders
Structured builders choose a stored type and attach the matching element metadata.
Measurement
const length = bd.measurement({
category: 'length',
unitPicker: 'fixed',
default_unit: 'cm',
resolve_to_your_unit: 'cm',
allow_decimals: true,
})
This stores RAW_JSON and selects the measurement form element.
Object
const shippingAddress = bd.object({
line1: bd.text().required(),
city: bd.text().required(),
postalCode: bd.text().required(),
})
The explicit { properties: { ... } } form is equivalent. Object fields store
RAW_JSON with nested property definitions in element metadata.
JSONB output for object-value elements
Every object-value form element can explicitly export as JSONB. Use a structured
builder where one exists, or pair bd.json() with the form element:
const structuredFields = {
profile: bd.object({
displayName: bd.text().required(),
}).strategy('jsonb'),
shippingAddress: bd.address().strategy('jsonb'),
coordinates: bd.geo().strategy('jsonb'),
availability: bd
.json()
.formElement('availability')
.strategy('jsonb'),
bookingWindow: bd
.json()
.formElement('date_range')
.strategy('jsonb'),
}
This applies to address_group, measurement, availability, date_range,
object, geo, time_picker_timeslot, and time_picker_datetime. Each uses
RAW_JSON; toJSONSchema() emits strategy: 'jsonb' for the receiving CLI and
API.
File, address, and geo
const documents = bd.file({
max_size_mb: 15,
allowed_mimetypes: ['application/pdf'],
})
const address = bd.address({
require_postal_code: true,
restrict_countries: ['US', 'CA'],
})
const coordinates = bd.geo()
| Builder | Stored type | Preferred form element |
|---|---|---|
bd.file() | FILES | formFileValue |
bd.address() | RAW_JSON | address_group |
bd.geo() | RAW_JSON | geo |
All builders accept an optional FieldOptions object, but chaining keeps large
declarations easier to read:
bd.text({ required: true, indexed: true })
bd.text()
.required()
.indexed()
Next: Field Modifiers.