UNPKG

@sanity/mutate

Version:

Experimental toolkit for working with Sanity mutations in JavaScript & TypeScript

170 lines 4.62 kB
import { a as IdentifiedSanityDocument, d as SanityDocumentBase, f as Transaction, o as Mutation, s as NodePatch } from "./types.js"; import { Mutation as SanityMutation, PatchMutationOperation, PatchOperations } from "@sanity/client"; type SanityDiffMatchPatch = { id: string; diffMatchPatch: { [path: string]: string; }; }; type SanitySetPatch = { id: string; set: { [path: string]: any; }; }; type InsertBefore = { before: string; items: any[]; }; type InsertAfter = { after: string; items: any[]; }; type InsertReplace = { replace: string; items: any[]; }; type Insert = InsertBefore | InsertAfter | InsertReplace; type SanityInsertPatch = { id: string; insert: Insert; }; type SanityUnsetPatch = { id: string; unset: string[]; }; type SanityIncPatch = { id: string; inc: { [path: string]: number; }; }; type SanityDecPatch = { id: string; dec: { [path: string]: number; }; }; type SanitySetIfMissingPatch = { id: string; setIfMissing: { [path: string]: any; }; }; type SanityPatch = PatchOperations & { id: string; }; type SanityCreateIfNotExistsMutation<Doc extends IdentifiedSanityDocument = IdentifiedSanityDocument> = { createIfNotExists: Doc; }; type SanityCreateOrReplaceMutation<Doc extends IdentifiedSanityDocument = IdentifiedSanityDocument> = { createOrReplace: Doc; }; type SanityCreateMutation<Doc extends SanityDocumentBase> = { create: Doc; }; type SanityDeleteMutation = { delete: { id: string; }; }; declare function decodeAll<Doc extends SanityDocumentBase>(sanityMutations: SanityMutation<Doc>[]): Mutation[]; declare function decode<Doc extends SanityDocumentBase>(encodedMutation: SanityMutation<Doc>): Mutation; declare function encode(mutation: Mutation): SanityMutation[] | SanityMutation; declare function encodeAll(mutations: Mutation[]): SanityMutation[]; declare function encodeTransaction(transaction: Transaction): { transactionId: string | undefined; mutations: SanityMutation[]; }; declare function encodeMutation(mutation: Mutation): SanityMutation[] | SanityMutation; declare function encodePatch(patch: NodePatch): { unset: string[]; insert?: undefined; diffMatchPatch?: undefined; inc?: undefined; dec?: undefined; set?: undefined; } | { insert: { [x: string]: string | readonly any[]; items: undefined; replace?: undefined; }; unset?: undefined; diffMatchPatch?: undefined; inc?: undefined; dec?: undefined; set?: undefined; } | { diffMatchPatch: { [x: string]: string; }; unset?: undefined; insert?: undefined; inc?: undefined; dec?: undefined; set?: undefined; } | { inc: { [x: string]: number; }; unset?: undefined; insert?: undefined; diffMatchPatch?: undefined; dec?: undefined; set?: undefined; } | { dec: { [x: string]: number; }; unset?: undefined; insert?: undefined; diffMatchPatch?: undefined; inc?: undefined; set?: undefined; } | { [x: string]: { [x: string]: unknown; }; unset?: undefined; insert?: undefined; diffMatchPatch?: undefined; inc?: undefined; dec?: undefined; set?: undefined; } | { unset: string[]; insert: { [x: string]: string | readonly any[]; items: undefined; replace?: undefined; }; diffMatchPatch?: undefined; inc?: undefined; dec?: undefined; set?: undefined; } | { set: { [k: string]: never; }; unset?: undefined; insert?: undefined; diffMatchPatch?: undefined; inc?: undefined; dec?: undefined; } | { insert: { replace: string; items: undefined; }; unset?: undefined; diffMatchPatch?: undefined; inc?: undefined; dec?: undefined; set?: undefined; }; declare namespace index_d_exports { export { Insert, InsertAfter, InsertBefore, InsertReplace, Mutation, PatchMutationOperation, SanityCreateIfNotExistsMutation, SanityCreateMutation, SanityCreateOrReplaceMutation, SanityDecPatch, SanityDeleteMutation, SanityDiffMatchPatch, SanityDocumentBase, SanityIncPatch, SanityInsertPatch, SanityMutation, SanityPatch, SanitySetIfMissingPatch, SanitySetPatch, SanityUnsetPatch, decode, decodeAll, encode, encodeAll, encodeMutation, encodePatch, encodeTransaction }; } export { SanityCreateOrReplaceMutation as a, SanityDiffMatchPatch as c, SanityMutation as d, SanitySetIfMissingPatch as f, __exportAll as h, SanityCreateMutation as i, SanityIncPatch as l, SanityUnsetPatch as m, Insert as n, SanityDecPatch as o, SanitySetPatch as p, SanityCreateIfNotExistsMutation as r, SanityDeleteMutation as s, index_d_exports as t, SanityInsertPatch as u }; //# sourceMappingURL=index.d.ts.map