The foundation of the Quatrain framework. This package provides the base components for building business objects and defining data models. It works entirely in-memory and has no persistence dependencies.
BaseObject, AbstractObject, DataObject for in-memory object managementUser and Entity models with full property definitionscreated, pending, active, deleted)npm install @quatrain/core
# or
yarn add @quatrain/core
import { BaseObject, StringProperty, NumberProperty } from '@quatrain/core'
export class Product extends BaseObject {
static COLLECTION = 'products'
static PROPS_DEFINITION = [
{ name: 'name', type: StringProperty.TYPE, mandatory: true },
{ name: 'sku', type: StringProperty.TYPE, mandatory: true },
{ name: 'price', type: NumberProperty.TYPE, defaultValue: 0 },
]
}
const product = await Product.factory()
product._.name = 'My Awesome Product'
product._.sku = 'PROD-001'
product._.price = 29.99
console.log(product.isValid()) // true
console.log(product.toJSON()) // { name: 'My Awesome Product', sku: 'PROD-001', price: 29.99 }
| Property | Description | Example |
|---|---|---|
StringProperty |
Text values | Names, descriptions, SKUs |
NumberProperty |
Numeric values | Prices, quantities, ages |
BooleanProperty |
True/false values | Flags, toggles |
DateTimeProperty |
Timestamps | Created dates, due dates |
EnumProperty |
Predefined options | Status, category |
ArrayProperty |
Lists of values | Tags, related items |
ObjectProperty |
References to other objects | Author, parent |
FileProperty |
File references | Documents, images |
HashProperty |
Encrypted values | Passwords |
MapProperty |
Key-value pairs | Metadata, settings |
Objects follow a standard lifecycle with built-in status management:
created → pending → active → deleted
Access status via object.status and update using object.set('status', statuses.ACTIVE).
This package is designed to be the base layer with no external dependencies except logging. For persistence, combine with backend adapters:
@quatrain/backend-postgres - PostgreSQL/Supabase@quatrain/backend-firestore - Firebase Firestore@quatrain/backend-sqlite - SQLiteFor concrete examples and usage guides, please refer to the How-To Guide.
AGPL-3.0-only