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).
Parameters
Section titled “Parameters”Input props.
document
Section titled “document”Record<string, unknown>
The saved document being duplicated, as returned
from vexConvexApi.get/find (a VexDocument/VexVersionDocument).
fields
Section titled “fields”Record<string, AdminField>
The source collection’s resolved fields map
(collection.fields, not yet flattened).
Returns
Section titled “Returns”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).
Throws
Section titled “Throws”Propagated from getDataFields if props.fields is
malformed (duplicate field key across tabs) — props.fields is assumed
to be an already-validated collection.fields.