@sanity/client 6.27.3-canary.2 → 6.28.0-instruct.0
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/README.md +85 -5
- package/dist/_chunks-cjs/config.cjs +4 -1
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/config.js +4 -1
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/csm.d.cts +6 -1
- package/dist/csm.d.ts +6 -1
- package/dist/index.browser.cjs +46 -5
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +221 -1
- package/dist/index.browser.d.ts +221 -1
- package/dist/index.browser.js +47 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +44 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -1
- package/dist/index.d.ts +210 -1
- package/dist/index.js +46 -7
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +215 -1
- package/dist/stega.browser.d.ts +215 -1
- package/dist/stega.browser.js +1 -1
- package/dist/stega.d.cts +215 -1
- package/dist/stega.d.ts +215 -1
- package/dist/stega.js +1 -1
- package/package.json +11 -12
- package/src/SanityClient.ts +5 -1
- package/src/assist/AssistClient.ts +87 -0
- package/src/assist/types.ts +178 -0
- package/src/data/dataMethods.ts +12 -3
- package/src/types.ts +16 -1
- package/src/warnings.ts +5 -1
- package/umd/sanityClient.js +121 -86
- package/umd/sanityClient.min.js +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type {Any as Any_2} from '@sanity/client'
|
|
1
2
|
import type {ContentSourceMapDocuments as ContentSourceMapDocuments_2} from '@sanity/client/csm'
|
|
2
3
|
import {ContentSourceMapParsedPath} from '@sanity/client/csm'
|
|
3
4
|
import {ContentSourceMapParsedPathKeyedSegment} from '@sanity/client/csm'
|
|
4
5
|
import {Observable} from 'rxjs'
|
|
5
6
|
import {Requester} from 'get-it'
|
|
6
7
|
import type {ResolveStudioUrl} from '@sanity/client/csm'
|
|
8
|
+
import type {SanityDocumentStub as SanityDocumentStub_2} from '@sanity/client'
|
|
7
9
|
import {StudioBaseRoute} from '@sanity/client/csm'
|
|
8
10
|
import {StudioBaseUrl} from '@sanity/client/csm'
|
|
9
11
|
import {StudioUrl} from '@sanity/client/csm'
|
|
@@ -116,6 +118,122 @@ export declare class AssetsClient {
|
|
|
116
118
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
/** @beta */
|
|
122
|
+
export declare type AssistAsyncInstruction<
|
|
123
|
+
T extends Record<string, Any_2> = Record<string, Any_2>,
|
|
124
|
+
> = (ExistingDocumentRequest | CreateDocumentRequest<T>) & AssistRequestBase & Async
|
|
125
|
+
|
|
126
|
+
/** @public */
|
|
127
|
+
declare class AssistClient {
|
|
128
|
+
#private
|
|
129
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
130
|
+
instruct(request: AssistAsyncInstruction): Promise<{
|
|
131
|
+
_id: string
|
|
132
|
+
}>
|
|
133
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
134
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
135
|
+
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** @beta */
|
|
139
|
+
export declare type AssistInstruction<T extends Record<string, Any_2> = Record<string, Any_2>> =
|
|
140
|
+
| AssistSyncInstruction<T>
|
|
141
|
+
| AssistAsyncInstruction<T>
|
|
142
|
+
|
|
143
|
+
declare interface AssistRequestBase {
|
|
144
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
145
|
+
schemaId: string
|
|
146
|
+
/** string template using $variable – more on this below under "Dynamic instruction" */
|
|
147
|
+
instruction: string
|
|
148
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
149
|
+
instructionParams?: InstructionParams
|
|
150
|
+
/**
|
|
151
|
+
* Optional document path output target for the instruction.
|
|
152
|
+
* When provided, the instruction will apply to this path in the document and its children.
|
|
153
|
+
*
|
|
154
|
+
* ## Examples
|
|
155
|
+
* - `path: 'title'` will output to the title field in the document
|
|
156
|
+
* - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
|
|
157
|
+
*/
|
|
158
|
+
path?: string
|
|
159
|
+
/**
|
|
160
|
+
* Controls sub-paths in the document that can be output to.
|
|
161
|
+
*
|
|
162
|
+
* The string-paths are relative to the `path` param
|
|
163
|
+
*
|
|
164
|
+
* Note: these path strings are less strictly validated than the `path` param itself:
|
|
165
|
+
* if an relative-path does not exist or is invalid, it will be silently ignored.
|
|
166
|
+
*
|
|
167
|
+
* @see AssistRequestBase#conditionalPaths
|
|
168
|
+
* @see AssistRequestBase#outputTypes
|
|
169
|
+
*/
|
|
170
|
+
relativeOutputPaths?:
|
|
171
|
+
| {
|
|
172
|
+
include: string[]
|
|
173
|
+
}
|
|
174
|
+
| {
|
|
175
|
+
exclude: string[]
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Controls which types the instruction is allowed to output to.
|
|
179
|
+
*
|
|
180
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
181
|
+
* @see AssistRequestBase#conditionalPaths
|
|
182
|
+
*/
|
|
183
|
+
outputTypes?:
|
|
184
|
+
| {
|
|
185
|
+
include: string[]
|
|
186
|
+
}
|
|
187
|
+
| {
|
|
188
|
+
exclude: string[]
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
|
|
192
|
+
*
|
|
193
|
+
* By default, AI Assist will not output to conditional `readOnly` and `hidden` fields,
|
|
194
|
+
* ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
|
|
195
|
+
*
|
|
196
|
+
* `conditionalPaths` param allows setting the default conditional value for
|
|
197
|
+
* `hidden` and `readOnly` to false,
|
|
198
|
+
* or individually set `hidden` and `readOnly` state for individual document paths.
|
|
199
|
+
*
|
|
200
|
+
*
|
|
201
|
+
* Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Assist,
|
|
202
|
+
* and cannot be changed via conditionalPaths.
|
|
203
|
+
*
|
|
204
|
+
* conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
|
|
205
|
+
*
|
|
206
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
207
|
+
* @see AssistRequestBase#outputTypes
|
|
208
|
+
*/
|
|
209
|
+
conditionalPaths?: {
|
|
210
|
+
defaultReadOnly?: boolean
|
|
211
|
+
defaultHidden?: boolean
|
|
212
|
+
paths?: {
|
|
213
|
+
/** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
|
|
214
|
+
path: string
|
|
215
|
+
readOnly: boolean
|
|
216
|
+
hidden: boolean
|
|
217
|
+
}[]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** @beta */
|
|
222
|
+
export declare type AssistSyncInstruction<T extends Record<string, Any_2> = Record<string, Any_2>> =
|
|
223
|
+
(ExistingDocumentRequest | CreateDocumentRequest<T>) & AssistRequestBase & Sync
|
|
224
|
+
|
|
225
|
+
declare interface Async {
|
|
226
|
+
/**
|
|
227
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
228
|
+
* The instruction operation will carry on in the background.
|
|
229
|
+
*
|
|
230
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
231
|
+
*
|
|
232
|
+
* async: true is incompatible with skipWrite, as async: true does not return the resulting document
|
|
233
|
+
*/
|
|
234
|
+
async: true
|
|
235
|
+
}
|
|
236
|
+
|
|
119
237
|
/** @internal */
|
|
120
238
|
export declare type AttributeSet = {
|
|
121
239
|
[key: string]: Any
|
|
@@ -401,7 +519,7 @@ export declare class ClientError extends Error {
|
|
|
401
519
|
|
|
402
520
|
/** @public */
|
|
403
521
|
export declare type ClientPerspective =
|
|
404
|
-
|
|
|
522
|
+
| DeprecatedPreviewDrafts
|
|
405
523
|
| 'published'
|
|
406
524
|
| 'drafts'
|
|
407
525
|
| 'raw'
|
|
@@ -446,6 +564,12 @@ export declare class ConnectionFailedError extends Error {
|
|
|
446
564
|
readonly name = 'ConnectionFailedError'
|
|
447
565
|
}
|
|
448
566
|
|
|
567
|
+
/** @beta */
|
|
568
|
+
export declare interface ConstantInstructionParam {
|
|
569
|
+
type: 'constant'
|
|
570
|
+
value: string
|
|
571
|
+
}
|
|
572
|
+
|
|
449
573
|
/** @public */
|
|
450
574
|
export declare interface ContentSourceMap {
|
|
451
575
|
mappings: ContentSourceMapMappings
|
|
@@ -565,6 +689,18 @@ export declare type CreateAction = {
|
|
|
565
689
|
/** @public */
|
|
566
690
|
export declare const createClient: (config: ClientConfig) => SanityClient
|
|
567
691
|
|
|
692
|
+
/**
|
|
693
|
+
* Instruction to create a new document
|
|
694
|
+
* @beta
|
|
695
|
+
*/
|
|
696
|
+
declare interface CreateDocumentRequest<T extends Record<string, Any_2> = Record<string, Any_2>> {
|
|
697
|
+
createDocument: {
|
|
698
|
+
/** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
|
|
699
|
+
_id?: string
|
|
700
|
+
_type: string
|
|
701
|
+
} & SanityDocumentStub_2<T>
|
|
702
|
+
}
|
|
703
|
+
|
|
568
704
|
/** @internal */
|
|
569
705
|
export declare interface CurrentSanityUser {
|
|
570
706
|
id: string
|
|
@@ -667,6 +803,11 @@ export declare type DeleteAction = {
|
|
|
667
803
|
declare const deprecatedCreateClient: (config: ClientConfig) => SanityClient
|
|
668
804
|
export default deprecatedCreateClient
|
|
669
805
|
|
|
806
|
+
/**
|
|
807
|
+
* @deprecated use 'drafts' instead
|
|
808
|
+
*/
|
|
809
|
+
declare type DeprecatedPreviewDrafts = 'previewDrafts'
|
|
810
|
+
|
|
670
811
|
/**
|
|
671
812
|
* Delete the draft version of a document.
|
|
672
813
|
* It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
|
|
@@ -753,6 +894,20 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
753
894
|
*/
|
|
754
895
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
755
896
|
|
|
897
|
+
/**
|
|
898
|
+
* Instruction for an existing document.
|
|
899
|
+
* @beta
|
|
900
|
+
*/
|
|
901
|
+
declare interface ExistingDocumentRequest {
|
|
902
|
+
documentId: string
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/** @beta */
|
|
906
|
+
export declare interface FieldInstructionParam {
|
|
907
|
+
type: 'field'
|
|
908
|
+
path: string
|
|
909
|
+
}
|
|
910
|
+
|
|
756
911
|
/** @public */
|
|
757
912
|
export declare type FilterDefault = (props: {
|
|
758
913
|
/**
|
|
@@ -819,6 +974,13 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
819
974
|
returnDocuments?: true
|
|
820
975
|
}
|
|
821
976
|
|
|
977
|
+
/** @beta */
|
|
978
|
+
export declare interface GroqInstructionParam {
|
|
979
|
+
type: 'groq'
|
|
980
|
+
query: string
|
|
981
|
+
params?: Record<string, string>
|
|
982
|
+
}
|
|
983
|
+
|
|
822
984
|
/** @public */
|
|
823
985
|
export declare type HttpRequest = {
|
|
824
986
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -879,6 +1041,16 @@ export declare type InsertPatch =
|
|
|
879
1041
|
items: Any[]
|
|
880
1042
|
}
|
|
881
1043
|
|
|
1044
|
+
/** @beta */
|
|
1045
|
+
export declare type InstructionParam =
|
|
1046
|
+
| string
|
|
1047
|
+
| ConstantInstructionParam
|
|
1048
|
+
| FieldInstructionParam
|
|
1049
|
+
| GroqInstructionParam
|
|
1050
|
+
|
|
1051
|
+
/** @beta */
|
|
1052
|
+
export declare type InstructionParams = Record<string, InstructionParam>
|
|
1053
|
+
|
|
882
1054
|
/**
|
|
883
1055
|
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
884
1056
|
*
|
|
@@ -1288,6 +1460,18 @@ export declare class ObservableAssetsClient {
|
|
|
1288
1460
|
>
|
|
1289
1461
|
}
|
|
1290
1462
|
|
|
1463
|
+
/** @public */
|
|
1464
|
+
declare class ObservableAssistClient {
|
|
1465
|
+
#private
|
|
1466
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1467
|
+
instruct(request: AssistAsyncInstruction): Observable<{
|
|
1468
|
+
_id: string
|
|
1469
|
+
}>
|
|
1470
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
1471
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
1472
|
+
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1291
1475
|
/** @internal */
|
|
1292
1476
|
export declare class ObservableDatasetsClient {
|
|
1293
1477
|
#private
|
|
@@ -1411,6 +1595,7 @@ export declare class ObservableSanityClient {
|
|
|
1411
1595
|
live: LiveClient
|
|
1412
1596
|
projects: ObservableProjectsClient
|
|
1413
1597
|
users: ObservableUsersClient
|
|
1598
|
+
assist: ObservableAssistClient
|
|
1414
1599
|
/**
|
|
1415
1600
|
* Instance properties
|
|
1416
1601
|
*/
|
|
@@ -2330,6 +2515,7 @@ export declare class SanityClient {
|
|
|
2330
2515
|
live: LiveClient
|
|
2331
2516
|
projects: ProjectsClient
|
|
2332
2517
|
users: UsersClient
|
|
2518
|
+
assist: AssistClient
|
|
2333
2519
|
/**
|
|
2334
2520
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2335
2521
|
*/
|
|
@@ -3044,6 +3230,29 @@ export {StudioBaseUrl}
|
|
|
3044
3230
|
|
|
3045
3231
|
export {StudioUrl}
|
|
3046
3232
|
|
|
3233
|
+
declare interface Sync {
|
|
3234
|
+
/**
|
|
3235
|
+
* By default, skipWrite: false.
|
|
3236
|
+
* Write enabled operations will mutate the target document, and emit AI presence in the studio.
|
|
3237
|
+
*
|
|
3238
|
+
* When skipWrite: true, the api will not mutate any documents nor emit presence.
|
|
3239
|
+
* Ie, when true, no changes will be made to content-lake
|
|
3240
|
+
*
|
|
3241
|
+
* skipWrite: true is incompatible with async: true,
|
|
3242
|
+
* as skipWrite implies that you will use the return value of the operation
|
|
3243
|
+
*/
|
|
3244
|
+
skipWrite?: boolean
|
|
3245
|
+
/**
|
|
3246
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
3247
|
+
* The instruction operation will carry on in the background.
|
|
3248
|
+
*
|
|
3249
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
3250
|
+
*
|
|
3251
|
+
* async: true is incompatible with skipWrite: true, as async: true does not return the resulting document
|
|
3252
|
+
*/
|
|
3253
|
+
async?: false
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3047
3256
|
/** @public */
|
|
3048
3257
|
export declare type SyncTag = `s1:${string}`
|
|
3049
3258
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type {Any as Any_2} from '@sanity/client'
|
|
1
2
|
import type {ContentSourceMapDocuments as ContentSourceMapDocuments_2} from '@sanity/client/csm'
|
|
2
3
|
import {ContentSourceMapParsedPath} from '@sanity/client/csm'
|
|
3
4
|
import {ContentSourceMapParsedPathKeyedSegment} from '@sanity/client/csm'
|
|
4
5
|
import {Observable} from 'rxjs'
|
|
5
6
|
import {Requester} from 'get-it'
|
|
6
7
|
import type {ResolveStudioUrl} from '@sanity/client/csm'
|
|
8
|
+
import type {SanityDocumentStub as SanityDocumentStub_2} from '@sanity/client'
|
|
7
9
|
import {StudioBaseRoute} from '@sanity/client/csm'
|
|
8
10
|
import {StudioBaseUrl} from '@sanity/client/csm'
|
|
9
11
|
import {StudioUrl} from '@sanity/client/csm'
|
|
@@ -116,6 +118,122 @@ export declare class AssetsClient {
|
|
|
116
118
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
/** @beta */
|
|
122
|
+
export declare type AssistAsyncInstruction<
|
|
123
|
+
T extends Record<string, Any_2> = Record<string, Any_2>,
|
|
124
|
+
> = (ExistingDocumentRequest | CreateDocumentRequest<T>) & AssistRequestBase & Async
|
|
125
|
+
|
|
126
|
+
/** @public */
|
|
127
|
+
declare class AssistClient {
|
|
128
|
+
#private
|
|
129
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
130
|
+
instruct(request: AssistAsyncInstruction): Promise<{
|
|
131
|
+
_id: string
|
|
132
|
+
}>
|
|
133
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
134
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
135
|
+
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** @beta */
|
|
139
|
+
export declare type AssistInstruction<T extends Record<string, Any_2> = Record<string, Any_2>> =
|
|
140
|
+
| AssistSyncInstruction<T>
|
|
141
|
+
| AssistAsyncInstruction<T>
|
|
142
|
+
|
|
143
|
+
declare interface AssistRequestBase {
|
|
144
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
145
|
+
schemaId: string
|
|
146
|
+
/** string template using $variable – more on this below under "Dynamic instruction" */
|
|
147
|
+
instruction: string
|
|
148
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
149
|
+
instructionParams?: InstructionParams
|
|
150
|
+
/**
|
|
151
|
+
* Optional document path output target for the instruction.
|
|
152
|
+
* When provided, the instruction will apply to this path in the document and its children.
|
|
153
|
+
*
|
|
154
|
+
* ## Examples
|
|
155
|
+
* - `path: 'title'` will output to the title field in the document
|
|
156
|
+
* - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
|
|
157
|
+
*/
|
|
158
|
+
path?: string
|
|
159
|
+
/**
|
|
160
|
+
* Controls sub-paths in the document that can be output to.
|
|
161
|
+
*
|
|
162
|
+
* The string-paths are relative to the `path` param
|
|
163
|
+
*
|
|
164
|
+
* Note: these path strings are less strictly validated than the `path` param itself:
|
|
165
|
+
* if an relative-path does not exist or is invalid, it will be silently ignored.
|
|
166
|
+
*
|
|
167
|
+
* @see AssistRequestBase#conditionalPaths
|
|
168
|
+
* @see AssistRequestBase#outputTypes
|
|
169
|
+
*/
|
|
170
|
+
relativeOutputPaths?:
|
|
171
|
+
| {
|
|
172
|
+
include: string[]
|
|
173
|
+
}
|
|
174
|
+
| {
|
|
175
|
+
exclude: string[]
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Controls which types the instruction is allowed to output to.
|
|
179
|
+
*
|
|
180
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
181
|
+
* @see AssistRequestBase#conditionalPaths
|
|
182
|
+
*/
|
|
183
|
+
outputTypes?:
|
|
184
|
+
| {
|
|
185
|
+
include: string[]
|
|
186
|
+
}
|
|
187
|
+
| {
|
|
188
|
+
exclude: string[]
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
|
|
192
|
+
*
|
|
193
|
+
* By default, AI Assist will not output to conditional `readOnly` and `hidden` fields,
|
|
194
|
+
* ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
|
|
195
|
+
*
|
|
196
|
+
* `conditionalPaths` param allows setting the default conditional value for
|
|
197
|
+
* `hidden` and `readOnly` to false,
|
|
198
|
+
* or individually set `hidden` and `readOnly` state for individual document paths.
|
|
199
|
+
*
|
|
200
|
+
*
|
|
201
|
+
* Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Assist,
|
|
202
|
+
* and cannot be changed via conditionalPaths.
|
|
203
|
+
*
|
|
204
|
+
* conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
|
|
205
|
+
*
|
|
206
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
207
|
+
* @see AssistRequestBase#outputTypes
|
|
208
|
+
*/
|
|
209
|
+
conditionalPaths?: {
|
|
210
|
+
defaultReadOnly?: boolean
|
|
211
|
+
defaultHidden?: boolean
|
|
212
|
+
paths?: {
|
|
213
|
+
/** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
|
|
214
|
+
path: string
|
|
215
|
+
readOnly: boolean
|
|
216
|
+
hidden: boolean
|
|
217
|
+
}[]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** @beta */
|
|
222
|
+
export declare type AssistSyncInstruction<T extends Record<string, Any_2> = Record<string, Any_2>> =
|
|
223
|
+
(ExistingDocumentRequest | CreateDocumentRequest<T>) & AssistRequestBase & Sync
|
|
224
|
+
|
|
225
|
+
declare interface Async {
|
|
226
|
+
/**
|
|
227
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
228
|
+
* The instruction operation will carry on in the background.
|
|
229
|
+
*
|
|
230
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
231
|
+
*
|
|
232
|
+
* async: true is incompatible with skipWrite, as async: true does not return the resulting document
|
|
233
|
+
*/
|
|
234
|
+
async: true
|
|
235
|
+
}
|
|
236
|
+
|
|
119
237
|
/** @internal */
|
|
120
238
|
export declare type AttributeSet = {
|
|
121
239
|
[key: string]: Any
|
|
@@ -401,7 +519,7 @@ export declare class ClientError extends Error {
|
|
|
401
519
|
|
|
402
520
|
/** @public */
|
|
403
521
|
export declare type ClientPerspective =
|
|
404
|
-
|
|
|
522
|
+
| DeprecatedPreviewDrafts
|
|
405
523
|
| 'published'
|
|
406
524
|
| 'drafts'
|
|
407
525
|
| 'raw'
|
|
@@ -446,6 +564,12 @@ export declare class ConnectionFailedError extends Error {
|
|
|
446
564
|
readonly name = 'ConnectionFailedError'
|
|
447
565
|
}
|
|
448
566
|
|
|
567
|
+
/** @beta */
|
|
568
|
+
export declare interface ConstantInstructionParam {
|
|
569
|
+
type: 'constant'
|
|
570
|
+
value: string
|
|
571
|
+
}
|
|
572
|
+
|
|
449
573
|
/** @public */
|
|
450
574
|
export declare interface ContentSourceMap {
|
|
451
575
|
mappings: ContentSourceMapMappings
|
|
@@ -565,6 +689,18 @@ export declare type CreateAction = {
|
|
|
565
689
|
/** @public */
|
|
566
690
|
export declare const createClient: (config: ClientConfig) => SanityClient
|
|
567
691
|
|
|
692
|
+
/**
|
|
693
|
+
* Instruction to create a new document
|
|
694
|
+
* @beta
|
|
695
|
+
*/
|
|
696
|
+
declare interface CreateDocumentRequest<T extends Record<string, Any_2> = Record<string, Any_2>> {
|
|
697
|
+
createDocument: {
|
|
698
|
+
/** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
|
|
699
|
+
_id?: string
|
|
700
|
+
_type: string
|
|
701
|
+
} & SanityDocumentStub_2<T>
|
|
702
|
+
}
|
|
703
|
+
|
|
568
704
|
/** @internal */
|
|
569
705
|
export declare interface CurrentSanityUser {
|
|
570
706
|
id: string
|
|
@@ -667,6 +803,11 @@ export declare type DeleteAction = {
|
|
|
667
803
|
declare const deprecatedCreateClient: (config: ClientConfig) => SanityClient
|
|
668
804
|
export default deprecatedCreateClient
|
|
669
805
|
|
|
806
|
+
/**
|
|
807
|
+
* @deprecated use 'drafts' instead
|
|
808
|
+
*/
|
|
809
|
+
declare type DeprecatedPreviewDrafts = 'previewDrafts'
|
|
810
|
+
|
|
670
811
|
/**
|
|
671
812
|
* Delete the draft version of a document.
|
|
672
813
|
* It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
|
|
@@ -753,6 +894,20 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
753
894
|
*/
|
|
754
895
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
755
896
|
|
|
897
|
+
/**
|
|
898
|
+
* Instruction for an existing document.
|
|
899
|
+
* @beta
|
|
900
|
+
*/
|
|
901
|
+
declare interface ExistingDocumentRequest {
|
|
902
|
+
documentId: string
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/** @beta */
|
|
906
|
+
export declare interface FieldInstructionParam {
|
|
907
|
+
type: 'field'
|
|
908
|
+
path: string
|
|
909
|
+
}
|
|
910
|
+
|
|
756
911
|
/** @public */
|
|
757
912
|
export declare type FilterDefault = (props: {
|
|
758
913
|
/**
|
|
@@ -819,6 +974,13 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
819
974
|
returnDocuments?: true
|
|
820
975
|
}
|
|
821
976
|
|
|
977
|
+
/** @beta */
|
|
978
|
+
export declare interface GroqInstructionParam {
|
|
979
|
+
type: 'groq'
|
|
980
|
+
query: string
|
|
981
|
+
params?: Record<string, string>
|
|
982
|
+
}
|
|
983
|
+
|
|
822
984
|
/** @public */
|
|
823
985
|
export declare type HttpRequest = {
|
|
824
986
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -879,6 +1041,16 @@ export declare type InsertPatch =
|
|
|
879
1041
|
items: Any[]
|
|
880
1042
|
}
|
|
881
1043
|
|
|
1044
|
+
/** @beta */
|
|
1045
|
+
export declare type InstructionParam =
|
|
1046
|
+
| string
|
|
1047
|
+
| ConstantInstructionParam
|
|
1048
|
+
| FieldInstructionParam
|
|
1049
|
+
| GroqInstructionParam
|
|
1050
|
+
|
|
1051
|
+
/** @beta */
|
|
1052
|
+
export declare type InstructionParams = Record<string, InstructionParam>
|
|
1053
|
+
|
|
882
1054
|
/**
|
|
883
1055
|
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
884
1056
|
*
|
|
@@ -1288,6 +1460,18 @@ export declare class ObservableAssetsClient {
|
|
|
1288
1460
|
>
|
|
1289
1461
|
}
|
|
1290
1462
|
|
|
1463
|
+
/** @public */
|
|
1464
|
+
declare class ObservableAssistClient {
|
|
1465
|
+
#private
|
|
1466
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1467
|
+
instruct(request: AssistAsyncInstruction): Observable<{
|
|
1468
|
+
_id: string
|
|
1469
|
+
}>
|
|
1470
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
1471
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
1472
|
+
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1291
1475
|
/** @internal */
|
|
1292
1476
|
export declare class ObservableDatasetsClient {
|
|
1293
1477
|
#private
|
|
@@ -1411,6 +1595,7 @@ export declare class ObservableSanityClient {
|
|
|
1411
1595
|
live: LiveClient
|
|
1412
1596
|
projects: ObservableProjectsClient
|
|
1413
1597
|
users: ObservableUsersClient
|
|
1598
|
+
assist: ObservableAssistClient
|
|
1414
1599
|
/**
|
|
1415
1600
|
* Instance properties
|
|
1416
1601
|
*/
|
|
@@ -2330,6 +2515,7 @@ export declare class SanityClient {
|
|
|
2330
2515
|
live: LiveClient
|
|
2331
2516
|
projects: ProjectsClient
|
|
2332
2517
|
users: UsersClient
|
|
2518
|
+
assist: AssistClient
|
|
2333
2519
|
/**
|
|
2334
2520
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2335
2521
|
*/
|
|
@@ -3044,6 +3230,29 @@ export {StudioBaseUrl}
|
|
|
3044
3230
|
|
|
3045
3231
|
export {StudioUrl}
|
|
3046
3232
|
|
|
3233
|
+
declare interface Sync {
|
|
3234
|
+
/**
|
|
3235
|
+
* By default, skipWrite: false.
|
|
3236
|
+
* Write enabled operations will mutate the target document, and emit AI presence in the studio.
|
|
3237
|
+
*
|
|
3238
|
+
* When skipWrite: true, the api will not mutate any documents nor emit presence.
|
|
3239
|
+
* Ie, when true, no changes will be made to content-lake
|
|
3240
|
+
*
|
|
3241
|
+
* skipWrite: true is incompatible with async: true,
|
|
3242
|
+
* as skipWrite implies that you will use the return value of the operation
|
|
3243
|
+
*/
|
|
3244
|
+
skipWrite?: boolean
|
|
3245
|
+
/**
|
|
3246
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
3247
|
+
* The instruction operation will carry on in the background.
|
|
3248
|
+
*
|
|
3249
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
3250
|
+
*
|
|
3251
|
+
* async: true is incompatible with skipWrite: true, as async: true does not return the resulting document
|
|
3252
|
+
*/
|
|
3253
|
+
async?: false
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3047
3256
|
/** @public */
|
|
3048
3257
|
export declare type SyncTag = `s1:${string}`
|
|
3049
3258
|
|