Skip to contents

Validates and summarizes a plan for execution by zotExecute(). A row has action "patch", "create", or "trash"; a user or group library; an item key for patch and Trash rows; and a payload list.

Usage

zotPreview(plan, describe)

Arguments

plan

A data.table with columns action, library, itemKey, payload (list column).

describe

Text identifying the batch.

Value

A zotPreview: the plan, its canonical SHA-256 digest, counts and creation time.

Details

zotPreview() validates the plan, rejects unknown actions and recognized source labels, copies the rows, and calculates a digest from a canonical JSON representation. It does not contact Zotero.

Three rules protect the ledger and the write itself. A create row leaves itemKey as NA, because zotExecute() identifies a create by its position and a keyed create would make a resumed batch create the item again. An identified item appears once per library, because the ledger holds one entry per key and a repeated key would silently drop the second row. A payload carries no key or version field: zotPatch() sends the version as a conditional header, and a payload version is read back changed, which reports a successful write as failed.

Examples

Plan <- data.table::data.table(
  action = "patch", library = "user", itemKey = "ABCD1234",
  payload = list(list(title = "A reviewed title"))
)
Preview <- zotPreview(Plan, describe = "Correct one title")
Preview
#> <zotPreview> Correct one title 
#>   digest: 34f12497d5349ed6e1397c32f5bedfa29625bb9006ad73c5258cb4aa38f0a9b3 
#>    action library     N
#>    <char>  <char> <int>
#> 1:  patch    user     1