@sanity/client 6.29.0-generate.0 → 6.29.0-generate.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.
- package/dist/index.browser.cjs +44 -0
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +354 -277
- package/dist/index.browser.d.ts +354 -277
- package/dist/index.browser.js +44 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +45 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +354 -266
- package/dist/index.d.ts +354 -266
- package/dist/index.js +45 -1
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +351 -263
- package/dist/stega.browser.d.ts +351 -263
- package/dist/stega.d.cts +351 -263
- package/dist/stega.d.ts +351 -263
- package/package.json +1 -1
- package/src/agent/actions/AgentActionsClient.ts +86 -9
- package/src/agent/actions/{types.ts → commonTypes.ts} +36 -156
- package/src/agent/actions/generate.ts +152 -1
- package/src/agent/actions/transform.ts +107 -0
- package/src/agent/actions/translate.ts +120 -0
- package/src/types.ts +26 -8
- package/umd/sanityClient.js +44 -0
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.d.cts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import type {AgentActionAsync} from '@sanity/client/agent/actions/commonTypes'
|
|
2
|
+
import type {AgentActionPath as AgentActionPath_2} from '@sanity/client/agent/actions/commonTypes'
|
|
3
|
+
import type {AgentActionPathSegment as AgentActionPathSegment_2} from '@sanity/client/agent/actions/commonTypes'
|
|
4
|
+
import type {AgentActionRequestBase} from '@sanity/client/agent/actions/commonTypes'
|
|
5
|
+
import type {AgentActionSync} from '@sanity/client/agent/actions/commonTypes'
|
|
6
|
+
import type {AgentActionTarget as AgentActionTarget_2} from '@sanity/client/agent/actions/commonTypes'
|
|
7
|
+
import type {AgentActionTargetInclude} from '@sanity/client/agent/actions/commonTypes'
|
|
1
8
|
import type {ContentSourceMapDocuments as ContentSourceMapDocuments_2} from '@sanity/client/csm'
|
|
2
9
|
import {ContentSourceMapParsedPath} from '@sanity/client/csm'
|
|
3
10
|
import {ContentSourceMapParsedPathKeyedSegment} from '@sanity/client/csm'
|
|
@@ -39,6 +46,27 @@ export declare interface ActionErrorItem {
|
|
|
39
46
|
index: number
|
|
40
47
|
}
|
|
41
48
|
|
|
49
|
+
/** @beta */
|
|
50
|
+
export declare type AgentActionParam =
|
|
51
|
+
| string
|
|
52
|
+
| ConstantAgentActionParam
|
|
53
|
+
| FieldAgentActionParam
|
|
54
|
+
| DocumentAgentActionParam
|
|
55
|
+
| GroqAgentActionParam
|
|
56
|
+
|
|
57
|
+
/** @beta */
|
|
58
|
+
export declare type AgentActionParams = Record<string, AgentActionParam>
|
|
59
|
+
|
|
60
|
+
/** @beta */
|
|
61
|
+
export declare type AgentActionPath = AgentActionPathSegment[]
|
|
62
|
+
|
|
63
|
+
/** @beta */
|
|
64
|
+
export declare type AgentActionPathSegment =
|
|
65
|
+
| string
|
|
66
|
+
| {
|
|
67
|
+
_key: string
|
|
68
|
+
}
|
|
69
|
+
|
|
42
70
|
/** @public */
|
|
43
71
|
declare class AgentActionsClient {
|
|
44
72
|
#private
|
|
@@ -49,8 +77,82 @@ declare class AgentActionsClient {
|
|
|
49
77
|
generate<DocumentShape extends Record<string, Any>>(
|
|
50
78
|
request: GenerateSyncInstruction<DocumentShape>,
|
|
51
79
|
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
80
|
+
transform(request: TransformDocumentAsync): Promise<{
|
|
81
|
+
_id: string
|
|
82
|
+
}>
|
|
83
|
+
transform<DocumentShape extends Record<string, Any>>(
|
|
84
|
+
request: TransformDocumentSync,
|
|
85
|
+
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
86
|
+
translate(request: TranslateDocumentAsync): Promise<{
|
|
87
|
+
_id: string
|
|
88
|
+
}>
|
|
89
|
+
translate<DocumentShape extends Record<string, Any>>(
|
|
90
|
+
request: TranslateDocumentSync,
|
|
91
|
+
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
52
92
|
}
|
|
53
93
|
|
|
94
|
+
/**
|
|
95
|
+
* @beta
|
|
96
|
+
*/
|
|
97
|
+
export declare interface AgentActionTarget {
|
|
98
|
+
/**
|
|
99
|
+
* Root target path.
|
|
100
|
+
*
|
|
101
|
+
* Use this to have the instruction only affect a part of the document.
|
|
102
|
+
*
|
|
103
|
+
* To further control the behavior of individual paths under the root, use `include`, `exclude`, `types.include`
|
|
104
|
+
* and `types.exclude`.
|
|
105
|
+
*
|
|
106
|
+
* Example:
|
|
107
|
+
*
|
|
108
|
+
* `path: ['body', {_key: 'someKey'}, 'nestedObject']`
|
|
109
|
+
*
|
|
110
|
+
* Here, the instruction will only write to fields under the nestedObject.
|
|
111
|
+
*
|
|
112
|
+
* Default: [] = the document itself
|
|
113
|
+
*
|
|
114
|
+
* @see #AgentActionPathSegment
|
|
115
|
+
* @see #AgentActionPath
|
|
116
|
+
* */
|
|
117
|
+
path?: AgentActionPathSegment | AgentActionPath
|
|
118
|
+
/**
|
|
119
|
+
* maxPathDepth controls how deep into the schema from the target root the instruction will affect.
|
|
120
|
+
*
|
|
121
|
+
* Depth is based on path segments:
|
|
122
|
+
* - `title` has depth 1
|
|
123
|
+
* - `array[_key="no"].title` has depth 3
|
|
124
|
+
*
|
|
125
|
+
* Be careful not to set this too high in studios with recursive document schemas, as it could have
|
|
126
|
+
* negative impact on performance; both for runtime and quality of responses.
|
|
127
|
+
*
|
|
128
|
+
* Default: 4
|
|
129
|
+
*/
|
|
130
|
+
maxPathDepth?: number
|
|
131
|
+
/**
|
|
132
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
133
|
+
* Fields or array items not on the exclude list, are implicitly included.
|
|
134
|
+
*/
|
|
135
|
+
exclude?: AgentActionPathSegment[]
|
|
136
|
+
/**
|
|
137
|
+
* Types can be used to exclude array item types or all fields directly under the target path of a certain type.
|
|
138
|
+
* If you do exclude: ['string'] all string fields under the target will be excluded, for instance.
|
|
139
|
+
*
|
|
140
|
+
* `types.include` and `types.exclude` are mutually exclusive.
|
|
141
|
+
*/
|
|
142
|
+
types?: AgentActionTypeConfig
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** @beta */
|
|
146
|
+
declare type AgentActionTypeConfig =
|
|
147
|
+
| {
|
|
148
|
+
include: string[]
|
|
149
|
+
exclude?: never
|
|
150
|
+
}
|
|
151
|
+
| {
|
|
152
|
+
exclude: string[]
|
|
153
|
+
include?: never
|
|
154
|
+
}
|
|
155
|
+
|
|
54
156
|
/** @internal */
|
|
55
157
|
export declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
|
|
56
158
|
returnFirst: false
|
|
@@ -69,12 +171,6 @@ export declare type AllDocumentsMutationOptions = BaseMutationOptions & {
|
|
|
69
171
|
*/
|
|
70
172
|
export declare type Any = any
|
|
71
173
|
|
|
72
|
-
/**
|
|
73
|
-
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
74
|
-
* @internal
|
|
75
|
-
*/
|
|
76
|
-
declare type Any_2 = any
|
|
77
|
-
|
|
78
174
|
/** @internal */
|
|
79
175
|
export declare interface ApiError {
|
|
80
176
|
error: string
|
|
@@ -134,18 +230,6 @@ export declare class AssetsClient {
|
|
|
134
230
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
135
231
|
}
|
|
136
232
|
|
|
137
|
-
declare interface Async {
|
|
138
|
-
/**
|
|
139
|
-
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
140
|
-
* The instruction operation will carry on in the background.
|
|
141
|
-
*
|
|
142
|
-
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
143
|
-
*
|
|
144
|
-
* async: true is incompatible with noWrite, as async: true does not return the resulting document
|
|
145
|
-
*/
|
|
146
|
-
async: true
|
|
147
|
-
}
|
|
148
|
-
|
|
149
233
|
/** @internal */
|
|
150
234
|
export declare type AttributeSet = {
|
|
151
235
|
[key: string]: Any
|
|
@@ -505,6 +589,12 @@ export declare class ConnectionFailedError extends Error {
|
|
|
505
589
|
readonly name = 'ConnectionFailedError'
|
|
506
590
|
}
|
|
507
591
|
|
|
592
|
+
/** @beta */
|
|
593
|
+
export declare interface ConstantAgentActionParam {
|
|
594
|
+
type: 'constant'
|
|
595
|
+
value: string
|
|
596
|
+
}
|
|
597
|
+
|
|
508
598
|
/** @public */
|
|
509
599
|
export declare interface ContentSourceMap {
|
|
510
600
|
mappings: ContentSourceMapMappings
|
|
@@ -624,19 +714,6 @@ export declare type CreateAction = {
|
|
|
624
714
|
/** @public */
|
|
625
715
|
export declare const createClient: (config: ClientConfig) => SanityClient
|
|
626
716
|
|
|
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
717
|
/** @public */
|
|
641
718
|
export declare interface CurrentSanityUser {
|
|
642
719
|
id: string
|
|
@@ -788,6 +865,19 @@ export declare type DisconnectEvent = {
|
|
|
788
865
|
reason: string
|
|
789
866
|
}
|
|
790
867
|
|
|
868
|
+
/**
|
|
869
|
+
*
|
|
870
|
+
* Includes a LLM-friendly version of the document in the instruction
|
|
871
|
+
* @beta
|
|
872
|
+
* */
|
|
873
|
+
export declare interface DocumentAgentActionParam {
|
|
874
|
+
type: 'document'
|
|
875
|
+
/**
|
|
876
|
+
* If omitted, implicitly uses the documentId of the instruction target
|
|
877
|
+
*/
|
|
878
|
+
documentId?: string
|
|
879
|
+
}
|
|
880
|
+
|
|
791
881
|
/**
|
|
792
882
|
* Modifies an existing draft document.
|
|
793
883
|
* It applies the given patch to the document referenced by draftId.
|
|
@@ -831,12 +921,20 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
831
921
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
832
922
|
|
|
833
923
|
/**
|
|
834
|
-
*
|
|
924
|
+
*
|
|
925
|
+
* Includes a LLM-friendly version of the field value in the instruction
|
|
835
926
|
* @beta
|
|
836
|
-
*/
|
|
837
|
-
declare interface
|
|
838
|
-
|
|
839
|
-
|
|
927
|
+
* */
|
|
928
|
+
export declare interface FieldAgentActionParam {
|
|
929
|
+
type: 'field'
|
|
930
|
+
/**
|
|
931
|
+
* Examples: ['title'], ['array', {_key: 'arrayItemKey'}, 'field']
|
|
932
|
+
*/
|
|
933
|
+
path: AgentActionPath
|
|
934
|
+
/**
|
|
935
|
+
* If omitted, implicitly uses the documentId of the instruction target
|
|
936
|
+
*/
|
|
937
|
+
documentId?: string
|
|
840
938
|
}
|
|
841
939
|
|
|
842
940
|
/** @public */
|
|
@@ -906,89 +1004,53 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
906
1004
|
}
|
|
907
1005
|
|
|
908
1006
|
/** @beta */
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
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
|
-
}
|
|
1007
|
+
declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
1008
|
+
| GenerateExistingDocumentRequest
|
|
1009
|
+
| GenerateCreateDocumentRequest<T>
|
|
1010
|
+
) &
|
|
1011
|
+
GenerateRequestBase &
|
|
1012
|
+
AgentActionAsync
|
|
931
1013
|
|
|
932
1014
|
/**
|
|
933
|
-
*
|
|
934
|
-
* Includes a LLM-friendly version of the field value in the instruction
|
|
1015
|
+
* Instruction to create a new document
|
|
935
1016
|
* @beta
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
documentId?: string
|
|
1017
|
+
*/
|
|
1018
|
+
declare interface GenerateCreateDocumentRequest<
|
|
1019
|
+
T extends Record<string, Any> = Record<string, Any>,
|
|
1020
|
+
> {
|
|
1021
|
+
createDocument: {
|
|
1022
|
+
/** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
|
|
1023
|
+
_id?: string
|
|
1024
|
+
_type: string
|
|
1025
|
+
} & SanityDocumentStub<T>
|
|
1026
|
+
documentId?: never
|
|
947
1027
|
}
|
|
948
1028
|
|
|
949
1029
|
/**
|
|
950
|
-
*
|
|
1030
|
+
* Instruction for an existing document.
|
|
951
1031
|
* @beta
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
params?: Record<string, string>
|
|
1032
|
+
*/
|
|
1033
|
+
declare interface GenerateExistingDocumentRequest {
|
|
1034
|
+
documentId: string
|
|
1035
|
+
createDocument?: never
|
|
957
1036
|
}
|
|
958
1037
|
|
|
959
1038
|
/** @beta */
|
|
960
|
-
export declare type GenerateInstruction<T extends Record<string,
|
|
1039
|
+
export declare type GenerateInstruction<T extends Record<string, Any> = Record<string, Any>> =
|
|
961
1040
|
| GenerateSyncInstruction<T>
|
|
962
1041
|
| GenerateAsyncInstruction<T>
|
|
963
1042
|
|
|
964
|
-
/**
|
|
965
|
-
export declare type
|
|
966
|
-
| string
|
|
967
|
-
| GenerateConstantInstructionParam
|
|
968
|
-
| GenerateFieldInstructionParam
|
|
969
|
-
| GenerateDocumentInstructionParam
|
|
970
|
-
| GenerateGroqInstructionParam
|
|
1043
|
+
/** @beta */
|
|
1044
|
+
export declare type GenerateOperation = 'set' | 'append' | 'mixed'
|
|
971
1045
|
|
|
972
|
-
/**
|
|
973
|
-
|
|
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 {
|
|
1046
|
+
/** @beta */
|
|
1047
|
+
declare interface GenerateRequestBase extends AgentActionRequestBase {
|
|
986
1048
|
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
987
1049
|
schemaId: string
|
|
988
|
-
/** string template using $variable
|
|
1050
|
+
/** string template using $variable */
|
|
989
1051
|
instruction: string
|
|
990
1052
|
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
991
|
-
instructionParams?:
|
|
1053
|
+
instructionParams?: AgentActionParams
|
|
992
1054
|
/**
|
|
993
1055
|
* Target defines which parts of the document will be affected by the instruction.
|
|
994
1056
|
* It can be an array, so multiple parts of the document can be separately configured in detail.
|
|
@@ -1000,106 +1062,21 @@ declare interface GenerateRequestBase {
|
|
|
1000
1062
|
* - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
|
|
1001
1063
|
* It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
|
|
1002
1064
|
*
|
|
1003
|
-
* @see
|
|
1065
|
+
* @see AgentActionRequestBase#conditionalPaths
|
|
1004
1066
|
*/
|
|
1005
1067
|
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
1068
|
}
|
|
1073
1069
|
|
|
1074
1070
|
/** @beta */
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1071
|
+
declare type GenerateSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
1072
|
+
| GenerateExistingDocumentRequest
|
|
1073
|
+
| GenerateCreateDocumentRequest<T>
|
|
1074
|
+
) &
|
|
1075
|
+
GenerateRequestBase &
|
|
1076
|
+
AgentActionSync
|
|
1078
1077
|
|
|
1079
|
-
/**
|
|
1080
|
-
|
|
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
|
|
1078
|
+
/** @beta */
|
|
1079
|
+
export declare interface GenerateTarget extends AgentActionTarget_2 {
|
|
1103
1080
|
/**
|
|
1104
1081
|
* Sets the default operation for all paths in the target.
|
|
1105
1082
|
* Generate runs in `'mixed'` operation mode by default:
|
|
@@ -1128,24 +1105,11 @@ declare interface GenerateTarget {
|
|
|
1128
1105
|
* To insert in the middle of the array, use `target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append'}`.
|
|
1129
1106
|
* Here, the output of the instruction will be appended after the array item with key `'appendAfterKey'`.
|
|
1130
1107
|
*
|
|
1131
|
-
* @see #
|
|
1108
|
+
* @see #AgentActionTargetInclude.operation
|
|
1132
1109
|
* @see #include
|
|
1133
|
-
* @see #
|
|
1110
|
+
* @see #AgentActionTargetInclude.include
|
|
1134
1111
|
*/
|
|
1135
1112
|
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
1113
|
/**
|
|
1150
1114
|
* By default, all children up to `target.maxPathDepth` are included.
|
|
1151
1115
|
*
|
|
@@ -1153,23 +1117,11 @@ declare interface GenerateTarget {
|
|
|
1153
1117
|
*
|
|
1154
1118
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
1155
1119
|
*/
|
|
1156
|
-
include?: (
|
|
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
|
|
1120
|
+
include?: (AgentActionPathSegment_2 | GenerateTargetInclude)[]
|
|
1169
1121
|
}
|
|
1170
1122
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1123
|
+
/** @beta */
|
|
1124
|
+
export declare interface GenerateTargetInclude extends AgentActionTargetInclude {
|
|
1173
1125
|
/**
|
|
1174
1126
|
* Sets the operation for this path, and all its children.
|
|
1175
1127
|
* This overrides any operation set parents or the root target.
|
|
@@ -1184,30 +1136,18 @@ declare interface GenerateTargetInclude {
|
|
|
1184
1136
|
*
|
|
1185
1137
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
1186
1138
|
*/
|
|
1187
|
-
include?: (
|
|
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
|
|
1139
|
+
include?: (AgentActionPathSegment_2 | GenerateTargetInclude)[]
|
|
1200
1140
|
}
|
|
1201
1141
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1142
|
+
/**
|
|
1143
|
+
* Includes a LLM-friendly version of GROQ query result in the instruction
|
|
1144
|
+
* @beta
|
|
1145
|
+
* */
|
|
1146
|
+
export declare interface GroqAgentActionParam {
|
|
1147
|
+
type: 'groq'
|
|
1148
|
+
query: string
|
|
1149
|
+
params?: Record<string, string>
|
|
1150
|
+
}
|
|
1211
1151
|
|
|
1212
1152
|
/** @public */
|
|
1213
1153
|
export declare type HttpRequest = {
|
|
@@ -1651,6 +1591,18 @@ declare class ObservableAgentsActionClient {
|
|
|
1651
1591
|
generate<DocumentShape extends Record<string, Any>>(
|
|
1652
1592
|
request: GenerateSyncInstruction<DocumentShape>,
|
|
1653
1593
|
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1594
|
+
transform(request: TransformDocumentAsync): Observable<{
|
|
1595
|
+
_id: string
|
|
1596
|
+
}>
|
|
1597
|
+
transform<DocumentShape extends Record<string, Any>>(
|
|
1598
|
+
request: TransformDocumentSync,
|
|
1599
|
+
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1600
|
+
translate(request: TranslateDocumentAsync): Observable<{
|
|
1601
|
+
_id: string
|
|
1602
|
+
}>
|
|
1603
|
+
translate<DocumentShape extends Record<string, Any>>(
|
|
1604
|
+
request: TranslateDocumentSync,
|
|
1605
|
+
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1654
1606
|
}
|
|
1655
1607
|
|
|
1656
1608
|
/** @internal */
|
|
@@ -3293,13 +3245,6 @@ export declare type SanityDocumentStub<T extends Record<string, Any> = Record<st
|
|
|
3293
3245
|
_type: string
|
|
3294
3246
|
}
|
|
3295
3247
|
|
|
3296
|
-
/** @public */
|
|
3297
|
-
declare type SanityDocumentStub_2<T extends Record<string, Any_2> = Record<string, Any_2>> = {
|
|
3298
|
-
[P in keyof T]: T[P]
|
|
3299
|
-
} & {
|
|
3300
|
-
_type: string
|
|
3301
|
-
}
|
|
3302
|
-
|
|
3303
3248
|
/** @internal */
|
|
3304
3249
|
export declare interface SanityImageAssetDocument extends SanityAssetDocument {
|
|
3305
3250
|
metadata: {
|
|
@@ -3476,29 +3421,6 @@ export {StudioBaseUrl}
|
|
|
3476
3421
|
|
|
3477
3422
|
export {StudioUrl}
|
|
3478
3423
|
|
|
3479
|
-
declare interface Sync {
|
|
3480
|
-
/**
|
|
3481
|
-
* By default, noWrite: false.
|
|
3482
|
-
* Write enabled operations will mutate the target document, and emit AI presence in the studio.
|
|
3483
|
-
*
|
|
3484
|
-
* When noWrite: true, the api will not mutate any documents nor emit presence.
|
|
3485
|
-
* Ie, when true, no changes will be made to content-lake
|
|
3486
|
-
*
|
|
3487
|
-
* noWrite: true is incompatible with async: true,
|
|
3488
|
-
* as noWrite implies that you will use the return value of the operation
|
|
3489
|
-
*/
|
|
3490
|
-
noWrite?: boolean
|
|
3491
|
-
/**
|
|
3492
|
-
* When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
|
|
3493
|
-
* The instruction operation will carry on in the background.
|
|
3494
|
-
*
|
|
3495
|
-
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
3496
|
-
*
|
|
3497
|
-
* async: true is incompatible with noWrite: true, as async: true does not return the resulting document
|
|
3498
|
-
*/
|
|
3499
|
-
async?: false
|
|
3500
|
-
}
|
|
3501
|
-
|
|
3502
3424
|
/** @public */
|
|
3503
3425
|
export declare type SyncTag = `s1:${string}`
|
|
3504
3426
|
|
|
@@ -3599,6 +3521,161 @@ export declare type TransactionMutationOptions =
|
|
|
3599
3521
|
| TransactionAllDocumentsMutationOptions
|
|
3600
3522
|
| TransactionAllDocumentIdsMutationOptions
|
|
3601
3523
|
|
|
3524
|
+
/** @beta */
|
|
3525
|
+
export declare type TransformDocument = TransformDocumentSync | TransformDocumentAsync
|
|
3526
|
+
|
|
3527
|
+
/** @beta */
|
|
3528
|
+
declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
3529
|
+
|
|
3530
|
+
/** @beta */
|
|
3531
|
+
declare type TransformDocumentSync = TransformRequestBase & AgentActionSync
|
|
3532
|
+
|
|
3533
|
+
/** @beta */
|
|
3534
|
+
declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
3535
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
3536
|
+
schemaId: string
|
|
3537
|
+
documentId: string
|
|
3538
|
+
targetDocument?: TransformTargetDocument
|
|
3539
|
+
/** string template using $variable */
|
|
3540
|
+
transformation: string
|
|
3541
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
3542
|
+
transformationParams?: AgentActionParams
|
|
3543
|
+
/**
|
|
3544
|
+
* Target defines which parts of the document will be affected by the instruction.
|
|
3545
|
+
* It can be an array, so multiple parts of the document can be separately configured in detail.
|
|
3546
|
+
*
|
|
3547
|
+
* Omitting target implies that the document itself is the root.
|
|
3548
|
+
*
|
|
3549
|
+
* Notes:
|
|
3550
|
+
* - instruction can only affect fields up to `maxPathDepth`
|
|
3551
|
+
* - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
|
|
3552
|
+
* It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
|
|
3553
|
+
*
|
|
3554
|
+
* @see AgentActionRequestBase#conditionalPaths
|
|
3555
|
+
*/
|
|
3556
|
+
target?: TransformTarget | TransformTarget[]
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
/** @beta */
|
|
3560
|
+
export declare interface TransformTarget extends AgentActionTarget_2 {
|
|
3561
|
+
/** string template using $variable from instructionParams */
|
|
3562
|
+
transformation?: string
|
|
3563
|
+
/**
|
|
3564
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
3565
|
+
*
|
|
3566
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
3567
|
+
*
|
|
3568
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
3569
|
+
*/
|
|
3570
|
+
include?: (AgentActionPathSegment_2 | TransformTargetInclude)[]
|
|
3571
|
+
}
|
|
3572
|
+
|
|
3573
|
+
/** @beta */
|
|
3574
|
+
export declare type TransformTargetDocument =
|
|
3575
|
+
| {
|
|
3576
|
+
operation: 'get'
|
|
3577
|
+
_id: string
|
|
3578
|
+
}
|
|
3579
|
+
| {
|
|
3580
|
+
operation: 'create'
|
|
3581
|
+
_id?: string
|
|
3582
|
+
}
|
|
3583
|
+
| {
|
|
3584
|
+
operation: 'createIfNotExists'
|
|
3585
|
+
_id: string
|
|
3586
|
+
}
|
|
3587
|
+
| {
|
|
3588
|
+
operation: 'createOrReplace'
|
|
3589
|
+
_id: string
|
|
3590
|
+
}
|
|
3591
|
+
|
|
3592
|
+
/** @beta */
|
|
3593
|
+
export declare interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
3594
|
+
/** string template using $variable from instructionParams */
|
|
3595
|
+
transformation?: string
|
|
3596
|
+
/**
|
|
3597
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
3598
|
+
*
|
|
3599
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
3600
|
+
*
|
|
3601
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
3602
|
+
*/
|
|
3603
|
+
include?: (AgentActionPathSegment_2 | TransformTargetInclude)[]
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
/** @beta */
|
|
3607
|
+
export declare type TranslateDocument = TranslateDocumentSync | TranslateDocumentAsync
|
|
3608
|
+
|
|
3609
|
+
/** @beta */
|
|
3610
|
+
declare type TranslateDocumentAsync = TranslateRequestBase & AgentActionAsync
|
|
3611
|
+
|
|
3612
|
+
/** @beta */
|
|
3613
|
+
declare type TranslateDocumentSync = TranslateRequestBase & AgentActionSync
|
|
3614
|
+
|
|
3615
|
+
/** @beta */
|
|
3616
|
+
declare interface TranslateLanguage {
|
|
3617
|
+
id: string
|
|
3618
|
+
title?: string
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3621
|
+
/** @beta */
|
|
3622
|
+
declare interface TranslateRequestBase extends AgentActionRequestBase {
|
|
3623
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
3624
|
+
schemaId: string
|
|
3625
|
+
documentId: string
|
|
3626
|
+
targetDocument?: TransformTargetDocument
|
|
3627
|
+
fromLanguage?: TranslateLanguage
|
|
3628
|
+
toLanguage: TranslateLanguage
|
|
3629
|
+
/** string template using $variable */
|
|
3630
|
+
styleGuide?: string
|
|
3631
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
3632
|
+
styleGuideParams?: AgentActionParams
|
|
3633
|
+
/**
|
|
3634
|
+
* Target defines which parts of the document will be affected by the instruction.
|
|
3635
|
+
* It can be an array, so multiple parts of the document can be separately configured in detail.
|
|
3636
|
+
*
|
|
3637
|
+
* Omitting target implies that the document itself is the root.
|
|
3638
|
+
*
|
|
3639
|
+
* Notes:
|
|
3640
|
+
* - instruction can only affect fields up to `maxPathDepth`
|
|
3641
|
+
* - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
|
|
3642
|
+
* It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
|
|
3643
|
+
*
|
|
3644
|
+
* @see AgentActionRequestBase#conditionalPaths
|
|
3645
|
+
*/
|
|
3646
|
+
target?: TranslateTarget | TranslateTarget[]
|
|
3647
|
+
languageFieldPath?: AgentActionPathSegment | AgentActionPath_2
|
|
3648
|
+
protectedPhrases?: string[]
|
|
3649
|
+
}
|
|
3650
|
+
|
|
3651
|
+
/** @beta */
|
|
3652
|
+
export declare interface TranslateTarget extends AgentActionTarget {
|
|
3653
|
+
/** string template using $variable from instructionParams */
|
|
3654
|
+
styleGuide?: string
|
|
3655
|
+
/**
|
|
3656
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
3657
|
+
*
|
|
3658
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
3659
|
+
*
|
|
3660
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
3661
|
+
*/
|
|
3662
|
+
include?: (AgentActionPathSegment | TranslateTargetInclude)[]
|
|
3663
|
+
}
|
|
3664
|
+
|
|
3665
|
+
/** @beta */
|
|
3666
|
+
export declare interface TranslateTargetInclude extends AgentActionTargetInclude {
|
|
3667
|
+
/** string template using $variable from instructionParams */
|
|
3668
|
+
styleGuide?: string
|
|
3669
|
+
/**
|
|
3670
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
3671
|
+
*
|
|
3672
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
3673
|
+
*
|
|
3674
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
3675
|
+
*/
|
|
3676
|
+
include?: (AgentActionPathSegment | TranslateTargetInclude)[]
|
|
3677
|
+
}
|
|
3678
|
+
|
|
3602
3679
|
/** @public */
|
|
3603
3680
|
export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
3604
3681
|
filterResponse: false
|