🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@sanity/mutate

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/mutate - npm Package Compare versions

Comparing version
0.17.1
to
0.18.0
+2
-2
dist/_chunks-dts/types.d.ts

@@ -100,5 +100,5 @@ import { Q as Path, X as Index, Z as KeyedPathElement, st as Optional, tt as AnyArray } from "./index2.js";

};
type DeleteMutation = {
type DeleteMutation<Id extends string = string> = {
type: 'delete';
id: string;
id: Id;
};

@@ -105,0 +105,0 @@ type PatchMutation<Patches extends NodePatchList = NodePatchList> = {

@@ -1,1 +0,1 @@

{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/mutations/operations/types.ts","../../src/mutations/types.ts"],"mappings":";KAKY,KAAA;EACV,IAAA;EACA,KAAA,EAAO,CAAA;AAAA;AAAA,KAGG,OAAA;EACV,IAAA;AAAA;AAAA,KAGU,cAAA;EACV,IAAA;EACA,KAAA,EAAO,CAAA;AAAA;AAAA,KAGG,KAAA;EACV,IAAA;EACA,MAAA,EAAQ,MAAA;AAAA;AAAA,KAGE,KAAA;EACV,IAAA;EACA,MAAA,EAAQ,MAAA;AAAA;AAAA,KAGE,gBAAA;AAAA,KAEA,QAAA,eACI,QAAA,cACF,gBAAA,wBACU,KAAA,GAAQ,gBAAA;EAE9B,IAAA;EACA,aAAA,EAAe,aAAA;EACf,QAAA,EAAU,GAAA;EACV,KAAA,EAAO,KAAA;AAAA;AAAA,KAGG,UAAA;EACV,IAAA;EACA,UAAA;EACA,QAAA;AAAA;AAAA,KAGU,QAAA,uBAA+B,KAAA,GAAQ,gBAAA;EACjD,IAAA;EACA,aAAA,EAAe,aAAA;AAAA;AAAA,KAGL,SAAA,eACI,QAAA,wBACQ,KAAA,GAAQ,gBAAA;EAE9B,IAAA;EACA,aAAA,EAAe,aAAA;EACf,KAAA,EAAO,KAAA;AAAA;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A;EACA,KAAA;EACA,UAAA;EACA,UAAA;EACA,IAAA;AAAA;AAAA,UAGe,wBAAA,SAAiC,kBAAA;EAChD,GAAA;AAAA;AAAA,KAGU,cAAA,aAA2B,QAAA,CAAS,kBAAA;EAC9C,IAAA;EACA,QAAA,EAAU,GAAA;AAAA;AAAA,KAGA,yBAAA,aAAsC,kBAAA;EAChD,IAAA;EACA,QAAA,EAAU,GAAA;AAAA;AAAA,KAGA,uBAAA,aAAoC,kBAAA;EAC9C,IAAA;EACA,QAAA,EAAU,GAAA;AAAA;AAAA,KAGA,cAAA;EACV,IAAA;EACA,EAAA;AAAA;AAAA,KAGU,aAAA,iBAA8B,aAAA,GAAgB,aAAA;EACxD,IAAA;EACA,EAAA;EACA,OAAA,EAAS,OAAA;EACT,OAAA,GAAU,YAAA;AAAA;AAAA,KAGA,QAAA,aAAqB,kBAAA,UAC7B,cAAA,CAAe,GAAA,IACf,yBAAA,CAA0B,GAAA,IAC1B,uBAAA,CAAwB,GAAA,IACxB,cAAA,GACA,aAAA;AAAA,KAEQ,SAAA,WACA,IAAA,GAAO,IAAA,YACP,SAAA,GAAY,SAAA;EAEtB,IAAA,EAAM,CAAA;EACN,EAAA,EAAI,CAAA;AAAA;AAAA,KAGM,YAAA;EACV,UAAA;AAAA;AAAA,UAGe,WAAA;EACf,EAAA;EACA,SAAA,EAAW,QAAA;AAAA"}
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/mutations/operations/types.ts","../../src/mutations/types.ts"],"mappings":";KAKY,KAAA;EACV,IAAA;EACA,KAAA,EAAO,CAAA;AAAA;AAAA,KAGG,OAAA;EACV,IAAA;AAAA;AAAA,KAGU,cAAA;EACV,IAAA;EACA,KAAA,EAAO,CAAA;AAAA;AAAA,KAGG,KAAA;EACV,IAAA;EACA,MAAA,EAAQ,MAAA;AAAA;AAAA,KAGE,KAAA;EACV,IAAA;EACA,MAAA,EAAQ,MAAA;AAAA;AAAA,KAGE,gBAAA;AAAA,KAEA,QAAA,eACI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A;EACA,SAAA,EAAW,QAAA;AAAA"}

@@ -1,1 +0,1 @@

{"version":3,"file":"utils.js","sources":["../../src/apply/utils/getKeyOf.ts","../../src/apply/utils/array.ts","../../src/apply/utils/omit.ts","../../src/apply/patch/operations/array.ts","../../src/apply/patch/operations/common.ts","../../src/apply/patch/operations/number.ts","../../src/apply/utils/hasOwn.ts","../../src/apply/utils/isEmpty.ts","../../src/apply/patch/operations/object.ts","../../src/apply/patch/operations/string.ts","../../src/apply/patch/applyOp.ts","../../src/apply/patch/applyNodePatch.ts","../../src/apply/applyPatchMutation.ts","../../src/apply/store/utils.ts"],"sourcesContent":["export function keyOf(value: any): string | null {\n return (\n (value !== null &&\n typeof value === 'object' &&\n typeof value._key === 'string' &&\n value._key) ||\n null\n )\n}\n","import {isKeyedElement, type PathElement} from '../../path'\nimport {keyOf} from './getKeyOf'\n\nexport function findTargetIndex<T>(array: T[], pathSegment: PathElement) {\n if (typeof pathSegment === 'number') {\n return normalizeIndex(array.length, pathSegment)\n }\n if (isKeyedElement(pathSegment)) {\n const idx = array.findIndex(value => keyOf(value) === pathSegment._key)\n return idx === -1 ? null : idx\n }\n throw new Error(\n `Expected path segment to be addressing a single array item either by numeric index or by '_key'. Instead saw ${JSON.stringify(\n pathSegment,\n )}`,\n )\n}\n\nexport function getTargetIdx(position: 'before' | 'after', index: number) {\n return position === 'before' ? index : index + 1\n}\n\n// normalizes the index according to the array length\n// returns null if the normalized index is out of bounds\nexport function normalizeIndex(length: number, index: number) {\n if (length === 0 && (index === -1 || index === 0)) {\n return 0\n }\n const normalized = index < 0 ? length + index : index\n return normalized >= length || normalized < 0 ? null : normalized\n}\n\n// non-mutating splice\nexport function splice<T>(arr: T[], start: number, deleteCount: number): T[]\nexport function splice<T>(\n arr: T[],\n start: number,\n deleteCount: number,\n items: T[],\n): T[]\nexport function splice<T>(\n arr: T[],\n start: number,\n deleteCount: number,\n items?: T[],\n): T[] {\n const copy = arr.slice()\n copy.splice(start, deleteCount, ...(items || []))\n return copy\n}\n","export function omit<T, K extends keyof T>(val: T, props: K[]): Omit<T, K> {\n const copy = {...val}\n for (const prop of props) {\n delete copy[prop]\n }\n return copy\n}\n","import {\n type InsertIfMissingOp,\n type InsertOp,\n type KeyedPathElement,\n type RelativePosition,\n type RemoveOp,\n type ReplaceOp,\n type TruncateOp,\n type UpsertOp,\n} from '../../../mutations/operations/types'\nimport {findTargetIndex, getTargetIdx, splice} from '../../utils/array'\n\nexport function insert<\n O extends InsertOp<unknown[], RelativePosition, number | KeyedPathElement>,\n CurrentValue extends unknown[],\n>(op: O, currentValue: CurrentValue) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"insert()\" on non-array value')\n }\n\n const index = findTargetIndex(currentValue, op.referenceItem)\n if (index === null) {\n throw new Error(`Found no matching array element to insert ${op.position}`)\n }\n // special case for empty arrays\n if (currentValue.length === 0) {\n return op.items\n }\n return splice(currentValue, getTargetIdx(op.position, index), 0, op.items)\n}\n\nexport function upsert<\n O extends UpsertOp<{_key: string}[], RelativePosition, KeyedPathElement>,\n CurrentValue extends unknown[],\n>(op: O, currentValue: CurrentValue) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"upsert()\" on non-array value')\n }\n\n if (op.items.length === 0) {\n return currentValue\n }\n const replaceItemsMap: Record<number, number> = {}\n const insertItems: unknown[] = []\n op.items.forEach((itemToBeUpserted: any, i) => {\n const existingIndex = currentValue.findIndex(\n existingItem => (existingItem as any)?._key === itemToBeUpserted._key,\n )\n if (existingIndex >= 0) {\n replaceItemsMap[existingIndex] = i\n } else {\n insertItems.push(itemToBeUpserted)\n }\n })\n\n const itemsToReplace = Object.keys(replaceItemsMap)\n if (itemsToReplace.length === 0 && insertItems.length == 0) {\n return currentValue\n }\n\n const next = [...currentValue]\n // Replace existing items\n for (const i of itemsToReplace) {\n const index = Number(i)\n next[index] = op.items[replaceItemsMap[index]!]!\n }\n\n // Insert the items that doesn't exist\n return insert(\n {\n type: 'insert',\n items: insertItems,\n referenceItem: op.referenceItem,\n position: op.position,\n },\n next,\n )\n}\nexport function insertIfMissing<\n O extends InsertIfMissingOp<\n {_key: string}[],\n RelativePosition,\n KeyedPathElement\n >,\n CurrentValue extends unknown[],\n>(op: O, currentValue: CurrentValue) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"insertIfMissing()\" on non-array value')\n }\n\n if (op.items.length === 0) {\n return currentValue\n }\n const itemsToInsert = op.items.filter(\n item =>\n !currentValue.find(existing => item._key === (existing as any)?._key),\n )\n\n if (itemsToInsert.length === 0) {\n return currentValue\n }\n\n // Insert the items that doesn't exist\n return insert(\n {\n type: 'insert',\n items: itemsToInsert,\n referenceItem: op.referenceItem,\n position: op.position,\n },\n currentValue,\n )\n}\n\nexport function replace<\n O extends ReplaceOp<unknown[], number | KeyedPathElement>,\n CurrentValue extends unknown[],\n>(op: O, currentValue: CurrentValue) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"replace()\" on non-array value')\n }\n\n const index = findTargetIndex(currentValue, op.referenceItem)\n if (index === null) {\n throw new Error(`Found no matching array element to replace`)\n }\n return splice(currentValue, index, op.items.length, op.items)\n}\nexport function remove<\n O extends RemoveOp<number | KeyedPathElement>,\n CurrentValue extends unknown[],\n>(op: O, currentValue: CurrentValue) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"remove()\" on non-array value')\n }\n\n const index = findTargetIndex(currentValue, op.referenceItem)\n if (index === null) {\n throw new Error(`Found no matching array element to replace`)\n }\n return splice(currentValue, index, 1, [])\n}\n\nexport function truncate<O extends TruncateOp, CurrentValue extends unknown[]>(\n op: O,\n currentValue: CurrentValue,\n) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"truncate()\" on non-array value')\n }\n\n return typeof op.endIndex === 'number'\n ? currentValue\n .slice(0, op.startIndex)\n .concat(currentValue.slice(op.endIndex))\n : currentValue.slice(0, op.startIndex)\n}\n","import {\n type SetIfMissingOp,\n type SetOp,\n type UnsetOp,\n} from '../../../mutations/operations/types'\n\nexport function set<O extends SetOp<any>, CurrentValue>(\n op: O,\n currentValue: CurrentValue,\n) {\n return op.value\n}\n\nexport function setIfMissing<O extends SetIfMissingOp<any>, CurrentValue>(\n op: O,\n currentValue: CurrentValue,\n) {\n return currentValue ?? op.value\n}\n\nexport function unset<O extends UnsetOp, CurrentValue>(op: O) {\n return undefined\n}\n","import {type DecOp, type IncOp} from '../../../mutations/operations/types'\n\nexport function inc<O extends IncOp<number>, CurrentValue extends number>(\n op: O,\n currentValue: CurrentValue,\n) {\n if (typeof currentValue !== 'number') {\n throw new TypeError('Cannot apply \"inc()\" on non-numeric value')\n }\n\n return currentValue + op.amount\n}\n\nexport function dec<O extends DecOp<number>, CurrentValue extends number>(\n op: O,\n currentValue: CurrentValue,\n) {\n if (typeof currentValue !== 'number') {\n throw new TypeError('Cannot apply \"dec()\" on non-numeric value')\n }\n\n return currentValue - op.amount\n}\n","export const hasOwn = Object.prototype.hasOwnProperty.call.bind(\n Object.prototype.hasOwnProperty,\n)\n","import {hasOwn} from './hasOwn'\n\nexport function isEmpty(v: object) {\n for (const key in v) {\n if (hasOwn(v, key)) {\n return false\n }\n }\n return true\n}\n","import {\n type AssignOp,\n type UnassignOp,\n} from '../../../mutations/operations/types'\nimport {isObject} from '../../../utils/isObject'\nimport {isEmpty} from '../../utils/isEmpty'\nimport {omit} from '../../utils/omit'\n\nexport function unassign<T extends object, K extends string[]>(\n op: UnassignOp<K>,\n currentValue: T,\n) {\n if (!isObject(currentValue)) {\n throw new TypeError('Cannot apply \"unassign()\" on non-object value')\n }\n\n return op.keys.length === 0\n ? currentValue\n : omit(currentValue, op.keys as any[])\n}\n\nexport function assign<T extends object>(op: AssignOp<T>, currentValue: T) {\n if (!isObject(currentValue)) {\n throw new TypeError('Cannot apply \"assign()\" on non-object value')\n }\n\n return isEmpty(op.value) ? currentValue : {...currentValue, ...op.value}\n}\n","import {applyPatches, parsePatch} from '@sanity/diff-match-patch'\n\nimport {type DiffMatchPatchOp} from '../../../mutations/operations/types'\n\nexport function diffMatchPatch<\n O extends DiffMatchPatchOp,\n CurrentValue extends string,\n>(op: O, currentValue: CurrentValue) {\n if (typeof currentValue !== 'string') {\n throw new TypeError('Cannot apply \"diffMatchPatch()\" on non-string value')\n }\n\n return applyPatches(parsePatch(op.value), currentValue)[0]\n}\n","import {\n type AnyOp,\n type ArrayOp,\n type NumberOp,\n type ObjectOp,\n type Operation,\n type StringOp,\n} from '../../mutations/operations/types'\nimport {type AnyArray} from '../../utils/typeUtils'\nimport * as operations from './operations'\nimport {type ApplyOp} from './typings/applyOp'\n\nexport function applyOp<const Op extends AnyOp, const CurrentValue>(\n op: Op,\n currentValue: CurrentValue,\n): ApplyOp<Op, CurrentValue>\nexport function applyOp<\n const Op extends NumberOp,\n const CurrentValue extends number,\n>(op: Op, currentValue: CurrentValue): ApplyOp<Op, CurrentValue>\nexport function applyOp<\n const Op extends StringOp,\n const CurrentValue extends string,\n>(op: Op, currentValue: CurrentValue): ApplyOp<Op, CurrentValue>\nexport function applyOp<\n const Op extends ObjectOp,\n const CurrentValue extends {[k in keyof any]: unknown},\n>(op: Op, currentValue: CurrentValue): ApplyOp<Op, CurrentValue>\nexport function applyOp<\n const Op extends ArrayOp,\n const CurrentValue extends AnyArray,\n>(op: Op, currentValue: CurrentValue): ApplyOp<Op, CurrentValue>\nexport function applyOp<const Op extends Operation, const CurrentValue>(\n op: Op,\n currentValue: CurrentValue,\n): ApplyOp<Op, CurrentValue> {\n if (!(op.type in operations)) {\n throw new Error(`Invalid operation type: \"${op.type}\"`)\n }\n\n // eslint-disable-next-line import/namespace\n return (operations[op.type] as CallableFunction)(op, currentValue)\n}\n","import {type Operation} from '../../mutations/operations/types'\nimport {type NodePatch, type NodePatchList} from '../../mutations/types'\nimport {isArrayElement, isPropertyElement, stringify} from '../../path'\nimport {isObject} from '../../utils/isObject'\nimport {type NormalizeReadOnlyArray} from '../../utils/typeUtils'\nimport {type KeyedPathElement, type Path} from '../'\nimport {findTargetIndex, splice} from '../utils/array'\nimport {omit} from '../utils/omit'\nimport {applyOp} from './applyOp'\nimport {\n type ApplyAtPath,\n type ApplyNodePatch,\n type ApplyPatches,\n} from './typings/applyNodePatch'\n\nexport function applyPatches<Patches extends NodePatchList, const Doc>(\n patches: Patches,\n document: Doc,\n): ApplyPatches<NormalizeReadOnlyArray<Patches>, Doc> {\n return (patches as NodePatch[]).reduce(\n (prev, patch) => applyNodePatch(patch, prev) as any,\n document,\n ) as any\n}\n\nexport function applyNodePatch<const Patch extends NodePatch, const Doc>(\n patch: Patch,\n document: Doc,\n): ApplyNodePatch<Patch, Doc> {\n return applyAtPath(patch.path, patch.op, document) as any\n}\n\nfunction applyAtPath<P extends Path, O extends Operation, T>(\n path: P,\n op: O,\n value: T,\n): ApplyAtPath<P, O, T> {\n if (!isNonEmptyArray(path)) {\n return applyOp(op as any, value) as any\n }\n\n const [head, ...tail] = path\n\n if (isArrayElement(head) && Array.isArray(value)) {\n return applyInArray(head, tail, op, value) as any\n }\n\n if (isPropertyElement(head) && isObject(value)) {\n return applyInObject(head, tail, op, value) as any\n }\n\n throw new Error(\n `Cannot apply operation of type \"${op.type}\" to path ${stringify(\n path,\n )} on ${typeof value} value`,\n )\n}\n\nfunction applyInObject<Key extends keyof any, T extends {[key in Key]?: any}>(\n head: Key,\n tail: Path,\n op: Operation,\n object: T,\n) {\n const current = object[head]\n\n if (current === undefined && tail.length > 0) {\n return object\n }\n\n // The patch targets the item at the index specified by \"head\"\n // so forward it to the item\n const patchedValue = applyAtPath(tail, op, current)\n\n if (patchedValue === undefined) {\n // unset op on an object field should not leave the field undefined\n // eg. apply(at('bar', unset()), {foo: 1, bar: 2, baz: 3} should result in\n // {foo: 1, baz: 3}, not {foo: 1, bar: undefined, baz: 3}\n\n return omit(object, [head])\n }\n // If the result of applying it to the item yields the item back we assume it was\n // a noop and don't modify our value. If we get a new value back, we return a\n // new array with the modified item replaced\n return patchedValue === current ? object : {...object, [head]: patchedValue}\n}\n\nfunction applyInArray<T>(\n head: number | KeyedPathElement,\n tail: Path,\n op: Operation,\n value: T[],\n) {\n const index = findTargetIndex(value, head!)\n\n if (index === null) {\n // partial is default behavior for arrays\n // the patch targets an index that is out of bounds\n return value\n }\n\n // If the given selector could not be found, return as-is\n if (index === -1) {\n return value\n }\n\n const current = value[index]!\n\n // The patch targets the item at the index specified by \"head\"\n // so forward it to the item\n const patchedItem = applyAtPath(tail, op, current)\n\n // If the result of applying it to the item yields the item back we assume it was\n // a noop and don't modify our value. If we get a new value back, we return a\n // new array with the modified item replaced\n return patchedItem === current\n ? value\n : splice(\n value,\n index,\n 1,\n // unset op on an array item should not leave a \"hole\" in the array\n // eg. apply(at('someArray[1]', unset()), ['foo', 'bar', 'baz'] should result in\n // ['foo', 'baz'], not ['foo', undefined, 'baz']\n patchedItem === undefined ? [] : [patchedItem],\n )\n}\n\nfunction isNonEmptyArray<T>(a: T[] | readonly T[]): a is [T, ...T[]] {\n return a.length > 0\n}\n","import {type PatchMutation, type SanityDocumentBase} from '../mutations/types'\nimport {type NormalizeReadOnlyArray} from '../utils/typeUtils'\nimport {applyPatches} from './patch/applyNodePatch'\nimport {type ApplyPatches} from './patch/typings/applyNodePatch'\n\nexport type ApplyPatchMutation<\n Mutation extends PatchMutation,\n Doc extends SanityDocumentBase,\n> =\n Mutation extends PatchMutation<infer Patches>\n ? ApplyPatches<NormalizeReadOnlyArray<Patches>, Doc>\n : Doc\n\nexport function applyPatchMutation<\n const Mutation extends PatchMutation,\n const Doc extends SanityDocumentBase,\n>(mutation: Mutation, document: Doc): ApplyPatchMutation<Mutation, Doc> {\n if (\n mutation.options?.ifRevision &&\n document._rev !== mutation.options.ifRevision\n ) {\n throw new Error('Revision mismatch')\n }\n if (mutation.id !== document._id) {\n throw new Error(\n `Document id mismatch. Refusing to apply mutation for document with id=\"${mutation.id}\" on the given document with id=\"${document._id}\"`,\n )\n }\n return applyPatches(mutation.patches, document) as any\n}\n","import {type SanityDocumentBase} from '../../mutations/types'\nimport {type StoredDocument} from '../applyInIndex'\n\nexport function hasId(doc: SanityDocumentBase): doc is StoredDocument {\n return '_id' in doc\n}\nexport function assignId<Doc extends SanityDocumentBase>(\n doc: Doc,\n generateId: () => string,\n): Doc & {_id: string} {\n return hasId(doc) ? doc : {...doc, _id: generateId()}\n}\n"],"names":["applyPatches"],"mappings":";;;AAAO,SAAS,MAAM,OAA2B;AAC/C,SACG,UAAU,QACT,OAAO,SAAU,YACjB,OAAO,MAAM,QAAS,YACtB,MAAM,QACR;AAEJ;ACLO,SAAS,gBAAmB,OAAY,aAA0B;AACvE,MAAI,OAAO,eAAgB;AACzB,WAAO,eAAe,MAAM,QAAQ,WAAW;AAEjD,MAAI,eAAe,WAAW,GAAG;AAC/B,UAAM,MAAM,MAAM,UAAU,CAAA,UAAS,MAAM,KAAK,MAAM,YAAY,IAAI;AACtE,WAAO,QAAQ,KAAK,OAAO;AAAA,EAC7B;AACA,QAAM,IAAI;AAAA,IACR,gHAAgH,KAAK;AAAA,MACnH;AAAA,IAAA,CACD;AAAA,EAAA;AAEL;AAEO,SAAS,aAAa,UAA8B,OAAe;AACxE,SAAO,aAAa,WAAW,QAAQ,QAAQ;AACjD;AAIO,SAAS,eAAe,QAAgB,OAAe;AAC5D,MAAI,WAAW,MAAM,UAAU,MAAM,UAAU;AAC7C,WAAO;AAET,QAAM,aAAa,QAAQ,IAAI,SAAS,QAAQ;AAChD,SAAO,cAAc,UAAU,aAAa,IAAI,OAAO;AACzD;AAUO,SAAS,OACd,KACA,OACA,aACA,OACK;AACL,QAAM,OAAO,IAAI,MAAA;AACjB,SAAA,KAAK,OAAO,OAAO,aAAa,GAAI,SAAS,CAAA,CAAG,GACzC;AACT;ACjDO,SAAS,KAA2B,KAAQ,OAAwB;AACzE,QAAM,OAAO,EAAC,GAAG,IAAA;AACjB,aAAW,QAAQ;AACjB,WAAO,KAAK,IAAI;AAElB,SAAO;AACT;ACMO,SAAS,OAGd,IAAO,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ACtE,MACE,SAAS,SAAS,cAClB,SAAS,SAAS,SAAS,QAAQ;AAEnC,UAAM,IAAI,MAAM,mBAAmB;AAErC,MAAI,SAAS,OAAO,SAAS;AAC3B,UAAM,IAAI;AAAA,MACR,0EAA0E,SAAS,EAAE,oCAAoC,SAAS,GAAG;AAAA,IAAA;AAGzI,SAAO,aAAa,SAAS,SAAS,QAAQ;AAChD;AC1BO,SAAS,MAAM,KAAgD;AACpE,SAAO,SAAS;AAClB;AACO,SAAS,SACd,KACA,YACqB;AACrB,SAAO,MAAM,GAAG,IAAI,MAAM,EAAC,GAAG,KAAK,KAAK,aAAW;AACrD;"}
{"version":3,"file":"utils.js","sources":["../../src/apply/utils/getKeyOf.ts","../../src/apply/utils/array.ts","../../src/apply/utils/omit.ts","../../src/apply/patch/operations/array.ts","../../src/apply/patch/operations/common.ts","../../src/apply/patch/operations/number.ts","../../src/apply/utils/hasOwn.ts","../../src/apply/utils/isEmpty.ts","../../src/apply/patch/operations/object.ts","../../src/apply/patch/operations/string.ts","../../src/apply/patch/applyOp.ts","../../src/apply/patch/applyNodePatch.ts","../../src/apply/applyPatchMutation.ts","../../src/apply/store/utils.ts"],"sourcesContent":["export function keyOf(value: any): string | null {\n return (\n (value !== null &&\n typeof value === 'object' &&\n typeof value._key === 'string' &&\n value._key) ||\n null\n )\n}\n","import {isKeyedElement, type PathElement} from '../../path'\nimport {keyOf} from './getKeyOf'\n\nexport function findTargetIndex<T>(array: T[], pathSegment: PathElement) {\n if (typeof pathSegment === 'number') {\n return normalizeIndex(array.length, pathSegment)\n }\n if (isKeyedElement(pathSegment)) {\n const idx = array.findIndex(value => keyOf(value) === pathSegment._key)\n return idx === -1 ? null : idx\n }\n throw new Error(\n `Expected path segment to be addressing a single array item either by numeric index or by '_key'. Instead saw ${JSON.stringify(\n pathSegment,\n )}`,\n )\n}\n\nexport function getTargetIdx(position: 'before' | 'after', index: number) {\n return position === 'before' ? index : index + 1\n}\n\n// normalizes the index according to the array length\n// returns null if the normalized index is out of bounds\nexport function normalizeIndex(length: number, index: number) {\n if (length === 0 && (index === -1 || index === 0)) {\n return 0\n }\n const normalized = index < 0 ? length + index : index\n return normalized >= length || normalized < 0 ? null : normalized\n}\n\n// non-mutating splice\nexport function splice<T>(\n arr: readonly T[],\n start: number,\n deleteCount: number,\n): T[]\nexport function splice<T>(\n arr: readonly T[],\n start: number,\n deleteCount: number,\n items: readonly T[],\n): T[]\nexport function splice<T>(\n arr: readonly T[],\n start: number,\n deleteCount: number,\n items?: readonly T[],\n): T[] {\n const copy = arr.slice()\n copy.splice(start, deleteCount, ...(items || []))\n return copy\n}\n","export function omit<T, K extends keyof T>(val: T, props: K[]): Omit<T, K> {\n const copy = {...val}\n for (const prop of props) {\n delete copy[prop]\n }\n return copy\n}\n","import {\n type InsertIfMissingOp,\n type InsertOp,\n type KeyedPathElement,\n type RelativePosition,\n type RemoveOp,\n type ReplaceOp,\n type TruncateOp,\n type UpsertOp,\n} from '../../../mutations/operations/types'\nimport {findTargetIndex, getTargetIdx, splice} from '../../utils/array'\n\nexport function insert<\n O extends InsertOp<unknown[], RelativePosition, number | KeyedPathElement>,\n CurrentValue extends unknown[],\n>(op: O, currentValue: CurrentValue) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"insert()\" on non-array value')\n }\n\n const index = findTargetIndex(currentValue, op.referenceItem)\n if (index === null) {\n throw new Error(`Found no matching array element to insert ${op.position}`)\n }\n // special case for empty arrays\n if (currentValue.length === 0) {\n return op.items\n }\n return splice(currentValue, getTargetIdx(op.position, index), 0, op.items)\n}\n\nexport function upsert<\n O extends UpsertOp<{_key: string}[], RelativePosition, KeyedPathElement>,\n CurrentValue extends unknown[],\n>(op: O, currentValue: CurrentValue) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"upsert()\" on non-array value')\n }\n\n if (op.items.length === 0) {\n return currentValue\n }\n const replaceItemsMap: Record<number, number> = {}\n const insertItems: unknown[] = []\n op.items.forEach((itemToBeUpserted: any, i) => {\n const existingIndex = currentValue.findIndex(\n existingItem => (existingItem as any)?._key === itemToBeUpserted._key,\n )\n if (existingIndex >= 0) {\n replaceItemsMap[existingIndex] = i\n } else {\n insertItems.push(itemToBeUpserted)\n }\n })\n\n const itemsToReplace = Object.keys(replaceItemsMap)\n if (itemsToReplace.length === 0 && insertItems.length == 0) {\n return currentValue\n }\n\n const next = [...currentValue]\n // Replace existing items\n for (const i of itemsToReplace) {\n const index = Number(i)\n next[index] = op.items[replaceItemsMap[index]!]!\n }\n\n // Insert the items that doesn't exist\n return insert(\n {\n type: 'insert',\n items: insertItems,\n referenceItem: op.referenceItem,\n position: op.position,\n },\n next,\n )\n}\nexport function insertIfMissing<\n O extends InsertIfMissingOp<\n {_key: string}[],\n RelativePosition,\n KeyedPathElement\n >,\n CurrentValue extends unknown[],\n>(op: O, currentValue: CurrentValue) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"insertIfMissing()\" on non-array value')\n }\n\n if (op.items.length === 0) {\n return currentValue\n }\n const itemsToInsert = op.items.filter(\n item =>\n !currentValue.find(existing => item._key === (existing as any)?._key),\n )\n\n if (itemsToInsert.length === 0) {\n return currentValue\n }\n\n // Insert the items that doesn't exist\n return insert(\n {\n type: 'insert',\n items: itemsToInsert,\n referenceItem: op.referenceItem,\n position: op.position,\n },\n currentValue,\n )\n}\n\nexport function replace<\n O extends ReplaceOp<unknown[], number | KeyedPathElement>,\n CurrentValue extends unknown[],\n>(op: O, currentValue: CurrentValue) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"replace()\" on non-array value')\n }\n\n const index = findTargetIndex(currentValue, op.referenceItem)\n if (index === null) {\n throw new Error(`Found no matching array element to replace`)\n }\n return splice(currentValue, index, op.items.length, op.items)\n}\nexport function remove<\n O extends RemoveOp<number | KeyedPathElement>,\n CurrentValue extends unknown[],\n>(op: O, currentValue: CurrentValue) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"remove()\" on non-array value')\n }\n\n const index = findTargetIndex(currentValue, op.referenceItem)\n if (index === null) {\n throw new Error(`Found no matching array element to replace`)\n }\n return splice(currentValue, index, 1, [])\n}\n\nexport function truncate<O extends TruncateOp, CurrentValue extends unknown[]>(\n op: O,\n currentValue: CurrentValue,\n) {\n if (!Array.isArray(currentValue)) {\n throw new TypeError('Cannot apply \"truncate()\" on non-array value')\n }\n\n return typeof op.endIndex === 'number'\n ? currentValue\n .slice(0, op.startIndex)\n .concat(currentValue.slice(op.endIndex))\n : currentValue.slice(0, op.startIndex)\n}\n","import {\n type SetIfMissingOp,\n type SetOp,\n type UnsetOp,\n} from '../../../mutations/operations/types'\n\nexport function set<O extends SetOp<any>, CurrentValue>(\n op: O,\n currentValue: CurrentValue,\n) {\n return op.value\n}\n\nexport function setIfMissing<O extends SetIfMissingOp<any>, CurrentValue>(\n op: O,\n currentValue: CurrentValue,\n) {\n return currentValue ?? op.value\n}\n\nexport function unset<O extends UnsetOp, CurrentValue>(op: O) {\n return undefined\n}\n","import {type DecOp, type IncOp} from '../../../mutations/operations/types'\n\nexport function inc<O extends IncOp<number>, CurrentValue extends number>(\n op: O,\n currentValue: CurrentValue,\n) {\n if (typeof currentValue !== 'number') {\n throw new TypeError('Cannot apply \"inc()\" on non-numeric value')\n }\n\n return currentValue + op.amount\n}\n\nexport function dec<O extends DecOp<number>, CurrentValue extends number>(\n op: O,\n currentValue: CurrentValue,\n) {\n if (typeof currentValue !== 'number') {\n throw new TypeError('Cannot apply \"dec()\" on non-numeric value')\n }\n\n return currentValue - op.amount\n}\n","export const hasOwn = Object.prototype.hasOwnProperty.call.bind(\n Object.prototype.hasOwnProperty,\n)\n","import {hasOwn} from './hasOwn'\n\nexport function isEmpty(v: object) {\n for (const key in v) {\n if (hasOwn(v, key)) {\n return false\n }\n }\n return true\n}\n","import {\n type AssignOp,\n type UnassignOp,\n} from '../../../mutations/operations/types'\nimport {isObject} from '../../../utils/isObject'\nimport {isEmpty} from '../../utils/isEmpty'\nimport {omit} from '../../utils/omit'\n\nexport function unassign<T extends object, K extends string[]>(\n op: UnassignOp<K>,\n currentValue: T,\n) {\n if (!isObject(currentValue)) {\n throw new TypeError('Cannot apply \"unassign()\" on non-object value')\n }\n\n return op.keys.length === 0\n ? currentValue\n : omit(currentValue, op.keys as any[])\n}\n\nexport function assign<T extends object>(op: AssignOp<T>, currentValue: T) {\n if (!isObject(currentValue)) {\n throw new TypeError('Cannot apply \"assign()\" on non-object value')\n }\n\n return isEmpty(op.value) ? currentValue : {...currentValue, ...op.value}\n}\n","import {applyPatches, parsePatch} from '@sanity/diff-match-patch'\n\nimport {type DiffMatchPatchOp} from '../../../mutations/operations/types'\n\nexport function diffMatchPatch<\n O extends DiffMatchPatchOp,\n CurrentValue extends string,\n>(op: O, currentValue: CurrentValue) {\n if (typeof currentValue !== 'string') {\n throw new TypeError('Cannot apply \"diffMatchPatch()\" on non-string value')\n }\n\n return applyPatches(parsePatch(op.value), currentValue)[0]\n}\n","import {\n type AnyOp,\n type ArrayOp,\n type NumberOp,\n type ObjectOp,\n type Operation,\n type StringOp,\n} from '../../mutations/operations/types'\nimport {type AnyArray} from '../../utils/typeUtils'\nimport * as operations from './operations'\nimport {type ApplyOp} from './typings/applyOp'\n\nexport function applyOp<const Op extends AnyOp, const CurrentValue>(\n op: Op,\n currentValue: CurrentValue,\n): ApplyOp<Op, CurrentValue>\nexport function applyOp<\n const Op extends NumberOp,\n const CurrentValue extends number,\n>(op: Op, currentValue: CurrentValue): ApplyOp<Op, CurrentValue>\nexport function applyOp<\n const Op extends StringOp,\n const CurrentValue extends string,\n>(op: Op, currentValue: CurrentValue): ApplyOp<Op, CurrentValue>\nexport function applyOp<\n const Op extends ObjectOp,\n const CurrentValue extends {[k in keyof any]: unknown},\n>(op: Op, currentValue: CurrentValue): ApplyOp<Op, CurrentValue>\nexport function applyOp<\n const Op extends ArrayOp,\n const CurrentValue extends AnyArray,\n>(op: Op, currentValue: CurrentValue): ApplyOp<Op, CurrentValue>\nexport function applyOp<const Op extends Operation, const CurrentValue>(\n op: Op,\n currentValue: CurrentValue,\n): ApplyOp<Op, CurrentValue> {\n if (!(op.type in operations)) {\n throw new Error(`Invalid operation type: \"${op.type}\"`)\n }\n\n // eslint-disable-next-line import/namespace\n return (operations[op.type] as CallableFunction)(op, currentValue)\n}\n","import {type Operation} from '../../mutations/operations/types'\nimport {type NodePatch, type NodePatchList} from '../../mutations/types'\nimport {isArrayElement, isPropertyElement, stringify} from '../../path'\nimport {isObject} from '../../utils/isObject'\nimport {type NormalizeReadOnlyArray} from '../../utils/typeUtils'\nimport {type KeyedPathElement, type Path} from '../'\nimport {findTargetIndex, splice} from '../utils/array'\nimport {omit} from '../utils/omit'\nimport {applyOp} from './applyOp'\nimport {\n type ApplyAtPath,\n type ApplyNodePatch,\n type ApplyPatches,\n} from './typings/applyNodePatch'\n\nexport function applyPatches<Patches extends NodePatchList, const Doc>(\n patches: Patches,\n document: Doc,\n): ApplyPatches<NormalizeReadOnlyArray<Patches>, Doc> {\n return (patches as NodePatch[]).reduce(\n (prev, patch) => applyNodePatch(patch, prev) as any,\n document,\n ) as any\n}\n\nexport function applyNodePatch<const Patch extends NodePatch, const Doc>(\n patch: Patch,\n document: Doc,\n): ApplyNodePatch<Patch, Doc> {\n return applyAtPath(patch.path, patch.op, document) as any\n}\n\nfunction applyAtPath<P extends Path, O extends Operation, T>(\n path: P,\n op: O,\n value: T,\n): ApplyAtPath<P, O, T> {\n if (!isNonEmptyArray(path)) {\n return applyOp(op as any, value) as any\n }\n\n const [head, ...tail] = path\n\n if (isArrayElement(head) && Array.isArray(value)) {\n return applyInArray(head, tail, op, value) as any\n }\n\n if (isPropertyElement(head) && isObject(value)) {\n return applyInObject(head, tail, op, value) as any\n }\n\n throw new Error(\n `Cannot apply operation of type \"${op.type}\" to path ${stringify(\n path,\n )} on ${typeof value} value`,\n )\n}\n\nfunction applyInObject<Key extends keyof any, T extends {[key in Key]?: any}>(\n head: Key,\n tail: Path,\n op: Operation,\n object: T,\n) {\n const current = object[head]\n\n if (current === undefined && tail.length > 0) {\n return object\n }\n\n // The patch targets the item at the index specified by \"head\"\n // so forward it to the item\n const patchedValue = applyAtPath(tail, op, current)\n\n if (patchedValue === undefined) {\n // unset op on an object field should not leave the field undefined\n // eg. apply(at('bar', unset()), {foo: 1, bar: 2, baz: 3} should result in\n // {foo: 1, baz: 3}, not {foo: 1, bar: undefined, baz: 3}\n\n return omit(object, [head])\n }\n // If the result of applying it to the item yields the item back we assume it was\n // a noop and don't modify our value. If we get a new value back, we return a\n // new array with the modified item replaced\n return patchedValue === current ? object : {...object, [head]: patchedValue}\n}\n\nfunction applyInArray<T>(\n head: number | KeyedPathElement,\n tail: Path,\n op: Operation,\n value: T[],\n) {\n const index = findTargetIndex(value, head!)\n\n if (index === null) {\n // partial is default behavior for arrays\n // the patch targets an index that is out of bounds\n return value\n }\n\n // If the given selector could not be found, return as-is\n if (index === -1) {\n return value\n }\n\n const current = value[index]!\n\n // The patch targets the item at the index specified by \"head\"\n // so forward it to the item\n const patchedItem = applyAtPath(tail, op, current)\n\n // If the result of applying it to the item yields the item back we assume it was\n // a noop and don't modify our value. If we get a new value back, we return a\n // new array with the modified item replaced\n return patchedItem === current\n ? value\n : splice(\n value,\n index,\n 1,\n // unset op on an array item should not leave a \"hole\" in the array\n // eg. apply(at('someArray[1]', unset()), ['foo', 'bar', 'baz'] should result in\n // ['foo', 'baz'], not ['foo', undefined, 'baz']\n patchedItem === undefined ? [] : [patchedItem],\n )\n}\n\nfunction isNonEmptyArray<T>(a: T[] | readonly T[]): a is [T, ...T[]] {\n return a.length > 0\n}\n","import {type PatchMutation, type SanityDocumentBase} from '../mutations/types'\nimport {type NormalizeReadOnlyArray} from '../utils/typeUtils'\nimport {applyPatches} from './patch/applyNodePatch'\nimport {type ApplyPatches} from './patch/typings/applyNodePatch'\n\nexport type ApplyPatchMutation<\n Mutation extends PatchMutation,\n Doc extends SanityDocumentBase,\n> =\n Mutation extends PatchMutation<infer Patches>\n ? ApplyPatches<NormalizeReadOnlyArray<Patches>, Doc>\n : Doc\n\nexport function applyPatchMutation<\n const Mutation extends PatchMutation,\n const Doc extends SanityDocumentBase,\n>(mutation: Mutation, document: Doc): ApplyPatchMutation<Mutation, Doc> {\n if (\n mutation.options?.ifRevision &&\n document._rev !== mutation.options.ifRevision\n ) {\n throw new Error('Revision mismatch')\n }\n if (mutation.id !== document._id) {\n throw new Error(\n `Document id mismatch. Refusing to apply mutation for document with id=\"${mutation.id}\" on the given document with id=\"${document._id}\"`,\n )\n }\n return applyPatches(mutation.patches, document) as any\n}\n","import {type SanityDocumentBase} from '../../mutations/types'\nimport {type StoredDocument} from '../applyInIndex'\n\nexport function hasId(doc: SanityDocumentBase): doc is StoredDocument {\n return '_id' in doc\n}\nexport function assignId<Doc extends SanityDocumentBase>(\n doc: Doc,\n generateId: () => string,\n): Doc & {_id: string} {\n return hasId(doc) ? doc : {...doc, _id: generateId()}\n}\n"],"names":["applyPatches"],"mappings":";;;AAAO,SAAS,MAAM,OAA2B;AAC/C,SACG,UAAU,QACT,OAAO,SAAU,YACjB,OAAO,MAAM,QAAS,YACtB,MAAM,QACR;AAEJ;ACLO,SAAS,gBAAmB,OAAY,aAA0B;AACvE,MAAI,OAAO,eAAgB;AACzB,WAAO,eAAe,MAAM,QAAQ,WAAW;AAEjD,MAAI,eAAe,WAAW,GAAG;AAC/B,UAAM,MAAM,MAAM,UAAU,CAAA,UAAS,MAAM,KAAK,MAAM,YAAY,IAAI;AACtE,WAAO,QAAQ,KAAK,OAAO;AAAA,EAC7B;AACA,QAAM,IAAI;AAAA,IACR,gHAAgH,KAAK;AAAA,MACnH;AAAA,IAAA,CACD;AAAA,EAAA;AAEL;AAEO,SAAS,aAAa,UAA8B,OAAe;AACxE,SAAO,aAAa,WAAW,QAAQ,QAAQ;AACjD;AAIO,SAAS,eAAe,QAAgB,OAAe;AAC5D,MAAI,WAAW,MAAM,UAAU,MAAM,UAAU;AAC7C,WAAO;AAET,QAAM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AgB,OAAO,IAAK;AAS1C,MAPI,UAAU,QAOV,UAAU;AACZ,WAAO;AAGT,QAAM,UAAU,MAAM,KAAK,GAIrB,cAAc,YAAY,MAAM,IAAI,OAAO;AAKjD,SAAO,gBAAgB,UACnB,QACA;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA,gBAAgB,SAAY,CAAA,IAAK,CAAC,WAAW;AAAA,EAAA;AAErD;AAEA,SAAS,gBAAmB,GAAyC;AACnE,SAAO,EAAE,SAAS;AACpB;ACrHO,SAAS,mBAGd,UAAoB,UAAkD;AACtE,MACE,SAAS,SAAS,cAClB,SAAS,SAAS,SAAS,QAAQ;AAEnC,UAAM,IAAI,MAAM,mBAAmB;AAErC,MAAI,SAAS,OAAO,SAAS;AAC3B,UAAM,IAAI;AAAA,MACR,0EAA0E,SAAS,EAAE,oCAAoC,SAAS,GAAG;AAAA,IAAA;AAGzI,SAAO,aAAa,SAAS,SAAS,QAAQ;AAChD;AC1BO,SAAS,MAAM,KAAgD;AACpE,SAAO,SAAS;AAClB;AACO,SAAS,SACd,KACA,YACqB;AACrB,SAAO,MAAM,GAAG,IAAI,MAAM,EAAC,GAAG,KAAK,KAAK,aAAW;AACrD;"}
import { $ as PathElement, A as SafePath, B as Try, C as ParseInnerExpression, D as ParseProperty, E as ParseObject, F as ToArray, G as AnyEmptyArray, H as Get, I as ToNumber, J as FindBy, K as ByIndex, L as Trim, M as SplitAll, N as StringToPath, O as ParseValue, P as StripError, Q as Path, R as TrimLeft, S as ParseExpressions, T as ParseNumber, U as GetAtPath, V as Unwrap, W as getAtPath, X as Index$1, Y as FindInArray, Z as KeyedPathElement, _ as MergeInner, a as isKeyElement, at as Format, b as ParseAllProps, c as startsWith, d as parse, et as PropertyName, f as Concat, g as Merge, h as Err, i as isIndexElement, it as EmptyArray, j as Split, k as Result, l as normalize, m as Digit, n as isElementEqual, nt as ArrayElement, o as isKeyedElement, ot as NormalizeReadOnlyArray, p as ConcatInner, q as ElementType, r as isEqual, rt as ArrayLength, s as isPropertyElement, st as Optional, t as isArrayElement, tt as AnyArray, u as stringify, v as Ok, w as ParseKVPair, x as ParseError, y as OnlyDigits, z as TrimRight } from "./_chunks-dts/index2.js";
import { A as StringOp, C as Operation, D as ReplaceOp, E as RemoveOp, M as UnassignOp, N as UnsetOp, O as SetIfMissingOp, P as UpsertOp, S as ObjectOp, T as RelativePosition, _ as DiffMatchPatchOp, b as InsertOp, c as NodePatchList, d as SanityDocumentBase, g as DecOp, h as AssignOp, i as DeleteMutation, j as TruncateOp, k as SetOp, l as PatchMutation, m as ArrayOp, n as CreateMutation, o as Mutation, p as AnyOp, r as CreateOrReplaceMutation, s as NodePatch, t as CreateIfNotExistsMutation, u as PatchOptions, v as IncOp, w as PrimitiveOp, x as NumberOp, y as InsertIfMissingOp } from "./_chunks-dts/types.js";
import { Call, Numbers, Tuples } from "hotscript";
declare function applyInCollection<Doc extends SanityDocumentBase>(collection: Doc[], mutations: Mutation | Mutation[]): any[];
/**
* Extracts the document shape an "add"-flavored mutation contributes.
* `delete` and `patch` don't introduce new shapes.
*/
type AddedDocument<M> = M extends CreateMutation<infer D> ? D : M extends CreateIfNotExistsMutation<infer D> ? D : M extends CreateOrReplaceMutation<infer D> ? D : never;
/**
* Extracts the literal `_id` of any delete mutation in the union.
* `DeleteMutation<string>` (non-literal id) extracts to `string`, which
* makes Exclude<…> a no-op — so non-literal deletes leave the result
* type alone, which is the right behaviour.
*/
type DeletedId<M> = M extends DeleteMutation<infer Id> ? Id : never;
type MutationOf<Muts> = Muts extends readonly Mutation[] ? Muts[number] : Muts;
declare function applyInCollection<const Doc extends SanityDocumentBase, const Muts extends Mutation | readonly Mutation[]>(collection: readonly Doc[], mutations: Muts): readonly Exclude<Doc | AddedDocument<MutationOf<Muts>>, {
_id: DeletedId<MutationOf<Muts>>;
}>[];
type RequiredSelect<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: T[P] };

@@ -6,0 +21,0 @@ declare const createStore: <Doc extends SanityDocumentBase>(initialEntries?: Doc[]) => {

@@ -1,1 +0,1 @@

{"version":3,"file":"_unstable_apply.d.ts","names":[],"sources":["../src/apply/applyInCollection.ts","../src/apply/store/store.ts","../src/apply/store/utils.ts","../src/apply/applyInIndex.ts","../src/apply/patch/typings/applyOp.ts","../src/apply/patch/typings/applyNodePatch.ts","../src/apply/applyPatchMutation.ts","../src/apply/patch/applyNodePatch.ts","../src/apply/patch/applyOp.ts"],"mappings":";;;iBAagB,iBAAA,aAA8B,kBAAA,CAAA,CAC5C,UAAA,EAAY,GAAA,IACZ,SAAA,EAAW,QAAA,GAAW,QAAA;AAAA,KCPZ,cAAA,oBAAkC,CAAA,IAAK,IAAA,CAAK,CAAA,EAAG,CAAA,YACnD,CAAA,KAAM,CAAA,CAAE,CAAA;AAAA,cAiBH,WAAA,eAA2B,kBAAA,EACtC,cAAA,GAAiB,GAAA;EAAA;;2BAoBQ,EAAA,EACjB,EAAA,KACH,MAAA,CAAO,IAAA,CAAI,MAAA,CAAA,QAAA,CAAA,GAAA,GAAA,kBAAA;IAA+C,GAAA,EAAK,EAAA;EAAA;qBAE/C,QAAA,KAAa,QAAA;AAAA;AAAA,iBChDpB,KAAA,CAAM,GAAA,EAAK,kBAAA,GAAqB,GAAA,IAAO,cAAA;AAAA,iBAGvC,QAAA,aAAqB,kBAAA,CAAA,CACnC,GAAA,EAAK,GAAA,EACL,UAAA,iBACC,GAAA;EAAO,GAAA;AAAA;AAAA,KCKE,aAAA,aAA0B,kBAAA;EAAA,CAAwB,EAAA,WAAa,GAAA;AAAA;AAAA,iBAE3D,YAAA,aACF,kBAAA,gBACE,aAAA,CAAc,QAAA,CAAS,GAAA,GAAA,CACrC,KAAA,EAAO,KAAA,EAAO,SAAA,EAAW,QAAA,CAAS,GAAA,MAAS,KAAA;AAAA,KAsBjC,QAAA,aAAqB,kBAAA,IAAsB,GAAA,GACrD,QAAA,CAAS,kBAAA;AAAA,KAEC,YAAA,aAAyB,kBAAA,I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L,kBAAA,CAAA,CAClB,QAAA,EAAU,QAAA,EAAU,QAAA,EAAU,GAAA,GAAM,kBAAA,CAAmB,QAAA,EAAU,GAAA;AAAA,iBCDnD,YAAA,iBAA6B,aAAA,YAAA,CAC3C,OAAA,EAAS,OAAA,EACT,QAAA,EAAU,GAAA,GACT,YAAA,CAAa,sBAAA,CAAuB,OAAA,GAAU,GAAA;AAAA,iBAOjC,cAAA,qBAAmC,SAAA,YAAA,CACjD,KAAA,EAAO,KAAA,EACP,QAAA,EAAU,GAAA,GACT,cAAA,CAAe,KAAA,EAAO,GAAA;AAAA,iBChBT,OAAA,kBAAyB,KAAA,qBAAA,CACvC,EAAA,EAAI,EAAA,EACJ,YAAA,EAAc,YAAA,GACb,OAAA,CAAQ,EAAA,EAAI,YAAA;AAAA,iBACC,OAAA,kBACG,QAAA,oCAAA,CAEjB,EAAA,EAAI,EAAA,EAAI,YAAA,EAAc,YAAA,GAAe,OAAA,CAAQ,EAAA,EAAI,YAAA;AAAA,iBACnC,OAAA,kBACG,QAAA,oCAAA,CAEjB,EAAA,EAAI,EAAA,EAAI,YAAA,EAAc,YAAA,GAAe,OAAA,CAAQ,EAAA,EAAI,YAAA;AAAA,iBACnC,OAAA,kBACG,QAAA,2DAAA,CAEjB,EAAA,EAAI,EAAA,EAAI,YAAA,EAAc,YAAA,GAAe,OAAA,CAAQ,EAAA,EAAI,YAAA;AAAA,iBACnC,OAAA,kBACG,OAAA,6BACU,QAAA,CAAA,CAC3B,EAAA,EAAI,EAAA,EAAI,YAAA,EAAc,YAAA,GAAe,OAAA,CAAQ,EAAA,EAAI,YAAA"}
{"version":3,"file":"_unstable_apply.d.ts","names":[],"sources":["../src/apply/applyInCollection.ts","../src/apply/store/store.ts","../src/apply/store/utils.ts","../src/apply/applyInIndex.ts","../src/apply/patch/typings/applyOp.ts","../src/apply/patch/typings/applyNodePatch.ts","../src/apply/applyPatchMutation.ts","../src/apply/patch/applyNodePatch.ts","../src/apply/patch/applyOp.ts"],"m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b,YAAA,CAAa,sBAAA,CAAuB,OAAA,GAAU,GAAA,IAC9C,GAAA;AAAA,iBAEU,kBAAA,wBACS,aAAA,oBACL,kBAAA,CAAA,CAClB,QAAA,EAAU,QAAA,EAAU,QAAA,EAAU,GAAA,GAAM,kBAAA,CAAmB,QAAA,EAAU,GAAA;AAAA,iBCDnD,YAAA,iBAA6B,aAAA,YAAA,CAC3C,OAAA,EAAS,OAAA,EACT,QAAA,EAAU,GAAA,GACT,YAAA,CAAa,sBAAA,CAAuB,OAAA,GAAU,GAAA;AAAA,iBAOjC,cAAA,qBAAmC,SAAA,YAAA,CACjD,KAAA,EAAO,KAAA,EACP,QAAA,EAAU,GAAA,GACT,cAAA,CAAe,KAAA,EAAO,GAAA;AAAA,iBChBT,OAAA,kBAAyB,KAAA,qBAAA,CACvC,EAAA,EAAI,EAAA,EACJ,YAAA,EAAc,YAAA,GACb,OAAA,CAAQ,EAAA,EAAI,YAAA;AAAA,iBACC,OAAA,kBACG,QAAA,oCAAA,CAEjB,EAAA,EAAI,EAAA,EAAI,YAAA,EAAc,YAAA,GAAe,OAAA,CAAQ,EAAA,EAAI,YAAA;AAAA,iBACnC,OAAA,kBACG,QAAA,oCAAA,CAEjB,EAAA,EAAI,EAAA,EAAI,YAAA,EAAc,YAAA,GAAe,OAAA,CAAQ,EAAA,EAAI,YAAA;AAAA,iBACnC,OAAA,kBACG,QAAA,2DAAA,CAEjB,EAAA,EAAI,EAAA,EAAI,YAAA,EAAc,YAAA,GAAe,OAAA,CAAQ,EAAA,EAAI,YAAA;AAAA,iBACnC,OAAA,kBACG,OAAA,6BACU,QAAA,CAAA,CAC3B,EAAA,EAAI,EAAA,EAAI,YAAA,EAAc,YAAA,GAAe,OAAA,CAAQ,EAAA,EAAI,YAAA"}

@@ -1,1 +0,1 @@

{"version":3,"file":"_unstable_apply.js","sources":["../src/apply/applyInCollection.ts","../src/apply/store/store.ts","../src/apply/applyInIndex.ts"],"sourcesContent":["import {\n type CreateIfNotExistsMutation,\n type CreateMutation,\n type CreateOrReplaceMutation,\n type DeleteMutation,\n type Mutation,\n type PatchMutation,\n type SanityDocumentBase,\n} from '../mutations/types'\nimport {arrify} from '../utils/arrify'\nimport {applyPatchMutation} from './applyPatchMutation'\nimport {splice} from './utils/array'\n\nexport function applyInCollection<Doc extends SanityDocumentBase>(\n collection: Doc[],\n mutations: Mutation | Mutation[],\n) {\n const a = arrify(mutations) as Mutation[]\n return a.reduce((prev, mutation) => {\n if (mutation.type === 'create') {\n return createIn(prev, mutation)\n }\n if (mutation.type === 'createIfNotExists') {\n return createIfNotExistsIn(prev, mutation)\n }\n if (mutation.type === 'delete') {\n return deleteIn(prev, mutation)\n }\n if (mutation.type === 'createOrReplace') {\n return createOrReplaceIn(prev, mutation)\n }\n if (mutation.type === 'patch') {\n return patchIn(prev, mutation)\n }\n // @ts-expect-error all cases should be covered\n throw new Error(`Invalid mutation type: ${mutation.type}`)\n }, collection)\n}\n\nfunction createIn<Doc extends SanityDocumentBase>(\n collection: Doc[],\n mutation: CreateMutation<Doc>,\n) {\n const currentIdx = collection.findIndex(\n doc => doc._id === mutation.document._id,\n )\n if (currentIdx !== -1) {\n throw new Error('Document already exist')\n }\n return collection.concat(mutation.document)\n}\n\nfunction createIfNotExistsIn<Doc extends SanityDocumentBase>(\n collection: Doc[],\n mutation: CreateIfNotExistsMutation<Doc>,\n) {\n const currentIdx = collection.findIndex(\n doc => doc._id === mutation.document._id,\n )\n return currentIdx === -1 ? collection.concat(mutation.document) : collection\n}\n\nfunction createOrReplaceIn<Doc extends SanityDocumentBase>(\n collection: Doc[],\n mutation: CreateOrReplaceMutation<Doc>,\n) {\n const currentIdx = collection.findIndex(\n doc => doc._id === mutation.document._id,\n )\n return currentIdx === -1\n ? collection.concat(mutation.document)\n : splice(collection, currentIdx, 1, [mutation.document])\n}\n\nfunction deleteIn<Doc extends SanityDocumentBase>(\n collection: Doc[],\n mutation: DeleteMutation,\n) {\n const currentIdx = collection.findIndex(doc => doc._id === mutation.id)\n return currentIdx === -1 ? collection : splice(collection, currentIdx, 1)\n}\n\nfunction patchIn<Doc extends SanityDocumentBase>(\n collection: Doc[],\n mutation: PatchMutation,\n): Doc[] {\n const currentIdx = collection.findIndex(doc => doc._id === mutation.id)\n if (currentIdx === -1) {\n throw new Error('Cannot apply patch on nonexistent document')\n }\n const current = collection[currentIdx]!\n\n const next = applyPatchMutation(mutation, current)\n\n return next === current\n ? collection\n : splice(collection, currentIdx, 1, [next])\n}\n","import {nanoid} from 'nanoid'\n\nimport {type DocumentIndex, type Format} from '../../apply'\nimport {type Mutation, type SanityDocumentBase} from '../../mutations/types'\nimport {arrify} from '../../utils/arrify'\nimport {applyInIndex, type ToIdentified, type ToStored} from '../applyInIndex'\nimport {assignId} from './utils'\n\nexport type RequiredSelect<T, K extends keyof T> = Omit<T, K> & {\n [P in K]-?: T[P]\n}\n\nfunction update<Doc extends ToIdentified<SanityDocumentBase>>(\n doc: Doc,\n revision: string,\n): ToStored<Doc> {\n return {\n ...doc,\n _rev: revision,\n _createdAt: doc._createdAt || new Date().toISOString(),\n _updatedAt: new Date().toISOString(),\n }\n}\n\nconst empty: DocumentIndex<any> = {}\n\nexport const createStore = <Doc extends SanityDocumentBase>(\n initialEntries?: Doc[],\n) => {\n let version = 0\n\n let index: DocumentIndex<Format<ToStored<Doc & SanityDocumentBase>>> =\n initialEntries && initialEntries?.length > 0\n ? Object.fromEntries(\n initialEntries.map(entry => {\n const doc = update(assignId(entry, nanoid), nanoid())\n return [doc._id, doc]\n }),\n )\n : empty\n\n return {\n get version() {\n return version\n },\n // todo: support listening for changes\n entries: () => Object.entries(index),\n get: <Id extends string>(\n id: Id,\n ): Format<Omit<(typeof index)[keyof typeof index], '_id'> & {_id: Id}> =>\n index[id] as any,\n apply: (mutations: Mutation[] | Mutation) => {\n const nextIndex = applyInIndex(index, arrify(mutations))\n if (nextIndex !== index) {\n index = nextIndex\n version++\n }\n },\n }\n}\n","import {nanoid} from 'nanoid'\n\nimport {\n type CreateIfNotExistsMutation,\n type CreateMutation,\n type CreateOrReplaceMutation,\n type DeleteMutation,\n type Mutation,\n type PatchMutation,\n type SanityDocumentBase,\n} from '../mutations/types'\nimport {applyPatchMutation} from './applyPatchMutation'\nimport {assignId, hasId, type RequiredSelect} from './store'\n\nexport type DocumentIndex<Doc extends SanityDocumentBase> = {[id: string]: Doc}\n\nexport function applyInIndex<\n Doc extends SanityDocumentBase,\n Index extends DocumentIndex<ToStored<Doc>>,\n>(index: Index, mutations: Mutation<Doc>[]): Index {\n return mutations.reduce((prev, mutation) => {\n if (mutation.type === 'create') {\n return createIn(prev, mutation)\n }\n if (mutation.type === 'createIfNotExists') {\n return createIfNotExistsIn(prev, mutation)\n }\n if (mutation.type === 'delete') {\n return deleteIn(prev, mutation)\n }\n if (mutation.type === 'createOrReplace') {\n return createOrReplaceIn(prev, mutation)\n }\n if (mutation.type === 'patch') {\n return patchIn(prev, mutation)\n }\n // @ts-expect-error all cases should be covered\n throw new Error(`Invalid mutation type: ${mutation.type}`)\n }, index)\n}\n\nexport type ToStored<Doc extends SanityDocumentBase> = Doc &\n Required<SanityDocumentBase>\n\nexport type ToIdentified<Doc extends SanityDocumentBase> = RequiredSelect<\n Doc,\n '_id'\n>\n\nexport type StoredDocument = ToStored<SanityDocumentBase>\n\nfunction createIn<\n Index extends DocumentIndex<Doc>,\n Doc extends SanityDocumentBase,\n>(index: Index, mutation: CreateMutation<Doc>): Index {\n const document = assignId(mutation.document, nanoid)\n\n if (document._id in index) {\n throw new Error('Document already exist')\n }\n return {...index, [document._id]: mutation.document}\n}\n\nfunction createIfNotExistsIn<\n Index extends DocumentIndex<Doc>,\n Doc extends SanityDocumentBase,\n>(index: Index, mutation: CreateIfNotExistsMutation<Doc>): Index {\n if (!hasId(mutation.document)) {\n throw new Error('Cannot createIfNotExists on document without _id')\n }\n return mutation.document._id in index\n ? index\n : {...index, [mutation.document._id]: mutation.document}\n}\n\nfunction createOrReplaceIn<\n Index extends DocumentIndex<Doc>,\n Doc extends SanityDocumentBase,\n>(index: Index, mutation: CreateOrReplaceMutation<Doc>): Index {\n if (!hasId(mutation.document)) {\n throw new Error('Cannot createIfNotExists on document without _id')\n }\n\n return {...index, [mutation.document._id]: mutation.document}\n}\n\nfunction deleteIn<Index extends DocumentIndex<SanityDocumentBase>>(\n index: Index,\n mutation: DeleteMutation,\n): Index {\n if (mutation.id in index) {\n const copy = {...index}\n delete copy[mutation.id]\n return copy\n } else {\n return index\n }\n}\n\nfunction patchIn<Index extends DocumentIndex<SanityDocumentBase>>(\n index: Index,\n mutation: PatchMutation,\n): Index {\n if (!(mutation.id in index)) {\n throw new Error('Cannot apply patch on nonexistent document')\n }\n const current = index[mutation.id]!\n const next = applyPatchMutation(mutation, current)\n\n return next === current ? index : {...index, [mutation.id]: next}\n}\n"],"names":["createIn","createIfNotExistsIn","deleteIn","createOrReplaceIn","patchIn"],"mappings":";;;;AAaO,SAAS,kBACd,YACA,WACA;AAEA,SADU,OAAO,SAAS,EACjB,OAAO,CAAC,MAAM,aAAa;AAClC,QAAI,SAAS,SAAS;AACpB,aAAOA,WAAS,MAAM,QAAQ;AAEhC,QAAI,SAAS,SAAS;AACpB,aAAOC,sBAAoB,MAAM,QAAQ;AAE3C,QAAI,SAAS,SAAS;AACpB,aAAOC,WAAS,MAAM,QAAQ;AAEhC,QAAI,SAAS,SAAS;AACpB,aAAOC,oBAAkB,MAAM,QAAQ;AAEzC,QAAI,SAAS,SAAS;AACpB,aAAOC,UAAQ,MAAM,QAAQ;AAG/B,UAAM,IAAI,MAAM,0BAA0B,SAAS,IAAI,EAAE;AAAA,EAC3D,GAAG,UAAU;AACf;AAEA,SAASJ,WACP,YACA,UACA;AAIA,MAHmB,WAAW;AAAA,IAC5B,CAAA,QAAO,IAAI,QAAQ,SAAS,SAAS;AAAA,EAAA,MAEpB;AACjB,UAAM,IAAI,MAAM,wBAAwB;AAE1C,SAAO,WAAW,OAAO,SAAS,QAAQ;AAC5C;AAEA,SAASC,sBACP,YACA,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,MAAM,SAAS,QAAQ;AAC1B,UAAM,IAAI,MAAM,kDAAkD;AAGpE,SAAO,EAAC,GAAG,OAAO,CAAC,SAAS,SAAS,GAAG,GAAG,SAAS,SAAA;AACtD;AAEA,SAAS,SACP,OACA,UACO;AACP,MAAI,SAAS,MAAM,OAAO;AACxB,UAAM,OAAO,EAAC,GAAG,MAAA;AACjB,WAAA,OAAO,KAAK,SAAS,EAAE,GAChB;AAAA,EACT;AACE,WAAO;AAEX;AAEA,SAAS,QACP,OACA,UACO;AACP,MAAI,EAAE,SAAS,MAAM;AACnB,UAAM,IAAI,MAAM,4CAA4C;AAE9D,QAAM,UAAU,MAAM,SAAS,EAAE,GAC3B,OAAO,mBAAmB,UAAU,OAAO;AAEjD,SAAO,SAAS,UAAU,QAAQ,EAAC,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,KAAA;AAC9D;"}
{"version":3,"file":"_unstable_apply.js","sources":["../src/apply/applyInCollection.ts","../src/apply/store/store.ts","../src/apply/applyInIndex.ts"],"sourcesContent":["import {\n type CreateIfNotExistsMutation,\n type CreateMutation,\n type CreateOrReplaceMutation,\n type DeleteMutation,\n type Mutation,\n type PatchMutation,\n type SanityDocumentBase,\n} from '../mutations/types'\nimport {arrify} from '../utils/arrify'\nimport {applyPatchMutation} from './applyPatchMutation'\nimport {splice} from './utils/array'\n\n/**\n * Extracts the document shape an \"add\"-flavored mutation contributes.\n * `delete` and `patch` don't introduce new shapes.\n */\ntype AddedDocument<M> =\n M extends CreateMutation<infer D>\n ? D\n : M extends CreateIfNotExistsMutation<infer D>\n ? D\n : M extends CreateOrReplaceMutation<infer D>\n ? D\n : never\n\n/**\n * Extracts the literal `_id` of any delete mutation in the union.\n * `DeleteMutation<string>` (non-literal id) extracts to `string`, which\n * makes Exclude<…> a no-op — so non-literal deletes leave the result\n * type alone, which is the right behaviour.\n */\ntype DeletedId<M> = M extends DeleteMutation<infer Id> ? Id : never\n\ntype MutationOf<Muts> = Muts extends readonly Mutation[] ? Muts[number] : Muts\n\nexport function applyInCollection<\n const Doc extends SanityDocumentBase,\n const Muts extends Mutation | readonly Mutation[],\n>(\n collection: readonly Doc[],\n mutations: Muts,\n): readonly Exclude<\n Doc | AddedDocument<MutationOf<Muts>>,\n {_id: DeletedId<MutationOf<Muts>>}\n>[] {\n const a = arrify(mutations as Mutation | Mutation[]) as Mutation[]\n return a.reduce((prev: readonly SanityDocumentBase[], mutation) => {\n if (mutation.type === 'create') {\n return createIn(prev, mutation)\n }\n if (mutation.type === 'createIfNotExists') {\n return createIfNotExistsIn(prev, mutation)\n }\n if (mutation.type === 'delete') {\n return deleteIn(prev, mutation)\n }\n if (mutation.type === 'createOrReplace') {\n return createOrReplaceIn(prev, mutation)\n }\n if (mutation.type === 'patch') {\n return patchIn(prev, mutation)\n }\n // @ts-expect-error all cases should be covered\n throw new Error(`Invalid mutation type: ${mutation.type}`)\n }, collection) as readonly Exclude<\n Doc | AddedDocument<MutationOf<Muts>>,\n {_id: DeletedId<MutationOf<Muts>>}\n >[]\n}\n\nfunction createIn<Doc extends SanityDocumentBase>(\n collection: readonly Doc[],\n mutation: CreateMutation<Doc>,\n) {\n const currentIdx = collection.findIndex(\n doc => doc._id === mutation.document._id,\n )\n if (currentIdx !== -1) {\n throw new Error('Document already exist')\n }\n return collection.concat(mutation.document)\n}\n\nfunction createIfNotExistsIn<Doc extends SanityDocumentBase>(\n collection: readonly Doc[],\n mutation: CreateIfNotExistsMutation<Doc>,\n) {\n const currentIdx = collection.findIndex(\n doc => doc._id === mutation.document._id,\n )\n return currentIdx === -1 ? collection.concat(mutation.document) : collection\n}\n\nfunction createOrReplaceIn<Doc extends SanityDocumentBase>(\n collection: readonly Doc[],\n mutation: CreateOrReplaceMutation<Doc>,\n) {\n const currentIdx = collection.findIndex(\n doc => doc._id === mutation.document._id,\n )\n return currentIdx === -1\n ? collection.concat(mutation.document)\n : splice(collection, currentIdx, 1, [mutation.document])\n}\n\nfunction deleteIn<Doc extends SanityDocumentBase>(\n collection: readonly Doc[],\n mutation: DeleteMutation,\n) {\n const currentIdx = collection.findIndex(doc => doc._id === mutation.id)\n return currentIdx === -1 ? collection : splice(collection, currentIdx, 1)\n}\n\nfunction patchIn<Doc extends SanityDocumentBase>(\n collection: readonly Doc[],\n mutation: PatchMutation,\n): readonly Doc[] {\n const currentIdx = collection.findIndex(doc => doc._id === mutation.id)\n if (currentIdx === -1) {\n throw new Error('Cannot apply patch on nonexistent document')\n }\n const current = collection[currentIdx]!\n\n const next = applyPatchMutation(mutation, current)\n\n return next === current\n ? collection\n : splice(collection, currentIdx, 1, [next])\n}\n","import {nanoid} from 'nanoid'\n\nimport {type DocumentIndex, type Format} from '../../apply'\nimport {type Mutation, type SanityDocumentBase} from '../../mutations/types'\nimport {arrify} from '../../utils/arrify'\nimport {applyInIndex, type ToIdentified, type ToStored} from '../applyInIndex'\nimport {assignId} from './utils'\n\nexport type RequiredSelect<T, K extends keyof T> = Omit<T, K> & {\n [P in K]-?: T[P]\n}\n\nfunction update<Doc extends ToIdentified<SanityDocumentBase>>(\n doc: Doc,\n revision: string,\n): ToStored<Doc> {\n return {\n ...doc,\n _rev: revision,\n _createdAt: doc._createdAt || new Date().toISOString(),\n _updatedAt: new Date().toISOString(),\n }\n}\n\nconst empty: DocumentIndex<any> = {}\n\nexport const createStore = <Doc extends SanityDocumentBase>(\n initialEntries?: Doc[],\n) => {\n let version = 0\n\n let index: DocumentIndex<Format<ToStored<Doc & SanityDocumentBase>>> =\n initialEntries && initialEntries?.length > 0\n ? Object.fromEntries(\n initialEntries.map(entry => {\n const doc = update(assignId(entry, nanoid), nanoid())\n return [doc._id, doc]\n }),\n )\n : empty\n\n return {\n get version() {\n return version\n },\n // todo: support listening for changes\n entries: () => Object.entries(index),\n get: <Id extends string>(\n id: Id,\n ): Format<Omit<(typeof index)[keyof typeof index], '_id'> & {_id: Id}> =>\n index[id] as any,\n apply: (mutations: Mutation[] | Mutation) => {\n const nextIndex = applyInIndex(index, arrify(mutations))\n if (nextIndex !== index) {\n index = nextIndex\n version++\n }\n },\n }\n}\n","import {nanoid} from 'nanoid'\n\nimport {\n type CreateIfNotExistsMutation,\n type CreateMutation,\n type CreateOrReplaceMutation,\n type DeleteMutation,\n type Mutation,\n type PatchMutation,\n type SanityDocumentBase,\n} from '../mutations/types'\nimport {applyPatchMutation} from './applyPatchMutation'\nimport {assignId, hasId, type RequiredSelect} from './store'\n\nexport type DocumentIndex<Doc extends SanityDocumentBase> = {[id: string]: Doc}\n\nexport function applyInIndex<\n Doc extends SanityDocumentBase,\n Index extends DocumentIndex<ToStored<Doc>>,\n>(index: Index, mutations: Mutation<Doc>[]): Index {\n return mutations.reduce((prev, mutation) => {\n if (mutation.type === 'create') {\n return createIn(prev, mutation)\n }\n if (mutation.type === 'createIfNotExists') {\n return createIfNotExistsIn(prev, mutation)\n }\n if (mutation.type === 'delete') {\n return deleteIn(prev, mutation)\n }\n if (mutation.type === 'createOrReplace') {\n return createOrReplaceIn(prev, mutation)\n }\n if (mutation.type === 'patch') {\n return patchIn(prev, mutation)\n }\n // @ts-expect-error all cases should be covered\n throw new Error(`Invalid mutation type: ${mutation.type}`)\n }, index)\n}\n\nexport type ToStored<Doc extends SanityDocumentBase> = Doc &\n Required<SanityDocumentBase>\n\nexport type ToIdentified<Doc extends SanityDocumentBase> = RequiredSelect<\n Doc,\n '_id'\n>\n\nexport type StoredDocument = ToStored<SanityDocumentBase>\n\nfunction createIn<\n Index extends DocumentIndex<Doc>,\n Doc extends SanityDocumentBase,\n>(index: Index, mutation: CreateMutation<Doc>): Index {\n const document = assignId(mutation.document, nanoid)\n\n if (document._id in index) {\n throw new Error('Document already exist')\n }\n return {...index, [document._id]: mutation.document}\n}\n\nfunction createIfNotExistsIn<\n Index extends DocumentIndex<Doc>,\n Doc extends SanityDocumentBase,\n>(index: Index, mutation: CreateIfNotExistsMutation<Doc>): Index {\n if (!hasId(mutation.document)) {\n throw new Error('Cannot createIfNotExists on document without _id')\n }\n return mutation.document._id in index\n ? index\n : {...index, [mutation.document._id]: mutation.document}\n}\n\nfunction createOrReplaceIn<\n Index extends DocumentIndex<Doc>,\n Doc extends SanityDocumentBase,\n>(index: Index, mutation: CreateOrReplaceMutation<Doc>): Index {\n if (!hasId(mutation.document)) {\n throw new Error('Cannot createIfNotExists on document without _id')\n }\n\n return {...index, [mutation.document._id]: mutation.document}\n}\n\nfunction deleteIn<Index extends DocumentIndex<SanityDocumentBase>>(\n index: Index,\n mutation: DeleteMutation,\n): Index {\n if (mutation.id in index) {\n const copy = {...index}\n delete copy[mutation.id]\n return copy\n } else {\n return index\n }\n}\n\nfunction patchIn<Index extends DocumentIndex<SanityDocumentBase>>(\n index: Index,\n mutation: PatchMutation,\n): Index {\n if (!(mutation.id in index)) {\n throw new Error('Cannot apply patch on nonexistent document')\n }\n const current = index[mutation.id]!\n const next = applyPatchMutation(mutation, current)\n\n return next === current ? index : {...index, [mutation.id]: next}\n}\n"],"names":["createIn","createIfNotExistsIn","deleteIn","createOrReplaceIn","patchIn"],"mappings":";;;;AAoCO,SAAS,kBAId,YACA,WAIE;AAEF,SADU,OAAO,SAAkC,EAC1C,OAAO,CAAC,MAAqC,aAAa;AACjE,QAAI,SAAS,SAAS;AACpB,aAAOA,WAAS,MAAM,QAAQ;AAEhC,QAAI,SAAS,SAAS;AACpB,aAAOC,sBAAoB,MAAM,QAAQ;AAE3C,QAAI,SAAS,SAAS;AACpB,aAAOC,WAAS,MAAM,QAAQ;AAEhC,QAAI,SAAS,SAAS;AACpB,aAAOC,oBAAkB,MAAM,QAAQ;AAEzC,QAAI,SAAS,SAAS;AACpB,aAAOC,UAAQ,MAAM,QAAQ;AAG/B,UAAM,IAAI,MAAM,0BAA0B,SAAS,IAAI,EAAE;AAAA,EAC3D,GAAG,UAAU;AAIf;AAEA,SAASJ,WACP,YACA,UACA;AAIA,MAHmB,WAAW;AAAA,IAC5B,CAAA,QAAO,IAAI,QAAQ,SAAS,SAAS;AAAA,EAAA,MAEpB;AACjB,UAAM,IAAI,MA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S,GAAG,GAAG,SAAS,SAAA;AACnD;AAEA,SAAS,kBAGP,OAAc,UAA+C;AAC7D,MAAI,CAAC,MAAM,SAAS,QAAQ;AAC1B,UAAM,IAAI,MAAM,kDAAkD;AAGpE,SAAO,EAAC,GAAG,OAAO,CAAC,SAAS,SAAS,GAAG,GAAG,SAAS,SAAA;AACtD;AAEA,SAAS,SACP,OACA,UACO;AACP,MAAI,SAAS,MAAM,OAAO;AACxB,UAAM,OAAO,EAAC,GAAG,MAAA;AACjB,WAAA,OAAO,KAAK,SAAS,EAAE,GAChB;AAAA,EACT;AACE,WAAO;AAEX;AAEA,SAAS,QACP,OACA,UACO;AACP,MAAI,EAAE,SAAS,MAAM;AACnB,UAAM,IAAI,MAAM,4CAA4C;AAE9D,QAAM,UAAU,MAAM,SAAS,EAAE,GAC3B,OAAO,mBAAmB,UAAU,OAAO;AAEjD,SAAO,SAAS,UAAU,QAAQ,EAAC,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,KAAA;AAC9D;"}

@@ -201,3 +201,3 @@ import { $ as PathElement, A as SafePath, B as Try, C as ParseInnerExpression, D as ParseProperty, E as ParseObject, F as ToArray, G as AnyEmptyArray, H as Get, I as ToNumber, J as FindBy, K as ByIndex, L as Trim, M as SplitAll, N as StringToPath, O as ParseValue, P as StripError, Q as Path, R as TrimLeft, S as ParseExpressions, T as ParseNumber, U as GetAtPath, V as Unwrap, W as getAtPath, X as Index, Y as FindInArray, Z as KeyedPathElement, _ as MergeInner, a as isKeyElement, b as ParseAllProps, c as startsWith, d as parse, et as PropertyName, f as Concat, g as Merge, h as Err, i as isIndexElement, j as Split, k as Result, l as normalize, m as Digit, n as isElementEqual, o as isKeyedElement, p as ConcatInner, q as ElementType, r as isEqual, s as isPropertyElement, st as Optional, t as isArrayElement, tt as AnyArray, u as stringify, v as Ok, w as ParseKVPair, x as ParseError, y as OnlyDigits, z as TrimRight } from "./_chunks-dts/index2.js";

};
}, "busy" | "error" | "ready", DocumentMutatorMachineInput, _$xstate.NonReducibleUnknown, _$xstate.EventObject, _$xstate.MetaObject, {
}, "error" | "busy" | "ready", DocumentMutatorMachineInput, _$xstate.NonReducibleUnknown, _$xstate.EventObject, _$xstate.MetaObject, {
id: "document-mutator";

@@ -204,0 +204,0 @@ states: {

@@ -166,35 +166,35 @@ import { h as __exportAll, t as index_d_exports$2 } from "./_chunks-dts/index.js";

declare function format<Doc extends SanityDocumentBase>(mutations: Mutation[]): string;
type Arrify<T> = (T extends (infer E)[] ? E : T)[];
declare function autoKeys<Item>(generateKey: (item: Item) => string): {
insert: <Pos extends RelativePosition, Ref extends Index | KeyedPathElement>(position: Pos, referenceItem: Ref, items: Item[]) => undefined<(Item & {
insert: <Pos extends RelativePosition, Ref extends Index | KeyedPathElement>(position: Pos, referenceItem: Ref, items: Item[]) => InsertOp<(Item & {
_key: string;
})[], Pos, Ref>;
upsert: <Pos extends RelativePosition, ReferenceItem extends KeyedPathElement>(items: Item[], position: Pos, referenceItem: ReferenceItem) => undefined<undefined<Item & {
upsert: <Pos extends RelativePosition, ReferenceItem extends KeyedPathElement>(items: Item[], position: Pos, referenceItem: ReferenceItem) => UpsertOp<Arrify<Item & {
_key: string;
}>, Pos, ReferenceItem>;
replace: <Pos extends RelativePosition, ReferenceItem extends Index | KeyedPathElement>(items: Item[], position: Pos, referenceItem: ReferenceItem) => undefined<(Item & {
replace: <Pos extends RelativePosition, ReferenceItem extends Index | KeyedPathElement>(items: Item[], position: Pos, referenceItem: ReferenceItem) => ReplaceOp<(Item & {
_key: string;
})[], ReferenceItem>;
insertBefore: <Ref extends Index | KeyedPathElement>(ref: Ref, items: Item[]) => undefined<(Item & {
insertBefore: <Ref extends Index | KeyedPathElement>(ref: Ref, items: Item[]) => InsertOp<(Item & {
_key: string;
})[], "before", Ref>;
prepend: (items: Item[]) => undefined<(Item & {
prepend: (items: Item[]) => InsertOp<(Item & {
_key: string;
})[], "before", 0>;
insertAfter: <Ref extends Index | KeyedPathElement>(ref: Ref, items: Item[]) => undefined<(Item & {
insertAfter: <Ref extends Index | KeyedPathElement>(ref: Ref, items: Item[]) => InsertOp<(Item & {
_key: string;
})[], "after", Ref>;
append: (items: Item[]) => undefined<(Item & {
append: (items: Item[]) => InsertOp<(Item & {
_key: string;
})[], "after", -1>;
};
declare function create<Doc extends Optional<SanityDocumentBase, '_id'>>(document: Doc): CreateMutation<Doc>;
declare function create<const Doc extends Optional<SanityDocumentBase, '_id'>>(document: Doc): CreateMutation<Doc>;
declare function patch<P extends NodePatchList | NodePatch>(id: string, patches: P, options?: PatchOptions): PatchMutation<NormalizeReadOnlyArray<Tuplify<P>>>;
declare function at<const P extends Path, O extends Operation>(path: P, operation: O): NodePatch<NormalizeReadOnlyArray<P>, O>;
declare function at<const P extends string, O extends Operation>(path: P, operation: O): NodePatch<SafePath<P>, O>;
declare function createIfNotExists<Doc extends SanityDocumentBase>(document: Doc): CreateIfNotExistsMutation<Doc>;
declare function createOrReplace<Doc extends SanityDocumentBase>(document: Doc): CreateOrReplaceMutation<Doc>;
declare function delete_(id: string): DeleteMutation;
declare function createIfNotExists<const Doc extends SanityDocumentBase>(document: Doc): CreateIfNotExistsMutation<Doc>;
declare function createOrReplace<const Doc extends SanityDocumentBase>(document: Doc): CreateOrReplaceMutation<Doc>;
declare function delete_<const Id extends string>(id: Id): DeleteMutation<Id>;
declare const del: typeof delete_;
declare const destroy: typeof delete_;
type Arrify<T> = (T extends (infer E)[] ? E : T)[];
declare const set: <const T>(value: T) => SetOp<T>;

@@ -201,0 +201,0 @@ declare const assign: <const T extends { [K in string]: unknown }>(value: T) => AssignOp<T>;

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","names":[],"sources":["../src/encoders/compact/types.ts","../src/encoders/compact/decode.ts","../src/encoders/compact/encode.ts","../src/encoders/compact/index.ts","../src/encoders/form-compat/form-patch-types.ts","../src/encoders/form-compat/encode.ts","../src/encoders/form-compat/index.ts","../src/formatters/compact.ts","../src/mutations/autoKeys.ts","../src/mutations/creators.ts","../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,gBAAA,8BACU,KAAA,GAAQ,gBAAA,CAAA,CAEpC,KAAA,EAAO,IAAA,GAAO,IAAA,IACd,QAAA,EAAU,GAAA,EACV,aAAA,EAAe,aAAA,GACd,QAAA,CAAS,MAAA,CAAO,IAAA,GAAO,GAAA,EAAK,aAAA;AAAA,iBAYf,eAAA;EACM,IAAA;AAAA,qBACF,gBAAA,8BACU,KAAA,GAAQ,gBAAA,CAAA,CAEpC,KAAA,EAAO,IAAA,GAAO,IAAA,IACd,QAAA,EAAU,GAAA,EACV,aAAA,EAAe,aAAA,GACd,iBAAA,CAAkB,MAAA,CAAO,IAAA,GAAO,GAAA,EAAK,aAAA"}
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/encoders/compact/types.ts","../src/encoders/compact/decode.ts","../src/encoders/compact/encode.ts","../src/encoders/compact/index.ts","../src/encoders/form-compat/form-patch-types.ts","../src/encoders/form-compat/encode.ts","../src/encoders/form-compat/index.ts","../src/formatters/compact.ts","../src/utils/arrify.ts","../src/mutations/autoKeys.ts","../src/mutations/creators.ts","../src/mutations/operations/creators.ts"],"mappings":";;;KAGY,EAAA;AAAA,KACA,YAAA;AAAA,KACA,WAAA;AAAA,KACA,SAAA;AAAA,KAEA,gBAAA,cAA4B,EAAA;AAAA,KAC5B,gBAAA,mBAAiC,GAAA;AAAA,KACjC,2BAAA,8BAAuD,GAAA;AAAA,KACvD,yBAAA,4BAAmD,GAAA;AAAA,KAEnD,aAAA,sBAGV,EAAA,EACA,WAAA,MAEA,YAAA;AAAA,KAEU,cAAA,uBAGV,EAAA,EACA,WAAA,GACC,gBAAA,EAAkB,SAAA,EAAS,QAAA,GAC5B,YAAA;AAAA,KAGU,cAAA,uBAGV,EAAA,EACA,WAAA,GACC,gBAAA,EAAkB,SAAA,EAAS,QAAA,GAC5B,YAAA;AAAA,KAGU,uBAAA,gCAGV,EAAA,EACA,WAAA,GACC,gBAAA,EAAkB,SAAA,EAAS,QAAA,GAC5B,YAAA;AAAA,KAGU,gBAAA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IAAA,GAAO,IAAA,IACd,QAAA,EAAU,GAAA,EACV,aAAA,EAAe,aAAA,GACd,iBAAA,CAAkB,MAAA,CAAO,IAAA,GAAO,GAAA,EAAK,aAAA"}

@@ -1,1 +0,1 @@

{"version":3,"file":"index.js","sources":["../src/encoders/compact/decode.ts","../src/encoders/compact/encode.ts","../src/mutations/creators.ts","../src/mutations/operations/creators.ts","../src/encoders/form-compat/encode.ts","../src/formatters/compact.ts","../src/mutations/autoKeys.ts"],"sourcesContent":["import {isObject} from 'lodash'\n\nimport {type UpsertOp} from '../../mutations/operations/types'\nimport {\n type Mutation,\n type PatchMutation,\n type SanityDocumentBase,\n} from '../../mutations/types'\nimport {type Index, type KeyedPathElement} from '../../path'\nimport {parse as parsePath} from '../../path/parser/parse'\nimport {\n type CompactMutation,\n type CompactPatchMutation,\n type CreateIfNotExistsMutation,\n type CreateMutation,\n type CreateOrReplaceMutation,\n type DeleteMutation,\n} from './types'\n\nexport {Mutation, SanityDocumentBase}\n\nexport function decode<Doc extends SanityDocumentBase>(\n mutations: CompactMutation<Doc>[],\n): Mutation[] {\n return mutations.map(decodeMutation)\n}\n\nexport function decodeMutation<Doc extends SanityDocumentBase>(\n mutation: CompactMutation<Doc>,\n): Mutation {\n const [type] = mutation\n if (type === 'delete') {\n const [, id] = mutation as DeleteMutation\n return {id, type}\n } else if (type === 'create') {\n const [, document] = mutation as CreateMutation<Doc>\n return {type, document}\n } else if (type === 'createIfNotExists') {\n const [, document] = mutation as CreateIfNotExistsMutation<Doc>\n return {type, document}\n } else if (type === 'createOrReplace') {\n const [, document] = mutation as CreateOrReplaceMutation<Doc>\n return {type, document}\n } else if (type === 'patch') {\n return decodePatchMutation(mutation)\n }\n throw new Error(`Unrecognized mutation: ${JSON.stringify(mutation)}`)\n}\n\nfunction decodePatchMutation(mutation: CompactPatchMutation): PatchMutation {\n const [, type, id, serializedPath, , revisionId] = mutation\n\n const path = parsePath(serializedPath)\n if (type === 'dec' || type === 'inc') {\n const [, , , , [amount]] = mutation\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'inc', amount}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'unset') {\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'unset'}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'insert') {\n const [, , , , [position, ref, items]] = mutation\n return {\n type: 'patch',\n id,\n patches: [\n {\n path,\n op: {\n type: 'insert',\n position,\n items,\n referenceItem: typeof ref === 'string' ? {_key: ref} : ref,\n },\n },\n ],\n ...createOpts(revisionId),\n }\n }\n if (type === 'set') {\n const [, , , , [value]] = mutation\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'set', value}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'setIfMissing') {\n const [, , , , [value]] = mutation\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'setIfMissing', value}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'diffMatchPatch') {\n const [, , , , [value]] = mutation\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'diffMatchPatch', value}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'truncate') {\n const [, , , , [startIndex, endIndex]] = mutation\n\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'truncate', startIndex, endIndex}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'assign') {\n const [, , , , [value]] = mutation\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'assign', value}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'replace') {\n const [, , , , [ref, items]] = mutation\n return {\n type: 'patch',\n id,\n patches: [\n {path, op: {type: 'replace', items, referenceItem: decodeItemRef(ref)}},\n ],\n ...createOpts(revisionId),\n }\n }\n if (type === 'upsert') {\n const [, , , , [position, referenceItem, items]] = mutation\n const decodedReferenceItem = decodeItemRef(referenceItem)\n return {\n type: 'patch',\n id,\n patches: [\n {\n path,\n op: {\n type: 'upsert',\n items,\n referenceItem: decodedReferenceItem,\n position,\n } as UpsertOp<typeof items, typeof position, any>,\n },\n ],\n ...createOpts(revisionId),\n }\n }\n throw new Error(`Invalid mutation type: ${type}`)\n}\n\nfunction decodeItemRef(ref: unknown): Index | KeyedPathElement {\n if (typeof ref === 'string') {\n return {_key: ref}\n }\n if (typeof ref === 'number') {\n return ref\n }\n if (!hasKey(ref)) {\n throw new Error('Cannot decode upsert patch: referenceItem is missing key')\n }\n return ref\n}\n\nfunction createOpts(revisionId: undefined | string) {\n return revisionId ? {options: {ifRevision: revisionId}} : null\n}\n\nfunction hasKey<T>(item: T): item is T & {_key: string} {\n return isObject(item) && '_key' in item\n}\n","// An example of a compact transport/serialization format\nimport {\n type Mutation,\n type NodePatch,\n type SanityDocumentBase,\n} from '../../mutations/types'\nimport {type Index, type KeyedPathElement} from '../../path'\nimport {stringify as stringifyPath} from '../../path/parser/stringify'\nimport {\n type CompactMutation,\n type CompactPatchMutation,\n type ItemRef,\n} from './types'\n\nexport function encode<Doc extends SanityDocumentBase>(\n mutations: Mutation[],\n): CompactMutation<Doc>[] {\n return mutations.flatMap(m => encodeMutation<Doc>(m))\n}\n\nfunction encodeItemRef(ref: Index | KeyedPathElement): ItemRef {\n return typeof ref === 'number' ? ref : ref._key\n}\n\nfunction encodeMutation<Doc extends SanityDocumentBase>(\n mutation: Mutation,\n): CompactMutation<Doc>[] {\n if (\n mutation.type === 'create' ||\n mutation.type === 'createIfNotExists' ||\n mutation.type === 'createOrReplace'\n ) {\n return [[mutation.type, mutation.document]]\n }\n if (mutation.type === 'delete') {\n return [['delete', mutation.id]]\n }\n if (mutation.type === 'patch') {\n return mutation.patches.map(patch =>\n maybeAddRevision(\n mutation.options?.ifRevision,\n encodePatchMutation(mutation.id, patch),\n ),\n )\n }\n\n //@ts-expect-error - all cases are covered\n throw new Error(`Invalid mutation type: ${mutation.type}`)\n}\n\nfunction encodePatchMutation(\n id: string,\n patch: NodePatch<any>,\n): CompactPatchMutation {\n const {op} = patch\n const path = stringifyPath(patch.path)\n if (op.type === 'unset') {\n return ['patch', 'unset', id, path, []]\n }\n if (op.type === 'diffMatchPatch') {\n return ['patch', 'diffMatchPatch', id, path, [op.value]]\n }\n if (op.type === 'inc' || op.type === 'dec') {\n return ['patch', op.type, id, path, [op.amount]]\n }\n if (op.type === 'set') {\n return ['patch', op.type, id, path, [op.value]]\n }\n if (op.type === 'setIfMissing') {\n return ['patch', op.type, id, path, [op.value]]\n }\n if (op.type === 'insert') {\n return [\n 'patch',\n 'insert',\n id,\n path,\n [op.position, encodeItemRef(op.referenceItem), op.items],\n ]\n }\n if (op.type === 'upsert') {\n return [\n 'patch',\n 'upsert',\n id,\n path,\n [op.position, encodeItemRef(op.referenceItem), op.items],\n ]\n }\n if (op.type === 'insertIfMissing') {\n return [\n 'patch',\n 'insertIfMissing',\n id,\n path,\n [op.position, encodeItemRef(op.referenceItem), op.items],\n ]\n }\n if (op.type === 'assign') {\n return ['patch', 'assign', id, path, [op.value]]\n }\n if (op.type === 'unassign') {\n return ['patch', 'assign', id, path, [op.keys]]\n }\n if (op.type === 'replace') {\n return [\n 'patch',\n 'replace',\n id,\n path,\n [encodeItemRef(op.referenceItem), op.items],\n ]\n }\n if (op.type === 'truncate') {\n return ['patch', 'truncate', id, path, [op.startIndex, op.endIndex]]\n }\n if (op.type === 'remove') {\n return ['patch', 'remove', id, path, [encodeItemRef(op.referenceItem)]]\n }\n // @ts-expect-error all cases are covered\n throw new Error(`Invalid operation type: ${op.type}`)\n}\n\nfunction maybeAddRevision<T extends CompactPatchMutation>(\n revision: string | undefined,\n mut: T,\n): T {\n const [mutType, patchType, id, path, args] = mut\n return (revision ? [mutType, patchType, id, path, args, revision] : mut) as T\n}\n","import {parse, type Path, type SafePath} from '../path'\nimport {arrify} from '../utils/arrify'\nimport {\n type NormalizeReadOnlyArray,\n type Optional,\n type Tuplify,\n} from '../utils/typeUtils'\nimport {type Operation} from './operations/types'\nimport {\n type CreateIfNotExistsMutation,\n type CreateMutation,\n type CreateOrReplaceMutation,\n type DeleteMutation,\n type NodePatch,\n type NodePatchList,\n type PatchMutation,\n type PatchOptions,\n type SanityDocumentBase,\n} from './types'\n\nexport function create<Doc extends Optional<SanityDocumentBase, '_id'>>(\n document: Doc,\n): CreateMutation<Doc> {\n return {type: 'create', document}\n}\n\nexport function patch<P extends NodePatchList | NodePatch>(\n id: string,\n patches: P,\n options?: PatchOptions,\n): PatchMutation<NormalizeReadOnlyArray<Tuplify<P>>> {\n return {\n type: 'patch',\n id,\n patches: arrify(patches) as any,\n ...(options ? {options} : {}),\n }\n}\n\nexport function at<const P extends Path, O extends Operation>(\n path: P,\n operation: O,\n): NodePatch<NormalizeReadOnlyArray<P>, O>\n\nexport function at<const P extends string, O extends Operation>(\n path: P,\n operation: O,\n): NodePatch<SafePath<P>, O>\n\nexport function at<O extends Operation>(\n path: Path | string,\n operation: O,\n): NodePatch<Path, O> {\n return {\n path: typeof path === 'string' ? parse(path) : path,\n op: operation,\n }\n}\n\nexport function createIfNotExists<Doc extends SanityDocumentBase>(\n document: Doc,\n): CreateIfNotExistsMutation<Doc> {\n return {type: 'createIfNotExists', document}\n}\n\nexport function createOrReplace<Doc extends SanityDocumentBase>(\n document: Doc,\n): CreateOrReplaceMutation<Doc> {\n return {type: 'createOrReplace', document}\n}\n\nexport function delete_(id: string): DeleteMutation {\n return {type: 'delete', id}\n}\n\nexport const del = delete_\nexport const destroy = delete_\n","import {type Arrify, arrify} from '../../utils/arrify'\nimport {\n type AnyArray,\n type ArrayElement,\n type NormalizeReadOnlyArray,\n} from '../../utils/typeUtils'\nimport {\n type AssignOp,\n type DecOp,\n type DiffMatchPatchOp,\n type IncOp,\n type Index,\n type InsertIfMissingOp,\n type InsertOp,\n type KeyedPathElement,\n type RelativePosition,\n type RemoveOp,\n type ReplaceOp,\n type SetIfMissingOp,\n type SetOp,\n type TruncateOp,\n type UnassignOp,\n type UnsetOp,\n type UpsertOp,\n} from './types'\n\nexport const set = <const T>(value: T): SetOp<T> => ({type: 'set', value})\n\nexport const assign = <const T extends {[K in string]: unknown}>(\n value: T,\n): AssignOp<T> => ({\n type: 'assign',\n value,\n})\n\nexport const unassign = <const K extends readonly string[]>(\n keys: K,\n): UnassignOp<K> => ({\n type: 'unassign',\n keys,\n})\n\nexport const setIfMissing = <const T>(value: T): SetIfMissingOp<T> => ({\n type: 'setIfMissing',\n value,\n})\n\nexport const unset = (): UnsetOp => ({type: 'unset'})\n\nexport const inc = <const N extends number = 1>(\n amount: N = 1 as N,\n): IncOp<N> => ({\n type: 'inc',\n amount,\n})\n\nexport const dec = <const N extends number = 1>(\n amount: N = 1 as N,\n): DecOp<N> => ({\n type: 'dec',\n amount,\n})\n\nexport const diffMatchPatch = (value: string): DiffMatchPatchOp => ({\n type: 'diffMatchPatch',\n value,\n})\n\nexport function insert<\n const Items extends AnyArray<unknown>,\n const Pos extends RelativePosition,\n const ReferenceItem extends Index | KeyedPathElement,\n>(\n items: Items | ArrayElement<Items>,\n position: Pos,\n indexOrReferenceItem: ReferenceItem,\n): InsertOp<NormalizeReadOnlyArray<Items>, Pos, ReferenceItem> {\n return {\n type: 'insert',\n referenceItem: indexOrReferenceItem,\n position,\n items: arrify(items) as any,\n }\n}\n\nexport function append<const Items extends AnyArray<unknown>>(\n items: Items | ArrayElement<Items>,\n) {\n return insert(items, 'after', -1)\n}\n\nexport function prepend<const Items extends AnyArray<unknown>>(\n items: Items | ArrayElement<Items>,\n) {\n return insert(items, 'before', 0)\n}\n\nexport function insertBefore<\n const Items extends AnyArray<unknown>,\n const ReferenceItem extends Index | KeyedPathElement,\n>(items: Items | ArrayElement<Items>, indexOrReferenceItem: ReferenceItem) {\n return insert(items, 'before', indexOrReferenceItem)\n}\n\nexport const insertAfter = <\n const Items extends AnyArray<unknown>,\n const ReferenceItem extends Index | KeyedPathElement,\n>(\n items: Items | ArrayElement<Items>,\n indexOrReferenceItem: ReferenceItem,\n) => {\n return insert(items, 'after', indexOrReferenceItem)\n}\n\nexport function truncate(startIndex: number, endIndex?: number): TruncateOp {\n return {\n type: 'truncate',\n startIndex,\n endIndex,\n }\n}\n\n/*\n Use this when you know the ref Items already exists\n */\nexport function replace<\n Items extends any[],\n ReferenceItem extends Index | KeyedPathElement,\n>(\n items: Items | ArrayElement<Items>,\n referenceItem: ReferenceItem,\n): ReplaceOp<Items, ReferenceItem> {\n return {\n type: 'replace',\n referenceItem,\n items: arrify(items) as Items,\n }\n}\n\n/*\n Remove an item from an array by either key or index\n */\nexport function remove<ReferenceItem extends Index | KeyedPathElement>(\n referenceItem: ReferenceItem,\n): RemoveOp<ReferenceItem> {\n return {\n type: 'remove',\n referenceItem,\n }\n}\n\n/*\nuse this when the reference Items may or may not exist\n */\nexport function upsert<\n const Item extends {_key: string},\n const Pos extends RelativePosition,\n const ReferenceItem extends Index | KeyedPathElement,\n>(\n items: Item | Item[],\n position: Pos,\n referenceItem: ReferenceItem,\n): UpsertOp<Arrify<Item>, Pos, ReferenceItem> {\n return {\n type: 'upsert',\n items: arrify(items) as Arrify<Item>,\n referenceItem,\n position,\n }\n}\n\n/*\nuse this when the reference Items may or may not exist\n */\nexport function insertIfMissing<\n const Item extends {_key: string},\n const Pos extends RelativePosition,\n const ReferenceItem extends Index | KeyedPathElement,\n>(\n items: Item | Item[],\n position: Pos,\n referenceItem: ReferenceItem,\n): InsertIfMissingOp<Arrify<Item>, Pos, ReferenceItem> {\n return {\n type: 'insertIfMissing',\n items: arrify(items) as Arrify<Item>,\n referenceItem,\n position,\n }\n}\n","import {at} from '../../mutations/creators'\nimport {\n diffMatchPatch,\n insert,\n set,\n setIfMissing,\n unset,\n} from '../../mutations/operations/creators'\nimport {type NodePatch} from '../../mutations/types'\nimport {type KeyedPathElement} from '../../path'\nimport {\n type CompatPath,\n type FormPatchLike,\n type FormPatchPath,\n} from './form-patch-types'\n\nfunction assertCompatible(formPatchPath: FormPatchPath): CompatPath {\n if (formPatchPath.length === 0) {\n return formPatchPath as never[]\n }\n for (const element of formPatchPath) {\n if (Array.isArray(element)) {\n throw new Error('Form patch paths cannot include arrays')\n }\n }\n return formPatchPath as CompatPath\n}\n\n/**\n * Convert a Sanity form patch (ie emitted from an input component) to a {@link NodePatch}\n * Note the lack of encodeMutation here. Sanity forms never emit *mutations*, only patches\n * @param patches - Array of {@link FormPatchLike}\n * @internal\n */\nexport function encodePatches(patches: FormPatchLike[]): NodePatch[] {\n return patches.map(formPatch => {\n const path = assertCompatible(formPatch.path)\n if (formPatch.type === 'unset') {\n return at(path, unset())\n }\n if (formPatch.type === 'set') {\n return at(path, set(formPatch.value))\n }\n if (formPatch.type === 'setIfMissing') {\n return at(path, setIfMissing(formPatch.value))\n }\n if (formPatch.type === 'insert') {\n const arrayPath = path.slice(0, -1)\n const itemRef = formPatch.path[formPatch.path.length - 1]\n return at(\n arrayPath,\n insert(\n formPatch.items,\n formPatch.position,\n itemRef as number | KeyedPathElement,\n ),\n )\n }\n if (formPatch.type === 'diffMatchPatch') {\n return at(path, diffMatchPatch(formPatch.value))\n }\n // @ts-expect-error - should be exhaustive\n throw new Error(`Unknown patch type ${formPatch.type}`)\n })\n}\n","// An example of a compact formatter\n\nimport {\n type Mutation,\n type NodePatch,\n type SanityDocumentBase,\n} from '../mutations/types'\nimport {type Index, type KeyedPathElement, stringify} from '../path'\n\nexport type ItemRef = string | number\n\nexport function format<Doc extends SanityDocumentBase>(\n mutations: Mutation[],\n): string {\n return mutations.flatMap(m => encodeMutation<Doc>(m)).join('\\n')\n}\n\nfunction encodeItemRef(ref: Index | KeyedPathElement): ItemRef {\n return typeof ref === 'number' ? ref : ref._key\n}\n\nfunction encodeMutation<Doc extends SanityDocumentBase>(\n mutation: Mutation,\n): string {\n if (\n mutation.type === 'create' ||\n mutation.type === 'createIfNotExists' ||\n mutation.type === 'createOrReplace'\n ) {\n return [mutation.type, ': ', JSON.stringify(mutation.document)].join('')\n }\n if (mutation.type === 'delete') {\n return ['delete ', mutation.id].join(': ')\n }\n if (mutation.type === 'patch') {\n const ifRevision = mutation.options?.ifRevision\n return [\n 'patch',\n ' ',\n `id=${mutation.id}`,\n ifRevision ? ` (if revision==${ifRevision})` : '',\n ':\\n',\n mutation.patches\n .map(nodePatch => ` ${formatPatchMutation(nodePatch)}`)\n .join('\\n'),\n ].join('')\n }\n\n //@ts-expect-error - all cases are covered\n throw new Error(`Invalid mutation type: ${mutation.type}`)\n}\n\nfunction formatPatchMutation(patch: NodePatch<any>): string {\n const {op} = patch\n const path = stringify(patch.path)\n if (op.type === 'unset') {\n return [path, 'unset()'].join(': ')\n }\n if (op.type === 'diffMatchPatch') {\n return [path, `diffMatchPatch(${op.value})`].join(': ')\n }\n if (op.type === 'inc' || op.type === 'dec') {\n return [path, `${op.type}(${op.amount})`].join(': ')\n }\n if (op.type === 'set' || op.type === 'setIfMissing') {\n return [path, `${op.type}(${JSON.stringify(op.value)})`].join(': ')\n }\n if (op.type === 'assign') {\n return [path, `${op.type}(${JSON.stringify(op.value)})`].join(': ')\n }\n if (op.type === 'unassign') {\n return [path, `${op.type}(${JSON.stringify(op.keys)})`].join(': ')\n }\n if (\n op.type === 'insert' ||\n op.type === 'upsert' ||\n op.type === 'insertIfMissing'\n ) {\n return [\n path,\n `${op.type}(${op.position}, ${encodeItemRef(\n op.referenceItem,\n )}, ${JSON.stringify(op.items)})`,\n ].join(': ')\n }\n if (op.type === 'replace') {\n return [\n path,\n `replace(${encodeItemRef(op.referenceItem)}, ${JSON.stringify(\n op.items,\n )})`,\n ].join(': ')\n }\n if (op.type === 'truncate') {\n return [path, `truncate(${op.startIndex}, ${op.endIndex}`].join(': ')\n }\n if (op.type === 'remove') {\n return [path, `remove(${encodeItemRef(op.referenceItem)})`].join(': ')\n }\n // @ts-expect-error all cases are covered\n throw new Error(`Invalid operation type: ${op.type}`)\n}\n","import {type Index, type KeyedPathElement} from '../path'\nimport {isObject} from '../utils/isObject'\nimport {\n insert as _insert,\n replace as _replace,\n upsert as _upsert,\n} from './operations/creators'\nimport {type RelativePosition} from './operations/types'\n\nexport function autoKeys<Item>(generateKey: (item: Item) => string) {\n const ensureKeys = createEnsureKeys(generateKey)\n\n const insert = <\n Pos extends RelativePosition,\n Ref extends Index | KeyedPathElement,\n >(\n position: Pos,\n referenceItem: Ref,\n items: Item[],\n ) => _insert(ensureKeys(items), position, referenceItem)\n\n const upsert = <\n Pos extends RelativePosition,\n ReferenceItem extends KeyedPathElement,\n >(\n items: Item[],\n position: Pos,\n referenceItem: ReferenceItem,\n ) => _upsert(ensureKeys(items), position, referenceItem)\n\n const replace = <\n Pos extends RelativePosition,\n ReferenceItem extends Index | KeyedPathElement,\n >(\n items: Item[],\n position: Pos,\n referenceItem: ReferenceItem,\n ) => _replace(ensureKeys(items), referenceItem)\n\n const insertBefore = <Ref extends Index | KeyedPathElement>(\n ref: Ref,\n items: Item[],\n ) => insert('before', ref, items)\n\n const prepend = (items: Item[]) => insertBefore(0, items)\n\n const insertAfter = <Ref extends Index | KeyedPathElement>(\n ref: Ref,\n items: Item[],\n ) => insert('after', ref, items)\n\n const append = (items: Item[]) => insert('after', -1, items)\n\n return {insert, upsert, replace, insertBefore, prepend, insertAfter, append}\n}\n\nfunction hasKey<T>(item: T): item is T & {_key: string} {\n return isObject(item) && '_key' in item\n}\n\nfunction createEnsureKeys<T>(generateKey: (item: T) => string) {\n return (array: T[]): (T & {_key: string})[] => {\n let didModify = false\n const withKeys = array.map((item): T & {_key: string} => {\n if (!hasKey(item)) {\n didModify = true\n return {...item, _key: generateKey(item)}\n }\n return item\n })\n return didModify ? withKeys : (array as (T & {_key: string})[])\n }\n}\n"],"names":["parsePath","hasKey","encodeMutation","encodeItemRef","patch","stringifyPath","insert","_insert","upsert","_upsert","replace","_replace","insertBefore","isObject"],"mappings":";;;;;;;AAqBO,SAAS,OACd,WACY;AACZ,SAAO,UAAU,IAAI,cAAc;AACrC;AAEO,SAAS,eACd,UACU;AACV,QAAM,CAAC,IAAI,IAAI;AACf,MAAI,SAAS,UAAU;AACrB,UAAM,CAAA,EAAG,EAAE,IAAI;AACf,WAAO,EAAC,IAAI,KAAA;AAAA,EACd,WAAW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AS;AACd,WAAO,CAAC,MAAM,UAAU,cAAc,GAAG,aAAa,CAAC,GAAG,EAAE,KAAK,IAAI;AAGvE,QAAM,IAAI,MAAM,2BAA2B,GAAG,IAAI,EAAE;AACtD;;;;;AC5FO,SAAS,SAAe,aAAqC;AAClE,QAAM,aAAa,iBAAiB,WAAW,GAEzCE,WAAS,CAIb,UACA,eACA,UACGC,OAAQ,WAAW,KAAK,GAAG,UAAU,aAAa,GAEjDC,WAAS,CAIb,OACA,UACA,kBACGC,OAAQ,WAAW,KAAK,GAAG,UAAU,aAAa,GAEjDC,YAAU,CAId,OACA,UACA,kBACGC,QAAS,WAAW,KAAK,GAAG,aAAa,GAExCC,gBAAe,CACnB,KACA,UACGN,SAAO,UAAU,KAAK,KAAK;AAWhC,SAAO,UAACA,UAAA,QAAQE,UAAA,SAAQE,WAAS,cAAAE,eAAc,SAT/B,CAAC,UAAkBA,cAAa,GAAG,KAAK,GASA,aAPpC,CAClB,KACA,UACGN,SAAO,SAAS,KAAK,KAAK,GAIsC,QAFtD,CAAC,UAAkBA,SAAO,SAAS,IAAI,KAAK,EAAA;AAG7D;AAEA,SAAS,OAAU,MAAqC;AACtD,SAAOO,WAAS,IAAI,KAAK,UAAU;AACrC;AAEA,SAAS,iBAAoB,aAAkC;AAC7D,SAAO,CAAC,UAAuC;AAC7C,QAAI,YAAY;AAChB,UAAM,WAAW,MAAM,IAAI,CAAC,SACrB,OAAO,IAAI,IAIT,QAHL,YAAY,IACL,EAAC,GAAG,MAAM,MAAM,YAAY,IAAI,IAG1C;AACD,WAAO,YAAY,WAAY;AAAA,EACjC;AACF;"}
{"version":3,"file":"index.js","sources":["../src/encoders/compact/decode.ts","../src/encoders/compact/encode.ts","../src/mutations/creators.ts","../src/mutations/operations/creators.ts","../src/encoders/form-compat/encode.ts","../src/formatters/compact.ts","../src/mutations/autoKeys.ts"],"sourcesContent":["import {isObject} from 'lodash'\n\nimport {type UpsertOp} from '../../mutations/operations/types'\nimport {\n type Mutation,\n type PatchMutation,\n type SanityDocumentBase,\n} from '../../mutations/types'\nimport {type Index, type KeyedPathElement} from '../../path'\nimport {parse as parsePath} from '../../path/parser/parse'\nimport {\n type CompactMutation,\n type CompactPatchMutation,\n type CreateIfNotExistsMutation,\n type CreateMutation,\n type CreateOrReplaceMutation,\n type DeleteMutation,\n} from './types'\n\nexport {Mutation, SanityDocumentBase}\n\nexport function decode<Doc extends SanityDocumentBase>(\n mutations: CompactMutation<Doc>[],\n): Mutation[] {\n return mutations.map(decodeMutation)\n}\n\nexport function decodeMutation<Doc extends SanityDocumentBase>(\n mutation: CompactMutation<Doc>,\n): Mutation {\n const [type] = mutation\n if (type === 'delete') {\n const [, id] = mutation as DeleteMutation\n return {id, type}\n } else if (type === 'create') {\n const [, document] = mutation as CreateMutation<Doc>\n return {type, document}\n } else if (type === 'createIfNotExists') {\n const [, document] = mutation as CreateIfNotExistsMutation<Doc>\n return {type, document}\n } else if (type === 'createOrReplace') {\n const [, document] = mutation as CreateOrReplaceMutation<Doc>\n return {type, document}\n } else if (type === 'patch') {\n return decodePatchMutation(mutation)\n }\n throw new Error(`Unrecognized mutation: ${JSON.stringify(mutation)}`)\n}\n\nfunction decodePatchMutation(mutation: CompactPatchMutation): PatchMutation {\n const [, type, id, serializedPath, , revisionId] = mutation\n\n const path = parsePath(serializedPath)\n if (type === 'dec' || type === 'inc') {\n const [, , , , [amount]] = mutation\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'inc', amount}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'unset') {\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'unset'}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'insert') {\n const [, , , , [position, ref, items]] = mutation\n return {\n type: 'patch',\n id,\n patches: [\n {\n path,\n op: {\n type: 'insert',\n position,\n items,\n referenceItem: typeof ref === 'string' ? {_key: ref} : ref,\n },\n },\n ],\n ...createOpts(revisionId),\n }\n }\n if (type === 'set') {\n const [, , , , [value]] = mutation\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'set', value}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'setIfMissing') {\n const [, , , , [value]] = mutation\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'setIfMissing', value}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'diffMatchPatch') {\n const [, , , , [value]] = mutation\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'diffMatchPatch', value}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'truncate') {\n const [, , , , [startIndex, endIndex]] = mutation\n\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'truncate', startIndex, endIndex}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'assign') {\n const [, , , , [value]] = mutation\n return {\n type: 'patch',\n id,\n patches: [{path, op: {type: 'assign', value}}],\n ...createOpts(revisionId),\n }\n }\n if (type === 'replace') {\n const [, , , , [ref, items]] = mutation\n return {\n type: 'patch',\n id,\n patches: [\n {path, op: {type: 'replace', items, referenceItem: decodeItemRef(ref)}},\n ],\n ...createOpts(revisionId),\n }\n }\n if (type === 'upsert') {\n const [, , , , [position, referenceItem, items]] = mutation\n const decodedReferenceItem = decodeItemRef(referenceItem)\n return {\n type: 'patch',\n id,\n patches: [\n {\n path,\n op: {\n type: 'upsert',\n items,\n referenceItem: decodedReferenceItem,\n position,\n } as UpsertOp<typeof items, typeof position, any>,\n },\n ],\n ...createOpts(revisionId),\n }\n }\n throw new Error(`Invalid mutation type: ${type}`)\n}\n\nfunction decodeItemRef(ref: unknown): Index | KeyedPathElement {\n if (typeof ref === 'string') {\n return {_key: ref}\n }\n if (typeof ref === 'number') {\n return ref\n }\n if (!hasKey(ref)) {\n throw new Error('Cannot decode upsert patch: referenceItem is missing key')\n }\n return ref\n}\n\nfunction createOpts(revisionId: undefined | string) {\n return revisionId ? {options: {ifRevision: revisionId}} : null\n}\n\nfunction hasKey<T>(item: T): item is T & {_key: string} {\n return isObject(item) && '_key' in item\n}\n","// An example of a compact transport/serialization format\nimport {\n type Mutation,\n type NodePatch,\n type SanityDocumentBase,\n} from '../../mutations/types'\nimport {type Index, type KeyedPathElement} from '../../path'\nimport {stringify as stringifyPath} from '../../path/parser/stringify'\nimport {\n type CompactMutation,\n type CompactPatchMutation,\n type ItemRef,\n} from './types'\n\nexport function encode<Doc extends SanityDocumentBase>(\n mutations: Mutation[],\n): CompactMutation<Doc>[] {\n return mutations.flatMap(m => encodeMutation<Doc>(m))\n}\n\nfunction encodeItemRef(ref: Index | KeyedPathElement): ItemRef {\n return typeof ref === 'number' ? ref : ref._key\n}\n\nfunction encodeMutation<Doc extends SanityDocumentBase>(\n mutation: Mutation,\n): CompactMutation<Doc>[] {\n if (\n mutation.type === 'create' ||\n mutation.type === 'createIfNotExists' ||\n mutation.type === 'createOrReplace'\n ) {\n return [[mutation.type, mutation.document]]\n }\n if (mutation.type === 'delete') {\n return [['delete', mutation.id]]\n }\n if (mutation.type === 'patch') {\n return mutation.patches.map(patch =>\n maybeAddRevision(\n mutation.options?.ifRevision,\n encodePatchMutation(mutation.id, patch),\n ),\n )\n }\n\n //@ts-expect-error - all cases are covered\n throw new Error(`Invalid mutation type: ${mutation.type}`)\n}\n\nfunction encodePatchMutation(\n id: string,\n patch: NodePatch<any>,\n): CompactPatchMutation {\n const {op} = patch\n const path = stringifyPath(patch.path)\n if (op.type === 'unset') {\n return ['patch', 'unset', id, path, []]\n }\n if (op.type === 'diffMatchPatch') {\n return ['patch', 'diffMatchPatch', id, path, [op.value]]\n }\n if (op.type === 'inc' || op.type === 'dec') {\n return ['patch', op.type, id, path, [op.amount]]\n }\n if (op.type === 'set') {\n return ['patch', op.type, id, path, [op.value]]\n }\n if (op.type === 'setIfMissing') {\n return ['patch', op.type, id, path, [op.value]]\n }\n if (op.type === 'insert') {\n return [\n 'patch',\n 'insert',\n id,\n path,\n [op.position, encodeItemRef(op.referenceItem), op.items],\n ]\n }\n if (op.type === 'upsert') {\n return [\n 'patch',\n 'upsert',\n id,\n path,\n [op.position, encodeItemRef(op.referenceItem), op.items],\n ]\n }\n if (op.type === 'insertIfMissing') {\n return [\n 'patch',\n 'insertIfMissing',\n id,\n path,\n [op.position, encodeItemRef(op.referenceItem), op.items],\n ]\n }\n if (op.type === 'assign') {\n return ['patch', 'assign', id, path, [op.value]]\n }\n if (op.type === 'unassign') {\n return ['patch', 'assign', id, path, [op.keys]]\n }\n if (op.type === 'replace') {\n return [\n 'patch',\n 'replace',\n id,\n path,\n [encodeItemRef(op.referenceItem), op.items],\n ]\n }\n if (op.type === 'truncate') {\n return ['patch', 'truncate', id, path, [op.startIndex, op.endIndex]]\n }\n if (op.type === 'remove') {\n return ['patch', 'remove', id, path, [encodeItemRef(op.referenceItem)]]\n }\n // @ts-expect-error all cases are covered\n throw new Error(`Invalid operation type: ${op.type}`)\n}\n\nfunction maybeAddRevision<T extends CompactPatchMutation>(\n revision: string | undefined,\n mut: T,\n): T {\n const [mutType, patchType, id, path, args] = mut\n return (revision ? [mutType, patchType, id, path, args, revision] : mut) as T\n}\n","import {parse, type Path, type SafePath} from '../path'\nimport {arrify} from '../utils/arrify'\nimport {\n type NormalizeReadOnlyArray,\n type Optional,\n type Tuplify,\n} from '../utils/typeUtils'\nimport {type Operation} from './operations/types'\nimport {\n type CreateIfNotExistsMutation,\n type CreateMutation,\n type CreateOrReplaceMutation,\n type DeleteMutation,\n type NodePatch,\n type NodePatchList,\n type PatchMutation,\n type PatchOptions,\n type SanityDocumentBase,\n} from './types'\n\nexport function create<const Doc extends Optional<SanityDocumentBase, '_id'>>(\n document: Doc,\n): CreateMutation<Doc> {\n return {type: 'create', document}\n}\n\nexport function patch<P extends NodePatchList | NodePatch>(\n id: string,\n patches: P,\n options?: PatchOptions,\n): PatchMutation<NormalizeReadOnlyArray<Tuplify<P>>> {\n return {\n type: 'patch',\n id,\n patches: arrify(patches) as any,\n ...(options ? {options} : {}),\n }\n}\n\nexport function at<const P extends Path, O extends Operation>(\n path: P,\n operation: O,\n): NodePatch<NormalizeReadOnlyArray<P>, O>\n\nexport function at<const P extends string, O extends Operation>(\n path: P,\n operation: O,\n): NodePatch<SafePath<P>, O>\n\nexport function at<O extends Operation>(\n path: Path | string,\n operation: O,\n): NodePatch<Path, O> {\n return {\n path: typeof path === 'string' ? parse(path) : path,\n op: operation,\n }\n}\n\nexport function createIfNotExists<const Doc extends SanityDocumentBase>(\n document: Doc,\n): CreateIfNotExistsMutation<Doc> {\n return {type: 'createIfNotExists', document}\n}\n\nexport function createOrReplace<const Doc extends SanityDocumentBase>(\n document: Doc,\n): CreateOrReplaceMutation<Doc> {\n return {type: 'createOrReplace', document}\n}\n\nexport function delete_<const Id extends string>(id: Id): DeleteMutation<Id> {\n return {type: 'delete', id}\n}\n\nexport const del = delete_\nexport const destroy = delete_\n","import {type Arrify, arrify} from '../../utils/arrify'\nimport {\n type AnyArray,\n type ArrayElement,\n type NormalizeReadOnlyArray,\n} from '../../utils/typeUtils'\nimport {\n type AssignOp,\n type DecOp,\n type DiffMatchPatchOp,\n type IncOp,\n type Index,\n type InsertIfMissingOp,\n type InsertOp,\n type KeyedPathElement,\n type RelativePosition,\n type RemoveOp,\n type ReplaceOp,\n type SetIfMissingOp,\n type SetOp,\n type TruncateOp,\n type UnassignOp,\n type UnsetOp,\n type UpsertOp,\n} from './types'\n\nexport const set = <const T>(value: T): SetOp<T> => ({type: 'set', value})\n\nexport const assign = <const T extends {[K in string]: unknown}>(\n value: T,\n): AssignOp<T> => ({\n type: 'assign',\n value,\n})\n\nexport const unassign = <const K extends readonly string[]>(\n keys: K,\n): UnassignOp<K> => ({\n type: 'unassign',\n keys,\n})\n\nexport const setIfMissing = <const T>(value: T): SetIfMissingOp<T> => ({\n type: 'setIfMissing',\n value,\n})\n\nexport const unset = (): UnsetOp => ({type: 'unset'})\n\nexport const inc = <const N extends number = 1>(\n amount: N = 1 as N,\n): IncOp<N> => ({\n type: 'inc',\n amount,\n})\n\nexport const dec = <const N extends number = 1>(\n amount: N = 1 as N,\n): DecOp<N> => ({\n type: 'dec',\n amount,\n})\n\nexport const diffMatchPatch = (value: string): DiffMatchPatchOp => ({\n type: 'diffMatchPatch',\n value,\n})\n\nexport function insert<\n const Items extends AnyArray<unknown>,\n const Pos extends RelativePosition,\n const ReferenceItem extends Index | KeyedPathElement,\n>(\n items: Items | ArrayElement<Items>,\n position: Pos,\n indexOrReferenceItem: ReferenceItem,\n): InsertOp<NormalizeReadOnlyArray<Items>, Pos, ReferenceItem> {\n return {\n type: 'insert',\n referenceItem: indexOrReferenceItem,\n position,\n items: arrify(items) as any,\n }\n}\n\nexport function append<const Items extends AnyArray<unknown>>(\n items: Items | ArrayElement<Items>,\n) {\n return insert(items, 'after', -1)\n}\n\nexport function prepend<const Items extends AnyArray<unknown>>(\n items: Items | ArrayElement<Items>,\n) {\n return insert(items, 'before', 0)\n}\n\nexport function insertBefore<\n const Items extends AnyArray<unknown>,\n const ReferenceItem extends Index | KeyedPathElement,\n>(items: Items | ArrayElement<Items>, indexOrReferenceItem: ReferenceItem) {\n return insert(items, 'before', indexOrReferenceItem)\n}\n\nexport const insertAfter = <\n const Items extends AnyArray<unknown>,\n const ReferenceItem extends Index | KeyedPathElement,\n>(\n items: Items | ArrayElement<Items>,\n indexOrReferenceItem: ReferenceItem,\n) => {\n return insert(items, 'after', indexOrReferenceItem)\n}\n\nexport function truncate(startIndex: number, endIndex?: number): TruncateOp {\n return {\n type: 'truncate',\n startIndex,\n endIndex,\n }\n}\n\n/*\n Use this when you know the ref Items already exists\n */\nexport function replace<\n Items extends any[],\n ReferenceItem extends Index | KeyedPathElement,\n>(\n items: Items | ArrayElement<Items>,\n referenceItem: ReferenceItem,\n): ReplaceOp<Items, ReferenceItem> {\n return {\n type: 'replace',\n referenceItem,\n items: arrify(items) as Items,\n }\n}\n\n/*\n Remove an item from an array by either key or index\n */\nexport function remove<ReferenceItem extends Index | KeyedPathElement>(\n referenceItem: ReferenceItem,\n): RemoveOp<ReferenceItem> {\n return {\n type: 'remove',\n referenceItem,\n }\n}\n\n/*\nuse this when the reference Items may or may not exist\n */\nexport function upsert<\n const Item extends {_key: string},\n const Pos extends RelativePosition,\n const ReferenceItem extends Index | KeyedPathElement,\n>(\n items: Item | Item[],\n position: Pos,\n referenceItem: ReferenceItem,\n): UpsertOp<Arrify<Item>, Pos, ReferenceItem> {\n return {\n type: 'upsert',\n items: arrify(items) as Arrify<Item>,\n referenceItem,\n position,\n }\n}\n\n/*\nuse this when the reference Items may or may not exist\n */\nexport function insertIfMissing<\n const Item extends {_key: string},\n const Pos extends RelativePosition,\n const ReferenceItem extends Index | KeyedPathElement,\n>(\n items: Item | Item[],\n position: Pos,\n referenceItem: ReferenceItem,\n): InsertIfMissingOp<Arrify<Item>, Pos, ReferenceItem> {\n return {\n type: 'insertIfMissing',\n items: arrify(items) as Arrify<Item>,\n referenceItem,\n position,\n }\n}\n","import {at} from '../../mutations/creators'\nimport {\n diffMatchPatch,\n insert,\n set,\n setIfMissing,\n unset,\n} from '../../mutations/operations/creators'\nimport {type NodePatch} from '../../mutations/types'\nimport {type KeyedPathElement} from '../../path'\nimport {\n type CompatPath,\n type FormPatchLike,\n type FormPatchPath,\n} from './form-patch-types'\n\nfunction assertCompatible(formPatchPath: FormPatchPath): CompatPath {\n if (formPatchPath.length === 0) {\n return formPatchPath as never[]\n }\n for (const element of formPatchPath) {\n if (Array.isArray(element)) {\n throw new Error('Form patch paths cannot include arrays')\n }\n }\n return formPatchPath as CompatPath\n}\n\n/**\n * Convert a Sanity form patch (ie emitted from an input component) to a {@link NodePatch}\n * Note the lack of encodeMutation here. Sanity forms never emit *mutations*, only patches\n * @param patches - Array of {@link FormPatchLike}\n * @internal\n */\nexport function encodePatches(patches: FormPatchLike[]): NodePatch[] {\n return patches.map(formPatch => {\n const path = assertCompatible(formPatch.path)\n if (formPatch.type === 'unset') {\n return at(path, unset())\n }\n if (formPatch.type === 'set') {\n return at(path, set(formPatch.value))\n }\n if (formPatch.type === 'setIfMissing') {\n return at(path, setIfMissing(formPatch.value))\n }\n if (formPatch.type === 'insert') {\n const arrayPath = path.slice(0, -1)\n const itemRef = formPatch.path[formPatch.path.length - 1]\n return at(\n arrayPath,\n insert(\n formPatch.items,\n formPatch.position,\n itemRef as number | KeyedPathElement,\n ),\n )\n }\n if (formPatch.type === 'diffMatchPatch') {\n return at(path, diffMatchPatch(formPatch.value))\n }\n // @ts-expect-error - should be exhaustive\n throw new Error(`Unknown patch type ${formPatch.type}`)\n })\n}\n","// An example of a compact formatter\n\nimport {\n type Mutation,\n type NodePatch,\n type SanityDocumentBase,\n} from '../mutations/types'\nimport {type Index, type KeyedPathElement, stringify} from '../path'\n\nexport type ItemRef = string | number\n\nexport function format<Doc extends SanityDocumentBase>(\n mutations: Mutation[],\n): string {\n return mutations.flatMap(m => encodeMutation<Doc>(m)).join('\\n')\n}\n\nfunction encodeItemRef(ref: Index | KeyedPathElement): ItemRef {\n return typeof ref === 'number' ? ref : ref._key\n}\n\nfunction encodeMutation<Doc extends SanityDocumentBase>(\n mutation: Mutation,\n): string {\n if (\n mutation.type === 'create' ||\n mutation.type === 'createIfNotExists' ||\n mutation.type === 'createOrReplace'\n ) {\n return [mutation.type, ': ', JSON.stringify(mutation.document)].join('')\n }\n if (mutation.type === 'delete') {\n return ['delete ', mutation.id].join(': ')\n }\n if (mutation.type === 'patch') {\n const ifRevision = mutation.options?.ifRevision\n return [\n 'patch',\n ' ',\n `id=${mutation.id}`,\n ifRevision ? ` (if revision==${ifRevision})` : '',\n ':\\n',\n mutation.patches\n .map(nodePatch => ` ${formatPatchMutation(nodePatch)}`)\n .join('\\n'),\n ].join('')\n }\n\n //@ts-expect-error - all cases are covered\n throw new Error(`Invalid mutation type: ${mutation.type}`)\n}\n\nfunction formatPatchMutation(patch: NodePatch<any>): string {\n const {op} = patch\n const path = stringify(patch.path)\n if (op.type === 'unset') {\n return [path, 'unset()'].join(': ')\n }\n if (op.type === 'diffMatchPatch') {\n return [path, `diffMatchPatch(${op.value})`].join(': ')\n }\n if (op.type === 'inc' || op.type === 'dec') {\n return [path, `${op.type}(${op.amount})`].join(': ')\n }\n if (op.type === 'set' || op.type === 'setIfMissing') {\n return [path, `${op.type}(${JSON.stringify(op.value)})`].join(': ')\n }\n if (op.type === 'assign') {\n return [path, `${op.type}(${JSON.stringify(op.value)})`].join(': ')\n }\n if (op.type === 'unassign') {\n return [path, `${op.type}(${JSON.stringify(op.keys)})`].join(': ')\n }\n if (\n op.type === 'insert' ||\n op.type === 'upsert' ||\n op.type === 'insertIfMissing'\n ) {\n return [\n path,\n `${op.type}(${op.position}, ${encodeItemRef(\n op.referenceItem,\n )}, ${JSON.stringify(op.items)})`,\n ].join(': ')\n }\n if (op.type === 'replace') {\n return [\n path,\n `replace(${encodeItemRef(op.referenceItem)}, ${JSON.stringify(\n op.items,\n )})`,\n ].join(': ')\n }\n if (op.type === 'truncate') {\n return [path, `truncate(${op.startIndex}, ${op.endIndex}`].join(': ')\n }\n if (op.type === 'remove') {\n return [path, `remove(${encodeItemRef(op.referenceItem)})`].join(': ')\n }\n // @ts-expect-error all cases are covered\n throw new Error(`Invalid operation type: ${op.type}`)\n}\n","import {type Index, type KeyedPathElement} from '../path'\nimport {type Arrify} from '../utils/arrify'\nimport {isObject} from '../utils/isObject'\nimport {\n insert as _insert,\n replace as _replace,\n upsert as _upsert,\n} from './operations/creators'\nimport {\n type InsertOp,\n type RelativePosition,\n type ReplaceOp,\n type UpsertOp,\n} from './operations/types'\n\nexport function autoKeys<Item>(generateKey: (item: Item) => string) {\n const ensureKeys = createEnsureKeys(generateKey)\n\n const insert = <\n Pos extends RelativePosition,\n Ref extends Index | KeyedPathElement,\n >(\n position: Pos,\n referenceItem: Ref,\n items: Item[],\n ): InsertOp<(Item & {_key: string})[], Pos, Ref> =>\n _insert(ensureKeys(items), position, referenceItem)\n\n const upsert = <\n Pos extends RelativePosition,\n ReferenceItem extends KeyedPathElement,\n >(\n items: Item[],\n position: Pos,\n referenceItem: ReferenceItem,\n ): UpsertOp<Arrify<Item & {_key: string}>, Pos, ReferenceItem> =>\n _upsert(ensureKeys(items), position, referenceItem)\n\n const replace = <\n Pos extends RelativePosition,\n ReferenceItem extends Index | KeyedPathElement,\n >(\n items: Item[],\n position: Pos,\n referenceItem: ReferenceItem,\n ): ReplaceOp<(Item & {_key: string})[], ReferenceItem> =>\n _replace(ensureKeys(items), referenceItem)\n\n const insertBefore = <Ref extends Index | KeyedPathElement>(\n ref: Ref,\n items: Item[],\n ): InsertOp<(Item & {_key: string})[], 'before', Ref> =>\n insert('before', ref, items)\n\n const prepend = (\n items: Item[],\n ): InsertOp<(Item & {_key: string})[], 'before', 0> => insertBefore(0, items)\n\n const insertAfter = <Ref extends Index | KeyedPathElement>(\n ref: Ref,\n items: Item[],\n ): InsertOp<(Item & {_key: string})[], 'after', Ref> =>\n insert('after', ref, items)\n\n const append = (\n items: Item[],\n ): InsertOp<(Item & {_key: string})[], 'after', -1> =>\n insert('after', -1, items)\n\n return {insert, upsert, replace, insertBefore, prepend, insertAfter, append}\n}\n\nfunction hasKey<T>(item: T): item is T & {_key: string} {\n return isObject(item) && '_key' in item\n}\n\nfunction createEnsureKeys<T>(generateKey: (item: T) => string) {\n return (array: T[]): (T & {_key: string})[] => {\n let didModify = false\n const withKeys = array.map((item): T & {_key: string} => {\n if (!hasKey(item)) {\n didModify = true\n return {...item, _key: generateKey(item)}\n }\n return item\n })\n return didModify ? withKeys : (array as (T & {_key: string})[])\n }\n}\n"],"names":["parsePath","hasKey","encodeMutation","encodeItemRef","patch","stringifyPath","insert","_insert","upsert","_upsert","replace","_replace","insertBefore","isObject"],"mappings":";;;;;;;AAqBO,SAAS,OACd,WACY;AACZ,SAAO,UAAU,IAAI,cAAc;AACrC;AAEO,SAAS,eACd,UACU;AACV,QAAM,CAAC,IAAI,IAAI;AACf,MAAI,SAAS,UAAU;AACrB,UAAM,CAAA,EAAG,EAAE,IAAI;AACf,WAAO,EAAC,IAAI,KAAA;AAAA,EACd,WAAW,SAAS,UAAU;AAC5B,UAAM,C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UAAU,cAAc,GAAG,aAAa,CAAC,GAAG,EAAE,KAAK,IAAI;AAGvE,QAAM,IAAI,MAAM,2BAA2B,GAAG,IAAI,EAAE;AACtD;;;;;ACtFO,SAAS,SAAe,aAAqC;AAClE,QAAM,aAAa,iBAAiB,WAAW,GAEzCE,WAAS,CAIb,UACA,eACA,UAEAC,OAAQ,WAAW,KAAK,GAAG,UAAU,aAAa,GAE9CC,WAAS,CAIb,OACA,UACA,kBAEAC,OAAQ,WAAW,KAAK,GAAG,UAAU,aAAa,GAE9CC,YAAU,CAId,OACA,UACA,kBAEAC,QAAS,WAAW,KAAK,GAAG,aAAa,GAErCC,gBAAe,CACnB,KACA,UAEAN,SAAO,UAAU,KAAK,KAAK;AAiB7B,SAAO,UAACA,UAAA,QAAQE,UAAA,SAAQE,WAAS,cAAAE,eAAc,SAf/B,CACd,UACqDA,cAAa,GAAG,KAAK,GAapB,aAXpC,CAClB,KACA,UAEAN,SAAO,SAAS,KAAK,KAAK,GAOyC,QALtD,CACb,UAEAA,SAAO,SAAS,IAAI,KAAK,EAAA;AAG7B;AAEA,SAAS,OAAU,MAAqC;AACtD,SAAOO,WAAS,IAAI,KAAK,UAAU;AACrC;AAEA,SAAS,iBAAoB,aAAkC;AAC7D,SAAO,CAAC,UAAuC;AAC7C,QAAI,YAAY;AAChB,UAAM,WAAW,MAAM,IAAI,CAAC,SACrB,OAAO,IAAI,IAIT,QAHL,YAAY,IACL,EAAC,GAAG,MAAM,MAAM,YAAY,IAAI,IAG1C;AACD,WAAO,YAAY,WAAY;AAAA,EACjC;AACF;"}
{
"name": "@sanity/mutate",
"version": "0.17.1",
"version": "0.18.0",
"description": "Experimental toolkit for working with Sanity mutations in JavaScript & TypeScript",

@@ -64,2 +64,3 @@ "keywords": [

"eslint-plugin-unused-imports": "^4.4.1",
"lefthook": "^2.1.6",
"npm-run-all2": "^8.0.4",

@@ -69,2 +70,3 @@ "prettier": "^3.8.3",

"rimraf": "^6.1.3",
"std-env": "^4.1.0",
"tsx": "^4.21.0",

@@ -88,4 +90,4 @@ "typescript": "^6.0.3",

"dev": "run-p pkg:watch",
"docs:build": "pnpm --filter @sanity/mutate-docs run build",
"docs:dev": "pnpm --filter @sanity/mutate-docs run dev",
"docs:build": "pnpm --filter @sanity/mutate-docs run build",
"docs:preview": "pnpm --filter @sanity/mutate-docs run preview",

@@ -92,0 +94,0 @@ "example:visual-editing": "pnpm --filter example-visual-editing run dev",

@@ -65,10 +65,10 @@ <p align="center">

Full reference and guides at **<https://sanity-io.github.io/mutate>** (sources in [`docs/`](./docs); run the site locally with `pnpm docs:dev`):
Full reference and guides at **<https://mutate.sanity.dev>** (sources in [`docs/`](./docs); run the site locally with `pnpm docs:dev`):
- [Getting Started](https://sanity-io.github.io/mutate/guide/getting-started)
- [Applying Mutations](https://sanity-io.github.io/mutate/guide/applying-mutations) — in-memory apply
- [Optimistic Store](https://sanity-io.github.io/mutate/guide/optimistic-store) — local replica with rebase
- [Recipes](https://sanity-io.github.io/mutate/guide/recipes)
- [Differences from the Sanity API](https://sanity-io.github.io/mutate/guide/differences-from-sanity-api)
- API reference: [mutations](https://sanity-io.github.io/mutate/api/mutations), [patches](https://sanity-io.github.io/mutate/api/patches), [operations](https://sanity-io.github.io/mutate/api/operations), [encoders](https://sanity-io.github.io/mutate/api/encoders)
- [Getting Started](https://mutate.sanity.dev/guide/getting-started)
- [Applying Mutations](https://mutate.sanity.dev/guide/applying-mutations) — in-memory apply
- [Optimistic Store](https://mutate.sanity.dev/guide/optimistic-store) — local replica with rebase
- [Recipes](https://mutate.sanity.dev/guide/recipes)
- [Differences from the Sanity API](https://mutate.sanity.dev/guide/differences-from-sanity-api)
- API reference: [mutations](https://mutate.sanity.dev/api/mutations), [patches](https://mutate.sanity.dev/api/patches), [operations](https://mutate.sanity.dev/api/operations), [encoders](https://mutate.sanity.dev/api/encoders)

@@ -75,0 +75,0 @@ ## License