@sanity/assist 2.0.5 → 3.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/dist/index.d.mts +377 -0
- package/dist/index.esm.js +2802 -5553
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2785 -5562
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4159 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +16 -20
- package/src/_lib/form/DocumentForm.tsx +7 -6
- package/src/assistDocument/AssistDocumentInput.tsx +2 -2
- package/src/assistDocument/components/instruction/BackToInstructionsLink.tsx +1 -1
- package/src/assistDocument/components/instruction/PromptInput.tsx +9 -3
- package/src/assistDocument/hooks/useAssistDocumentContextValue.tsx +3 -3
- package/src/assistFormComponents/validation/listItem.tsx +3 -3
- package/src/assistInspector/AssistInspector.tsx +11 -5
- package/src/assistInspector/InstructionTaskHistoryButton.tsx +4 -4
- package/src/assistInspector/helpers.ts +8 -8
- package/src/components/FadeInContent.tsx +2 -2
- package/src/components/ImageContext.tsx +2 -2
- package/src/components/SafeValueInput.tsx +6 -9
- package/src/fieldActions/assistFieldActions.tsx +1 -1
- package/src/fieldActions/generateCaptionActions.tsx +2 -2
- package/src/onboarding/InspectorOnboarding.tsx +1 -1
- package/src/presence/AssistAvatar.tsx +2 -2
- package/src/translate/getLanguageParams.ts +2 -2
- package/src/translate/translateActions.tsx +1 -1
- package/dist/index.cjs.mjs +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/assist",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "You create the instructions; Sanity AI Assist does the rest.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -17,17 +17,13 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Sanity <hello@sanity.io>",
|
|
20
|
+
"sideEffects": false,
|
|
20
21
|
"exports": {
|
|
21
22
|
".": {
|
|
22
|
-
"types": "./dist/index.d.ts",
|
|
23
23
|
"source": "./src/index.ts",
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
24
25
|
"require": "./dist/index.js",
|
|
25
|
-
"
|
|
26
|
-
"module": "./dist/index.esm.js",
|
|
27
|
-
"import": "./dist/index.cjs.mjs"
|
|
28
|
-
},
|
|
29
|
-
"import": "./dist/index.esm.js",
|
|
30
|
-
"default": "./dist/index.esm.js"
|
|
26
|
+
"default": "./dist/index.js"
|
|
31
27
|
},
|
|
32
28
|
"./package.json": "./package.json"
|
|
33
29
|
},
|
|
@@ -42,7 +38,7 @@
|
|
|
42
38
|
"v2-incompatible.js"
|
|
43
39
|
],
|
|
44
40
|
"scripts": {
|
|
45
|
-
"build": "run-s clean &&
|
|
41
|
+
"build": "run-s clean && pkg-utils build --strict && pkg-utils --strict",
|
|
46
42
|
"clean": "rimraf dist",
|
|
47
43
|
"format": "prettier --write --cache --ignore-unknown .",
|
|
48
44
|
"link-watch": "plugin-kit link-watch",
|
|
@@ -54,27 +50,26 @@
|
|
|
54
50
|
"release": "semantic-release"
|
|
55
51
|
},
|
|
56
52
|
"dependencies": {
|
|
57
|
-
"@sanity/icons": "^2.
|
|
53
|
+
"@sanity/icons": "^2.11.7",
|
|
58
54
|
"@sanity/incompatible-plugin": "^1.0.4",
|
|
59
|
-
"@sanity/ui": "^2.0
|
|
60
|
-
"date-fns": "^
|
|
61
|
-
"lodash
|
|
62
|
-
"react-fast-compare": "^3.2.
|
|
63
|
-
"
|
|
64
|
-
"rxjs": "^7.8.0",
|
|
55
|
+
"@sanity/ui": "^2.1.0",
|
|
56
|
+
"date-fns": "^3.6.0",
|
|
57
|
+
"lodash": "^4.17.21",
|
|
58
|
+
"react-fast-compare": "^3.2.2",
|
|
59
|
+
"rxjs": "^7.8.1",
|
|
65
60
|
"rxjs-exhaustmap-with-trailing": "^2.1.1"
|
|
66
61
|
},
|
|
67
62
|
"devDependencies": {
|
|
68
63
|
"@commitlint/cli": "^19.2.1",
|
|
69
64
|
"@commitlint/config-conventional": "^19.1.0",
|
|
70
65
|
"@rollup/plugin-image": "^3.0.3",
|
|
71
|
-
"@sanity/pkg-utils": "^
|
|
66
|
+
"@sanity/pkg-utils": "^6.1.0",
|
|
72
67
|
"@sanity/plugin-kit": "^3.1.10",
|
|
73
68
|
"@sanity/semantic-release-preset": "^4.1.7",
|
|
69
|
+
"@types/lodash": "^4.17.0",
|
|
74
70
|
"@types/react": "^18.2.75",
|
|
75
71
|
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
|
76
72
|
"@typescript-eslint/parser": "^7.6.0",
|
|
77
|
-
"date-fns": "^2.30.0",
|
|
78
73
|
"eslint": "^8.57.0",
|
|
79
74
|
"eslint-config-prettier": "^9.1.0",
|
|
80
75
|
"eslint-config-sanity": "^7.1.2",
|
|
@@ -92,9 +87,10 @@
|
|
|
92
87
|
"vitest": "^1.4.0"
|
|
93
88
|
},
|
|
94
89
|
"peerDependencies": {
|
|
90
|
+
"@sanity/mutator": "^3.36.4",
|
|
95
91
|
"react": "^18",
|
|
96
|
-
"sanity": "^3.
|
|
97
|
-
"styled-components": "^
|
|
92
|
+
"sanity": "^3.36.4",
|
|
93
|
+
"styled-components": "^6.1"
|
|
98
94
|
},
|
|
99
95
|
"engines": {
|
|
100
96
|
"node": ">=14"
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {Box, BoxProps, Flex, focusFirstDescendant, Spinner, Text} from '@sanity/ui'
|
|
2
|
-
import React
|
|
1
|
+
import {Box, type BoxProps, Flex, focusFirstDescendant, Spinner, Text} from '@sanity/ui'
|
|
2
|
+
import type React from 'react'
|
|
3
|
+
import {type HTMLProps, useEffect, useMemo, useRef} from 'react'
|
|
3
4
|
import {tap} from 'rxjs/operators'
|
|
4
5
|
import {
|
|
5
6
|
createPatchChannel,
|
|
6
|
-
DocumentMutationEvent,
|
|
7
|
-
DocumentRebaseEvent,
|
|
7
|
+
type DocumentMutationEvent,
|
|
8
|
+
type DocumentRebaseEvent,
|
|
8
9
|
FormBuilder,
|
|
9
10
|
fromMutationPatches,
|
|
10
|
-
PatchMsg,
|
|
11
|
+
type PatchMsg,
|
|
11
12
|
useDocumentPresence,
|
|
12
13
|
useDocumentStore,
|
|
13
14
|
} from 'sanity'
|
|
14
|
-
import {useDocumentPane} from 'sanity/
|
|
15
|
+
import {useDocumentPane} from 'sanity/structure'
|
|
15
16
|
|
|
16
17
|
import {assistFormId} from './constants'
|
|
17
18
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {useLayer} from '@sanity/ui'
|
|
2
2
|
import {useMemo} from 'react'
|
|
3
|
-
import {InputProps, ObjectInputProps, ObjectSchemaType} from 'sanity'
|
|
4
|
-
import {useDocumentPane} from 'sanity/
|
|
3
|
+
import type {InputProps, ObjectInputProps, ObjectSchemaType} from 'sanity'
|
|
4
|
+
import {useDocumentPane} from 'sanity/structure'
|
|
5
5
|
|
|
6
6
|
import {ConnectFromRegion} from '../_lib/connector'
|
|
7
7
|
import {assistFormId} from '../_lib/form/constants'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {ArrowLeftIcon} from '@sanity/icons'
|
|
2
2
|
import {Button} from '@sanity/ui'
|
|
3
3
|
import {useCallback} from 'react'
|
|
4
|
-
import {useDocumentPane} from 'sanity/
|
|
4
|
+
import {useDocumentPane} from 'sanity/structure'
|
|
5
5
|
|
|
6
6
|
import {aiInspectorId} from '../../../assistInspector/constants'
|
|
7
7
|
import {instructionParam} from '../../../types'
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import {Box} from '@sanity/ui'
|
|
2
2
|
import {useEffect} from 'react'
|
|
3
|
-
import {ArrayOfObjectsInputProps, set, typed} from 'sanity'
|
|
4
|
-
import styled from 'styled-components'
|
|
3
|
+
import {type ArrayOfObjectsInputProps, set, typed} from 'sanity'
|
|
4
|
+
import {styled} from 'styled-components'
|
|
5
5
|
|
|
6
6
|
import {randomKey} from '../../../_lib/randomKey'
|
|
7
|
-
import {
|
|
7
|
+
import type {
|
|
8
|
+
ContextBlock,
|
|
9
|
+
FieldRef,
|
|
10
|
+
PromptBlock,
|
|
11
|
+
PromptTextBlock,
|
|
12
|
+
UserInputBlock,
|
|
13
|
+
} from '../../../types'
|
|
8
14
|
|
|
9
15
|
const PteMods = styled(Box)`
|
|
10
16
|
& [data-testid='pt-editor__toolbar-card'] > div > div:last-child {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {useMemo} from 'react'
|
|
2
|
-
import {getPublishedId, ObjectSchemaType, useEditState} from 'sanity'
|
|
3
|
-
import {useDocumentPane} from 'sanity/
|
|
2
|
+
import {getPublishedId, type ObjectSchemaType, useEditState} from 'sanity'
|
|
3
|
+
import {useDocumentPane} from 'sanity/structure'
|
|
4
4
|
|
|
5
5
|
import {useAiPaneRouter} from '../../assistInspector/helpers'
|
|
6
6
|
import {fieldPathParam} from '../../types'
|
|
7
|
-
import {AssistDocumentContextValue} from '../AssistDocumentContext'
|
|
7
|
+
import type {AssistDocumentContextValue} from '../AssistDocumentContext'
|
|
8
8
|
import {isDocAssistable} from '../RequestRunInstructionProvider'
|
|
9
9
|
import {useStudioAssistDocument} from './useStudioAssistDocument'
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {Box, ButtonTone, Flex, MenuItem, Stack, Text} from '@sanity/ui'
|
|
1
|
+
import {Box, type ButtonTone, Flex, MenuItem, Stack, Text} from '@sanity/ui'
|
|
2
2
|
import {useCallback} from 'react'
|
|
3
|
-
import {Path, ValidationMarker} from 'sanity'
|
|
4
|
-
import styled from 'styled-components'
|
|
3
|
+
import type {Path, ValidationMarker} from 'sanity'
|
|
4
|
+
import {styled} from 'styled-components'
|
|
5
5
|
|
|
6
6
|
interface ValidationListItemProps {
|
|
7
7
|
marker: ValidationMarker
|
|
@@ -2,18 +2,18 @@ import {ArrowRightIcon, CloseIcon, PlayIcon, RetryIcon} from '@sanity/icons'
|
|
|
2
2
|
import {Box, Button, Card, Flex, Spinner, Stack, Text} from '@sanity/ui'
|
|
3
3
|
import {useCallback, useMemo, useRef} from 'react'
|
|
4
4
|
import {
|
|
5
|
-
DocumentInspectorProps,
|
|
5
|
+
type DocumentInspectorProps,
|
|
6
6
|
PresenceOverlay,
|
|
7
7
|
useEditState,
|
|
8
8
|
VirtualizerScrollInstanceProvider,
|
|
9
9
|
} from 'sanity'
|
|
10
10
|
import {
|
|
11
11
|
DocumentInspectorHeader,
|
|
12
|
-
DocumentPaneNode,
|
|
12
|
+
type DocumentPaneNode,
|
|
13
13
|
DocumentPaneProvider,
|
|
14
14
|
useDocumentPane,
|
|
15
|
-
} from 'sanity/
|
|
16
|
-
import styled from 'styled-components'
|
|
15
|
+
} from 'sanity/structure'
|
|
16
|
+
import {styled} from 'styled-components'
|
|
17
17
|
|
|
18
18
|
import {DocumentForm} from '../_lib/form'
|
|
19
19
|
import {TypePathContext} from '../assistDocument/components/AssistDocumentForm'
|
|
@@ -31,7 +31,13 @@ import {InspectorOnboarding} from '../onboarding/InspectorOnboarding'
|
|
|
31
31
|
import {inspectorOnboardingKey, useOnboardingFeature} from '../onboarding/onboardingStore'
|
|
32
32
|
import {assistDocumentTypeName, fieldPathParam, instructionParam} from '../types'
|
|
33
33
|
import {FieldTitle} from './FieldAutocomplete'
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
type FieldRef,
|
|
36
|
+
getFieldTitle,
|
|
37
|
+
useAiPaneRouter,
|
|
38
|
+
useSelectedField,
|
|
39
|
+
useTypePath,
|
|
40
|
+
} from './helpers'
|
|
35
41
|
import {InstructionTaskHistoryButton} from './InstructionTaskHistoryButton'
|
|
36
42
|
|
|
37
43
|
const CardWithShadowBelow = styled(Card)`
|
|
@@ -18,15 +18,15 @@ import {
|
|
|
18
18
|
useGlobalKeyDown,
|
|
19
19
|
useLayer,
|
|
20
20
|
} from '@sanity/ui'
|
|
21
|
-
import {createElement, ForwardedRef, forwardRef, useCallback, useMemo, useState} from 'react'
|
|
22
|
-
import {StatusButton, StatusButtonProps, typed, useClient} from 'sanity'
|
|
23
|
-
import
|
|
21
|
+
import {createElement, type ForwardedRef, forwardRef, useCallback, useMemo, useState} from 'react'
|
|
22
|
+
import {StatusButton, type StatusButtonProps, typed, useClient} from 'sanity'
|
|
23
|
+
import {keyframes, styled} from 'styled-components'
|
|
24
24
|
|
|
25
25
|
import {TimeAgo} from '../components/TimeAgo'
|
|
26
26
|
import {maxHistoryVisibilityMs, pluginTitle} from '../constants'
|
|
27
27
|
import {assistTasksStatusId} from '../helpers/ids'
|
|
28
28
|
import {getInstructionTitle} from '../helpers/misc'
|
|
29
|
-
import {AssistTasksStatus, InstructionTask, StudioInstruction, TaskEndedReason} from '../types'
|
|
29
|
+
import type {AssistTasksStatus, InstructionTask, StudioInstruction, TaskEndedReason} from '../types'
|
|
30
30
|
|
|
31
31
|
export interface InstructionTaskHistoryButtonProps {
|
|
32
32
|
documentId?: string
|
|
@@ -8,24 +8,24 @@ import {
|
|
|
8
8
|
StringIcon,
|
|
9
9
|
} from '@sanity/icons'
|
|
10
10
|
import {extractWithPath} from '@sanity/mutator'
|
|
11
|
-
import {ComponentType, useContext, useMemo} from 'react'
|
|
11
|
+
import {type ComponentType, useContext, useMemo} from 'react'
|
|
12
12
|
import {
|
|
13
|
-
ArraySchemaType,
|
|
13
|
+
type ArraySchemaType,
|
|
14
14
|
isKeySegment,
|
|
15
15
|
isObjectSchemaType,
|
|
16
|
-
ObjectSchemaType,
|
|
17
|
-
Path,
|
|
16
|
+
type ObjectSchemaType,
|
|
17
|
+
type Path,
|
|
18
18
|
pathToString,
|
|
19
|
-
SanityDocumentLike,
|
|
20
|
-
SchemaType,
|
|
19
|
+
type SanityDocumentLike,
|
|
20
|
+
type SchemaType,
|
|
21
21
|
stringToPath,
|
|
22
22
|
} from 'sanity'
|
|
23
|
-
import {type PaneRouterContextValue, usePaneRouter} from 'sanity/
|
|
23
|
+
import {type PaneRouterContextValue, usePaneRouter} from 'sanity/structure'
|
|
24
24
|
|
|
25
25
|
import {SelectedFieldContext} from '../assistDocument/components/SelectedFieldContext'
|
|
26
26
|
import {isAssistSupported} from '../helpers/assistSupported'
|
|
27
27
|
import {isPortableTextArray, isType} from '../helpers/typeUtils'
|
|
28
|
-
import {AssistInspectorRouteParams, documentRootKey, fieldPathParam} from '../types'
|
|
28
|
+
import {type AssistInspectorRouteParams, documentRootKey, fieldPathParam} from '../types'
|
|
29
29
|
|
|
30
30
|
export interface FieldRef {
|
|
31
31
|
key: string
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {forwardRef, ReactElement, ReactNode} from 'react'
|
|
2
|
-
import
|
|
1
|
+
import {forwardRef, type ReactElement, type ReactNode} from 'react'
|
|
2
|
+
import {keyframes, styled} from 'styled-components'
|
|
3
3
|
|
|
4
4
|
const fadeIn = keyframes`
|
|
5
5
|
0% {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {createContext, useEffect, useMemo, useState} from 'react'
|
|
2
|
-
import {InputProps, pathToString, useSyncState} from 'sanity'
|
|
3
|
-
import {usePaneRouter} from 'sanity/
|
|
2
|
+
import {type InputProps, pathToString, useSyncState} from 'sanity'
|
|
3
|
+
import {usePaneRouter} from 'sanity/structure'
|
|
4
4
|
|
|
5
5
|
import {useAssistDocumentContext} from '../assistDocument/AssistDocumentContext'
|
|
6
6
|
import {useAiAssistanceConfig} from '../assistLayout/AiAssistanceConfigContext'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Box, Button, Card, ErrorBoundary, Flex, Stack, Text} from '@sanity/ui'
|
|
2
|
-
import {ErrorInfo, PropsWithChildren, useCallback, useMemo, useState} from 'react'
|
|
3
|
-
import {InputProps, isArraySchemaType, PatchEvent, unset} from 'sanity'
|
|
4
|
-
import styled from 'styled-components'
|
|
2
|
+
import {type ErrorInfo, type PropsWithChildren, useCallback, useMemo, useState} from 'react'
|
|
3
|
+
import {type InputProps, isArraySchemaType, PatchEvent, unset} from 'sanity'
|
|
4
|
+
import {styled} from 'styled-components'
|
|
5
5
|
|
|
6
6
|
import {isPortableTextArray} from '../helpers/typeUtils'
|
|
7
7
|
|
|
@@ -25,12 +25,9 @@ export function ErrorWrapper(
|
|
|
25
25
|
const {onChange} = props
|
|
26
26
|
const [error, setError] = useState<Error | undefined>()
|
|
27
27
|
|
|
28
|
-
const catchError = useCallback(
|
|
29
|
-
(params
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
[setError],
|
|
33
|
-
)
|
|
28
|
+
const catchError = useCallback((params: {error: Error; info: ErrorInfo}) => {
|
|
29
|
+
setError(params.error)
|
|
30
|
+
}, [])
|
|
34
31
|
|
|
35
32
|
const unsetValue = useCallback(() => {
|
|
36
33
|
onChange(PatchEvent.from(unset()))
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
typed,
|
|
9
9
|
useCurrentUser,
|
|
10
10
|
} from 'sanity'
|
|
11
|
-
import {useDocumentPane} from 'sanity/
|
|
11
|
+
import {useDocumentPane} from 'sanity/structure'
|
|
12
12
|
|
|
13
13
|
import {useAssistDocumentContext} from '../assistDocument/AssistDocumentContext'
|
|
14
14
|
import {getIcon} from '../assistDocument/components/instruction/appearance/IconInput'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {ImageIcon} from '@sanity/icons'
|
|
2
2
|
import {Box, Spinner} from '@sanity/ui'
|
|
3
3
|
import {useContext, useMemo} from 'react'
|
|
4
|
-
import {DocumentFieldAction, DocumentFieldActionGroup, DocumentFieldActionItem} from 'sanity'
|
|
5
|
-
import {useDocumentPane} from 'sanity/
|
|
4
|
+
import type {DocumentFieldAction, DocumentFieldActionGroup, DocumentFieldActionItem} from 'sanity'
|
|
5
|
+
import {useDocumentPane} from 'sanity/structure'
|
|
6
6
|
|
|
7
7
|
import {useAssistDocumentContext} from '../assistDocument/AssistDocumentContext'
|
|
8
8
|
import {aiInspectorId} from '../assistInspector/constants'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {purple} from '@sanity/color'
|
|
2
2
|
import {SparklesIcon} from '@sanity/icons'
|
|
3
3
|
import {Text} from '@sanity/ui'
|
|
4
|
-
import {CSSProperties, useMemo} from 'react'
|
|
4
|
+
import {type CSSProperties, useMemo} from 'react'
|
|
5
5
|
import {useColorSchemeValue} from 'sanity'
|
|
6
|
-
import
|
|
6
|
+
import {keyframes, styled} from 'styled-components'
|
|
7
7
|
|
|
8
8
|
const Root = styled.span`
|
|
9
9
|
display: block;
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
DocumentFieldActionProps,
|
|
10
10
|
ObjectSchemaType,
|
|
11
11
|
} from 'sanity'
|
|
12
|
-
import {useDocumentPane} from 'sanity/
|
|
12
|
+
import {useDocumentPane} from 'sanity/structure'
|
|
13
13
|
|
|
14
14
|
import {useDraftDelayedTask} from '../assistDocument/RequestRunInstructionProvider'
|
|
15
15
|
import {useAiAssistanceConfig} from '../assistLayout/AiAssistanceConfigContext'
|
package/dist/index.cjs.mjs
DELETED