@sanity/client 6.29.0-generate.0 → 6.29.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/index.browser.cjs +2 -44
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +0 -404
- package/dist/index.browser.d.ts +0 -404
- package/dist/index.browser.js +2 -44
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -393
- package/dist/index.d.ts +0 -393
- package/dist/index.js +3 -45
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +0 -393
- package/dist/stega.browser.d.ts +0 -393
- package/dist/stega.d.cts +0 -393
- package/dist/stega.d.ts +0 -393
- package/package.json +2 -1
- package/src/SanityClient.ts +0 -13
- package/src/types.ts +0 -10
- package/umd/sanityClient.js +2 -44
- package/umd/sanityClient.min.js +2 -2
- package/src/agent/actions/AgentActionsClient.ts +0 -74
- package/src/agent/actions/generate.ts +0 -24
- package/src/agent/actions/types.ts +0 -373
package/dist/stega.d.ts
CHANGED
|
@@ -33,18 +33,6 @@ export declare interface ActionErrorItem {
|
|
|
33
33
|
index: number
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/** @public */
|
|
37
|
-
declare class AgentActionsClient {
|
|
38
|
-
#private
|
|
39
|
-
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
40
|
-
generate(request: GenerateAsyncInstruction): Promise<{
|
|
41
|
-
_id: string
|
|
42
|
-
}>
|
|
43
|
-
generate<DocumentShape extends Record<string, Any>>(
|
|
44
|
-
request: GenerateSyncInstruction<DocumentShape>,
|
|
45
|
-
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
46
|
-
}
|
|
47
|
-
|
|
48
36
|
/** @internal */
|
|
49
37
|
export declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
|
|
50
38
|
returnFirst: false
|
|
@@ -122,18 +110,6 @@ export declare class AssetsClient {
|
|
|
122
110
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
123
111
|
}
|
|
124
112
|
|
|
125
|
-
declare interface Async {
|
|
126
|
-
/**
|
|
127
|
-
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
128
|
-
* The instruction operation will carry on in the background.
|
|
129
|
-
*
|
|
130
|
-
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
131
|
-
*
|
|
132
|
-
* async: true is incompatible with noWrite, as async: true does not return the resulting document
|
|
133
|
-
*/
|
|
134
|
-
async: true
|
|
135
|
-
}
|
|
136
|
-
|
|
137
113
|
/** @internal */
|
|
138
114
|
export declare type AttributeSet = {
|
|
139
115
|
[key: string]: Any
|
|
@@ -717,19 +693,6 @@ export declare type CreateAction = {
|
|
|
717
693
|
*/
|
|
718
694
|
export declare const createClient: (config: ClientConfig_2) => SanityClient
|
|
719
695
|
|
|
720
|
-
/**
|
|
721
|
-
* Instruction to create a new document
|
|
722
|
-
* @beta
|
|
723
|
-
*/
|
|
724
|
-
declare interface CreateDocumentRequest<T extends Record<string, Any> = Record<string, Any>> {
|
|
725
|
-
createDocument: {
|
|
726
|
-
/** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
|
|
727
|
-
_id?: string
|
|
728
|
-
_type: string
|
|
729
|
-
} & SanityDocumentStub<T>
|
|
730
|
-
documentId?: never
|
|
731
|
-
}
|
|
732
|
-
|
|
733
696
|
/** @public */
|
|
734
697
|
export declare interface CurrentSanityUser {
|
|
735
698
|
id: string
|
|
@@ -935,15 +898,6 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
935
898
|
*/
|
|
936
899
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
937
900
|
|
|
938
|
-
/**
|
|
939
|
-
* Instruction for an existing document.
|
|
940
|
-
* @beta
|
|
941
|
-
*/
|
|
942
|
-
declare interface ExistingDocumentRequest {
|
|
943
|
-
documentId: string
|
|
944
|
-
createDocument?: never
|
|
945
|
-
}
|
|
946
|
-
|
|
947
901
|
/** @public */
|
|
948
902
|
export declare type FilterDefault = (props: {
|
|
949
903
|
/**
|
|
@@ -1059,312 +1013,6 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
1059
1013
|
returnDocuments?: true
|
|
1060
1014
|
}
|
|
1061
1015
|
|
|
1062
|
-
/** @beta */
|
|
1063
|
-
export declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> =
|
|
1064
|
-
(ExistingDocumentRequest | CreateDocumentRequest<T>) & GenerateRequestBase & Async
|
|
1065
|
-
|
|
1066
|
-
/** @beta */
|
|
1067
|
-
export declare interface GenerateConstantInstructionParam {
|
|
1068
|
-
type: 'constant'
|
|
1069
|
-
value: string
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
/**
|
|
1073
|
-
*
|
|
1074
|
-
* Includes a LLM-friendly version of the document in the instruction
|
|
1075
|
-
* @beta
|
|
1076
|
-
* */
|
|
1077
|
-
declare interface GenerateDocumentInstructionParam {
|
|
1078
|
-
type: 'document'
|
|
1079
|
-
/**
|
|
1080
|
-
* If omitted, implicitly uses the documentId of the instruction target
|
|
1081
|
-
*/
|
|
1082
|
-
documentId?: string
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
/**
|
|
1086
|
-
*
|
|
1087
|
-
* Includes a LLM-friendly version of the field value in the instruction
|
|
1088
|
-
* @beta
|
|
1089
|
-
* */
|
|
1090
|
-
export declare interface GenerateFieldInstructionParam {
|
|
1091
|
-
type: 'field'
|
|
1092
|
-
/**
|
|
1093
|
-
* Examples: ['title'], ['array', {_key: 'arrayItemKey'}, 'field']
|
|
1094
|
-
*/
|
|
1095
|
-
path: GeneratePath
|
|
1096
|
-
/**
|
|
1097
|
-
* If omitted, implicitly uses the documentId of the instruction target
|
|
1098
|
-
*/
|
|
1099
|
-
documentId?: string
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
/**
|
|
1103
|
-
* Includes a LLM-friendly version of GROQ query result in the instruction
|
|
1104
|
-
* @beta
|
|
1105
|
-
* */
|
|
1106
|
-
export declare interface GenerateGroqInstructionParam {
|
|
1107
|
-
type: 'groq'
|
|
1108
|
-
query: string
|
|
1109
|
-
params?: Record<string, string>
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
/** @beta */
|
|
1113
|
-
export declare type GenerateInstruction<T extends Record<string, Any> = Record<string, Any>> =
|
|
1114
|
-
| GenerateSyncInstruction<T>
|
|
1115
|
-
| GenerateAsyncInstruction<T>
|
|
1116
|
-
|
|
1117
|
-
/** @beta */
|
|
1118
|
-
export declare type GenerateInstructionParam =
|
|
1119
|
-
| string
|
|
1120
|
-
| GenerateConstantInstructionParam
|
|
1121
|
-
| GenerateFieldInstructionParam
|
|
1122
|
-
| GenerateDocumentInstructionParam
|
|
1123
|
-
| GenerateGroqInstructionParam
|
|
1124
|
-
|
|
1125
|
-
/** @beta */
|
|
1126
|
-
export declare type GenerateInstructionParams = Record<string, GenerateInstructionParam>
|
|
1127
|
-
|
|
1128
|
-
declare type GenerateOperation = 'set' | 'append' | 'mixed'
|
|
1129
|
-
|
|
1130
|
-
declare type GeneratePath = GeneratePathSegment[]
|
|
1131
|
-
|
|
1132
|
-
declare type GeneratePathSegment =
|
|
1133
|
-
| string
|
|
1134
|
-
| {
|
|
1135
|
-
_key: string
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
declare interface GenerateRequestBase {
|
|
1139
|
-
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
1140
|
-
schemaId: string
|
|
1141
|
-
/** string template using $variable – more on this below under "Dynamic instruction" */
|
|
1142
|
-
instruction: string
|
|
1143
|
-
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
1144
|
-
instructionParams?: GenerateInstructionParams
|
|
1145
|
-
/**
|
|
1146
|
-
* Target defines which parts of the document will be affected by the instruction.
|
|
1147
|
-
* It can be an array, so multiple parts of the document can be separately configured in detail.
|
|
1148
|
-
*
|
|
1149
|
-
* Omitting target implies that the document itself is the root.
|
|
1150
|
-
*
|
|
1151
|
-
* Notes:
|
|
1152
|
-
* - instruction can only affect fields up to `maxPathDepth`
|
|
1153
|
-
* - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
|
|
1154
|
-
* It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
|
|
1155
|
-
*
|
|
1156
|
-
* @see GenerateRequestBase#conditionalPaths
|
|
1157
|
-
*/
|
|
1158
|
-
target?: GenerateTarget | GenerateTarget[]
|
|
1159
|
-
/**
|
|
1160
|
-
* When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
|
|
1161
|
-
*
|
|
1162
|
-
* By default, Generate will not output to conditional `readOnly` and `hidden` fields,
|
|
1163
|
-
* ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
|
|
1164
|
-
*
|
|
1165
|
-
* `conditionalPaths` param allows setting the default conditional value for
|
|
1166
|
-
* `hidden` and `readOnly` to false,
|
|
1167
|
-
* or individually set `hidden` and `readOnly` state for individual document paths.
|
|
1168
|
-
*
|
|
1169
|
-
*
|
|
1170
|
-
* Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to Generate,
|
|
1171
|
-
* and cannot be changed via conditionalPaths
|
|
1172
|
-
*
|
|
1173
|
-
* conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
|
|
1174
|
-
*
|
|
1175
|
-
* Consider using `hidden: () => true` in schema config, if a field should be writeable only by Generate and never
|
|
1176
|
-
* visible in the studio – then make the field visible to the Generate using `conditionalPaths`.
|
|
1177
|
-
*
|
|
1178
|
-
* @see GenerateRequestBase#target
|
|
1179
|
-
*/
|
|
1180
|
-
conditionalPaths?: {
|
|
1181
|
-
defaultReadOnly?: boolean
|
|
1182
|
-
defaultHidden?: boolean
|
|
1183
|
-
paths?: {
|
|
1184
|
-
/** path here is not a relative path: it must be the full document path, regardless of `path` param used in targets */
|
|
1185
|
-
path: GeneratePath
|
|
1186
|
-
readOnly: boolean
|
|
1187
|
-
hidden: boolean
|
|
1188
|
-
}[]
|
|
1189
|
-
}
|
|
1190
|
-
/**
|
|
1191
|
-
* When localeSettings is provided on the request, instruct can write to date and datetime fields.
|
|
1192
|
-
* Otherwise, such fields will be ignored.
|
|
1193
|
-
*/
|
|
1194
|
-
localeSettings?: {
|
|
1195
|
-
/**
|
|
1196
|
-
* A valid Unicode BCP 47 locale identifier used to interpret and format
|
|
1197
|
-
* natural language inputs and date output. Examples include "en-US", "fr-FR", or "ja-JP".
|
|
1198
|
-
*
|
|
1199
|
-
* This affects how phrases like "next Friday" or "in two weeks" are parsed,
|
|
1200
|
-
* and how resulting dates are presented (e.g., 12-hour vs 24-hour format).
|
|
1201
|
-
*
|
|
1202
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#getcanonicalocales
|
|
1203
|
-
*/
|
|
1204
|
-
locale: string
|
|
1205
|
-
/**
|
|
1206
|
-
* A valid IANA time zone identifier used to resolve relative and absolute
|
|
1207
|
-
* date expressions to a specific point in time. Examples include
|
|
1208
|
-
* "America/New_York", "Europe/Paris", or "Asia/Tokyo".
|
|
1209
|
-
*
|
|
1210
|
-
* This ensures phrases like "tomorrow at 9am" are interpreted correctly
|
|
1211
|
-
* based on the user's local time.
|
|
1212
|
-
*
|
|
1213
|
-
* @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
1214
|
-
*/
|
|
1215
|
-
timeZone: string
|
|
1216
|
-
}
|
|
1217
|
-
/**
|
|
1218
|
-
* Controls how much variance the instructions will run with.
|
|
1219
|
-
*
|
|
1220
|
-
* Value must be in the range [0, 1] (inclusive).
|
|
1221
|
-
*
|
|
1222
|
-
* Default: 0.3
|
|
1223
|
-
*/
|
|
1224
|
-
temperature?: number
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
/** @beta */
|
|
1228
|
-
export declare type GenerateSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
1229
|
-
| ExistingDocumentRequest
|
|
1230
|
-
| CreateDocumentRequest<T>
|
|
1231
|
-
) &
|
|
1232
|
-
GenerateRequestBase &
|
|
1233
|
-
Sync
|
|
1234
|
-
|
|
1235
|
-
/**
|
|
1236
|
-
* @beta
|
|
1237
|
-
*/
|
|
1238
|
-
declare interface GenerateTarget {
|
|
1239
|
-
/**
|
|
1240
|
-
* Root target path.
|
|
1241
|
-
*
|
|
1242
|
-
* Use this to have the instruction only affect a part of the document.
|
|
1243
|
-
*
|
|
1244
|
-
* To further control the behavior of individual paths under the root, use `include`, `exclude`, `types.include`
|
|
1245
|
-
* and `types.exclude`.
|
|
1246
|
-
*
|
|
1247
|
-
* Example:
|
|
1248
|
-
*
|
|
1249
|
-
* `path: ['body', {_key: 'someKey'}, 'nestedObject']`
|
|
1250
|
-
*
|
|
1251
|
-
* Here, the instruction will only write to fields under the nestedObject.
|
|
1252
|
-
*
|
|
1253
|
-
* Default: [] = the document itself
|
|
1254
|
-
*
|
|
1255
|
-
* @see #GeneratePathSegment
|
|
1256
|
-
* @see #GeneratePath
|
|
1257
|
-
* */
|
|
1258
|
-
path?: GeneratePathSegment | GeneratePath
|
|
1259
|
-
/**
|
|
1260
|
-
* Sets the default operation for all paths in the target.
|
|
1261
|
-
* Generate runs in `'mixed'` operation mode by default:
|
|
1262
|
-
* Changes are set in all non-array fields, and append to all array fields.
|
|
1263
|
-
*
|
|
1264
|
-
* ### Operation types
|
|
1265
|
-
* - `'set'` – an *overwriting* operation, and replaces the full field value.
|
|
1266
|
-
* - `'append'`:
|
|
1267
|
-
* – array fields: appends new items to the end of the array,
|
|
1268
|
-
* - string fields: '<existing content> <new content>'
|
|
1269
|
-
* - text fields: '<existing content>\n<new content>'
|
|
1270
|
-
* - number fields: existing + new
|
|
1271
|
-
* - other field types not mentioned will set instead (dates, url)
|
|
1272
|
-
* - `'mixed'` – (default) sets non-array fields, and appends to array fields
|
|
1273
|
-
*
|
|
1274
|
-
* The default operation can be overridden on a per-path basis using `include`.
|
|
1275
|
-
*
|
|
1276
|
-
* Nested fields inherit the operation specified by their parent and falls back to the
|
|
1277
|
-
* top level target operation if not otherwise specified.
|
|
1278
|
-
*
|
|
1279
|
-
* Use `include` to change the `operation` of individual fields or items.
|
|
1280
|
-
*
|
|
1281
|
-
* #### Appending in the middle of arrays
|
|
1282
|
-
* `target: {path: ['array'], operation: 'append'}` will append the output of the instruction to the end of the array.
|
|
1283
|
-
*
|
|
1284
|
-
* To insert in the middle of the array, use `target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append'}`.
|
|
1285
|
-
* Here, the output of the instruction will be appended after the array item with key `'appendAfterKey'`.
|
|
1286
|
-
*
|
|
1287
|
-
* @see #GenerateTargetInclude.operation
|
|
1288
|
-
* @see #include
|
|
1289
|
-
* @see #GenerateTargetInclude.include
|
|
1290
|
-
*/
|
|
1291
|
-
operation?: GenerateOperation
|
|
1292
|
-
/**
|
|
1293
|
-
* maxPathDepth controls how deep into the schema from the target root the instruction will affect.
|
|
1294
|
-
*
|
|
1295
|
-
* Depth is based on path segments:
|
|
1296
|
-
* - `title` has depth 1
|
|
1297
|
-
* - `array[_key="no"].title` has depth 3
|
|
1298
|
-
*
|
|
1299
|
-
* Be careful not to set this too high in studios with recursive document schemas, as it could have
|
|
1300
|
-
* negative impact on performance; both for runtime and quality of responses.
|
|
1301
|
-
*
|
|
1302
|
-
* Default: 4
|
|
1303
|
-
*/
|
|
1304
|
-
maxPathDepth?: number
|
|
1305
|
-
/**
|
|
1306
|
-
* By default, all children up to `target.maxPathDepth` are included.
|
|
1307
|
-
*
|
|
1308
|
-
* When `include` is specified, only segments explicitly listed will be included.
|
|
1309
|
-
*
|
|
1310
|
-
* Fields or array items not on the include list, are implicitly excluded.
|
|
1311
|
-
*/
|
|
1312
|
-
include?: (GeneratePathSegment | GenerateTargetInclude)[]
|
|
1313
|
-
/**
|
|
1314
|
-
* By default, all children up to `target.maxPathDepth` are included.
|
|
1315
|
-
* Fields or array items not on the exclude list, are implicitly included.
|
|
1316
|
-
*/
|
|
1317
|
-
exclude?: GeneratePathSegment[]
|
|
1318
|
-
/**
|
|
1319
|
-
* Types can be used to exclude array item types or all fields directly under the target path of a certain type.
|
|
1320
|
-
* If you do exclude: ['string'] all string fields under the target will be excluded, for instance.
|
|
1321
|
-
*
|
|
1322
|
-
* `types.include` and `types.exclude` are mutually exclusive.
|
|
1323
|
-
*/
|
|
1324
|
-
types?: GenerateTypeConfig
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
declare interface GenerateTargetInclude {
|
|
1328
|
-
path: GeneratePathSegment | GeneratePath
|
|
1329
|
-
/**
|
|
1330
|
-
* Sets the operation for this path, and all its children.
|
|
1331
|
-
* This overrides any operation set parents or the root target.
|
|
1332
|
-
* @see #GenerateTarget.operation
|
|
1333
|
-
* @see #include
|
|
1334
|
-
*/
|
|
1335
|
-
operation?: GenerateOperation
|
|
1336
|
-
/**
|
|
1337
|
-
* By default, all children up to `target.maxPathDepth` are included.
|
|
1338
|
-
*
|
|
1339
|
-
* When `include` is specified, only segments explicitly listed will be included.
|
|
1340
|
-
*
|
|
1341
|
-
* Fields or array items not on the include list, are implicitly excluded.
|
|
1342
|
-
*/
|
|
1343
|
-
include?: (GeneratePathSegment | GenerateTargetInclude)[]
|
|
1344
|
-
/**
|
|
1345
|
-
* By default, all children up to `target.maxPathDepth` are included.
|
|
1346
|
-
* Fields or array items not on the exclude list, are implicitly included.
|
|
1347
|
-
*/
|
|
1348
|
-
exclude?: GeneratePathSegment[]
|
|
1349
|
-
/**
|
|
1350
|
-
* Types can be used to exclude array item types or all fields directly under the target path of a certain type.
|
|
1351
|
-
* If you do exclude: ['string'] all string fields under the target will be excluded, for instance.
|
|
1352
|
-
*
|
|
1353
|
-
* `types.include` and `types.exclude` are mutually exclusive.
|
|
1354
|
-
*/
|
|
1355
|
-
types?: GenerateTypeConfig
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
declare type GenerateTypeConfig =
|
|
1359
|
-
| {
|
|
1360
|
-
include: string[]
|
|
1361
|
-
exclude?: never
|
|
1362
|
-
}
|
|
1363
|
-
| {
|
|
1364
|
-
exclude: string[]
|
|
1365
|
-
include?: never
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
1016
|
/** @public */
|
|
1369
1017
|
export declare type HttpRequest = {
|
|
1370
1018
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -1814,18 +1462,6 @@ export declare type MutationSelectionQueryParams = {
|
|
|
1814
1462
|
[key: string]: Any
|
|
1815
1463
|
}
|
|
1816
1464
|
|
|
1817
|
-
/** @public */
|
|
1818
|
-
declare class ObservableAgentsActionClient {
|
|
1819
|
-
#private
|
|
1820
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1821
|
-
generate(request: GenerateAsyncInstruction): Observable<{
|
|
1822
|
-
_id: string
|
|
1823
|
-
}>
|
|
1824
|
-
generate<DocumentShape extends Record<string, Any>>(
|
|
1825
|
-
request: GenerateSyncInstruction<DocumentShape>,
|
|
1826
|
-
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
1465
|
/** @internal */
|
|
1830
1466
|
export declare class ObservableAssetsClient {
|
|
1831
1467
|
#private
|
|
@@ -2003,9 +1639,6 @@ export declare class ObservableSanityClient {
|
|
|
2003
1639
|
live: LiveClient
|
|
2004
1640
|
projects: ObservableProjectsClient
|
|
2005
1641
|
users: ObservableUsersClient
|
|
2006
|
-
agent: {
|
|
2007
|
-
action: ObservableAgentsActionClient
|
|
2008
|
-
}
|
|
2009
1642
|
/**
|
|
2010
1643
|
* Instance properties
|
|
2011
1644
|
*/
|
|
@@ -2937,9 +2570,6 @@ export declare class SanityClient {
|
|
|
2937
2570
|
live: LiveClient
|
|
2938
2571
|
projects: ProjectsClient
|
|
2939
2572
|
users: UsersClient
|
|
2940
|
-
agent: {
|
|
2941
|
-
action: AgentActionsClient
|
|
2942
|
-
}
|
|
2943
2573
|
/**
|
|
2944
2574
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2945
2575
|
*/
|
|
@@ -3723,29 +3353,6 @@ export declare type StudioBaseUrl =
|
|
|
3723
3353
|
/** @alpha */
|
|
3724
3354
|
export declare type StudioUrl = StudioBaseUrl | StudioBaseRoute
|
|
3725
3355
|
|
|
3726
|
-
declare interface Sync {
|
|
3727
|
-
/**
|
|
3728
|
-
* By default, noWrite: false.
|
|
3729
|
-
* Write enabled operations will mutate the target document, and emit AI presence in the studio.
|
|
3730
|
-
*
|
|
3731
|
-
* When noWrite: true, the api will not mutate any documents nor emit presence.
|
|
3732
|
-
* Ie, when true, no changes will be made to content-lake
|
|
3733
|
-
*
|
|
3734
|
-
* noWrite: true is incompatible with async: true,
|
|
3735
|
-
* as noWrite implies that you will use the return value of the operation
|
|
3736
|
-
*/
|
|
3737
|
-
noWrite?: boolean
|
|
3738
|
-
/**
|
|
3739
|
-
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
3740
|
-
* The instruction operation will carry on in the background.
|
|
3741
|
-
*
|
|
3742
|
-
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
3743
|
-
*
|
|
3744
|
-
* async: true is incompatible with noWrite: true, as async: true does not return the resulting document
|
|
3745
|
-
*/
|
|
3746
|
-
async?: false
|
|
3747
|
-
}
|
|
3748
|
-
|
|
3749
3356
|
/** @public */
|
|
3750
3357
|
export declare type SyncTag = `s1:${string}`
|
|
3751
3358
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "6.29.
|
|
3
|
+
"version": "6.29.1",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"import": "./dist/index.browser.js",
|
|
37
37
|
"require": "./dist/index.browser.cjs"
|
|
38
38
|
},
|
|
39
|
+
"sanity-function": "./dist/index.browser.js",
|
|
39
40
|
"react-server": "./dist/index.browser.js",
|
|
40
41
|
"bun": "./dist/index.browser.js",
|
|
41
42
|
"deno": "./dist/index.browser.js",
|
package/src/SanityClient.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {lastValueFrom, Observable} from 'rxjs'
|
|
2
2
|
|
|
3
|
-
import {AgentActionsClient, ObservableAgentsActionClient} from './agent/actions/AgentActionsClient'
|
|
4
3
|
import {AssetsClient, ObservableAssetsClient} from './assets/AssetsClient'
|
|
5
4
|
import {defaultConfig, initConfig} from './config'
|
|
6
5
|
import * as dataMethods from './data/dataMethods'
|
|
@@ -66,9 +65,6 @@ export class ObservableSanityClient {
|
|
|
66
65
|
live: LiveClient
|
|
67
66
|
projects: ObservableProjectsClient
|
|
68
67
|
users: ObservableUsersClient
|
|
69
|
-
agent: {
|
|
70
|
-
action: ObservableAgentsActionClient
|
|
71
|
-
}
|
|
72
68
|
|
|
73
69
|
/**
|
|
74
70
|
* Private properties
|
|
@@ -91,9 +87,6 @@ export class ObservableSanityClient {
|
|
|
91
87
|
this.live = new LiveClient(this)
|
|
92
88
|
this.projects = new ObservableProjectsClient(this, this.#httpRequest)
|
|
93
89
|
this.users = new ObservableUsersClient(this, this.#httpRequest)
|
|
94
|
-
this.agent = {
|
|
95
|
-
action: new ObservableAgentsActionClient(this, this.#httpRequest),
|
|
96
|
-
}
|
|
97
90
|
}
|
|
98
91
|
|
|
99
92
|
/**
|
|
@@ -740,9 +733,6 @@ export class SanityClient {
|
|
|
740
733
|
live: LiveClient
|
|
741
734
|
projects: ProjectsClient
|
|
742
735
|
users: UsersClient
|
|
743
|
-
agent: {
|
|
744
|
-
action: AgentActionsClient
|
|
745
|
-
}
|
|
746
736
|
|
|
747
737
|
/**
|
|
748
738
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
@@ -770,9 +760,6 @@ export class SanityClient {
|
|
|
770
760
|
this.live = new LiveClient(this)
|
|
771
761
|
this.projects = new ProjectsClient(this, this.#httpRequest)
|
|
772
762
|
this.users = new UsersClient(this, this.#httpRequest)
|
|
773
|
-
this.agent = {
|
|
774
|
-
action: new AgentActionsClient(this, this.#httpRequest),
|
|
775
|
-
}
|
|
776
763
|
|
|
777
764
|
this.observable = new ObservableSanityClient(httpRequest, config)
|
|
778
765
|
}
|
package/src/types.ts
CHANGED
|
@@ -1372,16 +1372,6 @@ export type ClientReturn<
|
|
|
1372
1372
|
Fallback = Any,
|
|
1373
1373
|
> = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
|
|
1374
1374
|
|
|
1375
|
-
export type {
|
|
1376
|
-
GenerateAsyncInstruction,
|
|
1377
|
-
GenerateConstantInstructionParam,
|
|
1378
|
-
GenerateFieldInstructionParam,
|
|
1379
|
-
GenerateGroqInstructionParam,
|
|
1380
|
-
GenerateInstruction,
|
|
1381
|
-
GenerateInstructionParam,
|
|
1382
|
-
GenerateInstructionParams,
|
|
1383
|
-
GenerateSyncInstruction,
|
|
1384
|
-
} from './agent/actions/types'
|
|
1385
1375
|
export type {
|
|
1386
1376
|
ContentSourceMapParsedPath,
|
|
1387
1377
|
ContentSourceMapParsedPathKeyedSegment,
|
package/umd/sanityClient.js
CHANGED
|
@@ -2871,42 +2871,6 @@ ${selectionOpts}`);
|
|
|
2871
2871
|
throw new Error(`Unsupported resource type: ${type.toString()}`);
|
|
2872
2872
|
}
|
|
2873
2873
|
};
|
|
2874
|
-
function _generate(client, httpRequest, request) {
|
|
2875
|
-
const dataset2 = hasDataset(client.config());
|
|
2876
|
-
return _request(client, httpRequest, {
|
|
2877
|
-
method: "POST",
|
|
2878
|
-
uri: `/agent/action/generate/${dataset2}`,
|
|
2879
|
-
body: request
|
|
2880
|
-
});
|
|
2881
|
-
}
|
|
2882
|
-
class ObservableAgentsActionClient {
|
|
2883
|
-
#client;
|
|
2884
|
-
#httpRequest;
|
|
2885
|
-
constructor(client, httpRequest) {
|
|
2886
|
-
this.#client = client, this.#httpRequest = httpRequest;
|
|
2887
|
-
}
|
|
2888
|
-
/**
|
|
2889
|
-
* Run an instruction to generate content in a target document.
|
|
2890
|
-
* @param request instruction request
|
|
2891
|
-
*/
|
|
2892
|
-
generate(request) {
|
|
2893
|
-
return _generate(this.#client, this.#httpRequest, request);
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
class AgentActionsClient {
|
|
2897
|
-
#client;
|
|
2898
|
-
#httpRequest;
|
|
2899
|
-
constructor(client, httpRequest) {
|
|
2900
|
-
this.#client = client, this.#httpRequest = httpRequest;
|
|
2901
|
-
}
|
|
2902
|
-
/**
|
|
2903
|
-
* Run an instruction to generate content in a target document.
|
|
2904
|
-
* @param request instruction request
|
|
2905
|
-
*/
|
|
2906
|
-
generate(request) {
|
|
2907
|
-
return lastValueFrom(_generate(this.#client, this.#httpRequest, request));
|
|
2908
|
-
}
|
|
2909
|
-
}
|
|
2910
2874
|
class ObservableAssetsClient {
|
|
2911
2875
|
#client;
|
|
2912
2876
|
#httpRequest;
|
|
@@ -3327,7 +3291,6 @@ ${selectionOpts}`);
|
|
|
3327
3291
|
live;
|
|
3328
3292
|
projects;
|
|
3329
3293
|
users;
|
|
3330
|
-
agent;
|
|
3331
3294
|
/**
|
|
3332
3295
|
* Private properties
|
|
3333
3296
|
*/
|
|
@@ -3338,9 +3301,7 @@ ${selectionOpts}`);
|
|
|
3338
3301
|
*/
|
|
3339
3302
|
listen = _listen;
|
|
3340
3303
|
constructor(httpRequest, config = defaultConfig) {
|
|
3341
|
-
this.config(config), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest)
|
|
3342
|
-
action: new ObservableAgentsActionClient(this, this.#httpRequest)
|
|
3343
|
-
};
|
|
3304
|
+
this.config(config), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest);
|
|
3344
3305
|
}
|
|
3345
3306
|
/**
|
|
3346
3307
|
* Clone the client - returns a new instance
|
|
@@ -3479,7 +3440,6 @@ ${selectionOpts}`);
|
|
|
3479
3440
|
live;
|
|
3480
3441
|
projects;
|
|
3481
3442
|
users;
|
|
3482
|
-
agent;
|
|
3483
3443
|
/**
|
|
3484
3444
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
3485
3445
|
*/
|
|
@@ -3494,9 +3454,7 @@ ${selectionOpts}`);
|
|
|
3494
3454
|
*/
|
|
3495
3455
|
listen = _listen;
|
|
3496
3456
|
constructor(httpRequest, config = defaultConfig) {
|
|
3497
|
-
this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.
|
|
3498
|
-
action: new AgentActionsClient(this, this.#httpRequest)
|
|
3499
|
-
}, this.observable = new ObservableSanityClient(httpRequest, config);
|
|
3457
|
+
this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
3500
3458
|
}
|
|
3501
3459
|
/**
|
|
3502
3460
|
* Clone the client - returns a new instance
|