Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@interactive-os/json-document-bulk-edit

Official headless JSONPath bulk editing extension for @interactive-os/json-document documents.

Use it when a product needs command-grade "replace all" or "delete all matches" behavior without putting query mutation commands in core: find/replace panels, batch cleanup tools, generated admin actions, CMS moderation queues, spreadsheet normalizers, or kanban maintenance commands.

import { createBulkEdit } from "@interactive-os/json-document-bulk-edit";

const bulk = createBulkEdit(doc);

bulk.replaceAll("$.items[*].done", true);
bulk.replaceAll("$.items[*].title", ({ value }) => String(value).trim());
bulk.deleteAll("$.items[?@.archived == true]", { label: "delete archived" });

Scope

  • Resolve JSONPath matches to unique JSON Pointers.
  • Read current matched values for mapper-based replacements.
  • Expose canReplaceAll / replaceAll.
  • Expose canDeleteAll / deleteAll.
  • Return the applied Pointer list and JSON Patch operations.
  • Pass optional document change metadata to doc.patch for command labels, origins, and merge keys.
  • Sort delete operations so nested paths and later array indexes are patched before earlier containers.

Non-goals

  • No search panel, replace dialog, confirmation UI, selection UI, or keyboard policy.
  • No product-specific command names.
  • No persistence, audit log, or undo label policy beyond forwarding caller metadata.
  • No stable identity lookup; host code owns id-to-pointer policy when needed.
  • No plugin registration; this package composes functions and does not call doc.use(...).
  • No @interactive-os/json-document internal imports.

Contract

@interactive-os/json-document-bulk-edit delegates to the public @interactive-os/json-document facade: canFind, query, at, canPatch, and patch.

Core remains the owner of JSONPath search and JSON Patch execution. This extension owns query-match batching and replace-all/delete-all command shaping.