ObjectStackObjectStack

Object

Object protocol schemas

API Operations Enum

Source: packages/spec/src/data/object.zod.ts

TypeScript Usage

import { ApiMethod, Index, Lifecycle, LifecycleClass, Object, ObjectAccessConfig, ObjectCapabilities, ObjectExtension, ObjectExternalBinding, ObjectFieldGroup, ObjectOwnershipEnum, ObjectRequiredPermissions, PerOperationRequiredPermissions, RowCrudActionOverride, SoftDeleteConfig, TenancyConfig, VersioningConfig } from '@objectstack/spec/data';
import type { ApiMethod, Index, Lifecycle, LifecycleClass, Object, ObjectAccessConfig, ObjectCapabilities, ObjectExtension, ObjectExternalBinding, ObjectFieldGroup, ObjectOwnershipEnum, ObjectRequiredPermissions, PerOperationRequiredPermissions, RowCrudActionOverride, SoftDeleteConfig, TenancyConfig, VersioningConfig } from '@objectstack/spec/data';

// Validate data
const result = ApiMethod.parse(data);

ApiMethod

Allowed Values

  • get
  • list
  • create
  • update
  • delete
  • upsert
  • bulk
  • aggregate
  • history
  • search
  • restore
  • purge
  • import
  • export

Index

Properties

PropertyTypeRequiredDescription
namestringoptionalIndex name (auto-generated if not provided)
fieldsstring[]Fields included in the index
typeEnum<'btree' | 'hash' | 'gin' | 'gist' | 'fulltext'>Index algorithm type
uniquebooleanWhether the index enforces uniqueness
partialstringoptionalPartial index condition (SQL WHERE clause for conditional indexes)

Lifecycle

Properties

PropertyTypeRequiredDescription
classEnum<'record' | 'audit' | 'telemetry' | 'transient' | 'event'>Persistence contract: record (business truth, permanent) | audit (compliance ledger) | telemetry (high-freq log) | transient (ephemeral state) | event (bus messages).
retentionObjectoptionalAge-based retention window enforced by the LifecycleService Reaper.
ttlObjectoptionalPer-row TTL auto-expiry (transient/event classes).
storageObjectoptionalPhysical storage strategy for high-frequency telemetry (LifecycleService Rotator).
archiveObjectoptionalCold-store archival (LifecycleService Archiver) — audit-class hot→cold hand-off.
reclaimbooleanoptionalRun driver space reclamation (SQLite incremental_vacuum) after sweeping this object. Default true for non-record classes.

LifecycleClass

Allowed Values

  • record
  • audit
  • telemetry
  • transient
  • event

Object

Properties

