@sanity/client 6.28.3-instruct.0 → 6.28.3-instruct.2

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.
@@ -110,117 +110,6 @@ 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
113
  declare interface Async {
225
114
  /**
226
115
  * When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
@@ -578,12 +467,6 @@ export declare class ConnectionFailedError extends Error {
578
467
  readonly name = 'ConnectionFailedError'
579
468
  }
580
469
 
581
- /** @beta */
582
- export declare interface ConstantInstructionParam {
583
- type: 'constant'
584
- value: string
585
- }
586
-
587
470
  /** @public */
588
471
  export declare interface ContentSourceMap {
589
472
  mappings: ContentSourceMapMappings
@@ -1040,23 +923,6 @@ declare interface ExistingDocumentRequest {
1040
923
  documentId: string
1041
924
  }
1042
925
 
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
926
  /** @public */
1061
927
  export declare type FilterDefault = (props: {
1062
928
  /**
@@ -1172,13 +1038,6 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
1172
1038
  returnDocuments?: true
1173
1039
  }
1174
1040
 
1175
- /** @beta */
1176
- export declare interface GroqInstructionParam {
1177
- type: 'groq'
1178
- query: string
1179
- params?: Record<string, string>
1180
- }
1181
-
1182
1041
  /** @public */
1183
1042
  export declare type HttpRequest = {
1184
1043
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
@@ -1250,15 +1109,143 @@ export declare type InsertPatch =
1250
1109
  }
1251
1110
 
1252
1111
  /** @beta */
1253
- export declare type InstructionParam =
1112
+ export declare type InstructAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> =
1113
+ (ExistingDocumentRequest | CreateDocumentRequest<T>) & InstructRequestBase & Async
1114
+
1115
+ /** @beta */
1116
+ export declare interface InstructConstantInstructionParam {
1117
+ type: 'constant'
1118
+ value: string
1119
+ }
1120
+
1121
+ /**
1122
+ *
1123
+ * Includes a LLM-friendly version of the field value in the instruction
1124
+ * @beta
1125
+ * */
1126
+ export declare interface InstructFieldInstructionParam {
1127
+ type: 'field'
1128
+ /**
1129
+ * Examples: 'title', 'array[_key=="key"].field'
1130
+ */
1131
+ path: string
1132
+ /**
1133
+ * If omitted, implicitly uses the documentId of the instruction target
1134
+ */
1135
+ documentId?: string
1136
+ }
1137
+
1138
+ /**
1139
+ * Includes a LLM-friendly version of GROQ query result in the instruction
1140
+ * @beta
1141
+ * */
1142
+ export declare interface InstructGroqInstructionParam {
1143
+ type: 'groq'
1144
+ query: string
1145
+ params?: Record<string, string>
1146
+ }
1147
+
1148
+ /** @beta */
1149
+ export declare type InstructInstruction<T extends Record<string, Any> = Record<string, Any>> =
1150
+ | InstructSyncInstruction<T>
1151
+ | InstructAsyncInstruction<T>
1152
+
1153
+ /** @beta */
1154
+ export declare type InstructInstructionParam =
1254
1155
  | string
1255
- | ConstantInstructionParam
1256
- | FieldInstructionParam
1156
+ | InstructConstantInstructionParam
1157
+ | InstructFieldInstructionParam
1257
1158
  | DocumentInstructionParam
1258
- | GroqInstructionParam
1159
+ | InstructGroqInstructionParam
1259
1160
 
1260
1161
  /** @beta */
1261
- export declare type InstructionParams = Record<string, InstructionParam>
1162
+ export declare type InstructInstructionParams = Record<string, InstructInstructionParam>
1163
+
1164
+ declare interface InstructRequestBase {
1165
+ /** schemaId as reported by sanity deploy / sanity schema store */
1166
+ schemaId: string
1167
+ /** string template using $variable – more on this below under "Dynamic instruction" */
1168
+ instruction: string
1169
+ /** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
1170
+ instructionParams?: InstructInstructionParams
1171
+ /**
1172
+ * Optional document path output target for the instruction.
1173
+ * When provided, the instruction will apply to this path in the document and its children.
1174
+ *
1175
+ * ## Examples
1176
+ * - `path: 'title'` will output to the title field in the document
1177
+ * - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
1178
+ */
1179
+ path?: string
1180
+ /**
1181
+ * Controls sub-paths in the document that can be output to.
1182
+ *
1183
+ * The string-paths are relative to the `path` param
1184
+ *
1185
+ * Note: these path strings are less strictly validated than the `path` param itself:
1186
+ * if an relative-path does not exist or is invalid, it will be silently ignored.
1187
+ *
1188
+ * @see InstructRequestBase#conditionalPaths
1189
+ * @see InstructRequestBase#outputTypes
1190
+ */
1191
+ relativeOutputPaths?:
1192
+ | {
1193
+ include: string[]
1194
+ }
1195
+ | {
1196
+ exclude: string[]
1197
+ }
1198
+ /**
1199
+ * Controls which types the instruction is allowed to output to.
1200
+ *
1201
+ * @see InstructRequestBase#relativeOutputPaths
1202
+ * @see InstructRequestBase#conditionalPaths
1203
+ */
1204
+ outputTypes?:
1205
+ | {
1206
+ include: string[]
1207
+ }
1208
+ | {
1209
+ exclude: string[]
1210
+ }
1211
+ /**
1212
+ * When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
1213
+ *
1214
+ * By default, AI Instruct will not output to conditional `readOnly` and `hidden` fields,
1215
+ * ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
1216
+ *
1217
+ * `conditionalPaths` param allows setting the default conditional value for
1218
+ * `hidden` and `readOnly` to false,
1219
+ * or individually set `hidden` and `readOnly` state for individual document paths.
1220
+ *
1221
+ *
1222
+ * Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Instruct,
1223
+ * and cannot be changed via conditionalPaths.
1224
+ *
1225
+ * conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
1226
+ *
1227
+ * @see InstructRequestBase#relativeOutputPaths
1228
+ * @see InstructRequestBase#outputTypes
1229
+ */
1230
+ conditionalPaths?: {
1231
+ defaultReadOnly?: boolean
1232
+ defaultHidden?: boolean
1233
+ paths?: {
1234
+ /** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
1235
+ path: string
1236
+ readOnly: boolean
1237
+ hidden: boolean
1238
+ }[]
1239
+ }
1240
+ }
1241
+
1242
+ /** @beta */
1243
+ export declare type InstructSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
1244
+ | ExistingDocumentRequest
1245
+ | CreateDocumentRequest<T>
1246
+ ) &
1247
+ InstructRequestBase &
1248
+ Sync
1262
1249
 
1263
1250
  /**
1264
1251
  * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
@@ -1681,18 +1668,6 @@ export declare class ObservableAssetsClient {
1681
1668
  >
1682
1669
  }
1683
1670
 
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
1671
  /** @internal */
1697
1672
  export declare class ObservableDatasetsClient {
1698
1673
  #private
@@ -1816,7 +1791,6 @@ export declare class ObservableSanityClient {
1816
1791
  live: LiveClient
1817
1792
  projects: ObservableProjectsClient
1818
1793
  users: ObservableUsersClient
1819
- assist: ObservableAssistClient
1820
1794
  /**
1821
1795
  * Instance properties
1822
1796
  */
@@ -2311,6 +2285,12 @@ export declare class ObservableSanityClient {
2311
2285
  * @param path - Path to append after the operation
2312
2286
  */
2313
2287
  getDataUrl(operation: string, path?: string): string
2288
+ instruct(request: InstructAsyncInstruction): Observable<{
2289
+ _id: string
2290
+ }>
2291
+ instruct<DocumentShape extends Record<string, Any>>(
2292
+ request: InstructSyncInstruction<DocumentShape>,
2293
+ ): Observable<IdentifiedSanityDocumentStub & DocumentShape>
2314
2294
  }
2315
2295
 
2316
2296
  /**
@@ -2748,7 +2728,6 @@ export declare class SanityClient {
2748
2728
  live: LiveClient
2749
2729
  projects: ProjectsClient
2750
2730
  users: UsersClient
2751
- assist: AssistClient
2752
2731
  /**
2753
2732
  * Observable version of the Sanity client, with the same configuration as the promise-based one
2754
2733
  */
@@ -3263,6 +3242,12 @@ export declare class SanityClient {
3263
3242
  * @param path - Path to append after the operation
3264
3243
  */
3265
3244
  getDataUrl(operation: string, path?: string): string
3245
+ instruct(request: InstructAsyncInstruction): Promise<{
3246
+ _id: string
3247
+ }>
3248
+ instruct<DocumentShape extends Record<string, Any>>(
3249
+ request: InstructSyncInstruction<DocumentShape>,
3250
+ ): Promise<IdentifiedSanityDocumentStub & DocumentShape>
3266
3251
  }
3267
3252
 
3268
3253
  /** @internal */