@sanity/client 6.28.3-instruct.0 → 6.28.3-instruct.1
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/_chunks-cjs/config.cjs +6 -13
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-es/config.js +6 -13
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/index.browser.cjs +48 -55
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +157 -153
- package/dist/index.browser.d.ts +157 -153
- package/dist/index.browser.js +48 -55
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +43 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +157 -153
- package/dist/index.d.ts +157 -153
- package/dist/index.js +43 -43
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +159 -160
- package/dist/stega.browser.d.ts +159 -160
- package/dist/stega.d.cts +159 -160
- package/dist/stega.d.ts +159 -160
- package/package.json +20 -20
- package/src/SanityClient.ts +5 -5
- package/src/{assist/AssistClient.ts → ai/AiClient.ts} +18 -12
- package/src/{assist → ai}/types.ts +30 -27
- package/src/config.ts +9 -18
- package/src/data/listen.ts +1 -1
- package/src/http/requestOptions.ts +1 -1
- package/src/types.ts +9 -9
- package/src/warnings.ts +5 -0
- package/umd/sanityClient.js +55 -60
- package/umd/sanityClient.min.js +2 -2
package/dist/stega.d.ts
CHANGED
|
@@ -33,6 +33,18 @@ export declare interface ActionErrorItem {
|
|
|
33
33
|
index: number
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/** @public */
|
|
37
|
+
declare class AiClient {
|
|
38
|
+
#private
|
|
39
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
40
|
+
instruct(request: InstructAsyncInstruction): Promise<{
|
|
41
|
+
_id: string
|
|
42
|
+
}>
|
|
43
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
44
|
+
request: InstructSyncInstruction<DocumentShape>,
|
|
45
|
+
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
46
|
+
}
|
|
47
|
+
|
|
36
48
|
/** @internal */
|
|
37
49
|
export declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
|
|
38
50
|
returnFirst: false
|
|
@@ -110,117 +122,6 @@ export declare class AssetsClient {
|
|
|
110
122
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
111
123
|
}
|
|
112
124
|
|
|
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
125
|
declare interface Async {
|
|
225
126
|
/**
|
|
226
127
|
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
@@ -578,12 +479,6 @@ export declare class ConnectionFailedError extends Error {
|
|
|
578
479
|
readonly name = 'ConnectionFailedError'
|
|
579
480
|
}
|
|
580
481
|
|
|
581
|
-
/** @beta */
|
|
582
|
-
export declare interface ConstantInstructionParam {
|
|
583
|
-
type: 'constant'
|
|
584
|
-
value: string
|
|
585
|
-
}
|
|
586
|
-
|
|
587
482
|
/** @public */
|
|
588
483
|
export declare interface ContentSourceMap {
|
|
589
484
|
mappings: ContentSourceMapMappings
|
|
@@ -1040,23 +935,6 @@ declare interface ExistingDocumentRequest {
|
|
|
1040
935
|
documentId: string
|
|
1041
936
|
}
|
|
1042
937
|
|
|
1043
|
-
/**
|
|
1044
|
-
*
|
|
1045
|
-
* Includes a LLM-friendly version of the field value in the instruction
|
|
1046
|
-
* @beta
|
|
1047
|
-
* */
|
|
1048
|
-
export declare interface FieldInstructionParam {
|
|
1049
|
-
type: 'field'
|
|
1050
|
-
/**
|
|
1051
|
-
* Examples: 'title', 'array[_key=="key"].field
|
|
1052
|
-
*/
|
|
1053
|
-
path: string
|
|
1054
|
-
/**
|
|
1055
|
-
* If omitted, implicitly uses the documentId of the instruction target
|
|
1056
|
-
*/
|
|
1057
|
-
documentId?: string
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
938
|
/** @public */
|
|
1061
939
|
export declare type FilterDefault = (props: {
|
|
1062
940
|
/**
|
|
@@ -1172,13 +1050,6 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
1172
1050
|
returnDocuments?: true
|
|
1173
1051
|
}
|
|
1174
1052
|
|
|
1175
|
-
/** @beta */
|
|
1176
|
-
export declare interface GroqInstructionParam {
|
|
1177
|
-
type: 'groq'
|
|
1178
|
-
query: string
|
|
1179
|
-
params?: Record<string, string>
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
1053
|
/** @public */
|
|
1183
1054
|
export declare type HttpRequest = {
|
|
1184
1055
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -1250,15 +1121,143 @@ export declare type InsertPatch =
|
|
|
1250
1121
|
}
|
|
1251
1122
|
|
|
1252
1123
|
/** @beta */
|
|
1253
|
-
export declare type
|
|
1124
|
+
export declare type InstructAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> =
|
|
1125
|
+
(ExistingDocumentRequest | CreateDocumentRequest<T>) & InstructRequestBase & Async
|
|
1126
|
+
|
|
1127
|
+
/** @beta */
|
|
1128
|
+
export declare interface InstructConstantInstructionParam {
|
|
1129
|
+
type: 'constant'
|
|
1130
|
+
value: string
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
*
|
|
1135
|
+
* Includes a LLM-friendly version of the field value in the instruction
|
|
1136
|
+
* @beta
|
|
1137
|
+
* */
|
|
1138
|
+
export declare interface InstructFieldInstructionParam {
|
|
1139
|
+
type: 'field'
|
|
1140
|
+
/**
|
|
1141
|
+
* Examples: 'title', 'array[_key=="key"].field'
|
|
1142
|
+
*/
|
|
1143
|
+
path: string
|
|
1144
|
+
/**
|
|
1145
|
+
* If omitted, implicitly uses the documentId of the instruction target
|
|
1146
|
+
*/
|
|
1147
|
+
documentId?: string
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* Includes a LLM-friendly version of GROQ query result in the instruction
|
|
1152
|
+
* @beta
|
|
1153
|
+
* */
|
|
1154
|
+
export declare interface InstructGroqInstructionParam {
|
|
1155
|
+
type: 'groq'
|
|
1156
|
+
query: string
|
|
1157
|
+
params?: Record<string, string>
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
/** @beta */
|
|
1161
|
+
export declare type InstructInstruction<T extends Record<string, Any> = Record<string, Any>> =
|
|
1162
|
+
| InstructSyncInstruction<T>
|
|
1163
|
+
| InstructAsyncInstruction<T>
|
|
1164
|
+
|
|
1165
|
+
/** @beta */
|
|
1166
|
+
export declare type InstructInstructionParam =
|
|
1254
1167
|
| string
|
|
1255
|
-
|
|
|
1256
|
-
|
|
|
1168
|
+
| InstructConstantInstructionParam
|
|
1169
|
+
| InstructFieldInstructionParam
|
|
1257
1170
|
| DocumentInstructionParam
|
|
1258
|
-
|
|
|
1171
|
+
| InstructGroqInstructionParam
|
|
1172
|
+
|
|
1173
|
+
/** @beta */
|
|
1174
|
+
export declare type InstructInstructionParams = Record<string, InstructInstructionParam>
|
|
1175
|
+
|
|
1176
|
+
declare interface InstructRequestBase {
|
|
1177
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
1178
|
+
schemaId: string
|
|
1179
|
+
/** string template using $variable – more on this below under "Dynamic instruction" */
|
|
1180
|
+
instruction: string
|
|
1181
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
1182
|
+
instructionParams?: InstructInstructionParams
|
|
1183
|
+
/**
|
|
1184
|
+
* Optional document path output target for the instruction.
|
|
1185
|
+
* When provided, the instruction will apply to this path in the document and its children.
|
|
1186
|
+
*
|
|
1187
|
+
* ## Examples
|
|
1188
|
+
* - `path: 'title'` will output to the title field in the document
|
|
1189
|
+
* - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
|
|
1190
|
+
*/
|
|
1191
|
+
path?: string
|
|
1192
|
+
/**
|
|
1193
|
+
* Controls sub-paths in the document that can be output to.
|
|
1194
|
+
*
|
|
1195
|
+
* The string-paths are relative to the `path` param
|
|
1196
|
+
*
|
|
1197
|
+
* Note: these path strings are less strictly validated than the `path` param itself:
|
|
1198
|
+
* if an relative-path does not exist or is invalid, it will be silently ignored.
|
|
1199
|
+
*
|
|
1200
|
+
* @see InstructRequestBase#conditionalPaths
|
|
1201
|
+
* @see InstructRequestBase#outputTypes
|
|
1202
|
+
*/
|
|
1203
|
+
relativeOutputPaths?:
|
|
1204
|
+
| {
|
|
1205
|
+
include: string[]
|
|
1206
|
+
}
|
|
1207
|
+
| {
|
|
1208
|
+
exclude: string[]
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Controls which types the instruction is allowed to output to.
|
|
1212
|
+
*
|
|
1213
|
+
* @see InstructRequestBase#relativeOutputPaths
|
|
1214
|
+
* @see InstructRequestBase#conditionalPaths
|
|
1215
|
+
*/
|
|
1216
|
+
outputTypes?:
|
|
1217
|
+
| {
|
|
1218
|
+
include: string[]
|
|
1219
|
+
}
|
|
1220
|
+
| {
|
|
1221
|
+
exclude: string[]
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
|
|
1225
|
+
*
|
|
1226
|
+
* By default, AI Instruct will not output to conditional `readOnly` and `hidden` fields,
|
|
1227
|
+
* ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
|
|
1228
|
+
*
|
|
1229
|
+
* `conditionalPaths` param allows setting the default conditional value for
|
|
1230
|
+
* `hidden` and `readOnly` to false,
|
|
1231
|
+
* or individually set `hidden` and `readOnly` state for individual document paths.
|
|
1232
|
+
*
|
|
1233
|
+
*
|
|
1234
|
+
* Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Instruct,
|
|
1235
|
+
* and cannot be changed via conditionalPaths.
|
|
1236
|
+
*
|
|
1237
|
+
* conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
|
|
1238
|
+
*
|
|
1239
|
+
* @see InstructRequestBase#relativeOutputPaths
|
|
1240
|
+
* @see InstructRequestBase#outputTypes
|
|
1241
|
+
*/
|
|
1242
|
+
conditionalPaths?: {
|
|
1243
|
+
defaultReadOnly?: boolean
|
|
1244
|
+
defaultHidden?: boolean
|
|
1245
|
+
paths?: {
|
|
1246
|
+
/** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
|
|
1247
|
+
path: string
|
|
1248
|
+
readOnly: boolean
|
|
1249
|
+
hidden: boolean
|
|
1250
|
+
}[]
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1259
1253
|
|
|
1260
1254
|
/** @beta */
|
|
1261
|
-
export declare type
|
|
1255
|
+
export declare type InstructSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
1256
|
+
| ExistingDocumentRequest
|
|
1257
|
+
| CreateDocumentRequest<T>
|
|
1258
|
+
) &
|
|
1259
|
+
InstructRequestBase &
|
|
1260
|
+
Sync
|
|
1262
1261
|
|
|
1263
1262
|
/**
|
|
1264
1263
|
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
@@ -1627,6 +1626,18 @@ export declare type MutationSelectionQueryParams = {
|
|
|
1627
1626
|
[key: string]: Any
|
|
1628
1627
|
}
|
|
1629
1628
|
|
|
1629
|
+
/** @public */
|
|
1630
|
+
declare class ObservableAiClient {
|
|
1631
|
+
#private
|
|
1632
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1633
|
+
instruct(request: InstructAsyncInstruction): Observable<{
|
|
1634
|
+
_id: string
|
|
1635
|
+
}>
|
|
1636
|
+
instruct<DocumentShape extends Record<string, Any>>(
|
|
1637
|
+
request: InstructSyncInstruction<DocumentShape>,
|
|
1638
|
+
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1630
1641
|
/** @internal */
|
|
1631
1642
|
export declare class ObservableAssetsClient {
|
|
1632
1643
|
#private
|
|
@@ -1681,18 +1692,6 @@ export declare class ObservableAssetsClient {
|
|
|
1681
1692
|
>
|
|
1682
1693
|
}
|
|
1683
1694
|
|
|
1684
|
-
/** @public */
|
|
1685
|
-
declare class ObservableAssistClient {
|
|
1686
|
-
#private
|
|
1687
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1688
|
-
instruct(request: AssistAsyncInstruction): Observable<{
|
|
1689
|
-
_id: string
|
|
1690
|
-
}>
|
|
1691
|
-
instruct<DocumentShape extends Record<string, Any>>(
|
|
1692
|
-
request: AssistSyncInstruction<DocumentShape>,
|
|
1693
|
-
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1696
1695
|
/** @internal */
|
|
1697
1696
|
export declare class ObservableDatasetsClient {
|
|
1698
1697
|
#private
|
|
@@ -1816,7 +1815,7 @@ export declare class ObservableSanityClient {
|
|
|
1816
1815
|
live: LiveClient
|
|
1817
1816
|
projects: ObservableProjectsClient
|
|
1818
1817
|
users: ObservableUsersClient
|
|
1819
|
-
|
|
1818
|
+
ai: ObservableAiClient
|
|
1820
1819
|
/**
|
|
1821
1820
|
* Instance properties
|
|
1822
1821
|
*/
|
|
@@ -2748,7 +2747,7 @@ export declare class SanityClient {
|
|
|
2748
2747
|
live: LiveClient
|
|
2749
2748
|
projects: ProjectsClient
|
|
2750
2749
|
users: UsersClient
|
|
2751
|
-
|
|
2750
|
+
ai: AiClient
|
|
2752
2751
|
/**
|
|
2753
2752
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2754
2753
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "6.28.3-instruct.
|
|
3
|
+
"version": "6.28.3-instruct.1",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -125,39 +125,39 @@
|
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@edge-runtime/types": "^4.0.0",
|
|
127
127
|
"@edge-runtime/vm": "^5.0.0",
|
|
128
|
-
"@eslint/eslintrc": "^3.
|
|
129
|
-
"@eslint/js": "^9.
|
|
130
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
131
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
128
|
+
"@eslint/eslintrc": "^3.3.0",
|
|
129
|
+
"@eslint/js": "^9.22.0",
|
|
130
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
131
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
132
132
|
"@sanity/client-latest": "npm:@sanity/client@latest",
|
|
133
|
-
"@sanity/pkg-utils": "^7.
|
|
133
|
+
"@sanity/pkg-utils": "^7.1.1",
|
|
134
134
|
"@types/json-diff": "^1.0.3",
|
|
135
135
|
"@types/node": "^22.9.0",
|
|
136
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
137
|
-
"@typescript-eslint/parser": "^8.
|
|
136
|
+
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
137
|
+
"@typescript-eslint/parser": "^8.26.1",
|
|
138
138
|
"@vercel/stega": "0.1.2",
|
|
139
|
-
"@vitest/coverage-v8": "3.0.
|
|
140
|
-
"eslint": "^9.
|
|
141
|
-
"eslint-config-prettier": "^10.
|
|
139
|
+
"@vitest/coverage-v8": "3.0.9",
|
|
140
|
+
"eslint": "^9.22.0",
|
|
141
|
+
"eslint-config-prettier": "^10.1.1",
|
|
142
142
|
"eslint-formatter-compact": "^8.40.0",
|
|
143
143
|
"eslint-plugin-prettier": "^5.2.3",
|
|
144
144
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
145
145
|
"faucet": "^0.0.4",
|
|
146
|
-
"globals": "^15.
|
|
146
|
+
"globals": "^15.15.0",
|
|
147
147
|
"happy-dom": "^12.10.3",
|
|
148
148
|
"json-diff": "^1.0.6",
|
|
149
149
|
"ls-engines": "^0.9.3",
|
|
150
|
-
"msw": "^2.7.
|
|
151
|
-
"next": "^15.
|
|
150
|
+
"msw": "^2.7.3",
|
|
151
|
+
"next": "^15.2.3",
|
|
152
152
|
"nock": "^13.5.6",
|
|
153
|
-
"prettier": "^3.5.
|
|
154
|
-
"prettier-plugin-packagejson": "^2.5.
|
|
153
|
+
"prettier": "^3.5.3",
|
|
154
|
+
"prettier-plugin-packagejson": "^2.5.10",
|
|
155
155
|
"rimraf": "^5.0.7",
|
|
156
|
-
"rollup": "^4.
|
|
156
|
+
"rollup": "^4.36.0",
|
|
157
157
|
"sse-channel": "^4.0.0",
|
|
158
|
-
"terser": "^5.
|
|
159
|
-
"typescript": "5.
|
|
160
|
-
"vitest": "3.0.
|
|
158
|
+
"terser": "^5.39.0",
|
|
159
|
+
"typescript": "5.8.2",
|
|
160
|
+
"vitest": "3.0.9"
|
|
161
161
|
},
|
|
162
162
|
"packageManager": "npm@11.0.0",
|
|
163
163
|
"engines": {
|
package/src/SanityClient.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {lastValueFrom, Observable} from 'rxjs'
|
|
2
2
|
|
|
3
|
+
import {AiClient, ObservableAiClient} from './ai/AiClient'
|
|
3
4
|
import {AssetsClient, ObservableAssetsClient} from './assets/AssetsClient'
|
|
4
|
-
import {AssistClient, ObservableAssistClient} from './assist/AssistClient'
|
|
5
5
|
import {defaultConfig, initConfig} from './config'
|
|
6
6
|
import * as dataMethods from './data/dataMethods'
|
|
7
7
|
import {_listen} from './data/listen'
|
|
@@ -66,7 +66,7 @@ export class ObservableSanityClient {
|
|
|
66
66
|
live: LiveClient
|
|
67
67
|
projects: ObservableProjectsClient
|
|
68
68
|
users: ObservableUsersClient
|
|
69
|
-
|
|
69
|
+
ai: ObservableAiClient
|
|
70
70
|
/**
|
|
71
71
|
* Private properties
|
|
72
72
|
*/
|
|
@@ -88,7 +88,7 @@ export class ObservableSanityClient {
|
|
|
88
88
|
this.live = new LiveClient(this)
|
|
89
89
|
this.projects = new ObservableProjectsClient(this, this.#httpRequest)
|
|
90
90
|
this.users = new ObservableUsersClient(this, this.#httpRequest)
|
|
91
|
-
this.
|
|
91
|
+
this.ai = new ObservableAiClient(this, this.#httpRequest)
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -735,7 +735,7 @@ export class SanityClient {
|
|
|
735
735
|
live: LiveClient
|
|
736
736
|
projects: ProjectsClient
|
|
737
737
|
users: UsersClient
|
|
738
|
-
|
|
738
|
+
ai: AiClient
|
|
739
739
|
|
|
740
740
|
/**
|
|
741
741
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
@@ -763,7 +763,7 @@ export class SanityClient {
|
|
|
763
763
|
this.live = new LiveClient(this)
|
|
764
764
|
this.projects = new ProjectsClient(this, this.#httpRequest)
|
|
765
765
|
this.users = new UsersClient(this, this.#httpRequest)
|
|
766
|
-
this.
|
|
766
|
+
this.ai = new AiClient(this, this.#httpRequest)
|
|
767
767
|
|
|
768
768
|
this.observable = new ObservableSanityClient(httpRequest, config)
|
|
769
769
|
}
|
|
@@ -4,17 +4,17 @@ import {_request} from '../data/dataMethods'
|
|
|
4
4
|
import type {ObservableSanityClient, SanityClient} from '../SanityClient'
|
|
5
5
|
import type {
|
|
6
6
|
Any,
|
|
7
|
-
AssistAsyncInstruction,
|
|
8
|
-
AssistInstruction,
|
|
9
|
-
AssistSyncInstruction,
|
|
10
7
|
HttpRequest,
|
|
11
8
|
IdentifiedSanityDocumentStub,
|
|
9
|
+
InstructAsyncInstruction,
|
|
10
|
+
InstructInstruction,
|
|
11
|
+
InstructSyncInstruction,
|
|
12
12
|
} from '../types'
|
|
13
13
|
import {hasDataset} from '../validators'
|
|
14
14
|
|
|
15
15
|
function _instruct<
|
|
16
16
|
DocumentShape extends Record<string, Any>,
|
|
17
|
-
Req extends
|
|
17
|
+
Req extends InstructInstruction<DocumentShape>,
|
|
18
18
|
>(
|
|
19
19
|
client: SanityClient | ObservableSanityClient,
|
|
20
20
|
httpRequest: HttpRequest,
|
|
@@ -31,7 +31,7 @@ function _instruct<
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/** @public */
|
|
34
|
-
export class
|
|
34
|
+
export class ObservableAiClient {
|
|
35
35
|
#client: ObservableSanityClient
|
|
36
36
|
#httpRequest: HttpRequest
|
|
37
37
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest) {
|
|
@@ -39,17 +39,20 @@ export class ObservableAssistClient {
|
|
|
39
39
|
this.#httpRequest = httpRequest
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
instruct(request:
|
|
42
|
+
instruct(request: InstructAsyncInstruction): Observable<{_id: string}>
|
|
43
43
|
|
|
44
44
|
instruct<DocumentShape extends Record<string, Any>>(
|
|
45
|
-
request:
|
|
45
|
+
request: InstructSyncInstruction<DocumentShape>,
|
|
46
46
|
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Run an ad-hoc instruction for a target document.
|
|
50
50
|
* @param request instruction request
|
|
51
51
|
*/
|
|
52
|
-
instruct<
|
|
52
|
+
instruct<
|
|
53
|
+
DocumentShape extends Record<string, Any>,
|
|
54
|
+
Req extends InstructInstruction<DocumentShape>,
|
|
55
|
+
>(
|
|
53
56
|
request: Req,
|
|
54
57
|
): Observable<
|
|
55
58
|
Req['async'] extends true ? {_id: string} : IdentifiedSanityDocumentStub & DocumentShape
|
|
@@ -59,7 +62,7 @@ export class ObservableAssistClient {
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
/** @public */
|
|
62
|
-
export class
|
|
65
|
+
export class AiClient {
|
|
63
66
|
#client: SanityClient
|
|
64
67
|
#httpRequest: HttpRequest
|
|
65
68
|
constructor(client: SanityClient, httpRequest: HttpRequest) {
|
|
@@ -67,17 +70,20 @@ export class AssistClient {
|
|
|
67
70
|
this.#httpRequest = httpRequest
|
|
68
71
|
}
|
|
69
72
|
|
|
70
|
-
instruct(request:
|
|
73
|
+
instruct(request: InstructAsyncInstruction): Promise<{_id: string}>
|
|
71
74
|
|
|
72
75
|
instruct<DocumentShape extends Record<string, Any>>(
|
|
73
|
-
request:
|
|
76
|
+
request: InstructSyncInstruction<DocumentShape>,
|
|
74
77
|
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
75
78
|
|
|
76
79
|
/**
|
|
77
80
|
* Run an ad-hoc instruction for a target document.
|
|
78
81
|
* @param request instruction request
|
|
79
82
|
*/
|
|
80
|
-
instruct<
|
|
83
|
+
instruct<
|
|
84
|
+
DocumentShape extends Record<string, Any>,
|
|
85
|
+
Req extends InstructInstruction<DocumentShape>,
|
|
86
|
+
>(
|
|
81
87
|
request: Req,
|
|
82
88
|
): Promise<
|
|
83
89
|
Req['async'] extends true ? {_id: string} : IdentifiedSanityDocumentStub & DocumentShape
|