PropertyTypeRequiredDescription
namestringMachine unique key (snake_case). Immutable.
labelstringoptionalHuman readable singular label (e.g. "Account")
pluralLabelstringoptionalHuman readable plural label (e.g. "Accounts")
descriptionstringoptionalDeveloper documentation / description
iconstringoptionalIcon name (Lucide/Material) for UI representation
tagsstring[]optionalCategorization tags (e.g. "sales", "system", "reference")
activebooleanoptionalIs the object active and usable
isSystembooleanoptionalIs system object (protected from deletion)
abstractbooleanoptionalIs abstract base object (cannot be instantiated)
managedByEnum<'platform' | 'config' | 'system' | 'append-only' | 'better-auth'>optionalLifecycle bucket — platform (user CRUD) | config (admin authored) | system (engine-managed) | append-only (audit) | better-auth (identity). UI clients honour the resolved affordance matrix.
userActionsObjectoptionalPer-object override of the resolved CRUD affordance matrix.
systemFieldsboolean | ObjectoptionalOpt out of, or selectively disable, registry-level system-field auto-injection.
datasourcestringoptionalTarget Datasource ID. "default" is the primary DB.
externalObjectoptionalRemote table binding for federated (external) objects.
fieldsRecord<string, Object>Field definitions map. Keys must be snake_case identifiers.
indexesObject[]optionalDatabase performance indexes
fieldGroupsObject[]optionalOrdered list of field groups (array order = display order). See ObjectFieldGroupSchema.
tenancyObjectoptionalMulti-tenancy configuration for SaaS applications
accessObjectoptional[ADR-0066 D2] Object exposure posture (public-by-default vs private secure-by-default).
requiredPermissionsstring[] | Objectoptional[ADR-0066 D3/⑤] Capabilities required to access this object (AND-gate) — string[] gates all CRUD, or a {read,create,update,delete} map gates per operation.
softDeleteObjectoptionalSoft delete (trash/recycle bin) configuration
versioningObjectoptionalRecord versioning and history tracking configuration
lifecycleObjectoptionalData lifecycle contract (ADR-0057): class + retention/ttl/rotation/archive policies enforced by the platform LifecycleService.
validations[__schema0](./__schema0)[]optionalObject-level validation rules
activityMilestonesObject[]optionalDeclarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2).
nameFieldstringoptional[ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). Pairs with recordName.
displayNameFieldstringoptional[DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField.
recordNameObjectoptionalRecord name generation configuration (Salesforce pattern)
titleFormatstring | Objectoptional[DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. Migrate a single-field title to nameField, a composite to a formula field designated as nameField.
highlightFieldsstring[]optional[ADR-0085] Ordered most-important fields; first entry wins where only one fits. Drives default columns, cards, previews, detail highlight strip. Renamed from compactLayout.
stageFieldstring | booleanoptional[ADR-0085] Lifecycle stage field (linear/ordered), or false to declare the status field non-linear and suppress stage heuristics. Absent = heuristic detection allowed.
listViewsRecord<string, Object>optionalBuilt-in named list views (segmented tabs) shipped with the object schema — "views" mode, dropdown userFilters allowed, no page-only tabs (ADR-0047)
searchableFieldsstring[]optionalFields the $search query matches against (ADR-0061). Canonical default for the record picker, list quick-search and global search; views may narrow it. When unset, search auto-defaults to the name/title field plus short-text fields.
searchObjectoptionalSearch engine configuration
enableObjectoptionalEnabled system features modules
sharingModelEnum<'private' | 'public_read' | 'public_read_write' | 'controlled_by_parent'>optionalOrg-Wide Default record visibility (OWD) for INTERNAL users. Canonical four only (legacy aliases removed, ADR-0090 D4): private (owner-only) | public_read (everyone reads, owner writes) | public_read_write (everyone reads+writes) | controlled_by_parent (derived from the master record). A CUSTOM object that omits this resolves to private at runtime (ADR-0090 D1).
externalSharingModelEnum<'private' | 'public_read' | 'public_read_write' | 'controlled_by_parent'>optional[ADR-0090 D11] OWD for external (portal/partner) principals. Defaults to private; must be <= sharingModel in openness.
publicSharingObjectoptionalPublic share-link policy (Notion/Figma-style link sharing)
keyPrefixstringoptionalShort prefix for record IDs (e.g., "001" for Account)
actionsObject[]optionalActions associated with this object (auto-populated from top-level actions via objectName)
protectionObjectoptionalPackage author protection block — lock policy for this object.
_lockEnum<'none' | 'no-overlay' | 'no-delete' | 'full'>optionalItem-level lock — controls overlay & delete (ADR-0010).
_lockReasonstringoptionalHuman-readable reason shown when a write is refused by _lock.
_lockSourceEnum<'artifact' | 'package' | 'env-forced'>optionalLayer that set _lock (artifact | package | env-forced).
_provenanceEnum<'package' | 'org' | 'env-forced'>optionalOrigin of the item (package | org | env-forced).
_packageIdstringoptionalOwning package machine id.
_packageVersionstringoptionalOwning package version.
_lockDocsUrlstringoptionalOptional documentation link surfaced next to _lockReason.

ObjectAccessConfig

Properties

PropertyTypeRequiredDescription
defaultEnum<'public' | 'private'>Default exposure posture: public (covered by wildcard grants) | private (needs explicit grant; exempt from wildcard RLS).

ObjectCapabilities

Properties

PropertyTypeRequiredDescription
trackHistorybooleanShow the record History tab (audit-trail UI). Pair with per-field trackHistory to pick which field diffs are summarized; audit capture itself is always on for compliance
searchablebooleanIndex records for global search
apiEnabledbooleanExpose object via automatic APIs
apiMethodsEnum<'get' | 'list' | 'create' | 'update' | 'delete' | 'upsert' | 'bulk' | 'aggregate' | 'history' | 'search' | 'restore' | 'purge' | 'import' | 'export'>[]optionalWhitelist of allowed API operations
filesbooleanGeneric record Attachments panel (sys_attachment). Opt-in: true surfaces the panel and permits attachments targeting this object; otherwise creation is rejected. Field.file/Field.image are independent
feedsbooleanRecord comments/collaboration feed. Default on; explicit false hides the feed UI and rejects new comments for this object
activitiesbooleanRecord activity timeline (sys_activity mirror of CRUD). Default on; explicit false stops mirroring and hides the timeline
trashbooleanEnable soft-delete with restore capability
mrubooleanTrack Most Recently Used (MRU) list for users
clonebooleanAllow record deep cloning

ObjectExtension

Properties

PropertyTypeRequiredDescription
extendstringTarget object name (FQN) to extend
fieldsRecord<string, Object>optionalFields to add/override
labelstringoptionalOverride label for the extended object
pluralLabelstringoptionalOverride plural label for the extended object
descriptionstringoptionalOverride description for the extended object
validations[__schema0](./__schema0)[]optionalAdditional validation rules to merge into the target object
indexesObject[]optionalAdditional indexes to merge into the target object
priorityintegeroptionalMerge priority (higher = applied later)

ObjectExternalBinding

External datasource binding (ADR-0015)

Properties

PropertyTypeRequiredDescription
remoteNamestringoptionalRemote table/view name. Defaults to object.name.
remoteSchemastringoptionalRemote schema/database qualifier.
writablebooleanPer-object write opt-in (also requires datasource.external.allowWrites).
columnMapRecord<string, string>optionalRemote column name → local field name.
introspectedAtstringoptionalSet by os datasource introspect; informational.
ignoreColumnsstring[]optionalRemote columns to skip during validation (dev convenience).

ObjectFieldGroup

Properties

PropertyTypeRequiredDescription
keystringGroup machine key (snake_case). Referenced by Field.group.
labelstringGroup display label
iconstringoptionalIcon name (Lucide/Material) for the group header
descriptionstringoptionalOptional description shown under the group header
collapseEnum<'none' | 'expanded' | 'collapsed'>[ADR-0085] Section collapse behaviour: 'none' (always open, no toggle), 'expanded' (collapsible, starts open), 'collapsed' (collapsible, starts closed).
defaultExpandedbooleanoptional[DEPRECATED → collapse] true → 'expanded', false → 'collapsed'.
collapsiblebooleanoptional[DEPRECATED → collapse] Boolean pair with collapsed; use the collapse enum.
collapsedbooleanoptional[DEPRECATED → collapse] Boolean pair with collapsible; use the collapse enum.

ObjectOwnershipEnum

Allowed Values

  • own
  • extend

ObjectRequiredPermissions

Union Options

This schema accepts one of the following structures:

Option 1

Type: string[]


Option 2

Properties

PropertyTypeRequiredDescription
readstring[]optionalCapabilities required to read (find/findOne/count/aggregate).
createstring[]optionalCapabilities required to create (insert).
updatestring[]optionalCapabilities required to update (update/transfer/restore).
deletestring[]optionalCapabilities required to delete (delete/purge).


PerOperationRequiredPermissions

Properties

PropertyTypeRequiredDescription
readstring[]optionalCapabilities required to read (find/findOne/count/aggregate).
createstring[]optionalCapabilities required to create (insert).
updatestring[]optionalCapabilities required to update (update/transfer/restore).
deletestring[]optionalCapabilities required to delete (delete/purge).

RowCrudActionOverride

Boolean-or-predicates override for a built-in row CRUD affordance.

Properties

PropertyTypeRequiredDescription
enabledbooleanoptionalObject-level on/off for the generic affordance; same meaning as the bare boolean form. Omitted → managedBy bucket default.
visibleWhenstring | ObjectoptionalPer-record CEL predicate; false → hide the row button for that record. Fail-closed.
disabledWhenstring | ObjectoptionalPer-record CEL predicate; true → render the row button disabled for that record. Fail-soft.

SoftDeleteConfig

Properties

PropertyTypeRequiredDescription
enabledbooleanEnable soft delete (trash/recycle bin)
fieldstringField name for soft delete timestamp
cascadeDeletebooleanCascade soft delete to related records

TenancyConfig

Properties

PropertyTypeRequiredDescription
enabledbooleanEnable multi-tenancy for this object
tenantFieldstringField name for tenant identifier

VersioningConfig

Properties

PropertyTypeRequiredDescription
enabledbooleanEnable record versioning
strategyEnum<'snapshot' | 'delta' | 'event-sourcing'>Versioning strategy: snapshot (full copy), delta (changes only), event-sourcing (event log)
retentionDaysnumberoptionalNumber of days to retain old versions (undefined = infinite)
versionFieldstringField name for version number/timestamp

On this page