{"version":3,"file":"index.browser.cjs","sources":["../src/http/browserMiddleware.ts","../src/http/errors.ts","../src/http/request.ts","../src/http/requestOptions.ts","../src/util/getSelection.ts","../src/validators.ts","../src/data/encodeQueryString.ts","../src/data/patch.ts","../src/data/transaction.ts","../src/data/dataMethods.ts","../src/assets/AssetsClient.ts","../src/generateHelpUrl.ts","../src/util/once.ts","../src/warnings.ts","../src/config.ts","../src/util/defaults.ts","../src/util/pick.ts","../src/data/listen.ts","../src/datasets/DatasetsClient.ts","../src/projects/ProjectsClient.ts","../src/users/UsersClient.ts","../src/SanityClient.ts","../src/index.browser.ts"],"sourcesContent":["export default []\n","import type {Any, ErrorProps, MutationError} from '../types'\n\nconst MAX_ITEMS_IN_ERROR_MESSAGE = 5\n\n/** @public */\nexport class ClientError extends Error {\n response: ErrorProps['response']\n statusCode: ErrorProps['statusCode'] = 400\n responseBody: ErrorProps['responseBody']\n details: ErrorProps['details']\n\n constructor(res: Any) {\n const props = extractErrorProps(res)\n super(props.message)\n Object.assign(this, props)\n }\n}\n\n/** @public */\nexport class ServerError extends Error {\n response: ErrorProps['response']\n statusCode: ErrorProps['statusCode'] = 500\n responseBody: ErrorProps['responseBody']\n details: ErrorProps['details']\n\n constructor(res: Any) {\n const props = extractErrorProps(res)\n super(props.message)\n Object.assign(this, props)\n }\n}\n\nfunction extractErrorProps(res: Any): ErrorProps {\n const body = res.body\n const props = {\n response: res,\n statusCode: res.statusCode,\n responseBody: stringifyBody(body, res),\n message: '',\n details: undefined as Any,\n }\n\n // API/Boom style errors ({statusCode, error, message})\n if (body.error && body.message) {\n props.message = `${body.error} - ${body.message}`\n return props\n }\n\n // Mutation errors (specifically)\n if (isMutationError(body)) {\n const allItems = body.error.items || []\n const items = allItems\n .slice(0, MAX_ITEMS_IN_ERROR_MESSAGE)\n .map((item) => item.error?.description)\n .filter(Boolean)\n let itemsStr = items.length ? `:\\n- ${items.join('\\n- ')}` : ''\n if (allItems.length > MAX_ITEMS_IN_ERROR_MESSAGE) {\n itemsStr += `\\n...and ${allItems.length - MAX_ITEMS_IN_ERROR_MESSAGE} more`\n }\n props.message = `${body.error.description}${itemsStr}`\n props.details = body.error\n return props\n }\n\n // Query/database errors ({error: {description, other, arb, props}})\n if (body.error && body.error.description) {\n props.message = body.error.description\n props.details = body.error\n return props\n }\n\n // Other, more arbitrary errors\n props.message = body.error || body.message || httpErrorMessage(res)\n return props\n}\n\nfunction isMutationError(body: Any): body is MutationError {\n return (\n isPlainObject(body) &&\n isPlainObject(body.error) &&\n body.error.type === 'mutationError' &&\n typeof body.error.description === 'string'\n )\n}\n\nfunction isPlainObject(obj: Any): obj is Record {\n return typeof obj === 'object' && obj !== null && !Array.isArray(obj)\n}\n\nfunction httpErrorMessage(res: Any) {\n const statusMessage = res.statusMessage ? ` ${res.statusMessage}` : ''\n return `${res.method}-request to ${res.url} resulted in HTTP ${res.statusCode}${statusMessage}`\n}\n\nfunction stringifyBody(body: Any, res: Any) {\n const contentType = (res.headers['content-type'] || '').toLowerCase()\n const isJson = contentType.indexOf('application/json') !== -1\n return isJson ? JSON.stringify(body, null, 2) : body\n}\n","import {getIt, type Middlewares} from 'get-it'\nimport {jsonRequest, jsonResponse, observable, progress} from 'get-it/middleware'\nimport {Observable} from 'rxjs'\n\nimport type {Any, HttpRequest, RequestOptions} from '../types'\nimport {ClientError, ServerError} from './errors'\n\nconst httpError = {\n onResponse: (res: Any) => {\n if (res.statusCode >= 500) {\n throw new ServerError(res)\n } else if (res.statusCode >= 400) {\n throw new ClientError(res)\n }\n\n return res\n },\n}\n\nconst printWarnings = {\n onResponse: (res: Any) => {\n const warn = res.headers['x-sanity-warning']\n const warnings = Array.isArray(warn) ? warn : [warn]\n warnings.filter(Boolean).forEach((msg) => console.warn(msg)) // eslint-disable-line no-console\n return res\n },\n}\n\n/** @internal */\nexport function defineHttpRequest(envMiddleware: Middlewares): HttpRequest {\n const request = getIt([\n ...envMiddleware,\n printWarnings,\n jsonRequest(),\n jsonResponse(),\n progress(),\n httpError,\n observable({implementation: Observable}),\n ])\n\n function httpRequest(options: RequestOptions, requester = request) {\n return requester({maxRedirects: 0, ...options} as Any)\n }\n\n httpRequest.defaultRequester = request\n\n return httpRequest\n}\n","import type {RequestOptions} from 'get-it'\n\nimport type {Any} from '../types'\n\nconst projectHeader = 'X-Sanity-Project-ID'\n\nexport function requestOptions(config: Any, overrides: Any = {}): Omit {\n const headers: Any = {}\n\n const token = overrides.token || config.token\n if (token) {\n headers.Authorization = `Bearer ${token}`\n }\n\n if (!overrides.useGlobalApi && !config.useProjectHostname && config.projectId) {\n headers[projectHeader] = config.projectId\n }\n\n const withCredentials = Boolean(\n typeof overrides.withCredentials === 'undefined'\n ? config.token || config.withCredentials\n : overrides.withCredentials\n )\n\n const timeout = typeof overrides.timeout === 'undefined' ? config.timeout : overrides.timeout\n return Object.assign({}, overrides, {\n headers: Object.assign({}, headers, overrides.headers || {}),\n timeout: typeof timeout === 'undefined' ? 5 * 60 * 1000 : timeout,\n proxy: overrides.proxy || config.proxy,\n json: true,\n withCredentials,\n })\n}\n","import type {MutationSelection} from '../types'\n\nexport function getSelection(sel: unknown): MutationSelection {\n if (typeof sel === 'string' || Array.isArray(sel)) {\n return {id: sel}\n }\n\n if (typeof sel === 'object' && sel !== null && 'query' in sel && typeof sel.query === 'string') {\n return 'params' in sel && typeof sel.params === 'object' && sel.params !== null\n ? {query: sel.query, params: sel.params}\n : {query: sel.query}\n }\n\n const selectionOpts = [\n '* Document ID ()',\n '* Array of document IDs',\n '* Object containing `query`',\n ].join('\\n')\n\n throw new Error(`Unknown selection - must be one of:\\n\\n${selectionOpts}`)\n}\n","import type {Any, InitializedClientConfig} from './types'\n\nconst VALID_ASSET_TYPES = ['image', 'file']\nconst VALID_INSERT_LOCATIONS = ['before', 'after', 'replace']\n\nexport const dataset = (name: string) => {\n if (!/^(~[a-z0-9]{1}[-\\w]{0,63}|[a-z0-9]{1}[-\\w]{0,63})$/.test(name)) {\n throw new Error(\n 'Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters'\n )\n }\n}\n\nexport const projectId = (id: string) => {\n if (!/^[-a-z0-9]+$/i.test(id)) {\n throw new Error('`projectId` can only contain only a-z, 0-9 and dashes')\n }\n}\n\nexport const validateAssetType = (type: string) => {\n if (VALID_ASSET_TYPES.indexOf(type) === -1) {\n throw new Error(`Invalid asset type: ${type}. Must be one of ${VALID_ASSET_TYPES.join(', ')}`)\n }\n}\n\nexport const validateObject = (op: string, val: Any) => {\n if (val === null || typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${op}() takes an object of properties`)\n }\n}\n\nexport const validateDocumentId = (op: string, id: string) => {\n if (typeof id !== 'string' || !/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(id) || id.includes('..')) {\n throw new Error(`${op}(): \"${id}\" is not a valid document ID`)\n }\n}\n\nexport const requireDocumentId = (op: string, doc: Record) => {\n if (!doc._id) {\n throw new Error(`${op}() requires that the document contains an ID (\"_id\" property)`)\n }\n\n validateDocumentId(op, doc._id)\n}\n\nexport const validateInsert = (at: string, selector: string, items: Any[]) => {\n const signature = 'insert(at, selector, items)'\n if (VALID_INSERT_LOCATIONS.indexOf(at) === -1) {\n const valid = VALID_INSERT_LOCATIONS.map((loc) => `\"${loc}\"`).join(', ')\n throw new Error(`${signature} takes an \"at\"-argument which is one of: ${valid}`)\n }\n\n if (typeof selector !== 'string') {\n throw new Error(`${signature} takes a \"selector\"-argument which must be a string`)\n }\n\n if (!Array.isArray(items)) {\n throw new Error(`${signature} takes an \"items\"-argument which must be an array`)\n }\n}\n\nexport const hasDataset = (config: InitializedClientConfig): string => {\n if (!config.dataset) {\n throw new Error('`dataset` must be provided to perform queries')\n }\n\n return config.dataset || ''\n}\n\nexport const requestTag = (tag: string) => {\n if (typeof tag !== 'string' || !/^[a-z0-9._-]{1,75}$/i.test(tag)) {\n throw new Error(\n `Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.`\n )\n }\n\n return tag\n}\n","import type {Any, QueryParams} from '../types'\n\nexport const encodeQueryString = ({\n query,\n params = {},\n options = {},\n}: {\n query: string\n params?: QueryParams\n options?: Any\n}) => {\n const searchParams = new URLSearchParams()\n // We generally want tag at the start of the query string\n const {tag, ...opts} = options\n if (tag) searchParams.set('tag', tag)\n searchParams.set('query', query)\n\n // Iterate params, the keys are prefixed with `$` and their values JSON stringified\n for (const [key, value] of Object.entries(params)) {\n searchParams.set(`$${key}`, JSON.stringify(value))\n }\n // Options are passed as-is\n for (const [key, value] of Object.entries(opts)) {\n // Skip falsy values\n if (value) searchParams.set(key, `${value}`)\n }\n\n return `?${searchParams}`\n}\n","import {type Observable} from 'rxjs'\n\nimport type {ObservableSanityClient, SanityClient} from '../SanityClient'\nimport type {\n AllDocumentIdsMutationOptions,\n AllDocumentsMutationOptions,\n Any,\n AttributeSet,\n BaseMutationOptions,\n FirstDocumentIdMutationOptions,\n FirstDocumentMutationOptions,\n MultipleMutationResult,\n PatchMutationOperation,\n PatchOperations,\n PatchSelection,\n SanityDocument,\n SingleMutationResult,\n} from '../types'\nimport {getSelection} from '../util/getSelection'\nimport {validateInsert, validateObject} from '../validators'\n\n/** @internal */\nexport class BasePatch {\n protected selection: PatchSelection\n protected operations: PatchOperations\n constructor(selection: PatchSelection, operations: PatchOperations = {}) {\n this.selection = selection\n this.operations = operations\n }\n\n /**\n * Sets the given attributes to the document. Does NOT merge objects.\n * The operation is added to the current patch, ready to be commited by `commit()`\n *\n * @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \\{\"nested.prop\": \"value\"\\}\n */\n set(attrs: AttributeSet): this {\n return this._assign('set', attrs)\n }\n\n /**\n * Sets the given attributes to the document if they are not currently set. Does NOT merge objects.\n * The operation is added to the current patch, ready to be commited by `commit()`\n *\n * @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \\{\"nested.prop\": \"value\"\\}\n */\n setIfMissing(attrs: AttributeSet): this {\n return this._assign('setIfMissing', attrs)\n }\n\n /**\n * Performs a \"diff-match-patch\" operation on the string attributes provided.\n * The operation is added to the current patch, ready to be commited by `commit()`\n *\n * @param attrs - Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: \\{\"nested.prop\": \"dmp\"\\}\n */\n diffMatchPatch(attrs: AttributeSet): this {\n validateObject('diffMatchPatch', attrs)\n return this._assign('diffMatchPatch', attrs)\n }\n\n /**\n * Unsets the attribute paths provided.\n * The operation is added to the current patch, ready to be commited by `commit()`\n *\n * @param attrs - Attribute paths to unset.\n */\n unset(attrs: string[]): this {\n if (!Array.isArray(attrs)) {\n throw new Error('unset(attrs) takes an array of attributes to unset, non-array given')\n }\n\n this.operations = Object.assign({}, this.operations, {unset: attrs})\n return this\n }\n\n /**\n * Increment a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.\n *\n * @param attrs - Object of attribute paths to increment, values representing the number to increment by.\n */\n inc(attrs: {[key: string]: number}): this {\n return this._assign('inc', attrs)\n }\n\n /**\n * Decrement a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.\n *\n * @param attrs - Object of attribute paths to decrement, values representing the number to decrement by.\n */\n dec(attrs: {[key: string]: number}): this {\n return this._assign('dec', attrs)\n }\n\n /**\n * Provides methods for modifying arrays, by inserting, appending and replacing elements via a JSONPath expression.\n *\n * @param at - Location to insert at, relative to the given selector, or 'replace' the matched path\n * @param selector - JSONPath expression, eg `comments[-1]` or `blocks[_key==\"abc123\"]`\n * @param items - Array of items to insert/replace\n */\n insert(at: 'before' | 'after' | 'replace', selector: string, items: Any[]): this {\n validateInsert(at, selector, items)\n return this._assign('insert', {[at]: selector, items})\n }\n\n /**\n * Append the given items to the array at the given JSONPath\n *\n * @param selector - Attribute/path to append to, eg `comments` or `person.hobbies`\n * @param items - Array of items to append to the array\n */\n append(selector: string, items: Any[]): this {\n return this.insert('after', `${selector}[-1]`, items)\n }\n\n /**\n * Prepend the given items to the array at the given JSONPath\n *\n * @param selector - Attribute/path to prepend to, eg `comments` or `person.hobbies`\n * @param items - Array of items to prepend to the array\n */\n prepend(selector: string, items: Any[]): this {\n return this.insert('before', `${selector}[0]`, items)\n }\n\n /**\n * Change the contents of an array by removing existing elements and/or adding new elements.\n *\n * @param selector - Attribute or JSONPath expression for array\n * @param start - Index at which to start changing the array (with origin 0). If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end of the array (with origin -1) and will be set to 0 if absolute value is greater than the length of the array.x\n * @param deleteCount - An integer indicating the number of old array elements to remove.\n * @param items - The elements to add to the array, beginning at the start index. If you don't specify any elements, splice() will only remove elements from the array.\n */\n splice(selector: string, start: number, deleteCount?: number, items?: Any[]): this {\n // Negative indexes doesn't mean the same in Sanity as they do in JS;\n // -1 means \"actually at the end of the array\", which allows inserting\n // at the end of the array without knowing its length. We therefore have\n // to substract negative indexes by one to match JS. If you want Sanity-\n // behaviour, just use `insert('replace', selector, items)` directly\n const delAll = typeof deleteCount === 'undefined' || deleteCount === -1\n const startIndex = start < 0 ? start - 1 : start\n const delCount = delAll ? -1 : Math.max(0, start + deleteCount)\n const delRange = startIndex < 0 && delCount >= 0 ? '' : delCount\n const rangeSelector = `${selector}[${startIndex}:${delRange}]`\n return this.insert('replace', rangeSelector, items || [])\n }\n\n /**\n * Adds a revision clause, preventing the document from being patched if the `_rev` property does not match the given value\n *\n * @param rev - Revision to lock the patch to\n */\n ifRevisionId(rev: string): this {\n this.operations.ifRevisionID = rev\n return this\n }\n\n /**\n * Return a plain JSON representation of the patch\n */\n serialize(): PatchMutationOperation {\n return {...getSelection(this.selection), ...this.operations}\n }\n\n /**\n * Return a plain JSON representation of the patch\n */\n toJSON(): PatchMutationOperation {\n return this.serialize()\n }\n\n /**\n * Clears the patch of all operations\n */\n reset(): this {\n this.operations = {}\n return this\n }\n\n protected _assign(op: keyof PatchOperations, props: Any, merge = true): this {\n validateObject(op, props)\n this.operations = Object.assign({}, this.operations, {\n [op]: Object.assign({}, (merge && this.operations[op]) || {}, props),\n })\n return this\n }\n\n protected _set(op: keyof PatchOperations, props: Any): this {\n return this._assign(op, props, false)\n }\n}\n\n/** @public */\nexport class ObservablePatch extends BasePatch {\n #client?: ObservableSanityClient\n\n constructor(\n selection: PatchSelection,\n operations?: PatchOperations,\n client?: ObservableSanityClient\n ) {\n super(selection, operations)\n this.#client = client\n }\n\n /**\n * Clones the patch\n */\n clone(): ObservablePatch {\n return new ObservablePatch(this.selection, {...this.operations}, this.#client)\n }\n\n /**\n * Commit the patch, returning an observable that produces the first patched document\n *\n * @param options - Options for the mutation operation\n */\n commit = Record>(\n options: FirstDocumentMutationOptions\n ): Observable>\n /**\n * Commit the patch, returning an observable that produces an array of the mutated documents\n *\n * @param options - Options for the mutation operation\n */\n commit = Record>(\n options: AllDocumentsMutationOptions\n ): Observable[]>\n /**\n * Commit the patch, returning an observable that produces a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: FirstDocumentIdMutationOptions): Observable\n /**\n * Commit the patch, returning an observable that produces a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: AllDocumentIdsMutationOptions): Observable\n /**\n * Commit the patch, returning an observable that produces the first patched document\n *\n * @param options - Options for the mutation operation\n */\n commit = Record>(\n options?: BaseMutationOptions\n ): Observable>\n commit = Record>(\n options?:\n | FirstDocumentMutationOptions\n | AllDocumentsMutationOptions\n | FirstDocumentIdMutationOptions\n | AllDocumentIdsMutationOptions\n | BaseMutationOptions\n ): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n if (!this.#client) {\n throw new Error(\n 'No `client` passed to patch, either provide one or pass the ' +\n 'patch to a clients `mutate()` method'\n )\n }\n\n const returnFirst = typeof this.selection === 'string'\n const opts = Object.assign({returnFirst, returnDocuments: true}, options)\n return this.#client.mutate({patch: this.serialize()} as Any, opts)\n }\n}\n\n/** @public */\nexport class Patch extends BasePatch {\n #client?: SanityClient\n constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient) {\n super(selection, operations)\n this.#client = client\n }\n\n /**\n * Clones the patch\n */\n clone(): Patch {\n return new Patch(this.selection, {...this.operations}, this.#client)\n }\n\n /**\n * Commit the patch, returning a promise that resolves to the first patched document\n *\n * @param options - Options for the mutation operation\n */\n commit = Record>(\n options: FirstDocumentMutationOptions\n ): Promise>\n /**\n * Commit the patch, returning a promise that resolves to an array of the mutated documents\n *\n * @param options - Options for the mutation operation\n */\n commit = Record>(\n options: AllDocumentsMutationOptions\n ): Promise[]>\n /**\n * Commit the patch, returning a promise that resolves to a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: FirstDocumentIdMutationOptions): Promise\n /**\n * Commit the patch, returning a promise that resolves to a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: AllDocumentIdsMutationOptions): Promise\n /**\n * Commit the patch, returning a promise that resolves to the first patched document\n *\n * @param options - Options for the mutation operation\n */\n commit = Record>(\n options?: BaseMutationOptions\n ): Promise>\n commit = Record>(\n options?:\n | FirstDocumentMutationOptions\n | AllDocumentsMutationOptions\n | FirstDocumentIdMutationOptions\n | AllDocumentIdsMutationOptions\n | BaseMutationOptions\n ): Promise<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n if (!this.#client) {\n throw new Error(\n 'No `client` passed to patch, either provide one or pass the ' +\n 'patch to a clients `mutate()` method'\n )\n }\n\n const returnFirst = typeof this.selection === 'string'\n const opts = Object.assign({returnFirst, returnDocuments: true}, options)\n return this.#client.mutate({patch: this.serialize()} as Any, opts)\n }\n}\n","import type {Observable} from 'rxjs'\n\nimport type {ObservableSanityClient, SanityClient} from '../SanityClient'\nimport type {\n Any,\n BaseMutationOptions,\n IdentifiedSanityDocumentStub,\n MultipleMutationResult,\n Mutation,\n PatchOperations,\n SanityDocument,\n SanityDocumentStub,\n SingleMutationResult,\n TransactionAllDocumentIdsMutationOptions,\n TransactionAllDocumentsMutationOptions,\n TransactionFirstDocumentIdMutationOptions,\n TransactionFirstDocumentMutationOptions,\n} from '../types'\nimport * as validators from '../validators'\nimport {ObservablePatch, Patch} from './patch'\n\n/** @public */\nexport type PatchBuilder = (patch: Patch) => Patch\n/** @public */\nexport type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch\n\nconst defaultMutateOptions = {returnDocuments: false}\n\n/** @internal */\nexport class BaseTransaction {\n protected operations: Mutation[]\n protected trxId?: string\n constructor(operations: Mutation[] = [], transactionId?: string) {\n this.operations = operations\n this.trxId = transactionId\n }\n /**\n * Creates a new Sanity document. If `_id` is provided and already exists, the mutation will fail. If no `_id` is given, one will automatically be generated by the database.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param doc - Document to create. Requires a `_type` property.\n */\n create = Record>(doc: SanityDocumentStub): this {\n validators.validateObject('create', doc)\n return this._add({create: doc})\n }\n\n /**\n * Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param doc - Document to create if it does not already exist. Requires `_id` and `_type` properties.\n */\n createIfNotExists = Record>(\n doc: IdentifiedSanityDocumentStub\n ): this {\n const op = 'createIfNotExists'\n validators.validateObject(op, doc)\n validators.requireDocumentId(op, doc)\n return this._add({[op]: doc})\n }\n\n /**\n * Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param doc - Document to create or replace. Requires `_id` and `_type` properties.\n */\n createOrReplace = Record>(\n doc: IdentifiedSanityDocumentStub\n ): this {\n const op = 'createOrReplace'\n validators.validateObject(op, doc)\n validators.requireDocumentId(op, doc)\n return this._add({[op]: doc})\n }\n\n /**\n * Deletes the document with the given document ID\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param documentId - Document ID to delete\n */\n delete(documentId: string): this {\n validators.validateDocumentId('delete', documentId)\n return this._add({delete: {id: documentId}})\n }\n\n /**\n * Gets the current transaction ID, if any\n */\n transactionId(): string | undefined\n /**\n * Set the ID of this transaction.\n *\n * @param id - Transaction ID\n */\n transactionId(id: string): this\n transactionId(id?: string): this | string | undefined {\n if (!id) {\n return this.trxId\n }\n\n this.trxId = id\n return this\n }\n\n /**\n * Return a plain JSON representation of the transaction\n */\n serialize(): Mutation[] {\n return [...this.operations]\n }\n\n /**\n * Return a plain JSON representation of the transaction\n */\n toJSON(): Mutation[] {\n return this.serialize()\n }\n\n /**\n * Clears the transaction of all operations\n */\n reset(): this {\n this.operations = []\n return this\n }\n\n protected _add(mut: Mutation): this {\n this.operations.push(mut)\n return this\n }\n}\n\n/** @public */\nexport class Transaction extends BaseTransaction {\n #client?: SanityClient\n constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string) {\n super(operations, transactionId)\n this.#client = client\n }\n\n /**\n * Clones the transaction\n */\n clone(): Transaction {\n return new Transaction([...this.operations], this.#client, this.trxId)\n }\n\n /**\n * Commit the transaction, returning a promise that resolves to the first mutated document\n *\n * @param options - Options for the mutation operation\n */\n commit>(\n options: TransactionFirstDocumentMutationOptions\n ): Promise>\n /**\n * Commit the transaction, returning a promise that resolves to an array of the mutated documents\n *\n * @param options - Options for the mutation operation\n */\n commit>(\n options: TransactionAllDocumentsMutationOptions\n ): Promise[]>\n /**\n * Commit the transaction, returning a promise that resolves to a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: TransactionFirstDocumentIdMutationOptions): Promise\n /**\n * Commit the transaction, returning a promise that resolves to a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: TransactionAllDocumentIdsMutationOptions): Promise\n /**\n * Commit the transaction, returning a promise that resolves to a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options?: BaseMutationOptions): Promise\n commit = Record>(\n options?:\n | TransactionFirstDocumentMutationOptions\n | TransactionAllDocumentsMutationOptions\n | TransactionFirstDocumentIdMutationOptions\n | TransactionAllDocumentIdsMutationOptions\n | BaseMutationOptions\n ): Promise<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n if (!this.#client) {\n throw new Error(\n 'No `client` passed to transaction, either provide one or pass the ' +\n 'transaction to a clients `mutate()` method'\n )\n }\n\n return this.#client.mutate(\n this.serialize() as Any,\n Object.assign({transactionId: this.trxId}, defaultMutateOptions, options || {})\n )\n }\n\n /**\n * Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param documentId - Document ID to perform the patch operation on\n * @param patchOps - Operations to perform, or a builder function\n */\n patch(documentId: string, patchOps?: PatchBuilder | PatchOperations): this\n /**\n * Adds the given patch instance to the transaction.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param patch - Patch to execute\n */\n patch(patch: Patch): this\n patch(patchOrDocumentId: Patch | string, patchOps?: PatchBuilder | PatchOperations): this {\n const isBuilder = typeof patchOps === 'function'\n const isPatch = typeof patchOrDocumentId !== 'string' && patchOrDocumentId instanceof Patch\n\n // transaction.patch(client.patch('documentId').inc({visits: 1}))\n if (isPatch) {\n return this._add({patch: patchOrDocumentId.serialize()})\n }\n\n // patch => patch.inc({visits: 1}).set({foo: 'bar'})\n if (isBuilder) {\n const patch = patchOps(new Patch(patchOrDocumentId, {}, this.#client))\n if (!(patch instanceof Patch)) {\n throw new Error('function passed to `patch()` must return the patch')\n }\n\n return this._add({patch: patch.serialize()})\n }\n\n return this._add({patch: {id: patchOrDocumentId, ...patchOps}})\n }\n}\n\n/** @public */\nexport class ObservableTransaction extends BaseTransaction {\n #client?: ObservableSanityClient\n constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string) {\n super(operations, transactionId)\n this.#client = client\n }\n\n /**\n * Clones the transaction\n */\n clone(): ObservableTransaction {\n return new ObservableTransaction([...this.operations], this.#client, this.trxId)\n }\n\n /**\n * Commit the transaction, returning an observable that produces the first mutated document\n *\n * @param options - Options for the mutation operation\n */\n commit>(\n options: TransactionFirstDocumentMutationOptions\n ): Observable>\n /**\n * Commit the transaction, returning an observable that produces an array of the mutated documents\n *\n * @param options - Options for the mutation operation\n */\n commit>(\n options: TransactionAllDocumentsMutationOptions\n ): Observable[]>\n /**\n * Commit the transaction, returning an observable that produces a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: TransactionFirstDocumentIdMutationOptions): Observable\n /**\n * Commit the transaction, returning an observable that produces a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: TransactionAllDocumentIdsMutationOptions): Observable\n /**\n * Commit the transaction, returning an observable that produces a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options?: BaseMutationOptions): Observable\n commit = Record>(\n options?:\n | TransactionFirstDocumentMutationOptions\n | TransactionAllDocumentsMutationOptions\n | TransactionFirstDocumentIdMutationOptions\n | TransactionAllDocumentIdsMutationOptions\n | BaseMutationOptions\n ): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n if (!this.#client) {\n throw new Error(\n 'No `client` passed to transaction, either provide one or pass the ' +\n 'transaction to a clients `mutate()` method'\n )\n }\n\n return this.#client.mutate(\n this.serialize() as Any,\n Object.assign({transactionId: this.trxId}, defaultMutateOptions, options || {})\n )\n }\n\n /**\n * Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param documentId - Document ID to perform the patch operation on\n * @param patchOps - Operations to perform, or a builder function\n */\n patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this\n /**\n * Adds the given patch instance to the transaction.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param patch - ObservablePatch to execute\n */\n patch(patch: ObservablePatch): this\n patch(\n patchOrDocumentId: ObservablePatch | string,\n patchOps?: ObservablePatchBuilder | PatchOperations\n ): this {\n const isBuilder = typeof patchOps === 'function'\n const isPatch =\n typeof patchOrDocumentId !== 'string' && patchOrDocumentId instanceof ObservablePatch\n\n // transaction.patch(client.patch('documentId').inc({visits: 1}))\n if (isPatch) {\n return this._add({patch: patchOrDocumentId.serialize()})\n }\n\n // patch => patch.inc({visits: 1}).set({foo: 'bar'})\n if (isBuilder) {\n const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this.#client))\n if (!(patch instanceof ObservablePatch)) {\n throw new Error('function passed to `patch()` must return the patch')\n }\n\n return this._add({patch: patch.serialize()})\n }\n\n return this._add({patch: {id: patchOrDocumentId, ...patchOps}})\n }\n}\n","import {type MonoTypeOperatorFunction, Observable} from 'rxjs'\nimport {filter, map} from 'rxjs/operators'\n\nimport {requestOptions} from '../http/requestOptions'\nimport type {ObservableSanityClient, SanityClient} from '../SanityClient'\nimport type {\n AllDocumentIdsMutationOptions,\n AllDocumentsMutationOptions,\n Any,\n BaseMutationOptions,\n FilteredResponseQueryOptions,\n FirstDocumentIdMutationOptions,\n FirstDocumentMutationOptions,\n HttpRequest,\n HttpRequestEvent,\n IdentifiedSanityDocumentStub,\n MultipleMutationResult,\n Mutation,\n MutationSelection,\n QueryParams,\n RawQueryResponse,\n RequestObservableOptions,\n RequestOptions,\n SanityDocument,\n SingleMutationResult,\n UnfilteredResponseQueryOptions,\n} from '../types'\nimport {getSelection} from '../util/getSelection'\nimport * as validate from '../validators'\nimport * as validators from '../validators'\nimport {encodeQueryString} from './encodeQueryString'\nimport {ObservablePatch, Patch} from './patch'\nimport {ObservableTransaction, Transaction} from './transaction'\n\nconst excludeFalsey = (param: Any, defValue: Any) => {\n const value = typeof param === 'undefined' ? defValue : param\n return param === false ? undefined : value\n}\n\nconst getMutationQuery = (options: BaseMutationOptions = {}) => {\n return {\n dryRun: options.dryRun,\n returnIds: true,\n returnDocuments: excludeFalsey(options.returnDocuments, true),\n visibility: options.visibility || 'sync',\n autoGenerateArrayKeys: options.autoGenerateArrayKeys,\n skipCrossDatasetReferenceValidation: options.skipCrossDatasetReferenceValidation,\n }\n}\n\nconst isResponse = (event: Any) => event.type === 'response'\nconst getBody = (event: Any) => event.body\n\nconst indexBy = (docs: Any[], attr: Any) =>\n docs.reduce((indexed, doc) => {\n indexed[attr(doc)] = doc\n return indexed\n }, Object.create(null))\n\nconst getQuerySizeLimit = 11264\n\n/** @internal */\nexport function _fetch(\n client: ObservableSanityClient | SanityClient,\n httpRequest: HttpRequest,\n query: string,\n params?: Q,\n options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {}\n): Observable | R> {\n const mapResponse =\n options.filterResponse === false ? (res: Any) => res : (res: Any) => res.result\n\n return _dataRequest(client, httpRequest, 'query', {query, params}, options).pipe(map(mapResponse))\n}\n\n/** @internal */\nexport function _getDocument>(\n client: ObservableSanityClient | SanityClient,\n httpRequest: HttpRequest,\n id: string,\n opts: {tag?: string} = {}\n): Observable | undefined> {\n const options = {uri: _getDataUrl(client, 'doc', id), json: true, tag: opts.tag}\n return _requestObservable | undefined>(client, httpRequest, options).pipe(\n filter(isResponse),\n map((event) => event.body.documents && event.body.documents[0])\n )\n}\n\n/** @internal */\nexport function _getDocuments>(\n client: ObservableSanityClient | SanityClient,\n httpRequest: HttpRequest,\n ids: string[],\n opts: {tag?: string} = {}\n): Observable<(SanityDocument | null)[]> {\n const options = {uri: _getDataUrl(client, 'doc', ids.join(',')), json: true, tag: opts.tag}\n return _requestObservable<(SanityDocument | null)[]>(client, httpRequest, options).pipe(\n filter(isResponse),\n map((event: Any) => {\n const indexed = indexBy(event.body.documents || [], (doc: Any) => doc._id)\n return ids.map((id) => indexed[id] || null)\n })\n )\n}\n\n/** @internal */\nexport function _createIfNotExists>(\n client: ObservableSanityClient | SanityClient,\n httpRequest: HttpRequest,\n doc: IdentifiedSanityDocumentStub,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n> {\n validators.requireDocumentId('createIfNotExists', doc)\n return _create(client, httpRequest, doc, 'createIfNotExists', options)\n}\n\n/** @internal */\nexport function _createOrReplace>(\n client: ObservableSanityClient | SanityClient,\n httpRequest: HttpRequest,\n doc: IdentifiedSanityDocumentStub,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n> {\n validators.requireDocumentId('createOrReplace', doc)\n return _create(client, httpRequest, doc, 'createOrReplace', options)\n}\n\n/** @internal */\nexport function _delete>(\n client: ObservableSanityClient | SanityClient,\n httpRequest: HttpRequest,\n selection: string | MutationSelection,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n> {\n return _dataRequest(\n client,\n httpRequest,\n 'mutate',\n {mutations: [{delete: getSelection(selection)}]},\n options\n )\n}\n\n/** @internal */\nexport function _mutate>(\n client: SanityClient | ObservableSanityClient,\n httpRequest: HttpRequest,\n mutations: Mutation[] | Patch | ObservablePatch | Transaction | ObservableTransaction,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n> {\n let mut: Mutation | Mutation[]\n if (mutations instanceof Patch || mutations instanceof ObservablePatch) {\n mut = {patch: mutations.serialize()}\n } else if (mutations instanceof Transaction || mutations instanceof ObservableTransaction) {\n mut = mutations.serialize()\n } else {\n mut = mutations\n }\n\n const muts = Array.isArray(mut) ? mut : [mut]\n const transactionId = (options && options.transactionId) || undefined\n return _dataRequest(client, httpRequest, 'mutate', {mutations: muts, transactionId}, options)\n}\n\n/**\n * @internal\n */\nexport function _dataRequest(\n client: SanityClient | ObservableSanityClient,\n httpRequest: HttpRequest,\n endpoint: string,\n body: Any,\n options: Any = {}\n): Any {\n const isMutation = endpoint === 'mutate'\n const isQuery = endpoint === 'query'\n\n // Check if the query string is within a configured threshold,\n // in which case we can use GET. Otherwise, use POST.\n const strQuery = isMutation ? '' : encodeQueryString(body)\n const useGet = !isMutation && strQuery.length < getQuerySizeLimit\n const stringQuery = useGet ? strQuery : ''\n const returnFirst = options.returnFirst\n const {timeout, token, tag, headers} = options\n\n const uri = _getDataUrl(client, endpoint, stringQuery)\n\n const reqOptions = {\n method: useGet ? 'GET' : 'POST',\n uri: uri,\n json: true,\n body: useGet ? undefined : body,\n query: isMutation && getMutationQuery(options),\n timeout,\n headers,\n token,\n tag,\n canUseCdn: isQuery,\n signal: options.signal,\n }\n\n return _requestObservable(client, httpRequest, reqOptions).pipe(\n filter(isResponse),\n map(getBody),\n map((res) => {\n if (!isMutation) {\n return res\n }\n\n // Should we return documents?\n const results = res.results || []\n if (options.returnDocuments) {\n return returnFirst\n ? results[0] && results[0].document\n : results.map((mut: Any) => mut.document)\n }\n\n // Return a reduced subset\n const key = returnFirst ? 'documentId' : 'documentIds'\n const ids = returnFirst ? results[0] && results[0].id : results.map((mut: Any) => mut.id)\n return {\n transactionId: res.transactionId,\n results: results,\n [key]: ids,\n }\n })\n )\n}\n\n/**\n * @internal\n */\nexport function _create>(\n client: SanityClient | ObservableSanityClient,\n httpRequest: HttpRequest,\n doc: Any,\n op: Any,\n options: Any = {}\n): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n> {\n const mutation = {[op]: doc}\n const opts = Object.assign({returnFirst: true, returnDocuments: true}, options)\n return _dataRequest(client, httpRequest, 'mutate', {mutations: [mutation]}, opts)\n}\n\n/**\n * @internal\n */\nexport function _requestObservable(\n client: SanityClient | ObservableSanityClient,\n httpRequest: HttpRequest,\n options: RequestObservableOptions\n): Observable> {\n const uri = options.url || (options.uri as string)\n const config = client.config()\n\n // If the `canUseCdn`-option is not set we detect it automatically based on the method + URL.\n // Only the /data endpoint is currently available through API-CDN.\n const canUseCdn =\n typeof options.canUseCdn === 'undefined'\n ? ['GET', 'HEAD'].indexOf(options.method || 'GET') >= 0 && uri.indexOf('/data/') === 0\n : options.canUseCdn\n\n const useCdn = config.useCdn && canUseCdn\n\n const tag =\n options.tag && config.requestTagPrefix\n ? [config.requestTagPrefix, options.tag].join('.')\n : options.tag || config.requestTagPrefix\n\n if (tag) {\n options.query = {tag: validate.requestTag(tag), ...options.query}\n }\n\n const reqOptions = requestOptions(\n config,\n Object.assign({}, options, {\n url: _getUrl(client, uri, useCdn),\n })\n ) as RequestOptions\n\n const request = new Observable>((subscriber) =>\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- the typings thinks it's optional because it's not required to specify it when calling createClient, but it's always defined in practice since SanityClient provides a default\n httpRequest(reqOptions, config.requester!).subscribe(subscriber)\n )\n\n return options.signal ? request.pipe(_withAbortSignal(options.signal)) : request\n}\n\n/**\n * @internal\n */\nexport function _request(\n client: SanityClient | ObservableSanityClient,\n httpRequest: HttpRequest,\n options: Any\n): Observable {\n const observable = _requestObservable(client, httpRequest, options).pipe(\n filter((event: Any) => event.type === 'response'),\n map((event: Any) => event.body)\n )\n\n return observable\n}\n\n/**\n * @internal\n */\nexport function _getDataUrl(\n client: SanityClient | ObservableSanityClient,\n operation: string,\n path?: string\n): string {\n const config = client.config()\n const catalog = validators.hasDataset(config)\n const baseUri = `/${operation}/${catalog}`\n const uri = path ? `${baseUri}/${path}` : baseUri\n return `/data${uri}`.replace(/\\/($|\\?)/, '$1')\n}\n\n/**\n * @internal\n */\nexport function _getUrl(\n client: SanityClient | ObservableSanityClient,\n uri: string,\n canUseCdn = false\n): string {\n const {url, cdnUrl} = client.config()\n const base = canUseCdn ? cdnUrl : url\n return `${base}/${uri.replace(/^\\//, '')}`\n}\n\n/**\n * @internal\n */\nfunction _withAbortSignal(signal: AbortSignal): MonoTypeOperatorFunction {\n return (input) => {\n return new Observable((observer) => {\n const abort = () => observer.error(_createAbortError(signal))\n\n if (signal && signal.aborted) {\n abort()\n return\n }\n const subscription = input.subscribe(observer)\n signal.addEventListener('abort', abort)\n return () => {\n signal.removeEventListener('abort', abort)\n subscription.unsubscribe()\n }\n })\n }\n}\n// DOMException is supported on most modern browsers and Node.js 18+.\n// @see https://developer.mozilla.org/en-US/docs/Web/API/DOMException#browser_compatibility\nconst isDomExceptionSupported = Boolean(globalThis.DOMException)\n\n/**\n * @internal\n * @param signal\n * Original source copied from https://github.com/sindresorhus/ky/blob/740732c78aad97e9aec199e9871bdbf0ae29b805/source/errors/DOMException.ts\n * TODO: When targeting Node.js 18, use `signal.throwIfAborted()` (https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted)\n */\nfunction _createAbortError(signal?: AbortSignal) {\n /*\n NOTE: Use DomException with AbortError name as specified in MDN docs (https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort)\n > When abort() is called, the fetch() promise rejects with an Error of type DOMException, with name AbortError.\n */\n if (isDomExceptionSupported) {\n return new DOMException(signal?.reason ?? 'The operation was aborted.', 'AbortError')\n }\n\n // DOMException not supported. Fall back to use of error and override name.\n const error = new Error(signal?.reason ?? 'The operation was aborted.')\n error.name = 'AbortError'\n\n return error\n}\n","import {lastValueFrom, type Observable} from 'rxjs'\nimport {filter, map} from 'rxjs/operators'\n\nimport {_requestObservable} from '../data/dataMethods'\nimport type {ObservableSanityClient, SanityClient} from '../SanityClient'\nimport type {\n Any,\n HttpRequest,\n HttpRequestEvent,\n ResponseEvent,\n SanityAssetDocument,\n SanityImageAssetDocument,\n UploadBody,\n UploadClientConfig,\n} from '../types'\nimport * as validators from '../validators'\n\n/** @internal */\nexport class ObservableAssetsClient {\n #client: ObservableSanityClient\n #httpRequest: HttpRequest\n constructor(client: ObservableSanityClient, httpRequest: HttpRequest) {\n this.#client = client\n this.#httpRequest = httpRequest\n }\n\n /**\n * Uploads a file asset to the configured dataset\n *\n * @param assetType - Asset type (file)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'file',\n body: UploadBody,\n options?: UploadClientConfig\n ): Observable>\n\n /**\n * Uploads an image asset to the configured dataset\n *\n * @param assetType - Asset type (image)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'image',\n body: UploadBody,\n options?: UploadClientConfig\n ): Observable>\n /**\n * Uploads a file or an image asset to the configured dataset\n *\n * @param assetType - Asset type (file/image)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'file' | 'image',\n body: UploadBody,\n options?: UploadClientConfig\n ): Observable>\n upload(\n assetType: 'file' | 'image',\n body: UploadBody,\n options?: UploadClientConfig\n ): Observable> {\n return _upload(this.#client, this.#httpRequest, assetType, body, options)\n }\n}\n\n/** @internal */\nexport class AssetsClient {\n #client: SanityClient\n #httpRequest: HttpRequest\n constructor(client: SanityClient, httpRequest: HttpRequest) {\n this.#client = client\n this.#httpRequest = httpRequest\n }\n\n /**\n * Uploads a file asset to the configured dataset\n *\n * @param assetType - Asset type (file)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'file',\n body: UploadBody,\n options?: UploadClientConfig\n ): Promise\n /**\n * Uploads an image asset to the configured dataset\n *\n * @param assetType - Asset type (image)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'image',\n body: UploadBody,\n options?: UploadClientConfig\n ): Promise\n /**\n * Uploads a file or an image asset to the configured dataset\n *\n * @param assetType - Asset type (file/image)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'file' | 'image',\n body: UploadBody,\n options?: UploadClientConfig\n ): Promise\n upload(\n assetType: 'file' | 'image',\n body: UploadBody,\n options?: UploadClientConfig\n ): Promise {\n const observable = _upload(this.#client, this.#httpRequest, assetType, body, options)\n return lastValueFrom(\n observable.pipe(\n filter((event: Any) => event.type === 'response'),\n map(\n (event) =>\n (event as ResponseEvent<{document: SanityAssetDocument | SanityImageAssetDocument}>)\n .body.document\n )\n )\n )\n }\n}\n\nfunction _upload(\n client: SanityClient | ObservableSanityClient,\n httpRequest: HttpRequest,\n assetType: 'image' | 'file',\n body: UploadBody,\n opts: UploadClientConfig = {}\n): Observable> {\n validators.validateAssetType(assetType)\n\n // If an empty array is given, explicitly set `none` to override API defaults\n let meta = opts.extract || undefined\n if (meta && !meta.length) {\n meta = ['none']\n }\n\n const dataset = validators.hasDataset(client.config())\n const assetEndpoint = assetType === 'image' ? 'images' : 'files'\n const options = optionsFromFile(opts, body)\n const {tag, label, title, description, creditLine, filename, source} = options\n const query: Any = {\n label,\n title,\n description,\n filename,\n meta,\n creditLine,\n }\n if (source) {\n query.sourceId = source.id\n query.sourceName = source.name\n query.sourceUrl = source.url\n }\n return _requestObservable(client, httpRequest, {\n tag,\n method: 'POST',\n timeout: options.timeout || 0,\n uri: `/assets/${assetEndpoint}/${dataset}`,\n headers: options.contentType ? {'Content-Type': options.contentType} : {},\n query,\n body,\n })\n}\n\nfunction optionsFromFile(opts: Record, file: Any) {\n if (typeof File === 'undefined' || !(file instanceof File)) {\n return opts\n }\n\n return Object.assign(\n {\n filename: opts.preserveFilename === false ? undefined : file.name,\n contentType: file.type,\n },\n opts\n )\n}\n","const BASE_URL = 'https://www.sanity.io/help/'\n\nexport function generateHelpUrl(slug: string) {\n return BASE_URL + slug\n}\n","import type {Any} from '../types'\n\nexport function once(fn: Any) {\n let didCall = false\n let returnValue: Any\n return (...args: Any[]) => {\n if (didCall) {\n return returnValue\n }\n returnValue = fn(...args)\n didCall = true\n return returnValue\n }\n}\n","import {generateHelpUrl} from './generateHelpUrl'\nimport {Any} from './types'\nimport {once} from './util/once'\n\nconst createWarningPrinter = (message: string[]) =>\n // eslint-disable-next-line no-console\n once((...args: Any[]) => console.warn(message.join(' '), ...args))\n\nexport const printCdnWarning = createWarningPrinter([\n 'You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and',\n `cheaper. Think about it! For more info, see ${generateHelpUrl('js-client-cdn-configuration')} `,\n 'To hide this warning, please set the `useCdn` option to either `true` or `false` when creating',\n 'the client.',\n])\n\nexport const printBrowserTokenWarning = createWarningPrinter([\n 'You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.',\n `See ${generateHelpUrl(\n 'js-client-browser-token'\n )} for more information and how to hide this warning.`,\n])\n\nexport const printNoApiVersionSpecifiedWarning = createWarningPrinter([\n 'Using the Sanity client without specifying an API version is deprecated.',\n `See ${generateHelpUrl('js-client-api-version')}`,\n])\n\nexport const printNoDefaultExport = createWarningPrinter([\n 'The default export of @sanity/client has been deprecated. Use the named export `createClient` instead',\n])\n","import {generateHelpUrl} from './generateHelpUrl'\nimport type {ClientConfig, InitializedClientConfig} from './types'\nimport * as validate from './validators'\nimport * as warnings from './warnings'\n\nconst defaultCdnHost = 'apicdn.sanity.io'\nexport const defaultConfig = {\n apiHost: 'https://api.sanity.io',\n apiVersion: '1',\n useProjectHostname: true,\n} satisfies ClientConfig\n\nconst LOCALHOSTS = ['localhost', '127.0.0.1', '0.0.0.0']\nconst isLocal = (host: string) => LOCALHOSTS.indexOf(host) !== -1\n\nexport const validateApiVersion = function validateApiVersion(apiVersion: string) {\n if (apiVersion === '1' || apiVersion === 'X') {\n return\n }\n\n const apiDate = new Date(apiVersion)\n const apiVersionValid =\n /^\\d{4}-\\d{2}-\\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0\n\n if (!apiVersionValid) {\n throw new Error('Invalid API version string, expected `1` or date in format `YYYY-MM-DD`')\n }\n}\n\nexport const initConfig = (\n config: Partial,\n prevConfig: Partial\n): InitializedClientConfig => {\n const specifiedConfig = Object.assign({}, prevConfig, config)\n if (!specifiedConfig.apiVersion) {\n warnings.printNoApiVersionSpecifiedWarning()\n }\n\n const newConfig = Object.assign({} as InitializedClientConfig, defaultConfig, specifiedConfig)\n const projectBased = newConfig.useProjectHostname\n\n if (typeof Promise === 'undefined') {\n const helpUrl = generateHelpUrl('js-client-promise-polyfill')\n throw new Error(`No native Promise-implementation found, polyfill needed - see ${helpUrl}`)\n }\n\n if (projectBased && !newConfig.projectId) {\n throw new Error('Configuration must contain `projectId`')\n }\n\n const isBrowser = typeof window !== 'undefined' && window.location && window.location.hostname\n const isLocalhost = isBrowser && isLocal(window.location.hostname)\n\n if (isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !== true) {\n warnings.printBrowserTokenWarning()\n } else if (typeof newConfig.useCdn === 'undefined') {\n warnings.printCdnWarning()\n }\n\n if (projectBased) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- the nullability here is wrong, as line 48 throws an error if it's undefined\n validate.projectId(newConfig.projectId!)\n }\n\n if (newConfig.dataset) {\n validate.dataset(newConfig.dataset)\n }\n\n if ('requestTagPrefix' in newConfig) {\n // Allow setting and unsetting request tag prefix\n newConfig.requestTagPrefix = newConfig.requestTagPrefix\n ? validate.requestTag(newConfig.requestTagPrefix).replace(/\\.+$/, '')\n : undefined\n }\n\n newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, '')\n newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost\n newConfig.useCdn = Boolean(newConfig.useCdn) && !newConfig.withCredentials\n\n validateApiVersion(newConfig.apiVersion)\n\n const hostParts = newConfig.apiHost.split('://', 2)\n const protocol = hostParts[0]\n const host = hostParts[1]\n const cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host\n\n if (newConfig.useProjectHostname) {\n newConfig.url = `${protocol}://${newConfig.projectId}.${host}/v${newConfig.apiVersion}`\n newConfig.cdnUrl = `${protocol}://${newConfig.projectId}.${cdnHost}/v${newConfig.apiVersion}`\n } else {\n newConfig.url = `${newConfig.apiHost}/v${newConfig.apiVersion}`\n newConfig.cdnUrl = newConfig.url\n }\n\n return newConfig\n}\n","import type {Any} from '../types'\n\nexport default (obj: Any, defaults: Any) =>\n Object.keys(defaults)\n .concat(Object.keys(obj))\n .reduce((target, prop) => {\n target[prop] = typeof obj[prop] === 'undefined' ? defaults[prop] : obj[prop]\n\n return target\n }, {} as Any)\n","import {Any} from '../types'\n\nexport const pick = (obj: Any, props: Any) =>\n props.reduce((selection: Any, prop: Any) => {\n if (typeof obj[prop] === 'undefined') {\n return selection\n }\n\n selection[prop] = obj[prop]\n return selection\n }, {})\n","import {Observable} from 'rxjs'\n\nimport type {ObservableSanityClient, SanityClient} from '../SanityClient'\nimport type {Any, ListenEvent, ListenOptions, MutationEvent, QueryParams} from '../types'\nimport defaults from '../util/defaults'\nimport {pick} from '../util/pick'\nimport {_getDataUrl} from './dataMethods'\nimport {encodeQueryString} from './encodeQueryString'\n\n// Limit is 16K for a _request_, eg including headers. Have to account for an\n// unknown range of headers, but an average EventSource request from Chrome seems\n// to have around 700 bytes of cruft, so let us account for 1.2K to be \"safe\"\nconst MAX_URL_LENGTH = 16000 - 1200\n\nconst possibleOptions = [\n 'includePreviousRevision',\n 'includeResult',\n 'visibility',\n 'effectFormat',\n 'tag',\n]\n\nconst defaultOptions = {\n includeResult: true,\n}\n\n/**\n * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.\n *\n * @param query - GROQ-filter to listen to changes for\n * @param params - Optional query parameters\n * @param options - Listener options\n * @internal\n */\nexport function _listen = Record>(\n this: SanityClient | ObservableSanityClient,\n query: string,\n params?: QueryParams\n): Observable>\n/**\n * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.\n *\n * @param query - GROQ-filter to listen to changes for\n * @param params - Optional query parameters\n * @param options - Listener options\n * @internal\n */\nexport function _listen = Record>(\n this: SanityClient | ObservableSanityClient,\n query: string,\n params?: QueryParams,\n options?: ListenOptions\n): Observable>\n/** @internal */\nexport function _listen = Record>(\n this: SanityClient | ObservableSanityClient,\n query: string,\n params?: QueryParams,\n opts: ListenOptions = {}\n): Observable | ListenEvent> {\n const {url, token, withCredentials, requestTagPrefix} = this.config()\n const tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join('.') : opts.tag\n const options = {...defaults(opts, defaultOptions), tag}\n const listenOpts = pick(options, possibleOptions)\n const qs = encodeQueryString({query, params, options: {tag, ...listenOpts}})\n\n const uri = `${url}${_getDataUrl(this, 'listen', qs)}`\n if (uri.length > MAX_URL_LENGTH) {\n return new Observable((observer) => observer.error(new Error('Query too large for listener')))\n }\n\n const listenFor = options.events ? options.events : ['mutation']\n const shouldEmitReconnect = listenFor.indexOf('reconnect') !== -1\n\n const esOptions: EventSourceInit & {headers?: Record} = {}\n if (token || withCredentials) {\n esOptions.withCredentials = true\n }\n\n if (token) {\n esOptions.headers = {\n Authorization: `Bearer ${token}`,\n }\n }\n\n return new Observable((observer) => {\n let es: InstanceType\n getEventSource()\n .then((eventSource) => {\n es = eventSource\n })\n .catch((reason) => {\n observer.error(reason)\n stop()\n })\n let reconnectTimer: NodeJS.Timeout\n let stopped = false\n\n function onError() {\n if (stopped) {\n return\n }\n\n emitReconnect()\n\n // Allow event handlers of `emitReconnect` to cancel/close the reconnect attempt\n if (stopped) {\n return\n }\n\n // Unless we've explicitly stopped the ES (in which case `stopped` should be true),\n // we should never be in a disconnected state. By default, EventSource will reconnect\n // automatically, in which case it sets readyState to `CONNECTING`, but in some cases\n // (like when a laptop lid is closed), it closes the connection. In these cases we need\n // to explicitly reconnect.\n if (es.readyState === es.CLOSED) {\n unsubscribe()\n clearTimeout(reconnectTimer)\n reconnectTimer = setTimeout(open, 100)\n }\n }\n\n function onChannelError(err: Any) {\n observer.error(cooerceError(err))\n }\n\n function onMessage(evt: Any) {\n const event = parseEvent(evt)\n return event instanceof Error ? observer.error(event) : observer.next(event)\n }\n\n function onDisconnect() {\n stopped = true\n unsubscribe()\n observer.complete()\n }\n\n function unsubscribe() {\n if (!es) return\n es.removeEventListener('error', onError)\n es.removeEventListener('channelError', onChannelError)\n es.removeEventListener('disconnect', onDisconnect)\n listenFor.forEach((type: string) => es.removeEventListener(type, onMessage))\n es.close()\n }\n\n function emitReconnect() {\n if (shouldEmitReconnect) {\n observer.next({type: 'reconnect'})\n }\n }\n\n async function getEventSource(): Promise> {\n const {default: EventSource} = await import('@sanity/eventsource')\n const evs = new EventSource(uri, esOptions)\n evs.addEventListener('error', onError)\n evs.addEventListener('channelError', onChannelError)\n evs.addEventListener('disconnect', onDisconnect)\n listenFor.forEach((type: string) => evs.addEventListener(type, onMessage))\n return evs\n }\n\n function open() {\n getEventSource()\n .then((eventSource) => {\n es = eventSource\n })\n .catch((reason) => {\n observer.error(reason)\n stop()\n })\n }\n\n function stop() {\n stopped = true\n unsubscribe()\n }\n\n return stop\n })\n}\n\nfunction parseEvent(event: Any) {\n try {\n const data = (event.data && JSON.parse(event.data)) || {}\n return Object.assign({type: event.type}, data)\n } catch (err) {\n return err\n }\n}\n\nfunction cooerceError(err: Any) {\n if (err instanceof Error) {\n return err\n }\n\n const evt = parseEvent(err)\n return evt instanceof Error ? evt : new Error(extractErrorMessage(evt))\n}\n\nfunction extractErrorMessage(err: Any) {\n if (!err.error) {\n return err.message || 'Unknown listener error'\n }\n\n if (err.error.description) {\n return err.error.description\n }\n\n return typeof err.error === 'string' ? err.error : JSON.stringify(err.error, null, 2)\n}\n","import {lastValueFrom, type Observable} from 'rxjs'\n\nimport {_request} from '../data/dataMethods'\nimport type {ObservableSanityClient, SanityClient} from '../SanityClient'\nimport type {DatasetAclMode, DatasetResponse, DatasetsResponse, HttpRequest} from '../types'\nimport * as validate from '../validators'\n\n/** @internal */\nexport class ObservableDatasetsClient {\n #client: ObservableSanityClient\n #httpRequest: HttpRequest\n constructor(client: ObservableSanityClient, httpRequest: HttpRequest) {\n this.#client = client\n this.#httpRequest = httpRequest\n }\n\n /**\n * Create a new dataset with the given name\n *\n * @param name - Name of the dataset to create\n * @param options - Options for the dataset\n */\n create(name: string, options?: {aclMode?: DatasetAclMode}): Observable {\n return _modify(this.#client, this.#httpRequest, 'PUT', name, options)\n }\n\n /**\n * Edit a dataset with the given name\n *\n * @param name - Name of the dataset to edit\n * @param options - New options for the dataset\n */\n edit(name: string, options?: {aclMode?: DatasetAclMode}): Observable {\n return _modify(this.#client, this.#httpRequest, 'PATCH', name, options)\n }\n\n /**\n * Delete a dataset with the given name\n *\n * @param name - Name of the dataset to delete\n */\n delete(name: string): Observable<{deleted: true}> {\n return _modify<{deleted: true}>(this.#client, this.#httpRequest, 'DELETE', name)\n }\n\n /**\n * Fetch a list of datasets for the configured project\n */\n list(): Observable {\n return _request(this.#client, this.#httpRequest, {uri: '/datasets'})\n }\n}\n\n/** @internal */\nexport class DatasetsClient {\n #client: SanityClient\n #httpRequest: HttpRequest\n constructor(client: SanityClient, httpRequest: HttpRequest) {\n this.#client = client\n this.#httpRequest = httpRequest\n }\n\n /**\n * Create a new dataset with the given name\n *\n * @param name - Name of the dataset to create\n * @param options - Options for the dataset\n */\n create(name: string, options?: {aclMode?: DatasetAclMode}): Promise {\n return lastValueFrom(\n _modify(this.#client, this.#httpRequest, 'PUT', name, options)\n )\n }\n\n /**\n * Edit a dataset with the given name\n *\n * @param name - Name of the dataset to edit\n * @param options - New options for the dataset\n */\n edit(name: string, options?: {aclMode?: DatasetAclMode}): Promise {\n return lastValueFrom(\n _modify(this.#client, this.#httpRequest, 'PATCH', name, options)\n )\n }\n\n /**\n * Delete a dataset with the given name\n *\n * @param name - Name of the dataset to delete\n */\n delete(name: string): Promise<{deleted: true}> {\n return lastValueFrom(_modify<{deleted: true}>(this.#client, this.#httpRequest, 'DELETE', name))\n }\n\n /**\n * Fetch a list of datasets for the configured project\n */\n list(): Promise {\n return lastValueFrom(\n _request(this.#client, this.#httpRequest, {uri: '/datasets'})\n )\n }\n}\n\nfunction _modify(\n client: SanityClient | ObservableSanityClient,\n httpRequest: HttpRequest,\n method: 'DELETE' | 'PATCH' | 'PUT',\n name: string,\n options?: {aclMode?: DatasetAclMode}\n) {\n validate.dataset(name)\n return _request(client, httpRequest, {method, uri: `/datasets/${name}`, body: options})\n}\n","import {lastValueFrom, type Observable} from 'rxjs'\n\nimport {_request} from '../data/dataMethods'\nimport type {ObservableSanityClient, SanityClient} from '../SanityClient'\nimport type {HttpRequest, SanityProject} from '../types'\n\n/** @internal */\nexport class ObservableProjectsClient {\n #client: ObservableSanityClient\n #httpRequest: HttpRequest\n constructor(client: ObservableSanityClient, httpRequest: HttpRequest) {\n this.#client = client\n this.#httpRequest = httpRequest\n }\n\n /**\n * Fetch a list of projects the authenticated user has access to\n */\n list(): Observable {\n return _request(this.#client, this.#httpRequest, {uri: '/projects'})\n }\n\n /**\n * Fetch a project by project ID\n *\n * @param projectId - ID of the project to fetch\n */\n getById(projectId: string): Observable {\n return _request(this.#client, this.#httpRequest, {uri: `/projects/${projectId}`})\n }\n}\n\n/** @internal */\nexport class ProjectsClient {\n #client: SanityClient\n #httpRequest: HttpRequest\n constructor(client: SanityClient, httpRequest: HttpRequest) {\n this.#client = client\n this.#httpRequest = httpRequest\n }\n\n /**\n * Fetch a list of projects the authenticated user has access to\n */\n list(): Promise {\n return lastValueFrom(\n _request(this.#client, this.#httpRequest, {uri: '/projects'})\n )\n }\n\n /**\n * Fetch a project by project ID\n *\n * @param projectId - ID of the project to fetch\n */\n getById(projectId: string): Promise {\n return lastValueFrom(\n _request(this.#client, this.#httpRequest, {uri: `/projects/${projectId}`})\n )\n }\n}\n","import {lastValueFrom, type Observable} from 'rxjs'\n\nimport {_request} from '../data/dataMethods'\nimport type {ObservableSanityClient, SanityClient} from '../SanityClient'\nimport type {CurrentSanityUser, HttpRequest, SanityUser} from '../types'\n\n/** @public */\nexport class ObservableUsersClient {\n #client: ObservableSanityClient\n #httpRequest: HttpRequest\n constructor(client: ObservableSanityClient, httpRequest: HttpRequest) {\n this.#client = client\n this.#httpRequest = httpRequest\n }\n\n /**\n * Fetch a user by user ID\n *\n * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.\n */\n getById(\n id: T\n ): Observable {\n return _request(\n this.#client,\n this.#httpRequest,\n {uri: `/users/${id}`}\n )\n }\n}\n\n/** @public */\nexport class UsersClient {\n #client: SanityClient\n #httpRequest: HttpRequest\n constructor(client: SanityClient, httpRequest: HttpRequest) {\n this.#client = client\n this.#httpRequest = httpRequest\n }\n\n /**\n * Fetch a user by user ID\n *\n * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.\n */\n getById(\n id: T\n ): Promise {\n return lastValueFrom(\n _request(this.#client, this.#httpRequest, {\n uri: `/users/${id}`,\n })\n )\n }\n}\n","import {lastValueFrom, Observable} from 'rxjs'\n\nimport {AssetsClient, ObservableAssetsClient} from './assets/AssetsClient'\nimport {defaultConfig, initConfig} from './config'\nimport * as dataMethods from './data/dataMethods'\nimport {_listen} from './data/listen'\nimport {ObservablePatch, Patch} from './data/patch'\nimport {ObservableTransaction, Transaction} from './data/transaction'\nimport {DatasetsClient, ObservableDatasetsClient} from './datasets/DatasetsClient'\nimport {ObservableProjectsClient, ProjectsClient} from './projects/ProjectsClient'\nimport type {\n AllDocumentIdsMutationOptions,\n AllDocumentsMutationOptions,\n Any,\n BaseMutationOptions,\n ClientConfig,\n FilteredResponseQueryOptions,\n FirstDocumentIdMutationOptions,\n FirstDocumentMutationOptions,\n HttpRequest,\n IdentifiedSanityDocumentStub,\n InitializedClientConfig,\n MultipleMutationResult,\n Mutation,\n MutationSelection,\n PatchOperations,\n PatchSelection,\n QueryParams,\n RawQueryResponse,\n RawRequestOptions,\n SanityDocument,\n SanityDocumentStub,\n SingleMutationResult,\n UnfilteredResponseQueryOptions,\n} from './types'\nimport {ObservableUsersClient, UsersClient} from './users/UsersClient'\n\nexport type {\n _listen,\n AssetsClient,\n DatasetsClient,\n ObservableAssetsClient,\n ObservableDatasetsClient,\n ObservableProjectsClient,\n ObservableUsersClient,\n ProjectsClient,\n UsersClient,\n}\n\n/** @public */\nexport class ObservableSanityClient {\n assets: ObservableAssetsClient\n datasets: ObservableDatasetsClient\n projects: ObservableProjectsClient\n users: ObservableUsersClient\n\n /**\n * Private properties\n */\n #clientConfig: InitializedClientConfig\n #httpRequest: HttpRequest\n\n /**\n * Instance properties\n */\n listen = _listen\n\n constructor(httpRequest: HttpRequest, config: ClientConfig = defaultConfig) {\n this.config(config)\n\n this.#httpRequest = httpRequest\n\n this.assets = new ObservableAssetsClient(this, this.#httpRequest)\n this.datasets = new ObservableDatasetsClient(this, this.#httpRequest)\n this.projects = new ObservableProjectsClient(this, this.#httpRequest)\n this.users = new ObservableUsersClient(this, this.#httpRequest)\n }\n\n /**\n * Clone the client - returns a new instance\n */\n clone(): ObservableSanityClient {\n return new ObservableSanityClient(this.#httpRequest, this.config())\n }\n\n /**\n * Returns the current client configuration\n */\n config(): InitializedClientConfig\n /**\n * Reconfigure the client. Note that this _mutates_ the current client.\n */\n config(newConfig?: Partial): this\n config(newConfig?: Partial): ClientConfig | this {\n if (newConfig === undefined) {\n return {...this.#clientConfig}\n }\n\n if (this.#clientConfig && this.#clientConfig.allowReconfigure === false) {\n throw new Error(\n 'Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client'\n )\n }\n\n this.#clientConfig = initConfig(newConfig, this.#clientConfig || {})\n return this\n }\n\n /**\n * Clone the client with a new (partial) configuration.\n *\n * @param newConfig - New client configuration properties, shallowly merged with existing configuration\n */\n withConfig(newConfig?: Partial): ObservableSanityClient {\n return new ObservableSanityClient(this.#httpRequest, {...this.config(), ...newConfig})\n }\n\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n */\n fetch(query: string): Observable\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n */\n fetch(query: string, params: Q): Observable\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n * @param options - Request options\n */\n fetch(\n query: string,\n params: Q | undefined,\n options: FilteredResponseQueryOptions\n ): Observable\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Query parameters\n * @param options - Request options\n */\n fetch(\n query: string,\n params: Q | undefined,\n options: UnfilteredResponseQueryOptions\n ): Observable>\n fetch(\n query: string,\n params?: Q,\n options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {}\n ): Observable | R> {\n return dataMethods._fetch(this, this.#httpRequest, query, params, options)\n }\n\n /**\n * Fetch a single document with the given ID.\n *\n * @param id - Document ID to fetch\n * @param options - Request options\n */\n getDocument = Record>(\n id: string,\n options?: {tag?: string}\n ): Observable | undefined> {\n return dataMethods._getDocument(this, this.#httpRequest, id, options)\n }\n\n /**\n * Fetch multiple documents in one request.\n * Should be used sparingly - performing a query is usually a better option.\n * The order/position of documents is preserved based on the original array of IDs.\n * If any of the documents are missing, they will be replaced by a `null` entry in the returned array\n *\n * @param ids - Document IDs to fetch\n * @param options - Request options\n */\n getDocuments = Record>(\n ids: string[],\n options?: {tag?: string}\n ): Observable<(SanityDocument | null)[]> {\n return dataMethods._getDocuments(this, this.#httpRequest, ids, options)\n }\n\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create = Record>(\n document: SanityDocumentStub,\n options: FirstDocumentMutationOptions\n ): Observable>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns an observable that resolves to an array containing the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create = Record>(\n document: SanityDocumentStub,\n options: AllDocumentsMutationOptions\n ): Observable[]>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns an observable that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create = Record>(\n document: SanityDocumentStub,\n options: FirstDocumentIdMutationOptions\n ): Observable\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns an observable that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create = Record>(\n document: SanityDocumentStub,\n options: AllDocumentIdsMutationOptions\n ): Observable\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create = Record>(\n document: SanityDocumentStub,\n options?: BaseMutationOptions\n ): Observable>\n create = Record>(\n document: SanityDocumentStub,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n ): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n return dataMethods._create(this, this.#httpRequest, document, 'create', options)\n }\n\n /**\n * Create a document if no document with the same ID already exists.\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options: FirstDocumentMutationOptions\n ): Observable>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns an observable that resolves to an array containing the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options: AllDocumentsMutationOptions\n ): Observable[]>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns an observable that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options: FirstDocumentIdMutationOptions\n ): Observable\n /**\n * Create a document if no document with the same ID already exists.\n * Returns an observable that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options: AllDocumentIdsMutationOptions\n ): Observable\n /**\n * Create a document if no document with the same ID already exists.\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options?: BaseMutationOptions\n ): Observable>\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n ): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n return dataMethods._createIfNotExists(this, this.#httpRequest, document, options)\n }\n\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options: FirstDocumentMutationOptions\n ): Observable>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns an observable that resolves to an array containing the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options: AllDocumentsMutationOptions\n ): Observable[]>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns an observable that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options: FirstDocumentIdMutationOptions\n ): Observable\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns an observable that resolves to a mutation result object containing the created document ID.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options: AllDocumentIdsMutationOptions\n ): Observable\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options?: BaseMutationOptions\n ): Observable>\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n ): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n return dataMethods._createOrReplace(this, this.#httpRequest, document, options)\n }\n\n /**\n * Deletes a document with the given document ID.\n * Returns an observable that resolves to the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n id: string,\n options: FirstDocumentMutationOptions\n ): Observable>\n /**\n * Deletes a document with the given document ID.\n * Returns an observable that resolves to an array containing the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n id: string,\n options: AllDocumentsMutationOptions\n ): Observable[]>\n /**\n * Deletes a document with the given document ID.\n * Returns an observable that resolves to a mutation result object containing the deleted document ID.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete(id: string, options: FirstDocumentIdMutationOptions): Observable\n /**\n * Deletes a document with the given document ID.\n * Returns an observable that resolves to a mutation result object containing the deleted document ID.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete(id: string, options: AllDocumentIdsMutationOptions): Observable\n /**\n * Deletes a document with the given document ID.\n * Returns an observable that resolves to the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n id: string,\n options?: BaseMutationOptions\n ): Observable>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns an observable that resolves to first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n selection: MutationSelection,\n options: FirstDocumentMutationOptions\n ): Observable>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns an observable that resolves to an array containing the deleted documents.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n selection: MutationSelection,\n options: AllDocumentsMutationOptions\n ): Observable[]>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete(\n selection: MutationSelection,\n options: FirstDocumentIdMutationOptions\n ): Observable\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete(\n selection: MutationSelection,\n options: AllDocumentIdsMutationOptions\n ): Observable\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns an observable that resolves to first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n selection: MutationSelection,\n options?: BaseMutationOptions\n ): Observable>\n delete = Record>(\n selection: string | MutationSelection,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n ): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n return dataMethods._delete(this, this.#httpRequest, selection, options)\n }\n\n /**\n * Perform mutation operations against the configured dataset\n * Returns an observable that resolves to the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate = Record>(\n operations: Mutation[] | ObservablePatch | ObservableTransaction,\n options: FirstDocumentMutationOptions\n ): Observable>\n /**\n * Perform mutation operations against the configured dataset.\n * Returns an observable that resolves to an array of the mutated documents.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate = Record>(\n operations: Mutation[] | ObservablePatch | ObservableTransaction,\n options: AllDocumentsMutationOptions\n ): Observable[]>\n /**\n * Perform mutation operations against the configured dataset\n * Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate = Record>(\n operations: Mutation[] | ObservablePatch | ObservableTransaction,\n options: FirstDocumentIdMutationOptions\n ): Observable\n /**\n * Perform mutation operations against the configured dataset\n * Returns an observable that resolves to a mutation result object containing the mutated document IDs.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate = Record>(\n operations: Mutation[] | ObservablePatch | ObservableTransaction,\n options: AllDocumentIdsMutationOptions\n ): Observable\n /**\n * Perform mutation operations against the configured dataset\n * Returns an observable that resolves to the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate = Record>(\n operations: Mutation[] | ObservablePatch | ObservableTransaction,\n options?: BaseMutationOptions\n ): Observable>\n mutate = Record>(\n operations: Mutation[] | ObservablePatch | ObservableTransaction,\n options?:\n | FirstDocumentMutationOptions\n | AllDocumentsMutationOptions\n | FirstDocumentIdMutationOptions\n | AllDocumentIdsMutationOptions\n | BaseMutationOptions\n ): Observable<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n return dataMethods._mutate(this, this.#httpRequest, operations, options)\n }\n\n /**\n * Create a new buildable patch of operations to perform\n *\n * @param documentId - Document ID(s) to patch\n * @param operations - Optional object of patch operations to initialize the patch instance with\n */\n patch(documentId: PatchSelection, operations?: PatchOperations): ObservablePatch {\n return new ObservablePatch(documentId, operations, this)\n }\n\n /**\n * Create a new transaction of mutations\n *\n * @param operations - Optional array of mutation operations to initialize the transaction instance with\n */\n transaction = Record>(\n operations?: Mutation[]\n ): ObservableTransaction {\n return new ObservableTransaction(operations, this)\n }\n\n /**\n * DEPRECATED: Perform an HTTP request against the Sanity API\n *\n * @deprecated Use your own request library!\n * @param options - Request options\n */\n request(options: RawRequestOptions): Observable {\n return dataMethods._request(this, this.#httpRequest, options)\n }\n\n /**\n * Get a Sanity API URL for the URI provided\n *\n * @param uri - URI/path to build URL for\n * @param canUseCdn - Whether or not to allow using the API CDN for this route\n */\n getUrl(uri: string, canUseCdn?: boolean): string {\n return dataMethods._getUrl(this, uri, canUseCdn)\n }\n\n /**\n * Get a Sanity API URL for the data operation and path provided\n *\n * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)\n * @param path - Path to append after the operation\n */\n getDataUrl(operation: string, path?: string): string {\n return dataMethods._getDataUrl(this, operation, path)\n }\n}\n\n/** @public */\nexport class SanityClient {\n assets: AssetsClient\n datasets: DatasetsClient\n projects: ProjectsClient\n users: UsersClient\n\n /**\n * Observable version of the Sanity client, with the same configuration as the promise-based one\n */\n observable: ObservableSanityClient\n\n /**\n * Private properties\n */\n #clientConfig: InitializedClientConfig\n #httpRequest: HttpRequest\n\n /**\n * Instance properties\n */\n listen = _listen\n\n constructor(httpRequest: HttpRequest, config: ClientConfig = defaultConfig) {\n this.config(config)\n\n this.#httpRequest = httpRequest\n\n this.assets = new AssetsClient(this, this.#httpRequest)\n this.datasets = new DatasetsClient(this, this.#httpRequest)\n this.projects = new ProjectsClient(this, this.#httpRequest)\n this.users = new UsersClient(this, this.#httpRequest)\n\n this.observable = new ObservableSanityClient(httpRequest, config)\n }\n\n /**\n * Clone the client - returns a new instance\n */\n clone(): SanityClient {\n return new SanityClient(this.#httpRequest, this.config())\n }\n\n /**\n * Returns the current client configuration\n */\n config(): InitializedClientConfig\n /**\n * Reconfigure the client. Note that this _mutates_ the current client.\n */\n config(newConfig?: Partial): this\n config(newConfig?: Partial): ClientConfig | this {\n if (newConfig === undefined) {\n return {...this.#clientConfig}\n }\n\n if (this.#clientConfig && this.#clientConfig.allowReconfigure === false) {\n throw new Error(\n 'Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client'\n )\n }\n\n if (this.observable) {\n this.observable.config(newConfig)\n }\n\n this.#clientConfig = initConfig(newConfig, this.#clientConfig || {})\n return this\n }\n\n /**\n * Clone the client with a new (partial) configuration.\n *\n * @param newConfig - New client configuration properties, shallowly merged with existing configuration\n */\n withConfig(newConfig?: Partial): SanityClient {\n return new SanityClient(this.#httpRequest, {...this.config(), ...newConfig})\n }\n\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n */\n fetch(query: string): Promise\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n */\n fetch(query: string, params: Q): Promise\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch(\n query: string,\n params: Q | undefined,\n options: FilteredResponseQueryOptions\n ): Promise\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch(\n query: string,\n params: Q | undefined,\n options: UnfilteredResponseQueryOptions\n ): Promise>\n fetch(\n query: string,\n params?: Q,\n options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {}\n ): Promise | R> {\n return lastValueFrom(dataMethods._fetch(this, this.#httpRequest, query, params, options))\n }\n\n /**\n * Fetch a single document with the given ID.\n *\n * @param id - Document ID to fetch\n * @param options - Request options\n */\n getDocument = Record>(\n id: string,\n options?: {tag?: string}\n ): Promise | undefined> {\n return lastValueFrom(dataMethods._getDocument(this, this.#httpRequest, id, options))\n }\n\n /**\n * Fetch multiple documents in one request.\n * Should be used sparingly - performing a query is usually a better option.\n * The order/position of documents is preserved based on the original array of IDs.\n * If any of the documents are missing, they will be replaced by a `null` entry in the returned array\n *\n * @param ids - Document IDs to fetch\n * @param options - Request options\n */\n getDocuments = Record>(\n ids: string[],\n options?: {tag?: string}\n ): Promise<(SanityDocument | null)[]> {\n return lastValueFrom(dataMethods._getDocuments(this, this.#httpRequest, ids, options))\n }\n\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create = Record>(\n document: SanityDocumentStub,\n options: FirstDocumentMutationOptions\n ): Promise>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns a promise that resolves to an array containing the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create = Record>(\n document: SanityDocumentStub,\n options: AllDocumentsMutationOptions\n ): Promise[]>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns a promise that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create = Record>(\n document: SanityDocumentStub,\n options: FirstDocumentIdMutationOptions\n ): Promise\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns a promise that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create = Record>(\n document: SanityDocumentStub,\n options: AllDocumentIdsMutationOptions\n ): Promise\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create = Record>(\n document: SanityDocumentStub,\n options?: BaseMutationOptions\n ): Promise>\n create = Record>(\n document: SanityDocumentStub,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n ): Promise<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n return lastValueFrom(\n dataMethods._create(this, this.#httpRequest, document, 'create', options)\n )\n }\n\n /**\n * Create a document if no document with the same ID already exists.\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options: FirstDocumentMutationOptions\n ): Promise>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns a promise that resolves to an array containing the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options: AllDocumentsMutationOptions\n ): Promise[]>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns a promise that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options: FirstDocumentIdMutationOptions\n ): Promise\n /**\n * Create a document if no document with the same ID already exists.\n * Returns a promise that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options: AllDocumentIdsMutationOptions\n ): Promise\n /**\n * Create a document if no document with the same ID already exists.\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options?: BaseMutationOptions\n ): Promise>\n createIfNotExists = Record>(\n document: IdentifiedSanityDocumentStub,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n ): Promise<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n return lastValueFrom(\n dataMethods._createIfNotExists(this, this.#httpRequest, document, options)\n )\n }\n\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options: FirstDocumentMutationOptions\n ): Promise>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns a promise that resolves to an array containing the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options: AllDocumentsMutationOptions\n ): Promise[]>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns a promise that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options: FirstDocumentIdMutationOptions\n ): Promise\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns a promise that resolves to a mutation result object containing the created document ID.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options: AllDocumentIdsMutationOptions\n ): Promise\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options?: BaseMutationOptions\n ): Promise>\n createOrReplace = Record>(\n document: IdentifiedSanityDocumentStub,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n ): Promise<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n return lastValueFrom(\n dataMethods._createOrReplace(this, this.#httpRequest, document, options)\n )\n }\n\n /**\n * Deletes a document with the given document ID.\n * Returns a promise that resolves to the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n id: string,\n options: FirstDocumentMutationOptions\n ): Promise>\n /**\n * Deletes a document with the given document ID.\n * Returns a promise that resolves to an array containing the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n id: string,\n options: AllDocumentsMutationOptions\n ): Promise[]>\n /**\n * Deletes a document with the given document ID.\n * Returns a promise that resolves to a mutation result object containing the deleted document ID.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete(id: string, options: FirstDocumentIdMutationOptions): Promise\n /**\n * Deletes a document with the given document ID.\n * Returns a promise that resolves to a mutation result object containing the deleted document ID.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete(id: string, options: AllDocumentIdsMutationOptions): Promise\n /**\n * Deletes a document with the given document ID.\n * Returns a promise that resolves to the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n id: string,\n options?: BaseMutationOptions\n ): Promise>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns a promise that resolves to first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n selection: MutationSelection,\n options: FirstDocumentMutationOptions\n ): Promise>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns a promise that resolves to an array containing the deleted documents.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n selection: MutationSelection,\n options: AllDocumentsMutationOptions\n ): Promise[]>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete(\n selection: MutationSelection,\n options: FirstDocumentIdMutationOptions\n ): Promise\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete(\n selection: MutationSelection,\n options: AllDocumentIdsMutationOptions\n ): Promise\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns a promise that resolves to first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete = Record>(\n selection: MutationSelection,\n options?: BaseMutationOptions\n ): Promise>\n delete = Record>(\n selection: string | MutationSelection,\n options?:\n | AllDocumentIdsMutationOptions\n | AllDocumentsMutationOptions\n | BaseMutationOptions\n | FirstDocumentIdMutationOptions\n | FirstDocumentMutationOptions\n ): Promise<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n return lastValueFrom(dataMethods._delete(this, this.#httpRequest, selection, options))\n }\n\n /**\n * Perform mutation operations against the configured dataset\n * Returns a promise that resolves to the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate = Record>(\n operations: Mutation[] | Patch | Transaction,\n options: FirstDocumentMutationOptions\n ): Promise>\n /**\n * Perform mutation operations against the configured dataset.\n * Returns a promise that resolves to an array of the mutated documents.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate = Record>(\n operations: Mutation[] | Patch | Transaction,\n options: AllDocumentsMutationOptions\n ): Promise[]>\n /**\n * Perform mutation operations against the configured dataset\n * Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate = Record>(\n operations: Mutation[] | Patch | Transaction,\n options: FirstDocumentIdMutationOptions\n ): Promise\n /**\n * Perform mutation operations against the configured dataset\n * Returns a promise that resolves to a mutation result object containing the mutated document IDs.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate>(\n operations: Mutation[] | Patch | Transaction,\n options: AllDocumentIdsMutationOptions\n ): Promise\n /**\n * Perform mutation operations against the configured dataset\n * Returns a promise that resolves to the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate = Record>(\n operations: Mutation[] | Patch | Transaction,\n options?: BaseMutationOptions\n ): Promise>\n mutate = Record>(\n operations: Mutation[] | Patch | Transaction,\n options?:\n | FirstDocumentMutationOptions\n | AllDocumentsMutationOptions\n | FirstDocumentIdMutationOptions\n | AllDocumentIdsMutationOptions\n | BaseMutationOptions\n ): Promise<\n SanityDocument | SanityDocument[] | SingleMutationResult | MultipleMutationResult\n > {\n return lastValueFrom(dataMethods._mutate(this, this.#httpRequest, operations, options))\n }\n\n /**\n * Create a new buildable patch of operations to perform\n *\n * @param documentId - Document ID(s)to patch\n * @param operations - Optional object of patch operations to initialize the patch instance with\n */\n patch(documentId: PatchSelection, operations?: PatchOperations): Patch {\n return new Patch(documentId, operations, this)\n }\n\n /**\n * Create a new transaction of mutations\n *\n * @param operations - Optional array of mutation operations to initialize the transaction instance with\n */\n transaction = Record>(\n operations?: Mutation[]\n ): Transaction {\n return new Transaction(operations, this)\n }\n\n /**\n * DEPRECATED: Perform an HTTP request against the Sanity API\n *\n * @deprecated Use your own request library!\n * @param options - Request options\n */\n request(options: RawRequestOptions): Promise {\n return lastValueFrom(dataMethods._request(this, this.#httpRequest, options))\n }\n\n /**\n * DEPRECATED: Perform an HTTP request a `/data` sub-endpoint\n *\n * @deprecated Use your own request library!\n * @param endpoint - Endpoint to hit (mutate, query etc)\n * @param body - Request body\n * @param options - Request options\n */\n dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise {\n return lastValueFrom(dataMethods._dataRequest(this, this.#httpRequest, endpoint, body, options))\n }\n\n /**\n * Get a Sanity API URL for the URI provided\n *\n * @param uri - URI/path to build URL for\n * @param canUseCdn - Whether or not to allow using the API CDN for this route\n */\n getUrl(uri: string, canUseCdn?: boolean): string {\n return dataMethods._getUrl(this, uri, canUseCdn)\n }\n\n /**\n * Get a Sanity API URL for the data operation and path provided\n *\n * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)\n * @param path - Path to append after the operation\n */\n getDataUrl(operation: string, path?: string): string {\n return dataMethods._getDataUrl(this, operation, path)\n }\n}\n","import envMiddleware from './http/browserMiddleware'\nimport {defineHttpRequest} from './http/request'\nimport {SanityClient} from './SanityClient'\nimport type {ClientConfig} from './types'\nimport {printNoDefaultExport} from './warnings'\n\nexport * from './data/patch'\nexport * from './data/transaction'\nexport {ClientError, ServerError} from './http/errors'\nexport * from './SanityClient'\nexport * from './types'\n\n// Set the http client to use for requests, and its environment specific middleware\nconst httpRequest = defineHttpRequest(envMiddleware)\n/** @public */\nexport const requester = httpRequest.defaultRequester\n\n/** @public */\nexport const createClient = (config: ClientConfig) => new SanityClient(httpRequest, config)\n\n/**\n * @public\n * @deprecated Use the named export `createClient` instead of the `default` export\n */\nexport default function deprecatedCreateClient(config: ClientConfig) {\n printNoDefaultExport()\n return new SanityClient(httpRequest, config)\n}\n\n/** @alpha */\nexport {adapter as unstable__adapter, environment as unstable__environment} from 'get-it'\n"],"names":["envMiddleware","MAX_ITEMS_IN_ERROR_MESSAGE","ClientError","Error","constructor","res","props","extractErrorProps","message","statusCode","Object","assign","ServerError","body","response","responseBody","stringifyBody","details","error","concat","isMutationError","allItems","items","slice","map","item","_a","description","filter","Boolean","itemsStr","length","join","httpErrorMessage","isPlainObject","type","obj","Array","isArray","statusMessage","method","url","contentType","headers","toLowerCase","isJson","indexOf","JSON","stringify","httpError","onResponse","printWarnings","warn","warnings","forEach","msg","console","defineHttpRequest","request","getIt","jsonRequest","jsonResponse","progress","observable","implementation","Observable","httpRequest","options","requester","arguments","undefined","maxRedirects","defaultRequester","projectHeader","requestOptions","config","overrides","token","Authorization","useGlobalApi","useProjectHostname","projectId","withCredentials","timeout","proxy","json","getSelection","sel","id","query","params","selectionOpts","VALID_ASSET_TYPES","VALID_INSERT_LOCATIONS","dataset","name","test","validateAssetType","validateObject","op","val","validateDocumentId","includes","requireDocumentId","doc","_id","validateInsert","at","selector","signature","valid","loc","hasDataset","requestTag","tag","encodeQueryString","_ref","searchParams","URLSearchParams","opts","set","key","value","entries","_client","BasePatch","selection","operations","attrs","_assign","setIfMissing","diffMatchPatch","unset","inc","dec","insert","append","prepend","splice","start","deleteCount","delAll","startIndex","delCount","Math","max","delRange","rangeSelector","ifRevisionId","rev","ifRevisionID","serialize","toJSON","reset","merge","_set","_ObservablePatch","client","__privateAdd","__privateSet","clone","__privateGet","commit","returnFirst","returnDocuments","mutate","patch","ObservablePatch","WeakMap","_Patch","Patch","defaultMutateOptions","BaseTransaction","transactionId","trxId","create","validators.validateObject","_add","createIfNotExists","validators.requireDocumentId","createOrReplace","delete","documentId","validators.validateDocumentId","mut","push","_Transaction","patchOrDocumentId","patchOps","isBuilder","isPatch","Transaction","_ObservableTransaction","ObservableTransaction","excludeFalsey","param","defValue","getMutationQuery","dryRun","returnIds","visibility","autoGenerateArrayKeys","skipCrossDatasetReferenceValidation","isResponse","event","getBody","indexBy","docs","attr","reduce","indexed","getQuerySizeLimit","_fetch","mapResponse","filterResponse","result","_dataRequest","pipe","_getDocument","uri","_getDataUrl","_requestObservable","documents","_getDocuments","ids","_createIfNotExists","_create","_createOrReplace","_delete","mutations","_mutate","muts","endpoint","isMutation","isQuery","strQuery","useGet","stringQuery","reqOptions","canUseCdn","signal","results","document","mutation","useCdn","requestTagPrefix","validate.requestTag","_getUrl","subscriber","subscribe","_withAbortSignal","_request","operation","path","catalog","validators.hasDataset","baseUri","replace","cdnUrl","base","input","observer","abort","_createAbortError","aborted","subscription","addEventListener","removeEventListener","unsubscribe","isDomExceptionSupported","globalThis","DOMException","_b","reason","_httpRequest","ObservableAssetsClient","upload","assetType","_upload","AssetsClient","lastValueFrom","validators.validateAssetType","meta","extract","assetEndpoint","optionsFromFile","label","title","creditLine","filename","source","sourceId","sourceName","sourceUrl","file","File","preserveFilename","BASE_URL","generateHelpUrl","slug","once","fn","didCall","returnValue","createWarningPrinter","_len","args","_key","printCdnWarning","printBrowserTokenWarning","printNoApiVersionSpecifiedWarning","printNoDefaultExport","defaultCdnHost","defaultConfig","apiHost","apiVersion","LOCALHOSTS","isLocal","host","validateApiVersion","apiDate","Date","apiVersionValid","getTime","initConfig","prevConfig","specifiedConfig","warnings.printNoApiVersionSpecifiedWarning","newConfig","projectBased","Promise","helpUrl","isBrowser","window","location","hostname","isLocalhost","ignoreBrowserTokenWarning","warnings.printBrowserTokenWarning","warnings.printCdnWarning","validate.projectId","validate.dataset","isDefaultApi","hostParts","split","protocol","cdnHost","defaults","keys","target","prop","pick","MAX_URL_LENGTH","possibleOptions","defaultOptions","includeResult","_listen","listenOpts","qs","listenFor","events","shouldEmitReconnect","esOptions","es","getEventSource","then","eventSource","catch","stop","reconnectTimer","stopped","onError","emitReconnect","readyState","CLOSED","clearTimeout","setTimeout","open","onChannelError","err","cooerceError","onMessage","evt","parseEvent","next","onDisconnect","complete","close","default","EventSource","evs","data","parse","extractErrorMessage","ObservableDatasetsClient","_modify","edit","list","DatasetsClient","ObservableProjectsClient","getById","ProjectsClient","ObservableUsersClient","UsersClient","_clientConfig","_ObservableSanityClient","listen","assets","datasets","projects","users","allowReconfigure","withConfig","fetch","dataMethods._fetch","getDocument","dataMethods._getDocument","getDocuments","dataMethods._getDocuments","dataMethods._create","dataMethods._createIfNotExists","dataMethods._createOrReplace","dataMethods._delete","dataMethods._mutate","transaction","dataMethods._request","getUrl","dataMethods._getUrl","getDataUrl","dataMethods._getDataUrl","ObservableSanityClient","_SanityClient","dataRequest","dataMethods._dataRequest","SanityClient","createClient","deprecatedCreateClient"],"mappings":";;;;;;;;;AAAA,IAAAA,aAAA,GAAe,EAAC;ACEhB,MAAMC,0BAA6B,GAAA,CAAA;AAG5B,MAAMC,oBAAoBC,KAAM,CAAA;EAMrCC,YAAYC,GAAU,EAAA;IACd,MAAAC,KAAA,GAAQC,kBAAkBF,GAAG,CAAA;IACnC,KAAA,CAAMC,MAAME,OAAO,CAAA;IANkB,IAAA,CAAAC,UAAA,GAAA,GAAA;IAO9BC,MAAA,CAAAC,MAAA,CAAO,MAAML,KAAK,CAAA;EAC3B;AACF;AAGO,MAAMM,oBAAoBT,KAAM,CAAA;EAMrCC,YAAYC,GAAU,EAAA;IACd,MAAAC,KAAA,GAAQC,kBAAkBF,GAAG,CAAA;IACnC,KAAA,CAAMC,MAAME,OAAO,CAAA;IANkB,IAAA,CAAAC,UAAA,GAAA,GAAA;IAO9BC,MAAA,CAAAC,MAAA,CAAO,MAAML,KAAK,CAAA;EAC3B;AACF;AAEA,SAASC,kBAAkBF,GAAsB,EAAA;EAC/C,MAAMQ,OAAOR,GAAI,CAAAQ,IAAA;EACjB,MAAMP,KAAQ,GAAA;IACZQ,QAAU,EAAAT,GAAA;IACVI,YAAYJ,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