@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/stega.browser.d.cts
CHANGED
|
@@ -110,6 +110,129 @@ export declare class AssetsClient {
|
|
|
110
110
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/** @beta */
|
|
114
|
+
export declare type AssistAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
115
|
+
| ExistingDocumentRequest
|
|
116
|
+
| CreateDocumentRequest<T>
|
|
117
|
+
) &
|
|
118
|
+
AssistRequestBase &
|
|
119
|
+
Async
|
|
120
|
+
|
|
121
|
+
/** @public */
|
|
122
|
+
declare class AssistClient {
|
|
123
|
+
#private
|
|
124
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
125
|
+
instruct(request: AssistAsyncInstruction): Promise<{
|
|
126
|
+
_id: string
|
|
127
|
+
}>
|
|
128
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
129
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
130
|
+
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** @beta */
|
|
134
|
+
export declare type AssistInstruction<T extends Record<string, Any> = Record<string, Any>> =
|
|
135
|
+
| AssistSyncInstruction<T>
|
|
136
|
+
| AssistAsyncInstruction<T>
|
|
137
|
+
|
|
138
|
+
declare interface AssistRequestBase {
|
|
139
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
140
|
+
schemaId: string
|
|
141
|
+
/** string template using $variable – more on this below under "Dynamic instruction" */
|
|
142
|
+
instruction: string
|
|
143
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
144
|
+
instructionParams?: InstructionParams
|
|
145
|
+
/**
|
|
146
|
+
* Optional document path output target for the instruction.
|
|
147
|
+
* When provided, the instruction will apply to this path in the document and its children.
|
|
148
|
+
*
|
|
149
|
+
* ## Examples
|
|
150
|
+
* - `path: 'title'` will output to the title field in the document
|
|
151
|
+
* - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
|
|
152
|
+
*/
|
|
153
|
+
path?: string
|
|
154
|
+
/**
|
|
155
|
+
* Controls sub-paths in the document that can be output to.
|
|
156
|
+
*
|
|
157
|
+
* The string-paths are relative to the `path` param
|
|
158
|
+
*
|
|
159
|
+
* Note: these path strings are less strictly validated than the `path` param itself:
|
|
160
|
+
* if an relative-path does not exist or is invalid, it will be silently ignored.
|
|
161
|
+
*
|
|
162
|
+
* @see AssistRequestBase#conditionalPaths
|
|
163
|
+
* @see AssistRequestBase#outputTypes
|
|
164
|
+
*/
|
|
165
|
+
relativeOutputPaths?:
|
|
166
|
+
| {
|
|
167
|
+
include: string[]
|
|
168
|
+
}
|
|
169
|
+
| {
|
|
170
|
+
exclude: string[]
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Controls which types the instruction is allowed to output to.
|
|
174
|
+
*
|
|
175
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
176
|
+
* @see AssistRequestBase#conditionalPaths
|
|
177
|
+
*/
|
|
178
|
+
outputTypes?:
|
|
179
|
+
| {
|
|
180
|
+
include: string[]
|
|
181
|
+
}
|
|
182
|
+
| {
|
|
183
|
+
exclude: string[]
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
|
|
187
|
+
*
|
|
188
|
+
* By default, AI Assist will not output to conditional `readOnly` and `hidden` fields,
|
|
189
|
+
* ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
|
|
190
|
+
*
|
|
191
|
+
* `conditionalPaths` param allows setting the default conditional value for
|
|
192
|
+
* `hidden` and `readOnly` to false,
|
|
193
|
+
* or individually set `hidden` and `readOnly` state for individual document paths.
|
|
194
|
+
*
|
|
195
|
+
*
|
|
196
|
+
* Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Assist,
|
|
197
|
+
* and cannot be changed via conditionalPaths.
|
|
198
|
+
*
|
|
199
|
+
* conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
|
|
200
|
+
*
|
|
201
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
202
|
+
* @see AssistRequestBase#outputTypes
|
|
203
|
+
*/
|
|
204
|
+
conditionalPaths?: {
|
|
205
|
+
defaultReadOnly?: boolean
|
|
206
|
+
defaultHidden?: boolean
|
|
207
|
+
paths?: {
|
|
208
|
+
/** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
|
|
209
|
+
path: string
|
|
210
|
+
readOnly: boolean
|
|
211
|
+
hidden: boolean
|
|
212
|
+
}[]
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** @beta */
|
|
217
|
+
export declare type AssistSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
218
|
+
| ExistingDocumentRequest
|
|
219
|
+
| CreateDocumentRequest<T>
|
|
220
|
+
) &
|
|
221
|
+
AssistRequestBase &
|
|
222
|
+
Sync
|
|
223
|
+
|
|
224
|
+
declare interface Async {
|
|
225
|
+
/**
|
|
226
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
227
|
+
* The instruction operation will carry on in the background.
|
|
228
|
+
*
|
|
229
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
230
|
+
*
|
|
231
|
+
* async: true is incompatible with skipWrite, as async: true does not return the resulting document
|
|
232
|
+
*/
|
|
233
|
+
async: true
|
|
234
|
+
}
|
|
235
|
+
|
|
113
236
|
/** @internal */
|
|
114
237
|
export declare type AttributeSet = {
|
|
115
238
|
[key: string]: Any
|
|
@@ -395,7 +518,7 @@ export declare class ClientError extends Error {
|
|
|
395
518
|
|
|
396
519
|
/** @public */
|
|
397
520
|
export declare type ClientPerspective =
|
|
398
|
-
|
|
|
521
|
+
| DeprecatedPreviewDrafts
|
|
399
522
|
| 'published'
|
|
400
523
|
| 'drafts'
|
|
401
524
|
| 'raw'
|
|
@@ -446,6 +569,12 @@ export declare class ConnectionFailedError extends Error {
|
|
|
446
569
|
readonly name = 'ConnectionFailedError'
|
|
447
570
|
}
|
|
448
571
|
|
|
572
|
+
/** @beta */
|
|
573
|
+
export declare interface ConstantInstructionParam {
|
|
574
|
+
type: 'constant'
|
|
575
|
+
value: string
|
|
576
|
+
}
|
|
577
|
+
|
|
449
578
|
/** @public */
|
|
450
579
|
export declare interface ContentSourceMap {
|
|
451
580
|
mappings: ContentSourceMapMappings
|
|
@@ -664,6 +793,18 @@ export declare type CreateAction = {
|
|
|
664
793
|
*/
|
|
665
794
|
export declare const createClient: (config: ClientConfig_2) => SanityClient
|
|
666
795
|
|
|
796
|
+
/**
|
|
797
|
+
* Instruction to create a new document
|
|
798
|
+
* @beta
|
|
799
|
+
*/
|
|
800
|
+
declare interface CreateDocumentRequest<T extends Record<string, Any> = Record<string, Any>> {
|
|
801
|
+
createDocument: {
|
|
802
|
+
/** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
|
|
803
|
+
_id?: string
|
|
804
|
+
_type: string
|
|
805
|
+
} & SanityDocumentStub<T>
|
|
806
|
+
}
|
|
807
|
+
|
|
667
808
|
/** @internal */
|
|
668
809
|
export declare interface CurrentSanityUser {
|
|
669
810
|
id: string
|
|
@@ -759,6 +900,11 @@ export declare type DeleteAction = {
|
|
|
759
900
|
purge?: boolean
|
|
760
901
|
}
|
|
761
902
|
|
|
903
|
+
/**
|
|
904
|
+
* @deprecated use 'drafts' instead
|
|
905
|
+
*/
|
|
906
|
+
declare type DeprecatedPreviewDrafts = 'previewDrafts'
|
|
907
|
+
|
|
762
908
|
/**
|
|
763
909
|
* Delete the draft version of a document.
|
|
764
910
|
* It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
|
|
@@ -864,6 +1010,20 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
864
1010
|
*/
|
|
865
1011
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
866
1012
|
|
|
1013
|
+
/**
|
|
1014
|
+
* Instruction for an existing document.
|
|
1015
|
+
* @beta
|
|
1016
|
+
*/
|
|
1017
|
+
declare interface ExistingDocumentRequest {
|
|
1018
|
+
documentId: string
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
/** @beta */
|
|
1022
|
+
export declare interface FieldInstructionParam {
|
|
1023
|
+
type: 'field'
|
|
1024
|
+
path: string
|
|
1025
|
+
}
|
|
1026
|
+
|
|
867
1027
|
/** @public */
|
|
868
1028
|
export declare type FilterDefault = (props: {
|
|
869
1029
|
/**
|
|
@@ -979,6 +1139,13 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
979
1139
|
returnDocuments?: true
|
|
980
1140
|
}
|
|
981
1141
|
|
|
1142
|
+
/** @beta */
|
|
1143
|
+
export declare interface GroqInstructionParam {
|
|
1144
|
+
type: 'groq'
|
|
1145
|
+
query: string
|
|
1146
|
+
params?: Record<string, string>
|
|
1147
|
+
}
|
|
1148
|
+
|
|
982
1149
|
/** @public */
|
|
983
1150
|
export declare type HttpRequest = {
|
|
984
1151
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -1049,6 +1216,16 @@ export declare type InsertPatch =
|
|
|
1049
1216
|
items: Any[]
|
|
1050
1217
|
}
|
|
1051
1218
|
|
|
1219
|
+
/** @beta */
|
|
1220
|
+
export declare type InstructionParam =
|
|
1221
|
+
| string
|
|
1222
|
+
| ConstantInstructionParam
|
|
1223
|
+
| FieldInstructionParam
|
|
1224
|
+
| GroqInstructionParam
|
|
1225
|
+
|
|
1226
|
+
/** @beta */
|
|
1227
|
+
export declare type InstructionParams = Record<string, InstructionParam>
|
|
1228
|
+
|
|
1052
1229
|
/**
|
|
1053
1230
|
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
1054
1231
|
*
|
|
@@ -1465,6 +1642,18 @@ export declare class ObservableAssetsClient {
|
|
|
1465
1642
|
>
|
|
1466
1643
|
}
|
|
1467
1644
|
|
|
1645
|
+
/** @public */
|
|
1646
|
+
declare class ObservableAssistClient {
|
|
1647
|
+
#private
|
|
1648
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1649
|
+
instruct(request: AssistAsyncInstruction): Observable<{
|
|
1650
|
+
_id: string
|
|
1651
|
+
}>
|
|
1652
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
1653
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
1654
|
+
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1468
1657
|
/** @internal */
|
|
1469
1658
|
export declare class ObservableDatasetsClient {
|
|
1470
1659
|
#private
|
|
@@ -1588,6 +1777,7 @@ export declare class ObservableSanityClient {
|
|
|
1588
1777
|
live: LiveClient
|
|
1589
1778
|
projects: ObservableProjectsClient
|
|
1590
1779
|
users: ObservableUsersClient
|
|
1780
|
+
assist: ObservableAssistClient
|
|
1591
1781
|
/**
|
|
1592
1782
|
* Instance properties
|
|
1593
1783
|
*/
|
|
@@ -2519,6 +2709,7 @@ export declare class SanityClient {
|
|
|
2519
2709
|
live: LiveClient
|
|
2520
2710
|
projects: ProjectsClient
|
|
2521
2711
|
users: UsersClient
|
|
2712
|
+
assist: AssistClient
|
|
2522
2713
|
/**
|
|
2523
2714
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2524
2715
|
*/
|
|
@@ -3302,6 +3493,29 @@ export declare type StudioBaseUrl =
|
|
|
3302
3493
|
/** @alpha */
|
|
3303
3494
|
export declare type StudioUrl = StudioBaseUrl | StudioBaseRoute
|
|
3304
3495
|
|
|
3496
|
+
declare interface Sync {
|
|
3497
|
+
/**
|
|
3498
|
+
* By default, skipWrite: false.
|
|
3499
|
+
* Write enabled operations will mutate the target document, and emit AI presence in the studio.
|
|
3500
|
+
*
|
|
3501
|
+
* When skipWrite: true, the api will not mutate any documents nor emit presence.
|
|
3502
|
+
* Ie, when true, no changes will be made to content-lake
|
|
3503
|
+
*
|
|
3504
|
+
* skipWrite: true is incompatible with async: true,
|
|
3505
|
+
* as skipWrite implies that you will use the return value of the operation
|
|
3506
|
+
*/
|
|
3507
|
+
skipWrite?: boolean
|
|
3508
|
+
/**
|
|
3509
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
3510
|
+
* The instruction operation will carry on in the background.
|
|
3511
|
+
*
|
|
3512
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
3513
|
+
*
|
|
3514
|
+
* async: true is incompatible with skipWrite: true, as async: true does not return the resulting document
|
|
3515
|
+
*/
|
|
3516
|
+
async?: false
|
|
3517
|
+
}
|
|
3518
|
+
|
|
3305
3519
|
/** @public */
|
|
3306
3520
|
export declare type SyncTag = `s1:${string}`
|
|
3307
3521
|
|
package/dist/stega.browser.d.ts
CHANGED
|
@@ -110,6 +110,129 @@ export declare class AssetsClient {
|
|
|
110
110
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/** @beta */
|
|
114
|
+
export declare type AssistAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
115
|
+
| ExistingDocumentRequest
|
|
116
|
+
| CreateDocumentRequest<T>
|
|
117
|
+
) &
|
|
118
|
+
AssistRequestBase &
|
|
119
|
+
Async
|
|
120
|
+
|
|
121
|
+
/** @public */
|
|
122
|
+
declare class AssistClient {
|
|
123
|
+
#private
|
|
124
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
125
|
+
instruct(request: AssistAsyncInstruction): Promise<{
|
|
126
|
+
_id: string
|
|
127
|
+
}>
|
|
128
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
129
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
130
|
+
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** @beta */
|
|
134
|
+
export declare type AssistInstruction<T extends Record<string, Any> = Record<string, Any>> =
|
|
135
|
+
| AssistSyncInstruction<T>
|
|
136
|
+
| AssistAsyncInstruction<T>
|
|
137
|
+
|
|
138
|
+
declare interface AssistRequestBase {
|
|
139
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
140
|
+
schemaId: string
|
|
141
|
+
/** string template using $variable – more on this below under "Dynamic instruction" */
|
|
142
|
+
instruction: string
|
|
143
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
144
|
+
instructionParams?: InstructionParams
|
|
145
|
+
/**
|
|
146
|
+
* Optional document path output target for the instruction.
|
|
147
|
+
* When provided, the instruction will apply to this path in the document and its children.
|
|
148
|
+
*
|
|
149
|
+
* ## Examples
|
|
150
|
+
* - `path: 'title'` will output to the title field in the document
|
|
151
|
+
* - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
|
|
152
|
+
*/
|
|
153
|
+
path?: string
|
|
154
|
+
/**
|
|
155
|
+
* Controls sub-paths in the document that can be output to.
|
|
156
|
+
*
|
|
157
|
+
* The string-paths are relative to the `path` param
|
|
158
|
+
*
|
|
159
|
+
* Note: these path strings are less strictly validated than the `path` param itself:
|
|
160
|
+
* if an relative-path does not exist or is invalid, it will be silently ignored.
|
|
161
|
+
*
|
|
162
|
+
* @see AssistRequestBase#conditionalPaths
|
|
163
|
+
* @see AssistRequestBase#outputTypes
|
|
164
|
+
*/
|
|
165
|
+
relativeOutputPaths?:
|
|
166
|
+
| {
|
|
167
|
+
include: string[]
|
|
168
|
+
}
|
|
169
|
+
| {
|
|
170
|
+
exclude: string[]
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Controls which types the instruction is allowed to output to.
|
|
174
|
+
*
|
|
175
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
176
|
+
* @see AssistRequestBase#conditionalPaths
|
|
177
|
+
*/
|
|
178
|
+
outputTypes?:
|
|
179
|
+
| {
|
|
180
|
+
include: string[]
|
|
181
|
+
}
|
|
182
|
+
| {
|
|
183
|
+
exclude: string[]
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
|
|
187
|
+
*
|
|
188
|
+
* By default, AI Assist will not output to conditional `readOnly` and `hidden` fields,
|
|
189
|
+
* ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
|
|
190
|
+
*
|
|
191
|
+
* `conditionalPaths` param allows setting the default conditional value for
|
|
192
|
+
* `hidden` and `readOnly` to false,
|
|
193
|
+
* or individually set `hidden` and `readOnly` state for individual document paths.
|
|
194
|
+
*
|
|
195
|
+
*
|
|
196
|
+
* Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Assist,
|
|
197
|
+
* and cannot be changed via conditionalPaths.
|
|
198
|
+
*
|
|
199
|
+
* conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
|
|
200
|
+
*
|
|
201
|
+
* @see AssistRequestBase#relativeOutputPaths
|
|
202
|
+
* @see AssistRequestBase#outputTypes
|
|
203
|
+
*/
|
|
204
|
+
conditionalPaths?: {
|
|
205
|
+
defaultReadOnly?: boolean
|
|
206
|
+
defaultHidden?: boolean
|
|
207
|
+
paths?: {
|
|
208
|
+
/** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
|
|
209
|
+
path: string
|
|
210
|
+
readOnly: boolean
|
|
211
|
+
hidden: boolean
|
|
212
|
+
}[]
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** @beta */
|
|
217
|
+
export declare type AssistSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
218
|
+
| ExistingDocumentRequest
|
|
219
|
+
| CreateDocumentRequest<T>
|
|
220
|
+
) &
|
|
221
|
+
AssistRequestBase &
|
|
222
|
+
Sync
|
|
223
|
+
|
|
224
|
+
declare interface Async {
|
|
225
|
+
/**
|
|
226
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
227
|
+
* The instruction operation will carry on in the background.
|
|
228
|
+
*
|
|
229
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
230
|
+
*
|
|
231
|
+
* async: true is incompatible with skipWrite, as async: true does not return the resulting document
|
|
232
|
+
*/
|
|
233
|
+
async: true
|
|
234
|
+
}
|
|
235
|
+
|
|
113
236
|
/** @internal */
|
|
114
237
|
export declare type AttributeSet = {
|
|
115
238
|
[key: string]: Any
|
|
@@ -395,7 +518,7 @@ export declare class ClientError extends Error {
|
|
|
395
518
|
|
|
396
519
|
/** @public */
|
|
397
520
|
export declare type ClientPerspective =
|
|
398
|
-
|
|
|
521
|
+
| DeprecatedPreviewDrafts
|
|
399
522
|
| 'published'
|
|
400
523
|
| 'drafts'
|
|
401
524
|
| 'raw'
|
|
@@ -446,6 +569,12 @@ export declare class ConnectionFailedError extends Error {
|
|
|
446
569
|
readonly name = 'ConnectionFailedError'
|
|
447
570
|
}
|
|
448
571
|
|
|
572
|
+
/** @beta */
|
|
573
|
+
export declare interface ConstantInstructionParam {
|
|
574
|
+
type: 'constant'
|
|
575
|
+
value: string
|
|
576
|
+
}
|
|
577
|
+
|
|
449
578
|
/** @public */
|
|
450
579
|
export declare interface ContentSourceMap {
|
|
451
580
|
mappings: ContentSourceMapMappings
|
|
@@ -664,6 +793,18 @@ export declare type CreateAction = {
|
|
|
664
793
|
*/
|
|
665
794
|
export declare const createClient: (config: ClientConfig_2) => SanityClient
|
|
666
795
|
|
|
796
|
+
/**
|
|
797
|
+
* Instruction to create a new document
|
|
798
|
+
* @beta
|
|
799
|
+
*/
|
|
800
|
+
declare interface CreateDocumentRequest<T extends Record<string, Any> = Record<string, Any>> {
|
|
801
|
+
createDocument: {
|
|
802
|
+
/** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
|
|
803
|
+
_id?: string
|
|
804
|
+
_type: string
|
|
805
|
+
} & SanityDocumentStub<T>
|
|
806
|
+
}
|
|
807
|
+
|
|
667
808
|
/** @internal */
|
|
668
809
|
export declare interface CurrentSanityUser {
|
|
669
810
|
id: string
|
|
@@ -759,6 +900,11 @@ export declare type DeleteAction = {
|
|
|
759
900
|
purge?: boolean
|
|
760
901
|
}
|
|
761
902
|
|
|
903
|
+
/**
|
|
904
|
+
* @deprecated use 'drafts' instead
|
|
905
|
+
*/
|
|
906
|
+
declare type DeprecatedPreviewDrafts = 'previewDrafts'
|
|
907
|
+
|
|
762
908
|
/**
|
|
763
909
|
* Delete the draft version of a document.
|
|
764
910
|
* It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
|
|
@@ -864,6 +1010,20 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
864
1010
|
*/
|
|
865
1011
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
866
1012
|
|
|
1013
|
+
/**
|
|
1014
|
+
* Instruction for an existing document.
|
|
1015
|
+
* @beta
|
|
1016
|
+
*/
|
|
1017
|
+
declare interface ExistingDocumentRequest {
|
|
1018
|
+
documentId: string
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
/** @beta */
|
|
1022
|
+
export declare interface FieldInstructionParam {
|
|
1023
|
+
type: 'field'
|
|
1024
|
+
path: string
|
|
1025
|
+
}
|
|
1026
|
+
|
|
867
1027
|
/** @public */
|
|
868
1028
|
export declare type FilterDefault = (props: {
|
|
869
1029
|
/**
|
|
@@ -979,6 +1139,13 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
979
1139
|
returnDocuments?: true
|
|
980
1140
|
}
|
|
981
1141
|
|
|
1142
|
+
/** @beta */
|
|
1143
|
+
export declare interface GroqInstructionParam {
|
|
1144
|
+
type: 'groq'
|
|
1145
|
+
query: string
|
|
1146
|
+
params?: Record<string, string>
|
|
1147
|
+
}
|
|
1148
|
+
|
|
982
1149
|
/** @public */
|
|
983
1150
|
export declare type HttpRequest = {
|
|
984
1151
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -1049,6 +1216,16 @@ export declare type InsertPatch =
|
|
|
1049
1216
|
items: Any[]
|
|
1050
1217
|
}
|
|
1051
1218
|
|
|
1219
|
+
/** @beta */
|
|
1220
|
+
export declare type InstructionParam =
|
|
1221
|
+
| string
|
|
1222
|
+
| ConstantInstructionParam
|
|
1223
|
+
| FieldInstructionParam
|
|
1224
|
+
| GroqInstructionParam
|
|
1225
|
+
|
|
1226
|
+
/** @beta */
|
|
1227
|
+
export declare type InstructionParams = Record<string, InstructionParam>
|
|
1228
|
+
|
|
1052
1229
|
/**
|
|
1053
1230
|
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
1054
1231
|
*
|
|
@@ -1465,6 +1642,18 @@ export declare class ObservableAssetsClient {
|
|
|
1465
1642
|
>
|
|
1466
1643
|
}
|
|
1467
1644
|
|
|
1645
|
+
/** @public */
|
|
1646
|
+
declare class ObservableAssistClient {
|
|
1647
|
+
#private
|
|
1648
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1649
|
+
instruct(request: AssistAsyncInstruction): Observable<{
|
|
1650
|
+
_id: string
|
|
1651
|
+
}>
|
|
1652
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
1653
|
+
request: AssistSyncInstruction<DocumentShape>,
|
|
1654
|
+
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1468
1657
|
/** @internal */
|
|
1469
1658
|
export declare class ObservableDatasetsClient {
|
|
1470
1659
|
#private
|
|
@@ -1588,6 +1777,7 @@ export declare class ObservableSanityClient {
|
|
|
1588
1777
|
live: LiveClient
|
|
1589
1778
|
projects: ObservableProjectsClient
|
|
1590
1779
|
users: ObservableUsersClient
|
|
1780
|
+
assist: ObservableAssistClient
|
|
1591
1781
|
/**
|
|
1592
1782
|
* Instance properties
|
|
1593
1783
|
*/
|
|
@@ -2519,6 +2709,7 @@ export declare class SanityClient {
|
|
|
2519
2709
|
live: LiveClient
|
|
2520
2710
|
projects: ProjectsClient
|
|
2521
2711
|
users: UsersClient
|
|
2712
|
+
assist: AssistClient
|
|
2522
2713
|
/**
|
|
2523
2714
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2524
2715
|
*/
|
|
@@ -3302,6 +3493,29 @@ export declare type StudioBaseUrl =
|
|
|
3302
3493
|
/** @alpha */
|
|
3303
3494
|
export declare type StudioUrl = StudioBaseUrl | StudioBaseRoute
|
|
3304
3495
|
|
|
3496
|
+
declare interface Sync {
|
|
3497
|
+
/**
|
|
3498
|
+
* By default, skipWrite: false.
|
|
3499
|
+
* Write enabled operations will mutate the target document, and emit AI presence in the studio.
|
|
3500
|
+
*
|
|
3501
|
+
* When skipWrite: true, the api will not mutate any documents nor emit presence.
|
|
3502
|
+
* Ie, when true, no changes will be made to content-lake
|
|
3503
|
+
*
|
|
3504
|
+
* skipWrite: true is incompatible with async: true,
|
|
3505
|
+
* as skipWrite implies that you will use the return value of the operation
|
|
3506
|
+
*/
|
|
3507
|
+
skipWrite?: boolean
|
|
3508
|
+
/**
|
|
3509
|
+
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
3510
|
+
* The instruction operation will carry on in the background.
|
|
3511
|
+
*
|
|
3512
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
3513
|
+
*
|
|
3514
|
+
* async: true is incompatible with skipWrite: true, as async: true does not return the resulting document
|
|
3515
|
+
*/
|
|
3516
|
+
async?: false
|
|
3517
|
+
}
|
|
3518
|
+
|
|
3305
3519
|
/** @public */
|
|
3306
3520
|
export declare type SyncTag = `s1:${string}`
|
|
3307
3521
|
|
package/dist/stega.browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { requester as requester$1, createClient as createClient$1, SanityClient, ObservableSanityClient } from "@sanity/client";
|
|
2
2
|
export * from "@sanity/client";
|
|
3
3
|
import { encodeIntoResult, stegaEncodeSourceMap } from "./_chunks-es/stegaEncodeSourceMap.js";
|
|
4
4
|
import { stegaClean, vercelStegaCleanAll } from "./_chunks-es/stegaClean.js";
|