@sanity/assist 5.0.4 → 6.0.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.
- package/LICENSE +1 -1
- package/README.md +28 -254
- package/dist/index.d.ts +322 -410
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3181 -2649
- package/dist/index.js.map +1 -1
- package/package.json +38 -78
- package/dist/index.cjs +0 -4239
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -791
- package/sanity.json +0 -8
- package/src/_lib/connector/ConnectFromRegion.tsx +0 -25
- package/src/_lib/connector/ConnectToRegion.tsx +0 -23
- package/src/_lib/connector/ConnectorRegion.tsx +0 -24
- package/src/_lib/connector/ConnectorsProvider.tsx +0 -20
- package/src/_lib/connector/ConnectorsStore.ts +0 -122
- package/src/_lib/connector/ConnectorsStoreContext.ts +0 -5
- package/src/_lib/connector/helpers.ts +0 -5
- package/src/_lib/connector/index.ts +0 -9
- package/src/_lib/connector/mapConnectorToLine.ts +0 -83
- package/src/_lib/connector/types.ts +0 -56
- package/src/_lib/connector/useConnectorsStore.ts +0 -14
- package/src/_lib/connector/useRegionRects.ts +0 -142
- package/src/_lib/fixedListenQuery.ts +0 -101
- package/src/_lib/form/DocumentForm.tsx +0 -201
- package/src/_lib/form/constants.ts +0 -1
- package/src/_lib/form/helpers.ts +0 -32
- package/src/_lib/form/index.ts +0 -1
- package/src/_lib/randomKey.ts +0 -29
- package/src/_lib/useListeningQuery.ts +0 -62
- package/src/_lib/usePrevious.ts +0 -9
- package/src/assistConnectors/AssistConnectorsOverlay.tsx +0 -133
- package/src/assistConnectors/ConnectorPath.tsx +0 -63
- package/src/assistConnectors/draw/arrowPath.ts +0 -9
- package/src/assistConnectors/draw/connectorPath.ts +0 -142
- package/src/assistConnectors/index.ts +0 -1
- package/src/assistDocument/AssistDocumentContext.tsx +0 -51
- package/src/assistDocument/AssistDocumentContextProvider.tsx +0 -17
- package/src/assistDocument/AssistDocumentInput.tsx +0 -61
- package/src/assistDocument/AssistDocumentLayout.tsx +0 -12
- package/src/assistDocument/RequestRunInstructionProvider.tsx +0 -61
- package/src/assistDocument/components/AssistDocumentForm.tsx +0 -287
- package/src/assistDocument/components/AssistTypeContext.tsx +0 -7
- package/src/assistDocument/components/FieldRefPreview.tsx +0 -26
- package/src/assistDocument/components/InstructionsArrayField.tsx +0 -8
- package/src/assistDocument/components/InstructionsArrayInput.tsx +0 -27
- package/src/assistDocument/components/SelectedFieldContext.tsx +0 -10
- package/src/assistDocument/components/generic/HiddenFieldTitle.tsx +0 -5
- package/src/assistDocument/components/helpers.ts +0 -21
- package/src/assistDocument/components/instruction/BackToInstructionsLink.tsx +0 -32
- package/src/assistDocument/components/instruction/FieldRefInput.tsx +0 -54
- package/src/assistDocument/components/instruction/InstructionInput.tsx +0 -89
- package/src/assistDocument/components/instruction/InstructionOutputField.tsx +0 -46
- package/src/assistDocument/components/instruction/InstructionOutputInput.tsx +0 -206
- package/src/assistDocument/components/instruction/PromptInput.tsx +0 -59
- package/src/assistDocument/components/instruction/appearance/IconInput.tsx +0 -46
- package/src/assistDocument/components/instruction/appearance/InstructionVisibility.tsx +0 -37
- package/src/assistDocument/hooks/useAssistDocumentContextValue.tsx +0 -127
- package/src/assistDocument/hooks/useDocumentState.ts +0 -6
- package/src/assistDocument/hooks/useInstructionToaster.tsx +0 -75
- package/src/assistDocument/hooks/useStudioAssistDocument.ts +0 -99
- package/src/assistDocument/index.ts +0 -1
- package/src/assistFormComponents/AssistField.tsx +0 -63
- package/src/assistFormComponents/AssistFormBlock.tsx +0 -31
- package/src/assistFormComponents/AssistInlineFormBlock.tsx +0 -13
- package/src/assistFormComponents/AssistItem.tsx +0 -21
- package/src/assistFormComponents/validation/listItem.tsx +0 -63
- package/src/assistFormComponents/validation/validationList.tsx +0 -90
- package/src/assistInspector/AssistInspector.tsx +0 -419
- package/src/assistInspector/FieldAutocomplete.tsx +0 -146
- package/src/assistInspector/InstructionTaskHistoryButton.tsx +0 -262
- package/src/assistInspector/constants.ts +0 -1
- package/src/assistInspector/helpers.ts +0 -211
- package/src/assistInspector/index.ts +0 -27
- package/src/assistLayout/AiAssistanceConfigContext.tsx +0 -32
- package/src/assistLayout/AiAssistanceConfigProvider.tsx +0 -98
- package/src/assistLayout/AssistLayout.tsx +0 -39
- package/src/assistLayout/RunInstructionProvider.tsx +0 -278
- package/src/assistLayout/fieldRefCache.tsx +0 -34
- package/src/assistTypes.ts +0 -83
- package/src/components/AssistFeatureBadge.tsx +0 -9
- package/src/components/FadeInContent.tsx +0 -40
- package/src/components/HideReferenceChangedBannerInput.tsx +0 -25
- package/src/components/ImageContext.tsx +0 -85
- package/src/components/SafeValueInput.tsx +0 -74
- package/src/components/TimeAgo.tsx +0 -18
- package/src/constants.ts +0 -20
- package/src/fieldActions/PrivateIcon.tsx +0 -20
- package/src/fieldActions/assistFieldActions.tsx +0 -320
- package/src/fieldActions/customFieldActions.tsx +0 -333
- package/src/fieldActions/generateCaptionActions.tsx +0 -77
- package/src/fieldActions/generateImageActions.tsx +0 -58
- package/src/fieldActions/useUserInput.ts +0 -107
- package/src/globals.d.ts +0 -4
- package/src/helpers/assistSupported.ts +0 -49
- package/src/helpers/conditionalMembers.test.ts +0 -319
- package/src/helpers/conditionalMembers.ts +0 -134
- package/src/helpers/ids.test.ts +0 -28
- package/src/helpers/ids.ts +0 -23
- package/src/helpers/misc.ts +0 -25
- package/src/helpers/styleguide.ts +0 -24
- package/src/helpers/typeUtils.ts +0 -60
- package/src/helpers/useAssistSupported.ts +0 -8
- package/src/index.ts +0 -26
- package/src/onboarding/FirstAssistedPathProvider.tsx +0 -30
- package/src/onboarding/InspectorOnboarding.tsx +0 -47
- package/src/onboarding/onboardingStore.ts +0 -32
- package/src/plugin.tsx +0 -162
- package/src/presence/AiFieldPresence.tsx +0 -28
- package/src/presence/AssistAvatar.tsx +0 -96
- package/src/presence/AssistDocumentPresence.tsx +0 -50
- package/src/presence/useAssistPresence.ts +0 -64
- package/src/schemas/assistDocumentSchema.tsx +0 -497
- package/src/schemas/contextDocumentSchema.tsx +0 -57
- package/src/schemas/index.ts +0 -69
- package/src/schemas/serialize/SchemTypeTool.tsx +0 -103
- package/src/schemas/serialize/schemaUtils.ts +0 -38
- package/src/schemas/serialize/serializeSchema.test.ts +0 -819
- package/src/schemas/serialize/serializeSchema.ts +0 -224
- package/src/schemas/serializedSchemaTypeSchema.ts +0 -60
- package/src/schemas/typeDefExtensions.ts +0 -127
- package/src/translate/FieldTranslationProvider.tsx +0 -382
- package/src/translate/getLanguageParams.ts +0 -26
- package/src/translate/languageStore.ts +0 -18
- package/src/translate/paths.test.ts +0 -181
- package/src/translate/paths.ts +0 -183
- package/src/translate/translateActions.tsx +0 -205
- package/src/translate/types.ts +0 -197
- package/src/types.ts +0 -220
- package/src/useApiClient.ts +0 -338
- package/v2-incompatible.js +0 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,29 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {CurrentUser} from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import {Path} from 'sanity'
|
|
9
|
-
import {Plugin as Plugin_2} from 'sanity'
|
|
10
|
-
import {PortableTextBlock} from '@portabletext/types'
|
|
11
|
-
import {PortableTextMarkDefinition} from '@portabletext/types'
|
|
12
|
-
import {PortableTextSpan} from '@portabletext/types'
|
|
13
|
-
import {SanityClient} from 'sanity'
|
|
14
|
-
import type {SanityClient as SanityClient_2} from '@sanity/client'
|
|
15
|
-
import {SanityDocumentLike} from 'sanity'
|
|
16
|
-
import {SchemaType} from 'sanity'
|
|
17
|
-
|
|
18
|
-
declare interface AgentActionConditionalPath {
|
|
19
|
-
path: AgentActionPath
|
|
20
|
-
readOnly: boolean
|
|
21
|
-
hidden: boolean
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export declare const assist: Plugin_2<void | AssistPluginConfig>
|
|
25
|
-
|
|
26
|
-
export declare interface AssistConfig {
|
|
1
|
+
import * as sanity from "sanity";
|
|
2
|
+
import { CurrentUser, DocumentFieldActionDivider, DocumentFieldActionGroup, DocumentFieldActionItem, ObjectSchemaType, Path, SanityClient, SanityDocumentLike, SchemaType } from "sanity";
|
|
3
|
+
import { SanityClient as SanityClient$1 } from "@sanity/client";
|
|
4
|
+
import { AgentActionPath } from "@sanity/client/stega";
|
|
5
|
+
import { PortableTextBlock, PortableTextMarkDefinition, PortableTextSpan } from "@portabletext/types";
|
|
6
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
|
+
interface AssistConfig {
|
|
27
8
|
/**
|
|
28
9
|
* As of v3.0 Assist can write to date and datetime fields.
|
|
29
10
|
*
|
|
@@ -41,7 +22,7 @@ export declare interface AssistConfig {
|
|
|
41
22
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#getcanonicalocales
|
|
42
23
|
* @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
43
24
|
*/
|
|
44
|
-
localeSettings?: (context: LocaleSettingsContext) => LocaleSettings
|
|
25
|
+
localeSettings?: (context: LocaleSettingsContext) => LocaleSettings;
|
|
45
26
|
/**
|
|
46
27
|
* The max depth for document paths AI Assist will write to.
|
|
47
28
|
*
|
|
@@ -57,7 +38,7 @@ export declare interface AssistConfig {
|
|
|
57
38
|
*
|
|
58
39
|
* Default: 4
|
|
59
40
|
*/
|
|
60
|
-
maxPathDepth?: number
|
|
41
|
+
maxPathDepth?: number;
|
|
61
42
|
/**
|
|
62
43
|
* Influences how much the output of an instruction will vary.
|
|
63
44
|
*
|
|
@@ -70,38 +51,46 @@ export declare interface AssistConfig {
|
|
|
70
51
|
*
|
|
71
52
|
* Default: 0.3
|
|
72
53
|
*/
|
|
73
|
-
temperature?: number
|
|
54
|
+
temperature?: number;
|
|
55
|
+
}
|
|
56
|
+
interface LocaleSettingsContext {
|
|
57
|
+
user: CurrentUser;
|
|
58
|
+
defaultSettings: LocaleSettings;
|
|
74
59
|
}
|
|
75
|
-
|
|
76
|
-
export declare type AssistFieldActionGroup = Omit<
|
|
77
|
-
DocumentFieldActionGroup,
|
|
78
|
-
'renderAsButton' | 'expanded' | 'children'
|
|
79
|
-
> & {
|
|
60
|
+
interface LocaleSettings {
|
|
80
61
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
62
|
+
* A valid Unicode BCP 47 locale identifier used to interpret and format
|
|
63
|
+
* natural language inputs and date output. Examples include "en-US", "fr-FR", or "ja-JP".
|
|
64
|
+
*
|
|
65
|
+
* This affects how phrases like "next Friday" or "in two weeks" are parsed,
|
|
66
|
+
* and how resulting dates are presented (e.g., 12-hour vs 24-hour format).
|
|
67
|
+
*
|
|
68
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#getcanonicalocales
|
|
69
|
+
*/
|
|
70
|
+
locale: string;
|
|
71
|
+
/**
|
|
72
|
+
* A valid IANA time zone identifier used to resolve relative and absolute
|
|
73
|
+
* date expressions to a specific point in time. Examples include
|
|
74
|
+
* "America/New_York", "Europe/Paris", or "Asia/Tokyo".
|
|
75
|
+
*
|
|
76
|
+
* This ensures phrases like "tomorrow at 9am" are interpreted correctly
|
|
77
|
+
* based on the user's local time.
|
|
78
|
+
*
|
|
79
|
+
* @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
83
80
|
*/
|
|
84
|
-
|
|
81
|
+
timeZone: string;
|
|
85
82
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
> & {
|
|
91
|
-
onAction: () => void | Promise<void>
|
|
83
|
+
interface AgentActionConditionalPath {
|
|
84
|
+
path: AgentActionPath;
|
|
85
|
+
readOnly: boolean;
|
|
86
|
+
hidden: boolean;
|
|
92
87
|
}
|
|
93
|
-
|
|
94
|
-
export declare type AssistFieldActionNode =
|
|
95
|
-
| AssistFieldActionItem
|
|
96
|
-
| AssistFieldActionGroup
|
|
97
|
-
| DocumentFieldActionDivider
|
|
98
|
-
|
|
99
|
-
export declare interface AssistFieldActionProps {
|
|
88
|
+
interface AssistFieldActionProps {
|
|
100
89
|
/**
|
|
101
90
|
* `actionType` will be `document` for action invoked from the top right document action menu, and
|
|
102
91
|
* `field` when invoked from a field action menu.
|
|
103
92
|
*/
|
|
104
|
-
actionType: 'document' | 'field'
|
|
93
|
+
actionType: 'document' | 'field';
|
|
105
94
|
/**
|
|
106
95
|
* This is the id of the current document pane; it contains `drafts.`or `versions. prefix` ect depending on context.
|
|
107
96
|
* Use this for `documentId` when calling any `client.agent.action`.
|
|
@@ -119,25 +108,25 @@ export declare interface AssistFieldActionProps {
|
|
|
119
108
|
* })
|
|
120
109
|
* ```
|
|
121
110
|
*/
|
|
122
|
-
documentIdForAction: string
|
|
111
|
+
documentIdForAction: string;
|
|
123
112
|
/**
|
|
124
113
|
* Schema type of the current document.
|
|
125
114
|
* @see documentIdForAction
|
|
126
115
|
*/
|
|
127
|
-
documentSchemaType: ObjectSchemaType
|
|
116
|
+
documentSchemaType: ObjectSchemaType;
|
|
128
117
|
/**
|
|
129
118
|
* Returns the current document value.
|
|
130
119
|
*
|
|
131
120
|
* Prefer passing this function to your hooks instead of passing the document value directly to avoid unnecessary re-renders.
|
|
132
121
|
* @see documentIdForAction
|
|
133
122
|
*/
|
|
134
|
-
getDocumentValue: () => SanityDocumentLike
|
|
123
|
+
getDocumentValue: () => SanityDocumentLike;
|
|
135
124
|
/**
|
|
136
125
|
* Returns the current readOnly and hidden state of all conditional members in the current document form.
|
|
137
126
|
*
|
|
138
127
|
* Intended to be passed to agent actions `conditionalPaths.paths`.
|
|
139
128
|
*/
|
|
140
|
-
getConditionalPaths: () => AgentActionConditionalPath[]
|
|
129
|
+
getConditionalPaths: () => AgentActionConditionalPath[];
|
|
141
130
|
/**
|
|
142
131
|
* `schemaId` for the current workspace.
|
|
143
132
|
*
|
|
@@ -159,7 +148,7 @@ export declare interface AssistFieldActionProps {
|
|
|
159
148
|
*
|
|
160
149
|
* ```
|
|
161
150
|
*/
|
|
162
|
-
schemaId: string
|
|
151
|
+
schemaId: string;
|
|
163
152
|
/**
|
|
164
153
|
* This is the schema type of the field the actions will be attached to (ie, schemaType for `path`)
|
|
165
154
|
*
|
|
@@ -180,7 +169,7 @@ export declare interface AssistFieldActionProps {
|
|
|
180
169
|
* })
|
|
181
170
|
* ```
|
|
182
171
|
*/
|
|
183
|
-
path: AgentActionPath
|
|
172
|
+
path: AgentActionPath;
|
|
184
173
|
/**
|
|
185
174
|
* This is the schema type of the field the actions will be attached to (ie, schemaType for `path`).
|
|
186
175
|
*
|
|
@@ -205,7 +194,7 @@ export declare interface AssistFieldActionProps {
|
|
|
205
194
|
*
|
|
206
195
|
* ```
|
|
207
196
|
*/
|
|
208
|
-
schemaType: SchemaType
|
|
197
|
+
schemaType: SchemaType;
|
|
209
198
|
/**
|
|
210
199
|
* Schema type of the parent field or array item holding this field.
|
|
211
200
|
*
|
|
@@ -214,147 +203,46 @@ export declare interface AssistFieldActionProps {
|
|
|
214
203
|
* @see schemaType
|
|
215
204
|
* @see documentSchemaType
|
|
216
205
|
*/
|
|
217
|
-
parentSchemaType?: SchemaType
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export declare interface AssistOptions {
|
|
221
|
-
aiAssist?: {
|
|
222
|
-
/** Set to true to disable assistance for this field or type */
|
|
223
|
-
exclude?: boolean
|
|
224
|
-
/**
|
|
225
|
-
* Set to true to add translation field-action to the field.
|
|
226
|
-
* Only has an effect in document types configured for document or field level translations.
|
|
227
|
-
*/
|
|
228
|
-
translateAction?: boolean
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
declare interface AssistPluginConfig {
|
|
233
|
-
translate?: TranslationConfig
|
|
234
|
-
/**
|
|
235
|
-
* Config that affects all instructions
|
|
236
|
-
*/
|
|
237
|
-
assist?: AssistConfig
|
|
238
|
-
fieldActions?: {
|
|
239
|
-
title?: string
|
|
240
|
-
/**
|
|
241
|
-
* The returned array can include `undefined` entries in the action array. These will be filtered out.
|
|
242
|
-
*/
|
|
243
|
-
useFieldActions?: (props: AssistFieldActionProps) => (AssistFieldActionNode | undefined)[]
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* @internal
|
|
247
|
-
*/
|
|
248
|
-
__customApiClient?: (defaultClient: SanityClient_2) => SanityClient_2
|
|
249
|
-
/**
|
|
250
|
-
* @internal
|
|
251
|
-
*/
|
|
252
|
-
__presets?: Record<string, AssistPreset>
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
declare interface AssistPreset {
|
|
256
|
-
fields?: PresetField[]
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
declare interface ContextBlock {
|
|
260
|
-
_type: typeof instructionContextTypeName
|
|
261
|
-
reference?: {
|
|
262
|
-
_type: 'reference'
|
|
263
|
-
_ref?: string
|
|
264
|
-
}
|
|
206
|
+
parentSchemaType?: SchemaType;
|
|
265
207
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
*/
|
|
272
|
-
export declare interface CustomInput {
|
|
208
|
+
type AssistFieldActionNode = AssistFieldActionItem | AssistFieldActionGroup | DocumentFieldActionDivider;
|
|
209
|
+
type AssistFieldActionItem = Omit<DocumentFieldActionItem, 'renderAsButton' | 'selected' | 'onAction'> & {
|
|
210
|
+
onAction: () => void | Promise<void>;
|
|
211
|
+
};
|
|
212
|
+
type AssistFieldActionGroup = Omit<DocumentFieldActionGroup, 'renderAsButton' | 'expanded' | 'children'> & {
|
|
273
213
|
/**
|
|
274
|
-
*
|
|
275
|
-
|
|
276
|
-
id: string
|
|
277
|
-
/**
|
|
278
|
-
* Title of the input field
|
|
279
|
-
*/
|
|
280
|
-
title: string
|
|
281
|
-
/**
|
|
282
|
-
* Additional info that will be displayed over the input
|
|
283
|
-
*/
|
|
284
|
-
description?: string
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export declare type CustomInputResult = {
|
|
288
|
-
/**
|
|
289
|
-
* Identifies which custom input the `result`belongs to
|
|
290
|
-
*/
|
|
291
|
-
input: CustomInput
|
|
292
|
-
/**
|
|
293
|
-
* The text provided by the user in the input
|
|
214
|
+
* `children` can include undefined entries in the action array. These will be filtered out.
|
|
215
|
+
* If the group has no defined children, the group will also be filtered out.
|
|
294
216
|
*/
|
|
295
|
-
|
|
217
|
+
children: (AssistFieldActionNode | undefined)[];
|
|
218
|
+
};
|
|
219
|
+
declare function defineAssistFieldAction(action: Omit<AssistFieldActionItem, 'type'>): AssistFieldActionItem;
|
|
220
|
+
declare function defineFieldActionDivider(): DocumentFieldActionDivider;
|
|
221
|
+
declare function defineAssistFieldActionGroup(group: Omit<AssistFieldActionGroup, 'type'>): AssistFieldActionGroup;
|
|
222
|
+
interface Language {
|
|
223
|
+
id: string;
|
|
224
|
+
title?: string;
|
|
296
225
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
*/
|
|
303
|
-
export declare const defaultLanguageOutputs: TranslationOutputsFunction
|
|
304
|
-
|
|
305
|
-
export declare function defineAssistFieldAction(
|
|
306
|
-
action: Omit<AssistFieldActionItem, 'type'>,
|
|
307
|
-
): AssistFieldActionItem
|
|
308
|
-
|
|
309
|
-
export declare function defineAssistFieldActionGroup(
|
|
310
|
-
group: Omit<AssistFieldActionGroup, 'type'>,
|
|
311
|
-
): AssistFieldActionGroup
|
|
312
|
-
|
|
313
|
-
export declare function defineFieldActionDivider(): DocumentFieldActionDivider
|
|
314
|
-
|
|
315
|
-
export declare interface DocumentMember {
|
|
316
|
-
schemaType: SchemaType
|
|
317
|
-
path: Path
|
|
318
|
-
name: string
|
|
319
|
-
value: unknown
|
|
226
|
+
interface DocumentMember {
|
|
227
|
+
schemaType: SchemaType;
|
|
228
|
+
path: Path;
|
|
229
|
+
name: string;
|
|
230
|
+
value: unknown;
|
|
320
231
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
* For instance: 'config.language'
|
|
326
|
-
*
|
|
327
|
-
* For projects that use the `@sanity/document-internationalization` plugin,
|
|
328
|
-
* this should be the same as `languageField` config for that plugin.
|
|
329
|
-
*
|
|
330
|
-
* Default: 'language'
|
|
331
|
-
*/
|
|
332
|
-
languageField: string
|
|
333
|
-
/**
|
|
334
|
-
* `documentTypes` should be an array of strings where each entry must match a name from your document schemas.
|
|
335
|
-
*
|
|
336
|
-
* If defined, this property will add a translate instruction to these document types.
|
|
337
|
-
* If undefined, the instruction will be added to all documents with aiAssistance enabled and a field matching `documentLanguageField` config.
|
|
338
|
-
*
|
|
339
|
-
* Documents with translation support will get a "Translate document>" instruction added.
|
|
340
|
-
**/
|
|
341
|
-
documentTypes?: string[]
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
declare interface FieldRef extends PortableTextMarkDefinition {
|
|
345
|
-
_type: typeof fieldReferenceTypeName
|
|
346
|
-
path?: string
|
|
232
|
+
interface TranslationOutput {
|
|
233
|
+
/** Language id */
|
|
234
|
+
id: string;
|
|
235
|
+
outputPath: Path;
|
|
347
236
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
export declare interface FieldTranslationConfig {
|
|
237
|
+
type TranslationOutputsFunction = (documentMember: DocumentMember, enclosingType: SchemaType, translateFromLanguageId: string, translateToLanguageIds: string[]) => TranslationOutput[] | undefined;
|
|
238
|
+
type LanguageCallback = (client: SanityClient, selectedLanguageParams: Record<string, unknown>) => Promise<Language[]>;
|
|
239
|
+
interface FieldTranslationConfig {
|
|
352
240
|
/**
|
|
353
241
|
* `documentTypes` should be an array of strings where each entry must match a name from your document schemas.
|
|
354
242
|
*
|
|
355
243
|
* If defined, matching document will get a "Translate fields" instruction added.
|
|
356
244
|
**/
|
|
357
|
-
documentTypes?: string[]
|
|
245
|
+
documentTypes?: string[];
|
|
358
246
|
/**
|
|
359
247
|
*
|
|
360
248
|
* Used for display strings in the Studio, and to determine languages for field level translations
|
|
@@ -362,13 +250,13 @@ export declare interface FieldTranslationConfig {
|
|
|
362
250
|
* If the studio is using the sanity-plugin-internationalized-array plugin, this
|
|
363
251
|
* should be set to the same configuration.
|
|
364
252
|
*/
|
|
365
|
-
languages: Language[] | LanguageCallback
|
|
253
|
+
languages: Language[] | LanguageCallback;
|
|
366
254
|
/**
|
|
367
255
|
* API version for client passed to LanguageCallback for languages
|
|
368
256
|
* https://www.sanity.io/docs/api-versioning
|
|
369
257
|
* @defaultValue '2022-11-27'
|
|
370
258
|
*/
|
|
371
|
-
apiVersion?: string
|
|
259
|
+
apiVersion?: string;
|
|
372
260
|
/**
|
|
373
261
|
* Specify fields that should be available in the languages callback:
|
|
374
262
|
* ```tsx
|
|
@@ -384,7 +272,7 @@ export declare interface FieldTranslationConfig {
|
|
|
384
272
|
* If the studio is using the sanity-plugin-internationalized-array plugin, this
|
|
385
273
|
* should be set to the same configuration.
|
|
386
274
|
*/
|
|
387
|
-
selectLanguageParams?: Record<string, string
|
|
275
|
+
selectLanguageParams?: Record<string, string>;
|
|
388
276
|
/**
|
|
389
277
|
* `translationOutputs` is used when the "Translate fields" instruction is started by a Studio user.
|
|
390
278
|
*
|
|
@@ -437,7 +325,7 @@ export declare interface FieldTranslationConfig {
|
|
|
437
325
|
*
|
|
438
326
|
* @see #maxPathDepth
|
|
439
327
|
**/
|
|
440
|
-
translationOutputs?: TranslationOutputsFunction
|
|
328
|
+
translationOutputs?: TranslationOutputsFunction;
|
|
441
329
|
/**
|
|
442
330
|
* The max depth for document paths AI Assist will translate.
|
|
443
331
|
*
|
|
@@ -450,139 +338,48 @@ export declare interface FieldTranslationConfig {
|
|
|
450
338
|
*
|
|
451
339
|
* Default: 6
|
|
452
340
|
*/
|
|
453
|
-
maxPathDepth?: number
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
export declare type GetUserInput = (args: {
|
|
457
|
-
/**
|
|
458
|
-
* Dialog title
|
|
459
|
-
*/
|
|
460
|
-
title: string
|
|
461
|
-
/**
|
|
462
|
-
* One titled input per array item
|
|
463
|
-
*/
|
|
464
|
-
inputs: CustomInput[]
|
|
465
|
-
}) => Promise<CustomInputResult[] | undefined>
|
|
466
|
-
|
|
467
|
-
declare type InlinePromptBlock = PortableTextSpan | FieldRef | UserInputBlock | ContextBlock
|
|
468
|
-
|
|
469
|
-
declare const instructionContextTypeName: 'sanity.assist.instruction.context'
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Returns true if the `schemaType` or any of its parent types (`schemaType.type`)` has `name` equal
|
|
473
|
-
* to `typeName`.
|
|
474
|
-
*
|
|
475
|
-
* Useful for checking if `schemaType` is a type alias of `ìmage`, `code` or similar.
|
|
476
|
-
*/
|
|
477
|
-
export declare function isType(schemaType: SchemaType, typeName: string): boolean
|
|
478
|
-
|
|
479
|
-
export declare interface Language {
|
|
480
|
-
id: string
|
|
481
|
-
title?: string
|
|
341
|
+
maxPathDepth?: number;
|
|
482
342
|
}
|
|
483
|
-
|
|
484
|
-
export declare type LanguageCallback = (
|
|
485
|
-
client: SanityClient,
|
|
486
|
-
selectedLanguageParams: Record<string, unknown>,
|
|
487
|
-
) => Promise<Language[]>
|
|
488
|
-
|
|
489
|
-
export declare interface LocaleSettings {
|
|
343
|
+
interface DocumentTranslationConfig {
|
|
490
344
|
/**
|
|
491
|
-
*
|
|
492
|
-
*
|
|
345
|
+
* Path to language field in documents. Can be a hidden field.
|
|
346
|
+
* For instance: 'config.language'
|
|
493
347
|
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
348
|
+
* For projects that use the `@sanity/document-internationalization` plugin,
|
|
349
|
+
* this should be the same as `languageField` config for that plugin.
|
|
496
350
|
*
|
|
497
|
-
*
|
|
351
|
+
* Default: 'language'
|
|
498
352
|
*/
|
|
499
|
-
|
|
353
|
+
languageField: string;
|
|
500
354
|
/**
|
|
501
|
-
*
|
|
502
|
-
* date expressions to a specific point in time. Examples include
|
|
503
|
-
* "America/New_York", "Europe/Paris", or "Asia/Tokyo".
|
|
355
|
+
* `documentTypes` should be an array of strings where each entry must match a name from your document schemas.
|
|
504
356
|
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
357
|
+
* If defined, this property will add a translate instruction to these document types.
|
|
358
|
+
* If undefined, the instruction will be added to all documents with aiAssistance enabled and a field matching `documentLanguageField` config.
|
|
507
359
|
*
|
|
508
|
-
*
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
export declare interface LocaleSettingsContext {
|
|
514
|
-
user: CurrentUser
|
|
515
|
-
defaultSettings: LocaleSettings
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
declare interface OutputFieldItem {
|
|
519
|
-
_type: typeof outputFieldTypeName
|
|
520
|
-
_key: string
|
|
521
|
-
relativePath?: string
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
declare const outputFieldTypeName: 'sanity.assist.output.field'
|
|
525
|
-
|
|
526
|
-
declare interface OutputTypeItem {
|
|
527
|
-
_type: typeof outputTypeTypeName
|
|
528
|
-
_key: string
|
|
529
|
-
type?: string
|
|
530
|
-
relativePath?: string
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
declare const outputTypeTypeName: 'sanity.assist.output.type'
|
|
534
|
-
|
|
535
|
-
declare interface PresetField {
|
|
536
|
-
path?: string
|
|
537
|
-
instructions?: PresetInstruction[]
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
declare interface PresetInstruction {
|
|
541
|
-
_key: string
|
|
542
|
-
prompt?: PromptTextBlock[]
|
|
543
|
-
title?: string
|
|
544
|
-
/**
|
|
545
|
-
* String key from `@sanity/icons` IconMap
|
|
546
|
-
*/
|
|
547
|
-
icon?: string
|
|
548
|
-
/**
|
|
549
|
-
* Type/field filter
|
|
550
|
-
*/
|
|
551
|
-
output?: (OutputFieldItem | OutputTypeItem)[]
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
declare type PromptTextBlock = Omit<
|
|
555
|
-
PortableTextBlock<never, InlinePromptBlock, 'normal', never>,
|
|
556
|
-
'_type'
|
|
557
|
-
> & {
|
|
558
|
-
_type: 'block'
|
|
360
|
+
* Documents with translation support will get a "Translate document>" instruction added.
|
|
361
|
+
**/
|
|
362
|
+
documentTypes?: string[];
|
|
559
363
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
| string
|
|
565
|
-
| ((context: TranslateStyleguideContext) => Promise<string>)
|
|
566
|
-
|
|
567
|
-
export declare interface TranslateStyleguideContext {
|
|
568
|
-
documentId: string
|
|
569
|
-
schemaType: ObjectSchemaType
|
|
570
|
-
client: SanityClient
|
|
364
|
+
interface TranslateStyleguideContext {
|
|
365
|
+
documentId: string;
|
|
366
|
+
schemaType: ObjectSchemaType;
|
|
367
|
+
client: SanityClient;
|
|
571
368
|
/**
|
|
572
369
|
* Only provided for field translations
|
|
573
370
|
*/
|
|
574
|
-
translatePath?: Path
|
|
371
|
+
translatePath?: Path;
|
|
575
372
|
}
|
|
576
|
-
|
|
577
|
-
|
|
373
|
+
type TranslateStyleguide = string | ((context: TranslateStyleguideContext) => Promise<string>);
|
|
374
|
+
interface TranslationConfig {
|
|
578
375
|
/**
|
|
579
376
|
* Config for document types with fields in multiple languages in the same document.
|
|
580
377
|
*/
|
|
581
|
-
field?: FieldTranslationConfig
|
|
378
|
+
field?: FieldTranslationConfig;
|
|
582
379
|
/**
|
|
583
380
|
* Config for document types with a single language field that determines the language for the whole document.
|
|
584
381
|
*/
|
|
585
|
-
document?: DocumentTranslationConfig
|
|
382
|
+
document?: DocumentTranslationConfig;
|
|
586
383
|
/**
|
|
587
384
|
* A "style guide" that can be used to provide guidance on how to translate content.
|
|
588
385
|
* Will be passed to the LLM - ergo this is only a guide and the model _may_ not
|
|
@@ -590,95 +387,100 @@ export declare interface TranslationConfig {
|
|
|
590
387
|
*
|
|
591
388
|
* When providing a function, consider caching the results of any async operation; it will invoked every time translate runs
|
|
592
389
|
*/
|
|
593
|
-
styleguide?: TranslateStyleguide
|
|
390
|
+
styleguide?: TranslateStyleguide;
|
|
594
391
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
392
|
+
declare const userInputTypeName: "sanity.assist.instruction.userInput";
|
|
393
|
+
declare const instructionContextTypeName: "sanity.assist.instruction.context";
|
|
394
|
+
declare const fieldReferenceTypeName: "sanity.assist.instruction.fieldRef";
|
|
395
|
+
declare const contextDocumentTypeName: "assist.instruction.context";
|
|
396
|
+
declare const outputFieldTypeName: "sanity.assist.output.field";
|
|
397
|
+
declare const outputTypeTypeName: "sanity.assist.output.type";
|
|
398
|
+
interface PresetInstruction {
|
|
399
|
+
_key: string;
|
|
400
|
+
prompt?: PromptTextBlock[];
|
|
401
|
+
title?: string;
|
|
402
|
+
/**
|
|
403
|
+
* String key from `@sanity/icons` IconMap
|
|
404
|
+
*/
|
|
405
|
+
icon?: string;
|
|
406
|
+
/**
|
|
407
|
+
* Type/field filter
|
|
408
|
+
*/
|
|
409
|
+
output?: (OutputFieldItem | OutputTypeItem)[];
|
|
600
410
|
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
411
|
+
interface PresetField {
|
|
412
|
+
path?: string;
|
|
413
|
+
instructions?: PresetInstruction[];
|
|
414
|
+
}
|
|
415
|
+
interface AssistPreset {
|
|
416
|
+
fields?: PresetField[];
|
|
417
|
+
}
|
|
418
|
+
interface FieldRef extends PortableTextMarkDefinition {
|
|
419
|
+
_type: typeof fieldReferenceTypeName;
|
|
420
|
+
path?: string;
|
|
421
|
+
}
|
|
422
|
+
interface ContextBlock {
|
|
423
|
+
_type: typeof instructionContextTypeName;
|
|
424
|
+
reference?: {
|
|
425
|
+
_type: 'reference';
|
|
426
|
+
_ref?: string;
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
interface UserInputBlock {
|
|
430
|
+
_type: typeof userInputTypeName;
|
|
431
|
+
_key: string;
|
|
432
|
+
message?: string;
|
|
433
|
+
description?: string;
|
|
434
|
+
}
|
|
435
|
+
type InlinePromptBlock = PortableTextSpan | FieldRef | UserInputBlock | ContextBlock;
|
|
436
|
+
type PromptTextBlock = Omit<PortableTextBlock<never, InlinePromptBlock, 'normal', never>, '_type'> & {
|
|
437
|
+
_type: 'block';
|
|
438
|
+
};
|
|
439
|
+
interface OutputFieldItem {
|
|
440
|
+
_type: typeof outputFieldTypeName;
|
|
441
|
+
_key: string;
|
|
442
|
+
relativePath?: string;
|
|
443
|
+
}
|
|
444
|
+
interface OutputTypeItem {
|
|
445
|
+
_type: typeof outputTypeTypeName;
|
|
446
|
+
_key: string;
|
|
447
|
+
type?: string;
|
|
448
|
+
relativePath?: string;
|
|
449
|
+
}
|
|
450
|
+
interface AssistPluginConfig {
|
|
451
|
+
translate?: TranslationConfig;
|
|
452
|
+
/**
|
|
453
|
+
* Config that affects all instructions
|
|
454
|
+
*/
|
|
455
|
+
assist?: AssistConfig;
|
|
456
|
+
fieldActions?: {
|
|
457
|
+
title?: string;
|
|
458
|
+
/**
|
|
459
|
+
* The returned array can include `undefined` entries in the action array. These will be filtered out.
|
|
460
|
+
*/
|
|
461
|
+
useFieldActions?: (props: AssistFieldActionProps) => (AssistFieldActionNode | undefined)[];
|
|
462
|
+
};
|
|
463
|
+
/**
|
|
464
|
+
* @internal
|
|
465
|
+
*/
|
|
466
|
+
__customApiClient?: (defaultClient: SanityClient$1) => SanityClient$1;
|
|
467
|
+
/**
|
|
468
|
+
* @internal
|
|
469
|
+
*/
|
|
470
|
+
__presets?: Record<string, AssistPreset>;
|
|
471
|
+
}
|
|
472
|
+
declare const assist: sanity.Plugin<void | AssistPluginConfig>;
|
|
473
|
+
declare function SchemaTypeTool(): react_jsx_runtime0.JSX.Element;
|
|
474
|
+
interface AssistOptions {
|
|
475
|
+
aiAssist?: {
|
|
476
|
+
/** Set to true to disable assistance for this field or type */exclude?: boolean;
|
|
477
|
+
/**
|
|
478
|
+
* Set to true to add translation field-action to the field.
|
|
479
|
+
* Only has an effect in document types configured for document or field level translations.
|
|
480
|
+
*/
|
|
481
|
+
translateAction?: boolean;
|
|
482
|
+
};
|
|
614
483
|
}
|
|
615
|
-
|
|
616
|
-
declare const userInputTypeName: 'sanity.assist.instruction.userInput'
|
|
617
|
-
|
|
618
|
-
/**
|
|
619
|
-
* `useUserInput` returns a function that can be used to await user input.
|
|
620
|
-
*
|
|
621
|
-
* Useful for custom `fieldActions` to get user input for populating Agent Action requests,.
|
|
622
|
-
*
|
|
623
|
-
* ```ts
|
|
624
|
-
* fieldActions: {
|
|
625
|
-
* useFieldActions: (props) => {
|
|
626
|
-
* const {
|
|
627
|
-
* documentSchemaType,
|
|
628
|
-
* schemaId,
|
|
629
|
-
* getDocumentValue,
|
|
630
|
-
* getConditionalPaths,
|
|
631
|
-
* documentIdForAction,
|
|
632
|
-
* } = props
|
|
633
|
-
* const client = useClient({apiVersion: 'vX'})
|
|
634
|
-
* const getUserInput = useUserInput()
|
|
635
|
-
* return useMemo(() => {
|
|
636
|
-
* return [
|
|
637
|
-
* defineAssistFieldAction({
|
|
638
|
-
* title: 'Log user input',
|
|
639
|
-
* icon: UserIcon,
|
|
640
|
-
* onAction: async () => {
|
|
641
|
-
* const input = await getUserInput({
|
|
642
|
-
* title: 'Topic',
|
|
643
|
-
* inputs: [{id: 'about', title: 'What should the article be about?'}],
|
|
644
|
-
* })
|
|
645
|
-
* if (!input) return // user canceled input
|
|
646
|
-
* await client.agent.action.generate({
|
|
647
|
-
* schemaId,
|
|
648
|
-
* targetDocument: {
|
|
649
|
-
* operation: 'createIfNotExists',
|
|
650
|
-
* _id: documentIdForAction,
|
|
651
|
-
* _type: documentSchemaType.name,
|
|
652
|
-
* initialValues: getDocumentValue(),
|
|
653
|
-
* },
|
|
654
|
-
* instruction: `
|
|
655
|
-
* Create a document about the following topic:
|
|
656
|
-
* $about
|
|
657
|
-
* ---
|
|
658
|
-
* `,
|
|
659
|
-
* instructionParams: {about: input[0].result},
|
|
660
|
-
* conditionalPaths: {paths: getConditionalPaths()},
|
|
661
|
-
* })
|
|
662
|
-
* },
|
|
663
|
-
* }),
|
|
664
|
-
* ]
|
|
665
|
-
* }, [
|
|
666
|
-
* client,
|
|
667
|
-
* documentSchemaType,
|
|
668
|
-
* schemaId,
|
|
669
|
-
* getDocumentValue,
|
|
670
|
-
* getConditionalPaths,
|
|
671
|
-
* documentIdForAction,
|
|
672
|
-
* getUserInput,
|
|
673
|
-
* ])
|
|
674
|
-
* },
|
|
675
|
-
* }
|
|
676
|
-
* ```
|
|
677
|
-
*/
|
|
678
|
-
export declare function useUserInput(): GetUserInput
|
|
679
|
-
|
|
680
|
-
export {}
|
|
681
|
-
|
|
682
484
|
declare module 'sanity' {
|
|
683
485
|
interface ArrayOptions extends AssistOptions {}
|
|
684
486
|
interface BlockOptions extends AssistOptions {}
|
|
@@ -725,7 +527,7 @@ declare module 'sanity' {
|
|
|
725
527
|
* })
|
|
726
528
|
* ```
|
|
727
529
|
*/
|
|
728
|
-
imageInstructionField?: string
|
|
530
|
+
imageInstructionField?: string;
|
|
729
531
|
/**
|
|
730
532
|
* When set, an image description will be automatically created for the image.
|
|
731
533
|
*
|
|
@@ -756,36 +558,146 @@ declare module 'sanity' {
|
|
|
756
558
|
* })
|
|
757
559
|
* ```
|
|
758
560
|
*/
|
|
759
|
-
imageDescriptionField?:
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
}
|
|
771
|
-
}
|
|
561
|
+
imageDescriptionField?: string | {
|
|
562
|
+
path: string;
|
|
563
|
+
/**
|
|
564
|
+
* When updateOnImageChange is true (or undefined), whenever the
|
|
565
|
+
* image asset changes, imageDescriptionField will be regenerated.
|
|
566
|
+
*
|
|
567
|
+
* default: true
|
|
568
|
+
* */
|
|
569
|
+
updateOnImageChange?: boolean;
|
|
570
|
+
};
|
|
571
|
+
};
|
|
772
572
|
}
|
|
773
573
|
interface NumberOptions extends AssistOptions {}
|
|
774
574
|
interface ObjectOptions extends AssistOptions {}
|
|
775
575
|
interface ReferenceBaseOptions {
|
|
776
576
|
aiAssist?: {
|
|
777
|
-
/** Set to true to disable assistance for this field or type */
|
|
778
|
-
exclude?: boolean
|
|
577
|
+
/** Set to true to disable assistance for this field or type */exclude?: boolean;
|
|
779
578
|
/**
|
|
780
579
|
* When set, the reference field will allow instructions to be added to it.
|
|
781
580
|
* Should be the name of the embeddings-index where assist will look for contextually relevant documents
|
|
782
581
|
* */
|
|
783
|
-
embeddingsIndex?: string
|
|
784
|
-
}
|
|
582
|
+
embeddingsIndex?: string;
|
|
583
|
+
};
|
|
785
584
|
}
|
|
786
585
|
interface SlugOptions extends AssistOptions {}
|
|
787
586
|
interface StringOptions extends AssistOptions {}
|
|
788
587
|
interface TextOptions extends AssistOptions {}
|
|
789
588
|
interface UrlOptions extends AssistOptions {}
|
|
790
589
|
interface EmailOptions extends AssistOptions {}
|
|
590
|
+
} //# sourceMappingURL=typeDefExtensions.d.ts.map
|
|
591
|
+
/**
|
|
592
|
+
* Default implementation for plugin config `translate.field.translationOutputs`
|
|
593
|
+
*
|
|
594
|
+
* @see FieldTranslationConfig#translationOutputs
|
|
595
|
+
*/
|
|
596
|
+
declare const defaultLanguageOutputs: TranslationOutputsFunction;
|
|
597
|
+
type GetUserInput = (args: {
|
|
598
|
+
/**
|
|
599
|
+
* Dialog title
|
|
600
|
+
*/
|
|
601
|
+
title: string;
|
|
602
|
+
/**
|
|
603
|
+
* One titled input per array item
|
|
604
|
+
*/
|
|
605
|
+
inputs: CustomInput[];
|
|
606
|
+
}) => Promise<CustomInputResult[] | undefined>;
|
|
607
|
+
/**
|
|
608
|
+
*
|
|
609
|
+
*/
|
|
610
|
+
interface CustomInput {
|
|
611
|
+
/**
|
|
612
|
+
* Id for the input
|
|
613
|
+
*/
|
|
614
|
+
id: string;
|
|
615
|
+
/**
|
|
616
|
+
* Title of the input field
|
|
617
|
+
*/
|
|
618
|
+
title: string;
|
|
619
|
+
/**
|
|
620
|
+
* Additional info that will be displayed over the input
|
|
621
|
+
*/
|
|
622
|
+
description?: string;
|
|
791
623
|
}
|
|
624
|
+
type CustomInputResult = {
|
|
625
|
+
/**
|
|
626
|
+
* Identifies which custom input the `result`belongs to
|
|
627
|
+
*/
|
|
628
|
+
input: CustomInput;
|
|
629
|
+
/**
|
|
630
|
+
* The text provided by the user in the input
|
|
631
|
+
*/
|
|
632
|
+
result: string;
|
|
633
|
+
};
|
|
634
|
+
/**
|
|
635
|
+
* `useUserInput` returns a function that can be used to await user input.
|
|
636
|
+
*
|
|
637
|
+
* Useful for custom `fieldActions` to get user input for populating Agent Action requests,.
|
|
638
|
+
*
|
|
639
|
+
* ```ts
|
|
640
|
+
* fieldActions: {
|
|
641
|
+
* useFieldActions: (props) => {
|
|
642
|
+
* const {
|
|
643
|
+
* documentSchemaType,
|
|
644
|
+
* schemaId,
|
|
645
|
+
* getDocumentValue,
|
|
646
|
+
* getConditionalPaths,
|
|
647
|
+
* documentIdForAction,
|
|
648
|
+
* } = props
|
|
649
|
+
* const client = useClient({apiVersion: 'vX'})
|
|
650
|
+
* const getUserInput = useUserInput()
|
|
651
|
+
* return useMemo(() => {
|
|
652
|
+
* return [
|
|
653
|
+
* defineAssistFieldAction({
|
|
654
|
+
* title: 'Log user input',
|
|
655
|
+
* icon: UserIcon,
|
|
656
|
+
* onAction: async () => {
|
|
657
|
+
* const input = await getUserInput({
|
|
658
|
+
* title: 'Topic',
|
|
659
|
+
* inputs: [{id: 'about', title: 'What should the article be about?'}],
|
|
660
|
+
* })
|
|
661
|
+
* if (!input) return // user canceled input
|
|
662
|
+
* await client.agent.action.generate({
|
|
663
|
+
* schemaId,
|
|
664
|
+
* targetDocument: {
|
|
665
|
+
* operation: 'createIfNotExists',
|
|
666
|
+
* _id: documentIdForAction,
|
|
667
|
+
* _type: documentSchemaType.name,
|
|
668
|
+
* initialValues: getDocumentValue(),
|
|
669
|
+
* },
|
|
670
|
+
* instruction: `
|
|
671
|
+
* Create a document about the following topic:
|
|
672
|
+
* $about
|
|
673
|
+
* ---
|
|
674
|
+
* `,
|
|
675
|
+
* instructionParams: {about: input[0].result},
|
|
676
|
+
* conditionalPaths: {paths: getConditionalPaths()},
|
|
677
|
+
* })
|
|
678
|
+
* },
|
|
679
|
+
* }),
|
|
680
|
+
* ]
|
|
681
|
+
* }, [
|
|
682
|
+
* client,
|
|
683
|
+
* documentSchemaType,
|
|
684
|
+
* schemaId,
|
|
685
|
+
* getDocumentValue,
|
|
686
|
+
* getConditionalPaths,
|
|
687
|
+
* documentIdForAction,
|
|
688
|
+
* getUserInput,
|
|
689
|
+
* ])
|
|
690
|
+
* },
|
|
691
|
+
* }
|
|
692
|
+
* ```
|
|
693
|
+
*/
|
|
694
|
+
declare function useUserInput(): GetUserInput;
|
|
695
|
+
/**
|
|
696
|
+
* Returns true if the `schemaType` or any of its parent types (`schemaType.type`)` has `name` equal
|
|
697
|
+
* to `typeName`.
|
|
698
|
+
*
|
|
699
|
+
* Useful for checking if `schemaType` is a type alias of `ìmage`, `code` or similar.
|
|
700
|
+
*/
|
|
701
|
+
declare function isType(schemaType: SchemaType, typeName: string): boolean;
|
|
702
|
+
export { AssistConfig, type AssistFieldActionGroup, type AssistFieldActionItem, type AssistFieldActionNode, type AssistFieldActionProps, AssistOptions, type CustomInput, type CustomInputResult, DocumentMember, DocumentTranslationConfig, FieldTranslationConfig, type GetUserInput, Language, LanguageCallback, LocaleSettings, LocaleSettingsContext, SchemaTypeTool, TranslateStyleguide, TranslateStyleguideContext, TranslationConfig, TranslationOutput, TranslationOutputsFunction, assist, contextDocumentTypeName, defaultLanguageOutputs, defineAssistFieldAction, defineAssistFieldActionGroup, defineFieldActionDivider, isType, useUserInput };
|
|
703
|
+
//# sourceMappingURL=index.d.ts.map
|