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

BuilderStored typeTypical value
bd.text()TEXTShort or long text
bd.number()NUMBERGeneral numbers
bd.numeric()NUMERICPrecision-oriented numbers
bd.boolean()BOOLEANtrue / false
bd.date()DATECalendar date
bd.dateTime()DATE_TIMEDate and time
bd.uuid()UUIDUUID string
bd.url()TEXTURL input intent
bd.email()EMAILSEmail value
bd.phone()PHONESPhone value
bd.richText()RICH_TEXTRich content
bd.json()RAW_JSONUnstructured JSON
bd.array()ARRAYArray value
bd.enum(values)SELECTOne fixed choice
bd.multiEnum(values)MULTI_SELECTSeveral fixed choices
bd.reference(target)RELATIONShort one-to-many reference
bd.relation()RELATIONFluent 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()
BuilderStored typePreferred form element
bd.file()FILESformFileValue
bd.address()RAW_JSONaddress_group
bd.geo()RAW_JSONgeo

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.