JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1427
  • Score
    100M100P100Q92827F
  • License MIT

Core logic, types, and validation for Object UI. Zero React dependencies.

Package Exports

  • @object-ui/core

Readme

@object-ui/core

Core logic, types, and validation for Object UI. Zero React dependencies.

Features

  • 🎯 Type Definitions - Complete TypeScript schemas for all components
  • πŸ” Component Registry - Framework-agnostic component registration system
  • πŸ“Š Data Scope - Data scope management and expression evaluation
  • βœ… Validation - Zod-based schema validation
  • πŸš€ Zero React - Can run in Node.js or any JavaScript environment

Installation

npm install @object-ui/core

Usage

Type Definitions

import type { 
  PageSchema, 
  FormSchema, 
  InputSchema,
  BaseSchema 
} from '@object-ui/core'

const mySchema: PageSchema = {
  type: 'page',
  title: 'My Page',
  body: []
}

Component Registry

import { ComponentRegistry } from '@object-ui/core'

const registry = new ComponentRegistry()
registry.register('button', buttonMetadata)
const metadata = registry.get('button')

Data Scope

import { DataScope } from '@object-ui/core'

const scope = new DataScope({ 
  user: { name: 'John', role: 'admin' } 
})

const userName = scope.get('user.name') // 'John'
const isAdmin = scope.evaluate('${user.role === "admin"}') // true

System Views (defineView)

Schemas authored in source code are part of the product contract and must not be mutated at runtime. Wrap them with defineView() to deep-freeze the graph and tag it as a System View.

import { defineView, cloneAsOverride, isSystemView } from '@object-ui/core'

export const userListView = defineView({
  type: 'list',
  data: { object: 'User' },
  columns: [{ name: 'email' }],
})

userListView.columns.push({ name: 'name' }) // ❌ TypeError (strict mode)
isSystemView(userListView)                   // βœ… true

// To produce a Tenant- or User-level override, derive a mutable copy:
const draft = cloneAsOverride(userListView)
draft.columns.push({ name: 'name' })         // βœ… allowed
isSystemView(draft)                          // false β€” clone is no longer System

View tiers (recommended layering):

Tier Source Mutable? API
System View code (import / as const) ❌ frozen defineView()
Tenant View backend / DB ⚠️ admin only cloneAsOverride() + persist
User View localStorage / API βœ… user-editable cloneAsOverride() + persist

Date, RegExp, Map, Set, and class instances passed via props are intentionally not frozen so infrastructure objects keep working.

Philosophy

This package is designed to be framework-agnostic. It contains:

  • βœ… Pure TypeScript types and interfaces
  • βœ… Core logic and utilities
  • βœ… Validation schemas
  • ❌ NO React components
  • ❌ NO UI rendering logic
  • ❌ NO framework dependencies

This allows the core types and logic to be used in:

  • Build tools and CLI utilities
  • Backend validation
  • Code generators
  • Alternative framework adapters (Vue, Svelte, etc.)

API Reference

See full documentation for detailed API reference.

Compatibility

  • Node.js: β‰₯ 18
  • TypeScript: β‰₯ 5.0 (strict mode)
  • @objectstack/spec: ^3.3.0
  • @objectstack/client: ^3.3.0
  • Tailwind CSS: β‰₯ 3.4 (for packages with UI)

License

MIT β€” see LICENSE.