@sanity/client 6.28.0-instruct.0 → 6.28.0-resources-projects.0

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.
@@ -1,178 +0,0 @@
1
- //Request shape
2
-
3
- import type {Any, SanityDocumentStub} from '@sanity/client'
4
-
5
- /** @beta */
6
- export interface ConstantInstructionParam {
7
- type: 'constant'
8
- value: string
9
- }
10
-
11
- /** @beta */
12
- export interface FieldInstructionParam {
13
- type: 'field'
14
- path: string
15
- }
16
-
17
- /** @beta */
18
- export interface GroqInstructionParam {
19
- type: 'groq'
20
- query: string
21
- params?: Record<string, string>
22
- }
23
-
24
- /** @beta */
25
- export type InstructionParam =
26
- | string
27
- | ConstantInstructionParam
28
- | FieldInstructionParam
29
- | GroqInstructionParam
30
-
31
- /** @beta */
32
- export type InstructionParams = Record<string, InstructionParam>
33
-
34
- interface AssistRequestBase {
35
- /** schemaId as reported by sanity deploy / sanity schema store */
36
- schemaId: string
37
- /** string template using $variable – more on this below under "Dynamic instruction" */
38
- instruction: string
39
- /** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
40
- instructionParams?: InstructionParams
41
- /**
42
- * Optional document path output target for the instruction.
43
- * When provided, the instruction will apply to this path in the document and its children.
44
- *
45
- * ## Examples
46
- * - `path: 'title'` will output to the title field in the document
47
- * - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
48
- */
49
- path?: string
50
-
51
- /**
52
- * Controls sub-paths in the document that can be output to.
53
- *
54
- * The string-paths are relative to the `path` param
55
- *
56
- * Note: these path strings are less strictly validated than the `path` param itself:
57
- * if an relative-path does not exist or is invalid, it will be silently ignored.
58
- *
59
- * @see AssistRequestBase#conditionalPaths
60
- * @see AssistRequestBase#outputTypes
61
- */
62
- relativeOutputPaths?: {include: string[]} | {exclude: string[]}
63
-
64
- /**
65
- * Controls which types the instruction is allowed to output to.
66
- *
67
- * @see AssistRequestBase#relativeOutputPaths
68
- * @see AssistRequestBase#conditionalPaths
69
- */
70
- outputTypes?: {include: string[]} | {exclude: string[]}
71
-
72
- /**
73
- * When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
74
- *
75
- * By default, AI Assist will not output to conditional `readOnly` and `hidden` fields,
76
- * ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
77
- *
78
- * `conditionalPaths` param allows setting the default conditional value for
79
- * `hidden` and `readOnly` to false,
80
- * or individually set `hidden` and `readOnly` state for individual document paths.
81
- *
82
- *
83
- * Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Assist,
84
- * and cannot be changed via conditionalPaths.
85
- *
86
- * conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
87
- *
88
- * @see AssistRequestBase#relativeOutputPaths
89
- * @see AssistRequestBase#outputTypes
90
- */
91
- conditionalPaths?: {
92
- defaultReadOnly?: boolean
93
- defaultHidden?: boolean
94
- paths?: {
95
- /** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
96
- path: string
97
- readOnly: boolean
98
- hidden: boolean
99
- }[]
100
- }
101
- }
102
-
103
- interface Sync {
104
- /**
105
- * By default, skipWrite: false.
106
- * Write enabled operations will mutate the target document, and emit AI presence in the studio.
107
- *
108
- * When skipWrite: true, the api will not mutate any documents nor emit presence.
109
- * Ie, when true, no changes will be made to content-lake
110
- *
111
- * skipWrite: true is incompatible with async: true,
112
- * as skipWrite implies that you will use the return value of the operation
113
- */
114
- skipWrite?: boolean
115
-
116
- /**
117
- * When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
118
- * The instruction operation will carry on in the background.
119
- *
120
- * When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
121
- *
122
- * async: true is incompatible with skipWrite: true, as async: true does not return the resulting document
123
- */
124
- async?: false
125
- }
126
-
127
- interface Async {
128
- /**
129
- * When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
130
- * The instruction operation will carry on in the background.
131
- *
132
- * When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
133
- *
134
- * async: true is incompatible with skipWrite, as async: true does not return the resulting document
135
- */
136
- async: true
137
- }
138
-
139
- /**
140
- * Instruction for an existing document.
141
- * @beta
142
- */
143
- interface ExistingDocumentRequest {
144
- documentId: string
145
- }
146
-
147
- /**
148
- * Instruction to create a new document
149
- * @beta
150
- */
151
- interface CreateDocumentRequest<T extends Record<string, Any> = Record<string, Any>> {
152
- createDocument: {
153
- /** if no _id is provided, one will be generated. _id is always returned when the requests succeed */
154
- _id?: string
155
- _type: string
156
- } & SanityDocumentStub<T>
157
- }
158
-
159
- /** @beta */
160
- export type AssistSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
161
- | ExistingDocumentRequest
162
- | CreateDocumentRequest<T>
163
- ) &
164
- AssistRequestBase &
165
- Sync
166
-
167
- /** @beta */
168
- export type AssistAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
169
- | ExistingDocumentRequest
170
- | CreateDocumentRequest<T>
171
- ) &
172
- AssistRequestBase &
173
- Async
174
-
175
- /** @beta */
176
- export type AssistInstruction<T extends Record<string, Any> = Record<string, Any>> =
177
- | AssistSyncInstruction<T>
178
- | AssistAsyncInstruction<T>