Client-safe foundation for MemberJunction Entity Record Cloning.
Overview
@memberjunction/record-cloning-base provides the core contracts, types, policy resolution, key classification, name templates, JSON remapping, and configuration validation for the record cloning subsystem.
It has zero database dependencies and no server-only dependencies, making it safe for use in both browser environments (such as Angular Explorer UI) and server environments (MJAPI).
Key Components
Contracts and Types (types.ts):
RecordCloneRequest, CloneRequestOptions
ClonePlan, ClonePlanNode, ClonePlanEdge
CloneFieldChange, CloneWarning, RecordCloneResult
Deterministic Plan Hash (ClonePlanHash.ts):
Builds the canonical form of a plan (nodes, edges, actions, field transformations; generated target keys ignored). The engine hashes it with SHA-256, so this package stays dependency-free.
Evaluates whether an edge is traversed as Deep, Reference, or Skip based on built-ins, database constraints, entity config, relationship config, presets, and request overrides.
Name Template Engine (NameTemplate.ts):
Formats copy names using tokens ({Name}, {n}, {Date}, {User}).
Unique Key Classifier (UniqueKeyClassifier.ts):
Categorizes single-column, parent-scoped, and live-state unique constraints.
JSON Remap Engine (JsonRemapEngine.ts):
Rewrites nested JSON documents and structures, with built-in presets (dashboard-ui-config, scheduled-job-configuration).
Field Mapping Pipeline (CloneFieldMapper.ts):
Pure, ordered field transformation pipeline (exclude, copy, reset, ownership, rename, FK and JSON remap, overrides, prompted values, rules).