@sanity/sdk-react 0.0.0-alpha.22 → 0.0.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +499 -3459
- package/dist/index.js +401 -465
- package/dist/index.js.map +1 -1
- package/package.json +18 -16
- package/src/_exports/index.ts +5 -6
- package/src/components/SDKProvider.test.tsx +78 -54
- package/src/components/SDKProvider.tsx +31 -26
- package/src/components/SanityApp.test.tsx +121 -15
- package/src/components/SanityApp.tsx +26 -15
- package/src/components/auth/AuthBoundary.test.tsx +32 -14
- package/src/components/auth/AuthBoundary.tsx +53 -23
- package/src/components/auth/LoginCallback.test.tsx +19 -6
- package/src/components/auth/LoginCallback.tsx +2 -11
- package/src/components/auth/LoginError.test.tsx +12 -4
- package/src/components/auth/LoginError.tsx +13 -21
- package/src/components/auth/LoginFooter.test.tsx +7 -3
- package/src/context/ResourceProvider.test.tsx +157 -0
- package/src/context/ResourceProvider.tsx +111 -0
- package/src/context/SanityInstanceContext.ts +1 -1
- package/src/hooks/auth/useLoginUrl.tsx +14 -0
- package/src/hooks/client/useClient.ts +2 -1
- package/src/hooks/comlink/useManageFavorite.test.ts +16 -8
- package/src/hooks/comlink/useManageFavorite.ts +37 -13
- package/src/hooks/comlink/useRecordDocumentHistoryEvent.test.ts +8 -4
- package/src/hooks/comlink/useRecordDocumentHistoryEvent.ts +10 -8
- package/src/hooks/context/useSanityInstance.test.tsx +157 -15
- package/src/hooks/context/useSanityInstance.ts +66 -26
- package/src/hooks/dashboard/useNavigateToStudioDocument.test.ts +13 -31
- package/src/hooks/dashboard/useNavigateToStudioDocument.ts +12 -15
- package/src/hooks/dashboard/{useStudioWorkspacesByResourceId.test.tsx → useStudioWorkspacesByProjectIdDataset.test.tsx} +13 -13
- package/src/hooks/dashboard/{useStudioWorkspacesByResourceId.ts → useStudioWorkspacesByProjectIdDataset.ts} +10 -9
- package/src/hooks/datasets/useDatasets.ts +15 -4
- package/src/hooks/document/useApplyDocumentActions.test.ts +4 -9
- package/src/hooks/document/useApplyDocumentActions.ts +6 -31
- package/src/hooks/document/useDocument.test.ts +2 -2
- package/src/hooks/document/useDocument.ts +40 -19
- package/src/hooks/document/useDocumentEvent.test.ts +2 -3
- package/src/hooks/document/useDocumentEvent.ts +7 -11
- package/src/hooks/document/useDocumentPermissions.test.ts +204 -0
- package/src/hooks/document/useDocumentPermissions.ts +31 -23
- package/src/hooks/document/useDocumentSyncStatus.ts +5 -4
- package/src/hooks/document/useEditDocument.test.ts +2 -3
- package/src/hooks/document/useEditDocument.ts +43 -29
- package/src/hooks/documents/useDocuments.test.tsx +30 -3
- package/src/hooks/documents/useDocuments.ts +20 -7
- package/src/hooks/helpers/createCallbackHook.test.tsx +2 -2
- package/src/hooks/helpers/createCallbackHook.tsx +2 -3
- package/src/hooks/helpers/createStateSourceHook.test.tsx +1 -1
- package/src/hooks/helpers/createStateSourceHook.tsx +5 -8
- package/src/hooks/paginatedDocuments/usePaginatedDocuments.test.tsx +43 -18
- package/src/hooks/paginatedDocuments/usePaginatedDocuments.ts +36 -50
- package/src/hooks/preview/usePreview.test.tsx +66 -7
- package/src/hooks/preview/usePreview.tsx +17 -12
- package/src/hooks/projection/useProjection.test.tsx +68 -3
- package/src/hooks/projection/useProjection.ts +21 -24
- package/src/hooks/projects/useProject.ts +7 -4
- package/src/hooks/query/useQuery.ts +32 -14
- package/src/hooks/users/useUsers.test.tsx +330 -0
- package/src/hooks/users/useUsers.ts +65 -52
- package/src/components/Login/LoginLinks.test.tsx +0 -90
- package/src/components/Login/LoginLinks.tsx +0 -58
- package/src/components/auth/Login.test.tsx +0 -27
- package/src/components/auth/Login.tsx +0 -39
- package/src/components/auth/LoginLayout.test.tsx +0 -19
- package/src/components/auth/LoginLayout.tsx +0 -69
- package/src/components/auth/authTestHelpers.tsx +0 -11
- package/src/context/SanityProvider.test.tsx +0 -25
- package/src/context/SanityProvider.tsx +0 -50
- package/src/hooks/auth/useLoginUrls.test.tsx +0 -68
- package/src/hooks/auth/useLoginUrls.tsx +0 -52
- package/src/hooks/users/useUsers.test.ts +0 -163
package/dist/index.d.ts
CHANGED
|
@@ -1,122 +1,36 @@
|
|
|
1
1
|
import {ActionsResult} from '@sanity/sdk'
|
|
2
2
|
import {ApplyDocumentActionsOptions} from '@sanity/sdk'
|
|
3
|
-
import {AuthProvider} from '@sanity/sdk'
|
|
4
3
|
import {AuthState} from '@sanity/sdk'
|
|
5
4
|
import {CanvasResource} from '@sanity/message-protocol'
|
|
6
5
|
import {ClientOptions} from '@sanity/sdk'
|
|
7
6
|
import {CurrentUser} from '@sanity/sdk'
|
|
7
|
+
import {DatasetHandle} from '@sanity/sdk'
|
|
8
8
|
import {DocumentAction} from '@sanity/sdk'
|
|
9
9
|
import {DocumentEvent} from '@sanity/sdk'
|
|
10
10
|
import {DocumentHandle} from '@sanity/sdk'
|
|
11
11
|
import {DocumentPermissionsResult} from '@sanity/sdk'
|
|
12
12
|
import {FallbackProps} from 'react-error-boundary'
|
|
13
13
|
import {FrameMessage} from '@sanity/sdk'
|
|
14
|
+
import {GetUsersOptions} from '@sanity/sdk'
|
|
14
15
|
import {JsonMatch} from '@sanity/sdk'
|
|
15
16
|
import {JsonMatchPath} from '@sanity/sdk'
|
|
16
17
|
import {MediaResource} from '@sanity/message-protocol'
|
|
17
|
-
import {Observable} from 'rxjs'
|
|
18
18
|
import {PreviewValue} from '@sanity/sdk'
|
|
19
|
+
import {ProjectHandle} from '@sanity/sdk'
|
|
19
20
|
import {QueryOptions} from '@sanity/sdk'
|
|
20
21
|
import {ReactElement} from 'react'
|
|
21
22
|
import {ReactNode} from 'react'
|
|
22
|
-
import {
|
|
23
|
-
import {ResourceId} from '@sanity/sdk'
|
|
24
|
-
import {ResourceType} from '@sanity/sdk'
|
|
23
|
+
import {SanityClient} from '@sanity/client'
|
|
25
24
|
import {SanityConfig} from '@sanity/sdk'
|
|
26
25
|
import {SanityDocument} from '@sanity/types'
|
|
27
26
|
import {SanityInstance} from '@sanity/sdk'
|
|
28
27
|
import {SanityProject as SanityProject_2} from '@sanity/sdk'
|
|
29
|
-
import {SanityUser
|
|
28
|
+
import {SanityUser} from '@sanity/sdk'
|
|
30
29
|
import {SortOrderingItem} from '@sanity/types'
|
|
31
30
|
import {StudioResource} from '@sanity/message-protocol'
|
|
32
31
|
import {ValidProjection} from '@sanity/sdk'
|
|
33
32
|
import {WindowMessage} from '@sanity/sdk'
|
|
34
33
|
|
|
35
|
-
/** @public */
|
|
36
|
-
declare type Action =
|
|
37
|
-
| CreateAction
|
|
38
|
-
| ReplaceDraftAction
|
|
39
|
-
| EditAction
|
|
40
|
-
| DeleteAction
|
|
41
|
-
| DiscardAction
|
|
42
|
-
| PublishAction
|
|
43
|
-
| UnpublishAction
|
|
44
|
-
|
|
45
|
-
/** @internal */
|
|
46
|
-
declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
|
|
47
|
-
returnFirst: false
|
|
48
|
-
returnDocuments: false
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** @internal */
|
|
52
|
-
declare type AllDocumentsMutationOptions = BaseMutationOptions & {
|
|
53
|
-
returnFirst: false
|
|
54
|
-
returnDocuments?: true
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
61
|
-
declare type Any = any
|
|
62
|
-
|
|
63
|
-
/** @public */
|
|
64
|
-
declare type AssetMetadataType =
|
|
65
|
-
| 'location'
|
|
66
|
-
| 'exif'
|
|
67
|
-
| 'image'
|
|
68
|
-
| 'palette'
|
|
69
|
-
| 'lqip'
|
|
70
|
-
| 'blurhash'
|
|
71
|
-
| 'none'
|
|
72
|
-
|
|
73
|
-
/** @internal */
|
|
74
|
-
declare class AssetsClient {
|
|
75
|
-
#private
|
|
76
|
-
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
77
|
-
/**
|
|
78
|
-
* Uploads a file asset to the configured dataset
|
|
79
|
-
*
|
|
80
|
-
* @param assetType - Asset type (file)
|
|
81
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
82
|
-
* @param options - Options to use for the upload
|
|
83
|
-
*/
|
|
84
|
-
upload(
|
|
85
|
-
assetType: 'file',
|
|
86
|
-
body: UploadBody,
|
|
87
|
-
options?: UploadClientConfig,
|
|
88
|
-
): Promise<SanityAssetDocument>
|
|
89
|
-
/**
|
|
90
|
-
* Uploads an image asset to the configured dataset
|
|
91
|
-
*
|
|
92
|
-
* @param assetType - Asset type (image)
|
|
93
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
94
|
-
* @param options - Options to use for the upload
|
|
95
|
-
*/
|
|
96
|
-
upload(
|
|
97
|
-
assetType: 'image',
|
|
98
|
-
body: UploadBody,
|
|
99
|
-
options?: UploadClientConfig,
|
|
100
|
-
): Promise<SanityImageAssetDocument>
|
|
101
|
-
/**
|
|
102
|
-
* Uploads a file or an image asset to the configured dataset
|
|
103
|
-
*
|
|
104
|
-
* @param assetType - Asset type (file/image)
|
|
105
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
106
|
-
* @param options - Options to use for the upload
|
|
107
|
-
*/
|
|
108
|
-
upload(
|
|
109
|
-
assetType: 'file' | 'image',
|
|
110
|
-
body: UploadBody,
|
|
111
|
-
options?: UploadClientConfig,
|
|
112
|
-
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/** @internal */
|
|
116
|
-
declare type AttributeSet = {
|
|
117
|
-
[key: string]: Any
|
|
118
|
-
}
|
|
119
|
-
|
|
120
34
|
/**
|
|
121
35
|
* A component that handles authentication flow and error boundaries for a
|
|
122
36
|
* protected section of the application.
|
|
@@ -144,2332 +58,350 @@ export declare function AuthBoundary({
|
|
|
144
58
|
}: AuthBoundaryProps): React.ReactNode
|
|
145
59
|
|
|
146
60
|
/**
|
|
147
|
-
* @
|
|
61
|
+
* @public
|
|
148
62
|
*/
|
|
149
|
-
declare interface AuthBoundaryProps
|
|
63
|
+
declare interface AuthBoundaryProps {
|
|
150
64
|
/**
|
|
151
65
|
* Custom component to render the login screen.
|
|
152
|
-
* Receives all
|
|
66
|
+
* Receives all props. Defaults to {@link Login}.
|
|
153
67
|
*/
|
|
154
|
-
LoginComponent?: React.ComponentType<
|
|
68
|
+
LoginComponent?: React.ComponentType<{
|
|
69
|
+
header?: React.ReactNode
|
|
70
|
+
footer?: React.ReactNode
|
|
71
|
+
}>
|
|
155
72
|
/**
|
|
156
73
|
* Custom component to render during OAuth callback processing.
|
|
157
|
-
* Receives all
|
|
74
|
+
* Receives all props. Defaults to {@link LoginCallback}.
|
|
158
75
|
*/
|
|
159
|
-
CallbackComponent?: React.ComponentType<
|
|
76
|
+
CallbackComponent?: React.ComponentType<{
|
|
77
|
+
header?: React.ReactNode
|
|
78
|
+
footer?: React.ReactNode
|
|
79
|
+
}>
|
|
160
80
|
/**
|
|
161
81
|
* Custom component to render when authentication errors occur.
|
|
162
|
-
* Receives
|
|
82
|
+
* Receives error boundary props and layout props. Defaults to
|
|
163
83
|
* {@link LoginError}
|
|
164
84
|
*/
|
|
165
85
|
LoginErrorComponent?: React.ComponentType<LoginErrorProps>
|
|
86
|
+
/** Header content to display */
|
|
87
|
+
header?: React.ReactNode
|
|
88
|
+
/** Footer content to display */
|
|
89
|
+
footer?: React.ReactNode
|
|
90
|
+
/** Protected content to render when authenticated */
|
|
91
|
+
children?: React.ReactNode
|
|
166
92
|
}
|
|
167
93
|
|
|
168
|
-
/**
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
94
|
+
/**
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
export declare type ComlinkStatus = 'idle' | 'handshaking' | 'connected' | 'disconnected'
|
|
98
|
+
|
|
99
|
+
/** @public */
|
|
100
|
+
declare type DatasetAclMode = 'public' | 'private' | 'custom'
|
|
101
|
+
|
|
102
|
+
/** @public */
|
|
103
|
+
export declare type DatasetsResponse = {
|
|
104
|
+
name: string
|
|
105
|
+
aclMode: DatasetAclMode
|
|
106
|
+
createdAt: string
|
|
107
|
+
createdByUserId: string
|
|
108
|
+
addonFor: string | null
|
|
109
|
+
datasetProfile: string
|
|
110
|
+
features: string[]
|
|
111
|
+
tags: string[]
|
|
112
|
+
}[]
|
|
174
113
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
returnDocuments?: boolean
|
|
179
|
-
returnFirst?: boolean
|
|
180
|
-
dryRun?: boolean
|
|
181
|
-
autoGenerateArrayKeys?: boolean
|
|
182
|
-
skipCrossDatasetReferenceValidation?: boolean
|
|
183
|
-
transactionId?: string
|
|
114
|
+
declare interface DocumentInteractionHistory {
|
|
115
|
+
recordEvent: (eventType: 'viewed' | 'edited' | 'created' | 'deleted') => void
|
|
116
|
+
isConnected: boolean
|
|
184
117
|
}
|
|
185
118
|
|
|
186
|
-
/**
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
194
|
-
*
|
|
195
|
-
* @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
|
|
196
|
-
*/
|
|
197
|
-
set(attrs: AttributeSet): this
|
|
119
|
+
/**
|
|
120
|
+
* Configuration options for the useDocuments hook
|
|
121
|
+
*
|
|
122
|
+
* @beta
|
|
123
|
+
* @category Types
|
|
124
|
+
*/
|
|
125
|
+
export declare interface DocumentsOptions extends QueryOptions {
|
|
198
126
|
/**
|
|
199
|
-
*
|
|
200
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
201
|
-
*
|
|
202
|
-
* @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
|
|
127
|
+
* GROQ filter expression to apply to the query
|
|
203
128
|
*/
|
|
204
|
-
|
|
129
|
+
filter?: string
|
|
205
130
|
/**
|
|
206
|
-
*
|
|
207
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
208
|
-
*
|
|
209
|
-
* @param attrs - Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "dmp"\}
|
|
131
|
+
* Number of items to load per batch (defaults to 25)
|
|
210
132
|
*/
|
|
211
|
-
|
|
133
|
+
batchSize?: number
|
|
212
134
|
/**
|
|
213
|
-
*
|
|
214
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
215
|
-
*
|
|
216
|
-
* @param attrs - Attribute paths to unset.
|
|
135
|
+
* Sorting configuration for the results
|
|
217
136
|
*/
|
|
218
|
-
|
|
137
|
+
orderings?: SortOrderingItem[]
|
|
219
138
|
/**
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
* @param attrs - Object of attribute paths to increment, values representing the number to increment by.
|
|
139
|
+
* Text search query to filter results
|
|
223
140
|
*/
|
|
224
|
-
|
|
141
|
+
search?: string
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Return value from the useDocuments hook
|
|
146
|
+
*
|
|
147
|
+
* @beta
|
|
148
|
+
* @category Types
|
|
149
|
+
*/
|
|
150
|
+
export declare interface DocumentsResponse {
|
|
225
151
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* @param attrs - Object of attribute paths to decrement, values representing the number to decrement by.
|
|
152
|
+
* Array of document handles for the current batch
|
|
229
153
|
*/
|
|
230
|
-
|
|
154
|
+
data: DocumentHandle[]
|
|
231
155
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* @param at - Location to insert at, relative to the given selector, or 'replace' the matched path
|
|
235
|
-
* @param selector - JSONPath expression, eg `comments[-1]` or `blocks[_key=="abc123"]`
|
|
236
|
-
* @param items - Array of items to insert/replace
|
|
156
|
+
* Whether there are more items available to load
|
|
237
157
|
*/
|
|
238
|
-
|
|
158
|
+
hasMore: boolean
|
|
239
159
|
/**
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* @param selector - Attribute/path to append to, eg `comments` or `person.hobbies`
|
|
243
|
-
* @param items - Array of items to append to the array
|
|
160
|
+
* Total count of items matching the query
|
|
244
161
|
*/
|
|
245
|
-
|
|
162
|
+
count: number
|
|
246
163
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* @param selector - Attribute/path to prepend to, eg `comments` or `person.hobbies`
|
|
250
|
-
* @param items - Array of items to prepend to the array
|
|
164
|
+
* Whether a query is currently in progress
|
|
251
165
|
*/
|
|
252
|
-
|
|
166
|
+
isPending: boolean
|
|
253
167
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* @param selector - Attribute or JSONPath expression for array
|
|
257
|
-
* @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
|
|
258
|
-
* @param deleteCount - An integer indicating the number of old array elements to remove.
|
|
259
|
-
* @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.
|
|
168
|
+
* Function to load the next batch of results
|
|
260
169
|
*/
|
|
261
|
-
|
|
170
|
+
loadMore: () => void
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
export declare interface FrameConnection<TFrameMessage extends FrameMessage> {
|
|
177
|
+
connect: (frameWindow: Window) => () => void
|
|
178
|
+
sendMessage: <T extends TFrameMessage['type']>(
|
|
179
|
+
...params: Extract<
|
|
180
|
+
TFrameMessage,
|
|
181
|
+
{
|
|
182
|
+
type: T
|
|
183
|
+
}
|
|
184
|
+
>['data'] extends undefined
|
|
185
|
+
? [type: T]
|
|
186
|
+
: [
|
|
187
|
+
type: T,
|
|
188
|
+
data: Extract<
|
|
189
|
+
TFrameMessage,
|
|
190
|
+
{
|
|
191
|
+
type: T
|
|
192
|
+
}
|
|
193
|
+
>['data'],
|
|
194
|
+
]
|
|
195
|
+
) => void
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @alpha
|
|
200
|
+
*/
|
|
201
|
+
declare type LoginErrorProps = FallbackProps
|
|
202
|
+
|
|
203
|
+
declare interface ManageFavorite {
|
|
204
|
+
favorite: () => void
|
|
205
|
+
unfavorite: () => void
|
|
206
|
+
isFavorited: boolean
|
|
207
|
+
isConnected: boolean
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @public
|
|
212
|
+
*/
|
|
213
|
+
declare type MessageData = Record<string, unknown> | undefined
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @internal
|
|
217
|
+
*/
|
|
218
|
+
export declare type MessageHandler<TWindowMessage extends WindowMessage> = (
|
|
219
|
+
event: TWindowMessage['data'],
|
|
220
|
+
) => TWindowMessage['response'] | Promise<TWindowMessage['response']>
|
|
221
|
+
|
|
222
|
+
declare interface NavigateToStudioResult {
|
|
223
|
+
navigateToStudioDocument: () => void
|
|
224
|
+
isConnected: boolean
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Configuration options for the usePaginatedDocuments hook
|
|
229
|
+
*
|
|
230
|
+
* @beta
|
|
231
|
+
* @category Types
|
|
232
|
+
*/
|
|
233
|
+
export declare interface PaginatedDocumentsOptions extends QueryOptions {
|
|
262
234
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* @param rev - Revision to lock the patch to
|
|
235
|
+
* GROQ filter expression to apply to the query
|
|
266
236
|
*/
|
|
267
|
-
|
|
237
|
+
filter?: string
|
|
268
238
|
/**
|
|
269
|
-
*
|
|
239
|
+
* Number of items to display per page (defaults to 25)
|
|
270
240
|
*/
|
|
271
|
-
|
|
241
|
+
pageSize?: number
|
|
272
242
|
/**
|
|
273
|
-
*
|
|
243
|
+
* Sorting configuration for the results
|
|
274
244
|
*/
|
|
275
|
-
|
|
245
|
+
orderings?: SortOrderingItem[]
|
|
276
246
|
/**
|
|
277
|
-
*
|
|
247
|
+
* Text search query to filter results
|
|
278
248
|
*/
|
|
279
|
-
|
|
280
|
-
protected _assign(op: keyof PatchOperations, props: Any, merge?: boolean): this
|
|
281
|
-
protected _set(op: keyof PatchOperations, props: Any): this
|
|
249
|
+
search?: string
|
|
282
250
|
}
|
|
283
251
|
|
|
284
|
-
/**
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
252
|
+
/**
|
|
253
|
+
* Return value from the usePaginatedDocuments hook
|
|
254
|
+
*
|
|
255
|
+
* @beta
|
|
256
|
+
* @category Types
|
|
257
|
+
*/
|
|
258
|
+
export declare interface PaginatedDocumentsResponse {
|
|
289
259
|
/**
|
|
290
|
-
*
|
|
291
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
292
|
-
*
|
|
293
|
-
* @param doc - Document to create. Requires a `_type` property.
|
|
260
|
+
* Array of document handles for the current page
|
|
294
261
|
*/
|
|
295
|
-
|
|
262
|
+
data: DocumentHandle[]
|
|
296
263
|
/**
|
|
297
|
-
*
|
|
298
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
299
|
-
*
|
|
300
|
-
* @param doc - Document to create if it does not already exist. Requires `_id` and `_type` properties.
|
|
264
|
+
* Whether a query is currently in progress
|
|
301
265
|
*/
|
|
302
|
-
|
|
303
|
-
doc: IdentifiedSanityDocumentStub<R>,
|
|
304
|
-
): this
|
|
266
|
+
isPending: boolean
|
|
305
267
|
/**
|
|
306
|
-
*
|
|
307
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
308
|
-
*
|
|
309
|
-
* @param doc - Document to create or replace. Requires `_id` and `_type` properties.
|
|
268
|
+
* Number of items displayed per page
|
|
310
269
|
*/
|
|
311
|
-
|
|
312
|
-
doc: IdentifiedSanityDocumentStub<R>,
|
|
313
|
-
): this
|
|
270
|
+
pageSize: number
|
|
314
271
|
/**
|
|
315
|
-
*
|
|
316
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
317
|
-
*
|
|
318
|
-
* @param documentId - Document ID to delete
|
|
272
|
+
* Current page number (1-indexed)
|
|
319
273
|
*/
|
|
320
|
-
|
|
274
|
+
currentPage: number
|
|
321
275
|
/**
|
|
322
|
-
*
|
|
276
|
+
* Total number of pages available
|
|
323
277
|
*/
|
|
324
|
-
|
|
278
|
+
totalPages: number
|
|
325
279
|
/**
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* @param id - Transaction ID
|
|
280
|
+
* Starting index of the current page (0-indexed)
|
|
329
281
|
*/
|
|
330
|
-
|
|
282
|
+
startIndex: number
|
|
331
283
|
/**
|
|
332
|
-
*
|
|
284
|
+
* Ending index of the current page (exclusive, 0-indexed)
|
|
333
285
|
*/
|
|
334
|
-
|
|
286
|
+
endIndex: number
|
|
335
287
|
/**
|
|
336
|
-
*
|
|
288
|
+
* Total count of items matching the query
|
|
337
289
|
*/
|
|
338
|
-
|
|
290
|
+
count: number
|
|
339
291
|
/**
|
|
340
|
-
*
|
|
292
|
+
* Navigate to the first page
|
|
341
293
|
*/
|
|
342
|
-
|
|
343
|
-
protected _add(mut: Mutation): this
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* An error occurred. This is different from a network-level error (which will be emitted as 'error').
|
|
348
|
-
* Possible causes are things such as malformed filters, non-existant datasets or similar.
|
|
349
|
-
*
|
|
350
|
-
* @public
|
|
351
|
-
*/
|
|
352
|
-
declare type ChannelErrorEvent = {
|
|
353
|
-
type: 'channelError'
|
|
354
|
-
message: string
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/** @public */
|
|
358
|
-
declare interface ClientConfig {
|
|
359
|
-
projectId?: string
|
|
360
|
-
dataset?: string
|
|
361
|
-
/** @defaultValue true */
|
|
362
|
-
useCdn?: boolean
|
|
363
|
-
token?: string
|
|
294
|
+
firstPage: () => void
|
|
364
295
|
/**
|
|
365
|
-
*
|
|
366
|
-
* @remarks
|
|
367
|
-
* As of API version `v2025-02-19`, the default perspective has changed from `raw` to `published`. {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog}
|
|
368
|
-
* @defaultValue 'published'
|
|
296
|
+
* Whether there is a first page available to navigate to
|
|
369
297
|
*/
|
|
370
|
-
|
|
371
|
-
apiHost?: string
|
|
372
|
-
/**
|
|
373
|
-
@remarks
|
|
374
|
-
* As of API version `v2025-02-19`, the default perspective has changed from `raw` to `published`. {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog}
|
|
375
|
-
*/
|
|
376
|
-
apiVersion?: string
|
|
377
|
-
proxy?: string
|
|
298
|
+
hasFirstPage: boolean
|
|
378
299
|
/**
|
|
379
|
-
*
|
|
300
|
+
* Navigate to the previous page
|
|
380
301
|
*/
|
|
381
|
-
|
|
382
|
-
ignoreBrowserTokenWarning?: boolean
|
|
383
|
-
withCredentials?: boolean
|
|
384
|
-
allowReconfigure?: boolean
|
|
385
|
-
timeout?: number
|
|
386
|
-
/** Number of retries for requests. Defaults to 5. */
|
|
387
|
-
maxRetries?: number
|
|
302
|
+
previousPage: () => void
|
|
388
303
|
/**
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
* Defaults to exponential back-off, starting at 100ms, doubling for each attempt, together with random
|
|
392
|
-
* jitter between 0 and 100 milliseconds. More specifically the following algorithm is used:
|
|
393
|
-
*
|
|
394
|
-
* Delay = 100 * 2^attemptNumber + randomNumberBetween0and100
|
|
304
|
+
* Whether there is a previous page available to navigate to
|
|
395
305
|
*/
|
|
396
|
-
|
|
306
|
+
hasPreviousPage: boolean
|
|
397
307
|
/**
|
|
398
|
-
*
|
|
308
|
+
* Navigate to the next page
|
|
399
309
|
*/
|
|
400
|
-
|
|
310
|
+
nextPage: () => void
|
|
401
311
|
/**
|
|
402
|
-
*
|
|
312
|
+
* Whether there is a next page available to navigate to
|
|
403
313
|
*/
|
|
404
|
-
|
|
314
|
+
hasNextPage: boolean
|
|
405
315
|
/**
|
|
406
|
-
*
|
|
316
|
+
* Navigate to the last page
|
|
407
317
|
*/
|
|
408
|
-
|
|
318
|
+
lastPage: () => void
|
|
409
319
|
/**
|
|
410
|
-
|
|
320
|
+
* Whether there is a last page available to navigate to
|
|
411
321
|
*/
|
|
412
|
-
|
|
413
|
-
| {
|
|
414
|
-
cache?: ResponseQueryOptions['cache']
|
|
415
|
-
next?: ResponseQueryOptions['next']
|
|
416
|
-
}
|
|
417
|
-
| boolean
|
|
322
|
+
hasLastPage: boolean
|
|
418
323
|
/**
|
|
419
|
-
*
|
|
324
|
+
* Navigate to a specific page number
|
|
325
|
+
* @param pageNumber - The page number to navigate to (1-indexed)
|
|
420
326
|
*/
|
|
421
|
-
|
|
327
|
+
goToPage: (pageNumber: number) => void
|
|
422
328
|
}
|
|
423
329
|
|
|
424
|
-
/** @public */
|
|
425
|
-
declare type ClientPerspective =
|
|
426
|
-
| DeprecatedPreviewDrafts
|
|
427
|
-
| 'published'
|
|
428
|
-
| 'drafts'
|
|
429
|
-
| 'raw'
|
|
430
|
-
| StackablePerspective[]
|
|
431
|
-
|
|
432
|
-
/** @public */
|
|
433
|
-
declare type ClientReturn<
|
|
434
|
-
GroqString extends string,
|
|
435
|
-
Fallback = Any,
|
|
436
|
-
> = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
|
|
437
|
-
|
|
438
330
|
/**
|
|
439
331
|
* @public
|
|
332
|
+
* @category Types
|
|
333
|
+
* @interface
|
|
440
334
|
*/
|
|
441
|
-
export declare type
|
|
442
|
-
|
|
443
|
-
/** @public */
|
|
444
|
-
declare interface ContentSourceMap {
|
|
445
|
-
mappings: ContentSourceMapMappings
|
|
446
|
-
documents: ContentSourceMapDocuments_2
|
|
447
|
-
paths: ContentSourceMapPaths
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
/** @public */
|
|
451
|
-
declare interface ContentSourceMapDocument extends ContentSourceMapDocumentBase {
|
|
452
|
-
_projectId?: undefined
|
|
453
|
-
_dataset?: undefined
|
|
454
|
-
}
|
|
335
|
+
export declare type ProjectWithoutMembers = Omit<SanityProject, 'members'>
|
|
455
336
|
|
|
456
|
-
/**
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
/** @public */
|
|
463
|
-
declare interface ContentSourceMapDocumentBase {
|
|
464
|
-
_id: string
|
|
465
|
-
_type: string
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
/** @public */
|
|
469
|
-
declare interface ContentSourceMapDocumentBase_2 {
|
|
470
|
-
_id: string
|
|
471
|
-
_type: string
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/** @public */
|
|
475
|
-
declare type ContentSourceMapDocuments = (
|
|
476
|
-
| ContentSourceMapDocument
|
|
477
|
-
| ContentSourceMapRemoteDocument
|
|
478
|
-
)[]
|
|
479
|
-
|
|
480
|
-
/** @public */
|
|
481
|
-
declare type ContentSourceMapDocuments_2 = (
|
|
482
|
-
| ContentSourceMapDocument_2
|
|
483
|
-
| ContentSourceMapRemoteDocument_2
|
|
484
|
-
)[]
|
|
485
|
-
|
|
486
|
-
/**
|
|
487
|
-
* DocumentValueSource is a path to a value within a document
|
|
488
|
-
* @public
|
|
489
|
-
*/
|
|
490
|
-
declare interface ContentSourceMapDocumentValueSource {
|
|
491
|
-
type: 'documentValue'
|
|
492
|
-
document: number
|
|
493
|
-
path: number
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* When a value is not from a source, its a literal
|
|
498
|
-
* @public
|
|
499
|
-
*/
|
|
500
|
-
declare interface ContentSourceMapLiteralSource {
|
|
501
|
-
type: 'literal'
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/** @public */
|
|
505
|
-
declare type ContentSourceMapMapping = ContentSourceMapValueMapping
|
|
506
|
-
|
|
507
|
-
/** @public */
|
|
508
|
-
declare type ContentSourceMapMappings = Record<string, ContentSourceMapMapping>
|
|
509
|
-
|
|
510
|
-
/** @alpha */
|
|
511
|
-
declare type ContentSourceMapParsedPath = (
|
|
512
|
-
| string
|
|
513
|
-
| number
|
|
514
|
-
| ContentSourceMapParsedPathKeyedSegment
|
|
515
|
-
)[]
|
|
516
|
-
|
|
517
|
-
/** @alpha */
|
|
518
|
-
declare type ContentSourceMapParsedPathKeyedSegment = {
|
|
519
|
-
_key: string
|
|
520
|
-
_index: number
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/** @public */
|
|
524
|
-
declare type ContentSourceMapPaths = string[]
|
|
525
|
-
|
|
526
|
-
/** @public */
|
|
527
|
-
declare interface ContentSourceMapRemoteDocument extends ContentSourceMapDocumentBase {
|
|
528
|
-
_projectId: string
|
|
529
|
-
_dataset: string
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
/** @public */
|
|
533
|
-
declare interface ContentSourceMapRemoteDocument_2 extends ContentSourceMapDocumentBase_2 {
|
|
534
|
-
_projectId: string
|
|
535
|
-
_dataset: string
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/** @public */
|
|
539
|
-
declare type ContentSourceMapSource =
|
|
540
|
-
| ContentSourceMapDocumentValueSource
|
|
541
|
-
| ContentSourceMapLiteralSource
|
|
542
|
-
| ContentSourceMapUnknownSource
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* When a field source is unknown
|
|
546
|
-
* @public
|
|
547
|
-
*/
|
|
548
|
-
declare interface ContentSourceMapUnknownSource {
|
|
549
|
-
type: 'unknown'
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* ValueMapping is a mapping when for value that is from a single source value
|
|
554
|
-
* It may refer to a field within a document or a literal value
|
|
555
|
-
* @public
|
|
556
|
-
*/
|
|
557
|
-
declare interface ContentSourceMapValueMapping {
|
|
558
|
-
type: 'value'
|
|
559
|
-
source: ContentSourceMapSource
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* Creates a new draft document. The published version of the document must not already exist.
|
|
564
|
-
* If the draft version of the document already exists the action will fail by default, but
|
|
565
|
-
* this can be adjusted to instead leave the existing document in place.
|
|
566
|
-
*
|
|
567
|
-
* @public
|
|
568
|
-
*/
|
|
569
|
-
declare type CreateAction = {
|
|
570
|
-
actionType: 'sanity.action.document.create'
|
|
571
|
-
/**
|
|
572
|
-
* ID of the published document to create a draft for.
|
|
573
|
-
*/
|
|
574
|
-
publishedId: string
|
|
575
|
-
/**
|
|
576
|
-
* Document to create. Requires a `_type` property.
|
|
577
|
-
*/
|
|
578
|
-
attributes: IdentifiedSanityDocumentStub
|
|
579
|
-
/**
|
|
580
|
-
* ifExists controls what to do if the draft already exists
|
|
581
|
-
*/
|
|
582
|
-
ifExists: 'fail' | 'ignore'
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
/** @public */
|
|
586
|
-
declare interface CurrentSanityUser {
|
|
587
|
-
id: string
|
|
588
|
-
name: string
|
|
589
|
-
email: string
|
|
590
|
-
profileImage: string | null
|
|
591
|
-
role: string
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
export {CurrentUser}
|
|
595
|
-
|
|
596
|
-
/** @public */
|
|
597
|
-
declare type DatasetAclMode = 'public' | 'private' | 'custom'
|
|
598
|
-
|
|
599
|
-
/** @public */
|
|
600
|
-
declare type DatasetResponse = {
|
|
601
|
-
datasetName: string
|
|
602
|
-
aclMode: DatasetAclMode
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
/** @internal */
|
|
606
|
-
declare class DatasetsClient {
|
|
607
|
-
#private
|
|
608
|
-
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
609
|
-
/**
|
|
610
|
-
* Create a new dataset with the given name
|
|
611
|
-
*
|
|
612
|
-
* @param name - Name of the dataset to create
|
|
613
|
-
* @param options - Options for the dataset
|
|
614
|
-
*/
|
|
615
|
-
create(
|
|
616
|
-
name: string,
|
|
617
|
-
options?: {
|
|
618
|
-
aclMode?: DatasetAclMode
|
|
619
|
-
},
|
|
620
|
-
): Promise<DatasetResponse>
|
|
621
|
-
/**
|
|
622
|
-
* Edit a dataset with the given name
|
|
623
|
-
*
|
|
624
|
-
* @param name - Name of the dataset to edit
|
|
625
|
-
* @param options - New options for the dataset
|
|
626
|
-
*/
|
|
627
|
-
edit(
|
|
628
|
-
name: string,
|
|
629
|
-
options?: {
|
|
630
|
-
aclMode?: DatasetAclMode
|
|
631
|
-
},
|
|
632
|
-
): Promise<DatasetResponse>
|
|
633
|
-
/**
|
|
634
|
-
* Delete a dataset with the given name
|
|
635
|
-
*
|
|
636
|
-
* @param name - Name of the dataset to delete
|
|
637
|
-
*/
|
|
638
|
-
delete(name: string): Promise<{
|
|
639
|
-
deleted: true
|
|
640
|
-
}>
|
|
641
|
-
/**
|
|
642
|
-
* Fetch a list of datasets for the configured project
|
|
643
|
-
*/
|
|
644
|
-
list(): Promise<DatasetsResponse>
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
/** @public */
|
|
648
|
-
export declare type DatasetsResponse = {
|
|
649
|
-
name: string
|
|
650
|
-
aclMode: DatasetAclMode
|
|
651
|
-
createdAt: string
|
|
652
|
-
createdByUserId: string
|
|
653
|
-
addonFor: string | null
|
|
654
|
-
datasetProfile: string
|
|
655
|
-
features: string[]
|
|
656
|
-
tags: string[]
|
|
657
|
-
}[]
|
|
658
|
-
|
|
659
|
-
/**
|
|
660
|
-
* Deletes the published version of a document and optionally some (likely all known) draft versions.
|
|
661
|
-
* If any draft version exists that is not specified for deletion this is an error.
|
|
662
|
-
* If the purge flag is set then the document history is also deleted.
|
|
663
|
-
*
|
|
664
|
-
* @public
|
|
665
|
-
*/
|
|
666
|
-
declare type DeleteAction = {
|
|
667
|
-
actionType: 'sanity.action.document.delete'
|
|
668
|
-
/**
|
|
669
|
-
* Published document ID to delete
|
|
670
|
-
*/
|
|
671
|
-
publishedId: string
|
|
672
|
-
/**
|
|
673
|
-
* Draft document ID to delete
|
|
674
|
-
*/
|
|
675
|
-
includeDrafts: string[]
|
|
676
|
-
/**
|
|
677
|
-
* Delete document history
|
|
678
|
-
*/
|
|
679
|
-
purge?: boolean
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* @deprecated use 'drafts' instead
|
|
684
|
-
*/
|
|
685
|
-
declare type DeprecatedPreviewDrafts = 'previewDrafts'
|
|
686
|
-
|
|
687
|
-
/**
|
|
688
|
-
* Delete the draft version of a document.
|
|
689
|
-
* It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
|
|
690
|
-
*
|
|
691
|
-
* @public
|
|
692
|
-
*/
|
|
693
|
-
declare type DiscardAction = {
|
|
694
|
-
actionType: 'sanity.action.document.discard'
|
|
695
|
-
/**
|
|
696
|
-
* Draft document ID to delete
|
|
697
|
-
*/
|
|
698
|
-
draftId: string
|
|
699
|
-
/**
|
|
700
|
-
* Delete document history
|
|
701
|
-
*/
|
|
702
|
-
purge?: boolean
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
/**
|
|
706
|
-
* The listener has been told to explicitly disconnect and not reconnect.
|
|
707
|
-
* This is a rare situation, but may occur if the API knows reconnect attempts will fail,
|
|
708
|
-
* eg in the case of a deleted dataset, a blocked project or similar events.
|
|
709
|
-
*
|
|
710
|
-
* Note that this is not treated as an error on the observable, but will complete the observable.
|
|
711
|
-
*
|
|
712
|
-
* @public
|
|
713
|
-
*/
|
|
714
|
-
declare type DisconnectEvent = {
|
|
715
|
-
type: 'disconnect'
|
|
716
|
-
reason: string
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
export {DocumentHandle}
|
|
720
|
-
|
|
721
|
-
declare interface DocumentInteractionHistory {
|
|
722
|
-
recordEvent: (eventType: 'viewed' | 'edited' | 'created' | 'deleted') => void
|
|
723
|
-
isConnected: boolean
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/**
|
|
727
|
-
* Configuration options for the useDocuments hook
|
|
728
|
-
*
|
|
729
|
-
* @beta
|
|
730
|
-
* @category Types
|
|
731
|
-
*/
|
|
732
|
-
export declare interface DocumentsOptions extends QueryOptions {
|
|
733
|
-
/**
|
|
734
|
-
* GROQ filter expression to apply to the query
|
|
735
|
-
*/
|
|
736
|
-
filter?: string
|
|
737
|
-
/**
|
|
738
|
-
* Number of items to load per batch (defaults to 25)
|
|
739
|
-
*/
|
|
740
|
-
batchSize?: number
|
|
741
|
-
/**
|
|
742
|
-
* Sorting configuration for the results
|
|
743
|
-
*/
|
|
744
|
-
orderings?: SortOrderingItem[]
|
|
745
|
-
/**
|
|
746
|
-
* Text search query to filter results
|
|
747
|
-
*/
|
|
748
|
-
search?: string
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
/**
|
|
752
|
-
* Return value from the useDocuments hook
|
|
753
|
-
*
|
|
754
|
-
* @beta
|
|
755
|
-
* @category Types
|
|
756
|
-
*/
|
|
757
|
-
export declare interface DocumentsResponse {
|
|
758
|
-
/**
|
|
759
|
-
* Array of document handles for the current batch
|
|
760
|
-
*/
|
|
761
|
-
data: DocumentHandle[]
|
|
762
|
-
/**
|
|
763
|
-
* Whether there are more items available to load
|
|
764
|
-
*/
|
|
765
|
-
hasMore: boolean
|
|
766
|
-
/**
|
|
767
|
-
* Total count of items matching the query
|
|
768
|
-
*/
|
|
769
|
-
count: number
|
|
770
|
-
/**
|
|
771
|
-
* Whether a query is currently in progress
|
|
772
|
-
*/
|
|
773
|
-
isPending: boolean
|
|
774
|
-
/**
|
|
775
|
-
* Function to load the next batch of results
|
|
776
|
-
*/
|
|
777
|
-
loadMore: () => void
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
/**
|
|
781
|
-
* Modifies an existing draft document.
|
|
782
|
-
* It applies the given patch to the document referenced by draftId.
|
|
783
|
-
* If there is no such document then one is created using the current state of the published version and then that is updated accordingly.
|
|
784
|
-
*
|
|
785
|
-
* @public
|
|
786
|
-
*/
|
|
787
|
-
declare type EditAction = {
|
|
788
|
-
actionType: 'sanity.action.document.edit'
|
|
789
|
-
/**
|
|
790
|
-
* Draft document ID to edit
|
|
791
|
-
*/
|
|
792
|
-
draftId: string
|
|
793
|
-
/**
|
|
794
|
-
* Published document ID to create draft from, if draft does not exist
|
|
795
|
-
*/
|
|
796
|
-
publishedId: string
|
|
797
|
-
/**
|
|
798
|
-
* Patch operations to apply
|
|
799
|
-
*/
|
|
800
|
-
patch: PatchOperations
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
/** @public */
|
|
804
|
-
declare type FilterDefault = (props: {
|
|
805
|
-
/**
|
|
806
|
-
* The path to the value in the source document, for example if you queried for a document like this:
|
|
807
|
-
* `*[_type == "author"][0]{"slug": slug.current}`
|
|
808
|
-
* Then the `sourcePath` for `result.slug` would be `['slug', 'current']`.
|
|
809
|
-
*
|
|
810
|
-
*/
|
|
811
|
-
sourcePath: ContentSourceMapParsedPath
|
|
812
|
-
/**
|
|
813
|
-
* If `sourcePath` alone isn't enough to tell you if it's safe to contain stega strings, then you can use `sourceDocument`
|
|
814
|
-
* for additional metadata.
|
|
815
|
-
* It'll always have a `_type` property, which can be used to trace it to the Studio Schema that were used initially.
|
|
816
|
-
* It also has `_id` to help you debug and look at the whole document when troubleshooting.
|
|
817
|
-
* Finally, if the document origins in a Cross Dataset Reference you'll also have `_projectId` and `_dataset` properties to help you trace it.
|
|
818
|
-
*/
|
|
819
|
-
sourceDocument: ContentSourceMapDocuments[number]
|
|
820
|
-
/**
|
|
821
|
-
* If you don't colocate your Studio Schemas with your GROQ queries it might be hard to make sense of `sourcePath`,
|
|
822
|
-
* as it operates on the original shape of a document.
|
|
823
|
-
* In that case `resultPath` can be used, as it mirrors the path to the value in the result.
|
|
824
|
-
* For example in a query like this:
|
|
825
|
-
* `*[_type == "author"][0]{"slug": slug.current}`
|
|
826
|
-
* The `resultPath` for `result.slug` would be `['slug']`, while `sourcePath` will be `['slug', 'current']`.
|
|
827
|
-
*/
|
|
828
|
-
resultPath: ContentSourceMapParsedPath
|
|
829
|
-
/**
|
|
830
|
-
* You can also use your own string validation logic to determine if it's safe.
|
|
831
|
-
*/
|
|
832
|
-
value: string
|
|
833
|
-
/**
|
|
834
|
-
* If you want to keep the default filtering behavior, but only override it for a specific path, you can use `filterDefault` to do that.
|
|
835
|
-
* For example, here all "icon" documents in a Page Builder skips encoding:
|
|
836
|
-
* ```ts
|
|
837
|
-
{
|
|
838
|
-
filter: (props) => {
|
|
839
|
-
switch (props.sourceDocument._type) {
|
|
840
|
-
case 'icon':
|
|
841
|
-
return false
|
|
842
|
-
default:
|
|
843
|
-
return props.filterDefault(props)
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
* ```
|
|
848
|
-
*/
|
|
849
|
-
filterDefault: FilterDefault
|
|
850
|
-
}) => boolean
|
|
851
|
-
|
|
852
|
-
/** @public */
|
|
853
|
-
declare interface FilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
854
|
-
filterResponse?: true
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
/** @internal */
|
|
858
|
-
declare type FirstDocumentIdMutationOptions = BaseMutationOptions & {
|
|
859
|
-
returnFirst?: true
|
|
860
|
-
returnDocuments: false
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
/** @internal */
|
|
864
|
-
declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
865
|
-
returnFirst?: true
|
|
866
|
-
returnDocuments?: true
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
/**
|
|
870
|
-
* @internal
|
|
871
|
-
*/
|
|
872
|
-
export declare interface FrameConnection<TFrameMessage extends FrameMessage> {
|
|
873
|
-
connect: (frameWindow: Window) => () => void
|
|
874
|
-
sendMessage: <T extends TFrameMessage['type']>(
|
|
875
|
-
...params: Extract<
|
|
876
|
-
TFrameMessage,
|
|
877
|
-
{
|
|
878
|
-
type: T
|
|
879
|
-
}
|
|
880
|
-
>['data'] extends undefined
|
|
881
|
-
? [type: T]
|
|
882
|
-
: [
|
|
883
|
-
type: T,
|
|
884
|
-
data: Extract<
|
|
885
|
-
TFrameMessage,
|
|
886
|
-
{
|
|
887
|
-
type: T
|
|
888
|
-
}
|
|
889
|
-
>['data'],
|
|
890
|
-
]
|
|
891
|
-
) => void
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
/** @public */
|
|
895
|
-
declare type HttpRequest = {
|
|
896
|
-
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
/** @public */
|
|
900
|
-
declare type HttpRequestEvent<T = unknown> = ResponseEvent<T> | ProgressEvent_2
|
|
901
|
-
|
|
902
|
-
/** @public */
|
|
903
|
-
declare type IdentifiedSanityDocumentStub<T extends Record<string, Any> = Record<string, Any>> = {
|
|
904
|
-
[P in keyof T]: T[P]
|
|
905
|
-
} & {
|
|
906
|
-
_id: string
|
|
907
|
-
} & SanityDocumentStub
|
|
908
|
-
|
|
909
|
-
/** @public */
|
|
910
|
-
declare interface InitializedClientConfig extends ClientConfig {
|
|
911
|
-
apiHost: string
|
|
912
|
-
apiVersion: string
|
|
913
|
-
useProjectHostname: boolean
|
|
914
|
-
useCdn: boolean
|
|
915
|
-
/**
|
|
916
|
-
* @deprecated Internal, don't use
|
|
917
|
-
*/
|
|
918
|
-
isDefaultApi: boolean
|
|
919
|
-
/**
|
|
920
|
-
* @deprecated Internal, don't use
|
|
921
|
-
*/
|
|
922
|
-
url: string
|
|
923
|
-
/**
|
|
924
|
-
* @deprecated Internal, don't use
|
|
925
|
-
*/
|
|
926
|
-
cdnUrl: string
|
|
927
|
-
/**
|
|
928
|
-
* The fully initialized stega config, can be used to check if stega is enabled
|
|
929
|
-
*/
|
|
930
|
-
stega: InitializedStegaConfig
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
/** @public */
|
|
934
|
-
declare type InitializedStegaConfig = Omit<StegaConfig, StegaConfigRequiredKeys> &
|
|
935
|
-
Required<Pick<StegaConfig, StegaConfigRequiredKeys>>
|
|
936
|
-
|
|
937
|
-
/** @internal */
|
|
938
|
-
declare type InsertPatch =
|
|
939
|
-
| {
|
|
940
|
-
before: string
|
|
941
|
-
items: Any[]
|
|
942
|
-
}
|
|
943
|
-
| {
|
|
944
|
-
after: string
|
|
945
|
-
items: Any[]
|
|
946
|
-
}
|
|
947
|
-
| {
|
|
948
|
-
replace: string
|
|
949
|
-
items: Any[]
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
/**
|
|
953
|
-
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
954
|
-
*
|
|
955
|
-
* @param query - GROQ-filter to listen to changes for
|
|
956
|
-
* @param params - Optional query parameters
|
|
957
|
-
* @param options - Optional listener options
|
|
958
|
-
* @public
|
|
959
|
-
*/
|
|
960
|
-
declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
|
|
961
|
-
this: SanityClient | ObservableSanityClient,
|
|
962
|
-
query: string,
|
|
963
|
-
params?: ListenParams,
|
|
964
|
-
): Observable<MutationEvent_2<R>>
|
|
965
|
-
|
|
966
|
-
/**
|
|
967
|
-
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
968
|
-
*
|
|
969
|
-
* @param query - GROQ-filter to listen to changes for
|
|
970
|
-
* @param params - Optional query parameters
|
|
971
|
-
* @param options - Optional listener options
|
|
972
|
-
* @public
|
|
973
|
-
*/
|
|
974
|
-
declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
|
|
975
|
-
this: SanityClient | ObservableSanityClient,
|
|
976
|
-
query: string,
|
|
977
|
-
params?: ListenParams,
|
|
978
|
-
options?: ListenOptions,
|
|
979
|
-
): Observable<ListenEvent<R>>
|
|
980
|
-
|
|
981
|
-
/** @public */
|
|
982
|
-
declare type ListenEvent<R extends Record<string, Any>> =
|
|
983
|
-
| MutationEvent_2<R>
|
|
984
|
-
| ChannelErrorEvent
|
|
985
|
-
| DisconnectEvent
|
|
986
|
-
| ReconnectEvent
|
|
987
|
-
| WelcomeEvent
|
|
988
|
-
| OpenEvent
|
|
989
|
-
|
|
990
|
-
/** @public */
|
|
991
|
-
declare type ListenEventName =
|
|
992
|
-
/** A mutation was performed */
|
|
993
|
-
| 'mutation'
|
|
994
|
-
/** The listener has been (re)established */
|
|
995
|
-
| 'welcome'
|
|
996
|
-
/** The listener has been disconnected, and a reconnect attempt is scheduled */
|
|
997
|
-
| 'reconnect'
|
|
998
|
-
|
|
999
|
-
/** @public */
|
|
1000
|
-
declare interface ListenOptions {
|
|
1001
|
-
/**
|
|
1002
|
-
* Whether or not to include the resulting document in addition to the mutations performed.
|
|
1003
|
-
* If you do not need the actual document, set this to `false` to reduce bandwidth usage.
|
|
1004
|
-
* The result will be available on the `.result` property of the events.
|
|
1005
|
-
* @defaultValue `true`
|
|
1006
|
-
*/
|
|
1007
|
-
includeResult?: boolean
|
|
1008
|
-
/**
|
|
1009
|
-
* Whether or not to include the mutations that was performed.
|
|
1010
|
-
* If you do not need the mutations, set this to `false` to reduce bandwidth usage.
|
|
1011
|
-
* @defaultValue `true`
|
|
1012
|
-
*/
|
|
1013
|
-
includeMutations?: boolean
|
|
1014
|
-
/**
|
|
1015
|
-
* Whether or not to include the document as it looked before the mutation event.
|
|
1016
|
-
* The previous revision will be available on the `.previous` property of the events,
|
|
1017
|
-
* and may be `null` in the case of a new document.
|
|
1018
|
-
* @defaultValue `false`
|
|
1019
|
-
*/
|
|
1020
|
-
includePreviousRevision?: boolean
|
|
1021
|
-
/**
|
|
1022
|
-
* Whether to include events for drafts and versions. As of API Version >= v2025-02-19, only events
|
|
1023
|
-
* for published documents will be included by default (see {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog})
|
|
1024
|
-
* If you need events from drafts and versions, set this to `true`.
|
|
1025
|
-
* Note: Keep in mind that additional document variants may be introduced in the future, so it's
|
|
1026
|
-
* recommended to respond to events in a way that's tolerant of potential future variants, e.g. by
|
|
1027
|
-
* explicitly checking whether the event is for a draft or a version.
|
|
1028
|
-
* @defaultValue `false`
|
|
1029
|
-
*/
|
|
1030
|
-
includeAllVersions?: boolean
|
|
1031
|
-
/**
|
|
1032
|
-
* Whether events should be sent as soon as a transaction has been committed (`transaction`, default),
|
|
1033
|
-
* or only after they are available for queries (query). Note that this is on a best-effort basis,
|
|
1034
|
-
* and listeners with `query` may in certain cases (notably with deferred transactions) receive events
|
|
1035
|
-
* that are not yet visible to queries.
|
|
1036
|
-
*
|
|
1037
|
-
* @defaultValue `'transaction'`
|
|
1038
|
-
*/
|
|
1039
|
-
visibility?: 'transaction' | 'query'
|
|
1040
|
-
/**
|
|
1041
|
-
* Array of event names to include in the observable. By default, only mutation events are included.
|
|
1042
|
-
*
|
|
1043
|
-
* @defaultValue `['mutation']`
|
|
1044
|
-
*/
|
|
1045
|
-
events?: ListenEventName[]
|
|
1046
|
-
/**
|
|
1047
|
-
* Format of "effects", eg the resulting changes of a mutation.
|
|
1048
|
-
* Currently only `mendoza` is supported, and (if set) will include `apply` and `revert` arrays
|
|
1049
|
-
* in the mutation events under the `effects` property.
|
|
1050
|
-
*
|
|
1051
|
-
* See {@link https://github.com/sanity-io/mendoza | The mendoza docs} for more info
|
|
1052
|
-
*
|
|
1053
|
-
* @defaultValue `undefined`
|
|
1054
|
-
*/
|
|
1055
|
-
effectFormat?: 'mendoza'
|
|
1056
|
-
/**
|
|
1057
|
-
* Optional request tag for the listener. Use to identify the request in logs.
|
|
1058
|
-
*
|
|
1059
|
-
* @defaultValue `undefined`
|
|
1060
|
-
*/
|
|
1061
|
-
tag?: string
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
/** @public */
|
|
1065
|
-
declare type ListenParams = {
|
|
1066
|
-
[key: string]: Any
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* @public
|
|
1071
|
-
*/
|
|
1072
|
-
declare class LiveClient {
|
|
1073
|
-
#private
|
|
1074
|
-
constructor(client: SanityClient | ObservableSanityClient)
|
|
1075
|
-
/**
|
|
1076
|
-
* Requires `apiVersion` to be `2021-03-25` or later.
|
|
1077
|
-
*/
|
|
1078
|
-
events({
|
|
1079
|
-
includeDrafts,
|
|
1080
|
-
tag: _tag,
|
|
1081
|
-
}?: {
|
|
1082
|
-
includeDrafts?: boolean
|
|
1083
|
-
/**
|
|
1084
|
-
* Optional request tag for the listener. Use to identify the request in logs.
|
|
1085
|
-
*
|
|
1086
|
-
* @defaultValue `undefined`
|
|
1087
|
-
*/
|
|
1088
|
-
tag?: string
|
|
1089
|
-
}): Observable<LiveEvent>
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
/** @public */
|
|
1093
|
-
declare type LiveEvent = LiveEventRestart | LiveEventReconnect | LiveEventMessage | LiveEventWelcome
|
|
1094
|
-
|
|
1095
|
-
/** @public */
|
|
1096
|
-
declare interface LiveEventMessage {
|
|
1097
|
-
type: 'message'
|
|
1098
|
-
id: string
|
|
1099
|
-
tags: SyncTag[]
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
/** @public */
|
|
1103
|
-
declare interface LiveEventReconnect {
|
|
1104
|
-
type: 'reconnect'
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
/** @public */
|
|
1108
|
-
declare interface LiveEventRestart {
|
|
1109
|
-
type: 'restart'
|
|
1110
|
-
id: string
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
/** @public */
|
|
1114
|
-
declare interface LiveEventWelcome {
|
|
1115
|
-
type: 'welcome'
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
/** @public */
|
|
1119
|
-
declare type Logger =
|
|
1120
|
-
| typeof console
|
|
1121
|
-
| Partial<
|
|
1122
|
-
Pick<typeof console, 'debug' | 'error' | 'groupCollapsed' | 'groupEnd' | 'log' | 'table'>
|
|
1123
|
-
>
|
|
1124
|
-
|
|
1125
|
-
/**
|
|
1126
|
-
* @alpha
|
|
1127
|
-
*/
|
|
1128
|
-
declare type LoginErrorProps = FallbackProps & LoginLayoutProps
|
|
1129
|
-
|
|
1130
|
-
/**
|
|
1131
|
-
* @alpha
|
|
1132
|
-
*/
|
|
1133
|
-
declare interface LoginLayoutProps {
|
|
1134
|
-
/** Optional header content rendered at top of card */
|
|
1135
|
-
header?: React.ReactNode
|
|
1136
|
-
/** Optional footer content rendered below card. Defaults to an internal login footer */
|
|
1137
|
-
footer?: React.ReactNode
|
|
1138
|
-
/** Main content rendered in card body */
|
|
1139
|
-
children?: React.ReactNode
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
declare interface ManageFavorite {
|
|
1143
|
-
favorite: () => void
|
|
1144
|
-
unfavorite: () => void
|
|
1145
|
-
isFavorited: boolean
|
|
1146
|
-
isConnected: boolean
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
/**
|
|
1150
|
-
* @public
|
|
1151
|
-
*/
|
|
1152
|
-
declare type MessageData = Record<string, unknown> | undefined
|
|
1153
|
-
|
|
1154
|
-
/**
|
|
1155
|
-
* @internal
|
|
1156
|
-
*/
|
|
1157
|
-
export declare type MessageHandler<TWindowMessage extends WindowMessage> = (
|
|
1158
|
-
event: TWindowMessage['data'],
|
|
1159
|
-
) => TWindowMessage['response'] | Promise<TWindowMessage['response']>
|
|
1160
|
-
|
|
1161
|
-
/** @internal */
|
|
1162
|
-
declare interface MultipleActionResult {
|
|
1163
|
-
transactionId: string
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
/** @internal */
|
|
1167
|
-
declare interface MultipleMutationResult {
|
|
1168
|
-
transactionId: string
|
|
1169
|
-
documentIds: string[]
|
|
1170
|
-
results: {
|
|
1171
|
-
id: string
|
|
1172
|
-
operation: MutationOperation
|
|
1173
|
-
}[]
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
/** @public */
|
|
1177
|
-
declare type Mutation<R extends Record<string, Any> = Record<string, Any>> =
|
|
1178
|
-
| {
|
|
1179
|
-
create: SanityDocumentStub<R>
|
|
1180
|
-
}
|
|
1181
|
-
| {
|
|
1182
|
-
createOrReplace: IdentifiedSanityDocumentStub<R>
|
|
1183
|
-
}
|
|
1184
|
-
| {
|
|
1185
|
-
createIfNotExists: IdentifiedSanityDocumentStub<R>
|
|
1186
|
-
}
|
|
1187
|
-
| {
|
|
1188
|
-
delete: MutationSelection
|
|
1189
|
-
}
|
|
1190
|
-
| {
|
|
1191
|
-
patch: PatchMutationOperation
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
/**
|
|
1195
|
-
* A mutation was performed. Note that when updating multiple documents in a transaction,
|
|
1196
|
-
* each document affected will get a separate mutation event.
|
|
1197
|
-
*
|
|
1198
|
-
* @public
|
|
1199
|
-
*/
|
|
1200
|
-
declare type MutationEvent_2<R extends Record<string, Any> = Record<string, Any>> = {
|
|
1201
|
-
type: 'mutation'
|
|
1202
|
-
/**
|
|
1203
|
-
* The ID of the document that was affected
|
|
1204
|
-
*/
|
|
1205
|
-
documentId: string
|
|
1206
|
-
/**
|
|
1207
|
-
* A unique ID for this event
|
|
1208
|
-
*/
|
|
1209
|
-
eventId: string
|
|
1210
|
-
/**
|
|
1211
|
-
* The user ID of the user that performed the mutation
|
|
1212
|
-
*/
|
|
1213
|
-
identity: string
|
|
1214
|
-
/**
|
|
1215
|
-
* An array of mutations that were performed. Note that this can differ slightly from the
|
|
1216
|
-
* mutations sent to the server, as the server may perform some mutations automatically.
|
|
1217
|
-
*/
|
|
1218
|
-
mutations: Mutation[]
|
|
1219
|
-
/**
|
|
1220
|
-
* The revision ID of the document before the mutation was performed
|
|
1221
|
-
*/
|
|
1222
|
-
previousRev?: string
|
|
1223
|
-
/**
|
|
1224
|
-
* The revision ID of the document after the mutation was performed
|
|
1225
|
-
*/
|
|
1226
|
-
resultRev?: string
|
|
1227
|
-
/**
|
|
1228
|
-
* The document as it looked after the mutation was performed. This is only included if
|
|
1229
|
-
* the listener was configured with `includeResult: true`.
|
|
1230
|
-
*/
|
|
1231
|
-
result?: SanityDocument_2<R>
|
|
1232
|
-
/**
|
|
1233
|
-
* The document as it looked before the mutation was performed. This is only included if
|
|
1234
|
-
* the listener was configured with `includePreviousRevision: true`.
|
|
1235
|
-
*/
|
|
1236
|
-
previous?: SanityDocument_2<R> | null
|
|
1237
|
-
/**
|
|
1238
|
-
* The effects of the mutation, if the listener was configured with `effectFormat: 'mendoza'`.
|
|
1239
|
-
* Object with `apply` and `revert` arrays, see {@link https://github.com/sanity-io/mendoza}.
|
|
1240
|
-
*/
|
|
1241
|
-
effects?: {
|
|
1242
|
-
apply: unknown[]
|
|
1243
|
-
revert: unknown[]
|
|
1244
|
-
}
|
|
1245
|
-
/**
|
|
1246
|
-
* A timestamp for when the mutation was performed
|
|
1247
|
-
*/
|
|
1248
|
-
timestamp: string
|
|
1249
|
-
/**
|
|
1250
|
-
* The transaction ID for the mutation
|
|
1251
|
-
*/
|
|
1252
|
-
transactionId: string
|
|
1253
|
-
/**
|
|
1254
|
-
* The type of transition the document went through.
|
|
1255
|
-
*
|
|
1256
|
-
* - `update` means the document was previously part of the subscribed set of documents,
|
|
1257
|
-
* and still is.
|
|
1258
|
-
* - `appear` means the document was not previously part of the subscribed set of documents,
|
|
1259
|
-
* but is now. This can happen both on create or if updating to a state where it now matches
|
|
1260
|
-
* the filter provided to the listener.
|
|
1261
|
-
* - `disappear` means the document was previously part of the subscribed set of documents,
|
|
1262
|
-
* but is no longer. This can happen both on delete or if updating to a state where it no
|
|
1263
|
-
* longer matches the filter provided to the listener.
|
|
1264
|
-
*/
|
|
1265
|
-
transition: 'update' | 'appear' | 'disappear'
|
|
1266
|
-
/**
|
|
1267
|
-
* Whether the change that triggered this event is visible to queries (query) or only to
|
|
1268
|
-
* subsequent transactions (transaction). The listener client can specify a preferred visibility
|
|
1269
|
-
* through the `visibility` parameter on the listener, but this is only on a best-effort basis,
|
|
1270
|
-
* and may yet not be accurate.
|
|
1271
|
-
*/
|
|
1272
|
-
visibility: 'query' | 'transaction'
|
|
1273
|
-
/**
|
|
1274
|
-
* The total number of events that will be sent for this transaction.
|
|
1275
|
-
* Note that this may differ from the amount of _documents_ affected by the transaction, as this
|
|
1276
|
-
* number only includes the documents that matches the given filter.
|
|
1277
|
-
*
|
|
1278
|
-
* This can be useful if you need to perform changes to all matched documents atomically,
|
|
1279
|
-
* eg you would wait for `transactionTotalEvents` events with the same `transactionId` before
|
|
1280
|
-
* applying the changes locally.
|
|
1281
|
-
*/
|
|
1282
|
-
transactionTotalEvents: number
|
|
1283
|
-
/**
|
|
1284
|
-
* The index of this event within the transaction. Note that events may be delivered out of order,
|
|
1285
|
-
* and that the index is zero-based.
|
|
1286
|
-
*/
|
|
1287
|
-
transactionCurrentEvent: number
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
/** @internal */
|
|
1291
|
-
declare type MutationOperation = 'create' | 'delete' | 'update' | 'none'
|
|
1292
|
-
|
|
1293
|
-
/** @internal */
|
|
1294
|
-
declare type MutationSelection =
|
|
1295
|
-
| {
|
|
1296
|
-
query: string
|
|
1297
|
-
params?: MutationSelectionQueryParams
|
|
1298
|
-
}
|
|
1299
|
-
| {
|
|
1300
|
-
id: string | string[]
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
/** @internal */
|
|
1304
|
-
declare type MutationSelectionQueryParams = {
|
|
1305
|
-
[key: string]: Any
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
declare interface NavigateToStudioResult {
|
|
1309
|
-
navigateToStudioDocument: () => void
|
|
1310
|
-
isConnected: boolean
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
/** @internal */
|
|
1314
|
-
declare class ObservableAssetsClient {
|
|
1315
|
-
#private
|
|
1316
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1317
|
-
/**
|
|
1318
|
-
* Uploads a file asset to the configured dataset
|
|
1319
|
-
*
|
|
1320
|
-
* @param assetType - Asset type (file)
|
|
1321
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1322
|
-
* @param options - Options to use for the upload
|
|
1323
|
-
*/
|
|
1324
|
-
upload(
|
|
1325
|
-
assetType: 'file',
|
|
1326
|
-
body: UploadBody,
|
|
1327
|
-
options?: UploadClientConfig,
|
|
1328
|
-
): Observable<
|
|
1329
|
-
HttpRequestEvent<{
|
|
1330
|
-
document: SanityAssetDocument
|
|
1331
|
-
}>
|
|
1332
|
-
>
|
|
1333
|
-
/**
|
|
1334
|
-
* Uploads an image asset to the configured dataset
|
|
1335
|
-
*
|
|
1336
|
-
* @param assetType - Asset type (image)
|
|
1337
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1338
|
-
* @param options - Options to use for the upload
|
|
1339
|
-
*/
|
|
1340
|
-
upload(
|
|
1341
|
-
assetType: 'image',
|
|
1342
|
-
body: UploadBody,
|
|
1343
|
-
options?: UploadClientConfig,
|
|
1344
|
-
): Observable<
|
|
1345
|
-
HttpRequestEvent<{
|
|
1346
|
-
document: SanityImageAssetDocument
|
|
1347
|
-
}>
|
|
1348
|
-
>
|
|
1349
|
-
/**
|
|
1350
|
-
* Uploads a file or an image asset to the configured dataset
|
|
1351
|
-
*
|
|
1352
|
-
* @param assetType - Asset type (file/image)
|
|
1353
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1354
|
-
* @param options - Options to use for the upload
|
|
1355
|
-
*/
|
|
1356
|
-
upload(
|
|
1357
|
-
assetType: 'file' | 'image',
|
|
1358
|
-
body: UploadBody,
|
|
1359
|
-
options?: UploadClientConfig,
|
|
1360
|
-
): Observable<
|
|
1361
|
-
HttpRequestEvent<{
|
|
1362
|
-
document: SanityAssetDocument | SanityImageAssetDocument
|
|
1363
|
-
}>
|
|
1364
|
-
>
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
/** @internal */
|
|
1368
|
-
declare class ObservableDatasetsClient {
|
|
1369
|
-
#private
|
|
1370
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1371
|
-
/**
|
|
1372
|
-
* Create a new dataset with the given name
|
|
1373
|
-
*
|
|
1374
|
-
* @param name - Name of the dataset to create
|
|
1375
|
-
* @param options - Options for the dataset
|
|
1376
|
-
*/
|
|
1377
|
-
create(
|
|
1378
|
-
name: string,
|
|
1379
|
-
options?: {
|
|
1380
|
-
aclMode?: DatasetAclMode
|
|
1381
|
-
},
|
|
1382
|
-
): Observable<DatasetResponse>
|
|
1383
|
-
/**
|
|
1384
|
-
* Edit a dataset with the given name
|
|
1385
|
-
*
|
|
1386
|
-
* @param name - Name of the dataset to edit
|
|
1387
|
-
* @param options - New options for the dataset
|
|
1388
|
-
*/
|
|
1389
|
-
edit(
|
|
1390
|
-
name: string,
|
|
1391
|
-
options?: {
|
|
1392
|
-
aclMode?: DatasetAclMode
|
|
1393
|
-
},
|
|
1394
|
-
): Observable<DatasetResponse>
|
|
1395
|
-
/**
|
|
1396
|
-
* Delete a dataset with the given name
|
|
1397
|
-
*
|
|
1398
|
-
* @param name - Name of the dataset to delete
|
|
1399
|
-
*/
|
|
1400
|
-
delete(name: string): Observable<{
|
|
1401
|
-
deleted: true
|
|
1402
|
-
}>
|
|
1403
|
-
/**
|
|
1404
|
-
* Fetch a list of datasets for the configured project
|
|
1405
|
-
*/
|
|
1406
|
-
list(): Observable<DatasetsResponse>
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
/** @public */
|
|
1410
|
-
declare class ObservablePatch extends BasePatch {
|
|
1411
|
-
#private
|
|
1412
|
-
constructor(
|
|
1413
|
-
selection: PatchSelection,
|
|
1414
|
-
operations?: PatchOperations,
|
|
1415
|
-
client?: ObservableSanityClient,
|
|
1416
|
-
)
|
|
1417
|
-
/**
|
|
1418
|
-
* Clones the patch
|
|
1419
|
-
*/
|
|
1420
|
-
clone(): ObservablePatch
|
|
1421
|
-
/**
|
|
1422
|
-
* Commit the patch, returning an observable that produces the first patched document
|
|
1423
|
-
*
|
|
1424
|
-
* @param options - Options for the mutation operation
|
|
1425
|
-
*/
|
|
1426
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1427
|
-
options: FirstDocumentMutationOptions,
|
|
1428
|
-
): Observable<SanityDocument_2<R>>
|
|
1429
|
-
/**
|
|
1430
|
-
* Commit the patch, returning an observable that produces an array of the mutated documents
|
|
1431
|
-
*
|
|
1432
|
-
* @param options - Options for the mutation operation
|
|
1433
|
-
*/
|
|
1434
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1435
|
-
options: AllDocumentsMutationOptions,
|
|
1436
|
-
): Observable<SanityDocument_2<R>[]>
|
|
1437
|
-
/**
|
|
1438
|
-
* Commit the patch, returning an observable that produces a mutation result object
|
|
1439
|
-
*
|
|
1440
|
-
* @param options - Options for the mutation operation
|
|
1441
|
-
*/
|
|
1442
|
-
commit(options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
1443
|
-
/**
|
|
1444
|
-
* Commit the patch, returning an observable that produces a mutation result object
|
|
1445
|
-
*
|
|
1446
|
-
* @param options - Options for the mutation operation
|
|
1447
|
-
*/
|
|
1448
|
-
commit(options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
1449
|
-
/**
|
|
1450
|
-
* Commit the patch, returning an observable that produces the first patched document
|
|
1451
|
-
*
|
|
1452
|
-
* @param options - Options for the mutation operation
|
|
1453
|
-
*/
|
|
1454
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1455
|
-
options?: BaseMutationOptions,
|
|
1456
|
-
): Observable<SanityDocument_2<R>>
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
/** @public */
|
|
1460
|
-
declare type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch
|
|
1461
|
-
|
|
1462
|
-
/** @internal */
|
|
1463
|
-
declare class ObservableProjectsClient {
|
|
1464
|
-
#private
|
|
1465
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1466
|
-
/**
|
|
1467
|
-
* Fetch a list of projects the authenticated user has access to.
|
|
1468
|
-
*
|
|
1469
|
-
* @param options - Options for the list request
|
|
1470
|
-
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
1471
|
-
*/
|
|
1472
|
-
list(options?: {includeMembers?: true}): Observable<SanityProject[]>
|
|
1473
|
-
list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
|
|
1474
|
-
/**
|
|
1475
|
-
* Fetch a project by project ID
|
|
1476
|
-
*
|
|
1477
|
-
* @param projectId - ID of the project to fetch
|
|
1478
|
-
*/
|
|
1479
|
-
getById(projectId: string): Observable<SanityProject>
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
/** @public */
|
|
1483
|
-
declare class ObservableSanityClient {
|
|
1484
|
-
#private
|
|
1485
|
-
assets: ObservableAssetsClient
|
|
1486
|
-
datasets: ObservableDatasetsClient
|
|
1487
|
-
live: LiveClient
|
|
1488
|
-
projects: ObservableProjectsClient
|
|
1489
|
-
users: ObservableUsersClient
|
|
1490
|
-
/**
|
|
1491
|
-
* Instance properties
|
|
1492
|
-
*/
|
|
1493
|
-
listen: typeof _listen
|
|
1494
|
-
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1495
|
-
/**
|
|
1496
|
-
* Clone the client - returns a new instance
|
|
1497
|
-
*/
|
|
1498
|
-
clone(): ObservableSanityClient
|
|
1499
|
-
/**
|
|
1500
|
-
* Returns the current client configuration
|
|
1501
|
-
*/
|
|
1502
|
-
config(): InitializedClientConfig
|
|
1503
|
-
/**
|
|
1504
|
-
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
1505
|
-
*/
|
|
1506
|
-
config(newConfig?: Partial<ClientConfig>): this
|
|
1507
|
-
/**
|
|
1508
|
-
* Clone the client with a new (partial) configuration.
|
|
1509
|
-
*
|
|
1510
|
-
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
1511
|
-
*/
|
|
1512
|
-
withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
|
|
1513
|
-
/**
|
|
1514
|
-
* Perform a GROQ-query against the configured dataset.
|
|
1515
|
-
*
|
|
1516
|
-
* @param query - GROQ-query to perform
|
|
1517
|
-
*/
|
|
1518
|
-
fetch<
|
|
1519
|
-
R = Any,
|
|
1520
|
-
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
1521
|
-
const G extends string = string,
|
|
1522
|
-
>(query: G, params?: Q | QueryWithoutParams): Observable<ClientReturn<G, R>>
|
|
1523
|
-
/**
|
|
1524
|
-
* Perform a GROQ-query against the configured dataset.
|
|
1525
|
-
*
|
|
1526
|
-
* @param query - GROQ-query to perform
|
|
1527
|
-
* @param params - Optional query parameters
|
|
1528
|
-
* @param options - Optional request options
|
|
1529
|
-
*/
|
|
1530
|
-
fetch<
|
|
1531
|
-
R = Any,
|
|
1532
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1533
|
-
const G extends string = string,
|
|
1534
|
-
>(
|
|
1535
|
-
query: G,
|
|
1536
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1537
|
-
options?: FilteredResponseQueryOptions,
|
|
1538
|
-
): Observable<ClientReturn<G, R>>
|
|
1539
|
-
/**
|
|
1540
|
-
* Perform a GROQ-query against the configured dataset.
|
|
1541
|
-
*
|
|
1542
|
-
* @param query - GROQ-query to perform
|
|
1543
|
-
* @param params - Optional query parameters
|
|
1544
|
-
* @param options - Request options
|
|
1545
|
-
*/
|
|
1546
|
-
fetch<
|
|
1547
|
-
R = Any,
|
|
1548
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1549
|
-
const G extends string = string,
|
|
1550
|
-
>(
|
|
1551
|
-
query: string,
|
|
1552
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1553
|
-
options: UnfilteredResponseQueryOptions,
|
|
1554
|
-
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
1555
|
-
/**
|
|
1556
|
-
* Perform a GROQ-query against the configured dataset.
|
|
1557
|
-
*
|
|
1558
|
-
* @param query - GROQ-query to perform
|
|
1559
|
-
* @param params - Optional query parameters
|
|
1560
|
-
* @param options - Request options
|
|
1561
|
-
*/
|
|
1562
|
-
fetch<
|
|
1563
|
-
R = Any,
|
|
1564
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1565
|
-
const G extends string = string,
|
|
1566
|
-
>(
|
|
1567
|
-
query: G,
|
|
1568
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1569
|
-
options: UnfilteredResponseWithoutQuery,
|
|
1570
|
-
): Observable<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
1571
|
-
/**
|
|
1572
|
-
* Fetch a single document with the given ID.
|
|
1573
|
-
*
|
|
1574
|
-
* @param id - Document ID to fetch
|
|
1575
|
-
* @param options - Request options
|
|
1576
|
-
*/
|
|
1577
|
-
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
1578
|
-
id: string,
|
|
1579
|
-
options?: {
|
|
1580
|
-
tag?: string
|
|
1581
|
-
},
|
|
1582
|
-
): Observable<SanityDocument_2<R> | undefined>
|
|
1583
|
-
/**
|
|
1584
|
-
* Fetch multiple documents in one request.
|
|
1585
|
-
* Should be used sparingly - performing a query is usually a better option.
|
|
1586
|
-
* The order/position of documents is preserved based on the original array of IDs.
|
|
1587
|
-
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1588
|
-
*
|
|
1589
|
-
* @param ids - Document IDs to fetch
|
|
1590
|
-
* @param options - Request options
|
|
1591
|
-
*/
|
|
1592
|
-
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
1593
|
-
ids: string[],
|
|
1594
|
-
options?: {
|
|
1595
|
-
tag?: string
|
|
1596
|
-
},
|
|
1597
|
-
): Observable<(SanityDocument_2<R> | null)[]>
|
|
1598
|
-
/**
|
|
1599
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1600
|
-
* Returns an observable that resolves to the created document.
|
|
1601
|
-
*
|
|
1602
|
-
* @param document - Document to create
|
|
1603
|
-
* @param options - Mutation options
|
|
1604
|
-
*/
|
|
1605
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1606
|
-
document: SanityDocumentStub<R>,
|
|
1607
|
-
options: FirstDocumentMutationOptions,
|
|
1608
|
-
): Observable<SanityDocument_2<R>>
|
|
1609
|
-
/**
|
|
1610
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1611
|
-
* Returns an observable that resolves to an array containing the created document.
|
|
1612
|
-
*
|
|
1613
|
-
* @param document - Document to create
|
|
1614
|
-
* @param options - Mutation options
|
|
1615
|
-
*/
|
|
1616
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1617
|
-
document: SanityDocumentStub<R>,
|
|
1618
|
-
options: AllDocumentsMutationOptions,
|
|
1619
|
-
): Observable<SanityDocument_2<R>[]>
|
|
1620
|
-
/**
|
|
1621
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1622
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1623
|
-
*
|
|
1624
|
-
* @param document - Document to create
|
|
1625
|
-
* @param options - Mutation options
|
|
1626
|
-
*/
|
|
1627
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1628
|
-
document: SanityDocumentStub<R>,
|
|
1629
|
-
options: FirstDocumentIdMutationOptions,
|
|
1630
|
-
): Observable<SingleMutationResult>
|
|
1631
|
-
/**
|
|
1632
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1633
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1634
|
-
*
|
|
1635
|
-
* @param document - Document to create
|
|
1636
|
-
* @param options - Mutation options
|
|
1637
|
-
*/
|
|
1638
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1639
|
-
document: SanityDocumentStub<R>,
|
|
1640
|
-
options: AllDocumentIdsMutationOptions,
|
|
1641
|
-
): Observable<MultipleMutationResult>
|
|
1642
|
-
/**
|
|
1643
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1644
|
-
* Returns an observable that resolves to the created document.
|
|
1645
|
-
*
|
|
1646
|
-
* @param document - Document to create
|
|
1647
|
-
* @param options - Mutation options
|
|
1648
|
-
*/
|
|
1649
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1650
|
-
document: SanityDocumentStub<R>,
|
|
1651
|
-
options?: BaseMutationOptions,
|
|
1652
|
-
): Observable<SanityDocument_2<R>>
|
|
1653
|
-
/**
|
|
1654
|
-
* Create a document if no document with the same ID already exists.
|
|
1655
|
-
* Returns an observable that resolves to the created document.
|
|
1656
|
-
*
|
|
1657
|
-
* @param document - Document to create
|
|
1658
|
-
* @param options - Mutation options
|
|
1659
|
-
*/
|
|
1660
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1661
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1662
|
-
options: FirstDocumentMutationOptions,
|
|
1663
|
-
): Observable<SanityDocument_2<R>>
|
|
1664
|
-
/**
|
|
1665
|
-
* Create a document if no document with the same ID already exists.
|
|
1666
|
-
* Returns an observable that resolves to an array containing the created document.
|
|
1667
|
-
*
|
|
1668
|
-
* @param document - Document to create
|
|
1669
|
-
* @param options - Mutation options
|
|
1670
|
-
*/
|
|
1671
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1672
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1673
|
-
options: AllDocumentsMutationOptions,
|
|
1674
|
-
): Observable<SanityDocument_2<R>[]>
|
|
1675
|
-
/**
|
|
1676
|
-
* Create a document if no document with the same ID already exists.
|
|
1677
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1678
|
-
*
|
|
1679
|
-
* @param document - Document to create
|
|
1680
|
-
* @param options - Mutation options
|
|
1681
|
-
*/
|
|
1682
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1683
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1684
|
-
options: FirstDocumentIdMutationOptions,
|
|
1685
|
-
): Observable<SingleMutationResult>
|
|
1686
|
-
/**
|
|
1687
|
-
* Create a document if no document with the same ID already exists.
|
|
1688
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1689
|
-
*
|
|
1690
|
-
* @param document - Document to create
|
|
1691
|
-
* @param options - Mutation options
|
|
1692
|
-
*/
|
|
1693
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1694
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1695
|
-
options: AllDocumentIdsMutationOptions,
|
|
1696
|
-
): Observable<MultipleMutationResult>
|
|
1697
|
-
/**
|
|
1698
|
-
* Create a document if no document with the same ID already exists.
|
|
1699
|
-
* Returns an observable that resolves to the created document.
|
|
1700
|
-
*
|
|
1701
|
-
* @param document - Document to create
|
|
1702
|
-
* @param options - Mutation options
|
|
1703
|
-
*/
|
|
1704
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1705
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1706
|
-
options?: BaseMutationOptions,
|
|
1707
|
-
): Observable<SanityDocument_2<R>>
|
|
1708
|
-
/**
|
|
1709
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1710
|
-
* Returns an observable that resolves to the created document.
|
|
1711
|
-
*
|
|
1712
|
-
* @param document - Document to either create or replace
|
|
1713
|
-
* @param options - Mutation options
|
|
1714
|
-
*/
|
|
1715
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1716
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1717
|
-
options: FirstDocumentMutationOptions,
|
|
1718
|
-
): Observable<SanityDocument_2<R>>
|
|
1719
|
-
/**
|
|
1720
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1721
|
-
* Returns an observable that resolves to an array containing the created document.
|
|
1722
|
-
*
|
|
1723
|
-
* @param document - Document to either create or replace
|
|
1724
|
-
* @param options - Mutation options
|
|
1725
|
-
*/
|
|
1726
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1727
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1728
|
-
options: AllDocumentsMutationOptions,
|
|
1729
|
-
): Observable<SanityDocument_2<R>[]>
|
|
1730
|
-
/**
|
|
1731
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1732
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1733
|
-
*
|
|
1734
|
-
* @param document - Document to either create or replace
|
|
1735
|
-
* @param options - Mutation options
|
|
1736
|
-
*/
|
|
1737
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1738
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1739
|
-
options: FirstDocumentIdMutationOptions,
|
|
1740
|
-
): Observable<SingleMutationResult>
|
|
1741
|
-
/**
|
|
1742
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1743
|
-
* Returns an observable that resolves to a mutation result object containing the created document ID.
|
|
1744
|
-
*
|
|
1745
|
-
* @param document - Document to either create or replace
|
|
1746
|
-
* @param options - Mutation options
|
|
1747
|
-
*/
|
|
1748
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1749
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1750
|
-
options: AllDocumentIdsMutationOptions,
|
|
1751
|
-
): Observable<MultipleMutationResult>
|
|
1752
|
-
/**
|
|
1753
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1754
|
-
* Returns an observable that resolves to the created document.
|
|
1755
|
-
*
|
|
1756
|
-
* @param document - Document to either create or replace
|
|
1757
|
-
* @param options - Mutation options
|
|
1758
|
-
*/
|
|
1759
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1760
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
1761
|
-
options?: BaseMutationOptions,
|
|
1762
|
-
): Observable<SanityDocument_2<R>>
|
|
1763
|
-
/**
|
|
1764
|
-
* Deletes a document with the given document ID.
|
|
1765
|
-
* Returns an observable that resolves to the deleted document.
|
|
1766
|
-
*
|
|
1767
|
-
* @param id - Document ID to delete
|
|
1768
|
-
* @param options - Options for the mutation
|
|
1769
|
-
*/
|
|
1770
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1771
|
-
id: string,
|
|
1772
|
-
options: FirstDocumentMutationOptions,
|
|
1773
|
-
): Observable<SanityDocument_2<R>>
|
|
1774
|
-
/**
|
|
1775
|
-
* Deletes a document with the given document ID.
|
|
1776
|
-
* Returns an observable that resolves to an array containing the deleted document.
|
|
1777
|
-
*
|
|
1778
|
-
* @param id - Document ID to delete
|
|
1779
|
-
* @param options - Options for the mutation
|
|
1780
|
-
*/
|
|
1781
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1782
|
-
id: string,
|
|
1783
|
-
options: AllDocumentsMutationOptions,
|
|
1784
|
-
): Observable<SanityDocument_2<R>[]>
|
|
1785
|
-
/**
|
|
1786
|
-
* Deletes a document with the given document ID.
|
|
1787
|
-
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
1788
|
-
*
|
|
1789
|
-
* @param id - Document ID to delete
|
|
1790
|
-
* @param options - Options for the mutation
|
|
1791
|
-
*/
|
|
1792
|
-
delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
1793
|
-
/**
|
|
1794
|
-
* Deletes a document with the given document ID.
|
|
1795
|
-
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
1796
|
-
*
|
|
1797
|
-
* @param id - Document ID to delete
|
|
1798
|
-
* @param options - Options for the mutation
|
|
1799
|
-
*/
|
|
1800
|
-
delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
1801
|
-
/**
|
|
1802
|
-
* Deletes a document with the given document ID.
|
|
1803
|
-
* Returns an observable that resolves to the deleted document.
|
|
1804
|
-
*
|
|
1805
|
-
* @param id - Document ID to delete
|
|
1806
|
-
* @param options - Options for the mutation
|
|
1807
|
-
*/
|
|
1808
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1809
|
-
id: string,
|
|
1810
|
-
options?: BaseMutationOptions,
|
|
1811
|
-
): Observable<SanityDocument_2<R>>
|
|
1812
|
-
/**
|
|
1813
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
1814
|
-
* Returns an observable that resolves to first deleted document.
|
|
1815
|
-
*
|
|
1816
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1817
|
-
* @param options - Options for the mutation
|
|
1818
|
-
*/
|
|
1819
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1820
|
-
selection: MutationSelection,
|
|
1821
|
-
options: FirstDocumentMutationOptions,
|
|
1822
|
-
): Observable<SanityDocument_2<R>>
|
|
1823
|
-
/**
|
|
1824
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
1825
|
-
* Returns an observable that resolves to an array containing the deleted documents.
|
|
1826
|
-
*
|
|
1827
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1828
|
-
* @param options - Options for the mutation
|
|
1829
|
-
*/
|
|
1830
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1831
|
-
selection: MutationSelection,
|
|
1832
|
-
options: AllDocumentsMutationOptions,
|
|
1833
|
-
): Observable<SanityDocument_2<R>[]>
|
|
1834
|
-
/**
|
|
1835
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
1836
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
|
|
1837
|
-
*
|
|
1838
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1839
|
-
* @param options - Options for the mutation
|
|
1840
|
-
*/
|
|
1841
|
-
delete(
|
|
1842
|
-
selection: MutationSelection,
|
|
1843
|
-
options: FirstDocumentIdMutationOptions,
|
|
1844
|
-
): Observable<SingleMutationResult>
|
|
1845
|
-
/**
|
|
1846
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
1847
|
-
* Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
|
|
1848
|
-
*
|
|
1849
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1850
|
-
* @param options - Options for the mutation
|
|
1851
|
-
*/
|
|
1852
|
-
delete(
|
|
1853
|
-
selection: MutationSelection,
|
|
1854
|
-
options: AllDocumentIdsMutationOptions,
|
|
1855
|
-
): Observable<MultipleMutationResult>
|
|
1856
|
-
/**
|
|
1857
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
1858
|
-
* Returns an observable that resolves to first deleted document.
|
|
1859
|
-
*
|
|
1860
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1861
|
-
* @param options - Options for the mutation
|
|
1862
|
-
*/
|
|
1863
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1864
|
-
selection: MutationSelection,
|
|
1865
|
-
options?: BaseMutationOptions,
|
|
1866
|
-
): Observable<SanityDocument_2<R>>
|
|
1867
|
-
/**
|
|
1868
|
-
* Perform mutation operations against the configured dataset
|
|
1869
|
-
* Returns an observable that resolves to the first mutated document.
|
|
1870
|
-
*
|
|
1871
|
-
* @param operations - Mutation operations to execute
|
|
1872
|
-
* @param options - Mutation options
|
|
1873
|
-
*/
|
|
1874
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1875
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1876
|
-
options: FirstDocumentMutationOptions,
|
|
1877
|
-
): Observable<SanityDocument_2<R>>
|
|
1878
|
-
/**
|
|
1879
|
-
* Perform mutation operations against the configured dataset.
|
|
1880
|
-
* Returns an observable that resolves to an array of the mutated documents.
|
|
1881
|
-
*
|
|
1882
|
-
* @param operations - Mutation operations to execute
|
|
1883
|
-
* @param options - Mutation options
|
|
1884
|
-
*/
|
|
1885
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1886
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1887
|
-
options: AllDocumentsMutationOptions,
|
|
1888
|
-
): Observable<SanityDocument_2<R>[]>
|
|
1889
|
-
/**
|
|
1890
|
-
* Perform mutation operations against the configured dataset
|
|
1891
|
-
* Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
1892
|
-
*
|
|
1893
|
-
* @param operations - Mutation operations to execute
|
|
1894
|
-
* @param options - Mutation options
|
|
1895
|
-
*/
|
|
1896
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1897
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1898
|
-
options: FirstDocumentIdMutationOptions,
|
|
1899
|
-
): Observable<SingleMutationResult>
|
|
1900
|
-
/**
|
|
1901
|
-
* Perform mutation operations against the configured dataset
|
|
1902
|
-
* Returns an observable that resolves to a mutation result object containing the mutated document IDs.
|
|
1903
|
-
*
|
|
1904
|
-
* @param operations - Mutation operations to execute
|
|
1905
|
-
* @param options - Mutation options
|
|
1906
|
-
*/
|
|
1907
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1908
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1909
|
-
options: AllDocumentIdsMutationOptions,
|
|
1910
|
-
): Observable<MultipleMutationResult>
|
|
1911
|
-
/**
|
|
1912
|
-
* Perform mutation operations against the configured dataset
|
|
1913
|
-
* Returns an observable that resolves to the first mutated document.
|
|
1914
|
-
*
|
|
1915
|
-
* @param operations - Mutation operations to execute
|
|
1916
|
-
* @param options - Mutation options
|
|
1917
|
-
*/
|
|
1918
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1919
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1920
|
-
options?: BaseMutationOptions,
|
|
1921
|
-
): Observable<SanityDocument_2<R>>
|
|
1922
|
-
/**
|
|
1923
|
-
* Create a new buildable patch of operations to perform
|
|
1924
|
-
*
|
|
1925
|
-
* @param documentId - Document ID to patch
|
|
1926
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1927
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
1928
|
-
*/
|
|
1929
|
-
patch(documentId: string, operations?: PatchOperations): ObservablePatch
|
|
1930
|
-
/**
|
|
1931
|
-
* Create a new buildable patch of operations to perform
|
|
1932
|
-
*
|
|
1933
|
-
* @param documentIds - Array of document IDs to patch
|
|
1934
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1935
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
1936
|
-
*/
|
|
1937
|
-
patch(documentIds: string[], operations?: PatchOperations): ObservablePatch
|
|
1938
|
-
/**
|
|
1939
|
-
* Create a new buildable patch of operations to perform
|
|
1940
|
-
*
|
|
1941
|
-
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
1942
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1943
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
1944
|
-
*/
|
|
1945
|
-
patch(selection: MutationSelection, operations?: PatchOperations): ObservablePatch
|
|
1946
|
-
/**
|
|
1947
|
-
* Create a new transaction of mutations
|
|
1948
|
-
*
|
|
1949
|
-
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
1950
|
-
*/
|
|
1951
|
-
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
1952
|
-
operations?: Mutation<R>[],
|
|
1953
|
-
): ObservableTransaction
|
|
1954
|
-
/**
|
|
1955
|
-
* Perform action operations against the configured dataset
|
|
1956
|
-
*
|
|
1957
|
-
* @param operations - Action operation(s) to execute
|
|
1958
|
-
* @param options - Action options
|
|
1959
|
-
*/
|
|
1960
|
-
action(
|
|
1961
|
-
operations: Action | Action[],
|
|
1962
|
-
options?: BaseActionOptions,
|
|
1963
|
-
): Observable<SingleActionResult | MultipleActionResult>
|
|
1964
|
-
/**
|
|
1965
|
-
* Perform an HTTP request against the Sanity API
|
|
1966
|
-
*
|
|
1967
|
-
* @param options - Request options
|
|
1968
|
-
*/
|
|
1969
|
-
request<R = Any>(options: RawRequestOptions): Observable<R>
|
|
1970
|
-
/**
|
|
1971
|
-
* Get a Sanity API URL for the URI provided
|
|
1972
|
-
*
|
|
1973
|
-
* @param uri - URI/path to build URL for
|
|
1974
|
-
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
1975
|
-
*/
|
|
1976
|
-
getUrl(uri: string, canUseCdn?: boolean): string
|
|
1977
|
-
/**
|
|
1978
|
-
* Get a Sanity API URL for the data operation and path provided
|
|
1979
|
-
*
|
|
1980
|
-
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
1981
|
-
* @param path - Path to append after the operation
|
|
1982
|
-
*/
|
|
1983
|
-
getDataUrl(operation: string, path?: string): string
|
|
1984
|
-
}
|
|
1985
|
-
|
|
1986
|
-
/** @public */
|
|
1987
|
-
declare class ObservableTransaction extends BaseTransaction {
|
|
1988
|
-
#private
|
|
1989
|
-
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
|
|
1990
|
-
/**
|
|
1991
|
-
* Clones the transaction
|
|
1992
|
-
*/
|
|
1993
|
-
clone(): ObservableTransaction
|
|
1994
|
-
/**
|
|
1995
|
-
* Commit the transaction, returning an observable that produces the first mutated document
|
|
1996
|
-
*
|
|
1997
|
-
* @param options - Options for the mutation operation
|
|
1998
|
-
*/
|
|
1999
|
-
commit<R extends Record<string, Any>>(
|
|
2000
|
-
options: TransactionFirstDocumentMutationOptions,
|
|
2001
|
-
): Observable<SanityDocument_2<R>>
|
|
2002
|
-
/**
|
|
2003
|
-
* Commit the transaction, returning an observable that produces an array of the mutated documents
|
|
2004
|
-
*
|
|
2005
|
-
* @param options - Options for the mutation operation
|
|
2006
|
-
*/
|
|
2007
|
-
commit<R extends Record<string, Any>>(
|
|
2008
|
-
options: TransactionAllDocumentsMutationOptions,
|
|
2009
|
-
): Observable<SanityDocument_2<R>[]>
|
|
2010
|
-
/**
|
|
2011
|
-
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2012
|
-
*
|
|
2013
|
-
* @param options - Options for the mutation operation
|
|
2014
|
-
*/
|
|
2015
|
-
commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2016
|
-
/**
|
|
2017
|
-
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2018
|
-
*
|
|
2019
|
-
* @param options - Options for the mutation operation
|
|
2020
|
-
*/
|
|
2021
|
-
commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2022
|
-
/**
|
|
2023
|
-
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2024
|
-
*
|
|
2025
|
-
* @param options - Options for the mutation operation
|
|
2026
|
-
*/
|
|
2027
|
-
commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
|
|
2028
|
-
/**
|
|
2029
|
-
* Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
|
|
2030
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2031
|
-
*
|
|
2032
|
-
* @param documentId - Document ID to perform the patch operation on
|
|
2033
|
-
* @param patchOps - Operations to perform, or a builder function
|
|
2034
|
-
*/
|
|
2035
|
-
patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this
|
|
2036
|
-
/**
|
|
2037
|
-
* Adds the given patch instance to the transaction.
|
|
2038
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2039
|
-
*
|
|
2040
|
-
* @param patch - ObservablePatch to execute
|
|
2041
|
-
*/
|
|
2042
|
-
patch(patch: ObservablePatch): this
|
|
2043
|
-
}
|
|
2044
|
-
|
|
2045
|
-
/** @public */
|
|
2046
|
-
declare class ObservableUsersClient {
|
|
2047
|
-
#private
|
|
2048
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
2049
|
-
/**
|
|
2050
|
-
* Fetch a user by user ID
|
|
2051
|
-
*
|
|
2052
|
-
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
2053
|
-
*/
|
|
2054
|
-
getById<T extends 'me' | string>(
|
|
2055
|
-
id: T,
|
|
2056
|
-
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
/**
|
|
2060
|
-
* The listener connection has been established
|
|
2061
|
-
* note: it's usually a better option to use the 'welcome' event
|
|
2062
|
-
* @public
|
|
2063
|
-
*/
|
|
2064
|
-
declare type OpenEvent = {
|
|
2065
|
-
type: 'open'
|
|
2066
|
-
}
|
|
2067
|
-
|
|
2068
|
-
/**
|
|
2069
|
-
* Configuration options for the usePaginatedDocuments hook
|
|
2070
|
-
*
|
|
2071
|
-
* @beta
|
|
2072
|
-
* @category Types
|
|
2073
|
-
*/
|
|
2074
|
-
export declare interface PaginatedDocumentsOptions extends QueryOptions {
|
|
2075
|
-
/**
|
|
2076
|
-
* GROQ filter expression to apply to the query
|
|
2077
|
-
*/
|
|
2078
|
-
filter?: string
|
|
2079
|
-
/**
|
|
2080
|
-
* Number of items to display per page (defaults to 25)
|
|
2081
|
-
*/
|
|
2082
|
-
pageSize?: number
|
|
2083
|
-
/**
|
|
2084
|
-
* Sorting configuration for the results
|
|
2085
|
-
*/
|
|
2086
|
-
orderings?: SortOrderingItem[]
|
|
2087
|
-
/**
|
|
2088
|
-
* Text search query to filter results
|
|
2089
|
-
*/
|
|
2090
|
-
search?: string
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
|
-
/**
|
|
2094
|
-
* Return value from the usePaginatedDocuments hook
|
|
2095
|
-
*
|
|
2096
|
-
* @beta
|
|
2097
|
-
* @category Types
|
|
2098
|
-
*/
|
|
2099
|
-
export declare interface PaginatedDocumentsResponse {
|
|
2100
|
-
/**
|
|
2101
|
-
* Array of document handles for the current page
|
|
2102
|
-
*/
|
|
2103
|
-
data: DocumentHandle[]
|
|
2104
|
-
/**
|
|
2105
|
-
* Whether a query is currently in progress
|
|
2106
|
-
*/
|
|
2107
|
-
isPending: boolean
|
|
2108
|
-
/**
|
|
2109
|
-
* Number of items displayed per page
|
|
2110
|
-
*/
|
|
2111
|
-
pageSize: number
|
|
2112
|
-
/**
|
|
2113
|
-
* Current page number (1-indexed)
|
|
2114
|
-
*/
|
|
2115
|
-
currentPage: number
|
|
2116
|
-
/**
|
|
2117
|
-
* Total number of pages available
|
|
2118
|
-
*/
|
|
2119
|
-
totalPages: number
|
|
2120
|
-
/**
|
|
2121
|
-
* Starting index of the current page (0-indexed)
|
|
2122
|
-
*/
|
|
2123
|
-
startIndex: number
|
|
2124
|
-
/**
|
|
2125
|
-
* Ending index of the current page (exclusive, 0-indexed)
|
|
2126
|
-
*/
|
|
2127
|
-
endIndex: number
|
|
2128
|
-
/**
|
|
2129
|
-
* Total count of items matching the query
|
|
2130
|
-
*/
|
|
2131
|
-
count: number
|
|
2132
|
-
/**
|
|
2133
|
-
* Navigate to the first page
|
|
2134
|
-
*/
|
|
2135
|
-
firstPage: () => void
|
|
2136
|
-
/**
|
|
2137
|
-
* Whether there is a first page available to navigate to
|
|
2138
|
-
*/
|
|
2139
|
-
hasFirstPage: boolean
|
|
2140
|
-
/**
|
|
2141
|
-
* Navigate to the previous page
|
|
2142
|
-
*/
|
|
2143
|
-
previousPage: () => void
|
|
2144
|
-
/**
|
|
2145
|
-
* Whether there is a previous page available to navigate to
|
|
2146
|
-
*/
|
|
2147
|
-
hasPreviousPage: boolean
|
|
2148
|
-
/**
|
|
2149
|
-
* Navigate to the next page
|
|
2150
|
-
*/
|
|
2151
|
-
nextPage: () => void
|
|
2152
|
-
/**
|
|
2153
|
-
* Whether there is a next page available to navigate to
|
|
2154
|
-
*/
|
|
2155
|
-
hasNextPage: boolean
|
|
2156
|
-
/**
|
|
2157
|
-
* Navigate to the last page
|
|
2158
|
-
*/
|
|
2159
|
-
lastPage: () => void
|
|
2160
|
-
/**
|
|
2161
|
-
* Whether there is a last page available to navigate to
|
|
2162
|
-
*/
|
|
2163
|
-
hasLastPage: boolean
|
|
2164
|
-
/**
|
|
2165
|
-
* Navigate to a specific page number
|
|
2166
|
-
* @param pageNumber - The page number to navigate to (1-indexed)
|
|
2167
|
-
*/
|
|
2168
|
-
goToPage: (pageNumber: number) => void
|
|
2169
|
-
}
|
|
2170
|
-
|
|
2171
|
-
/** @public */
|
|
2172
|
-
declare class Patch extends BasePatch {
|
|
2173
|
-
#private
|
|
2174
|
-
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
|
|
2175
|
-
/**
|
|
2176
|
-
* Clones the patch
|
|
2177
|
-
*/
|
|
2178
|
-
clone(): Patch
|
|
2179
|
-
/**
|
|
2180
|
-
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2181
|
-
*
|
|
2182
|
-
* @param options - Options for the mutation operation
|
|
2183
|
-
*/
|
|
2184
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2185
|
-
options: FirstDocumentMutationOptions,
|
|
2186
|
-
): Promise<SanityDocument_2<R>>
|
|
2187
|
-
/**
|
|
2188
|
-
* Commit the patch, returning a promise that resolves to an array of the mutated documents
|
|
2189
|
-
*
|
|
2190
|
-
* @param options - Options for the mutation operation
|
|
2191
|
-
*/
|
|
2192
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2193
|
-
options: AllDocumentsMutationOptions,
|
|
2194
|
-
): Promise<SanityDocument_2<R>[]>
|
|
2195
|
-
/**
|
|
2196
|
-
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2197
|
-
*
|
|
2198
|
-
* @param options - Options for the mutation operation
|
|
2199
|
-
*/
|
|
2200
|
-
commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
2201
|
-
/**
|
|
2202
|
-
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2203
|
-
*
|
|
2204
|
-
* @param options - Options for the mutation operation
|
|
2205
|
-
*/
|
|
2206
|
-
commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
2207
|
-
/**
|
|
2208
|
-
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2209
|
-
*
|
|
2210
|
-
* @param options - Options for the mutation operation
|
|
2211
|
-
*/
|
|
2212
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2213
|
-
options?: BaseMutationOptions,
|
|
2214
|
-
): Promise<SanityDocument_2<R>>
|
|
2215
|
-
}
|
|
2216
|
-
|
|
2217
|
-
/** @public */
|
|
2218
|
-
declare type PatchBuilder = (patch: Patch) => Patch
|
|
2219
|
-
|
|
2220
|
-
/** @internal */
|
|
2221
|
-
declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
2222
|
-
|
|
2223
|
-
/** @internal */
|
|
2224
|
-
declare interface PatchOperations {
|
|
2225
|
-
set?: {
|
|
2226
|
-
[key: string]: Any
|
|
2227
|
-
}
|
|
2228
|
-
setIfMissing?: {
|
|
2229
|
-
[key: string]: Any
|
|
2230
|
-
}
|
|
2231
|
-
diffMatchPatch?: {
|
|
2232
|
-
[key: string]: Any
|
|
2233
|
-
}
|
|
2234
|
-
unset?: string[]
|
|
2235
|
-
inc?: {
|
|
2236
|
-
[key: string]: number
|
|
2237
|
-
}
|
|
2238
|
-
dec?: {
|
|
2239
|
-
[key: string]: number
|
|
2240
|
-
}
|
|
2241
|
-
insert?: InsertPatch
|
|
2242
|
-
ifRevisionID?: string
|
|
2243
|
-
}
|
|
2244
|
-
|
|
2245
|
-
/** @internal */
|
|
2246
|
-
declare type PatchSelection = string | string[] | MutationSelection
|
|
2247
|
-
|
|
2248
|
-
/** @public */
|
|
2249
|
-
declare interface ProgressEvent_2 {
|
|
2250
|
-
type: 'progress'
|
|
2251
|
-
stage: 'upload' | 'download'
|
|
2252
|
-
percent: number
|
|
2253
|
-
total?: number
|
|
2254
|
-
loaded?: number
|
|
2255
|
-
lengthComputable: boolean
|
|
2256
|
-
}
|
|
2257
|
-
|
|
2258
|
-
/** @internal */
|
|
2259
|
-
declare class ProjectsClient {
|
|
2260
|
-
#private
|
|
2261
|
-
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
2262
|
-
/**
|
|
2263
|
-
* Fetch a list of projects the authenticated user has access to.
|
|
2264
|
-
*
|
|
2265
|
-
* @param options - Options for the list request
|
|
2266
|
-
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
2267
|
-
*/
|
|
2268
|
-
list(options?: {includeMembers?: true}): Promise<SanityProject[]>
|
|
2269
|
-
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
2270
|
-
/**
|
|
2271
|
-
* Fetch a project by project ID
|
|
2272
|
-
*
|
|
2273
|
-
* @param projectId - ID of the project to fetch
|
|
2274
|
-
*/
|
|
2275
|
-
getById(projectId: string): Promise<SanityProject>
|
|
2276
|
-
}
|
|
2277
|
-
|
|
2278
|
-
/**
|
|
2279
|
-
* @public
|
|
2280
|
-
* @category Types
|
|
2281
|
-
* @interface
|
|
2282
|
-
*/
|
|
2283
|
-
export declare type ProjectWithoutMembers = Omit<SanityProject, 'members'>
|
|
2284
|
-
|
|
2285
|
-
/**
|
|
2286
|
-
* Publishes a draft document.
|
|
2287
|
-
* If a published version of the document already exists this is replaced by the current draft document.
|
|
2288
|
-
* In either case the draft document is deleted.
|
|
2289
|
-
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
2290
|
-
* that the draft and/or published versions of the document have not been changed by another client.
|
|
2291
|
-
*
|
|
2292
|
-
* @public
|
|
2293
|
-
*/
|
|
2294
|
-
declare type PublishAction = {
|
|
2295
|
-
actionType: 'sanity.action.document.publish'
|
|
2296
|
-
/**
|
|
2297
|
-
* Draft document ID to publish
|
|
2298
|
-
*/
|
|
2299
|
-
draftId: string
|
|
2300
|
-
/**
|
|
2301
|
-
* Draft revision ID to match
|
|
2302
|
-
*/
|
|
2303
|
-
ifDraftRevisionId?: string
|
|
2304
|
-
/**
|
|
2305
|
-
* Published document ID to replace
|
|
2306
|
-
*/
|
|
2307
|
-
publishedId: string
|
|
2308
|
-
/**
|
|
2309
|
-
* Published revision ID to match
|
|
2310
|
-
*/
|
|
2311
|
-
ifPublishedRevisionId?: string
|
|
2312
|
-
}
|
|
2313
|
-
|
|
2314
|
-
/** @public */
|
|
2315
|
-
declare interface QueryParams {
|
|
2316
|
-
[key: string]: any
|
|
2317
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2318
|
-
body?: never
|
|
2319
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2320
|
-
cache?: 'next' extends keyof RequestInit ? never : any
|
|
2321
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2322
|
-
filterResponse?: never
|
|
2323
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2324
|
-
headers?: never
|
|
2325
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2326
|
-
method?: never
|
|
2327
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2328
|
-
next?: 'next' extends keyof RequestInit ? never : any
|
|
2329
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2330
|
-
perspective?: never
|
|
2331
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2332
|
-
query?: never
|
|
2333
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2334
|
-
resultSourceMap?: never
|
|
2335
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2336
|
-
returnQuery?: never
|
|
2337
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2338
|
-
signal?: never
|
|
2339
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2340
|
-
stega?: never
|
|
2341
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2342
|
-
tag?: never
|
|
2343
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2344
|
-
timeout?: never
|
|
2345
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2346
|
-
token?: never
|
|
2347
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2348
|
-
useCdn?: never
|
|
2349
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2350
|
-
lastLiveEventId?: never
|
|
2351
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2352
|
-
cacheMode?: never
|
|
2353
|
-
}
|
|
2354
|
-
|
|
2355
|
-
/**
|
|
2356
|
-
* This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
|
|
2357
|
-
* @public
|
|
2358
|
-
*/
|
|
2359
|
-
declare type QueryWithoutParams = Record<string, never> | undefined
|
|
2360
|
-
|
|
2361
|
-
/** @public */
|
|
2362
|
-
declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
|
|
2363
|
-
|
|
2364
|
-
/** @public */
|
|
2365
|
-
declare interface RawQueryResponse<R> {
|
|
2366
|
-
query: string
|
|
2367
|
-
ms: number
|
|
2368
|
-
result: R
|
|
2369
|
-
resultSourceMap?: ContentSourceMap
|
|
2370
|
-
/** Requires `apiVersion` to be `2021-03-25` or later. */
|
|
2371
|
-
syncTags?: SyncTag[]
|
|
2372
|
-
}
|
|
2373
|
-
|
|
2374
|
-
/** @internal */
|
|
2375
|
-
declare interface RawRequestOptions {
|
|
2376
|
-
url?: string
|
|
2377
|
-
uri?: string
|
|
2378
|
-
method?: string
|
|
2379
|
-
token?: string
|
|
2380
|
-
json?: boolean
|
|
2381
|
-
tag?: string
|
|
2382
|
-
useGlobalApi?: boolean
|
|
2383
|
-
withCredentials?: boolean
|
|
2384
|
-
query?: {
|
|
2385
|
-
[key: string]: string | string[]
|
|
2386
|
-
}
|
|
2387
|
-
headers?: {
|
|
2388
|
-
[key: string]: string
|
|
2389
|
-
}
|
|
2390
|
-
timeout?: number
|
|
2391
|
-
proxy?: string
|
|
2392
|
-
body?: Any
|
|
2393
|
-
maxRedirects?: number
|
|
2394
|
-
signal?: AbortSignal
|
|
2395
|
-
}
|
|
2396
|
-
|
|
2397
|
-
/**
|
|
2398
|
-
* This version is provided by pkg-utils at build time
|
|
2399
|
-
* @internal
|
|
2400
|
-
*/
|
|
2401
|
-
export declare const REACT_SDK_VERSION: {}
|
|
337
|
+
/**
|
|
338
|
+
* This version is provided by pkg-utils at build time
|
|
339
|
+
* @internal
|
|
340
|
+
*/
|
|
341
|
+
export declare const REACT_SDK_VERSION: {}
|
|
2402
342
|
|
|
2403
343
|
/**
|
|
2404
|
-
*
|
|
344
|
+
* Provides a Sanity instance to child components through React Context
|
|
2405
345
|
*
|
|
2406
|
-
* @
|
|
346
|
+
* @internal
|
|
347
|
+
*
|
|
348
|
+
* @remarks
|
|
349
|
+
* The ResourceProvider creates a hierarchical structure of Sanity instances:
|
|
350
|
+
* - When used as a root provider, it creates a new Sanity instance with the given config
|
|
351
|
+
* - When nested inside another ResourceProvider, it creates a child instance that
|
|
352
|
+
* inherits and extends the parent's configuration
|
|
353
|
+
*
|
|
354
|
+
* Features:
|
|
355
|
+
* - Automatically manages the lifecycle of Sanity instances
|
|
356
|
+
* - Disposes instances when the component unmounts
|
|
357
|
+
* - Includes a Suspense boundary for data loading
|
|
358
|
+
* - Enables hierarchical configuration inheritance
|
|
359
|
+
*
|
|
360
|
+
* Use this component to:
|
|
361
|
+
* - Set up project/dataset configuration for an application
|
|
362
|
+
* - Override specific configuration values in a section of your app
|
|
363
|
+
* - Create isolated instance hierarchies for different features
|
|
364
|
+
*
|
|
365
|
+
* @example Creating a root provider
|
|
366
|
+
* ```tsx
|
|
367
|
+
* <ResourceProvider
|
|
368
|
+
* projectId="your-project-id"
|
|
369
|
+
* dataset="production"
|
|
370
|
+
* fallback={<LoadingSpinner />}
|
|
371
|
+
* >
|
|
372
|
+
* <YourApp />
|
|
373
|
+
* </ResourceProvider>
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* @example Creating nested providers with configuration inheritance
|
|
377
|
+
* ```tsx
|
|
378
|
+
* // Root provider with production config with nested provider for preview features with custom dataset
|
|
379
|
+
* <ResourceProvider projectId="abc123" dataset="production" fallback={<Loading />}>
|
|
380
|
+
* <div>...Main app content</div>
|
|
381
|
+
* <Dashboard />
|
|
382
|
+
* <ResourceProvider dataset="preview" fallback={<Loading />}>
|
|
383
|
+
* <PreviewFeatures />
|
|
384
|
+
* </ResourceProvider>
|
|
385
|
+
* </ResourceProvider>
|
|
386
|
+
* ```
|
|
2407
387
|
*/
|
|
2408
|
-
declare
|
|
2409
|
-
|
|
2410
|
-
|
|
388
|
+
export declare function ResourceProvider({
|
|
389
|
+
children,
|
|
390
|
+
fallback,
|
|
391
|
+
...config
|
|
392
|
+
}: ResourceProviderProps): React.ReactNode
|
|
2411
393
|
|
|
2412
394
|
/**
|
|
2413
|
-
*
|
|
2414
|
-
*
|
|
2415
|
-
*
|
|
2416
|
-
* @public
|
|
395
|
+
* Props for the ResourceProvider component
|
|
396
|
+
* @internal
|
|
2417
397
|
*/
|
|
2418
|
-
declare
|
|
2419
|
-
actionType: 'sanity.action.document.replaceDraft'
|
|
398
|
+
export declare interface ResourceProviderProps extends SanityConfig {
|
|
2420
399
|
/**
|
|
2421
|
-
*
|
|
2422
|
-
|
|
2423
|
-
publishedId: string
|
|
2424
|
-
/**
|
|
2425
|
-
* Document to create if it does not already exist. Requires `_id` and `_type` properties.
|
|
2426
|
-
*/
|
|
2427
|
-
attributes: IdentifiedSanityDocumentStub
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
/** @public */
|
|
2431
|
-
declare interface RequestOptions {
|
|
2432
|
-
timeout?: number
|
|
2433
|
-
token?: string
|
|
2434
|
-
tag?: string
|
|
2435
|
-
headers?: Record<string, string>
|
|
2436
|
-
method?: string
|
|
2437
|
-
query?: Any
|
|
2438
|
-
body?: Any
|
|
2439
|
-
signal?: AbortSignal
|
|
2440
|
-
}
|
|
2441
|
-
|
|
2442
|
-
/** @alpha */
|
|
2443
|
-
declare type ResolveStudioUrl = (sourceDocument: ContentSourceMapDocuments[number]) => StudioUrl
|
|
2444
|
-
|
|
2445
|
-
/** @public */
|
|
2446
|
-
declare interface ResponseEvent<T = unknown> {
|
|
2447
|
-
type: 'response'
|
|
2448
|
-
body: T
|
|
2449
|
-
url: string
|
|
2450
|
-
method: string
|
|
2451
|
-
statusCode: number
|
|
2452
|
-
statusMessage?: string
|
|
2453
|
-
headers: Record<string, string>
|
|
2454
|
-
}
|
|
2455
|
-
|
|
2456
|
-
/** @public */
|
|
2457
|
-
declare interface ResponseQueryOptions extends RequestOptions {
|
|
2458
|
-
perspective?: ClientPerspective
|
|
2459
|
-
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2460
|
-
returnQuery?: boolean
|
|
2461
|
-
useCdn?: boolean
|
|
2462
|
-
stega?: boolean | StegaConfig
|
|
2463
|
-
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2464
|
-
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2465
|
-
lastLiveEventId?: string | string[] | null
|
|
2466
|
-
/**
|
|
2467
|
-
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
2468
|
-
* Tradeoff between latency and freshness of content.
|
|
2469
|
-
*
|
|
2470
|
-
* Only to be used with live content queries and when useCdn is true.
|
|
400
|
+
* React node to show while content is loading
|
|
401
|
+
* Used as the fallback for the internal Suspense boundary
|
|
2471
402
|
*/
|
|
2472
|
-
|
|
403
|
+
fallback: React.ReactNode
|
|
404
|
+
children: React.ReactNode
|
|
2473
405
|
}
|
|
2474
406
|
|
|
2475
407
|
/**
|
|
@@ -2479,6 +411,9 @@ declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2479
411
|
* as well as application context and state which is used by the Sanity React hooks. Your application
|
|
2480
412
|
* must be wrapped with the SanityApp component to function properly.
|
|
2481
413
|
*
|
|
414
|
+
* SanityApp creates a hierarchy of ResourceProviders, each providing a SanityInstance that can be
|
|
415
|
+
* accessed by hooks. The first configuration in the array becomes the default instance.
|
|
416
|
+
*
|
|
2482
417
|
* @param props - Your Sanity configuration and the React children to render
|
|
2483
418
|
* @returns Your Sanity application, integrated with your Sanity configuration and application context
|
|
2484
419
|
*
|
|
@@ -2489,16 +424,14 @@ declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2489
424
|
* import MyAppRoot from './Root'
|
|
2490
425
|
*
|
|
2491
426
|
* // Single project configuration
|
|
2492
|
-
* const
|
|
2493
|
-
*
|
|
2494
|
-
*
|
|
2495
|
-
*
|
|
2496
|
-
* },
|
|
2497
|
-
* ]
|
|
427
|
+
* const mySanityConfig = {
|
|
428
|
+
* projectId: 'my-project-id',
|
|
429
|
+
* dataset: 'production',
|
|
430
|
+
* }
|
|
2498
431
|
*
|
|
2499
432
|
* // Or multiple project configurations
|
|
2500
433
|
* const multipleConfigs = [
|
|
2501
|
-
* // Configuration for your main project. This will be used as the default project for
|
|
434
|
+
* // Configuration for your main project. This will be used as the default project for hooks.
|
|
2502
435
|
* {
|
|
2503
436
|
* projectId: 'marketing-website-project',
|
|
2504
437
|
* dataset: 'production',
|
|
@@ -2517,628 +450,34 @@ declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2517
450
|
*
|
|
2518
451
|
* export default function MyApp() {
|
|
2519
452
|
* return (
|
|
2520
|
-
* <SanityApp
|
|
453
|
+
* <SanityApp config={mySanityConfig} fallback={<LoadingSpinner />}>
|
|
2521
454
|
* <MyAppRoot />
|
|
2522
455
|
* </SanityApp>
|
|
2523
456
|
* )
|
|
2524
457
|
* }
|
|
2525
458
|
* ```
|
|
2526
459
|
*/
|
|
2527
|
-
export declare function SanityApp({
|
|
460
|
+
export declare function SanityApp({
|
|
461
|
+
children,
|
|
462
|
+
fallback,
|
|
463
|
+
config,
|
|
464
|
+
sanityConfigs,
|
|
465
|
+
...props
|
|
466
|
+
}: SanityAppProps): ReactElement
|
|
2528
467
|
|
|
2529
468
|
/**
|
|
2530
469
|
* @public
|
|
2531
470
|
*/
|
|
2532
471
|
export declare interface SanityAppProps {
|
|
2533
|
-
|
|
472
|
+
config: SanityConfig | SanityConfig[]
|
|
473
|
+
/** @deprecated use the `config` prop instead. */
|
|
474
|
+
sanityConfigs?: SanityConfig[]
|
|
2534
475
|
children: React.ReactNode
|
|
2535
476
|
fallback: React.ReactNode
|
|
2536
477
|
}
|
|
2537
478
|
|
|
2538
|
-
/** @internal */
|
|
2539
|
-
declare interface SanityAssetDocument extends SanityDocument_2 {
|
|
2540
|
-
url: string
|
|
2541
|
-
path: string
|
|
2542
|
-
size: number
|
|
2543
|
-
assetId: string
|
|
2544
|
-
mimeType: string
|
|
2545
|
-
sha1hash: string
|
|
2546
|
-
extension: string
|
|
2547
|
-
uploadId?: string
|
|
2548
|
-
originalFilename?: string
|
|
2549
|
-
}
|
|
2550
|
-
|
|
2551
|
-
/** @public */
|
|
2552
|
-
declare class SanityClient {
|
|
2553
|
-
#private
|
|
2554
|
-
assets: AssetsClient
|
|
2555
|
-
datasets: DatasetsClient
|
|
2556
|
-
live: LiveClient
|
|
2557
|
-
projects: ProjectsClient
|
|
2558
|
-
users: UsersClient
|
|
2559
|
-
/**
|
|
2560
|
-
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2561
|
-
*/
|
|
2562
|
-
observable: ObservableSanityClient
|
|
2563
|
-
/**
|
|
2564
|
-
* Instance properties
|
|
2565
|
-
*/
|
|
2566
|
-
listen: typeof _listen
|
|
2567
|
-
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
2568
|
-
/**
|
|
2569
|
-
* Clone the client - returns a new instance
|
|
2570
|
-
*/
|
|
2571
|
-
clone(): SanityClient
|
|
2572
|
-
/**
|
|
2573
|
-
* Returns the current client configuration
|
|
2574
|
-
*/
|
|
2575
|
-
config(): InitializedClientConfig
|
|
2576
|
-
/**
|
|
2577
|
-
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
2578
|
-
*/
|
|
2579
|
-
config(newConfig?: Partial<ClientConfig>): this
|
|
2580
|
-
/**
|
|
2581
|
-
* Clone the client with a new (partial) configuration.
|
|
2582
|
-
*
|
|
2583
|
-
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
2584
|
-
*/
|
|
2585
|
-
withConfig(newConfig?: Partial<ClientConfig>): SanityClient
|
|
2586
|
-
/**
|
|
2587
|
-
* Perform a GROQ-query against the configured dataset.
|
|
2588
|
-
*
|
|
2589
|
-
* @param query - GROQ-query to perform
|
|
2590
|
-
*/
|
|
2591
|
-
fetch<
|
|
2592
|
-
R = Any,
|
|
2593
|
-
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
2594
|
-
const G extends string = string,
|
|
2595
|
-
>(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
|
|
2596
|
-
/**
|
|
2597
|
-
* Perform a GROQ-query against the configured dataset.
|
|
2598
|
-
*
|
|
2599
|
-
* @param query - GROQ-query to perform
|
|
2600
|
-
* @param params - Optional query parameters
|
|
2601
|
-
* @param options - Optional request options
|
|
2602
|
-
*/
|
|
2603
|
-
fetch<
|
|
2604
|
-
R = Any,
|
|
2605
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2606
|
-
const G extends string = string,
|
|
2607
|
-
>(
|
|
2608
|
-
query: G,
|
|
2609
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2610
|
-
options?: FilteredResponseQueryOptions,
|
|
2611
|
-
): Promise<ClientReturn<G, R>>
|
|
2612
|
-
/**
|
|
2613
|
-
* Perform a GROQ-query against the configured dataset.
|
|
2614
|
-
*
|
|
2615
|
-
* @param query - GROQ-query to perform
|
|
2616
|
-
* @param params - Optional query parameters
|
|
2617
|
-
* @param options - Request options
|
|
2618
|
-
*/
|
|
2619
|
-
fetch<
|
|
2620
|
-
R = Any,
|
|
2621
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2622
|
-
const G extends string = string,
|
|
2623
|
-
>(
|
|
2624
|
-
query: G,
|
|
2625
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2626
|
-
options: UnfilteredResponseQueryOptions,
|
|
2627
|
-
): Promise<RawQueryResponse<ClientReturn<G, R>>>
|
|
2628
|
-
/**
|
|
2629
|
-
* Perform a GROQ-query against the configured dataset.
|
|
2630
|
-
*
|
|
2631
|
-
* @param query - GROQ-query to perform
|
|
2632
|
-
* @param params - Optional query parameters
|
|
2633
|
-
* @param options - Request options
|
|
2634
|
-
*/
|
|
2635
|
-
fetch<
|
|
2636
|
-
R = Any,
|
|
2637
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2638
|
-
const G extends string = string,
|
|
2639
|
-
>(
|
|
2640
|
-
query: G,
|
|
2641
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2642
|
-
options: UnfilteredResponseWithoutQuery,
|
|
2643
|
-
): Promise<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
2644
|
-
/**
|
|
2645
|
-
* Fetch a single document with the given ID.
|
|
2646
|
-
*
|
|
2647
|
-
* @param id - Document ID to fetch
|
|
2648
|
-
* @param options - Request options
|
|
2649
|
-
*/
|
|
2650
|
-
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
2651
|
-
id: string,
|
|
2652
|
-
options?: {
|
|
2653
|
-
signal?: AbortSignal
|
|
2654
|
-
tag?: string
|
|
2655
|
-
},
|
|
2656
|
-
): Promise<SanityDocument_2<R> | undefined>
|
|
2657
|
-
/**
|
|
2658
|
-
* Fetch multiple documents in one request.
|
|
2659
|
-
* Should be used sparingly - performing a query is usually a better option.
|
|
2660
|
-
* The order/position of documents is preserved based on the original array of IDs.
|
|
2661
|
-
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
2662
|
-
*
|
|
2663
|
-
* @param ids - Document IDs to fetch
|
|
2664
|
-
* @param options - Request options
|
|
2665
|
-
*/
|
|
2666
|
-
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
2667
|
-
ids: string[],
|
|
2668
|
-
options?: {
|
|
2669
|
-
signal?: AbortSignal
|
|
2670
|
-
tag?: string
|
|
2671
|
-
},
|
|
2672
|
-
): Promise<(SanityDocument_2<R> | null)[]>
|
|
2673
|
-
/**
|
|
2674
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2675
|
-
* Returns a promise that resolves to the created document.
|
|
2676
|
-
*
|
|
2677
|
-
* @param document - Document to create
|
|
2678
|
-
* @param options - Mutation options
|
|
2679
|
-
*/
|
|
2680
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2681
|
-
document: SanityDocumentStub<R>,
|
|
2682
|
-
options: FirstDocumentMutationOptions,
|
|
2683
|
-
): Promise<SanityDocument_2<R>>
|
|
2684
|
-
/**
|
|
2685
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2686
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
2687
|
-
*
|
|
2688
|
-
* @param document - Document to create
|
|
2689
|
-
* @param options - Mutation options
|
|
2690
|
-
*/
|
|
2691
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2692
|
-
document: SanityDocumentStub<R>,
|
|
2693
|
-
options: AllDocumentsMutationOptions,
|
|
2694
|
-
): Promise<SanityDocument_2<R>[]>
|
|
2695
|
-
/**
|
|
2696
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2697
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2698
|
-
*
|
|
2699
|
-
* @param document - Document to create
|
|
2700
|
-
* @param options - Mutation options
|
|
2701
|
-
*/
|
|
2702
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2703
|
-
document: SanityDocumentStub<R>,
|
|
2704
|
-
options: FirstDocumentIdMutationOptions,
|
|
2705
|
-
): Promise<SingleMutationResult>
|
|
2706
|
-
/**
|
|
2707
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2708
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2709
|
-
*
|
|
2710
|
-
* @param document - Document to create
|
|
2711
|
-
* @param options - Mutation options
|
|
2712
|
-
*/
|
|
2713
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2714
|
-
document: SanityDocumentStub<R>,
|
|
2715
|
-
options: AllDocumentIdsMutationOptions,
|
|
2716
|
-
): Promise<MultipleMutationResult>
|
|
2717
|
-
/**
|
|
2718
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2719
|
-
* Returns a promise that resolves to the created document.
|
|
2720
|
-
*
|
|
2721
|
-
* @param document - Document to create
|
|
2722
|
-
* @param options - Mutation options
|
|
2723
|
-
*/
|
|
2724
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2725
|
-
document: SanityDocumentStub<R>,
|
|
2726
|
-
options?: BaseMutationOptions,
|
|
2727
|
-
): Promise<SanityDocument_2<R>>
|
|
2728
|
-
/**
|
|
2729
|
-
* Create a document if no document with the same ID already exists.
|
|
2730
|
-
* Returns a promise that resolves to the created document.
|
|
2731
|
-
*
|
|
2732
|
-
* @param document - Document to create
|
|
2733
|
-
* @param options - Mutation options
|
|
2734
|
-
*/
|
|
2735
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2736
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2737
|
-
options: FirstDocumentMutationOptions,
|
|
2738
|
-
): Promise<SanityDocument_2<R>>
|
|
2739
|
-
/**
|
|
2740
|
-
* Create a document if no document with the same ID already exists.
|
|
2741
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
2742
|
-
*
|
|
2743
|
-
* @param document - Document to create
|
|
2744
|
-
* @param options - Mutation options
|
|
2745
|
-
*/
|
|
2746
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2747
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2748
|
-
options: AllDocumentsMutationOptions,
|
|
2749
|
-
): Promise<SanityDocument_2<R>[]>
|
|
2750
|
-
/**
|
|
2751
|
-
* Create a document if no document with the same ID already exists.
|
|
2752
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2753
|
-
*
|
|
2754
|
-
* @param document - Document to create
|
|
2755
|
-
* @param options - Mutation options
|
|
2756
|
-
*/
|
|
2757
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2758
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2759
|
-
options: FirstDocumentIdMutationOptions,
|
|
2760
|
-
): Promise<SingleMutationResult>
|
|
2761
|
-
/**
|
|
2762
|
-
* Create a document if no document with the same ID already exists.
|
|
2763
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2764
|
-
*
|
|
2765
|
-
* @param document - Document to create
|
|
2766
|
-
* @param options - Mutation options
|
|
2767
|
-
*/
|
|
2768
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2769
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2770
|
-
options: AllDocumentIdsMutationOptions,
|
|
2771
|
-
): Promise<MultipleMutationResult>
|
|
2772
|
-
/**
|
|
2773
|
-
* Create a document if no document with the same ID already exists.
|
|
2774
|
-
* Returns a promise that resolves to the created document.
|
|
2775
|
-
*
|
|
2776
|
-
* @param document - Document to create
|
|
2777
|
-
* @param options - Mutation options
|
|
2778
|
-
*/
|
|
2779
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2780
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2781
|
-
options?: BaseMutationOptions,
|
|
2782
|
-
): Promise<SanityDocument_2<R>>
|
|
2783
|
-
/**
|
|
2784
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2785
|
-
* Returns a promise that resolves to the created document.
|
|
2786
|
-
*
|
|
2787
|
-
* @param document - Document to either create or replace
|
|
2788
|
-
* @param options - Mutation options
|
|
2789
|
-
*/
|
|
2790
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2791
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2792
|
-
options: FirstDocumentMutationOptions,
|
|
2793
|
-
): Promise<SanityDocument_2<R>>
|
|
2794
|
-
/**
|
|
2795
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2796
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
2797
|
-
*
|
|
2798
|
-
* @param document - Document to either create or replace
|
|
2799
|
-
* @param options - Mutation options
|
|
2800
|
-
*/
|
|
2801
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2802
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2803
|
-
options: AllDocumentsMutationOptions,
|
|
2804
|
-
): Promise<SanityDocument_2<R>[]>
|
|
2805
|
-
/**
|
|
2806
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2807
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2808
|
-
*
|
|
2809
|
-
* @param document - Document to either create or replace
|
|
2810
|
-
* @param options - Mutation options
|
|
2811
|
-
*/
|
|
2812
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2813
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2814
|
-
options: FirstDocumentIdMutationOptions,
|
|
2815
|
-
): Promise<SingleMutationResult>
|
|
2816
|
-
/**
|
|
2817
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2818
|
-
* Returns a promise that resolves to a mutation result object containing the created document ID.
|
|
2819
|
-
*
|
|
2820
|
-
* @param document - Document to either create or replace
|
|
2821
|
-
* @param options - Mutation options
|
|
2822
|
-
*/
|
|
2823
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2824
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2825
|
-
options: AllDocumentIdsMutationOptions,
|
|
2826
|
-
): Promise<MultipleMutationResult>
|
|
2827
|
-
/**
|
|
2828
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2829
|
-
* Returns a promise that resolves to the created document.
|
|
2830
|
-
*
|
|
2831
|
-
* @param document - Document to either create or replace
|
|
2832
|
-
* @param options - Mutation options
|
|
2833
|
-
*/
|
|
2834
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2835
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2836
|
-
options?: BaseMutationOptions,
|
|
2837
|
-
): Promise<SanityDocument_2<R>>
|
|
2838
|
-
/**
|
|
2839
|
-
* Deletes a document with the given document ID.
|
|
2840
|
-
* Returns a promise that resolves to the deleted document.
|
|
2841
|
-
*
|
|
2842
|
-
* @param id - Document ID to delete
|
|
2843
|
-
* @param options - Options for the mutation
|
|
2844
|
-
*/
|
|
2845
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2846
|
-
id: string,
|
|
2847
|
-
options: FirstDocumentMutationOptions,
|
|
2848
|
-
): Promise<SanityDocument_2<R>>
|
|
2849
|
-
/**
|
|
2850
|
-
* Deletes a document with the given document ID.
|
|
2851
|
-
* Returns a promise that resolves to an array containing the deleted document.
|
|
2852
|
-
*
|
|
2853
|
-
* @param id - Document ID to delete
|
|
2854
|
-
* @param options - Options for the mutation
|
|
2855
|
-
*/
|
|
2856
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2857
|
-
id: string,
|
|
2858
|
-
options: AllDocumentsMutationOptions,
|
|
2859
|
-
): Promise<SanityDocument_2<R>[]>
|
|
2860
|
-
/**
|
|
2861
|
-
* Deletes a document with the given document ID.
|
|
2862
|
-
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
2863
|
-
*
|
|
2864
|
-
* @param id - Document ID to delete
|
|
2865
|
-
* @param options - Options for the mutation
|
|
2866
|
-
*/
|
|
2867
|
-
delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
2868
|
-
/**
|
|
2869
|
-
* Deletes a document with the given document ID.
|
|
2870
|
-
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
2871
|
-
*
|
|
2872
|
-
* @param id - Document ID to delete
|
|
2873
|
-
* @param options - Options for the mutation
|
|
2874
|
-
*/
|
|
2875
|
-
delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
2876
|
-
/**
|
|
2877
|
-
* Deletes a document with the given document ID.
|
|
2878
|
-
* Returns a promise that resolves to the deleted document.
|
|
2879
|
-
*
|
|
2880
|
-
* @param id - Document ID to delete
|
|
2881
|
-
* @param options - Options for the mutation
|
|
2882
|
-
*/
|
|
2883
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2884
|
-
id: string,
|
|
2885
|
-
options?: BaseMutationOptions,
|
|
2886
|
-
): Promise<SanityDocument_2<R>>
|
|
2887
|
-
/**
|
|
2888
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2889
|
-
* Returns a promise that resolves to first deleted document.
|
|
2890
|
-
*
|
|
2891
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2892
|
-
* @param options - Options for the mutation
|
|
2893
|
-
*/
|
|
2894
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2895
|
-
selection: MutationSelection,
|
|
2896
|
-
options: FirstDocumentMutationOptions,
|
|
2897
|
-
): Promise<SanityDocument_2<R>>
|
|
2898
|
-
/**
|
|
2899
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2900
|
-
* Returns a promise that resolves to an array containing the deleted documents.
|
|
2901
|
-
*
|
|
2902
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2903
|
-
* @param options - Options for the mutation
|
|
2904
|
-
*/
|
|
2905
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2906
|
-
selection: MutationSelection,
|
|
2907
|
-
options: AllDocumentsMutationOptions,
|
|
2908
|
-
): Promise<SanityDocument_2<R>[]>
|
|
2909
|
-
/**
|
|
2910
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2911
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
|
|
2912
|
-
*
|
|
2913
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2914
|
-
* @param options - Options for the mutation
|
|
2915
|
-
*/
|
|
2916
|
-
delete(
|
|
2917
|
-
selection: MutationSelection,
|
|
2918
|
-
options: FirstDocumentIdMutationOptions,
|
|
2919
|
-
): Promise<SingleMutationResult>
|
|
2920
|
-
/**
|
|
2921
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2922
|
-
* Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
|
|
2923
|
-
*
|
|
2924
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2925
|
-
* @param options - Options for the mutation
|
|
2926
|
-
*/
|
|
2927
|
-
delete(
|
|
2928
|
-
selection: MutationSelection,
|
|
2929
|
-
options: AllDocumentIdsMutationOptions,
|
|
2930
|
-
): Promise<MultipleMutationResult>
|
|
2931
|
-
/**
|
|
2932
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2933
|
-
* Returns a promise that resolves to first deleted document.
|
|
2934
|
-
*
|
|
2935
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2936
|
-
* @param options - Options for the mutation
|
|
2937
|
-
*/
|
|
2938
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2939
|
-
selection: MutationSelection,
|
|
2940
|
-
options?: BaseMutationOptions,
|
|
2941
|
-
): Promise<SanityDocument_2<R>>
|
|
2942
|
-
/**
|
|
2943
|
-
* Perform mutation operations against the configured dataset
|
|
2944
|
-
* Returns a promise that resolves to the first mutated document.
|
|
2945
|
-
*
|
|
2946
|
-
* @param operations - Mutation operations to execute
|
|
2947
|
-
* @param options - Mutation options
|
|
2948
|
-
*/
|
|
2949
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2950
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
2951
|
-
options: FirstDocumentMutationOptions,
|
|
2952
|
-
): Promise<SanityDocument_2<R>>
|
|
2953
|
-
/**
|
|
2954
|
-
* Perform mutation operations against the configured dataset.
|
|
2955
|
-
* Returns a promise that resolves to an array of the mutated documents.
|
|
2956
|
-
*
|
|
2957
|
-
* @param operations - Mutation operations to execute
|
|
2958
|
-
* @param options - Mutation options
|
|
2959
|
-
*/
|
|
2960
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2961
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
2962
|
-
options: AllDocumentsMutationOptions,
|
|
2963
|
-
): Promise<SanityDocument_2<R>[]>
|
|
2964
|
-
/**
|
|
2965
|
-
* Perform mutation operations against the configured dataset
|
|
2966
|
-
* Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
2967
|
-
*
|
|
2968
|
-
* @param operations - Mutation operations to execute
|
|
2969
|
-
* @param options - Mutation options
|
|
2970
|
-
*/
|
|
2971
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2972
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
2973
|
-
options: FirstDocumentIdMutationOptions,
|
|
2974
|
-
): Promise<SingleMutationResult>
|
|
2975
|
-
/**
|
|
2976
|
-
* Perform mutation operations against the configured dataset
|
|
2977
|
-
* Returns a promise that resolves to a mutation result object containing the mutated document IDs.
|
|
2978
|
-
*
|
|
2979
|
-
* @param operations - Mutation operations to execute
|
|
2980
|
-
* @param options - Mutation options
|
|
2981
|
-
*/
|
|
2982
|
-
mutate<R extends Record<string, Any>>(
|
|
2983
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
2984
|
-
options: AllDocumentIdsMutationOptions,
|
|
2985
|
-
): Promise<MultipleMutationResult>
|
|
2986
|
-
/**
|
|
2987
|
-
* Perform mutation operations against the configured dataset
|
|
2988
|
-
* Returns a promise that resolves to the first mutated document.
|
|
2989
|
-
*
|
|
2990
|
-
* @param operations - Mutation operations to execute
|
|
2991
|
-
* @param options - Mutation options
|
|
2992
|
-
*/
|
|
2993
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2994
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
2995
|
-
options?: BaseMutationOptions,
|
|
2996
|
-
): Promise<SanityDocument_2<R>>
|
|
2997
|
-
/**
|
|
2998
|
-
* Create a new buildable patch of operations to perform
|
|
2999
|
-
*
|
|
3000
|
-
* @param documentId - Document ID to patch
|
|
3001
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3002
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3003
|
-
*/
|
|
3004
|
-
patch(documentId: string, operations?: PatchOperations): Patch
|
|
3005
|
-
/**
|
|
3006
|
-
* Create a new buildable patch of operations to perform
|
|
3007
|
-
*
|
|
3008
|
-
* @param documentIds - Array of document IDs to patch
|
|
3009
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3010
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3011
|
-
*/
|
|
3012
|
-
patch(documentIds: string[], operations?: PatchOperations): Patch
|
|
3013
|
-
/**
|
|
3014
|
-
* Create a new buildable patch of operations to perform
|
|
3015
|
-
*
|
|
3016
|
-
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
3017
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3018
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3019
|
-
*/
|
|
3020
|
-
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
3021
|
-
/**
|
|
3022
|
-
* Create a new transaction of mutations
|
|
3023
|
-
*
|
|
3024
|
-
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
3025
|
-
*/
|
|
3026
|
-
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
3027
|
-
operations?: Mutation<R>[],
|
|
3028
|
-
): Transaction
|
|
3029
|
-
/**
|
|
3030
|
-
* Perform action operations against the configured dataset
|
|
3031
|
-
* Returns a promise that resolves to the transaction result
|
|
3032
|
-
*
|
|
3033
|
-
* @param operations - Action operation(s) to execute
|
|
3034
|
-
* @param options - Action options
|
|
3035
|
-
*/
|
|
3036
|
-
action(
|
|
3037
|
-
operations: Action | Action[],
|
|
3038
|
-
options?: BaseActionOptions,
|
|
3039
|
-
): Promise<SingleActionResult | MultipleActionResult>
|
|
3040
|
-
/**
|
|
3041
|
-
* Perform a request against the Sanity API
|
|
3042
|
-
* NOTE: Only use this for Sanity API endpoints, not for your own APIs!
|
|
3043
|
-
*
|
|
3044
|
-
* @param options - Request options
|
|
3045
|
-
* @returns Promise resolving to the response body
|
|
3046
|
-
*/
|
|
3047
|
-
request<R = Any>(options: RawRequestOptions): Promise<R>
|
|
3048
|
-
/**
|
|
3049
|
-
* Perform an HTTP request a `/data` sub-endpoint
|
|
3050
|
-
* NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
|
|
3051
|
-
*
|
|
3052
|
-
* @deprecated - Use `request()` or your own HTTP library instead
|
|
3053
|
-
* @param endpoint - Endpoint to hit (mutate, query etc)
|
|
3054
|
-
* @param body - Request body
|
|
3055
|
-
* @param options - Request options
|
|
3056
|
-
* @internal
|
|
3057
|
-
*/
|
|
3058
|
-
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
|
|
3059
|
-
/**
|
|
3060
|
-
* Get a Sanity API URL for the URI provided
|
|
3061
|
-
*
|
|
3062
|
-
* @param uri - URI/path to build URL for
|
|
3063
|
-
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
3064
|
-
*/
|
|
3065
|
-
getUrl(uri: string, canUseCdn?: boolean): string
|
|
3066
|
-
/**
|
|
3067
|
-
* Get a Sanity API URL for the data operation and path provided
|
|
3068
|
-
*
|
|
3069
|
-
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
3070
|
-
* @param path - Path to append after the operation
|
|
3071
|
-
*/
|
|
3072
|
-
getDataUrl(operation: string, path?: string): string
|
|
3073
|
-
}
|
|
3074
|
-
|
|
3075
479
|
export {SanityDocument}
|
|
3076
480
|
|
|
3077
|
-
/** @internal */
|
|
3078
|
-
declare type SanityDocument_2<T extends Record<string, Any> = Record<string, Any>> = {
|
|
3079
|
-
[P in keyof T]: T[P]
|
|
3080
|
-
} & {
|
|
3081
|
-
_id: string
|
|
3082
|
-
_rev: string
|
|
3083
|
-
_type: string
|
|
3084
|
-
_createdAt: string
|
|
3085
|
-
_updatedAt: string
|
|
3086
|
-
/**
|
|
3087
|
-
* Present when `perspective` is set to `previewDrafts`
|
|
3088
|
-
*/
|
|
3089
|
-
_originalId?: string
|
|
3090
|
-
}
|
|
3091
|
-
|
|
3092
|
-
/** @public */
|
|
3093
|
-
declare type SanityDocumentStub<T extends Record<string, Any> = Record<string, Any>> = {
|
|
3094
|
-
[P in keyof T]: T[P]
|
|
3095
|
-
} & {
|
|
3096
|
-
_type: string
|
|
3097
|
-
}
|
|
3098
|
-
|
|
3099
|
-
/** @internal */
|
|
3100
|
-
declare interface SanityImageAssetDocument extends SanityAssetDocument {
|
|
3101
|
-
metadata: {
|
|
3102
|
-
_type: 'sanity.imageMetadata'
|
|
3103
|
-
hasAlpha: boolean
|
|
3104
|
-
isOpaque: boolean
|
|
3105
|
-
lqip?: string
|
|
3106
|
-
blurHash?: string
|
|
3107
|
-
dimensions: {
|
|
3108
|
-
_type: 'sanity.imageDimensions'
|
|
3109
|
-
aspectRatio: number
|
|
3110
|
-
height: number
|
|
3111
|
-
width: number
|
|
3112
|
-
}
|
|
3113
|
-
palette?: {
|
|
3114
|
-
_type: 'sanity.imagePalette'
|
|
3115
|
-
darkMuted?: SanityImagePalette
|
|
3116
|
-
darkVibrant?: SanityImagePalette
|
|
3117
|
-
dominant?: SanityImagePalette
|
|
3118
|
-
lightMuted?: SanityImagePalette
|
|
3119
|
-
lightVibrant?: SanityImagePalette
|
|
3120
|
-
muted?: SanityImagePalette
|
|
3121
|
-
vibrant?: SanityImagePalette
|
|
3122
|
-
}
|
|
3123
|
-
image?: {
|
|
3124
|
-
_type: 'sanity.imageExifTags'
|
|
3125
|
-
[key: string]: Any
|
|
3126
|
-
}
|
|
3127
|
-
exif?: {
|
|
3128
|
-
_type: 'sanity.imageExifMetadata'
|
|
3129
|
-
[key: string]: Any
|
|
3130
|
-
}
|
|
3131
|
-
}
|
|
3132
|
-
}
|
|
3133
|
-
|
|
3134
|
-
/** @internal */
|
|
3135
|
-
declare interface SanityImagePalette {
|
|
3136
|
-
background: string
|
|
3137
|
-
foreground: string
|
|
3138
|
-
population: number
|
|
3139
|
-
title: string
|
|
3140
|
-
}
|
|
3141
|
-
|
|
3142
481
|
/** @public */
|
|
3143
482
|
export declare interface SanityProject {
|
|
3144
483
|
id: string
|
|
@@ -3171,67 +510,7 @@ export declare interface SanityProject {
|
|
|
3171
510
|
export declare interface SanityProjectMember {
|
|
3172
511
|
id: string
|
|
3173
512
|
role: string
|
|
3174
|
-
isRobot: boolean
|
|
3175
|
-
isCurrentUser: boolean
|
|
3176
|
-
}
|
|
3177
|
-
|
|
3178
|
-
/**
|
|
3179
|
-
* @internal
|
|
3180
|
-
*
|
|
3181
|
-
* Top-level context provider that provides access to the Sanity configuration instance.
|
|
3182
|
-
* This must wrap any components making use of the Sanity SDK React hooks.
|
|
3183
|
-
*
|
|
3184
|
-
* @remarks In most cases, SanityApp should be used rather than SanityProvider directly; SanityApp bundles both SanityProvider and an authentication layer.
|
|
3185
|
-
* @param props - Sanity project and dataset configuration
|
|
3186
|
-
* @returns Rendered component
|
|
3187
|
-
* @example
|
|
3188
|
-
* ```tsx
|
|
3189
|
-
* import {createSanityInstance} from '@sanity/sdk'
|
|
3190
|
-
* import {SanityProvider} from '@sanity/sdk-react'
|
|
3191
|
-
*
|
|
3192
|
-
* import MyAppRoot from './Root'
|
|
3193
|
-
*
|
|
3194
|
-
* const sanityInstance = createSanityInstance({
|
|
3195
|
-
* projectId: 'your-project-id',
|
|
3196
|
-
* dataset: 'production',
|
|
3197
|
-
* })
|
|
3198
|
-
*
|
|
3199
|
-
* export default function MyApp() {
|
|
3200
|
-
* return (
|
|
3201
|
-
* <SanityProvider sanityInstance={sanityInstance}>
|
|
3202
|
-
* <MyAppRoot />
|
|
3203
|
-
* </SanityProvider>
|
|
3204
|
-
* )
|
|
3205
|
-
* }
|
|
3206
|
-
* ```
|
|
3207
|
-
*/
|
|
3208
|
-
export declare const SanityProvider: ({
|
|
3209
|
-
children,
|
|
3210
|
-
sanityInstances,
|
|
3211
|
-
}: SanityProviderProps) => ReactElement
|
|
3212
|
-
|
|
3213
|
-
/**
|
|
3214
|
-
* @internal
|
|
3215
|
-
*/
|
|
3216
|
-
export declare interface SanityProviderProps {
|
|
3217
|
-
children: React.ReactNode
|
|
3218
|
-
sanityInstances: SanityInstance[]
|
|
3219
|
-
}
|
|
3220
|
-
|
|
3221
|
-
/** @public */
|
|
3222
|
-
declare interface SanityQueries {}
|
|
3223
|
-
|
|
3224
|
-
/** @public */
|
|
3225
|
-
declare interface SanityUser {
|
|
3226
|
-
id: string
|
|
3227
|
-
projectId: string
|
|
3228
|
-
displayName: string
|
|
3229
|
-
familyName: string | null
|
|
3230
|
-
givenName: string | null
|
|
3231
|
-
middleName: string | null
|
|
3232
|
-
imageUrl: string | null
|
|
3233
|
-
createdAt: string
|
|
3234
|
-
updatedAt: string
|
|
513
|
+
isRobot: boolean
|
|
3235
514
|
isCurrentUser: boolean
|
|
3236
515
|
}
|
|
3237
516
|
|
|
@@ -3239,294 +518,35 @@ declare interface SanityUser {
|
|
|
3239
518
|
* @internal
|
|
3240
519
|
*
|
|
3241
520
|
* Top-level context provider that provides access to the Sanity SDK.
|
|
521
|
+
* Creates a hierarchy of ResourceProviders, each providing a SanityInstance that can be
|
|
522
|
+
* accessed by hooks. The first configuration in the array becomes the default instance.
|
|
3242
523
|
*/
|
|
3243
524
|
export declare function SDKProvider({
|
|
3244
525
|
children,
|
|
3245
|
-
|
|
526
|
+
config,
|
|
3246
527
|
fallback,
|
|
528
|
+
...props
|
|
3247
529
|
}: SDKProviderProps): ReactElement
|
|
3248
530
|
|
|
3249
531
|
/**
|
|
3250
532
|
* @internal
|
|
3251
533
|
*/
|
|
3252
|
-
export declare interface SDKProviderProps {
|
|
534
|
+
export declare interface SDKProviderProps extends AuthBoundaryProps {
|
|
3253
535
|
children: ReactNode
|
|
3254
|
-
|
|
536
|
+
config: SanityConfig | SanityConfig[]
|
|
3255
537
|
fallback: ReactNode
|
|
3256
538
|
}
|
|
3257
539
|
|
|
3258
|
-
/** @internal */
|
|
3259
|
-
declare interface SingleActionResult {
|
|
3260
|
-
transactionId: string
|
|
3261
|
-
}
|
|
3262
|
-
|
|
3263
|
-
/** @internal */
|
|
3264
|
-
declare interface SingleMutationResult {
|
|
3265
|
-
transactionId: string
|
|
3266
|
-
documentId: string
|
|
3267
|
-
results: {
|
|
3268
|
-
id: string
|
|
3269
|
-
operation: MutationOperation
|
|
3270
|
-
}[]
|
|
3271
|
-
}
|
|
3272
|
-
|
|
3273
540
|
export {SortOrderingItem}
|
|
3274
541
|
|
|
3275
|
-
/** @public */
|
|
3276
|
-
declare type StackablePerspective = ('published' | 'drafts' | string) & {}
|
|
3277
|
-
|
|
3278
|
-
/** @public */
|
|
3279
|
-
declare interface StegaConfig {
|
|
3280
|
-
/**
|
|
3281
|
-
* Enable or disable stega encoded strings in query results
|
|
3282
|
-
* ```ts
|
|
3283
|
-
{
|
|
3284
|
-
enabled: process.env.VERCEL_ENV !== 'production'
|
|
3285
|
-
}
|
|
3286
|
-
* ```
|
|
3287
|
-
* @defaultValue `false`
|
|
3288
|
-
*/
|
|
3289
|
-
enabled?: boolean
|
|
3290
|
-
/**
|
|
3291
|
-
* Where the Studio is hosted.
|
|
3292
|
-
* If it's embedded in the app, use the base path for example `/studio`.
|
|
3293
|
-
* Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.
|
|
3294
|
-
*
|
|
3295
|
-
*/
|
|
3296
|
-
studioUrl?: StudioUrl | ResolveStudioUrl
|
|
3297
|
-
filter?: FilterDefault
|
|
3298
|
-
/**
|
|
3299
|
-
* Specify a `console.log` compatible logger to see debug logs, which keys are encoded and which are not.
|
|
3300
|
-
*/
|
|
3301
|
-
logger?: Logger
|
|
3302
|
-
/**
|
|
3303
|
-
* Set to `true` to omit cross dataset reference specific data from encoded strings
|
|
3304
|
-
*/
|
|
3305
|
-
omitCrossDatasetReferenceData?: boolean
|
|
3306
|
-
}
|
|
3307
|
-
|
|
3308
|
-
/** @public */
|
|
3309
|
-
declare type StegaConfigRequiredKeys = Extract<keyof StegaConfig, 'enabled'>
|
|
3310
|
-
|
|
3311
|
-
/** @alpha */
|
|
3312
|
-
declare type StudioBaseRoute = {
|
|
3313
|
-
baseUrl: StudioBaseUrl
|
|
3314
|
-
workspace?: string
|
|
3315
|
-
tool?: string
|
|
3316
|
-
}
|
|
3317
|
-
|
|
3318
|
-
/** @alpha */
|
|
3319
|
-
declare type StudioBaseUrl = `/${string}` | `${string}.sanity.studio` | `https://${string}` | string
|
|
3320
|
-
|
|
3321
|
-
/** @alpha */
|
|
3322
|
-
declare type StudioUrl = StudioBaseUrl | StudioBaseRoute
|
|
3323
|
-
|
|
3324
542
|
declare interface StudioWorkspacesResult {
|
|
3325
|
-
|
|
543
|
+
workspacesByProjectIdAndDataset: WorkspacesByProjectIdDataset
|
|
3326
544
|
error: string | null
|
|
3327
545
|
isConnected: boolean
|
|
3328
546
|
}
|
|
3329
547
|
|
|
3330
|
-
/** @public */
|
|
3331
|
-
declare type SyncTag = `s1:${string}`
|
|
3332
|
-
|
|
3333
|
-
/** @public */
|
|
3334
|
-
declare class Transaction extends BaseTransaction {
|
|
3335
|
-
#private
|
|
3336
|
-
constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string)
|
|
3337
|
-
/**
|
|
3338
|
-
* Clones the transaction
|
|
3339
|
-
*/
|
|
3340
|
-
clone(): Transaction
|
|
3341
|
-
/**
|
|
3342
|
-
* Commit the transaction, returning a promise that resolves to the first mutated document
|
|
3343
|
-
*
|
|
3344
|
-
* @param options - Options for the mutation operation
|
|
3345
|
-
*/
|
|
3346
|
-
commit<R extends Record<string, Any>>(
|
|
3347
|
-
options: TransactionFirstDocumentMutationOptions,
|
|
3348
|
-
): Promise<SanityDocument_2<R>>
|
|
3349
|
-
/**
|
|
3350
|
-
* Commit the transaction, returning a promise that resolves to an array of the mutated documents
|
|
3351
|
-
*
|
|
3352
|
-
* @param options - Options for the mutation operation
|
|
3353
|
-
*/
|
|
3354
|
-
commit<R extends Record<string, Any>>(
|
|
3355
|
-
options: TransactionAllDocumentsMutationOptions,
|
|
3356
|
-
): Promise<SanityDocument_2<R>[]>
|
|
3357
|
-
/**
|
|
3358
|
-
* Commit the transaction, returning a promise that resolves to a mutation result object
|
|
3359
|
-
*
|
|
3360
|
-
* @param options - Options for the mutation operation
|
|
3361
|
-
*/
|
|
3362
|
-
commit(options: TransactionFirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
3363
|
-
/**
|
|
3364
|
-
* Commit the transaction, returning a promise that resolves to a mutation result object
|
|
3365
|
-
*
|
|
3366
|
-
* @param options - Options for the mutation operation
|
|
3367
|
-
*/
|
|
3368
|
-
commit(options: TransactionAllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
3369
|
-
/**
|
|
3370
|
-
* Commit the transaction, returning a promise that resolves to a mutation result object
|
|
3371
|
-
*
|
|
3372
|
-
* @param options - Options for the mutation operation
|
|
3373
|
-
*/
|
|
3374
|
-
commit(options?: BaseMutationOptions): Promise<MultipleMutationResult>
|
|
3375
|
-
/**
|
|
3376
|
-
* Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
|
|
3377
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
3378
|
-
*
|
|
3379
|
-
* @param documentId - Document ID to perform the patch operation on
|
|
3380
|
-
* @param patchOps - Operations to perform, or a builder function
|
|
3381
|
-
*/
|
|
3382
|
-
patch(documentId: string, patchOps?: PatchBuilder | PatchOperations): this
|
|
3383
|
-
/**
|
|
3384
|
-
* Performs a patch on the given selection. Can either be a builder function or an object of patch operations.
|
|
3385
|
-
*
|
|
3386
|
-
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
3387
|
-
* @param patchOps - Operations to perform, or a builder function
|
|
3388
|
-
*/
|
|
3389
|
-
patch(patch: MutationSelection, patchOps?: PatchBuilder | PatchOperations): this
|
|
3390
|
-
/**
|
|
3391
|
-
* Adds the given patch instance to the transaction.
|
|
3392
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
3393
|
-
*
|
|
3394
|
-
* @param patch - Patch to execute
|
|
3395
|
-
*/
|
|
3396
|
-
patch(patch: Patch): this
|
|
3397
|
-
}
|
|
3398
|
-
|
|
3399
|
-
/** @internal */
|
|
3400
|
-
declare type TransactionAllDocumentIdsMutationOptions = BaseMutationOptions & {
|
|
3401
|
-
returnFirst?: false
|
|
3402
|
-
returnDocuments?: false
|
|
3403
|
-
}
|
|
3404
|
-
|
|
3405
|
-
/** @internal */
|
|
3406
|
-
declare type TransactionAllDocumentsMutationOptions = BaseMutationOptions & {
|
|
3407
|
-
returnFirst?: false
|
|
3408
|
-
returnDocuments: true
|
|
3409
|
-
}
|
|
3410
|
-
|
|
3411
|
-
/** @internal */
|
|
3412
|
-
declare type TransactionFirstDocumentIdMutationOptions = BaseMutationOptions & {
|
|
3413
|
-
returnFirst: true
|
|
3414
|
-
returnDocuments?: false
|
|
3415
|
-
}
|
|
3416
|
-
|
|
3417
|
-
/** @internal */
|
|
3418
|
-
declare type TransactionFirstDocumentMutationOptions = BaseMutationOptions & {
|
|
3419
|
-
returnFirst: true
|
|
3420
|
-
returnDocuments: true
|
|
3421
|
-
}
|
|
3422
|
-
|
|
3423
|
-
/** @public */
|
|
3424
|
-
declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
3425
|
-
filterResponse: false
|
|
3426
|
-
/**
|
|
3427
|
-
* When `filterResponse` is `false`, `returnQuery` also defaults to `true` for
|
|
3428
|
-
* backwards compatibility (on the client side, not from the content lake API).
|
|
3429
|
-
* Can also explicitly be set to `true`.
|
|
3430
|
-
*/
|
|
3431
|
-
returnQuery?: true
|
|
3432
|
-
}
|
|
3433
|
-
|
|
3434
|
-
/**
|
|
3435
|
-
* When using `filterResponse: false`, but you do not wish to receive back the query from
|
|
3436
|
-
* the content lake API.
|
|
3437
|
-
*
|
|
3438
|
-
* @public
|
|
3439
|
-
*/
|
|
3440
|
-
declare interface UnfilteredResponseWithoutQuery extends ResponseQueryOptions {
|
|
3441
|
-
filterResponse: false
|
|
3442
|
-
returnQuery: false
|
|
3443
|
-
}
|
|
3444
|
-
|
|
3445
|
-
/**
|
|
3446
|
-
* Retract a published document.
|
|
3447
|
-
* If there is no draft version then this is created from the published version.
|
|
3448
|
-
* In either case the published version is deleted.
|
|
3449
|
-
*
|
|
3450
|
-
* @public
|
|
3451
|
-
*/
|
|
3452
|
-
declare type UnpublishAction = {
|
|
3453
|
-
actionType: 'sanity.action.document.unpublish'
|
|
3454
|
-
/**
|
|
3455
|
-
* Draft document ID to replace the published document with
|
|
3456
|
-
*/
|
|
3457
|
-
draftId: string
|
|
3458
|
-
/**
|
|
3459
|
-
* Published document ID to delete
|
|
3460
|
-
*/
|
|
3461
|
-
publishedId: string
|
|
3462
|
-
}
|
|
3463
|
-
|
|
3464
548
|
declare type Updater<TValue> = TValue | ((nextValue: TValue) => TValue)
|
|
3465
549
|
|
|
3466
|
-
/** @public */
|
|
3467
|
-
declare type UploadBody = File | Blob | Buffer | NodeJS.ReadableStream
|
|
3468
|
-
|
|
3469
|
-
/** @public */
|
|
3470
|
-
declare interface UploadClientConfig {
|
|
3471
|
-
/**
|
|
3472
|
-
* Optional request tag for the upload
|
|
3473
|
-
*/
|
|
3474
|
-
tag?: string
|
|
3475
|
-
/**
|
|
3476
|
-
* Whether or not to preserve the original filename (default: true)
|
|
3477
|
-
*/
|
|
3478
|
-
preserveFilename?: boolean
|
|
3479
|
-
/**
|
|
3480
|
-
* Filename for this file (optional)
|
|
3481
|
-
*/
|
|
3482
|
-
filename?: string
|
|
3483
|
-
/**
|
|
3484
|
-
* Milliseconds to wait before timing the request out
|
|
3485
|
-
*/
|
|
3486
|
-
timeout?: number
|
|
3487
|
-
/**
|
|
3488
|
-
* Mime type of the file
|
|
3489
|
-
*/
|
|
3490
|
-
contentType?: string
|
|
3491
|
-
/**
|
|
3492
|
-
* Array of metadata parts to extract from asset
|
|
3493
|
-
*/
|
|
3494
|
-
extract?: AssetMetadataType[]
|
|
3495
|
-
/**
|
|
3496
|
-
* Optional freeform label for the asset. Generally not used.
|
|
3497
|
-
*/
|
|
3498
|
-
label?: string
|
|
3499
|
-
/**
|
|
3500
|
-
* Optional title for the asset
|
|
3501
|
-
*/
|
|
3502
|
-
title?: string
|
|
3503
|
-
/**
|
|
3504
|
-
* Optional description for the asset
|
|
3505
|
-
*/
|
|
3506
|
-
description?: string
|
|
3507
|
-
/**
|
|
3508
|
-
* The credit to person(s) and/or organization(s) required by the supplier of the asset to be used when published
|
|
3509
|
-
*/
|
|
3510
|
-
creditLine?: string
|
|
3511
|
-
/**
|
|
3512
|
-
* Source data (when the asset is from an external service)
|
|
3513
|
-
*/
|
|
3514
|
-
source?: {
|
|
3515
|
-
/**
|
|
3516
|
-
* The (u)id of the asset within the source, i.e. 'i-f323r1E'
|
|
3517
|
-
*/
|
|
3518
|
-
id: string
|
|
3519
|
-
/**
|
|
3520
|
-
* The name of the source, i.e. 'unsplash'
|
|
3521
|
-
*/
|
|
3522
|
-
name: string
|
|
3523
|
-
/**
|
|
3524
|
-
* A url to where to find the asset, or get more info about it in the source
|
|
3525
|
-
*/
|
|
3526
|
-
url?: string
|
|
3527
|
-
}
|
|
3528
|
-
}
|
|
3529
|
-
|
|
3530
550
|
/**
|
|
3531
551
|
*
|
|
3532
552
|
* @beta
|
|
@@ -3534,7 +554,7 @@ declare interface UploadClientConfig {
|
|
|
3534
554
|
* Provides a callback for applying one or more actions to a document.
|
|
3535
555
|
*
|
|
3536
556
|
* @category Documents
|
|
3537
|
-
* @param
|
|
557
|
+
* @param dataset - An optional dataset handle with projectId and dataset. If not provided, the nearest SanityInstance from context will be used.
|
|
3538
558
|
* @returns A function that takes one more more {@link DocumentAction}s and returns a promise that resolves to an {@link ActionsResult}.
|
|
3539
559
|
* @example Publish or unpublish a document
|
|
3540
560
|
* ```
|
|
@@ -3542,7 +562,7 @@ declare interface UploadClientConfig {
|
|
|
3542
562
|
* import { useApplyDocumentActions } from '@sanity/sdk-react'
|
|
3543
563
|
*
|
|
3544
564
|
* const apply = useApplyDocumentActions()
|
|
3545
|
-
* const myDocument = {
|
|
565
|
+
* const myDocument = { documentId: 'my-document-id', documentType: 'my-document-type' }
|
|
3546
566
|
*
|
|
3547
567
|
* return (
|
|
3548
568
|
* <button onClick={() => apply(publishDocument(myDocument))}>Publish</button>
|
|
@@ -3558,7 +578,7 @@ declare interface UploadClientConfig {
|
|
|
3558
578
|
* const apply = useApplyDocumentActions()
|
|
3559
579
|
*
|
|
3560
580
|
* const handleCreateAndPublish = () => {
|
|
3561
|
-
* const handle = {
|
|
581
|
+
* const handle = { documentId: window.crypto.randomUUID(), documentType: 'my-document-type' }
|
|
3562
582
|
* apply([
|
|
3563
583
|
* createDocument(handle),
|
|
3564
584
|
* publishDocument(handle),
|
|
@@ -3567,17 +587,15 @@ declare interface UploadClientConfig {
|
|
|
3567
587
|
*
|
|
3568
588
|
* return (
|
|
3569
589
|
* <button onClick={handleCreateAndPublish}>
|
|
3570
|
-
* I
|
|
590
|
+
* I'm feeling lucky
|
|
3571
591
|
* </button>
|
|
3572
592
|
* )
|
|
3573
593
|
* ```
|
|
3574
594
|
*/
|
|
3575
|
-
export declare
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
options?: ApplyDocumentActionsOptions,
|
|
3580
|
-
) => Promise<ActionsResult<TDocument>>
|
|
595
|
+
export declare const useApplyDocumentActions: () => (
|
|
596
|
+
action: DocumentAction | DocumentAction[],
|
|
597
|
+
options?: ApplyDocumentActionsOptions | undefined,
|
|
598
|
+
) => Promise<ActionsResult<SanityDocument>>
|
|
3581
599
|
|
|
3582
600
|
/**
|
|
3583
601
|
* @internal
|
|
@@ -3636,7 +654,7 @@ export declare const useAuthToken: () => string | null
|
|
|
3636
654
|
* @public
|
|
3637
655
|
* @function
|
|
3638
656
|
*/
|
|
3639
|
-
export declare const useClient: (
|
|
657
|
+
export declare const useClient: (x: ClientOptions) => SanityClient
|
|
3640
658
|
|
|
3641
659
|
declare type UseCurrentUser = {
|
|
3642
660
|
/**
|
|
@@ -3726,20 +744,26 @@ export declare const useDatasets: UseDatasets
|
|
|
3726
744
|
* ## useDocument(doc, path)
|
|
3727
745
|
* Read and subscribe to nested values in a document
|
|
3728
746
|
* @category Documents
|
|
3729
|
-
* @param doc - The document to read state from
|
|
3730
|
-
* the document will be read from the specified Sanity project and dataset that is included in the handle. If no `resourceId` is provided, the default project and dataset from your `SanityApp` configuration will be used.
|
|
747
|
+
* @param doc - The document to read state from, specified as a DocumentHandle
|
|
3731
748
|
* @param path - The path to the nested value to read from
|
|
3732
749
|
* @returns The value at the specified path
|
|
3733
750
|
* @example
|
|
3734
751
|
* ```tsx
|
|
3735
|
-
* import {
|
|
752
|
+
* import {useDocument} from '@sanity/sdk-react'
|
|
753
|
+
*
|
|
754
|
+
* const documentHandle = {
|
|
755
|
+
* documentId: 'order-123',
|
|
756
|
+
* documentType: 'order',
|
|
757
|
+
* projectId: 'abc123',
|
|
758
|
+
* dataset: 'production'
|
|
759
|
+
* }
|
|
3736
760
|
*
|
|
3737
|
-
* function OrderLink(
|
|
761
|
+
* function OrderLink() {
|
|
3738
762
|
* const title = useDocument(documentHandle, 'title')
|
|
3739
763
|
* const id = useDocument(documentHandle, '_id')
|
|
3740
764
|
*
|
|
3741
765
|
* return (
|
|
3742
|
-
* <a href
|
|
766
|
+
* <a href={`/order/${id}`}>Order {title} today!</a>
|
|
3743
767
|
* )
|
|
3744
768
|
* }
|
|
3745
769
|
* ```
|
|
@@ -3754,11 +778,11 @@ export declare function useDocument<
|
|
|
3754
778
|
* @beta
|
|
3755
779
|
* ## useDocument(doc)
|
|
3756
780
|
* Read and subscribe to an entire document
|
|
3757
|
-
* @param doc - The document to read state from
|
|
781
|
+
* @param doc - The document to read state from, specified as a DocumentHandle
|
|
3758
782
|
* @returns The document state as an object
|
|
3759
783
|
* @example
|
|
3760
784
|
* ```tsx
|
|
3761
|
-
* import {type SanityDocument,
|
|
785
|
+
* import {type SanityDocument, useDocument} from '@sanity/sdk-react'
|
|
3762
786
|
*
|
|
3763
787
|
* interface Book extends SanityDocument {
|
|
3764
788
|
* title: string
|
|
@@ -3766,19 +790,30 @@ export declare function useDocument<
|
|
|
3766
790
|
* summary: string
|
|
3767
791
|
* }
|
|
3768
792
|
*
|
|
3769
|
-
*
|
|
793
|
+
* const documentHandle = {
|
|
794
|
+
* documentId: 'book-123',
|
|
795
|
+
* documentType: 'book',
|
|
796
|
+
* projectId: 'abc123',
|
|
797
|
+
* dataset: 'production'
|
|
798
|
+
* }
|
|
799
|
+
*
|
|
800
|
+
* function DocumentView() {
|
|
3770
801
|
* const book = useDocument<Book>(documentHandle)
|
|
3771
802
|
*
|
|
803
|
+
* if (!book) {
|
|
804
|
+
* return <div>Loading...</div>
|
|
805
|
+
* }
|
|
806
|
+
*
|
|
3772
807
|
* return (
|
|
3773
808
|
* <article>
|
|
3774
|
-
* <h1>{book
|
|
3775
|
-
* <address>By {book
|
|
809
|
+
* <h1>{book.title}</h1>
|
|
810
|
+
* <address>By {book.author}</address>
|
|
3776
811
|
*
|
|
3777
812
|
* <h2>Summary</h2>
|
|
3778
|
-
* {book
|
|
813
|
+
* {book.summary}
|
|
3779
814
|
*
|
|
3780
815
|
* <h2>Order</h2>
|
|
3781
|
-
* <a href
|
|
816
|
+
* <a href={`/order/${book._id}`}>Order {book.title} today!</a>
|
|
3782
817
|
* </article>
|
|
3783
818
|
* )
|
|
3784
819
|
* }
|
|
@@ -3793,13 +828,14 @@ export declare function useDocument<TDocument extends SanityDocument>(
|
|
|
3793
828
|
*
|
|
3794
829
|
* @beta
|
|
3795
830
|
*
|
|
3796
|
-
* Subscribes an event handler to events in your application
|
|
831
|
+
* Subscribes an event handler to events in your application's document store, such as document
|
|
3797
832
|
* creation, deletion, and updates.
|
|
3798
833
|
*
|
|
3799
834
|
* @category Documents
|
|
3800
835
|
* @param handler - The event handler to register.
|
|
3801
|
-
* @param doc - The document to subscribe to events for. If you pass a `DocumentHandle` with
|
|
3802
|
-
* the document will be read from the specified Sanity project and dataset that is included in the handle. If no `
|
|
836
|
+
* @param doc - The document to subscribe to events for. If you pass a `DocumentHandle` with specified `projectId` and `dataset`,
|
|
837
|
+
* the document will be read from the specified Sanity project and dataset that is included in the handle. If no `projectId` or `dataset` is provided,
|
|
838
|
+
* the document will use the nearest instance from context.
|
|
3803
839
|
* @example
|
|
3804
840
|
* ```
|
|
3805
841
|
* import {useDocumentEvent} from '@sanity/sdk-react'
|
|
@@ -3816,7 +852,7 @@ export declare function useDocument<TDocument extends SanityDocument>(
|
|
|
3816
852
|
*/
|
|
3817
853
|
export declare function useDocumentEvent(
|
|
3818
854
|
handler: (documentEvent: DocumentEvent) => void,
|
|
3819
|
-
|
|
855
|
+
dataset: DatasetHandle,
|
|
3820
856
|
): void
|
|
3821
857
|
|
|
3822
858
|
/**
|
|
@@ -3826,7 +862,7 @@ export declare function useDocumentEvent(
|
|
|
3826
862
|
* Check if the current user has the specified permissions for the given document actions.
|
|
3827
863
|
*
|
|
3828
864
|
* @category Permissions
|
|
3829
|
-
* @param
|
|
865
|
+
* @param actionOrActions - One more more calls to a particular document action function for a given document
|
|
3830
866
|
* @returns An object that specifies whether the action is allowed; if the action is not allowed, an explanatory message and list of reasons is also provided.
|
|
3831
867
|
*
|
|
3832
868
|
* @example Checking for permission to publish a document
|
|
@@ -3858,7 +894,7 @@ export declare function useDocumentEvent(
|
|
|
3858
894
|
* ```
|
|
3859
895
|
*/
|
|
3860
896
|
export declare function useDocumentPermissions(
|
|
3861
|
-
|
|
897
|
+
actionOrActions: DocumentAction | DocumentAction[],
|
|
3862
898
|
): DocumentPermissionsResult
|
|
3863
899
|
|
|
3864
900
|
/**
|
|
@@ -3870,9 +906,15 @@ export declare function useDocumentPermissions(
|
|
|
3870
906
|
* @category Documents
|
|
3871
907
|
* @param options - Configuration options for the infinite list
|
|
3872
908
|
* @returns An object containing the list of document handles, the loading state, the total count of retrieved document handles, and a function to load more
|
|
3873
|
-
*
|
|
909
|
+
*
|
|
910
|
+
* @remarks
|
|
911
|
+
* - The returned document handles include projectId and dataset information from the current Sanity instance
|
|
912
|
+
* - This makes them ready to use with document operations and other document hooks
|
|
913
|
+
* - The hook automatically uses the correct Sanity instance based on the projectId and dataset in the options
|
|
914
|
+
*
|
|
915
|
+
* @example Basic infinite list with loading more
|
|
3874
916
|
* ```tsx
|
|
3875
|
-
* const {data, hasMore, isPending, loadMore} = useDocuments({
|
|
917
|
+
* const { data, hasMore, isPending, loadMore, count } = useDocuments({
|
|
3876
918
|
* filter: '_type == "post"',
|
|
3877
919
|
* search: searchTerm,
|
|
3878
920
|
* batchSize: 10,
|
|
@@ -3884,16 +926,17 @@ export declare function useDocumentPermissions(
|
|
|
3884
926
|
* Total documents: {count}
|
|
3885
927
|
* <ol>
|
|
3886
928
|
* {data.map((doc) => (
|
|
3887
|
-
* <li key={doc.
|
|
929
|
+
* <li key={doc.documentId}>
|
|
3888
930
|
* <MyDocumentComponent doc={doc} />
|
|
3889
931
|
* </li>
|
|
3890
932
|
* ))}
|
|
3891
933
|
* </ol>
|
|
3892
|
-
* {hasMore && <button onClick={loadMore}
|
|
934
|
+
* {hasMore && <button onClick={loadMore} disabled={isPending}>
|
|
935
|
+
* {isPending ? 'Loading...' : 'Load More'}
|
|
936
|
+
* </button>}
|
|
3893
937
|
* </div>
|
|
3894
938
|
* )
|
|
3895
939
|
* ```
|
|
3896
|
-
*
|
|
3897
940
|
*/
|
|
3898
941
|
export declare function useDocuments({
|
|
3899
942
|
batchSize,
|
|
@@ -3906,15 +949,16 @@ export declare function useDocuments({
|
|
|
3906
949
|
|
|
3907
950
|
declare type UseDocumentSyncStatus = {
|
|
3908
951
|
/**
|
|
3909
|
-
* Exposes the document
|
|
952
|
+
* Exposes the document's sync status between local and remote document states.
|
|
3910
953
|
*
|
|
3911
954
|
* @category Documents
|
|
3912
|
-
* @param doc - The document handle to get sync status for. If you pass a `DocumentHandle` with
|
|
3913
|
-
* the document will be read from the specified Sanity project and dataset that is included in the handle. If no `
|
|
955
|
+
* @param doc - The document handle to get sync status for. If you pass a `DocumentHandle` with specified `projectId` and `dataset`,
|
|
956
|
+
* the document will be read from the specified Sanity project and dataset that is included in the handle. If no `projectId` or `dataset` is provided,
|
|
957
|
+
* the document will use the nearest instance from context.
|
|
3914
958
|
* @returns `true` if local changes are synced with remote, `false` if the changes are not synced, and `undefined` if the document is not found
|
|
3915
959
|
* @example Disable a Save button when there are no changes to sync
|
|
3916
960
|
* ```
|
|
3917
|
-
* const myDocumentHandle = {
|
|
961
|
+
* const myDocumentHandle = { documentId: 'documentId', documentType: 'documentType', projectId: 'projectId', dataset: 'dataset' }
|
|
3918
962
|
* const documentSynced = useDocumentSyncStatus(myDocumentHandle)
|
|
3919
963
|
*
|
|
3920
964
|
* return (
|
|
@@ -3941,12 +985,18 @@ export declare const useDocumentSyncStatus: UseDocumentSyncStatus
|
|
|
3941
985
|
* Edit a nested value within a document
|
|
3942
986
|
*
|
|
3943
987
|
* @category Documents
|
|
3944
|
-
* @param
|
|
988
|
+
* @param docHandle - The document to be edited, specified as a DocumentHandle
|
|
3945
989
|
* @param path - The path to the nested value to be edited
|
|
3946
990
|
* @returns A function to update the nested value. Accepts either a new value, or an updater function that exposes the previous value and returns a new value.
|
|
3947
|
-
* @example Update a document
|
|
3948
|
-
* ```
|
|
3949
|
-
* const handle = {
|
|
991
|
+
* @example Update a document's name by providing the new value directly
|
|
992
|
+
* ```tsx
|
|
993
|
+
* const handle = {
|
|
994
|
+
* documentId: 'movie-123',
|
|
995
|
+
* documentType: 'movie',
|
|
996
|
+
* projectId: 'abc123',
|
|
997
|
+
* dataset: 'production'
|
|
998
|
+
* }
|
|
999
|
+
*
|
|
3950
1000
|
* const name = useDocument(handle, 'name')
|
|
3951
1001
|
* const editName = useEditDocument(handle, 'name')
|
|
3952
1002
|
*
|
|
@@ -3960,8 +1010,14 @@ export declare const useDocumentSyncStatus: UseDocumentSyncStatus
|
|
|
3960
1010
|
* ```
|
|
3961
1011
|
*
|
|
3962
1012
|
* @example Update a count on a document by providing an updater function
|
|
3963
|
-
* ```
|
|
3964
|
-
* const handle = {
|
|
1013
|
+
* ```tsx
|
|
1014
|
+
* const handle = {
|
|
1015
|
+
* documentId: 'counter-123',
|
|
1016
|
+
* documentType: 'counter',
|
|
1017
|
+
* projectId: 'abc123',
|
|
1018
|
+
* dataset: 'production'
|
|
1019
|
+
* }
|
|
1020
|
+
*
|
|
3965
1021
|
* const count = useDocument(handle, 'count')
|
|
3966
1022
|
* const editCount = useEditDocument(handle, 'count')
|
|
3967
1023
|
*
|
|
@@ -3983,7 +1039,7 @@ export declare function useEditDocument<
|
|
|
3983
1039
|
TDocument extends SanityDocument,
|
|
3984
1040
|
TPath extends JsonMatchPath<TDocument>,
|
|
3985
1041
|
>(
|
|
3986
|
-
|
|
1042
|
+
docHandle: DocumentHandle<TDocument>,
|
|
3987
1043
|
path: TPath,
|
|
3988
1044
|
): (nextValue: Updater<JsonMatch<TDocument, TPath>>) => Promise<ActionsResult<TDocument>>
|
|
3989
1045
|
|
|
@@ -3993,15 +1049,20 @@ export declare function useEditDocument<
|
|
|
3993
1049
|
*
|
|
3994
1050
|
* ## useEditDocument(doc)
|
|
3995
1051
|
* Edit an entire document
|
|
3996
|
-
* @param
|
|
3997
|
-
*
|
|
1052
|
+
* @param docHandle - The document to be edited, specified as a DocumentHandle.
|
|
1053
|
+
* The hook will automatically use the Sanity instance that matches the project and dataset specified in the handle.
|
|
3998
1054
|
* @returns A function to update the document state. Accepts either a new document state, or an updater function that exposes the previous document state and returns the new document state.
|
|
3999
1055
|
* @example
|
|
4000
|
-
* ```
|
|
4001
|
-
* const myDocumentHandle = {
|
|
1056
|
+
* ```tsx
|
|
1057
|
+
* const myDocumentHandle = {
|
|
1058
|
+
* documentId: 'product-123',
|
|
1059
|
+
* documentType: 'product',
|
|
1060
|
+
* projectId: 'abc123',
|
|
1061
|
+
* dataset: 'production'
|
|
1062
|
+
* }
|
|
4002
1063
|
*
|
|
4003
1064
|
* const myDocument = useDocument(myDocumentHandle)
|
|
4004
|
-
* const { title, price } = myDocument
|
|
1065
|
+
* const { title, price } = myDocument ?? {}
|
|
4005
1066
|
*
|
|
4006
1067
|
* const editMyDocument = useEditDocument(myDocumentHandle)
|
|
4007
1068
|
*
|
|
@@ -4039,7 +1100,7 @@ export declare function useEditDocument<
|
|
|
4039
1100
|
* <input
|
|
4040
1101
|
* name='salePrice'
|
|
4041
1102
|
* type='checkbox'
|
|
4042
|
-
* checked={
|
|
1103
|
+
* checked={myDocument && 'salePrice' in myDocument}
|
|
4043
1104
|
* onChange={handleSaleChange}
|
|
4044
1105
|
* />
|
|
4045
1106
|
* </form>
|
|
@@ -4051,7 +1112,7 @@ export declare function useEditDocument<
|
|
|
4051
1112
|
* ```
|
|
4052
1113
|
*/
|
|
4053
1114
|
export declare function useEditDocument<TDocument extends SanityDocument>(
|
|
4054
|
-
|
|
1115
|
+
docHandle: DocumentHandle<TDocument>,
|
|
4055
1116
|
): (nextValue: Updater<TDocument>) => Promise<ActionsResult<TDocument>>
|
|
4056
1117
|
|
|
4057
1118
|
/**
|
|
@@ -4128,45 +1189,9 @@ export declare const useHandleAuthCallback: () => (
|
|
|
4128
1189
|
) => Promise<string | false>
|
|
4129
1190
|
|
|
4130
1191
|
/**
|
|
4131
|
-
* @internal
|
|
4132
|
-
* A React hook that retrieves the available authentication provider URLs for login.
|
|
4133
|
-
*
|
|
4134
|
-
* @remarks
|
|
4135
|
-
* This hook fetches the login URLs from the Sanity auth store when the component mounts.
|
|
4136
|
-
* Each provider object contains information about an authentication method, including its URL.
|
|
4137
|
-
* The hook will suspend if the login URLs have not yet loaded.
|
|
4138
|
-
*
|
|
4139
|
-
* @example
|
|
4140
|
-
* ```tsx
|
|
4141
|
-
* // LoginProviders component that uses the hook
|
|
4142
|
-
* function LoginProviders() {
|
|
4143
|
-
* const providers = useLoginUrls()
|
|
4144
|
-
*
|
|
4145
|
-
* return (
|
|
4146
|
-
* <div>
|
|
4147
|
-
* {providers.map((provider) => (
|
|
4148
|
-
* <a key={provider.name} href={provider.url}>
|
|
4149
|
-
* Login with {provider.title}
|
|
4150
|
-
* </a>
|
|
4151
|
-
* ))}
|
|
4152
|
-
* </div>
|
|
4153
|
-
* )
|
|
4154
|
-
* }
|
|
4155
|
-
*
|
|
4156
|
-
* // Parent component with Suspense boundary
|
|
4157
|
-
* function LoginPage() {
|
|
4158
|
-
* return (
|
|
4159
|
-
* <Suspense fallback={<div>Loading authentication providers...</div>}>
|
|
4160
|
-
* <LoginProviders />
|
|
4161
|
-
* </Suspense>
|
|
4162
|
-
* )
|
|
4163
|
-
* }
|
|
4164
|
-
* ```
|
|
4165
|
-
*
|
|
4166
|
-
* @returns An array of {@link AuthProvider} objects containing login URLs and provider information
|
|
4167
1192
|
* @public
|
|
4168
1193
|
*/
|
|
4169
|
-
export declare function
|
|
1194
|
+
export declare function useLoginUrl(): string
|
|
4170
1195
|
|
|
4171
1196
|
/**
|
|
4172
1197
|
* Hook to log out of the current session
|
|
@@ -4211,13 +1236,13 @@ export declare const useLogOut: () => () => Promise<void>
|
|
|
4211
1236
|
export declare function useManageFavorite({
|
|
4212
1237
|
documentId,
|
|
4213
1238
|
documentType,
|
|
4214
|
-
|
|
1239
|
+
projectId: paramProjectId,
|
|
1240
|
+
dataset: paramDataset,
|
|
1241
|
+
resourceId: paramResourceId,
|
|
4215
1242
|
resourceType,
|
|
4216
1243
|
}: UseManageFavoriteProps): ManageFavorite
|
|
4217
1244
|
|
|
4218
|
-
declare interface UseManageFavoriteProps {
|
|
4219
|
-
documentId: string
|
|
4220
|
-
documentType: string
|
|
1245
|
+
declare interface UseManageFavoriteProps extends DocumentHandle {
|
|
4221
1246
|
resourceId?: string
|
|
4222
1247
|
resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']
|
|
4223
1248
|
}
|
|
@@ -4268,7 +1293,13 @@ export declare function useNavigateToStudioDocument(
|
|
|
4268
1293
|
* @category Documents
|
|
4269
1294
|
* @param options - Configuration options for the paginated list
|
|
4270
1295
|
* @returns An object containing the current page of document handles, the loading and pagination state, and navigation functions
|
|
4271
|
-
*
|
|
1296
|
+
*
|
|
1297
|
+
* @remarks
|
|
1298
|
+
* - The returned document handles include projectId and dataset information from the current Sanity instance
|
|
1299
|
+
* - This makes them ready to use with document operations and other document hooks
|
|
1300
|
+
* - The hook automatically uses the correct Sanity instance based on the projectId and dataset in the options
|
|
1301
|
+
*
|
|
1302
|
+
* @example Basic usage
|
|
4272
1303
|
* ```tsx
|
|
4273
1304
|
* const {
|
|
4274
1305
|
* data,
|
|
@@ -4290,14 +1321,12 @@ export declare function useNavigateToStudioDocument(
|
|
|
4290
1321
|
* <>
|
|
4291
1322
|
* <table>
|
|
4292
1323
|
* {data.map(doc => (
|
|
4293
|
-
* <MyTableRowComponent key={doc.
|
|
1324
|
+
* <MyTableRowComponent key={doc.documentId} doc={doc} />
|
|
4294
1325
|
* ))}
|
|
4295
1326
|
* </table>
|
|
4296
|
-
*
|
|
4297
|
-
*
|
|
4298
|
-
*
|
|
4299
|
-
* {hasNextPage && <button onClick={nextPage}>Next</button>}
|
|
4300
|
-
* </>
|
|
1327
|
+
* {hasPreviousPage && <button onClick={previousPage}>Previous</button>}
|
|
1328
|
+
* {currentPage} / {totalPages}
|
|
1329
|
+
* {hasNextPage && <button onClick={nextPage}>Next</button>}
|
|
4301
1330
|
* </>
|
|
4302
1331
|
* )
|
|
4303
1332
|
* ```
|
|
@@ -4310,7 +1339,7 @@ export declare function usePaginatedDocuments({
|
|
|
4310
1339
|
orderings,
|
|
4311
1340
|
search,
|
|
4312
1341
|
...options
|
|
4313
|
-
}
|
|
1342
|
+
}: PaginatedDocumentsOptions): PaginatedDocumentsResponse
|
|
4314
1343
|
|
|
4315
1344
|
/**
|
|
4316
1345
|
* @beta
|
|
@@ -4356,17 +1385,17 @@ export declare function usePaginatedDocuments({
|
|
|
4356
1385
|
* )
|
|
4357
1386
|
* ```
|
|
4358
1387
|
*/
|
|
4359
|
-
export declare function usePreview({
|
|
4360
|
-
document: {_id, _type},
|
|
4361
|
-
ref,
|
|
4362
|
-
}: UsePreviewOptions): UsePreviewResults
|
|
1388
|
+
export declare function usePreview({ref, ...docHandle}: UsePreviewOptions): UsePreviewResults
|
|
4363
1389
|
|
|
4364
1390
|
/**
|
|
4365
1391
|
* @beta
|
|
4366
1392
|
* @category Types
|
|
4367
1393
|
*/
|
|
4368
|
-
export declare interface UsePreviewOptions {
|
|
4369
|
-
|
|
1394
|
+
export declare interface UsePreviewOptions extends DocumentHandle {
|
|
1395
|
+
/**
|
|
1396
|
+
* Optional ref object to track visibility. When provided, preview resolution
|
|
1397
|
+
* only occurs when the referenced element is visible in the viewport.
|
|
1398
|
+
*/
|
|
4370
1399
|
ref?: React.RefObject<unknown>
|
|
4371
1400
|
}
|
|
4372
1401
|
|
|
@@ -4402,7 +1431,7 @@ declare type UseProject = {
|
|
|
4402
1431
|
* }
|
|
4403
1432
|
* ```
|
|
4404
1433
|
*/
|
|
4405
|
-
(
|
|
1434
|
+
(projectHandle?: ProjectHandle): SanityProject_2
|
|
4406
1435
|
}
|
|
4407
1436
|
|
|
4408
1437
|
/**
|
|
@@ -4470,28 +1499,27 @@ export declare const useProject: UseProject
|
|
|
4470
1499
|
* )
|
|
4471
1500
|
* ```
|
|
4472
1501
|
*/
|
|
4473
|
-
export declare function useProjection<
|
|
4474
|
-
document: {_id, _type},
|
|
4475
|
-
projection,
|
|
1502
|
+
export declare function useProjection<TData extends object>({
|
|
4476
1503
|
ref,
|
|
4477
|
-
|
|
1504
|
+
projection,
|
|
1505
|
+
...docHandle
|
|
1506
|
+
}: UseProjectionOptions): UseProjectionResults<TData>
|
|
4478
1507
|
|
|
4479
1508
|
/**
|
|
4480
1509
|
* @public
|
|
4481
1510
|
* @category Types
|
|
4482
1511
|
*/
|
|
4483
|
-
export declare interface UseProjectionOptions {
|
|
4484
|
-
document: DocumentHandle
|
|
4485
|
-
projection: ValidProjection
|
|
1512
|
+
export declare interface UseProjectionOptions extends DocumentHandle {
|
|
4486
1513
|
ref?: React.RefObject<unknown>
|
|
1514
|
+
projection: ValidProjection
|
|
4487
1515
|
}
|
|
4488
1516
|
|
|
4489
1517
|
/**
|
|
4490
1518
|
* @public
|
|
4491
1519
|
* @category Types
|
|
4492
1520
|
*/
|
|
4493
|
-
export declare interface UseProjectionResults<
|
|
4494
|
-
data:
|
|
1521
|
+
export declare interface UseProjectionResults<TData extends object> {
|
|
1522
|
+
data: TData
|
|
4495
1523
|
isPending: boolean
|
|
4496
1524
|
}
|
|
4497
1525
|
|
|
@@ -4528,7 +1556,7 @@ export declare const useProjects: UseProjects
|
|
|
4528
1556
|
* Executes GROQ queries against a Sanity dataset.
|
|
4529
1557
|
*
|
|
4530
1558
|
* This hook provides a convenient way to fetch and subscribe to real-time updates
|
|
4531
|
-
* for your Sanity content. Changes made to the dataset
|
|
1559
|
+
* for your Sanity content. Changes made to the dataset's content will trigger
|
|
4532
1560
|
* automatic updates.
|
|
4533
1561
|
*
|
|
4534
1562
|
* @remarks
|
|
@@ -4538,7 +1566,7 @@ export declare const useProjects: UseProjects
|
|
|
4538
1566
|
* @beta
|
|
4539
1567
|
* @category GROQ
|
|
4540
1568
|
* @param query - GROQ query string to execute
|
|
4541
|
-
* @param options - Optional configuration for the query
|
|
1569
|
+
* @param options - Optional configuration for the query, including projectId and dataset
|
|
4542
1570
|
* @returns Object containing the query result and a pending state flag
|
|
4543
1571
|
*
|
|
4544
1572
|
* @example Basic usage
|
|
@@ -4554,6 +1582,15 @@ export declare const useProjects: UseProjects
|
|
|
4554
1582
|
* })
|
|
4555
1583
|
* ```
|
|
4556
1584
|
*
|
|
1585
|
+
* @example Query from a specific project/dataset
|
|
1586
|
+
* ```tsx
|
|
1587
|
+
* // Specify which project and dataset to query
|
|
1588
|
+
* const {data} = useQuery<Movie[]>('*[_type == "movie"]', {
|
|
1589
|
+
* projectId: 'abc123',
|
|
1590
|
+
* dataset: 'production'
|
|
1591
|
+
* })
|
|
1592
|
+
* ```
|
|
1593
|
+
*
|
|
4557
1594
|
* @example With a loading state for transitions
|
|
4558
1595
|
* ```tsx
|
|
4559
1596
|
* const {data, isPending} = useQuery<Movie[]>('*[_type == "movie"]')
|
|
@@ -4617,44 +1654,94 @@ export declare function useRecordDocumentHistoryEvent({
|
|
|
4617
1654
|
/**
|
|
4618
1655
|
* @public
|
|
4619
1656
|
*/
|
|
4620
|
-
declare interface UseRecordDocumentHistoryEventProps {
|
|
4621
|
-
documentId: string
|
|
4622
|
-
documentType: string
|
|
1657
|
+
declare interface UseRecordDocumentHistoryEventProps extends DocumentHandle {
|
|
4623
1658
|
resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']
|
|
4624
1659
|
resourceId?: string
|
|
4625
1660
|
}
|
|
4626
1661
|
|
|
4627
|
-
/**
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
1662
|
+
/**
|
|
1663
|
+
* @public
|
|
1664
|
+
* @category Types
|
|
1665
|
+
*/
|
|
1666
|
+
export declare interface UsersResult {
|
|
4631
1667
|
/**
|
|
4632
|
-
*
|
|
4633
|
-
|
|
4634
|
-
|
|
1668
|
+
* The users fetched.
|
|
1669
|
+
*/
|
|
1670
|
+
data: SanityUser[]
|
|
1671
|
+
/**
|
|
1672
|
+
* Whether there are more users to fetch.
|
|
1673
|
+
*/
|
|
1674
|
+
hasMore: boolean
|
|
1675
|
+
/**
|
|
1676
|
+
* Whether a users request is currently in progress
|
|
1677
|
+
*/
|
|
1678
|
+
isPending: boolean
|
|
1679
|
+
/**
|
|
1680
|
+
* Load more users.
|
|
4635
1681
|
*/
|
|
4636
|
-
|
|
1682
|
+
loadMore: () => void
|
|
4637
1683
|
}
|
|
4638
1684
|
|
|
4639
1685
|
/**
|
|
4640
|
-
*
|
|
4641
|
-
* This must be called from within a `SanityProvider` component.
|
|
4642
|
-
* @internal
|
|
1686
|
+
* Retrieves the current Sanity instance or finds a matching instance from the hierarchy
|
|
4643
1687
|
*
|
|
4644
|
-
* @
|
|
4645
|
-
*
|
|
4646
|
-
* @
|
|
1688
|
+
* @public
|
|
1689
|
+
*
|
|
1690
|
+
* @param config - Optional configuration to match against when finding an instance
|
|
1691
|
+
* @returns The current or matching Sanity instance
|
|
1692
|
+
*
|
|
1693
|
+
* @remarks
|
|
1694
|
+
* This hook accesses the nearest Sanity instance from the React context. When provided with
|
|
1695
|
+
* a configuration object, it traverses up the instance hierarchy to find the closest instance
|
|
1696
|
+
* that matches the specified configuration using shallow comparison of properties.
|
|
1697
|
+
*
|
|
1698
|
+
* The hook must be used within a component wrapped by a `ResourceProvider` or `SanityApp`.
|
|
1699
|
+
*
|
|
1700
|
+
* Use this hook when you need to:
|
|
1701
|
+
* - Access the current SanityInstance from context
|
|
1702
|
+
* - Find a specific instance with matching project/dataset configuration
|
|
1703
|
+
* - Access a parent instance with specific configuration values
|
|
1704
|
+
*
|
|
1705
|
+
* @example Get the current instance
|
|
4647
1706
|
* ```tsx
|
|
4648
|
-
*
|
|
1707
|
+
* // Get the current instance from context
|
|
1708
|
+
* const instance = useSanityInstance()
|
|
1709
|
+
* console.log(instance.config.projectId)
|
|
4649
1710
|
* ```
|
|
1711
|
+
*
|
|
1712
|
+
* @example Find an instance with specific configuration
|
|
1713
|
+
* ```tsx
|
|
1714
|
+
* // Find an instance matching the given project and dataset
|
|
1715
|
+
* const instance = useSanityInstance({
|
|
1716
|
+
* projectId: 'abc123',
|
|
1717
|
+
* dataset: 'production'
|
|
1718
|
+
* })
|
|
1719
|
+
*
|
|
1720
|
+
* // Use instance for API calls
|
|
1721
|
+
* const fetchDocument = (docId) => {
|
|
1722
|
+
* // Instance is guaranteed to have the matching config
|
|
1723
|
+
* return client.fetch(`*[_id == $id][0]`, { id: docId })
|
|
1724
|
+
* }
|
|
1725
|
+
* ```
|
|
1726
|
+
*
|
|
1727
|
+
* @example Match partial configuration
|
|
1728
|
+
* ```tsx
|
|
1729
|
+
* // Find an instance with specific auth configuration
|
|
1730
|
+
* const instance = useSanityInstance({
|
|
1731
|
+
* auth: { requireLogin: true }
|
|
1732
|
+
* })
|
|
1733
|
+
* ```
|
|
1734
|
+
*
|
|
1735
|
+
* @throws Error if no SanityInstance is found in context
|
|
1736
|
+
* @throws Error if no matching instance is found for the provided config
|
|
4650
1737
|
*/
|
|
4651
|
-
export declare const useSanityInstance: (
|
|
1738
|
+
export declare const useSanityInstance: (config?: SanityConfig) => SanityInstance
|
|
4652
1739
|
|
|
4653
1740
|
/**
|
|
4654
1741
|
* Hook that fetches studio workspaces and organizes them by projectId:dataset
|
|
4655
1742
|
* @internal
|
|
4656
1743
|
*/
|
|
4657
|
-
export declare function
|
|
1744
|
+
export declare function useStudioWorkspacesByProjectIdDataset(): StudioWorkspacesResult
|
|
4658
1745
|
|
|
4659
1746
|
/**
|
|
4660
1747
|
*
|
|
@@ -4663,70 +1750,32 @@ export declare function useStudioWorkspacesByResourceId(): StudioWorkspacesResul
|
|
|
4663
1750
|
* Retrieves the users for a given resource (either a project or an organization).
|
|
4664
1751
|
*
|
|
4665
1752
|
* @category Users
|
|
4666
|
-
* @param params - The resource type
|
|
1753
|
+
* @param params - The resource type, project ID, and the limit of users to fetch
|
|
4667
1754
|
* @returns A list of users, a boolean indicating whether there are more users to fetch, and a function to load more users
|
|
4668
1755
|
*
|
|
4669
1756
|
* @example
|
|
4670
1757
|
* ```
|
|
4671
|
-
* const {
|
|
1758
|
+
* const { data, hasMore, loadMore, isPending } = useUsers({
|
|
4672
1759
|
* resourceType: 'organization',
|
|
4673
|
-
*
|
|
4674
|
-
*
|
|
1760
|
+
* organizationId: 'my-org-id',
|
|
1761
|
+
* batchSize: 10,
|
|
4675
1762
|
* })
|
|
4676
1763
|
*
|
|
4677
1764
|
* return (
|
|
4678
1765
|
* <div>
|
|
4679
|
-
* {
|
|
1766
|
+
* {data.map(user => (
|
|
4680
1767
|
* <figure key={user.sanityUserId}>
|
|
4681
1768
|
* <img src={user.profile.imageUrl} alt='' />
|
|
4682
1769
|
* <figcaption>{user.profile.displayName}</figcaption>
|
|
4683
1770
|
* <address>{user.profile.email}</address>
|
|
4684
1771
|
* </figure>
|
|
4685
1772
|
* ))}
|
|
4686
|
-
* {hasMore && <button onClick={loadMore}>Load More</button>}
|
|
1773
|
+
* {hasMore && <button onClick={loadMore}>{isPending ? 'Loading...' : 'Load More'</button>}
|
|
4687
1774
|
* </div>
|
|
4688
1775
|
* )
|
|
4689
1776
|
* ```
|
|
4690
1777
|
*/
|
|
4691
|
-
export declare function useUsers(
|
|
4692
|
-
|
|
4693
|
-
/**
|
|
4694
|
-
* @public
|
|
4695
|
-
* @category Types
|
|
4696
|
-
*/
|
|
4697
|
-
export declare interface UseUsersParams {
|
|
4698
|
-
/**
|
|
4699
|
-
* The type of resource to fetch users for.
|
|
4700
|
-
*/
|
|
4701
|
-
resourceType: ResourceType
|
|
4702
|
-
/**
|
|
4703
|
-
* The ID of the resource to fetch users for.
|
|
4704
|
-
*/
|
|
4705
|
-
resourceId: string
|
|
4706
|
-
/**
|
|
4707
|
-
* The limit of users to fetch.
|
|
4708
|
-
*/
|
|
4709
|
-
limit?: number
|
|
4710
|
-
}
|
|
4711
|
-
|
|
4712
|
-
/**
|
|
4713
|
-
* @public
|
|
4714
|
-
* @category Types
|
|
4715
|
-
*/
|
|
4716
|
-
export declare interface UseUsersResult {
|
|
4717
|
-
/**
|
|
4718
|
-
* The users fetched.
|
|
4719
|
-
*/
|
|
4720
|
-
users: SanityUser_2[]
|
|
4721
|
-
/**
|
|
4722
|
-
* Whether there are more users to fetch.
|
|
4723
|
-
*/
|
|
4724
|
-
hasMore: boolean
|
|
4725
|
-
/**
|
|
4726
|
-
* Load more users.
|
|
4727
|
-
*/
|
|
4728
|
-
loadMore: () => void
|
|
4729
|
-
}
|
|
1778
|
+
export declare function useUsers(options?: GetUsersOptions): UsersResult
|
|
4730
1779
|
|
|
4731
1780
|
/**
|
|
4732
1781
|
* @internal
|
|
@@ -4757,17 +1806,6 @@ export declare interface UseWindowConnectionOptions<TMessage extends FrameMessag
|
|
|
4757
1806
|
onStatus?: (status: ComlinkStatus) => void
|
|
4758
1807
|
}
|
|
4759
1808
|
|
|
4760
|
-
/**
|
|
4761
|
-
* The listener has been established, and will start receiving events.
|
|
4762
|
-
* Note that this is also emitted upon _reconnection_.
|
|
4763
|
-
*
|
|
4764
|
-
* @public
|
|
4765
|
-
*/
|
|
4766
|
-
declare type WelcomeEvent = {
|
|
4767
|
-
type: 'welcome'
|
|
4768
|
-
listenerName: string
|
|
4769
|
-
}
|
|
4770
|
-
|
|
4771
1809
|
/**
|
|
4772
1810
|
* @internal
|
|
4773
1811
|
*/
|
|
@@ -4809,8 +1847,10 @@ declare interface Workspace {
|
|
|
4809
1847
|
_ref: string
|
|
4810
1848
|
}
|
|
4811
1849
|
|
|
4812
|
-
declare interface
|
|
4813
|
-
[key: string]: Workspace[]
|
|
1850
|
+
declare interface WorkspacesByProjectIdDataset {
|
|
1851
|
+
[key: `${string}:${string}`]: Workspace[]
|
|
4814
1852
|
}
|
|
4815
1853
|
|
|
1854
|
+
export * from '@sanity/sdk'
|
|
1855
|
+
|
|
4816
1856
|
export {}
|