The ObjectStack Protocol & Specification repository defines the core type definitions and interfaces for the ObjectStack ecosystem. This repository serves as the "Constitution" of the system, providing the contract between backend (ObjectQL) parsers and frontend (ObjectUI) renderers.
This repository contains:
- TypeScript Interfaces: Shared types for the entire ObjectStack ecosystem
- No Logic: Only type definitions, no runtime code or business logic
- Universal Compatibility: Works in Node.js, Browser, and Electron environments
The metamodel defines the structure for describing data models in ObjectStack:
Defines the available field data types:
- Text types:
text,textarea,email,url - Numeric types:
number,currency,percentage - Date/Time types:
date,datetime - Relation types:
lookup - Selection types:
select,multiselect - Special types:
boolean,json,file,image
Represents a field definition within an entity:
interface ObjectField {
name: string; // Field identifier
label: string; // Display label
type: FieldType; // Data type
required?: boolean; // Validation
unique?: boolean; // Constraint
lookupEntity?: string; // For lookup fields
// ... and more options
}Represents a complete entity (data model) definition:
interface ObjectEntity {
name: string; // Entity identifier
label: string; // Singular display label
pluralLabel: string; // Plural display label
fields: ObjectField[]; // Field definitions
primaryKey?: string; // Primary key field
displayField?: string; // Display field for lookups
// ... and more options
}Represents a view configuration for presenting entity data:
interface ObjectView {
name: string; // View identifier
label: string; // Display label
entityName: string; // Target entity
type: ViewType; // Presentation type (list, form, detail, etc.)
fields?: string[]; // Fields to display
columns?: ViewColumn[]; // Column configuration
filters?: ViewFilter[]; // Default filters
sort?: ViewSort[]; // Default sort order
// ... and more options
}npm install @objectstack/spec// Import all metamodel types
import { ObjectEntity, ObjectField, ObjectView, FieldType } from '@objectstack/spec';
// Or import specific types
import type { ObjectEntity } from '@objectstack/spec';import { ObjectEntity, ObjectField } from '@objectstack/spec';
const userEntity: ObjectEntity = {
name: 'User',
label: 'User',
pluralLabel: 'Users',
description: 'System user account',
fields: [
{
name: 'id',
label: 'ID',
type: 'text',
required: true,
readonly: true
},
{
name: 'email',
label: 'Email',
type: 'email',
required: true,
unique: true
},
{
name: 'name',
label: 'Full Name',
type: 'text',
required: true
},
{
name: 'role',
label: 'Role',
type: 'select',
required: true,
options: [
{ value: 'admin', label: 'Administrator' },
{ value: 'user', label: 'User' }
]
}
],
primaryKey: 'id',
displayField: 'name'
};npm install
npm run buildThis will compile TypeScript files to JavaScript and generate type declarations in the dist/ directory.
Following the ObjectStack Protocol:
- Strict Types, No Logic: This repository contains only type definitions
- Documentation as Code: Every interface property has TSDoc comments for IntelliSense
- Universal Compatibility: Pure TypeScript with no platform-specific dependencies
MIT