@sanity/sdk-react 0.0.0-alpha.21 → 0.0.0-alpha.23
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 +502 -3460
- package/dist/index.js +400 -465
- package/dist/index.js.map +1 -1
- package/package.json +17 -15
- package/src/_exports/index.ts +4 -5
- 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,354 @@ 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
|
+
export {CurrentUser}
|
|
100
|
+
|
|
101
|
+
/** @public */
|
|
102
|
+
declare type DatasetAclMode = 'public' | 'private' | 'custom'
|
|
103
|
+
|
|
104
|
+
/** @public */
|
|
105
|
+
export declare type DatasetsResponse = {
|
|
106
|
+
name: string
|
|
107
|
+
aclMode: DatasetAclMode
|
|
108
|
+
createdAt: string
|
|
109
|
+
createdByUserId: string
|
|
110
|
+
addonFor: string | null
|
|
111
|
+
datasetProfile: string
|
|
112
|
+
features: string[]
|
|
113
|
+
tags: string[]
|
|
114
|
+
}[]
|
|
115
|
+
|
|
116
|
+
export {DocumentHandle}
|
|
174
117
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
returnDocuments?: boolean
|
|
179
|
-
returnFirst?: boolean
|
|
180
|
-
dryRun?: boolean
|
|
181
|
-
autoGenerateArrayKeys?: boolean
|
|
182
|
-
skipCrossDatasetReferenceValidation?: boolean
|
|
183
|
-
transactionId?: string
|
|
118
|
+
declare interface DocumentInteractionHistory {
|
|
119
|
+
recordEvent: (eventType: 'viewed' | 'edited' | 'created' | 'deleted') => void
|
|
120
|
+
isConnected: boolean
|
|
184
121
|
}
|
|
185
122
|
|
|
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
|
|
123
|
+
/**
|
|
124
|
+
* Configuration options for the useDocuments hook
|
|
125
|
+
*
|
|
126
|
+
* @beta
|
|
127
|
+
* @category Types
|
|
128
|
+
*/
|
|
129
|
+
export declare interface DocumentsOptions extends QueryOptions {
|
|
198
130
|
/**
|
|
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"\}
|
|
131
|
+
* GROQ filter expression to apply to the query
|
|
203
132
|
*/
|
|
204
|
-
|
|
133
|
+
filter?: string
|
|
205
134
|
/**
|
|
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"\}
|
|
135
|
+
* Number of items to load per batch (defaults to 25)
|
|
210
136
|
*/
|
|
211
|
-
|
|
137
|
+
batchSize?: number
|
|
212
138
|
/**
|
|
213
|
-
*
|
|
214
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
215
|
-
*
|
|
216
|
-
* @param attrs - Attribute paths to unset.
|
|
139
|
+
* Sorting configuration for the results
|
|
217
140
|
*/
|
|
218
|
-
|
|
141
|
+
orderings?: SortOrderingItem[]
|
|
219
142
|
/**
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
* @param attrs - Object of attribute paths to increment, values representing the number to increment by.
|
|
143
|
+
* Text search query to filter results
|
|
223
144
|
*/
|
|
224
|
-
|
|
145
|
+
search?: string
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Return value from the useDocuments hook
|
|
150
|
+
*
|
|
151
|
+
* @beta
|
|
152
|
+
* @category Types
|
|
153
|
+
*/
|
|
154
|
+
export declare interface DocumentsResponse {
|
|
225
155
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* @param attrs - Object of attribute paths to decrement, values representing the number to decrement by.
|
|
156
|
+
* Array of document handles for the current batch
|
|
229
157
|
*/
|
|
230
|
-
|
|
158
|
+
data: DocumentHandle[]
|
|
231
159
|
/**
|
|
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
|
|
160
|
+
* Whether there are more items available to load
|
|
237
161
|
*/
|
|
238
|
-
|
|
162
|
+
hasMore: boolean
|
|
239
163
|
/**
|
|
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
|
|
164
|
+
* Total count of items matching the query
|
|
244
165
|
*/
|
|
245
|
-
|
|
166
|
+
count: number
|
|
246
167
|
/**
|
|
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
|
|
168
|
+
* Whether a query is currently in progress
|
|
251
169
|
*/
|
|
252
|
-
|
|
170
|
+
isPending: boolean
|
|
253
171
|
/**
|
|
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.
|
|
172
|
+
* Function to load the next batch of results
|
|
260
173
|
*/
|
|
261
|
-
|
|
174
|
+
loadMore: () => void
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
export declare interface FrameConnection<TFrameMessage extends FrameMessage> {
|
|
181
|
+
connect: (frameWindow: Window) => () => void
|
|
182
|
+
sendMessage: <T extends TFrameMessage['type']>(
|
|
183
|
+
...params: Extract<
|
|
184
|
+
TFrameMessage,
|
|
185
|
+
{
|
|
186
|
+
type: T
|
|
187
|
+
}
|
|
188
|
+
>['data'] extends undefined
|
|
189
|
+
? [type: T]
|
|
190
|
+
: [
|
|
191
|
+
type: T,
|
|
192
|
+
data: Extract<
|
|
193
|
+
TFrameMessage,
|
|
194
|
+
{
|
|
195
|
+
type: T
|
|
196
|
+
}
|
|
197
|
+
>['data'],
|
|
198
|
+
]
|
|
199
|
+
) => void
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @alpha
|
|
204
|
+
*/
|
|
205
|
+
declare type LoginErrorProps = FallbackProps
|
|
206
|
+
|
|
207
|
+
declare interface ManageFavorite {
|
|
208
|
+
favorite: () => void
|
|
209
|
+
unfavorite: () => void
|
|
210
|
+
isFavorited: boolean
|
|
211
|
+
isConnected: boolean
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
declare type MessageData = Record<string, unknown> | undefined
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @internal
|
|
221
|
+
*/
|
|
222
|
+
export declare type MessageHandler<TWindowMessage extends WindowMessage> = (
|
|
223
|
+
event: TWindowMessage['data'],
|
|
224
|
+
) => TWindowMessage['response'] | Promise<TWindowMessage['response']>
|
|
225
|
+
|
|
226
|
+
declare interface NavigateToStudioResult {
|
|
227
|
+
navigateToStudioDocument: () => void
|
|
228
|
+
isConnected: boolean
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Configuration options for the usePaginatedDocuments hook
|
|
233
|
+
*
|
|
234
|
+
* @beta
|
|
235
|
+
* @category Types
|
|
236
|
+
*/
|
|
237
|
+
export declare interface PaginatedDocumentsOptions extends QueryOptions {
|
|
262
238
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* @param rev - Revision to lock the patch to
|
|
239
|
+
* GROQ filter expression to apply to the query
|
|
266
240
|
*/
|
|
267
|
-
|
|
241
|
+
filter?: string
|
|
268
242
|
/**
|
|
269
|
-
*
|
|
243
|
+
* Number of items to display per page (defaults to 25)
|
|
270
244
|
*/
|
|
271
|
-
|
|
245
|
+
pageSize?: number
|
|
272
246
|
/**
|
|
273
|
-
*
|
|
247
|
+
* Sorting configuration for the results
|
|
274
248
|
*/
|
|
275
|
-
|
|
249
|
+
orderings?: SortOrderingItem[]
|
|
276
250
|
/**
|
|
277
|
-
*
|
|
251
|
+
* Text search query to filter results
|
|
278
252
|
*/
|
|
279
|
-
|
|
280
|
-
protected _assign(op: keyof PatchOperations, props: Any, merge?: boolean): this
|
|
281
|
-
protected _set(op: keyof PatchOperations, props: Any): this
|
|
253
|
+
search?: string
|
|
282
254
|
}
|
|
283
255
|
|
|
284
|
-
/**
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Return value from the usePaginatedDocuments hook
|
|
258
|
+
*
|
|
259
|
+
* @beta
|
|
260
|
+
* @category Types
|
|
261
|
+
*/
|
|
262
|
+
export declare interface PaginatedDocumentsResponse {
|
|
289
263
|
/**
|
|
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.
|
|
264
|
+
* Array of document handles for the current page
|
|
294
265
|
*/
|
|
295
|
-
|
|
266
|
+
data: DocumentHandle[]
|
|
296
267
|
/**
|
|
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.
|
|
268
|
+
* Whether a query is currently in progress
|
|
301
269
|
*/
|
|
302
|
-
|
|
303
|
-
doc: IdentifiedSanityDocumentStub<R>,
|
|
304
|
-
): this
|
|
270
|
+
isPending: boolean
|
|
305
271
|
/**
|
|
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.
|
|
272
|
+
* Number of items displayed per page
|
|
310
273
|
*/
|
|
311
|
-
|
|
312
|
-
doc: IdentifiedSanityDocumentStub<R>,
|
|
313
|
-
): this
|
|
274
|
+
pageSize: number
|
|
314
275
|
/**
|
|
315
|
-
*
|
|
316
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
317
|
-
*
|
|
318
|
-
* @param documentId - Document ID to delete
|
|
276
|
+
* Current page number (1-indexed)
|
|
319
277
|
*/
|
|
320
|
-
|
|
278
|
+
currentPage: number
|
|
321
279
|
/**
|
|
322
|
-
*
|
|
280
|
+
* Total number of pages available
|
|
323
281
|
*/
|
|
324
|
-
|
|
282
|
+
totalPages: number
|
|
325
283
|
/**
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* @param id - Transaction ID
|
|
284
|
+
* Starting index of the current page (0-indexed)
|
|
329
285
|
*/
|
|
330
|
-
|
|
286
|
+
startIndex: number
|
|
331
287
|
/**
|
|
332
|
-
*
|
|
288
|
+
* Ending index of the current page (exclusive, 0-indexed)
|
|
333
289
|
*/
|
|
334
|
-
|
|
290
|
+
endIndex: number
|
|
335
291
|
/**
|
|
336
|
-
*
|
|
292
|
+
* Total count of items matching the query
|
|
337
293
|
*/
|
|
338
|
-
|
|
294
|
+
count: number
|
|
339
295
|
/**
|
|
340
|
-
*
|
|
296
|
+
* Navigate to the first page
|
|
341
297
|
*/
|
|
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
|
|
298
|
+
firstPage: () => void
|
|
364
299
|
/**
|
|
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'
|
|
300
|
+
* Whether there is a first page available to navigate to
|
|
369
301
|
*/
|
|
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
|
|
302
|
+
hasFirstPage: boolean
|
|
378
303
|
/**
|
|
379
|
-
*
|
|
304
|
+
* Navigate to the previous page
|
|
380
305
|
*/
|
|
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
|
|
306
|
+
previousPage: () => void
|
|
388
307
|
/**
|
|
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
|
|
308
|
+
* Whether there is a previous page available to navigate to
|
|
395
309
|
*/
|
|
396
|
-
|
|
310
|
+
hasPreviousPage: boolean
|
|
397
311
|
/**
|
|
398
|
-
*
|
|
312
|
+
* Navigate to the next page
|
|
399
313
|
*/
|
|
400
|
-
|
|
314
|
+
nextPage: () => void
|
|
401
315
|
/**
|
|
402
|
-
*
|
|
316
|
+
* Whether there is a next page available to navigate to
|
|
403
317
|
*/
|
|
404
|
-
|
|
318
|
+
hasNextPage: boolean
|
|
405
319
|
/**
|
|
406
|
-
*
|
|
320
|
+
* Navigate to the last page
|
|
407
321
|
*/
|
|
408
|
-
|
|
322
|
+
lastPage: () => void
|
|
409
323
|
/**
|
|
410
|
-
|
|
324
|
+
* Whether there is a last page available to navigate to
|
|
411
325
|
*/
|
|
412
|
-
|
|
413
|
-
| {
|
|
414
|
-
cache?: ResponseQueryOptions['cache']
|
|
415
|
-
next?: ResponseQueryOptions['next']
|
|
416
|
-
}
|
|
417
|
-
| boolean
|
|
326
|
+
hasLastPage: boolean
|
|
418
327
|
/**
|
|
419
|
-
*
|
|
328
|
+
* Navigate to a specific page number
|
|
329
|
+
* @param pageNumber - The page number to navigate to (1-indexed)
|
|
420
330
|
*/
|
|
421
|
-
|
|
331
|
+
goToPage: (pageNumber: number) => void
|
|
422
332
|
}
|
|
423
333
|
|
|
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
334
|
/**
|
|
439
335
|
* @public
|
|
336
|
+
* @category Types
|
|
337
|
+
* @interface
|
|
440
338
|
*/
|
|
441
|
-
export declare type
|
|
442
|
-
|
|
443
|
-
/** @public */
|
|
444
|
-
declare interface ContentSourceMap {
|
|
445
|
-
mappings: ContentSourceMapMappings
|
|
446
|
-
documents: ContentSourceMapDocuments_2
|
|
447
|
-
paths: ContentSourceMapPaths
|
|
448
|
-
}
|
|
339
|
+
export declare type ProjectWithoutMembers = Omit<SanityProject, 'members'>
|
|
449
340
|
|
|
450
|
-
/**
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/** @public */
|
|
457
|
-
declare interface ContentSourceMapDocument_2 extends ContentSourceMapDocumentBase_2 {
|
|
458
|
-
_projectId?: undefined
|
|
459
|
-
_dataset?: undefined
|
|
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: {}
|
|
341
|
+
/**
|
|
342
|
+
* This version is provided by pkg-utils at build time
|
|
343
|
+
* @internal
|
|
344
|
+
*/
|
|
345
|
+
export declare const REACT_SDK_VERSION: {}
|
|
2402
346
|
|
|
2403
347
|
/**
|
|
2404
|
-
*
|
|
348
|
+
* Provides a Sanity instance to child components through React Context
|
|
2405
349
|
*
|
|
2406
|
-
* @
|
|
350
|
+
* @internal
|
|
351
|
+
*
|
|
352
|
+
* @remarks
|
|
353
|
+
* The ResourceProvider creates a hierarchical structure of Sanity instances:
|
|
354
|
+
* - When used as a root provider, it creates a new Sanity instance with the given config
|
|
355
|
+
* - When nested inside another ResourceProvider, it creates a child instance that
|
|
356
|
+
* inherits and extends the parent's configuration
|
|
357
|
+
*
|
|
358
|
+
* Features:
|
|
359
|
+
* - Automatically manages the lifecycle of Sanity instances
|
|
360
|
+
* - Disposes instances when the component unmounts
|
|
361
|
+
* - Includes a Suspense boundary for data loading
|
|
362
|
+
* - Enables hierarchical configuration inheritance
|
|
363
|
+
*
|
|
364
|
+
* Use this component to:
|
|
365
|
+
* - Set up project/dataset configuration for an application
|
|
366
|
+
* - Override specific configuration values in a section of your app
|
|
367
|
+
* - Create isolated instance hierarchies for different features
|
|
368
|
+
*
|
|
369
|
+
* @example Creating a root provider
|
|
370
|
+
* ```tsx
|
|
371
|
+
* <ResourceProvider
|
|
372
|
+
* projectId="your-project-id"
|
|
373
|
+
* dataset="production"
|
|
374
|
+
* fallback={<LoadingSpinner />}
|
|
375
|
+
* >
|
|
376
|
+
* <YourApp />
|
|
377
|
+
* </ResourceProvider>
|
|
378
|
+
* ```
|
|
379
|
+
*
|
|
380
|
+
* @example Creating nested providers with configuration inheritance
|
|
381
|
+
* ```tsx
|
|
382
|
+
* // Root provider with production config with nested provider for preview features with custom dataset
|
|
383
|
+
* <ResourceProvider projectId="abc123" dataset="production" fallback={<Loading />}>
|
|
384
|
+
* <div>...Main app content</div>
|
|
385
|
+
* <Dashboard />
|
|
386
|
+
* <ResourceProvider dataset="preview" fallback={<Loading />}>
|
|
387
|
+
* <PreviewFeatures />
|
|
388
|
+
* </ResourceProvider>
|
|
389
|
+
* </ResourceProvider>
|
|
390
|
+
* ```
|
|
2407
391
|
*/
|
|
2408
|
-
declare
|
|
2409
|
-
|
|
2410
|
-
|
|
392
|
+
export declare function ResourceProvider({
|
|
393
|
+
children,
|
|
394
|
+
fallback,
|
|
395
|
+
...config
|
|
396
|
+
}: ResourceProviderProps): React.ReactNode
|
|
2411
397
|
|
|
2412
398
|
/**
|
|
2413
|
-
*
|
|
2414
|
-
*
|
|
2415
|
-
*
|
|
2416
|
-
* @public
|
|
399
|
+
* Props for the ResourceProvider component
|
|
400
|
+
* @internal
|
|
2417
401
|
*/
|
|
2418
|
-
declare
|
|
2419
|
-
actionType: 'sanity.action.document.replaceDraft'
|
|
2420
|
-
/**
|
|
2421
|
-
* Published document ID to create draft from, if draft does not exist
|
|
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
|
|
402
|
+
export declare interface ResourceProviderProps extends SanityConfig {
|
|
2466
403
|
/**
|
|
2467
|
-
*
|
|
2468
|
-
*
|
|
2469
|
-
*
|
|
2470
|
-
* Only to be used with live content queries and when useCdn is true.
|
|
404
|
+
* React node to show while content is loading
|
|
405
|
+
* Used as the fallback for the internal Suspense boundary
|
|
2471
406
|
*/
|
|
2472
|
-
|
|
407
|
+
fallback: React.ReactNode
|
|
408
|
+
children: React.ReactNode
|
|
2473
409
|
}
|
|
2474
410
|
|
|
2475
411
|
/**
|
|
@@ -2479,6 +415,9 @@ declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2479
415
|
* as well as application context and state which is used by the Sanity React hooks. Your application
|
|
2480
416
|
* must be wrapped with the SanityApp component to function properly.
|
|
2481
417
|
*
|
|
418
|
+
* SanityApp creates a hierarchy of ResourceProviders, each providing a SanityInstance that can be
|
|
419
|
+
* accessed by hooks. The first configuration in the array becomes the default instance.
|
|
420
|
+
*
|
|
2482
421
|
* @param props - Your Sanity configuration and the React children to render
|
|
2483
422
|
* @returns Your Sanity application, integrated with your Sanity configuration and application context
|
|
2484
423
|
*
|
|
@@ -2489,16 +428,14 @@ declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2489
428
|
* import MyAppRoot from './Root'
|
|
2490
429
|
*
|
|
2491
430
|
* // Single project configuration
|
|
2492
|
-
* const
|
|
2493
|
-
*
|
|
2494
|
-
*
|
|
2495
|
-
*
|
|
2496
|
-
* },
|
|
2497
|
-
* ]
|
|
431
|
+
* const mySanityConfig = {
|
|
432
|
+
* projectId: 'my-project-id',
|
|
433
|
+
* dataset: 'production',
|
|
434
|
+
* }
|
|
2498
435
|
*
|
|
2499
436
|
* // Or multiple project configurations
|
|
2500
437
|
* const multipleConfigs = [
|
|
2501
|
-
* // Configuration for your main project. This will be used as the default project for
|
|
438
|
+
* // Configuration for your main project. This will be used as the default project for hooks.
|
|
2502
439
|
* {
|
|
2503
440
|
* projectId: 'marketing-website-project',
|
|
2504
441
|
* dataset: 'production',
|
|
@@ -2517,628 +454,34 @@ declare interface ResponseQueryOptions extends RequestOptions {
|
|
|
2517
454
|
*
|
|
2518
455
|
* export default function MyApp() {
|
|
2519
456
|
* return (
|
|
2520
|
-
* <SanityApp
|
|
457
|
+
* <SanityApp config={mySanityConfig} fallback={<LoadingSpinner />}>
|
|
2521
458
|
* <MyAppRoot />
|
|
2522
459
|
* </SanityApp>
|
|
2523
460
|
* )
|
|
2524
461
|
* }
|
|
2525
462
|
* ```
|
|
2526
463
|
*/
|
|
2527
|
-
export declare function SanityApp({
|
|
464
|
+
export declare function SanityApp({
|
|
465
|
+
children,
|
|
466
|
+
fallback,
|
|
467
|
+
config,
|
|
468
|
+
sanityConfigs,
|
|
469
|
+
...props
|
|
470
|
+
}: SanityAppProps): ReactElement
|
|
2528
471
|
|
|
2529
472
|
/**
|
|
2530
473
|
* @public
|
|
2531
474
|
*/
|
|
2532
475
|
export declare interface SanityAppProps {
|
|
2533
|
-
|
|
476
|
+
config: SanityConfig | SanityConfig[]
|
|
477
|
+
/** @deprecated use the `config` prop instead. */
|
|
478
|
+
sanityConfigs?: SanityConfig[]
|
|
2534
479
|
children: React.ReactNode
|
|
2535
480
|
fallback: React.ReactNode
|
|
2536
481
|
}
|
|
2537
482
|
|
|
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
483
|
export {SanityDocument}
|
|
3076
484
|
|
|
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
485
|
/** @public */
|
|
3143
486
|
export declare interface SanityProject {
|
|
3144
487
|
id: string
|
|
@@ -3170,68 +513,8 @@ export declare interface SanityProject {
|
|
|
3170
513
|
/** @public */
|
|
3171
514
|
export declare interface SanityProjectMember {
|
|
3172
515
|
id: string
|
|
3173
|
-
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
|
|
516
|
+
role: string
|
|
517
|
+
isRobot: boolean
|
|
3235
518
|
isCurrentUser: boolean
|
|
3236
519
|
}
|
|
3237
520
|
|
|
@@ -3239,294 +522,35 @@ declare interface SanityUser {
|
|
|
3239
522
|
* @internal
|
|
3240
523
|
*
|
|
3241
524
|
* Top-level context provider that provides access to the Sanity SDK.
|
|
525
|
+
* Creates a hierarchy of ResourceProviders, each providing a SanityInstance that can be
|
|
526
|
+
* accessed by hooks. The first configuration in the array becomes the default instance.
|
|
3242
527
|
*/
|
|
3243
528
|
export declare function SDKProvider({
|
|
3244
529
|
children,
|
|
3245
|
-
|
|
530
|
+
config,
|
|
3246
531
|
fallback,
|
|
532
|
+
...props
|
|
3247
533
|
}: SDKProviderProps): ReactElement
|
|
3248
534
|
|
|
3249
535
|
/**
|
|
3250
536
|
* @internal
|
|
3251
537
|
*/
|
|
3252
|
-
export declare interface SDKProviderProps {
|
|
538
|
+
export declare interface SDKProviderProps extends AuthBoundaryProps {
|
|
3253
539
|
children: ReactNode
|
|
3254
|
-
|
|
540
|
+
config: SanityConfig | SanityConfig[]
|
|
3255
541
|
fallback: ReactNode
|
|
3256
542
|
}
|
|
3257
543
|
|
|
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
544
|
export {SortOrderingItem}
|
|
3274
545
|
|
|
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
546
|
declare interface StudioWorkspacesResult {
|
|
3325
|
-
|
|
547
|
+
workspacesByProjectIdAndDataset: WorkspacesByProjectIdDataset
|
|
3326
548
|
error: string | null
|
|
3327
549
|
isConnected: boolean
|
|
3328
550
|
}
|
|
3329
551
|
|
|
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
552
|
declare type Updater<TValue> = TValue | ((nextValue: TValue) => TValue)
|
|
3465
553
|
|
|
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
554
|
/**
|
|
3531
555
|
*
|
|
3532
556
|
* @beta
|
|
@@ -3534,7 +558,7 @@ declare interface UploadClientConfig {
|
|
|
3534
558
|
* Provides a callback for applying one or more actions to a document.
|
|
3535
559
|
*
|
|
3536
560
|
* @category Documents
|
|
3537
|
-
* @param
|
|
561
|
+
* @param dataset - An optional dataset handle with projectId and dataset. If not provided, the nearest SanityInstance from context will be used.
|
|
3538
562
|
* @returns A function that takes one more more {@link DocumentAction}s and returns a promise that resolves to an {@link ActionsResult}.
|
|
3539
563
|
* @example Publish or unpublish a document
|
|
3540
564
|
* ```
|
|
@@ -3542,7 +566,7 @@ declare interface UploadClientConfig {
|
|
|
3542
566
|
* import { useApplyDocumentActions } from '@sanity/sdk-react'
|
|
3543
567
|
*
|
|
3544
568
|
* const apply = useApplyDocumentActions()
|
|
3545
|
-
* const myDocument = {
|
|
569
|
+
* const myDocument = { documentId: 'my-document-id', documentType: 'my-document-type' }
|
|
3546
570
|
*
|
|
3547
571
|
* return (
|
|
3548
572
|
* <button onClick={() => apply(publishDocument(myDocument))}>Publish</button>
|
|
@@ -3558,7 +582,7 @@ declare interface UploadClientConfig {
|
|
|
3558
582
|
* const apply = useApplyDocumentActions()
|
|
3559
583
|
*
|
|
3560
584
|
* const handleCreateAndPublish = () => {
|
|
3561
|
-
* const handle = {
|
|
585
|
+
* const handle = { documentId: window.crypto.randomUUID(), documentType: 'my-document-type' }
|
|
3562
586
|
* apply([
|
|
3563
587
|
* createDocument(handle),
|
|
3564
588
|
* publishDocument(handle),
|
|
@@ -3567,17 +591,15 @@ declare interface UploadClientConfig {
|
|
|
3567
591
|
*
|
|
3568
592
|
* return (
|
|
3569
593
|
* <button onClick={handleCreateAndPublish}>
|
|
3570
|
-
* I
|
|
594
|
+
* I'm feeling lucky
|
|
3571
595
|
* </button>
|
|
3572
596
|
* )
|
|
3573
597
|
* ```
|
|
3574
598
|
*/
|
|
3575
|
-
export declare
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
options?: ApplyDocumentActionsOptions,
|
|
3580
|
-
) => Promise<ActionsResult<TDocument>>
|
|
599
|
+
export declare const useApplyDocumentActions: () => (
|
|
600
|
+
action: DocumentAction | DocumentAction[],
|
|
601
|
+
options?: ApplyDocumentActionsOptions | undefined,
|
|
602
|
+
) => Promise<ActionsResult<SanityDocument>>
|
|
3581
603
|
|
|
3582
604
|
/**
|
|
3583
605
|
* @internal
|
|
@@ -3636,7 +658,7 @@ export declare const useAuthToken: () => string | null
|
|
|
3636
658
|
* @public
|
|
3637
659
|
* @function
|
|
3638
660
|
*/
|
|
3639
|
-
export declare const useClient: (
|
|
661
|
+
export declare const useClient: (x: ClientOptions) => SanityClient
|
|
3640
662
|
|
|
3641
663
|
declare type UseCurrentUser = {
|
|
3642
664
|
/**
|
|
@@ -3726,20 +748,26 @@ export declare const useDatasets: UseDatasets
|
|
|
3726
748
|
* ## useDocument(doc, path)
|
|
3727
749
|
* Read and subscribe to nested values in a document
|
|
3728
750
|
* @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.
|
|
751
|
+
* @param doc - The document to read state from, specified as a DocumentHandle
|
|
3731
752
|
* @param path - The path to the nested value to read from
|
|
3732
753
|
* @returns The value at the specified path
|
|
3733
754
|
* @example
|
|
3734
755
|
* ```tsx
|
|
3735
|
-
* import {
|
|
756
|
+
* import {useDocument} from '@sanity/sdk-react'
|
|
757
|
+
*
|
|
758
|
+
* const documentHandle = {
|
|
759
|
+
* documentId: 'order-123',
|
|
760
|
+
* documentType: 'order',
|
|
761
|
+
* projectId: 'abc123',
|
|
762
|
+
* dataset: 'production'
|
|
763
|
+
* }
|
|
3736
764
|
*
|
|
3737
|
-
* function OrderLink(
|
|
765
|
+
* function OrderLink() {
|
|
3738
766
|
* const title = useDocument(documentHandle, 'title')
|
|
3739
767
|
* const id = useDocument(documentHandle, '_id')
|
|
3740
768
|
*
|
|
3741
769
|
* return (
|
|
3742
|
-
* <a href
|
|
770
|
+
* <a href={`/order/${id}`}>Order {title} today!</a>
|
|
3743
771
|
* )
|
|
3744
772
|
* }
|
|
3745
773
|
* ```
|
|
@@ -3754,11 +782,11 @@ export declare function useDocument<
|
|
|
3754
782
|
* @beta
|
|
3755
783
|
* ## useDocument(doc)
|
|
3756
784
|
* Read and subscribe to an entire document
|
|
3757
|
-
* @param doc - The document to read state from
|
|
785
|
+
* @param doc - The document to read state from, specified as a DocumentHandle
|
|
3758
786
|
* @returns The document state as an object
|
|
3759
787
|
* @example
|
|
3760
788
|
* ```tsx
|
|
3761
|
-
* import {type SanityDocument,
|
|
789
|
+
* import {type SanityDocument, useDocument} from '@sanity/sdk-react'
|
|
3762
790
|
*
|
|
3763
791
|
* interface Book extends SanityDocument {
|
|
3764
792
|
* title: string
|
|
@@ -3766,19 +794,30 @@ export declare function useDocument<
|
|
|
3766
794
|
* summary: string
|
|
3767
795
|
* }
|
|
3768
796
|
*
|
|
3769
|
-
*
|
|
797
|
+
* const documentHandle = {
|
|
798
|
+
* documentId: 'book-123',
|
|
799
|
+
* documentType: 'book',
|
|
800
|
+
* projectId: 'abc123',
|
|
801
|
+
* dataset: 'production'
|
|
802
|
+
* }
|
|
803
|
+
*
|
|
804
|
+
* function DocumentView() {
|
|
3770
805
|
* const book = useDocument<Book>(documentHandle)
|
|
3771
806
|
*
|
|
807
|
+
* if (!book) {
|
|
808
|
+
* return <div>Loading...</div>
|
|
809
|
+
* }
|
|
810
|
+
*
|
|
3772
811
|
* return (
|
|
3773
812
|
* <article>
|
|
3774
|
-
* <h1>{book
|
|
3775
|
-
* <address>By {book
|
|
813
|
+
* <h1>{book.title}</h1>
|
|
814
|
+
* <address>By {book.author}</address>
|
|
3776
815
|
*
|
|
3777
816
|
* <h2>Summary</h2>
|
|
3778
|
-
* {book
|
|
817
|
+
* {book.summary}
|
|
3779
818
|
*
|
|
3780
819
|
* <h2>Order</h2>
|
|
3781
|
-
* <a href
|
|
820
|
+
* <a href={`/order/${book._id}`}>Order {book.title} today!</a>
|
|
3782
821
|
* </article>
|
|
3783
822
|
* )
|
|
3784
823
|
* }
|
|
@@ -3793,13 +832,14 @@ export declare function useDocument<TDocument extends SanityDocument>(
|
|
|
3793
832
|
*
|
|
3794
833
|
* @beta
|
|
3795
834
|
*
|
|
3796
|
-
* Subscribes an event handler to events in your application
|
|
835
|
+
* Subscribes an event handler to events in your application's document store, such as document
|
|
3797
836
|
* creation, deletion, and updates.
|
|
3798
837
|
*
|
|
3799
838
|
* @category Documents
|
|
3800
839
|
* @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 `
|
|
840
|
+
* @param doc - The document to subscribe to events for. If you pass a `DocumentHandle` with specified `projectId` and `dataset`,
|
|
841
|
+
* 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,
|
|
842
|
+
* the document will use the nearest instance from context.
|
|
3803
843
|
* @example
|
|
3804
844
|
* ```
|
|
3805
845
|
* import {useDocumentEvent} from '@sanity/sdk-react'
|
|
@@ -3816,7 +856,7 @@ export declare function useDocument<TDocument extends SanityDocument>(
|
|
|
3816
856
|
*/
|
|
3817
857
|
export declare function useDocumentEvent(
|
|
3818
858
|
handler: (documentEvent: DocumentEvent) => void,
|
|
3819
|
-
|
|
859
|
+
dataset: DatasetHandle,
|
|
3820
860
|
): void
|
|
3821
861
|
|
|
3822
862
|
/**
|
|
@@ -3826,7 +866,7 @@ export declare function useDocumentEvent(
|
|
|
3826
866
|
* Check if the current user has the specified permissions for the given document actions.
|
|
3827
867
|
*
|
|
3828
868
|
* @category Permissions
|
|
3829
|
-
* @param
|
|
869
|
+
* @param actionOrActions - One more more calls to a particular document action function for a given document
|
|
3830
870
|
* @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
871
|
*
|
|
3832
872
|
* @example Checking for permission to publish a document
|
|
@@ -3858,7 +898,7 @@ export declare function useDocumentEvent(
|
|
|
3858
898
|
* ```
|
|
3859
899
|
*/
|
|
3860
900
|
export declare function useDocumentPermissions(
|
|
3861
|
-
|
|
901
|
+
actionOrActions: DocumentAction | DocumentAction[],
|
|
3862
902
|
): DocumentPermissionsResult
|
|
3863
903
|
|
|
3864
904
|
/**
|
|
@@ -3870,9 +910,15 @@ export declare function useDocumentPermissions(
|
|
|
3870
910
|
* @category Documents
|
|
3871
911
|
* @param options - Configuration options for the infinite list
|
|
3872
912
|
* @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
|
-
*
|
|
913
|
+
*
|
|
914
|
+
* @remarks
|
|
915
|
+
* - The returned document handles include projectId and dataset information from the current Sanity instance
|
|
916
|
+
* - This makes them ready to use with document operations and other document hooks
|
|
917
|
+
* - The hook automatically uses the correct Sanity instance based on the projectId and dataset in the options
|
|
918
|
+
*
|
|
919
|
+
* @example Basic infinite list with loading more
|
|
3874
920
|
* ```tsx
|
|
3875
|
-
* const {data, hasMore, isPending, loadMore} = useDocuments({
|
|
921
|
+
* const { data, hasMore, isPending, loadMore, count } = useDocuments({
|
|
3876
922
|
* filter: '_type == "post"',
|
|
3877
923
|
* search: searchTerm,
|
|
3878
924
|
* batchSize: 10,
|
|
@@ -3884,16 +930,17 @@ export declare function useDocumentPermissions(
|
|
|
3884
930
|
* Total documents: {count}
|
|
3885
931
|
* <ol>
|
|
3886
932
|
* {data.map((doc) => (
|
|
3887
|
-
* <li key={doc.
|
|
933
|
+
* <li key={doc.documentId}>
|
|
3888
934
|
* <MyDocumentComponent doc={doc} />
|
|
3889
935
|
* </li>
|
|
3890
936
|
* ))}
|
|
3891
937
|
* </ol>
|
|
3892
|
-
* {hasMore && <button onClick={loadMore}
|
|
938
|
+
* {hasMore && <button onClick={loadMore} disabled={isPending}>
|
|
939
|
+
* {isPending ? 'Loading...' : 'Load More'}
|
|
940
|
+
* </button>}
|
|
3893
941
|
* </div>
|
|
3894
942
|
* )
|
|
3895
943
|
* ```
|
|
3896
|
-
*
|
|
3897
944
|
*/
|
|
3898
945
|
export declare function useDocuments({
|
|
3899
946
|
batchSize,
|
|
@@ -3906,15 +953,16 @@ export declare function useDocuments({
|
|
|
3906
953
|
|
|
3907
954
|
declare type UseDocumentSyncStatus = {
|
|
3908
955
|
/**
|
|
3909
|
-
* Exposes the document
|
|
956
|
+
* Exposes the document's sync status between local and remote document states.
|
|
3910
957
|
*
|
|
3911
958
|
* @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 `
|
|
959
|
+
* @param doc - The document handle to get sync status for. If you pass a `DocumentHandle` with specified `projectId` and `dataset`,
|
|
960
|
+
* 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,
|
|
961
|
+
* the document will use the nearest instance from context.
|
|
3914
962
|
* @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
963
|
* @example Disable a Save button when there are no changes to sync
|
|
3916
964
|
* ```
|
|
3917
|
-
* const myDocumentHandle = {
|
|
965
|
+
* const myDocumentHandle = { documentId: 'documentId', documentType: 'documentType', projectId: 'projectId', dataset: 'dataset' }
|
|
3918
966
|
* const documentSynced = useDocumentSyncStatus(myDocumentHandle)
|
|
3919
967
|
*
|
|
3920
968
|
* return (
|
|
@@ -3941,12 +989,18 @@ export declare const useDocumentSyncStatus: UseDocumentSyncStatus
|
|
|
3941
989
|
* Edit a nested value within a document
|
|
3942
990
|
*
|
|
3943
991
|
* @category Documents
|
|
3944
|
-
* @param
|
|
992
|
+
* @param docHandle - The document to be edited, specified as a DocumentHandle
|
|
3945
993
|
* @param path - The path to the nested value to be edited
|
|
3946
994
|
* @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 = {
|
|
995
|
+
* @example Update a document's name by providing the new value directly
|
|
996
|
+
* ```tsx
|
|
997
|
+
* const handle = {
|
|
998
|
+
* documentId: 'movie-123',
|
|
999
|
+
* documentType: 'movie',
|
|
1000
|
+
* projectId: 'abc123',
|
|
1001
|
+
* dataset: 'production'
|
|
1002
|
+
* }
|
|
1003
|
+
*
|
|
3950
1004
|
* const name = useDocument(handle, 'name')
|
|
3951
1005
|
* const editName = useEditDocument(handle, 'name')
|
|
3952
1006
|
*
|
|
@@ -3960,8 +1014,14 @@ export declare const useDocumentSyncStatus: UseDocumentSyncStatus
|
|
|
3960
1014
|
* ```
|
|
3961
1015
|
*
|
|
3962
1016
|
* @example Update a count on a document by providing an updater function
|
|
3963
|
-
* ```
|
|
3964
|
-
* const handle = {
|
|
1017
|
+
* ```tsx
|
|
1018
|
+
* const handle = {
|
|
1019
|
+
* documentId: 'counter-123',
|
|
1020
|
+
* documentType: 'counter',
|
|
1021
|
+
* projectId: 'abc123',
|
|
1022
|
+
* dataset: 'production'
|
|
1023
|
+
* }
|
|
1024
|
+
*
|
|
3965
1025
|
* const count = useDocument(handle, 'count')
|
|
3966
1026
|
* const editCount = useEditDocument(handle, 'count')
|
|
3967
1027
|
*
|
|
@@ -3983,7 +1043,7 @@ export declare function useEditDocument<
|
|
|
3983
1043
|
TDocument extends SanityDocument,
|
|
3984
1044
|
TPath extends JsonMatchPath<TDocument>,
|
|
3985
1045
|
>(
|
|
3986
|
-
|
|
1046
|
+
docHandle: DocumentHandle<TDocument>,
|
|
3987
1047
|
path: TPath,
|
|
3988
1048
|
): (nextValue: Updater<JsonMatch<TDocument, TPath>>) => Promise<ActionsResult<TDocument>>
|
|
3989
1049
|
|
|
@@ -3993,15 +1053,20 @@ export declare function useEditDocument<
|
|
|
3993
1053
|
*
|
|
3994
1054
|
* ## useEditDocument(doc)
|
|
3995
1055
|
* Edit an entire document
|
|
3996
|
-
* @param
|
|
3997
|
-
*
|
|
1056
|
+
* @param docHandle - The document to be edited, specified as a DocumentHandle.
|
|
1057
|
+
* The hook will automatically use the Sanity instance that matches the project and dataset specified in the handle.
|
|
3998
1058
|
* @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
1059
|
* @example
|
|
4000
|
-
* ```
|
|
4001
|
-
* const myDocumentHandle = {
|
|
1060
|
+
* ```tsx
|
|
1061
|
+
* const myDocumentHandle = {
|
|
1062
|
+
* documentId: 'product-123',
|
|
1063
|
+
* documentType: 'product',
|
|
1064
|
+
* projectId: 'abc123',
|
|
1065
|
+
* dataset: 'production'
|
|
1066
|
+
* }
|
|
4002
1067
|
*
|
|
4003
1068
|
* const myDocument = useDocument(myDocumentHandle)
|
|
4004
|
-
* const { title, price } = myDocument
|
|
1069
|
+
* const { title, price } = myDocument ?? {}
|
|
4005
1070
|
*
|
|
4006
1071
|
* const editMyDocument = useEditDocument(myDocumentHandle)
|
|
4007
1072
|
*
|
|
@@ -4039,7 +1104,7 @@ export declare function useEditDocument<
|
|
|
4039
1104
|
* <input
|
|
4040
1105
|
* name='salePrice'
|
|
4041
1106
|
* type='checkbox'
|
|
4042
|
-
* checked={
|
|
1107
|
+
* checked={myDocument && 'salePrice' in myDocument}
|
|
4043
1108
|
* onChange={handleSaleChange}
|
|
4044
1109
|
* />
|
|
4045
1110
|
* </form>
|
|
@@ -4051,7 +1116,7 @@ export declare function useEditDocument<
|
|
|
4051
1116
|
* ```
|
|
4052
1117
|
*/
|
|
4053
1118
|
export declare function useEditDocument<TDocument extends SanityDocument>(
|
|
4054
|
-
|
|
1119
|
+
docHandle: DocumentHandle<TDocument>,
|
|
4055
1120
|
): (nextValue: Updater<TDocument>) => Promise<ActionsResult<TDocument>>
|
|
4056
1121
|
|
|
4057
1122
|
/**
|
|
@@ -4128,45 +1193,9 @@ export declare const useHandleAuthCallback: () => (
|
|
|
4128
1193
|
) => Promise<string | false>
|
|
4129
1194
|
|
|
4130
1195
|
/**
|
|
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
1196
|
* @public
|
|
4168
1197
|
*/
|
|
4169
|
-
export declare function
|
|
1198
|
+
export declare function useLoginUrl(): string
|
|
4170
1199
|
|
|
4171
1200
|
/**
|
|
4172
1201
|
* Hook to log out of the current session
|
|
@@ -4211,13 +1240,13 @@ export declare const useLogOut: () => () => Promise<void>
|
|
|
4211
1240
|
export declare function useManageFavorite({
|
|
4212
1241
|
documentId,
|
|
4213
1242
|
documentType,
|
|
4214
|
-
|
|
1243
|
+
projectId: paramProjectId,
|
|
1244
|
+
dataset: paramDataset,
|
|
1245
|
+
resourceId: paramResourceId,
|
|
4215
1246
|
resourceType,
|
|
4216
1247
|
}: UseManageFavoriteProps): ManageFavorite
|
|
4217
1248
|
|
|
4218
|
-
declare interface UseManageFavoriteProps {
|
|
4219
|
-
documentId: string
|
|
4220
|
-
documentType: string
|
|
1249
|
+
declare interface UseManageFavoriteProps extends DocumentHandle {
|
|
4221
1250
|
resourceId?: string
|
|
4222
1251
|
resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']
|
|
4223
1252
|
}
|
|
@@ -4268,7 +1297,13 @@ export declare function useNavigateToStudioDocument(
|
|
|
4268
1297
|
* @category Documents
|
|
4269
1298
|
* @param options - Configuration options for the paginated list
|
|
4270
1299
|
* @returns An object containing the current page of document handles, the loading and pagination state, and navigation functions
|
|
4271
|
-
*
|
|
1300
|
+
*
|
|
1301
|
+
* @remarks
|
|
1302
|
+
* - The returned document handles include projectId and dataset information from the current Sanity instance
|
|
1303
|
+
* - This makes them ready to use with document operations and other document hooks
|
|
1304
|
+
* - The hook automatically uses the correct Sanity instance based on the projectId and dataset in the options
|
|
1305
|
+
*
|
|
1306
|
+
* @example Basic usage
|
|
4272
1307
|
* ```tsx
|
|
4273
1308
|
* const {
|
|
4274
1309
|
* data,
|
|
@@ -4290,14 +1325,12 @@ export declare function useNavigateToStudioDocument(
|
|
|
4290
1325
|
* <>
|
|
4291
1326
|
* <table>
|
|
4292
1327
|
* {data.map(doc => (
|
|
4293
|
-
* <MyTableRowComponent key={doc.
|
|
1328
|
+
* <MyTableRowComponent key={doc.documentId} doc={doc} />
|
|
4294
1329
|
* ))}
|
|
4295
1330
|
* </table>
|
|
4296
|
-
*
|
|
4297
|
-
*
|
|
4298
|
-
*
|
|
4299
|
-
* {hasNextPage && <button onClick={nextPage}>Next</button>}
|
|
4300
|
-
* </>
|
|
1331
|
+
* {hasPreviousPage && <button onClick={previousPage}>Previous</button>}
|
|
1332
|
+
* {currentPage} / {totalPages}
|
|
1333
|
+
* {hasNextPage && <button onClick={nextPage}>Next</button>}
|
|
4301
1334
|
* </>
|
|
4302
1335
|
* )
|
|
4303
1336
|
* ```
|
|
@@ -4310,7 +1343,7 @@ export declare function usePaginatedDocuments({
|
|
|
4310
1343
|
orderings,
|
|
4311
1344
|
search,
|
|
4312
1345
|
...options
|
|
4313
|
-
}
|
|
1346
|
+
}: PaginatedDocumentsOptions): PaginatedDocumentsResponse
|
|
4314
1347
|
|
|
4315
1348
|
/**
|
|
4316
1349
|
* @beta
|
|
@@ -4356,17 +1389,17 @@ export declare function usePaginatedDocuments({
|
|
|
4356
1389
|
* )
|
|
4357
1390
|
* ```
|
|
4358
1391
|
*/
|
|
4359
|
-
export declare function usePreview({
|
|
4360
|
-
document: {_id, _type},
|
|
4361
|
-
ref,
|
|
4362
|
-
}: UsePreviewOptions): UsePreviewResults
|
|
1392
|
+
export declare function usePreview({ref, ...docHandle}: UsePreviewOptions): UsePreviewResults
|
|
4363
1393
|
|
|
4364
1394
|
/**
|
|
4365
1395
|
* @beta
|
|
4366
1396
|
* @category Types
|
|
4367
1397
|
*/
|
|
4368
|
-
export declare interface UsePreviewOptions {
|
|
4369
|
-
|
|
1398
|
+
export declare interface UsePreviewOptions extends DocumentHandle {
|
|
1399
|
+
/**
|
|
1400
|
+
* Optional ref object to track visibility. When provided, preview resolution
|
|
1401
|
+
* only occurs when the referenced element is visible in the viewport.
|
|
1402
|
+
*/
|
|
4370
1403
|
ref?: React.RefObject<unknown>
|
|
4371
1404
|
}
|
|
4372
1405
|
|
|
@@ -4402,7 +1435,7 @@ declare type UseProject = {
|
|
|
4402
1435
|
* }
|
|
4403
1436
|
* ```
|
|
4404
1437
|
*/
|
|
4405
|
-
(
|
|
1438
|
+
(projectHandle?: ProjectHandle): SanityProject_2
|
|
4406
1439
|
}
|
|
4407
1440
|
|
|
4408
1441
|
/**
|
|
@@ -4470,28 +1503,27 @@ export declare const useProject: UseProject
|
|
|
4470
1503
|
* )
|
|
4471
1504
|
* ```
|
|
4472
1505
|
*/
|
|
4473
|
-
export declare function useProjection<
|
|
4474
|
-
document: {_id, _type},
|
|
4475
|
-
projection,
|
|
1506
|
+
export declare function useProjection<TData extends object>({
|
|
4476
1507
|
ref,
|
|
4477
|
-
|
|
1508
|
+
projection,
|
|
1509
|
+
...docHandle
|
|
1510
|
+
}: UseProjectionOptions): UseProjectionResults<TData>
|
|
4478
1511
|
|
|
4479
1512
|
/**
|
|
4480
1513
|
* @public
|
|
4481
1514
|
* @category Types
|
|
4482
1515
|
*/
|
|
4483
|
-
export declare interface UseProjectionOptions {
|
|
4484
|
-
document: DocumentHandle
|
|
4485
|
-
projection: ValidProjection
|
|
1516
|
+
export declare interface UseProjectionOptions extends DocumentHandle {
|
|
4486
1517
|
ref?: React.RefObject<unknown>
|
|
1518
|
+
projection: ValidProjection
|
|
4487
1519
|
}
|
|
4488
1520
|
|
|
4489
1521
|
/**
|
|
4490
1522
|
* @public
|
|
4491
1523
|
* @category Types
|
|
4492
1524
|
*/
|
|
4493
|
-
export declare interface UseProjectionResults<
|
|
4494
|
-
data:
|
|
1525
|
+
export declare interface UseProjectionResults<TData extends object> {
|
|
1526
|
+
data: TData
|
|
4495
1527
|
isPending: boolean
|
|
4496
1528
|
}
|
|
4497
1529
|
|
|
@@ -4528,7 +1560,7 @@ export declare const useProjects: UseProjects
|
|
|
4528
1560
|
* Executes GROQ queries against a Sanity dataset.
|
|
4529
1561
|
*
|
|
4530
1562
|
* This hook provides a convenient way to fetch and subscribe to real-time updates
|
|
4531
|
-
* for your Sanity content. Changes made to the dataset
|
|
1563
|
+
* for your Sanity content. Changes made to the dataset's content will trigger
|
|
4532
1564
|
* automatic updates.
|
|
4533
1565
|
*
|
|
4534
1566
|
* @remarks
|
|
@@ -4538,7 +1570,7 @@ export declare const useProjects: UseProjects
|
|
|
4538
1570
|
* @beta
|
|
4539
1571
|
* @category GROQ
|
|
4540
1572
|
* @param query - GROQ query string to execute
|
|
4541
|
-
* @param options - Optional configuration for the query
|
|
1573
|
+
* @param options - Optional configuration for the query, including projectId and dataset
|
|
4542
1574
|
* @returns Object containing the query result and a pending state flag
|
|
4543
1575
|
*
|
|
4544
1576
|
* @example Basic usage
|
|
@@ -4554,6 +1586,15 @@ export declare const useProjects: UseProjects
|
|
|
4554
1586
|
* })
|
|
4555
1587
|
* ```
|
|
4556
1588
|
*
|
|
1589
|
+
* @example Query from a specific project/dataset
|
|
1590
|
+
* ```tsx
|
|
1591
|
+
* // Specify which project and dataset to query
|
|
1592
|
+
* const {data} = useQuery<Movie[]>('*[_type == "movie"]', {
|
|
1593
|
+
* projectId: 'abc123',
|
|
1594
|
+
* dataset: 'production'
|
|
1595
|
+
* })
|
|
1596
|
+
* ```
|
|
1597
|
+
*
|
|
4557
1598
|
* @example With a loading state for transitions
|
|
4558
1599
|
* ```tsx
|
|
4559
1600
|
* const {data, isPending} = useQuery<Movie[]>('*[_type == "movie"]')
|
|
@@ -4617,44 +1658,94 @@ export declare function useRecordDocumentHistoryEvent({
|
|
|
4617
1658
|
/**
|
|
4618
1659
|
* @public
|
|
4619
1660
|
*/
|
|
4620
|
-
declare interface UseRecordDocumentHistoryEventProps {
|
|
4621
|
-
documentId: string
|
|
4622
|
-
documentType: string
|
|
1661
|
+
declare interface UseRecordDocumentHistoryEventProps extends DocumentHandle {
|
|
4623
1662
|
resourceType: StudioResource['type'] | MediaResource['type'] | CanvasResource['type']
|
|
4624
1663
|
resourceId?: string
|
|
4625
1664
|
}
|
|
4626
1665
|
|
|
4627
|
-
/**
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
1666
|
+
/**
|
|
1667
|
+
* @public
|
|
1668
|
+
* @category Types
|
|
1669
|
+
*/
|
|
1670
|
+
export declare interface UsersResult {
|
|
4631
1671
|
/**
|
|
4632
|
-
*
|
|
4633
|
-
|
|
4634
|
-
|
|
1672
|
+
* The users fetched.
|
|
1673
|
+
*/
|
|
1674
|
+
data: SanityUser[]
|
|
1675
|
+
/**
|
|
1676
|
+
* Whether there are more users to fetch.
|
|
4635
1677
|
*/
|
|
4636
|
-
|
|
1678
|
+
hasMore: boolean
|
|
1679
|
+
/**
|
|
1680
|
+
* Whether a users request is currently in progress
|
|
1681
|
+
*/
|
|
1682
|
+
isPending: boolean
|
|
1683
|
+
/**
|
|
1684
|
+
* Load more users.
|
|
1685
|
+
*/
|
|
1686
|
+
loadMore: () => void
|
|
4637
1687
|
}
|
|
4638
1688
|
|
|
4639
1689
|
/**
|
|
4640
|
-
*
|
|
4641
|
-
* This must be called from within a `SanityProvider` component.
|
|
4642
|
-
* @internal
|
|
1690
|
+
* Retrieves the current Sanity instance or finds a matching instance from the hierarchy
|
|
4643
1691
|
*
|
|
4644
|
-
* @
|
|
4645
|
-
*
|
|
4646
|
-
* @
|
|
1692
|
+
* @public
|
|
1693
|
+
*
|
|
1694
|
+
* @param config - Optional configuration to match against when finding an instance
|
|
1695
|
+
* @returns The current or matching Sanity instance
|
|
1696
|
+
*
|
|
1697
|
+
* @remarks
|
|
1698
|
+
* This hook accesses the nearest Sanity instance from the React context. When provided with
|
|
1699
|
+
* a configuration object, it traverses up the instance hierarchy to find the closest instance
|
|
1700
|
+
* that matches the specified configuration using shallow comparison of properties.
|
|
1701
|
+
*
|
|
1702
|
+
* The hook must be used within a component wrapped by a `ResourceProvider` or `SanityApp`.
|
|
1703
|
+
*
|
|
1704
|
+
* Use this hook when you need to:
|
|
1705
|
+
* - Access the current SanityInstance from context
|
|
1706
|
+
* - Find a specific instance with matching project/dataset configuration
|
|
1707
|
+
* - Access a parent instance with specific configuration values
|
|
1708
|
+
*
|
|
1709
|
+
* @example Get the current instance
|
|
1710
|
+
* ```tsx
|
|
1711
|
+
* // Get the current instance from context
|
|
1712
|
+
* const instance = useSanityInstance()
|
|
1713
|
+
* console.log(instance.config.projectId)
|
|
1714
|
+
* ```
|
|
1715
|
+
*
|
|
1716
|
+
* @example Find an instance with specific configuration
|
|
1717
|
+
* ```tsx
|
|
1718
|
+
* // Find an instance matching the given project and dataset
|
|
1719
|
+
* const instance = useSanityInstance({
|
|
1720
|
+
* projectId: 'abc123',
|
|
1721
|
+
* dataset: 'production'
|
|
1722
|
+
* })
|
|
1723
|
+
*
|
|
1724
|
+
* // Use instance for API calls
|
|
1725
|
+
* const fetchDocument = (docId) => {
|
|
1726
|
+
* // Instance is guaranteed to have the matching config
|
|
1727
|
+
* return client.fetch(`*[_id == $id][0]`, { id: docId })
|
|
1728
|
+
* }
|
|
1729
|
+
* ```
|
|
1730
|
+
*
|
|
1731
|
+
* @example Match partial configuration
|
|
4647
1732
|
* ```tsx
|
|
4648
|
-
*
|
|
1733
|
+
* // Find an instance with specific auth configuration
|
|
1734
|
+
* const instance = useSanityInstance({
|
|
1735
|
+
* auth: { requireLogin: true }
|
|
1736
|
+
* })
|
|
4649
1737
|
* ```
|
|
1738
|
+
*
|
|
1739
|
+
* @throws Error if no SanityInstance is found in context
|
|
1740
|
+
* @throws Error if no matching instance is found for the provided config
|
|
4650
1741
|
*/
|
|
4651
|
-
export declare const useSanityInstance: (
|
|
1742
|
+
export declare const useSanityInstance: (config?: SanityConfig) => SanityInstance
|
|
4652
1743
|
|
|
4653
1744
|
/**
|
|
4654
1745
|
* Hook that fetches studio workspaces and organizes them by projectId:dataset
|
|
4655
1746
|
* @internal
|
|
4656
1747
|
*/
|
|
4657
|
-
export declare function
|
|
1748
|
+
export declare function useStudioWorkspacesByProjectIdDataset(): StudioWorkspacesResult
|
|
4658
1749
|
|
|
4659
1750
|
/**
|
|
4660
1751
|
*
|
|
@@ -4663,70 +1754,32 @@ export declare function useStudioWorkspacesByResourceId(): StudioWorkspacesResul
|
|
|
4663
1754
|
* Retrieves the users for a given resource (either a project or an organization).
|
|
4664
1755
|
*
|
|
4665
1756
|
* @category Users
|
|
4666
|
-
* @param params - The resource type
|
|
1757
|
+
* @param params - The resource type, project ID, and the limit of users to fetch
|
|
4667
1758
|
* @returns A list of users, a boolean indicating whether there are more users to fetch, and a function to load more users
|
|
4668
1759
|
*
|
|
4669
1760
|
* @example
|
|
4670
1761
|
* ```
|
|
4671
|
-
* const {
|
|
1762
|
+
* const { data, hasMore, loadMore, isPending } = useUsers({
|
|
4672
1763
|
* resourceType: 'organization',
|
|
4673
|
-
*
|
|
4674
|
-
*
|
|
1764
|
+
* organizationId: 'my-org-id',
|
|
1765
|
+
* batchSize: 10,
|
|
4675
1766
|
* })
|
|
4676
1767
|
*
|
|
4677
1768
|
* return (
|
|
4678
1769
|
* <div>
|
|
4679
|
-
* {
|
|
1770
|
+
* {data.map(user => (
|
|
4680
1771
|
* <figure key={user.sanityUserId}>
|
|
4681
1772
|
* <img src={user.profile.imageUrl} alt='' />
|
|
4682
1773
|
* <figcaption>{user.profile.displayName}</figcaption>
|
|
4683
1774
|
* <address>{user.profile.email}</address>
|
|
4684
1775
|
* </figure>
|
|
4685
1776
|
* ))}
|
|
4686
|
-
* {hasMore && <button onClick={loadMore}>Load More</button>}
|
|
1777
|
+
* {hasMore && <button onClick={loadMore}>{isPending ? 'Loading...' : 'Load More'</button>}
|
|
4687
1778
|
* </div>
|
|
4688
1779
|
* )
|
|
4689
1780
|
* ```
|
|
4690
1781
|
*/
|
|
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
|
-
}
|
|
1782
|
+
export declare function useUsers(options?: GetUsersOptions): UsersResult
|
|
4730
1783
|
|
|
4731
1784
|
/**
|
|
4732
1785
|
* @internal
|
|
@@ -4757,17 +1810,6 @@ export declare interface UseWindowConnectionOptions<TMessage extends FrameMessag
|
|
|
4757
1810
|
onStatus?: (status: ComlinkStatus) => void
|
|
4758
1811
|
}
|
|
4759
1812
|
|
|
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
1813
|
/**
|
|
4772
1814
|
* @internal
|
|
4773
1815
|
*/
|
|
@@ -4809,8 +1851,8 @@ declare interface Workspace {
|
|
|
4809
1851
|
_ref: string
|
|
4810
1852
|
}
|
|
4811
1853
|
|
|
4812
|
-
declare interface
|
|
4813
|
-
[key: string]: Workspace[]
|
|
1854
|
+
declare interface WorkspacesByProjectIdDataset {
|
|
1855
|
+
[key: `${string}:${string}`]: Workspace[]
|
|
4814
1856
|
}
|
|
4815
1857
|
|
|
4816
1858
|
export {}
|