@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.browser.d.cts
CHANGED
|
@@ -57,6 +57,12 @@ export declare type AllDocumentsMutationOptions = BaseMutationOptions & {
|
|
|
57
57
|
*/
|
|
58
58
|
export declare type Any = any
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
declare type Any_2 = any
|
|
65
|
+
|
|
60
66
|
/** @internal */
|
|
61
67
|
export declare interface ApiError {
|
|
62
68
|
error: string
|
|
@@ -116,6 +122,122 @@ export declare class AssetsClient {
|
|
|
116
122
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
117
123
|
}
|
|
118
124
|
|
|
125
|
+
/** @beta */
|
|
126
|
+
export declare type AssistAsyncInstruction<
|
|
127
|
+
T extends Record<string, Any_2> = Record<string, Any_2>,
|
|
128
|
+
> = (ExistingDocumentRequest | CreateDocumentRequest<T>) & AssistRequestBase & Async
|
|
129
|
+
|
|
130
|
+
/** @public */
|
|
131
|
+
declare class AssistClient {
|
|
132
|
+
#private
|
|
133
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
134
|
+
instruct(request: AssistAsyncInstruction): Promise<{
|
|
135
|
+
_id: string
|
|
136
|
+
}>
|
|
137
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
138
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
139
|
+
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** @beta */
|
|
143
|
+
export declare type AssistInstruction<T extends Record<string, Any_2> = Record<string, Any_2>> =
|
|
144
|
+
| AssistSyncInstruction<T>
|
|
145
|
+
| AssistAsyncInstruction<T>
|
|
146
|
+
|
|
147
|
+
declare interface AssistRequestBase {
|
|
148
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
149
|
+
schemaId: string
|
|
150
|
+
/** string template using $variable – more on this below under "Dynamic instruction" */
|
|
151
|
+
instruction: string
|
|
152
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
153
|
+
instructionParams?: InstructionParams
|
|
154
|
+
/**
|
|
155
|
+
* Optional document path output target for the instruction.
|
|
156
|
+
* When provided, the instruction will apply to this path in the document and its children.
|
|
157
|
+
*
|
|
158
|
+
* ## Examples
|
|
159
|
+
* - `path: 'title'` will output to the title field in the document
|
|
160
|
+
* - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
|
|
161
|
+
*/
|
|
162
|
+
path?: string
|
|
163
|
+
/**
|
|
164
|
+
* Controls sub-paths in the document that can be output to.
|
|
165
|
+
*
|
|
166
|
+
* The string-paths are relative to the `path` param
|
|
167
|
+
*
|
|
168
|
+
* Note: these path strings are less strictly validated than the `path` param itself:
|
|
169
|
+
* if an relative-path does not exist or is invalid, it will be silently ignored.
|
|
170
|
+
*
|
|
171
|
+
* @see AssistRequestBase#conditionalPaths
|
|
172
|
+
* @see AssistRequestBase#outputTypes
|
|
173
|
+
*/
|
|
174
|
+
relativeOutputPaths?:
|
|
175
|
+
| {
|
|
176
|
+
include: string[]
|
|
177
|
+
}
|
|
178
|
+
| {
|
|
179
|
+
exclude: string[]
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Controls which types the instruction is allowed to output to.
|
|
183
|
+
*
|
|
184
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
185
|
+
* @see AssistRequestBase#conditionalPaths
|
|
186
|
+
*/
|
|
187
|
+
outputTypes?:
|
|
188
|
+
| {
|
|
189
|
+
include: string[]
|
|
190
|
+
}
|
|
191
|
+
| {
|
|
192
|
+
exclude: string[]
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
|
|
196
|
+
*
|
|
197
|
+
* By default, AI Assist will not output to conditional `readOnly` and `hidden` fields,
|
|
198
|
+
* ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
|
|
199
|
+
*
|
|
200
|
+
* `conditionalPaths` param allows setting the default conditional value for
|
|
201
|
+
* `hidden` and `readOnly` to false,
|
|
202
|
+
* or individually set `hidden` and `readOnly` state for individual document paths.
|
|
203
|
+
*
|
|
204
|
+
*
|
|
205
|
+
* Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Assist,
|
|
206
|
+
* and cannot be changed via conditionalPaths.
|
|
207
|
+
*
|
|
208
|
+
* conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
|
|
209
|
+
*
|
|
210
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
211
|
+
* @see AssistRequestBase#outputTypes
|
|
212
|
+
*/
|
|
213
|
+
conditionalPaths?: {
|
|
214
|
+
defaultReadOnly?: boolean
|
|
215
|
+
defaultHidden?: boolean
|
|
216
|
+
paths?: {
|
|
217
|
+
/** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
|
|
218
|
+
path: string
|
|
219
|
+
readOnly: boolean
|
|
220
|
+
hidden: boolean
|
|
221
|
+
}[]
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** @beta */
|
|
226
|
+
export declare type AssistSyncInstruction<T extends Record<string, Any_2> = Record<string, Any_2>> =
|
|
227
|
+
(ExistingDocumentRequest | CreateDocumentRequest<T>) & AssistRequestBase & Sync
|
|
228
|
+
|
|
229
|
+
declare interface Async {
|
|
230
|
+
/**
|
|
231
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
232
|
+
* The instruction operation will carry on in the background.
|
|
233
|
+
*
|
|
234
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
235
|
+
*
|
|
236
|
+
* async: true is incompatible with skipWrite, as async: true does not return the resulting document
|
|
237
|
+
*/
|
|
238
|
+
async: true
|
|
239
|
+
}
|
|
240
|
+
|
|
119
241
|
/** @internal */
|
|
120
242
|
export declare type AttributeSet = {
|
|
121
243
|
[key: string]: Any
|
|
@@ -401,7 +523,7 @@ export declare class ClientError extends Error {
|
|
|
401
523
|
|
|
402
524
|
/** @public */
|
|
403
525
|
export declare type ClientPerspective =
|
|
404
|
-
|
|
|
526
|
+
| DeprecatedPreviewDrafts
|
|
405
527
|
| 'published'
|
|
406
528
|
| 'drafts'
|
|
407
529
|
| 'raw'
|
|
@@ -446,6 +568,12 @@ export declare class ConnectionFailedError extends Error {
|
|
|
446
568
|
readonly name = 'ConnectionFailedError'
|
|
447
569
|
}
|
|
448
570
|
|
|
571
|
+
/** @beta */
|
|
572
|
+
export declare interface ConstantInstructionParam {
|
|
573
|
+
type: 'constant'
|
|
574
|
+
value: string
|
|
575
|
+
}
|
|
576
|
+
|
|
449
577
|
/** @public */
|
|
450
578
|
export declare interface ContentSourceMap {
|
|
451
579
|
mappings: ContentSourceMapMappings
|
|
@@ -565,6 +693,18 @@ export declare type CreateAction = {
|
|
|
565
693
|
/** @public */
|
|
566
694
|
export declare const createClient: (config: ClientConfig) => SanityClient
|
|
567
695
|
|
|
696
|
+
/**
|
|
697
|
+
* Instruction to create a new document
|
|
698
|
+
* @beta
|
|
699
|
+
*/
|
|
700
|
+
declare interface CreateDocumentRequest<T extends Record<string, Any_2> = Record<string, Any_2>> {
|
|
701
|
+
createDocument: {
|
|
702
|
+
/** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
|
|
703
|
+
_id?: string
|
|
704
|
+
_type: string
|
|
705
|
+
} & SanityDocumentStub_2<T>
|
|
706
|
+
}
|
|
707
|
+
|
|
568
708
|
/** @internal */
|
|
569
709
|
export declare interface CurrentSanityUser {
|
|
570
710
|
id: string
|
|
@@ -667,6 +807,11 @@ export declare type DeleteAction = {
|
|
|
667
807
|
declare const deprecatedCreateClient: (config: ClientConfig) => SanityClient
|
|
668
808
|
export default deprecatedCreateClient
|
|
669
809
|
|
|
810
|
+
/**
|
|
811
|
+
* @deprecated use 'drafts' instead
|
|
812
|
+
*/
|
|
813
|
+
declare type DeprecatedPreviewDrafts = 'previewDrafts'
|
|
814
|
+
|
|
670
815
|
/**
|
|
671
816
|
* Delete the draft version of a document.
|
|
672
817
|
* It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
|
|
@@ -753,6 +898,20 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
753
898
|
*/
|
|
754
899
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
755
900
|
|
|
901
|
+
/**
|
|
902
|
+
* Instruction for an existing document.
|
|
903
|
+
* @beta
|
|
904
|
+
*/
|
|
905
|
+
declare interface ExistingDocumentRequest {
|
|
906
|
+
documentId: string
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/** @beta */
|
|
910
|
+
export declare interface FieldInstructionParam {
|
|
911
|
+
type: 'field'
|
|
912
|
+
path: string
|
|
913
|
+
}
|
|
914
|
+
|
|
756
915
|
/** @public */
|
|
757
916
|
export declare type FilterDefault = (props: {
|
|
758
917
|
/**
|
|
@@ -819,6 +978,13 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
819
978
|
returnDocuments?: true
|
|
820
979
|
}
|
|
821
980
|
|
|
981
|
+
/** @beta */
|
|
982
|
+
export declare interface GroqInstructionParam {
|
|
983
|
+
type: 'groq'
|
|
984
|
+
query: string
|
|
985
|
+
params?: Record<string, string>
|
|
986
|
+
}
|
|
987
|
+
|
|
822
988
|
/** @public */
|
|
823
989
|
export declare type HttpRequest = {
|
|
824
990
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -879,6 +1045,16 @@ export declare type InsertPatch =
|
|
|
879
1045
|
items: Any[]
|
|
880
1046
|
}
|
|
881
1047
|
|
|
1048
|
+
/** @beta */
|
|
1049
|
+
export declare type InstructionParam =
|
|
1050
|
+
| string
|
|
1051
|
+
| ConstantInstructionParam
|
|
1052
|
+
| FieldInstructionParam
|
|
1053
|
+
| GroqInstructionParam
|
|
1054
|
+
|
|
1055
|
+
/** @beta */
|
|
1056
|
+
export declare type InstructionParams = Record<string, InstructionParam>
|
|
1057
|
+
|
|
882
1058
|
/**
|
|
883
1059
|
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
884
1060
|
*
|
|
@@ -1288,6 +1464,18 @@ export declare class ObservableAssetsClient {
|
|
|
1288
1464
|
>
|
|
1289
1465
|
}
|
|
1290
1466
|
|
|
1467
|
+
/** @public */
|
|
1468
|
+
declare class ObservableAssistClient {
|
|
1469
|
+
#private
|
|
1470
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1471
|
+
instruct(request: AssistAsyncInstruction): Observable<{
|
|
1472
|
+
_id: string
|
|
1473
|
+
}>
|
|
1474
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
1475
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
1476
|
+
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1291
1479
|
/** @internal */
|
|
1292
1480
|
export declare class ObservableDatasetsClient {
|
|
1293
1481
|
#private
|
|
@@ -1411,6 +1599,7 @@ export declare class ObservableSanityClient {
|
|
|
1411
1599
|
live: LiveClient
|
|
1412
1600
|
projects: ObservableProjectsClient
|
|
1413
1601
|
users: ObservableUsersClient
|
|
1602
|
+
assist: ObservableAssistClient
|
|
1414
1603
|
/**
|
|
1415
1604
|
* Instance properties
|
|
1416
1605
|
*/
|
|
@@ -2330,6 +2519,7 @@ export declare class SanityClient {
|
|
|
2330
2519
|
live: LiveClient
|
|
2331
2520
|
projects: ProjectsClient
|
|
2332
2521
|
users: UsersClient
|
|
2522
|
+
assist: AssistClient
|
|
2333
2523
|
/**
|
|
2334
2524
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2335
2525
|
*/
|
|
@@ -2868,6 +3058,13 @@ export declare type SanityDocumentStub<T extends Record<string, Any> = Record<st
|
|
|
2868
3058
|
_type: string
|
|
2869
3059
|
}
|
|
2870
3060
|
|
|
3061
|
+
/** @public */
|
|
3062
|
+
declare type SanityDocumentStub_2<T extends Record<string, Any_2> = Record<string, Any_2>> = {
|
|
3063
|
+
[P in keyof T]: T[P]
|
|
3064
|
+
} & {
|
|
3065
|
+
_type: string
|
|
3066
|
+
}
|
|
3067
|
+
|
|
2871
3068
|
/** @internal */
|
|
2872
3069
|
export declare interface SanityImageAssetDocument extends SanityAssetDocument {
|
|
2873
3070
|
metadata: {
|
|
@@ -3044,6 +3241,29 @@ export {StudioBaseUrl}
|
|
|
3044
3241
|
|
|
3045
3242
|
export {StudioUrl}
|
|
3046
3243
|
|
|
3244
|
+
declare interface Sync {
|
|
3245
|
+
/**
|
|
3246
|
+
* By default, skipWrite: false.
|
|
3247
|
+
* Write enabled operations will mutate the target document, and emit AI presence in the studio.
|
|
3248
|
+
*
|
|
3249
|
+
* When skipWrite: true, the api will not mutate any documents nor emit presence.
|
|
3250
|
+
* Ie, when true, no changes will be made to content-lake
|
|
3251
|
+
*
|
|
3252
|
+
* skipWrite: true is incompatible with async: true,
|
|
3253
|
+
* as skipWrite implies that you will use the return value of the operation
|
|
3254
|
+
*/
|
|
3255
|
+
skipWrite?: boolean
|
|
3256
|
+
/**
|
|
3257
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
3258
|
+
* The instruction operation will carry on in the background.
|
|
3259
|
+
*
|
|
3260
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
3261
|
+
*
|
|
3262
|
+
* async: true is incompatible with skipWrite: true, as async: true does not return the resulting document
|
|
3263
|
+
*/
|
|
3264
|
+
async?: false
|
|
3265
|
+
}
|
|
3266
|
+
|
|
3047
3267
|
/** @public */
|
|
3048
3268
|
export declare type SyncTag = `s1:${string}`
|
|
3049
3269
|
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -57,6 +57,12 @@ export declare type AllDocumentsMutationOptions = BaseMutationOptions & {
|
|
|
57
57
|
*/
|
|
58
58
|
export declare type Any = any
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
declare type Any_2 = any
|
|
65
|
+
|
|
60
66
|
/** @internal */
|
|
61
67
|
export declare interface ApiError {
|
|
62
68
|
error: string
|
|
@@ -116,6 +122,122 @@ export declare class AssetsClient {
|
|
|
116
122
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
117
123
|
}
|
|
118
124
|
|
|
125
|
+
/** @beta */
|
|
126
|
+
export declare type AssistAsyncInstruction<
|
|
127
|
+
T extends Record<string, Any_2> = Record<string, Any_2>,
|
|
128
|
+
> = (ExistingDocumentRequest | CreateDocumentRequest<T>) & AssistRequestBase & Async
|
|
129
|
+
|
|
130
|
+
/** @public */
|
|
131
|
+
declare class AssistClient {
|
|
132
|
+
#private
|
|
133
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
134
|
+
instruct(request: AssistAsyncInstruction): Promise<{
|
|
135
|
+
_id: string
|
|
136
|
+
}>
|
|
137
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
138
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
139
|
+
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** @beta */
|
|
143
|
+
export declare type AssistInstruction<T extends Record<string, Any_2> = Record<string, Any_2>> =
|
|
144
|
+
| AssistSyncInstruction<T>
|
|
145
|
+
| AssistAsyncInstruction<T>
|
|
146
|
+
|
|
147
|
+
declare interface AssistRequestBase {
|
|
148
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
149
|
+
schemaId: string
|
|
150
|
+
/** string template using $variable – more on this below under "Dynamic instruction" */
|
|
151
|
+
instruction: string
|
|
152
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
153
|
+
instructionParams?: InstructionParams
|
|
154
|
+
/**
|
|
155
|
+
* Optional document path output target for the instruction.
|
|
156
|
+
* When provided, the instruction will apply to this path in the document and its children.
|
|
157
|
+
*
|
|
158
|
+
* ## Examples
|
|
159
|
+
* - `path: 'title'` will output to the title field in the document
|
|
160
|
+
* - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
|
|
161
|
+
*/
|
|
162
|
+
path?: string
|
|
163
|
+
/**
|
|
164
|
+
* Controls sub-paths in the document that can be output to.
|
|
165
|
+
*
|
|
166
|
+
* The string-paths are relative to the `path` param
|
|
167
|
+
*
|
|
168
|
+
* Note: these path strings are less strictly validated than the `path` param itself:
|
|
169
|
+
* if an relative-path does not exist or is invalid, it will be silently ignored.
|
|
170
|
+
*
|
|
171
|
+
* @see AssistRequestBase#conditionalPaths
|
|
172
|
+
* @see AssistRequestBase#outputTypes
|
|
173
|
+
*/
|
|
174
|
+
relativeOutputPaths?:
|
|
175
|
+
| {
|
|
176
|
+
include: string[]
|
|
177
|
+
}
|
|
178
|
+
| {
|
|
179
|
+
exclude: string[]
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Controls which types the instruction is allowed to output to.
|
|
183
|
+
*
|
|
184
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
185
|
+
* @see AssistRequestBase#conditionalPaths
|
|
186
|
+
*/
|
|
187
|
+
outputTypes?:
|
|
188
|
+
| {
|
|
189
|
+
include: string[]
|
|
190
|
+
}
|
|
191
|
+
| {
|
|
192
|
+
exclude: string[]
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
|
|
196
|
+
*
|
|
197
|
+
* By default, AI Assist will not output to conditional `readOnly` and `hidden` fields,
|
|
198
|
+
* ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
|
|
199
|
+
*
|
|
200
|
+
* `conditionalPaths` param allows setting the default conditional value for
|
|
201
|
+
* `hidden` and `readOnly` to false,
|
|
202
|
+
* or individually set `hidden` and `readOnly` state for individual document paths.
|
|
203
|
+
*
|
|
204
|
+
*
|
|
205
|
+
* Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Assist,
|
|
206
|
+
* and cannot be changed via conditionalPaths.
|
|
207
|
+
*
|
|
208
|
+
* conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
|
|
209
|
+
*
|
|
210
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
211
|
+
* @see AssistRequestBase#outputTypes
|
|
212
|
+
*/
|
|
213
|
+
conditionalPaths?: {
|
|
214
|
+
defaultReadOnly?: boolean
|
|
215
|
+
defaultHidden?: boolean
|
|
216
|
+
paths?: {
|
|
217
|
+
/** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
|
|
218
|
+
path: string
|
|
219
|
+
readOnly: boolean
|
|
220
|
+
hidden: boolean
|
|
221
|
+
}[]
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** @beta */
|
|
226
|
+
export declare type AssistSyncInstruction<T extends Record<string, Any_2> = Record<string, Any_2>> =
|
|
227
|
+
(ExistingDocumentRequest | CreateDocumentRequest<T>) & AssistRequestBase & Sync
|
|
228
|
+
|
|
229
|
+
declare interface Async {
|
|
230
|
+
/**
|
|
231
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
232
|
+
* The instruction operation will carry on in the background.
|
|
233
|
+
*
|
|
234
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
235
|
+
*
|
|
236
|
+
* async: true is incompatible with skipWrite, as async: true does not return the resulting document
|
|
237
|
+
*/
|
|
238
|
+
async: true
|
|
239
|
+
}
|
|
240
|
+
|
|
119
241
|
/** @internal */
|
|
120
242
|
export declare type AttributeSet = {
|
|
121
243
|
[key: string]: Any
|
|
@@ -401,7 +523,7 @@ export declare class ClientError extends Error {
|
|
|
401
523
|
|
|
402
524
|
/** @public */
|
|
403
525
|
export declare type ClientPerspective =
|
|
404
|
-
|
|
|
526
|
+
| DeprecatedPreviewDrafts
|
|
405
527
|
| 'published'
|
|
406
528
|
| 'drafts'
|
|
407
529
|
| 'raw'
|
|
@@ -446,6 +568,12 @@ export declare class ConnectionFailedError extends Error {
|
|
|
446
568
|
readonly name = 'ConnectionFailedError'
|
|
447
569
|
}
|
|
448
570
|
|
|
571
|
+
/** @beta */
|
|
572
|
+
export declare interface ConstantInstructionParam {
|
|
573
|
+
type: 'constant'
|
|
574
|
+
value: string
|
|
575
|
+
}
|
|
576
|
+
|
|
449
577
|
/** @public */
|
|
450
578
|
export declare interface ContentSourceMap {
|
|
451
579
|
mappings: ContentSourceMapMappings
|
|
@@ -565,6 +693,18 @@ export declare type CreateAction = {
|
|
|
565
693
|
/** @public */
|
|
566
694
|
export declare const createClient: (config: ClientConfig) => SanityClient
|
|
567
695
|
|
|
696
|
+
/**
|
|
697
|
+
* Instruction to create a new document
|
|
698
|
+
* @beta
|
|
699
|
+
*/
|
|
700
|
+
declare interface CreateDocumentRequest<T extends Record<string, Any_2> = Record<string, Any_2>> {
|
|
701
|
+
createDocument: {
|
|
702
|
+
/** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
|
|
703
|
+
_id?: string
|
|
704
|
+
_type: string
|
|
705
|
+
} & SanityDocumentStub_2<T>
|
|
706
|
+
}
|
|
707
|
+
|
|
568
708
|
/** @internal */
|
|
569
709
|
export declare interface CurrentSanityUser {
|
|
570
710
|
id: string
|
|
@@ -667,6 +807,11 @@ export declare type DeleteAction = {
|
|
|
667
807
|
declare const deprecatedCreateClient: (config: ClientConfig) => SanityClient
|
|
668
808
|
export default deprecatedCreateClient
|
|
669
809
|
|
|
810
|
+
/**
|
|
811
|
+
* @deprecated use 'drafts' instead
|
|
812
|
+
*/
|
|
813
|
+
declare type DeprecatedPreviewDrafts = 'previewDrafts'
|
|
814
|
+
|
|
670
815
|
/**
|
|
671
816
|
* Delete the draft version of a document.
|
|
672
817
|
* It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
|
|
@@ -753,6 +898,20 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
753
898
|
*/
|
|
754
899
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
755
900
|
|
|
901
|
+
/**
|
|
902
|
+
* Instruction for an existing document.
|
|
903
|
+
* @beta
|
|
904
|
+
*/
|
|
905
|
+
declare interface ExistingDocumentRequest {
|
|
906
|
+
documentId: string
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/** @beta */
|
|
910
|
+
export declare interface FieldInstructionParam {
|
|
911
|
+
type: 'field'
|
|
912
|
+
path: string
|
|
913
|
+
}
|
|
914
|
+
|
|
756
915
|
/** @public */
|
|
757
916
|
export declare type FilterDefault = (props: {
|
|
758
917
|
/**
|
|
@@ -819,6 +978,13 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
819
978
|
returnDocuments?: true
|
|
820
979
|
}
|
|
821
980
|
|
|
981
|
+
/** @beta */
|
|
982
|
+
export declare interface GroqInstructionParam {
|
|
983
|
+
type: 'groq'
|
|
984
|
+
query: string
|
|
985
|
+
params?: Record<string, string>
|
|
986
|
+
}
|
|
987
|
+
|
|
822
988
|
/** @public */
|
|
823
989
|
export declare type HttpRequest = {
|
|
824
990
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -879,6 +1045,16 @@ export declare type InsertPatch =
|
|
|
879
1045
|
items: Any[]
|
|
880
1046
|
}
|
|
881
1047
|
|
|
1048
|
+
/** @beta */
|
|
1049
|
+
export declare type InstructionParam =
|
|
1050
|
+
| string
|
|
1051
|
+
| ConstantInstructionParam
|
|
1052
|
+
| FieldInstructionParam
|
|
1053
|
+
| GroqInstructionParam
|
|
1054
|
+
|
|
1055
|
+
/** @beta */
|
|
1056
|
+
export declare type InstructionParams = Record<string, InstructionParam>
|
|
1057
|
+
|
|
882
1058
|
/**
|
|
883
1059
|
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
884
1060
|
*
|
|
@@ -1288,6 +1464,18 @@ export declare class ObservableAssetsClient {
|
|
|
1288
1464
|
>
|
|
1289
1465
|
}
|
|
1290
1466
|
|
|
1467
|
+
/** @public */
|
|
1468
|
+
declare class ObservableAssistClient {
|
|
1469
|
+
#private
|
|
1470
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1471
|
+
instruct(request: AssistAsyncInstruction): Observable<{
|
|
1472
|
+
_id: string
|
|
1473
|
+
}>
|
|
1474
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
1475
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
1476
|
+
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1291
1479
|
/** @internal */
|
|
1292
1480
|
export declare class ObservableDatasetsClient {
|
|
1293
1481
|
#private
|
|
@@ -1411,6 +1599,7 @@ export declare class ObservableSanityClient {
|
|
|
1411
1599
|
live: LiveClient
|
|
1412
1600
|
projects: ObservableProjectsClient
|
|
1413
1601
|
users: ObservableUsersClient
|
|
1602
|
+
assist: ObservableAssistClient
|
|
1414
1603
|
/**
|
|
1415
1604
|
* Instance properties
|
|
1416
1605
|
*/
|
|
@@ -2330,6 +2519,7 @@ export declare class SanityClient {
|
|
|
2330
2519
|
live: LiveClient
|
|
2331
2520
|
projects: ProjectsClient
|
|
2332
2521
|
users: UsersClient
|
|
2522
|
+
assist: AssistClient
|
|
2333
2523
|
/**
|
|
2334
2524
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2335
2525
|
*/
|
|
@@ -2868,6 +3058,13 @@ export declare type SanityDocumentStub<T extends Record<string, Any> = Record<st
|
|
|
2868
3058
|
_type: string
|
|
2869
3059
|
}
|
|
2870
3060
|
|
|
3061
|
+
/** @public */
|
|
3062
|
+
declare type SanityDocumentStub_2<T extends Record<string, Any_2> = Record<string, Any_2>> = {
|
|
3063
|
+
[P in keyof T]: T[P]
|
|
3064
|
+
} & {
|
|
3065
|
+
_type: string
|
|
3066
|
+
}
|
|
3067
|
+
|
|
2871
3068
|
/** @internal */
|
|
2872
3069
|
export declare interface SanityImageAssetDocument extends SanityAssetDocument {
|
|
2873
3070
|
metadata: {
|
|
@@ -3044,6 +3241,29 @@ export {StudioBaseUrl}
|
|
|
3044
3241
|
|
|
3045
3242
|
export {StudioUrl}
|
|
3046
3243
|
|
|
3244
|
+
declare interface Sync {
|
|
3245
|
+
/**
|
|
3246
|
+
* By default, skipWrite: false.
|
|
3247
|
+
* Write enabled operations will mutate the target document, and emit AI presence in the studio.
|
|
3248
|
+
*
|
|
3249
|
+
* When skipWrite: true, the api will not mutate any documents nor emit presence.
|
|
3250
|
+
* Ie, when true, no changes will be made to content-lake
|
|
3251
|
+
*
|
|
3252
|
+
* skipWrite: true is incompatible with async: true,
|
|
3253
|
+
* as skipWrite implies that you will use the return value of the operation
|
|
3254
|
+
*/
|
|
3255
|
+
skipWrite?: boolean
|
|
3256
|
+
/**
|
|
3257
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
3258
|
+
* The instruction operation will carry on in the background.
|
|
3259
|
+
*
|
|
3260
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
3261
|
+
*
|
|
3262
|
+
* async: true is incompatible with skipWrite: true, as async: true does not return the resulting document
|
|
3263
|
+
*/
|
|
3264
|
+
async?: false
|
|
3265
|
+
}
|
|
3266
|
+
|
|
3047
3267
|
/** @public */
|
|
3048
3268
|
export declare type SyncTag = `s1:${string}`
|
|
3049
3269
|
|