# `JsonPatchOp`

> Contract 2.0.0 · package sha256 `a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e` · generated from `configurator-runtime.d.ts` by `services/onsite-scripter/scripts/build-contract-docs.mjs`; edit the source, not this file.

Type · `import type { JsonPatchOp } from '@holostep-configurators/runtime-client/contract';` · stable · since 2.0.0 · section 5. Writers, transactions, session

RFC 6902 over [`SessionState`](SessionState.md). Paths are keyed, never array indexes (spec section 6.9).
[`applyPatch`](Writer.applyPatch.md) writes these:
- `/model/node/{nodeId}/{field}`: a scene-model node wherever it sits in the tree; `field` is
  a field of the stored node format or one the node already carries ('unknown-field'
  otherwise), and a `defaultNodeId` written here names one of its children, or is null or ''
  ('unknown-id' otherwise);
- `/model/node/{nodeId}/children` and `/model/root`: ordered lists of child `nodeId`s, replaced
  whole (insert, reorder and reparent are written this way);
- `/connections/{from.node}:{from.connector}`: a connection (split at the last ':'; a connector
  id never holds one);
- `/look/rules/{ruleId}`: a rule; `/look/ruleOrder/apply` and `/look/ruleOrder/find`: the rule
  ids of each block (spec section 6.10, R2), in order, replaced whole;
- `/checkpoint`: the page state.
The feed's entries, `inverse`s and dry-run patches also name these, which [`applyPatch`](Writer.applyPatch.md) refuses
at the call (a 'test' too) with HoloInputError 'invalid-input' whose `fix` names the member
that writes them:
- `/look/collections/{name}/items/{key}` (an item) and `/look/collections/{name}/order` (its
  item keys, in order): [`collection(name).set()`](Collection.set.md);
- `/look/collections/{name}/stage` (a collection's stage layer, [`CollectionSpec.stage`](CollectionSpec.stage.md), added
  when first written, removed when cleared) and `/look/stageOrder` (the stage layers' order,
  [`LookState.stageOrder`](LookState.stageOrder.md)): [`stage.set()`](Stage.set.md);
- `/look/materials/{name}`: [`apply({ materials })`](Writer.apply.md) or [`materials.create()`](Materials.create.md).
Undo an entry that touched them with [`session.history`](Session.history.md). `~1` escapes `/` as in RFC 6901.

## Declaration

```ts
export type JsonPatchOp = {
  op: 'add' | 'replace' | 'test';
  path: string;
  value: JsonValue;
} | {
  op: 'remove';
  path: string;
} | {
  op: 'move' | 'copy';
  from: string;
  path: string;
};
```

## Generic-API test (spec 3.1)

| Rule | Result |
| --- | --- |
| 1. Neutral name | pass: `JsonPatchOp` names no product |
| 2. A precedent | not recorded: no ledger row (coverage.json) names this member or its owner |
| 3. Two apps, or labs | not recorded: no ledger row names this member or its owner |
| 4. The cheaper fix first | not recorded per member (Appendix B decides it per need) |
