@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.d.cts CHANGED
@@ -1,11 +1,9 @@
1
- import type {Any as Any_2} from '@sanity/client'
2
1
  import type {ContentSourceMapDocuments as ContentSourceMapDocuments_2} from '@sanity/client/csm'
3
2
  import {ContentSourceMapParsedPath} from '@sanity/client/csm'
4
3
  import {ContentSourceMapParsedPathKeyedSegment} from '@sanity/client/csm'
5
4
  import {Observable} from 'rxjs'
6
5
  import {Requester} from 'get-it'
7
6
  import type {ResolveStudioUrl} from '@sanity/client/csm'
8
- import type {SanityDocumentStub as SanityDocumentStub_2} from '@sanity/client'
9
7
  import {StudioBaseRoute} from '@sanity/client/csm'
10
8
  import {StudioBaseUrl} from '@sanity/client/csm'
11
9
  import {StudioUrl} from '@sanity/client/csm'
@@ -41,18 +39,6 @@ export declare interface ActionErrorItem {
41
39
  index: number
42
40
  }
43
41
 
44
- /** @public */
45
- declare class AgentActionsClient {
46
- #private
47
- constructor(client: SanityClient, httpRequest: HttpRequest)
48
- generate(request: GenerateAsyncInstruction): Promise<{
49
- _id: string
50
- }>
51
- generate<DocumentShape extends Record<string, Any>>(
52
- request: GenerateSyncInstruction<DocumentShape>,
53
- ): Promise<IdentifiedSanityDocumentStub & DocumentShape>
54
- }
55
-
56
42
  /** @internal */
57
43
  export declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
58
44
  returnFirst: false
@@ -130,18 +116,6 @@ export declare class AssetsClient {
130
116
  ): Promise<SanityAssetDocument | SanityImageAssetDocument>
131
117
  }
132
118
 
133
- declare interface Async {
134
- /**
135
- * When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
136
- * The instruction operation will carry on in the background.
137
- *
138
- * When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
139
- *
140
- * async: true is incompatible with noWrite, as async: true does not return the resulting document
141
- */
142
- async: true
143
- }
144
-
145
119
  /** @internal */
