ObjectStack Protocol & Specification - The Constitution of the ObjectStack Ecosystem
This package defines the core interfaces, schemas, and conventions for the ObjectStack ecosystem. It serves as the "Constitution" - the shared language that ObjectOS, ObjectStudio, ObjectCloud, and all third-party plugins use to communicate.
Guiding Principle: "Strict Types, No Logic"
This package contains:
- ✅ TypeScript Interfaces (Shared types)
- ✅ Zod Schemas (Validation rules with type inference)
- ✅ Constants (Convention configurations)
This package does NOT contain:
- ❌ Database connections
- ❌ UI components
- ❌ Runtime business logic
pnpm install @objectstack/specDefines the structure of a package configuration file. All packages (apps, plugins, drivers, modules) must conform to this schema.
import { ManifestSchema, type ObjectStackManifest } from '@objectstack/spec';
// Validate a manifest
const manifest: ObjectStackManifest = {
id: 'com.example.myapp',
version: '1.0.0',
type: 'plugin',
name: 'My App',
permissions: ['system.user.read'],
menus: [
{ label: 'Dashboard', path: '/dashboard', icon: 'home' }
]
};
// Validate with Zod
ManifestSchema.parse(manifest);Defines the contract that every plugin must implement to be loaded by ObjectOS.
import { ObjectStackPlugin, PluginContext } from '@objectstack/spec';
export default function createPlugin(): ObjectStackPlugin {
return {
async onInstall(ctx: PluginContext) {
ctx.logger.info('Plugin installed');
},
async onEnable(ctx: PluginContext) {
ctx.logger.info('Plugin enabled');
},
async onDisable(ctx: PluginContext) {
ctx.logger.info('Plugin disabled');
}
};
}Defines the "Law of Location" - where things must be in ObjectStack packages.
import { PKG_CONVENTIONS } from '@objectstack/spec';
console.log(PKG_CONVENTIONS.DIRS.SCHEMA); // 'src/schemas'
console.log(PKG_CONVENTIONS.DIRS.TRIGGERS); // 'src/triggers'
console.log(PKG_CONVENTIONS.FILES.MANIFEST); // 'objectstack.config.ts'ManifestSchema- Zod schema for package manifestsMenuItemSchema- Zod schema for menu itemsObjectStackManifest- TypeScript type for manifestsMenuItem- TypeScript type for menu items
ObjectStackPlugin- Plugin interface with lifecycle methodsPluginContext- Context provided to plugin methodsPluginFactory- Plugin factory function typePluginLogger- Logger interfaceObjectQLClient- Database client interfaceObjectOSKernel- OS kernel interface
PKG_CONVENTIONS- Directory and file conventionsPackageDirectory- Type for package directoriesPackageFile- Type for package files
# Install dependencies
pnpm install
# Build the project
pnpm run build
# Watch mode for development
pnpm run dev
# Clean build artifacts
pnpm run cleanThe 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
}pnpm 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'
};pnpm install
pnpm 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