1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263 |
- import {Observable} from 'rxjs'
- import {Requester} from 'get-it'
- import {adapter as unstable__adapter} from 'get-it'
- import {environment as unstable__environment} from 'get-it'
- export declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
- returnFirst: false
- returnDocuments: false
- }
- export declare type AllDocumentsMutationOptions = BaseMutationOptions & {
- returnFirst: false
- returnDocuments?: true
- }
- export declare type Any = any
- export declare interface ApiError {
- error: string
- message: string
- statusCode: number
- }
- export declare type AssetMetadataType =
- | 'location'
- | 'exif'
- | 'image'
- | 'palette'
- | 'lqip'
- | 'blurhash'
- | 'none'
- export declare class AssetsClient {
- #private
- constructor(client: SanityClient, httpRequest: HttpRequest)
- /**
- * Uploads a file asset to the configured dataset
- *
- * @param assetType - Asset type (file)
- * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
- * @param options - Options to use for the upload
- */
- upload(
- assetType: 'file',
- body: UploadBody,
- options?: UploadClientConfig
- ): Promise<SanityAssetDocument>
- /**
- * Uploads an image asset to the configured dataset
- *
- * @param assetType - Asset type (image)
- * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
- * @param options - Options to use for the upload
- */
- upload(
- assetType: 'image',
- body: UploadBody,
- options?: UploadClientConfig
- ): Promise<SanityImageAssetDocument>
- /**
- * Uploads a file or an image asset to the configured dataset
- *
- * @param assetType - Asset type (file/image)
- * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
- * @param options - Options to use for the upload
- */
- upload(
- assetType: 'file' | 'image',
- body: UploadBody,
- options?: UploadClientConfig
- ): Promise<SanityAssetDocument | SanityImageAssetDocument>
- }
- /** @internal */
- export declare type AttributeSet = {
- [key: string]: Any
- }
- export declare interface AuthProvider {
- name: string
- title: string
- url: string
- }
- export declare type AuthProviderResponse = {
- providers: AuthProvider[]
- }
- export declare type BaseMutationOptions = RequestOptions & {
- visibility?: 'sync' | 'async' | 'deferred'
- returnDocuments?: boolean
- returnFirst?: boolean
- dryRun?: boolean
- autoGenerateArrayKeys?: boolean
- skipCrossDatasetReferenceValidation?: boolean
- transactionId?: string
- }
- export declare class BasePatch {
- protected selection: PatchSelection
- protected operations: PatchOperations
- constructor(selection: PatchSelection, operations?: PatchOperations)
- /**
- * Sets the given attributes to the document. Does NOT merge objects.
- * The operation is added to the current patch, ready to be commited by `commit()`
- *
- * @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
- */
- set(attrs: AttributeSet): this
- /**
- * Sets the given attributes to the document if they are not currently set. Does NOT merge objects.
- * The operation is added to the current patch, ready to be commited by `commit()`
- *
- * @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
- */
- setIfMissing(attrs: AttributeSet): this
- /**
- * Performs a "diff-match-patch" operation on the string attributes provided.
- * The operation is added to the current patch, ready to be commited by `commit()`
- *
- * @param attrs - Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "dmp"\}
- */
- diffMatchPatch(attrs: AttributeSet): this
- /**
- * Unsets the attribute paths provided.
- * The operation is added to the current patch, ready to be commited by `commit()`
- *
- * @param attrs - Attribute paths to unset.
- */
- unset(attrs: string[]): this
- /**
- * 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.
- *
- * @param attrs - Object of attribute paths to increment, values representing the number to increment by.
- */
- inc(attrs: {[key: string]: number}): this
- /**
- * 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.
- *
- * @param attrs - Object of attribute paths to decrement, values representing the number to decrement by.
- */
- dec(attrs: {[key: string]: number}): this
- /**
- * Provides methods for modifying arrays, by inserting, appending and replacing elements via a JSONPath expression.
- *
- * @param at - Location to insert at, relative to the given selector, or 'replace' the matched path
- * @param selector - JSONPath expression, eg `comments[-1]` or `blocks[_key=="abc123"]`
- * @param items - Array of items to insert/replace
- */
- insert(at: 'before' | 'after' | 'replace', selector: string, items: Any[]): this
- /**
- * Append the given items to the array at the given JSONPath
- *
- * @param selector - Attribute/path to append to, eg `comments` or `person.hobbies`
- * @param items - Array of items to append to the array
- */
- append(selector: string, items: Any[]): this
- /**
- * Prepend the given items to the array at the given JSONPath
- *
- * @param selector - Attribute/path to prepend to, eg `comments` or `person.hobbies`
- * @param items - Array of items to prepend to the array
- */
- prepend(selector: string, items: Any[]): this
- /**
- * Change the contents of an array by removing existing elements and/or adding new elements.
- *
- * @param selector - Attribute or JSONPath expression for array
- * @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
- * @param deleteCount - An integer indicating the number of old array elements to remove.
- * @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.
- */
- splice(selector: string, start: number, deleteCount?: number, items?: Any[]): this
- /**
- * Adds a revision clause, preventing the document from being patched if the `_rev` property does not match the given value
- *
- * @param rev - Revision to lock the patch to
- */
- ifRevisionId(rev: string): this
- /**
- * Return a plain JSON representation of the patch
- */
- serialize(): PatchMutationOperation
- /**
- * Return a plain JSON representation of the patch
- */
- toJSON(): PatchMutationOperation
- /**
- * Clears the patch of all operations
- */
- reset(): this
- protected _assign(op: keyof PatchOperations, props: Any, merge?: boolean): this
- protected _set(op: keyof PatchOperations, props: Any): this
- }
- /** @internal */
- export declare class BaseTransaction {
- protected operations: Mutation[]
- protected trxId?: string
- constructor(operations?: Mutation[], transactionId?: string)
- /**
- * 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.
- * The operation is added to the current transaction, ready to be commited by `commit()`
- *
- * @param doc - Document to create. Requires a `_type` property.
- */
- create<R extends Record<string, Any> = Record<string, Any>>(doc: SanityDocumentStub<R>): this
- /**
- * Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.
- * The operation is added to the current transaction, ready to be commited by `commit()`
- *
- * @param doc - Document to create if it does not already exist. Requires `_id` and `_type` properties.
- */
- createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
- doc: IdentifiedSanityDocumentStub<R>
- ): this
- /**
- * Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.
- * The operation is added to the current transaction, ready to be commited by `commit()`
- *
- * @param doc - Document to create or replace. Requires `_id` and `_type` properties.
- */
- createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
- doc: IdentifiedSanityDocumentStub<R>
- ): this
- /**
- * Deletes the document with the given document ID
- * The operation is added to the current transaction, ready to be commited by `commit()`
- *
- * @param documentId - Document ID to delete
- */
- delete(documentId: string): this
- /**
- * Gets the current transaction ID, if any
- */
- transactionId(): string | undefined
- /**
- * Set the ID of this transaction.
- *
- * @param id - Transaction ID
- */
- transactionId(id: string): this
- /**
- * Return a plain JSON representation of the transaction
- */
- serialize(): Mutation[]
- /**
- * Return a plain JSON representation of the transaction
- */
- toJSON(): Mutation[]
- /**
- * Clears the transaction of all operations
- */
- reset(): this
- protected _add(mut: Mutation): this
- }
- /** @public */
- export declare type ChannelErrorEvent = {
- type: 'channelError'
- message: string
- }
- /** @public */
- export declare interface ClientConfig {
- projectId?: string
- dataset?: string
- useCdn?: boolean
- token?: string
- apiHost?: string
- apiVersion?: string
- proxy?: string
- requestTagPrefix?: string
- ignoreBrowserTokenWarning?: boolean
- withCredentials?: boolean
- allowReconfigure?: boolean
- timeout?: number
- /**
- * @deprecated Don't use
- */
- useProjectHostname?: boolean
- /**
- * @deprecated Don't use
- */
- requester?: Requester
- }
- /** @public */
- export declare class ClientError extends Error {
- response: ErrorProps['response']
- statusCode: ErrorProps['statusCode']
- responseBody: ErrorProps['responseBody']
- details: ErrorProps['details']
- constructor(res: Any)
- }
- /** @public */
- export declare const createClient: (config: ClientConfig) => SanityClient
- /** @internal */
- export declare interface CurrentSanityUser {
- id: string
- name: string
- email: string
- profileImage: string | null
- role: string
- }
- /** @internal */
- export declare type DatasetAclMode = 'public' | 'private' | 'custom'
- /** @internal */
- export declare type DatasetResponse = {
- datasetName: string
- aclMode: DatasetAclMode
- }
- /** @internal */
- export declare class DatasetsClient {
- #private
- constructor(client: SanityClient, httpRequest: HttpRequest)
- /**
- * Create a new dataset with the given name
- *
- * @param name - Name of the dataset to create
- * @param options - Options for the dataset
- */
- create(
- name: string,
- options?: {
- aclMode?: DatasetAclMode
- }
- ): Promise<DatasetResponse>
- /**
- * Edit a dataset with the given name
- *
- * @param name - Name of the dataset to edit
- * @param options - New options for the dataset
- */
- edit(
- name: string,
- options?: {
- aclMode?: DatasetAclMode
- }
- ): Promise<DatasetResponse>
- /**
- * Delete a dataset with the given name
- *
- * @param name - Name of the dataset to delete
- */
- delete(name: string): Promise<{
- deleted: true
- }>
- /**
- * Fetch a list of datasets for the configured project
- */
- list(): Promise<DatasetsResponse>
- }
- /** @internal */
- export declare type DatasetsResponse = {
- name: string
- aclMode: DatasetAclMode
- }[]
- /**
- * @public
- * @deprecated Use the named export `createClient` instead of the `default` export
- */
- declare function deprecatedCreateClient(config: ClientConfig): SanityClient
- export default deprecatedCreateClient
- /** @public */
- export declare type DisconnectEvent = {
- type: 'disconnect'
- reason: string
- }
- /** @public */
- export declare interface ErrorProps {
- message: string
- response: Any
- statusCode: number
- responseBody: Any
- details: Any
- }
- /** @internal */
- export declare type FilteredResponseQueryOptions = RequestOptions & {
- filterResponse?: true
- }
- /** @internal */
- export declare type FirstDocumentIdMutationOptions = BaseMutationOptions & {
- returnFirst?: true
- returnDocuments: false
- }
- /** @internal */
- export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
- returnFirst?: true
- returnDocuments?: true
- }
- /** @public */
- export declare type HttpRequest = {
- defaultRequester: Requester
- (options: RequestOptions, requester: Requester): ReturnType<Requester>
- }
- /** @public */
- export declare type HttpRequestEvent<T = unknown> = ResponseEvent<T> | ProgressEvent_2
- /** @public */
- export declare type IdentifiedSanityDocumentStub<
- T extends Record<string, Any> = Record<string, Any>
- > = {
- [P in keyof T]: T[P]
- } & {
- _id: string
- } & SanityDocumentStub
- /** @public */
- export declare interface InitializedClientConfig extends ClientConfig {
- apiHost: string
- apiVersion: string
- useProjectHostname: boolean
- useCdn: boolean
- /**
- * @deprecated Internal, don't use
- */
- isDefaultApi: boolean
- /**
- * @deprecated Internal, don't use
- */
- url: string
- /**
- * @deprecated Internal, don't use
- */
- cdnUrl: string
- }
- /** @internal */
- export declare type InsertPatch =
- | {
- before: string
- items: Any[]
- }
- | {
- after: string
- items: Any[]
- }
- | {
- replace: string
- items: Any[]
- }
- /**
- * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
- *
- * @param query - GROQ-filter to listen to changes for
- * @param params - Optional query parameters
- * @param options - Listener options
- * @internal
- */
- export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
- this: SanityClient | ObservableSanityClient,
- query: string,
- params?: QueryParams
- ): Observable<MutationEvent_2<R>>
- /**
- * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
- *
- * @param query - GROQ-filter to listen to changes for
- * @param params - Optional query parameters
- * @param options - Listener options
- * @internal
- */
- export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
- this: SanityClient | ObservableSanityClient,
- query: string,
- params?: QueryParams,
- options?: ListenOptions
- ): Observable<ListenEvent<R>>
- /** @public */
- export declare type ListenEvent<R extends Record<string, Any>> =
- | MutationEvent_2<R>
- | ChannelErrorEvent
- | DisconnectEvent
- | ReconnectEvent
- | WelcomeEvent
- /** @public */
- export declare type ListenEventName = 'mutation' | 'welcome' | 'reconnect'
- /** @public */
- export declare interface ListenOptions {
- includeResult?: boolean
- includePreviousRevision?: boolean
- visibility?: 'sync' | 'async' | 'query'
- events?: ListenEventName[]
- effectFormat?: 'mendoza'
- tag?: string
- }
- /** @internal */
- export declare interface MultipleMutationResult {
- transactionId: string
- documentIds: string[]
- results: {
- id: string
- operation: MutationOperation
- }[]
- }
- /** @public */
- export declare type Mutation<R extends Record<string, Any> = Record<string, Any>> =
- | {
- create: SanityDocumentStub<R>
- }
- | {
- createOrReplace: IdentifiedSanityDocumentStub<R>
- }
- | {
- createIfNotExists: IdentifiedSanityDocumentStub<R>
- }
- | {
- delete: MutationSelection
- }
- | {
- patch: PatchMutationOperation
- }
- /** @internal */
- export declare interface MutationError {
- error: {
- type: 'mutationError'
- description: string
- items?: MutationErrorItem[]
- }
- }
- /** @internal */
- export declare interface MutationErrorItem {
- error: {
- type: string
- description: string
- value?: unknown
- }
- }
- /** @public */
- declare type MutationEvent_2<R extends Record<string, Any> = Record<string, Any>> = {
- type: 'mutation'
- documentId: string
- eventId: string
- identity: string
- mutations: Mutation[]
- previousRev?: string
- resultRev?: string
- result?: SanityDocument<R>
- previous?: SanityDocument<R> | null
- effects?: {
- apply: unknown[]
- revert: unknown[]
- }
- timestamp: string
- transactionId: string
- transition: 'update' | 'appear' | 'disappear'
- visibility: 'query' | 'transaction'
- }
- export {MutationEvent_2 as MutationEvent}
- /** @internal */
- export declare type MutationOperation = 'create' | 'delete' | 'update' | 'none'
- /** @internal */
- export declare type MutationSelection =
- | {
- query: string
- params?: QueryParams
- }
- | {
- id: string | string[]
- }
- /** @internal */
- export declare class ObservableAssetsClient {
- #private
- constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
- /**
- * Uploads a file asset to the configured dataset
- *
- * @param assetType - Asset type (file)
- * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
- * @param options - Options to use for the upload
- */
- upload(
- assetType: 'file',
- body: UploadBody,
- options?: UploadClientConfig
- ): Observable<
- HttpRequestEvent<{
- document: SanityAssetDocument
- }>
- >
- /**
- * Uploads an image asset to the configured dataset
- *
- * @param assetType - Asset type (image)
- * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
- * @param options - Options to use for the upload
- */
- upload(
- assetType: 'image',
- body: UploadBody,
- options?: UploadClientConfig
- ): Observable<
- HttpRequestEvent<{
- document: SanityImageAssetDocument
- }>
- >
- /**
- * Uploads a file or an image asset to the configured dataset
- *
- * @param assetType - Asset type (file/image)
- * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
- * @param options - Options to use for the upload
- */
- upload(
- assetType: 'file' | 'image',
- body: UploadBody,
- options?: UploadClientConfig
- ): Observable<
- HttpRequestEvent<{
- document: SanityAssetDocument | SanityImageAssetDocument
- }>
- >
- }
- /** @internal */
- export declare class ObservableDatasetsClient {
- #private
- constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
- /**
- * Create a new dataset with the given name
- *
- * @param name - Name of the dataset to create
- * @param options - Options for the dataset
- */
- create(
- name: string,
- options?: {
- aclMode?: DatasetAclMode
- }
- ): Observable<DatasetResponse>
- /**
- * Edit a dataset with the given name
- *
- * @param name - Name of the dataset to edit
- * @param options - New options for the dataset
- */
- edit(
- name: string,
- options?: {
- aclMode?: DatasetAclMode
- }
- ): Observable<DatasetResponse>
- /**
- * Delete a dataset with the given name
- *
- * @param name - Name of the dataset to delete
- */
- delete(name: string): Observable<{
- deleted: true
- }>
- /**
- * Fetch a list of datasets for the configured project
- */
- list(): Observable<DatasetsResponse>
- }
- /** @public */
- export declare class ObservablePatch extends BasePatch {
- #private
- constructor(
- selection: PatchSelection,
- operations?: PatchOperations,
- client?: ObservableSanityClient
- )
- /**
- * Clones the patch
- */
- clone(): ObservablePatch
- /**
- * Commit the patch, returning an observable that produces the first patched document
- *
- * @param options - Options for the mutation operation
- */
- commit<R extends Record<string, Any> = Record<string, Any>>(
- options: FirstDocumentMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Commit the patch, returning an observable that produces an array of the mutated documents
- *
- * @param options - Options for the mutation operation
- */
- commit<R extends Record<string, Any> = Record<string, Any>>(
- options: AllDocumentsMutationOptions
- ): Observable<SanityDocument<R>[]>
- /**
- * Commit the patch, returning an observable that produces a mutation result object
- *
- * @param options - Options for the mutation operation
- */
- commit(options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
- /**
- * Commit the patch, returning an observable that produces a mutation result object
- *
- * @param options - Options for the mutation operation
- */
- commit(options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
- /**
- * Commit the patch, returning an observable that produces the first patched document
- *
- * @param options - Options for the mutation operation
- */
- commit<R extends Record<string, Any> = Record<string, Any>>(
- options?: BaseMutationOptions
- ): Observable<SanityDocument<R>>
- }
- /** @public */
- export declare type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch
- /** @internal */
- export declare class ObservableProjectsClient {
- #private
- constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
- /**
- * Fetch a list of projects the authenticated user has access to
- */
- list(): Observable<SanityProject[]>
- /**
- * Fetch a project by project ID
- *
- * @param projectId - ID of the project to fetch
- */
- getById(projectId: string): Observable<SanityProject>
- }
- /** @public */
- export declare class ObservableSanityClient {
- #private
- assets: ObservableAssetsClient
- datasets: ObservableDatasetsClient
- projects: ObservableProjectsClient
- users: ObservableUsersClient
- /**
- * Instance properties
- */
- listen: typeof _listen
- constructor(httpRequest: HttpRequest, config?: ClientConfig)
- /**
- * Clone the client - returns a new instance
- */
- clone(): ObservableSanityClient
- /**
- * Returns the current client configuration
- */
- config(): InitializedClientConfig
- /**
- * Reconfigure the client. Note that this _mutates_ the current client.
- */
- config(newConfig?: Partial<ClientConfig>): this
- /**
- * Clone the client with a new (partial) configuration.
- *
- * @param newConfig - New client configuration properties, shallowly merged with existing configuration
- */
- withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
- /**
- * Perform a GROQ-query against the configured dataset.
- *
- * @param query - GROQ-query to perform
- */
- fetch<R = Any>(query: string): Observable<R>
- /**
- * Perform a GROQ-query against the configured dataset.
- *
- * @param query - GROQ-query to perform
- * @param params - Query parameters
- */
- fetch<R = Any, Q = QueryParams>(query: string, params: Q): Observable<R>
- /**
- * Perform a GROQ-query against the configured dataset.
- *
- * @param query - GROQ-query to perform
- * @param params - Query parameters
- * @param options - Request options
- */
- fetch<R = Any, Q = QueryParams>(
- query: string,
- params: Q | undefined,
- options: FilteredResponseQueryOptions
- ): Observable<R>
- /**
- * Perform a GROQ-query against the configured dataset.
- *
- * @param query - GROQ-query to perform
- * @param params - Query parameters
- * @param options - Request options
- */
- fetch<R = Any, Q = QueryParams>(
- query: string,
- params: Q | undefined,
- options: UnfilteredResponseQueryOptions
- ): Observable<RawQueryResponse<R>>
- /**
- * Fetch a single document with the given ID.
- *
- * @param id - Document ID to fetch
- * @param options - Request options
- */
- getDocument<R extends Record<string, Any> = Record<string, Any>>(
- id: string,
- options?: {
- tag?: string
- }
- ): Observable<SanityDocument<R> | undefined>
- /**
- * Fetch multiple documents in one request.
- * Should be used sparingly - performing a query is usually a better option.
- * The order/position of documents is preserved based on the original array of IDs.
- * If any of the documents are missing, they will be replaced by a `null` entry in the returned array
- *
- * @param ids - Document IDs to fetch
- * @param options - Request options
- */
- getDocuments<R extends Record<string, Any> = Record<string, Any>>(
- ids: string[],
- options?: {
- tag?: string
- }
- ): Observable<(SanityDocument<R> | null)[]>
- /**
- * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
- * Returns an observable that resolves to the created document.
- *
- * @param document - Document to create
- * @param options - Mutation options
- */
- create<R extends Record<string, Any> = Record<string, Any>>(
- document: SanityDocumentStub<R>,
- options: FirstDocumentMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
- * Returns an observable that resolves to an array containing the created document.
- *
- * @param document - Document to create
- * @param options - Mutation options
- */
- create<R extends Record<string, Any> = Record<string, Any>>(
- document: SanityDocumentStub<R>,
- options: AllDocumentsMutationOptions
- ): Observable<SanityDocument<R>[]>
- /**
- * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
- * Returns an observable that resolves to a mutation result object containing the ID of the created document.
- *
- * @param document - Document to create
- * @param options - Mutation options
- */
- create<R extends Record<string, Any> = Record<string, Any>>(
- document: SanityDocumentStub<R>,
- options: FirstDocumentIdMutationOptions
- ): Observable<SingleMutationResult>
- /**
- * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
- * Returns an observable that resolves to a mutation result object containing the ID of the created document.
- *
- * @param document - Document to create
- * @param options - Mutation options
- */
- create<R extends Record<string, Any> = Record<string, Any>>(
- document: SanityDocumentStub<R>,
- options: AllDocumentIdsMutationOptions
- ): Observable<MultipleMutationResult>
- /**
- * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
- * Returns an observable that resolves to the created document.
- *
- * @param document - Document to create
- * @param options - Mutation options
- */
- create<R extends Record<string, Any> = Record<string, Any>>(
- document: SanityDocumentStub<R>,
- options?: BaseMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Create a document if no document with the same ID already exists.
- * Returns an observable that resolves to the created document.
- *
- * @param document - Document to create
- * @param options - Mutation options
- */
- createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: FirstDocumentMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Create a document if no document with the same ID already exists.
- * Returns an observable that resolves to an array containing the created document.
- *
- * @param document - Document to create
- * @param options - Mutation options
- */
- createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: AllDocumentsMutationOptions
- ): Observable<SanityDocument<R>[]>
- /**
- * Create a document if no document with the same ID already exists.
- * Returns an observable that resolves to a mutation result object containing the ID of the created document.
- *
- * @param document - Document to create
- * @param options - Mutation options
- */
- createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: FirstDocumentIdMutationOptions
- ): Observable<SingleMutationResult>
- /**
- * Create a document if no document with the same ID already exists.
- * Returns an observable that resolves to a mutation result object containing the ID of the created document.
- *
- * @param document - Document to create
- * @param options - Mutation options
- */
- createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: AllDocumentIdsMutationOptions
- ): Observable<MultipleMutationResult>
- /**
- * Create a document if no document with the same ID already exists.
- * Returns an observable that resolves to the created document.
- *
- * @param document - Document to create
- * @param options - Mutation options
- */
- createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options?: BaseMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Create a document if it does not exist, or replace a document with the same document ID
- * Returns an observable that resolves to the created document.
- *
- * @param document - Document to either create or replace
- * @param options - Mutation options
- */
- createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: FirstDocumentMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Create a document if it does not exist, or replace a document with the same document ID
- * Returns an observable that resolves to an array containing the created document.
- *
- * @param document - Document to either create or replace
- * @param options - Mutation options
- */
- createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: AllDocumentsMutationOptions
- ): Observable<SanityDocument<R>[]>
- /**
- * Create a document if it does not exist, or replace a document with the same document ID
- * Returns an observable that resolves to a mutation result object containing the ID of the created document.
- *
- * @param document - Document to either create or replace
- * @param options - Mutation options
- */
- createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: FirstDocumentIdMutationOptions
- ): Observable<SingleMutationResult>
- /**
- * Create a document if it does not exist, or replace a document with the same document ID
- * Returns an observable that resolves to a mutation result object containing the created document ID.
- *
- * @param document - Document to either create or replace
- * @param options - Mutation options
- */
- createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: AllDocumentIdsMutationOptions
- ): Observable<MultipleMutationResult>
- /**
- * Create a document if it does not exist, or replace a document with the same document ID
- * Returns an observable that resolves to the created document.
- *
- * @param document - Document to either create or replace
- * @param options - Mutation options
- */
- createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options?: BaseMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Deletes a document with the given document ID.
- * Returns an observable that resolves to the deleted document.
- *
- * @param id - Document ID to delete
- * @param options - Options for the mutation
- */
- delete<R extends Record<string, Any> = Record<string, Any>>(
- id: string,
- options: FirstDocumentMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Deletes a document with the given document ID.
- * Returns an observable that resolves to an array containing the deleted document.
- *
- * @param id - Document ID to delete
- * @param options - Options for the mutation
- */
- delete<R extends Record<string, Any> = Record<string, Any>>(
- id: string,
- options: AllDocumentsMutationOptions
- ): Observable<SanityDocument<R>[]>
- /**
- * Deletes a document with the given document ID.
- * Returns an observable that resolves to a mutation result object containing the deleted document ID.
- *
- * @param id - Document ID to delete
- * @param options - Options for the mutation
- */
- delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
- /**
- * Deletes a document with the given document ID.
- * Returns an observable that resolves to a mutation result object containing the deleted document ID.
- *
- * @param id - Document ID to delete
- * @param options - Options for the mutation
- */
- delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
- /**
- * Deletes a document with the given document ID.
- * Returns an observable that resolves to the deleted document.
- *
- * @param id - Document ID to delete
- * @param options - Options for the mutation
- */
- delete<R extends Record<string, Any> = Record<string, Any>>(
- id: string,
- options?: BaseMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Deletes one or more documents matching the given query or document ID.
- * Returns an observable that resolves to first deleted document.
- *
- * @param selection - An object with either an `id` or `query` key defining what to delete
- * @param options - Options for the mutation
- */
- delete<R extends Record<string, Any> = Record<string, Any>>(
- selection: MutationSelection,
- options: FirstDocumentMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Deletes one or more documents matching the given query or document ID.
- * Returns an observable that resolves to an array containing the deleted documents.
- *
- * @param selection - An object with either an `id` or `query` key defining what to delete
- * @param options - Options for the mutation
- */
- delete<R extends Record<string, Any> = Record<string, Any>>(
- selection: MutationSelection,
- options: AllDocumentsMutationOptions
- ): Observable<SanityDocument<R>[]>
- /**
- * Deletes one or more documents matching the given query or document ID.
- * Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
- *
- * @param selection - An object with either an `id` or `query` key defining what to delete
- * @param options - Options for the mutation
- */
- delete(
- selection: MutationSelection,
- options: FirstDocumentIdMutationOptions
- ): Observable<SingleMutationResult>
- /**
- * Deletes one or more documents matching the given query or document ID.
- * Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
- *
- * @param selection - An object with either an `id` or `query` key defining what to delete
- * @param options - Options for the mutation
- */
- delete(
- selection: MutationSelection,
- options: AllDocumentIdsMutationOptions
- ): Observable<MultipleMutationResult>
- /**
- * Deletes one or more documents matching the given query or document ID.
- * Returns an observable that resolves to first deleted document.
- *
- * @param selection - An object with either an `id` or `query` key defining what to delete
- * @param options - Options for the mutation
- */
- delete<R extends Record<string, Any> = Record<string, Any>>(
- selection: MutationSelection,
- options?: BaseMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Perform mutation operations against the configured dataset
- * Returns an observable that resolves to the first mutated document.
- *
- * @param operations - Mutation operations to execute
- * @param options - Mutation options
- */
- mutate<R extends Record<string, Any> = Record<string, Any>>(
- operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
- options: FirstDocumentMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Perform mutation operations against the configured dataset.
- * Returns an observable that resolves to an array of the mutated documents.
- *
- * @param operations - Mutation operations to execute
- * @param options - Mutation options
- */
- mutate<R extends Record<string, Any> = Record<string, Any>>(
- operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
- options: AllDocumentsMutationOptions
- ): Observable<SanityDocument<R>[]>
- /**
- * Perform mutation operations against the configured dataset
- * Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
- *
- * @param operations - Mutation operations to execute
- * @param options - Mutation options
- */
- mutate<R extends Record<string, Any> = Record<string, Any>>(
- operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
- options: FirstDocumentIdMutationOptions
- ): Observable<SingleMutationResult>
- /**
- * Perform mutation operations against the configured dataset
- * Returns an observable that resolves to a mutation result object containing the mutated document IDs.
- *
- * @param operations - Mutation operations to execute
- * @param options - Mutation options
- */
- mutate<R extends Record<string, Any> = Record<string, Any>>(
- operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
- options: AllDocumentIdsMutationOptions
- ): Observable<MultipleMutationResult>
- /**
- * Perform mutation operations against the configured dataset
- * Returns an observable that resolves to the first mutated document.
- *
- * @param operations - Mutation operations to execute
- * @param options - Mutation options
- */
- mutate<R extends Record<string, Any> = Record<string, Any>>(
- operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
- options?: BaseMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Create a new buildable patch of operations to perform
- *
- * @param documentId - Document ID(s) to patch
- * @param operations - Optional object of patch operations to initialize the patch instance with
- */
- patch(documentId: PatchSelection, operations?: PatchOperations): ObservablePatch
- /**
- * Create a new transaction of mutations
- *
- * @param operations - Optional array of mutation operations to initialize the transaction instance with
- */
- transaction<R extends Record<string, Any> = Record<string, Any>>(
- operations?: Mutation<R>[]
- ): ObservableTransaction
- /**
- * DEPRECATED: Perform an HTTP request against the Sanity API
- *
- * @deprecated Use your own request library!
- * @param options - Request options
- */
- request<R = Any>(options: RawRequestOptions): Observable<R>
- /**
- * Get a Sanity API URL for the URI provided
- *
- * @param uri - URI/path to build URL for
- * @param canUseCdn - Whether or not to allow using the API CDN for this route
- */
- getUrl(uri: string, canUseCdn?: boolean): string
- /**
- * Get a Sanity API URL for the data operation and path provided
- *
- * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
- * @param path - Path to append after the operation
- */
- getDataUrl(operation: string, path?: string): string
- }
- /** @public */
- export declare class ObservableTransaction extends BaseTransaction {
- #private
- constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
- /**
- * Clones the transaction
- */
- clone(): ObservableTransaction
- /**
- * Commit the transaction, returning an observable that produces the first mutated document
- *
- * @param options - Options for the mutation operation
- */
- commit<R extends Record<string, Any>>(
- options: TransactionFirstDocumentMutationOptions
- ): Observable<SanityDocument<R>>
- /**
- * Commit the transaction, returning an observable that produces an array of the mutated documents
- *
- * @param options - Options for the mutation operation
- */
- commit<R extends Record<string, Any>>(
- options: TransactionAllDocumentsMutationOptions
- ): Observable<SanityDocument<R>[]>
- /**
- * Commit the transaction, returning an observable that produces a mutation result object
- *
- * @param options - Options for the mutation operation
- */
- commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
- /**
- * Commit the transaction, returning an observable that produces a mutation result object
- *
- * @param options - Options for the mutation operation
- */
- commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
- /**
- * Commit the transaction, returning an observable that produces a mutation result object
- *
- * @param options - Options for the mutation operation
- */
- commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
- /**
- * Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
- * The operation is added to the current transaction, ready to be commited by `commit()`
- *
- * @param documentId - Document ID to perform the patch operation on
- * @param patchOps - Operations to perform, or a builder function
- */
- patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this
- /**
- * Adds the given patch instance to the transaction.
- * The operation is added to the current transaction, ready to be commited by `commit()`
- *
- * @param patch - ObservablePatch to execute
- */
- patch(patch: ObservablePatch): this
- }
- /** @public */
- export declare class ObservableUsersClient {
- #private
- constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
- /**
- * Fetch a user by user ID
- *
- * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
- */
- getById<T extends 'me' | string>(
- id: T
- ): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
- }
- /** @public */
- export declare class Patch extends BasePatch {
- #private
- constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
- /**
- * Clones the patch
- */
- clone(): Patch
- /**
- * Commit the patch, returning a promise that resolves to the first patched document
- *
- * @param options - Options for the mutation operation
- */
- commit<R extends Record<string, Any> = Record<string, Any>>(
- options: FirstDocumentMutationOptions
- ): Promise<SanityDocument<R>>
- /**
- * Commit the patch, returning a promise that resolves to an array of the mutated documents
- *
- * @param options - Options for the mutation operation
- */
- commit<R extends Record<string, Any> = Record<string, Any>>(
- options: AllDocumentsMutationOptions
- ): Promise<SanityDocument<R>[]>
- /**
- * Commit the patch, returning a promise that resolves to a mutation result object
- *
- * @param options - Options for the mutation operation
- */
- commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
- /**
- * Commit the patch, returning a promise that resolves to a mutation result object
- *
- * @param options - Options for the mutation operation
- */
- commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
- /**
- * Commit the patch, returning a promise that resolves to the first patched document
- *
- * @param options - Options for the mutation operation
- */
- commit<R extends Record<string, Any> = Record<string, Any>>(
- options?: BaseMutationOptions
- ): Promise<SanityDocument<R>>
- }
- /** @public */
- export declare type PatchBuilder = (patch: Patch) => Patch
- /** @internal */
- export declare type PatchMutationOperation = PatchOperations & MutationSelection
- /** @internal */
- export declare interface PatchOperations {
- set?: {
- [key: string]: Any
- }
- setIfMissing?: {
- [key: string]: Any
- }
- diffMatchPatch?: {
- [key: string]: Any
- }
- unset?: string[]
- inc?: {
- [key: string]: number
- }
- dec?: {
- [key: string]: number
- }
- insert?: InsertPatch
- ifRevisionID?: string
- }
- export declare type PatchSelection = string | string[] | MutationSelection
- declare interface ProgressEvent_2 {
- type: 'progress'
- stage: 'upload' | 'download'
- percent: number
- total?: number
- loaded?: number
- lengthComputable: boolean
- }
- export {ProgressEvent_2 as ProgressEvent}
- export declare class ProjectsClient {
- #private
- constructor(client: SanityClient, httpRequest: HttpRequest)
- /**
- * Fetch a list of projects the authenticated user has access to
- */
- list(): Promise<SanityProject[]>
- /**
- * Fetch a project by project ID
- *
- * @param projectId - ID of the project to fetch
- */
- getById(projectId: string): Promise<SanityProject>
- }
- /** @public */
- export declare type QueryParams = {
- [key: string]: Any
- }
- export declare interface RawQueryResponse<R> {
- q: string
- ms: number
- result: R
- }
- export declare interface RawRequestOptions {
- url?: string
- uri?: string
- method?: string
- token?: string
- json?: boolean
- tag?: string
- useGlobalApi?: boolean
- withCredentials?: boolean
- query?: {
- [key: string]: string | string[]
- }
- headers?: {
- [key: string]: string
- }
- timeout?: number
- proxy?: string
- body?: Any
- maxRedirects?: number
- }
- export declare type ReconnectEvent = {
- type: 'reconnect'
- }
- export declare const requester: Requester
- export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
- url?: string
- uri?: string
- canUseCdn?: boolean
- tag?: string
- }
- export declare interface RequestOptions {
- timeout?: number
- token?: string
- tag?: string
- headers?: Record<string, string>
- method?: string
- query?: Any
- body?: Any
- signal?: AbortSignal
- }
- export declare interface ResponseEvent<T = unknown> {
- type: 'response'
- body: T
- url: string
- method: string
- statusCode: number
- statusMessage?: string
- headers: Record<string, string>
- }
- export declare interface SanityAssetDocument extends SanityDocument {
- url: string
- path: string
- size: number
- assetId: string
- mimeType: string
- sha1hash: string
- extension: string
- uploadId?: string
- originalFilename?: string
- }
- export declare class SanityClient {
- #private
- assets: AssetsClient
- datasets: DatasetsClient
- projects: ProjectsClient
- users: UsersClient
-
- observable: ObservableSanityClient
-
- listen: typeof _listen
- constructor(httpRequest: HttpRequest, config?: ClientConfig)
- /**
- * Clone the client - returns a new instance
- */
- clone(): SanityClient
- /**
- * Returns the current client configuration
- */
- config(): InitializedClientConfig
- /**
- * Reconfigure the client. Note that this _mutates_ the current client.
- */
- config(newConfig?: Partial<ClientConfig>): this
- /**
- * Clone the client with a new (partial) configuration.
- *
- * @param newConfig - New client configuration properties, shallowly merged with existing configuration
- */
- withConfig(newConfig?: Partial<ClientConfig>): SanityClient
- /**
- * Perform a GROQ-query against the configured dataset.
- *
- * @param query - GROQ-query to perform
- */
- fetch<R = Any>(query: string): Promise<R>
- /**
- * Perform a GROQ-query against the configured dataset.
- *
- * @param query - GROQ-query to perform
- * @param params - Optional query parameters
- */
- fetch<R = Any, Q = QueryParams>(query: string, params: Q): Promise<R>
- /**
- * Perform a GROQ-query against the configured dataset.
- *
- * @param query - GROQ-query to perform
- * @param params - Optional query parameters
- * @param options - Request options
- */
- fetch<R = Any, Q = QueryParams>(
- query: string,
- params: Q | undefined,
- options: FilteredResponseQueryOptions
- ): Promise<R>
- /**
- * Perform a GROQ-query against the configured dataset.
- *
- * @param query - GROQ-query to perform
- * @param params - Optional query parameters
- * @param options - Request options
- */
- fetch<R = Any, Q = QueryParams>(
- query: string,
- params: Q | undefined,
- options: UnfilteredResponseQueryOptions
- ): Promise<RawQueryResponse<R>>
- /**
- * Fetch a single document with the given ID.
- *
- * @param id - Document ID to fetch
- * @param options - Request options
- */
- getDocument<R extends Record<string, Any> = Record<string, Any>>(
- id: string,
- options?: {
- tag?: string
- }
- ): Promise<SanityDocument<R> | undefined>
-
- getDocuments<R extends Record<string, Any> = Record<string, Any>>(
- ids: string[],
- options?: {
- tag?: string
- }
- ): Promise<(SanityDocument<R> | null)[]>
-
- create<R extends Record<string, Any> = Record<string, Any>>(
- document: SanityDocumentStub<R>,
- options: FirstDocumentMutationOptions
- ): Promise<SanityDocument<R>>
-
- create<R extends Record<string, Any> = Record<string, Any>>(
- document: SanityDocumentStub<R>,
- options: AllDocumentsMutationOptions
- ): Promise<SanityDocument<R>[]>
-
- create<R extends Record<string, Any> = Record<string, Any>>(
- document: SanityDocumentStub<R>,
- options: FirstDocumentIdMutationOptions
- ): Promise<SingleMutationResult>
-
- create<R extends Record<string, Any> = Record<string, Any>>(
- document: SanityDocumentStub<R>,
- options: AllDocumentIdsMutationOptions
- ): Promise<MultipleMutationResult>
-
- create<R extends Record<string, Any> = Record<string, Any>>(
- document: SanityDocumentStub<R>,
- options?: BaseMutationOptions
- ): Promise<SanityDocument<R>>
-
- createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: FirstDocumentMutationOptions
- ): Promise<SanityDocument<R>>
-
- createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: AllDocumentsMutationOptions
- ): Promise<SanityDocument<R>[]>
-
- createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: FirstDocumentIdMutationOptions
- ): Promise<SingleMutationResult>
-
- createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: AllDocumentIdsMutationOptions
- ): Promise<MultipleMutationResult>
-
- createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options?: BaseMutationOptions
- ): Promise<SanityDocument<R>>
-
- createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: FirstDocumentMutationOptions
- ): Promise<SanityDocument<R>>
-
- createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: AllDocumentsMutationOptions
- ): Promise<SanityDocument<R>[]>
-
- createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: FirstDocumentIdMutationOptions
- ): Promise<SingleMutationResult>
-
- createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options: AllDocumentIdsMutationOptions
- ): Promise<MultipleMutationResult>
-
- createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
- document: IdentifiedSanityDocumentStub<R>,
- options?: BaseMutationOptions
- ): Promise<SanityDocument<R>>
-
- delete<R extends Record<string, Any> = Record<string, Any>>(
- id: string,
- options: FirstDocumentMutationOptions
- ): Promise<SanityDocument<R>>
-
- delete<R extends Record<string, Any> = Record<string, Any>>(
- id: string,
- options: AllDocumentsMutationOptions
- ): Promise<SanityDocument<R>[]>
-
- delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
-
- delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
-
- delete<R extends Record<string, Any> = Record<string, Any>>(
- id: string,
- options?: BaseMutationOptions
- ): Promise<SanityDocument<R>>
-
- delete<R extends Record<string, Any> = Record<string, Any>>(
- selection: MutationSelection,
- options: FirstDocumentMutationOptions
- ): Promise<SanityDocument<R>>
-
- delete<R extends Record<string, Any> = Record<string, Any>>(
- selection: MutationSelection,
- options: AllDocumentsMutationOptions
- ): Promise<SanityDocument<R>[]>
-
- delete(
- selection: MutationSelection,
- options: FirstDocumentIdMutationOptions
- ): Promise<SingleMutationResult>
-
- delete(
- selection: MutationSelection,
- options: AllDocumentIdsMutationOptions
- ): Promise<MultipleMutationResult>
-
- delete<R extends Record<string, Any> = Record<string, Any>>(
- selection: MutationSelection,
- options?: BaseMutationOptions
- ): Promise<SanityDocument<R>>
-
- mutate<R extends Record<string, Any> = Record<string, Any>>(
- operations: Mutation<R>[] | Patch | Transaction,
- options: FirstDocumentMutationOptions
- ): Promise<SanityDocument<R>>
-
- mutate<R extends Record<string, Any> = Record<string, Any>>(
- operations: Mutation<R>[] | Patch | Transaction,
- options: AllDocumentsMutationOptions
- ): Promise<SanityDocument<R>[]>
-
- mutate<R extends Record<string, Any> = Record<string, Any>>(
- operations: Mutation<R>[] | Patch | Transaction,
- options: FirstDocumentIdMutationOptions
- ): Promise<SingleMutationResult>
-
- mutate<R extends Record<string, Any>>(
- operations: Mutation<R>[] | Patch | Transaction,
- options: AllDocumentIdsMutationOptions
- ): Promise<MultipleMutationResult>
-
- mutate<R extends Record<string, Any> = Record<string, Any>>(
- operations: Mutation<R>[] | Patch | Transaction,
- options?: BaseMutationOptions
- ): Promise<SanityDocument<R>>
-
- patch(documentId: PatchSelection, operations?: PatchOperations): Patch
-
- transaction<R extends Record<string, Any> = Record<string, Any>>(
- operations?: Mutation<R>[]
- ): Transaction
-
- request<R = Any>(options: RawRequestOptions): Promise<R>
-
- dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
-
- getUrl(uri: string, canUseCdn?: boolean): string
-
- getDataUrl(operation: string, path?: string): string
- }
- export declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = {
- [P in keyof T]: T[P]
- } & {
- _id: string
- _rev: string
- _type: string
- _createdAt: string
- _updatedAt: string
- }
- export declare type SanityDocumentStub<T extends Record<string, Any> = Record<string, Any>> = {
- [P in keyof T]: T[P]
- } & {
- _type: string
- }
- export declare interface SanityImageAssetDocument extends SanityAssetDocument {
- metadata: {
- _type: 'sanity.imageMetadata'
- hasAlpha: boolean
- isOpaque: boolean
- lqip?: string
- blurHash?: string
- dimensions: {
- _type: 'sanity.imageDimensions'
- aspectRatio: number
- height: number
- width: number
- }
- palette?: {
- _type: 'sanity.imagePalette'
- darkMuted?: SanityImagePalette
- darkVibrant?: SanityImagePalette
- dominant?: SanityImagePalette
- lightMuted?: SanityImagePalette
- lightVibrant?: SanityImagePalette
- muted?: SanityImagePalette
- vibrant?: SanityImagePalette
- }
- image?: {
- _type: 'sanity.imageExifTags'
- [key: string]: Any
- }
- exif?: {
- _type: 'sanity.imageExifMetadata'
- [key: string]: Any
- }
- }
- }
- export declare interface SanityImagePalette {
- background: string
- foreground: string
- population: number
- title: string
- }
- export declare interface SanityProject {
- id: string
- displayName: string
- studioHost: string | null
- organizationId: string | null
- isBlocked: boolean
- isDisabled: boolean
- isDisabledByUser: boolean
- createdAt: string
- pendingInvites?: number
- maxRetentionDays?: number
- members: SanityProjectMember[]
- metadata: {
- color?: string
- externalStudioHost?: string
- }
- }
- export declare interface SanityProjectMember {
- id: string
- role: string
- isRobot: boolean
- isCurrentUser: boolean
- }
- export declare interface SanityReference {
- _ref: string
- }
- export declare interface SanityUser {
- id: string
- projectId: string
- displayName: string
- familyName: string | null
- givenName: string | null
- middleName: string | null
- imageUrl: string | null
- createdAt: string
- updatedAt: string
- isCurrentUser: boolean
- }
- export declare class ServerError extends Error {
- response: ErrorProps['response']
- statusCode: ErrorProps['statusCode']
- responseBody: ErrorProps['responseBody']
- details: ErrorProps['details']
- constructor(res: Any)
- }
- /** @internal */
- export declare interface SingleMutationResult {
- transactionId: string
- documentId: string
- results: {
- id: string
- operation: MutationOperation
- }[]
- }
- export declare class Transaction extends BaseTransaction {
- #private
- constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string)
- /**
- * Clones the transaction
- */
- clone(): Transaction
- /**
- * Commit the transaction, returning a promise that resolves to the first mutated document
- *
- * @param options - Options for the mutation operation
- */
- commit<R extends Record<string, Any>>(
- options: TransactionFirstDocumentMutationOptions
- ): Promise<SanityDocument<R>>
- /**
- * Commit the transaction, returning a promise that resolves to an array of the mutated documents
- *
- * @param options - Options for the mutation operation
- */
- commit<R extends Record<string, Any>>(
- options: TransactionAllDocumentsMutationOptions
- ): Promise<SanityDocument<R>[]>
- /**
- * Commit the transaction, returning a promise that resolves to a mutation result object
- *
- * @param options - Options for the mutation operation
- */
- commit(options: TransactionFirstDocumentIdMutationOptions): Promise<SingleMutationResult>
- /**
- * Commit the transaction, returning a promise that resolves to a mutation result object
- *
- * @param options - Options for the mutation operation
- */
- commit(options: TransactionAllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
- /**
- * Commit the transaction, returning a promise that resolves to a mutation result object
- *
- * @param options - Options for the mutation operation
- */
- commit(options?: BaseMutationOptions): Promise<MultipleMutationResult>
- /**
- * Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
- * The operation is added to the current transaction, ready to be commited by `commit()`
- *
- * @param documentId - Document ID to perform the patch operation on
- * @param patchOps - Operations to perform, or a builder function
- */
- patch(documentId: string, patchOps?: PatchBuilder | PatchOperations): this
- /**
- * Adds the given patch instance to the transaction.
- * The operation is added to the current transaction, ready to be commited by `commit()`
- *
- * @param patch - Patch to execute
- */
- patch(patch: Patch): this
- }
- /** @internal */
- export declare type TransactionAllDocumentIdsMutationOptions = BaseMutationOptions & {
- returnFirst?: false
- returnDocuments?: false
- }
- export declare type TransactionAllDocumentsMutationOptions = BaseMutationOptions & {
- returnFirst?: false
- returnDocuments: true
- }
- export declare type TransactionFirstDocumentIdMutationOptions = BaseMutationOptions & {
- returnFirst: true
- returnDocuments?: false
- }
- export declare type TransactionFirstDocumentMutationOptions = BaseMutationOptions & {
- returnFirst: true
- returnDocuments: true
- }
- export declare type TransactionMutationOptions =
- | TransactionFirstDocumentMutationOptions
- | TransactionFirstDocumentIdMutationOptions
- | TransactionAllDocumentsMutationOptions
- | TransactionAllDocumentIdsMutationOptions
- export declare type UnfilteredResponseQueryOptions = RequestOptions & {
- filterResponse: false
- }
- export {unstable__adapter}
- export {unstable__environment}
- export declare type UploadBody = File | Blob | Buffer | NodeJS.ReadableStream
- export declare interface UploadClientConfig {
-
- tag?: string
-
- preserveFilename?: boolean
-
- filename?: string
-
- timeout?: number
-
- contentType?: string
-
- extract?: AssetMetadataType[]
-
- label?: string
-
- title?: string
-
- description?: string
-
- creditLine?: string
-
- source?: {
-
- id: string
-
- name: string
-
- url?: string
- }
- }
- export declare class UsersClient {
- #private
- constructor(client: SanityClient, httpRequest: HttpRequest)
- /**
- * Fetch a user by user ID
- *
- * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
- */
- getById<T extends 'me' | string>(id: T): Promise<T extends 'me' ? CurrentSanityUser : SanityUser>
- }
- /** @public */
- export declare type WelcomeEvent = {
- type: 'welcome'
- }
- export {}
|