146
120
  export declare type AttributeSet = {
147
121
  [key: string]: Any
@@ -624,19 +598,6 @@ export declare type CreateAction = {
624
598
  */
625
599
  export declare const createClient: (config: ClientConfig) => SanityClient
626
600
 
627
- /**
628
- * Instruction to create a new document
629
- * @beta
630
- */
631
- declare interface CreateDocumentRequest<T extends Record<string, Any_2> = Record<string, Any_2>> {
632
- createDocument: {
633
- /** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
634
- _id?: string
635
- _type: string
636
- } & SanityDocumentStub_2<T>
637
- documentId?: never
638
- }
639
-
640
601
  /** @public */
641
602
  export declare interface CurrentSanityUser {
642
603
  id: string
@@ -830,15 +791,6 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
830
791
  */
831
792
  export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
832
793
 
833
- /**
834
- * Instruction for an existing document.
835
- * @beta
836
- */
837
- declare interface ExistingDocumentRequest {
838
- documentId: string
839
- createDocument?: never
840
- }
841
-
842
794
  /** @public */
843
795
  export declare type FilterDefault = (props: {
844
796
  /**
@@ -905,310 +857,6 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
905
857
  returnDocuments?: true
906
858
  }
907
859
 
908
- /** @beta */
909
- export declare type GenerateAsyncInstruction<
910
- T extends Record<string, Any_2> = Record<string, Any_2>,
911
- > = (ExistingDocumentRequest | CreateDocumentRequest<T>) & GenerateRequestBase & Async
912
-
913
- /** @beta */
914
- export declare interface GenerateConstantInstructionParam {
915
- type: 'constant'
916
- value: string
917
- }
918
-
919
- /**
920
- *
921
- * Includes a LLM-friendly version of the document in the instruction
922
- * @beta
923
- * */
924
- declare interface GenerateDocumentInstructionParam {
925
- type: 'document'
926
- /**
927
- * If omitted, implicitly uses the documentId of the instruction target
928
- */
929
- documentId?: string
930
- }
931
-
932
- /**
933
- *
934
- * Includes a LLM-friendly version of the field value in the instruction
935
- * @beta
936
- * */
937
- export declare interface GenerateFieldInstructionParam {
938
- type: 'field'
939
- /**
940
- * Examples: ['title'], ['array', {_key: 'arrayItemKey'}, 'field']
941
- */
942
- path: GeneratePath
943
- /**
944
- * If omitted, implicitly uses the documentId of the instruction target
945
- */
946
- documentId?: string
947
- }
948
-
949
- /**
950
- * Includes a LLM-friendly version of GROQ query result in the instruction
951
- * @beta
952
- * */
953
- export declare interface GenerateGroqInstructionParam {
954
- type: 'groq'
955
- query: string
956
- params?: Record<string, string>
957
- }
958
-
959
- /** @beta */
960
- export declare type GenerateInstruction<T extends Record<string, Any_2> = Record<string, Any_2>> =
961
- | GenerateSyncInstruction<T>
962
- | GenerateAsyncInstruction<T>
963
-
964
- /** @beta */
965
- export declare type GenerateInstructionParam =
966
- | string
967
- | GenerateConstantInstructionParam
968
- | GenerateFieldInstructionParam
969
- | GenerateDocumentInstructionParam
970
- | GenerateGroqInstructionParam
971
-
972
- /** @beta */
973
- export declare type GenerateInstructionParams = Record<string, GenerateInstructionParam>
974
-
975
- declare type GenerateOperation = 'set' | 'append' | 'mixed'
976
-
977
- declare type GeneratePath = GeneratePathSegment[]
978
-
979
- declare type GeneratePathSegment =
980
- | string
981
- | {
982
- _key: string
983
- }
984
-
985
- declare interface GenerateRequestBase {
986
- /** schemaId as reported by sanity deploy / sanity schema store */
987
- schemaId: string
988
- /** string template using $variable – more on this below under "Dynamic instruction" */
989
- instruction: string
990
- /** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
991
- instructionParams?: GenerateInstructionParams
992
- /**
993
- * Target defines which parts of the document will be affected by the instruction.
994
- * It can be an array, so multiple parts of the document can be separately configured in detail.
995
- *
996
- * Omitting target implies that the document itself is the root.
997
- *
998
- * Notes:
999
- * - instruction can only affect fields up to `maxPathDepth`
1000
- * - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
1001
- * It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
1002
- *
1003
- * @see GenerateRequestBase#conditionalPaths
1004
- */
1005
- target?: GenerateTarget | GenerateTarget[]
1006
- /**
1007
- * When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
1008
- *
1009
- * By default, Generate will not output to conditional `readOnly` and `hidden` fields,
1010
- * ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
1011
- *
1012
- * `conditionalPaths` param allows setting the default conditional value for
1013
- * `hidden` and `readOnly` to false,
1014
- * or individually set `hidden` and `readOnly` state for individual document paths.
1015
- *
1016
- *
1017
- * Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to Generate,
1018
- * and cannot be changed via conditionalPaths
1019
- *
1020
- * conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
1021
- *
1022
- * Consider using `hidden: () => true` in schema config, if a field should be writeable only by Generate and never
1023
- * visible in the studio – then make the field visible to the Generate using `conditionalPaths`.
1024
- *
1025
- * @see GenerateRequestBase#target
1026
- */
1027
- conditionalPaths?: {
1028
- defaultReadOnly?: boolean
1029
- defaultHidden?: boolean
1030
- paths?: {
1031
- /** path here is not a relative path: it must be the full document path, regardless of `path` param used in targets */
1032
- path: GeneratePath
1033
- readOnly: boolean
1034
- hidden: boolean
1035
- }[]
1036
- }
1037
- /**
1038
- * When localeSettings is provided on the request, instruct can write to date and datetime fields.
1039
- * Otherwise, such fields will be ignored.
1040
- */
1041
- localeSettings?: {
1042
- /**
1043
- * A valid Unicode BCP 47 locale identifier used to interpret and format
1044
- * natural language inputs and date output. Examples include "en-US", "fr-FR", or "ja-JP".
1045
- *
1046
- * This affects how phrases like "next Friday" or "in two weeks" are parsed,
1047
- * and how resulting dates are presented (e.g., 12-hour vs 24-hour format).
1048
- *
1049
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#getcanonicalocales
1050
- */
1051
- locale: string
1052
- /**
1053
- * A valid IANA time zone identifier used to resolve relative and absolute
1054
- * date expressions to a specific point in time. Examples include
1055
- * "America/New_York", "Europe/Paris", or "Asia/Tokyo".
1056
- *
1057
- * This ensures phrases like "tomorrow at 9am" are interpreted correctly
1058
- * based on the user's local time.
1059
- *
1060
- * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
1061
- */
1062
- timeZone: string
1063
- }
1064
- /**
1065
- * Controls how much variance the instructions will run with.
1066
- *
1067
- * Value must be in the range [0, 1] (inclusive).
1068
- *
1069
- * Default: 0.3
1070
- */
1071
- temperature?: number
1072
- }
1073
-
1074
- /** @beta */
1075
- export declare type GenerateSyncInstruction<
1076
- T extends Record<string, Any_2> = Record<string, Any_2>,
1077
- > = (ExistingDocumentRequest | CreateDocumentRequest<T>) & GenerateRequestBase & Sync
1078
-
1079
- /**
1080
- * @beta
1081
- */
1082
- declare interface GenerateTarget {
1083
- /**
1084
- * Root target path.
1085
- *
1086
- * Use this to have the instruction only affect a part of the document.
1087
- *
1088
- * To further control the behavior of individual paths under the root, use `include`, `exclude`, `types.include`
1089
- * and `types.exclude`.
1090
- *
1091
- * Example:
1092
- *
1093
- * `path: ['body', {_key: 'someKey'}, 'nestedObject']`
1094
- *
1095
- * Here, the instruction will only write to fields under the nestedObject.
1096
- *
1097
- * Default: [] = the document itself
1098
- *
1099
- * @see #GeneratePathSegment
1100
- * @see #GeneratePath
1101
- * */
1102
- path?: GeneratePathSegment | GeneratePath
1103
- /**
1104
- * Sets the default operation for all paths in the target.
1105
- * Generate runs in `'mixed'` operation mode by default:
1106
- * Changes are set in all non-array fields, and append to all array fields.
1107
- *
1108
- * ### Operation types
1109
- * - `'set'` – an *overwriting* operation, and replaces the full field value.
1110
- * - `'append'`:
1111
- * – array fields: appends new items to the end of the array,
1112
- * - string fields: '<existing content> <new content>'
1113
- * - text fields: '<existing content>\n<new content>'
1114
- * - number fields: existing + new
1115
- * - other field types not mentioned will set instead (dates, url)
1116
- * - `'mixed'` – (default) sets non-array fields, and appends to array fields
1117
- *
1118
- * The default operation can be overridden on a per-path basis using `include`.
1119
- *
1120
- * Nested fields inherit the operation specified by their parent and falls back to the
1121
- * top level target operation if not otherwise specified.
1122
- *
1123
- * Use `include` to change the `operation` of individual fields or items.
1124
- *
1125
- * #### Appending in the middle of arrays
1126
- * `target: {path: ['array'], operation: 'append'}` will append the output of the instruction to the end of the array.
1127
- *
1128
- * To insert in the middle of the array, use `target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append'}`.
1129
- * Here, the output of the instruction will be appended after the array item with key `'appendAfterKey'`.
1130
- *
1131
- * @see #GenerateTargetInclude.operation
1132
- * @see #include
1133
- * @see #GenerateTargetInclude.include
1134
- */
1135
- operation?: GenerateOperation
1136
- /**
1137
- * maxPathDepth controls how deep into the schema from the target root the instruction will affect.
1138
- *
1139
- * Depth is based on path segments:
1140
- * - `title` has depth 1
1141
- * - `array[_key="no"].title` has depth 3
1142
- *
1143
- * Be careful not to set this too high in studios with recursive document schemas, as it could have
1144
- * negative impact on performance; both for runtime and quality of responses.
1145
- *
1146
- * Default: 4
1147
- */
1148
- maxPathDepth?: number
1149
- /**
1150
- * By default, all children up to `target.maxPathDepth` are included.
1151
- *
1152
- * When `include` is specified, only segments explicitly listed will be included.
1153
- *
1154
- * Fields or array items not on the include list, are implicitly excluded.
1155
- */
1156
- include?: (GeneratePathSegment | GenerateTargetInclude)[]
1157
- /**
1158
- * By default, all children up to `target.maxPathDepth` are included.
1159
- * Fields or array items not on the exclude list, are implicitly included.
1160
- */
1161
- exclude?: GeneratePathSegment[]
1162
- /**
1163
- * Types can be used to exclude array item types or all fields directly under the target path of a certain type.
1164
- * If you do exclude: ['string'] all string fields under the target will be excluded, for instance.
1165
- *
1166
- * `types.include` and `types.exclude` are mutually exclusive.
1167
- */
1168
- types?: GenerateTypeConfig
1169
- }
1170
-
1171
- declare interface GenerateTargetInclude {
1172
- path: GeneratePathSegment | GeneratePath
1173
- /**
1174
- * Sets the operation for this path, and all its children.
1175
- * This overrides any operation set parents or the root target.
1176
- * @see #GenerateTarget.operation
1177
- * @see #include
1178
- */
1179
- operation?: GenerateOperation
1180
- /**
1181
- * By default, all children up to `target.maxPathDepth` are included.
1182
- *
1183
- * When `include` is specified, only segments explicitly listed will be included.
1184
- *
1185
- * Fields or array items not on the include list, are implicitly excluded.
1186
- */
1187
- include?: (GeneratePathSegment | GenerateTargetInclude)[]
1188
- /**
1189
- * By default, all children up to `target.maxPathDepth` are included.
1190
- * Fields or array items not on the exclude list, are implicitly included.
1191
- */
1192
- exclude?: GeneratePathSegment[]
1193
- /**
1194
- * Types can be used to exclude array item types or all fields directly under the target path of a certain type.
1195
- * If you do exclude: ['string'] all string fields under the target will be excluded, for instance.
1196
- *
1197
- * `types.include` and `types.exclude` are mutually exclusive.
1198
- */
1199
- types?: GenerateTypeConfig
1200
- }
1201
-
1202
- declare type GenerateTypeConfig =
1203
- | {
1204
- include: string[]
1205
- exclude?: never
1206
- }
1207
- | {
1208
- exclude: string[]
1209
- include?: never
1210
- }
1211
-
1212
860
  /** @public */
1213
861
  export declare type HttpRequest = {
1214
862
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
@@ -1641,18 +1289,6 @@ export declare type MutationSelectionQueryParams = {
1641
1289
  [key: string]: Any
1642
1290
  }
1643
1291
 
1644
- /** @public */
1645
- declare class ObservableAgentsActionClient {
1646
- #private
1647
- constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
1648
- generate(request: GenerateAsyncInstruction): Observable<{
1649
- _id: string
1650
- }>
1651
- generate<DocumentShape extends Record<string, Any>>(
1652
- request: GenerateSyncInstruction<DocumentShape>,
1653
- ): Observable<IdentifiedSanityDocumentStub & DocumentShape>
1654
- }
1655
-
1656
1292
  /** @internal */
1657
1293
  export declare class ObservableAssetsClient {
1658
1294
  #private
@@ -1830,9 +1466,6 @@ export declare class ObservableSanityClient {
1830
1466
  live: LiveClient
1831
1467
  projects: ObservableProjectsClient
1832
1468
  users: ObservableUsersClient
1833
- agent: {
1834
- action: ObservableAgentsActionClient
1835
- }
1836
1469
  /**
1837
1470
  * Instance properties
1838
1471
  */
@@ -2752,9 +2385,6 @@ export declare class SanityClient {
2752
2385
  live: LiveClient
2753
2386
  projects: ProjectsClient
2754
2387
  users: UsersClient
2755
- agent: {
2756
- action: AgentActionsClient
2757
- }
2758
2388
  /**
2759
2389
  * Observable version of the Sanity client, with the same configuration as the promise-based one
2760
2390
  */
@@ -3469,29 +3099,6 @@ export {StudioBaseUrl}
3469
3099
 
3470
3100
  export {StudioUrl}
3471
3101
 
3472
- declare interface Sync {
3473
- /**
3474
- * By default, noWrite: false.
3475
- * Write enabled operations will mutate the target document, and emit AI presence in the studio.
3476
- *
3477
- * When noWrite: true, the api will not mutate any documents nor emit presence.
3478
- * Ie, when true, no changes will be made to content-lake
3479
- *
3480
- * noWrite: true is incompatible with async: true,
3481
- * as noWrite implies that you will use the return value of the operation
3482
- */
3483
- noWrite?: boolean
3484
- /**
3485
- * When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
3486
- * The instruction operation will carry on in the background.
3487
- *
3488
- * When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
3489
- *
3490
- * async: true is incompatible with noWrite: true, as async: true does not return the resulting document
3491
- */
3492
- async?: false
3493
- }
3494
-
3495
3102
  /** @public */
3496
3103
  export declare type SyncTag = `s1:${string}`
3497
3104