@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.d.cts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import type {
|
|
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'
|
|
2
8
|
import type {ContentSourceMapDocuments as ContentSourceMapDocuments_2} from '@sanity/client/csm'
|
|
3
9
|
import {ContentSourceMapParsedPath} from '@sanity/client/csm'
|
|
4
10
|
import {ContentSourceMapParsedPathKeyedSegment} from '@sanity/client/csm'
|
|
5
11
|
import {Observable} from 'rxjs'
|
|
6
12
|
import {Requester} from 'get-it'
|
|
7
13
|
import type {ResolveStudioUrl} from '@sanity/client/csm'
|
|
8
|
-
import type {SanityDocumentStub as SanityDocumentStub_2} from '@sanity/client'
|
|
9
14
|
import {StudioBaseRoute} from '@sanity/client/csm'
|
|
10
15
|
import {StudioBaseUrl} from '@sanity/client/csm'
|
|
11
16
|
import {StudioUrl} from '@sanity/client/csm'
|
|
@@ -41,6 +46,27 @@ export declare interface ActionErrorItem {
|
|
|
41
46
|
index: number
|
|
42
47
|
}
|
|
43
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
|
+
|
|
44
70
|
/** @public */
|
|
45
71
|
declare class AgentActionsClient {
|
|
46
72
|
#private
|
|
@@ -51,8 +77,82 @@ declare class AgentActionsClient {
|
|
|
51
77
|
generate<DocumentShape extends Record<string, Any>>(
|
|
52
78
|
request: GenerateSyncInstruction<DocumentShape>,
|
|
53
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>
|
|
92
|
+
}
|
|
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
|
|
54
143
|
}
|
|
55
144
|
|
|
145
|
+
/** @beta */
|
|
146
|
+
declare type AgentActionTypeConfig =
|
|
147
|
+
| {
|
|
148
|
+
include: string[]
|
|
149
|
+
exclude?: never
|
|
150
|
+
}
|
|
151
|
+
| {
|
|
152
|
+
exclude: string[]
|
|
153
|
+
include?: never
|
|
154
|
+
}
|
|
155
|
+
|
|
56
156
|
/** @internal */
|
|
57
157
|
export declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
|
|
58
158
|
returnFirst: false
|
|
@@ -130,18 +230,6 @@ export declare class AssetsClient {
|
|
|
130
230
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
131
231
|
}
|
|
132
232
|
|
|
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
233
|
/** @internal */
|
|
146
234
|
export declare type AttributeSet = {
|
|
147
235
|
[key: string]: Any
|
|
@@ -501,6 +589,12 @@ export declare class ConnectionFailedError extends Error {
|
|
|
501
589
|
readonly name = 'ConnectionFailedError'
|
|
502
590
|
}
|
|
503
591
|
|
|
592
|
+
/** @beta */
|
|
593
|
+
export declare interface ConstantAgentActionParam {
|
|
594
|
+
type: 'constant'
|
|
595
|
+
value: string
|
|
596
|
+
}
|
|
597
|
+
|
|
504
598
|
/** @public */
|
|
505
599
|
export declare interface ContentSourceMap {
|
|
506
600
|
mappings: ContentSourceMapMappings
|
|
@@ -624,19 +718,6 @@ export declare type CreateAction = {
|
|
|
624
718
|
*/
|
|
625
719
|
export declare const createClient: (config: ClientConfig) => SanityClient
|
|
626
720
|
|
|
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
721
|
/** @public */
|
|
641
722
|
export declare interface CurrentSanityUser {
|
|
642
723
|
id: string
|
|
@@ -788,6 +869,19 @@ export declare type DisconnectEvent = {
|
|
|
788
869
|
reason: string
|
|
789
870
|
}
|
|
790
871
|
|
|
872
|
+
/**
|
|
873
|
+
*
|
|
874
|
+
* Includes a LLM-friendly version of the document in the instruction
|
|
875
|
+
* @beta
|
|
876
|
+
* */
|
|
877
|
+
export declare interface DocumentAgentActionParam {
|
|
878
|
+
type: 'document'
|
|
879
|
+
/**
|
|
880
|
+
* If omitted, implicitly uses the documentId of the instruction target
|
|
881
|
+
*/
|
|
882
|
+
documentId?: string
|
|
883
|
+
}
|
|
884
|
+
|
|
791
885
|
/**
|
|
792
886
|
* Modifies an existing draft document.
|
|
793
887
|
* It applies the given patch to the document referenced by draftId.
|
|
@@ -831,12 +925,20 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
831
925
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
832
926
|
|
|
833
927
|
/**
|
|
834
|
-
*
|
|
928
|
+
*
|
|
929
|
+
* Includes a LLM-friendly version of the field value in the instruction
|
|
835
930
|
* @beta
|
|
836
|
-
*/
|
|
837
|
-
declare interface
|
|
838
|
-
|
|
839
|
-
|
|
931
|
+
* */
|
|
932
|
+
export declare interface FieldAgentActionParam {
|
|
933
|
+
type: 'field'
|
|
934
|
+
/**
|
|
935
|
+
* Examples: ['title'], ['array', {_key: 'arrayItemKey'}, 'field']
|
|
936
|
+
*/
|
|
937
|
+
path: AgentActionPath
|
|
938
|
+
/**
|
|
939
|
+
* If omitted, implicitly uses the documentId of the instruction target
|
|
940
|
+
*/
|
|
941
|
+
documentId?: string
|
|
840
942
|
}
|
|
841
943
|
|
|
842
944
|
/** @public */
|
|
@@ -906,89 +1008,53 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
906
1008
|
}
|
|
907
1009
|
|
|
908
1010
|
/** @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
|
-
}
|
|
1011
|
+
declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
1012
|
+
| GenerateExistingDocumentRequest
|
|
1013
|
+
| GenerateCreateDocumentRequest<T>
|
|
1014
|
+
) &
|
|
1015
|
+
GenerateRequestBase &
|
|
1016
|
+
AgentActionAsync
|
|
931
1017
|
|
|
932
1018
|
/**
|
|
933
|
-
*
|
|
934
|
-
* Includes a LLM-friendly version of the field value in the instruction
|
|
1019
|
+
* Instruction to create a new document
|
|
935
1020
|
* @beta
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
documentId?: string
|
|
1021
|
+
*/
|
|
1022
|
+
declare interface GenerateCreateDocumentRequest<
|
|
1023
|
+
T extends Record<string, Any> = Record<string, Any>,
|
|
1024
|
+
> {
|
|
1025
|
+
createDocument: {
|
|
1026
|
+
/** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
|
|
1027
|
+
_id?: string
|
|
1028
|
+
_type: string
|
|
1029
|
+
} & SanityDocumentStub<T>
|
|
1030
|
+
documentId?: never
|
|
947
1031
|
}
|
|
948
1032
|
|
|
949
1033
|
/**
|
|
950
|
-
*
|
|
1034
|
+
* Instruction for an existing document.
|
|
951
1035
|
* @beta
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
params?: Record<string, string>
|
|
1036
|
+
*/
|
|
1037
|
+
declare interface GenerateExistingDocumentRequest {
|
|
1038
|
+
documentId: string
|
|
1039
|
+
createDocument?: never
|
|
957
1040
|
}
|
|
958
1041
|
|
|
959
1042
|
/** @beta */
|
|
960
|
-
export declare type GenerateInstruction<T extends Record<string,
|
|
1043
|
+
export declare type GenerateInstruction<T extends Record<string, Any> = Record<string, Any>> =
|
|
961
1044
|
| GenerateSyncInstruction<T>
|
|
962
1045
|
| GenerateAsyncInstruction<T>
|
|
963
1046
|
|
|
964
|
-
/**
|
|
965
|
-
export declare type
|
|
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
|
-
}
|
|
1047
|
+
/** @beta */
|
|
1048
|
+
export declare type GenerateOperation = 'set' | 'append' | 'mixed'
|
|
984
1049
|
|
|
985
|
-
|
|
1050
|
+
/** @beta */
|
|
1051
|
+
declare interface GenerateRequestBase extends AgentActionRequestBase {
|
|
986
1052
|
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
987
1053
|
schemaId: string
|
|
988
|
-
/** string template using $variable
|
|
1054
|
+
/** string template using $variable */
|
|
989
1055
|
instruction: string
|
|
990
1056
|
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
991
|
-
instructionParams?:
|
|
1057
|
+
instructionParams?: AgentActionParams
|
|
992
1058
|
/**
|
|
993
1059
|
* Target defines which parts of the document will be affected by the instruction.
|
|
994
1060
|
* It can be an array, so multiple parts of the document can be separately configured in detail.
|
|
@@ -1000,106 +1066,21 @@ declare interface GenerateRequestBase {
|
|
|
1000
1066
|
* - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
|
|
1001
1067
|
* It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
|
|
1002
1068
|
*
|
|
1003
|
-
* @see
|
|
1069
|
+
* @see AgentActionRequestBase#conditionalPaths
|
|
1004
1070
|
*/
|
|
1005
1071
|
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
1072
|
}
|
|
1073
1073
|
|
|
1074
1074
|
/** @beta */
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1075
|
+
declare type GenerateSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
1076
|
+
| GenerateExistingDocumentRequest
|
|
1077
|
+
| GenerateCreateDocumentRequest<T>
|
|
1078
|
+
) &
|
|
1079
|
+
GenerateRequestBase &
|
|
1080
|
+
AgentActionSync
|
|
1078
1081
|
|
|
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
|
|
1082
|
+
/** @beta */
|
|
1083
|
+
export declare interface GenerateTarget extends AgentActionTarget_2 {
|
|
1103
1084
|
/**
|
|
1104
1085
|
* Sets the default operation for all paths in the target.
|
|
1105
1086
|
* Generate runs in `'mixed'` operation mode by default:
|
|
@@ -1128,24 +1109,11 @@ declare interface GenerateTarget {
|
|
|
1128
1109
|
* To insert in the middle of the array, use `target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append'}`.
|
|
1129
1110
|
* Here, the output of the instruction will be appended after the array item with key `'appendAfterKey'`.
|
|
1130
1111
|
*
|
|
1131
|
-
* @see #
|
|
1112
|
+
* @see #AgentActionTargetInclude.operation
|
|
1132
1113
|
* @see #include
|
|
1133
|
-
* @see #
|
|
1114
|
+
* @see #AgentActionTargetInclude.include
|
|
1134
1115
|
*/
|
|
1135
1116
|
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
1117
|
/**
|
|
1150
1118
|
* By default, all children up to `target.maxPathDepth` are included.
|
|
1151
1119
|
*
|
|
@@ -1153,23 +1121,11 @@ declare interface GenerateTarget {
|
|
|
1153
1121
|
*
|
|
1154
1122
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
1155
1123
|
*/
|
|
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
|
|
1124
|
+
include?: (AgentActionPathSegment_2 | GenerateTargetInclude)[]
|
|
1169
1125
|
}
|
|
1170
1126
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1127
|
+
/** @beta */
|
|
1128
|
+
export declare interface GenerateTargetInclude extends AgentActionTargetInclude {
|
|
1173
1129
|
/**
|
|
1174
1130
|
* Sets the operation for this path, and all its children.
|
|
1175
1131
|
* This overrides any operation set parents or the root target.
|
|
@@ -1184,30 +1140,18 @@ declare interface GenerateTargetInclude {
|
|
|
1184
1140
|
*
|
|
1185
1141
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
1186
1142
|
*/
|
|
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
|
|
1143
|
+
include?: (AgentActionPathSegment_2 | GenerateTargetInclude)[]
|
|
1200
1144
|
}
|
|
1201
1145
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1146
|
+
/**
|
|
1147
|
+
* Includes a LLM-friendly version of GROQ query result in the instruction
|
|
1148
|
+
* @beta
|
|
1149
|
+
* */
|
|
1150
|
+
export declare interface GroqAgentActionParam {
|
|
1151
|
+
type: 'groq'
|
|
1152
|
+
query: string
|
|
1153
|
+
params?: Record<string, string>
|
|
1154
|
+
}
|
|
1211
1155
|
|
|
1212
1156
|
/** @public */
|
|
1213
1157
|
export declare type HttpRequest = {
|
|
@@ -1651,6 +1595,18 @@ declare class ObservableAgentsActionClient {
|
|
|
1651
1595
|
generate<DocumentShape extends Record<string, Any>>(
|
|
1652
1596
|
request: GenerateSyncInstruction<DocumentShape>,
|
|
1653
1597
|
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1598
|
+
transform(request: TransformDocumentAsync): Observable<{
|
|
1599
|
+
_id: string
|
|
1600
|
+
}>
|
|
1601
|
+
transform<DocumentShape extends Record<string, Any>>(
|
|
1602
|
+
request: TransformDocumentSync,
|
|
1603
|
+
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1604
|
+
translate(request: TranslateDocumentAsync): Observable<{
|
|
1605
|
+
_id: string
|
|
1606
|
+
}>
|
|
1607
|
+
translate<DocumentShape extends Record<string, Any>>(
|
|
1608
|
+
request: TranslateDocumentSync,
|
|
1609
|
+
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
1654
1610
|
}
|
|
1655
1611
|
|
|
1656
1612
|
/** @internal */
|
|
@@ -3469,29 +3425,6 @@ export {StudioBaseUrl}
|
|
|
3469
3425
|
|
|
3470
3426
|
export {StudioUrl}
|
|
3471
3427
|
|
|
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
3428
|
/** @public */
|
|
3496
3429
|
export declare type SyncTag = `s1:${string}`
|
|
3497
3430
|
|
|
@@ -3592,6 +3525,161 @@ export declare type TransactionMutationOptions =
|
|
|
3592
3525
|
| TransactionAllDocumentsMutationOptions
|
|
3593
3526
|
| TransactionAllDocumentIdsMutationOptions
|
|
3594
3527
|
|
|
3528
|
+
/** @beta */
|
|
3529
|
+
export declare type TransformDocument = TransformDocumentSync | TransformDocumentAsync
|
|
3530
|
+
|
|
3531
|
+
/** @beta */
|
|
3532
|
+
declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
3533
|
+
|
|
3534
|
+
/** @beta */
|
|
3535
|
+
declare type TransformDocumentSync = TransformRequestBase & AgentActionSync
|
|
3536
|
+
|
|
3537
|
+
/** @beta */
|
|
3538
|
+
declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
3539
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
3540
|
+
schemaId: string
|
|
3541
|
+
documentId: string
|
|
3542
|
+
targetDocument?: TransformTargetDocument
|
|
3543
|
+
/** string template using $variable */
|
|
3544
|
+
transformation: string
|
|
3545
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
3546
|
+
transformationParams?: AgentActionParams
|
|
3547
|
+
/**
|
|
3548
|
+
* Target defines which parts of the document will be affected by the instruction.
|
|
3549
|
+
* It can be an array, so multiple parts of the document can be separately configured in detail.
|
|
3550
|
+
*
|
|
3551
|
+
* Omitting target implies that the document itself is the root.
|
|
3552
|
+
*
|
|
3553
|
+
* Notes:
|
|
3554
|
+
* - instruction can only affect fields up to `maxPathDepth`
|
|
3555
|
+
* - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
|
|
3556
|
+
* It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
|
|
3557
|
+
*
|
|
3558
|
+
* @see AgentActionRequestBase#conditionalPaths
|
|
3559
|
+
*/
|
|
3560
|
+
target?: TransformTarget | TransformTarget[]
|
|
3561
|
+
}
|
|
3562
|
+
|
|
3563
|
+
/** @beta */
|
|
3564
|
+
export declare interface TransformTarget extends AgentActionTarget_2 {
|
|
3565
|
+
/** string template using $variable from instructionParams */
|
|
3566
|
+
transformation?: string
|
|
3567
|
+
/**
|
|
3568
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
3569
|
+
*
|
|
3570
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
3571
|
+
*
|
|
3572
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
3573
|
+
*/
|
|
3574
|
+
include?: (AgentActionPathSegment_2 | TransformTargetInclude)[]
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
/** @beta */
|
|
3578
|
+
export declare type TransformTargetDocument =
|
|
3579
|
+
| {
|
|
3580
|
+
operation: 'get'
|
|
3581
|
+
_id: string
|
|
3582
|
+
}
|
|
3583
|
+
| {
|
|
3584
|
+
operation: 'create'
|
|
3585
|
+
_id?: string
|
|
3586
|
+
}
|
|
3587
|
+
| {
|
|
3588
|
+
operation: 'createIfNotExists'
|
|
3589
|
+
_id: string
|
|
3590
|
+
}
|
|
3591
|
+
| {
|
|
3592
|
+
operation: 'createOrReplace'
|
|
3593
|
+
_id: string
|
|
3594
|
+
}
|
|
3595
|
+
|
|
3596
|
+
/** @beta */
|
|
3597
|
+
export declare interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
3598
|
+
/** string template using $variable from instructionParams */
|
|
3599
|
+
transformation?: string
|
|
3600
|
+
/**
|
|
3601
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
3602
|
+
*
|
|
3603
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
3604
|
+
*
|
|
3605
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
3606
|
+
*/
|
|
3607
|
+
include?: (AgentActionPathSegment_2 | TransformTargetInclude)[]
|
|
3608
|
+
}
|
|
3609
|
+
|
|
3610
|
+
/** @beta */
|
|
3611
|
+
export declare type TranslateDocument = TranslateDocumentSync | TranslateDocumentAsync
|
|
3612
|
+
|
|
3613
|
+
/** @beta */
|
|
3614
|
+
declare type TranslateDocumentAsync = TranslateRequestBase & AgentActionAsync
|
|
3615
|
+
|
|
3616
|
+
/** @beta */
|
|
3617
|
+
declare type TranslateDocumentSync = TranslateRequestBase & AgentActionSync
|
|
3618
|
+
|
|
3619
|
+
/** @beta */
|
|
3620
|
+
declare interface TranslateLanguage {
|
|
3621
|
+
id: string
|
|
3622
|
+
title?: string
|
|
3623
|
+
}
|
|
3624
|
+
|
|
3625
|
+
/** @beta */
|
|
3626
|
+
declare interface TranslateRequestBase extends AgentActionRequestBase {
|
|
3627
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
3628
|
+
schemaId: string
|
|
3629
|
+
documentId: string
|
|
3630
|
+
targetDocument?: TransformTargetDocument
|
|
3631
|
+
fromLanguage?: TranslateLanguage
|
|
3632
|
+
toLanguage: TranslateLanguage
|
|
3633
|
+
/** string template using $variable */
|
|
3634
|
+
styleGuide?: string
|
|
3635
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
3636
|
+
styleGuideParams?: AgentActionParams
|
|
3637
|
+
/**
|
|
3638
|
+
* Target defines which parts of the document will be affected by the instruction.
|
|
3639
|
+
* It can be an array, so multiple parts of the document can be separately configured in detail.
|
|
3640
|
+
*
|
|
3641
|
+
* Omitting target implies that the document itself is the root.
|
|
3642
|
+
*
|
|
3643
|
+
* Notes:
|
|
3644
|
+
* - instruction can only affect fields up to `maxPathDepth`
|
|
3645
|
+
* - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
|
|
3646
|
+
* It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
|
|
3647
|
+
*
|
|
3648
|
+
* @see AgentActionRequestBase#conditionalPaths
|
|
3649
|
+
*/
|
|
3650
|
+
target?: TranslateTarget | TranslateTarget[]
|
|
3651
|
+
languageFieldPath?: AgentActionPathSegment | AgentActionPath_2
|
|
3652
|
+
protectedPhrases?: string[]
|
|
3653
|
+
}
|
|
3654
|
+
|
|
3655
|
+
/** @beta */
|
|
3656
|
+
export declare interface TranslateTarget extends AgentActionTarget {
|
|
3657
|
+
/** string template using $variable from instructionParams */
|
|
3658
|
+
styleGuide?: string
|
|
3659
|
+
/**
|
|
3660
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
3661
|
+
*
|
|
3662
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
3663
|
+
*
|
|
3664
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
3665
|
+
*/
|
|
3666
|
+
include?: (AgentActionPathSegment | TranslateTargetInclude)[]
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
/** @beta */
|
|
3670
|
+
export declare interface TranslateTargetInclude extends AgentActionTargetInclude {
|
|
3671
|
+
/** string template using $variable from instructionParams */
|
|
3672
|
+
styleGuide?: string
|
|
3673
|
+
/**
|
|
3674
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
3675
|
+
*
|
|
3676
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
3677
|
+
*
|
|
3678
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
3679
|
+
*/
|
|
3680
|
+
include?: (AgentActionPathSegment | TranslateTargetInclude)[]
|
|
3681
|
+
}
|
|
3682
|
+
|
|
3595
3683
|
/** @public */
|
|
3596
3684
|
export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
3597
3685
|
filterResponse: false
|