Skip to content

cloneDocumentForDuplicate

cloneDocumentForDuplicate(props): Record<string, unknown>

Defined in: packages/core/src/documents/cloneDocumentForDuplicate.ts:70

Builds the payload for a duplicated document: the source document’s saved values, with every framework field stripped and every array/block item’s id regenerated so the clone shares no item identity with the original.

Decision 8 (spec.md): only framework fields are stripped — _id, _creationTime, updatedAt, and (versioned collections only) vex_status, vex_publishedAt, vex_publishedId, vex_activeVersion. Every other value, including unique fields like a slug, copies as-is; a unique-value conflict is resolved by the fallback create modal (Step 6, decision 7).

Input props.

Record<string, unknown>

The saved document being duplicated, as returned from vexConvexApi.get/find (a VexDocument/VexVersionDocument).

Record<string, AdminField>

The source collection’s resolved fields map (collection.fields, not yet flattened).

Record<string, unknown>

A plain object: props.document minus every framework field, with a fresh id on every array/block item at any nesting depth. Ready to pass as data to create() (Step 6).

Propagated from getDataFields if props.fields is malformed (duplicate field key across tabs) — props.fields is assumed to be an already-validated collection.fields.