Selegic CRM Docs
ServerDynamic Objects

Overview

Runtime-defined entities that allow tenants to create custom data structures without code deployments.

Dynamic Objects (also known as Custom Objects) enable Selegic CRM tenants to define their own data structures at runtime without requiring code deployments or Prisma migrations.

Core Philosophy

  • Multi-Tenancy: Data is strictly isolated per tenant using TenantPrisma transaction client
  • Runtime Validation: Entity definitions are converted to JSON Schemas for real-time request validation
  • Schema Discovery: Metadata service tracks fields, relationships, and types for every dynamic entity
  • Unified Pipeline: Dynamic operations share the same pipeline logic as standard CRUD

Key Components

ComponentFilePurpose
DynamicRepositoryservices/dynamic-repository.service.tsExecutes dynamic SQL/Prisma calls against tenant DB
ValidationServiceservices/validation.service.tsGenerates and caches JSON schemas
EntityMetadataServiceservices/entity-metadata.service.tsSource of truth for entity structures
OperationHandlerServiceservices/operation-handler.service.tsOrchestrates validation, hooks, flows, execution
FlowIntegrationServiceservices/flow-integration.service.tsRuns pre/post flows for automation

File Structure

features/dynamic-objects/
├── dynamic.routes.ts        # Hono routes for dynamic objects
├── factory.ts               # Dynamic service factory
├── hooks.ts                 # Dynamic hook registry
├── layers.ts                # Request-scoped layer composition
├── services/
│   ├── dynamic-repository.service.ts
│   ├── validation.service.ts
│   ├── entity-metadata.service.ts
│   ├── operation-handler.service.ts
│   ├── flow-integration.service.ts
│   ├── dynamic-hook.service.ts
│   └── audit-field.service.ts
├── types/
│   └── index.ts
└── tests/

Quick Navigation

How It Works

  1. Request arrives with tenant context (x-tenant-id)
  2. Entity lookup — Is this a static or dynamic model?
  3. Field metadata fetch — Get field definitions from Entity/Field tables
  4. Validation — Validate request body against cached JSON schema
  5. Execute — Run pre-flows, database operation, post-flows
  6. Response — Return result with computed formula fields

On this page