@airdraft/ui-core
v0.1.9
Published
Airdraft UI core — field type metadata, validators, and schema mutation helpers (zero framework deps)
Readme
@airdraft/ui-core
Shared UI-layer constants and utilities for Airdraft. Provides field-type metadata (labels, icons, descriptions), the schema editor mutation helpers, and collection name validators consumed by @airdraft/react-ui.
Installation
npm install @airdraft/ui-coreThis package is typically a transitive dependency — you don't need to install it directly unless you're building a custom schema editor or type picker.
Exports
Field type metadata
import { FIELD_TYPE_META, VISIBLE_FIELD_TYPES } from '@airdraft/ui-core'
import type { FieldTypeMeta } from '@airdraft/ui-core'| Export | Description |
|---|---|
| FIELD_TYPE_META | Record<FieldType, FieldTypeMeta> — label, description, and Lucide icon name for every field type |
| VISIBLE_FIELD_TYPES | FieldType[] — all field types with hidden !== true; use this to populate a type picker (excludes the deprecated image type) |
| FieldTypeMeta | { type, label, description, icon, hidden? } |
Supported field types (all included in FIELD_TYPE_META):
string · text · number · boolean · date · datetime · list · select · multiselect · rich-text · relation · relations · object · url · media · blocks
image is present but marked hidden: true — it is excluded from VISIBLE_FIELD_TYPES and the schema editor type picker. Use media for new fields.
Schema editor mutations
import { applyFieldUpdate, applyFieldDelete, buildDefaultPath } from '@airdraft/ui-core'| Export | Description |
|---|---|
| applyFieldUpdate(collection, key, config) | Returns a new CollectionConfig with the field at key upserted |
| applyFieldDelete(collection, key) | Returns a new CollectionConfig with the field at key removed |
| buildDefaultPath(name, format) | Generates a default path pattern for a collection (e.g. content/posts/**) |
Validators
import { validateFieldKey, generateFieldKey, validateCollectionName } from '@airdraft/ui-core'| Export | Description |
|---|---|
| validateFieldKey(key) | Returns { valid: boolean, error?: string }. Keys must match [a-zA-Z][a-zA-Z0-9_]*. |
| generateFieldKey(label) | Converts a human label to a valid snake_case field key (e.g. "Hero Image" → "hero_image"). |
| validateCollectionName(name) | Returns { valid: boolean, error?: string }. Rejects reserved names (schema, health, openapi, etc.). |
Constants
import { RESERVED_COLLECTION_NAMES } from '@airdraft/ui-core'RESERVED_COLLECTION_NAMES — string[] of names that cannot be used as collection names (schema, media, openapi, health, apply, collections).
Breaking change (v0.1.8):
RESERVED_COLLECTION_NAMESwas previously exported asSet<string>. It is now astring[]. Replace any.has(name)calls with.includes(name).
Changelog
See CHANGELOG.md.
