@datatechsolutions/shared-domain

v4.3.0

Published

Shared types, errors, and utilities for Datatech Solutions

Downloads

4,478

Readme

@datatechsolutions/shared-domain

Foundation library for the Datatech Solutions platform. Contains all domain types, error classes, database schemas, repositories, workflow engine, and shared utilities used by the platform applications (windsock, kori-erp, astrlabe).

Install

npm install @datatechsolutions/shared-domain

What's Inside

Domain Types (~50+)

Type definitions for all business entities: users, organizations, customers, products, invites, rules, agents, approvals, triggers, chat, subscriptions, workflows, metrics, and tools.

Error Classes (78)

Typed error hierarchy extending APIError. Categories: authentication (20), authorization (6), validation (7+), not-found (14), conflict (6+), business logic (12+), billing/Stripe (5+), server (9+), workflow (7).

import { StationNotFoundError, ValidationError } from '@datatechsolutions/shared-domain'

Repositories

Data access layer with base repository pattern and specialized repositories for each entity. All use Sequelize with PostgreSQL.

import { getDb, schema } from '@datatechsolutions/shared-domain'

Database Schemas

Sequelize + PostgreSQL with Row-Level Security:

  • kori-erp (src/erp/db/orm/): 14 tables — customers, products, sales, invoices, inventory, leads, tasks, users, organizations, etc.

Workflow Engine

Graph-based execution engine with 20 node executors in 5 phases:

| Phase | Executors | |-------|-----------| | 1 — Control Flow | start, end, if-else, list-operator, note, template-transform, variable-assigner, variable-aggregator | | 2 — Code & HTTP | code, http-request, answer | | 3 — AI | knowledge-base, parameter-extractor, question-classifier, document-extractor | | 4 — Containers | iteration, iteration-start | | 5 — Entities | agent, tool, rule |

import { executeGraph, NodeExecutorRegistry, WorkflowVariablePool } from '@datatechsolutions/shared-domain'

Utilities

Logger, AuditLogger, response helpers, error handler, date utilities, validation schemas (Zod), entity registry, plan pricing calculator, auth constants.

Entry Points

Use explicit bounded-context entrypoints instead of the root barrel.

| Import Path | Description | |-------------|-------------| | @datatechsolutions/shared-domain/common | Runtime-safe shared utilities/errors/constants | | @datatechsolutions/shared-domain/ports | Public ports namespace (all contexts) | | @datatechsolutions/shared-domain/ports/common | Cross-product date/time ports and helpers | | @datatechsolutions/shared-domain/ports/auth | Auth ports/JWT claims | | @datatechsolutions/shared-domain/ports/platform-core | Platform core ports | | @datatechsolutions/shared-domain/ports/workflow | Workflow ports | | @datatechsolutions/shared-domain/ports/erp | ERP ports | | @datatechsolutions/shared-domain/server/common | Shared server HTTP/auth helpers | | @datatechsolutions/shared-domain/server/auth | Auth server repositories/db | | @datatechsolutions/shared-domain/server/platform-core | Platform core server repositories/db | | @datatechsolutions/shared-domain/server/workflow | Workflow server repositories/db/engine | | @datatechsolutions/shared-domain/server/erp | ERP server exports | | @datatechsolutions/shared-domain/erp | ERP modules and types |

Scripts

| Script | Command | Description | |--------|---------|-------------| | build | tsc | Compile TypeScript to dist/ | | watch | tsc -w | Watch mode compilation | | clean | rm -rf dist | Remove build output | | test | vitest run | Run tests | | test:watch | vitest | Run tests in watch mode | | db:sync | npx sequelize-cli db:migrate | Sync schema to database | | db:generate | npx sequelize-cli migration:generate | Generate migration SQL | | db:migrate | npx sequelize-cli db:migrate | Run pending migrations |