@sanity/assist 2.0.4 → 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.
Files changed (96) hide show
  1. package/README.md +2 -2
  2. package/dist/index.d.mts +377 -0
  3. package/dist/index.esm.js +3132 -5883
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +3109 -5886
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +4159 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +32 -37
  10. package/src/_lib/connector/ConnectFromRegion.tsx +4 -3
  11. package/src/_lib/connector/ConnectToRegion.tsx +1 -0
  12. package/src/_lib/connector/ConnectorRegion.tsx +2 -1
  13. package/src/_lib/connector/ConnectorsProvider.tsx +2 -1
  14. package/src/_lib/connector/ConnectorsStoreContext.ts +1 -0
  15. package/src/_lib/connector/index.ts +1 -1
  16. package/src/_lib/connector/mapConnectorToLine.ts +2 -2
  17. package/src/_lib/connector/useConnectorsStore.ts +2 -1
  18. package/src/_lib/connector/useRegionRects.ts +4 -3
  19. package/src/_lib/fixedListenQuery.ts +11 -11
  20. package/src/_lib/form/DocumentForm.tsx +11 -9
  21. package/src/_lib/form/helpers.ts +2 -1
  22. package/src/_lib/useListeningQuery.ts +4 -3
  23. package/src/assistConnectors/AssistConnectorsOverlay.tsx +1 -0
  24. package/src/assistConnectors/ConnectorPath.tsx +3 -2
  25. package/src/assistConnectors/draw/connectorPath.ts +13 -13
  26. package/src/assistDocument/AssistDocumentContext.tsx +3 -2
  27. package/src/assistDocument/AssistDocumentContextProvider.tsx +2 -1
  28. package/src/assistDocument/AssistDocumentInput.tsx +10 -9
  29. package/src/assistDocument/RequestRunInstructionProvider.tsx +4 -3
  30. package/src/assistDocument/components/AssistDocumentForm.tsx +25 -24
  31. package/src/assistDocument/components/FieldRefPreview.tsx +4 -3
  32. package/src/assistDocument/components/InstructionsArrayInput.tsx +4 -3
  33. package/src/assistDocument/components/SelectedFieldContext.tsx +1 -1
  34. package/src/assistDocument/components/helpers.ts +4 -4
  35. package/src/assistDocument/components/instruction/BackToInstructionsLink.tsx +4 -3
  36. package/src/assistDocument/components/instruction/FieldRefInput.tsx +5 -4
  37. package/src/assistDocument/components/instruction/InstructionInput.tsx +3 -2
  38. package/src/assistDocument/components/instruction/InstructionOutputField.tsx +2 -1
  39. package/src/assistDocument/components/instruction/InstructionOutputInput.tsx +14 -13
  40. package/src/assistDocument/components/instruction/PromptInput.tsx +10 -3
  41. package/src/assistDocument/components/instruction/appearance/IconInput.tsx +2 -2
  42. package/src/assistDocument/components/instruction/appearance/InstructionVisibility.tsx +1 -1
  43. package/src/assistDocument/hooks/useAssistDocumentContextValue.tsx +8 -7
  44. package/src/assistDocument/hooks/useInstructionToaster.tsx +6 -5
  45. package/src/assistDocument/hooks/useStudioAssistDocument.ts +14 -13
  46. package/src/assistFormComponents/AssistField.tsx +9 -8
  47. package/src/assistFormComponents/AssistFormBlock.tsx +5 -4
  48. package/src/assistFormComponents/AssistInlineFormBlock.tsx +1 -1
  49. package/src/assistFormComponents/AssistItem.tsx +3 -2
  50. package/src/assistFormComponents/validation/listItem.tsx +3 -3
  51. package/src/assistFormComponents/validation/validationList.tsx +3 -2
  52. package/src/assistInspector/AssistInspector.tsx +25 -18
  53. package/src/assistInspector/FieldAutocomplete.tsx +4 -3
  54. package/src/assistInspector/InstructionTaskHistoryButton.tsx +20 -19
  55. package/src/assistInspector/helpers.ts +16 -15
  56. package/src/assistInspector/index.ts +4 -3
  57. package/src/assistLayout/AiAssistanceConfigContext.tsx +1 -0
  58. package/src/assistLayout/AssistLayout.tsx +5 -4
  59. package/src/assistLayout/RunInstructionProvider.tsx +18 -15
  60. package/src/components/FadeInContent.tsx +3 -3
  61. package/src/components/HideReferenceChangedBannerInput.tsx +1 -1
  62. package/src/components/ImageContext.tsx +5 -4
  63. package/src/components/SafeValueInput.tsx +9 -11
  64. package/src/components/TimeAgo.tsx +1 -1
  65. package/src/fieldActions/assistFieldActions.tsx +31 -30
  66. package/src/fieldActions/generateCaptionActions.tsx +8 -7
  67. package/src/fieldActions/generateImageActions.tsx +6 -5
  68. package/src/helpers/assistSupported.ts +1 -0
  69. package/src/helpers/conditionalMembers.test.ts +2 -1
  70. package/src/helpers/conditionalMembers.ts +17 -14
  71. package/src/helpers/misc.ts +3 -2
  72. package/src/helpers/typeUtils.ts +1 -1
  73. package/src/helpers/useAssistSupported.ts +2 -1
  74. package/src/onboarding/FieldActionsOnboarding.tsx +2 -1
  75. package/src/onboarding/FirstAssistedPathProvider.tsx +4 -3
  76. package/src/onboarding/InspectorOnboarding.tsx +3 -2
  77. package/src/onboarding/onboardingStore.ts +1 -1
  78. package/src/presence/AiFieldPresence.tsx +3 -1
  79. package/src/presence/AssistAvatar.tsx +2 -2
  80. package/src/presence/AssistDocumentPresence.tsx +7 -6
  81. package/src/presence/useAssistPresence.ts +6 -3
  82. package/src/schemas/assistDocumentSchema.tsx +21 -20
  83. package/src/schemas/contextDocumentSchema.tsx +3 -2
  84. package/src/schemas/index.ts +2 -1
  85. package/src/schemas/serialize/SchemTypeTool.tsx +4 -3
  86. package/src/schemas/serialize/serializeSchema.test.ts +3 -2
  87. package/src/schemas/serialize/serializeSchema.ts +15 -14
  88. package/src/schemas/serializedSchemaTypeSchema.ts +2 -1
  89. package/src/translate/FieldTranslationProvider.tsx +33 -25
  90. package/src/translate/getLanguageParams.ts +4 -4
  91. package/src/translate/paths.test.ts +11 -4
  92. package/src/translate/paths.ts +12 -11
  93. package/src/translate/translateActions.tsx +12 -11
  94. package/src/translate/types.ts +2 -2
  95. package/src/useApiClient.ts +9 -9
  96. package/dist/index.cjs.mjs +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/assist",
3
- "version": "2.0.4",
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
- "node": {
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 && plugin-kit verify-package --silent && pkg-utils build --strict && pkg-utils --strict",
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,48 +50,47 @@
54
50
  "release": "semantic-release"
55
51
  },
56
52
  "dependencies": {
57
- "@sanity/icons": "^2.8.0",
53
+ "@sanity/icons": "^2.11.7",
58
54
  "@sanity/incompatible-plugin": "^1.0.4",
59
- "@sanity/ui": "^2.0.2",
60
- "date-fns": "^2.30.0",
61
- "lodash.get": "^4.4.2",
62
- "react-fast-compare": "^3.2.1",
63
- "react-is": "^18.2.0",
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
- "@commitlint/cli": "^18.4.3",
69
- "@commitlint/config-conventional": "^18.4.3",
63
+ "@commitlint/cli": "^19.2.1",
64
+ "@commitlint/config-conventional": "^19.1.0",
70
65
  "@rollup/plugin-image": "^3.0.3",
71
- "@sanity/pkg-utils": "^2.4.10",
66
+ "@sanity/pkg-utils": "^6.1.0",
72
67
  "@sanity/plugin-kit": "^3.1.10",
73
68
  "@sanity/semantic-release-preset": "^4.1.7",
74
- "@types/react": "^18.2.37",
75
- "@types/styled-components": "^5.1.30",
76
- "@typescript-eslint/eslint-plugin": "^7.0.1",
77
- "@typescript-eslint/parser": "^7.0.1",
78
- "date-fns": "^2.30.0",
79
- "eslint": "^8.56.0",
80
- "eslint-config-prettier": "^8.10.0",
81
- "eslint-config-sanity": "^6.0.0",
82
- "eslint-plugin-prettier": "^4.2.1",
83
- "eslint-plugin-react": "^7.33.2",
69
+ "@types/lodash": "^4.17.0",
70
+ "@types/react": "^18.2.75",
71
+ "@typescript-eslint/eslint-plugin": "^7.6.0",
72
+ "@typescript-eslint/parser": "^7.6.0",
73
+ "eslint": "^8.57.0",
74
+ "eslint-config-prettier": "^9.1.0",
75
+ "eslint-config-sanity": "^7.1.2",
76
+ "eslint-plugin-prettier": "^5.1.3",
77
+ "eslint-plugin-react": "^7.34.1",
84
78
  "eslint-plugin-react-hooks": "^4.6.0",
85
- "npm-run-all": "^4.1.5",
79
+ "npm-run-all2": "^5.0.0",
86
80
  "react": "^18.2.0",
87
81
  "react-dom": "^18.2.0",
88
82
  "rimraf": "^5.0.5",
89
- "sanity": "^3.28.0",
90
- "semantic-release": "^23.0.2",
91
- "styled-components": "^6.1.1",
92
- "typescript": "^5.3.3",
93
- "vitest": "^1.2.1"
83
+ "sanity": "^3.36.4",
84
+ "semantic-release": "^23.0.7",
85
+ "styled-components": "^6.1.8",
86
+ "typescript": "5.4.2",
87
+ "vitest": "^1.4.0"
94
88
  },
95
89
  "peerDependencies": {
90
+ "@sanity/mutator": "^3.36.4",
96
91
  "react": "^18",
97
- "sanity": "^3.26",
98
- "styled-components": "^5.2 || ^6.0.0"
92
+ "sanity": "^3.36.4",
93
+ "styled-components": "^6.1"
99
94
  },
100
95
  "engines": {
101
96
  "node": ">=14"
@@ -1,10 +1,11 @@
1
1
  import {HTMLProps, useEffect, useState} from 'react'
2
- import {useConnectorsStore} from './useConnectorsStore'
3
- import {ConnectorRegionRects} from './types'
2
+
4
3
  import {ConnectorRegion} from './ConnectorRegion'
4
+ import {ConnectorRegionRects} from './types'
5
+ import {useConnectorsStore} from './useConnectorsStore'
5
6
 
6
7
  export function ConnectFromRegion(
7
- props: {_key: string; zIndex: number} & HTMLProps<HTMLDivElement>
8
+ props: {_key: string; zIndex: number} & HTMLProps<HTMLDivElement>,
8
9
  ) {
9
10
  const {children, _key: key, zIndex, ...restProps} = props
10
11
  const store = useConnectorsStore()
@@ -1,4 +1,5 @@
1
1
  import {HTMLProps, useEffect, useState} from 'react'
2
+
2
3
  import {ConnectorRegion} from './ConnectorRegion'
3
4
  import {ConnectorRegionRects} from './types'
4
5
  import {useConnectorsStore} from './useConnectorsStore'
@@ -1,11 +1,12 @@
1
1
  import {HTMLProps, useEffect} from 'react'
2
+
2
3
  import {ConnectorRegionRects} from './types'
3
4
  import {useRegionRects} from './useRegionRects'
4
5
 
5
6
  export function ConnectorRegion(
6
7
  props: {
7
8
  onRectsChange?: (rects: ConnectorRegionRects | null) => void
8
- } & HTMLProps<HTMLDivElement>
9
+ } & HTMLProps<HTMLDivElement>,
9
10
  ) {
10
11
  const {children, onRectsChange, ...restProps} = props
11
12
 
@@ -1,4 +1,5 @@
1
1
  import {ReactNode, useEffect, useMemo} from 'react'
2
+
2
3
  import {ConnectorsStore, createConnectorsStore} from './ConnectorsStore'
3
4
  import {ConnectorsStoreContext} from './ConnectorsStoreContext'
4
5
  import {Connector} from './types'
@@ -12,7 +13,7 @@ export function ConnectorsProvider(props: {
12
13
 
13
14
  useEffect(
14
15
  () => onConnectorsChange && store.connectors.subscribe(onConnectorsChange),
15
- [onConnectorsChange, store]
16
+ [onConnectorsChange, store],
16
17
  )
17
18
 
18
19
  return <ConnectorsStoreContext.Provider value={store}>{children}</ConnectorsStoreContext.Provider>
@@ -1,4 +1,5 @@
1
1
  import {createContext} from 'react'
2
+
2
3
  import {ConnectorsStore} from './ConnectorsStore'
3
4
 
4
5
  export const ConnectorsStoreContext = createContext<ConnectorsStore | null>(null)
@@ -1,9 +1,9 @@
1
1
  export * from './ConnectFromRegion'
2
- export * from './ConnectToRegion'
3
2
  export * from './ConnectorRegion'
4
3
  export * from './ConnectorsProvider'
5
4
  export * from './ConnectorsStore'
6
5
  export * from './ConnectorsStoreContext'
6
+ export * from './ConnectToRegion'
7
7
  export * from './mapConnectorToLine'
8
8
  export * from './types'
9
9
  export * from './useConnectorsStore'
@@ -9,7 +9,7 @@ import {
9
9
  function getConnectorLinePoint(
10
10
  options: ConnectorOptions,
11
11
  rect: Rect,
12
- bounds: Rect
12
+ bounds: Rect,
13
13
  ): ConnectorLinePoint {
14
14
  const centerY = rect.y + rect.h / 2
15
15
  const isAbove = rect.y + rect.h < bounds.y + options.arrow.marginY
@@ -30,7 +30,7 @@ function getConnectorLinePoint(
30
30
 
31
31
  export function mapConnectorToLine(
32
32
  options: ConnectorOptions,
33
- connector: {from: ConnectorRegionRects; to: ConnectorRegionRects}
33
+ connector: {from: ConnectorRegionRects; to: ConnectorRegionRects},
34
34
  ): ConnectorLine {
35
35
  const fromBounds: Rect = {
36
36
  y: connector.from.bounds.y + options.arrow.threshold,
@@ -1,6 +1,7 @@
1
1
  import {useContext} from 'react'
2
- import {ConnectorsStoreContext} from './ConnectorsStoreContext'
2
+
3
3
  import {ConnectorsStore} from './ConnectorsStore'
4
+ import {ConnectorsStoreContext} from './ConnectorsStoreContext'
4
5
 
5
6
  export function useConnectorsStore(): ConnectorsStore {
6
7
  const store = useContext(ConnectorsStoreContext)
@@ -1,6 +1,7 @@
1
1
  import {useEffect, useMemo, useRef, useState} from 'react'
2
- import {Rect, Scroll} from './types'
2
+
3
3
  import {hasOverflowScroll} from './helpers'
4
+ import {Rect, Scroll} from './types'
4
5
 
5
6
  export function useRegionRects() {
6
7
  const ref = useRef<HTMLDivElement>(null)
@@ -123,7 +124,7 @@ export function useRegionRects() {
123
124
  w: relativeBoundsRect.w,
124
125
  h: relativeBoundsRect.h,
125
126
  },
126
- [relativeBoundsRect, boundsScroll]
127
+ [relativeBoundsRect, boundsScroll],
127
128
  )
128
129
 
129
130
  const element: Rect | null = useMemo(
@@ -134,7 +135,7 @@ export function useRegionRects() {
134
135
  w: relativeElementRect.w,
135
136
  h: relativeElementRect.h,
136
137
  },
137
- [relativeElementRect, scroll]
138
+ [relativeElementRect, scroll],
138
139
  )
139
140
 
140
141
  return {bounds, element, ref}
@@ -19,21 +19,21 @@ const fetch = (
19
19
  client: SanityClient,
20
20
  query: string,
21
21
  params: ListenQueryParams,
22
- options: ListenQueryOptions
22
+ options: ListenQueryOptions,
23
23
  ) =>
24
24
  defer(() =>
25
25
  // getVersionedClient(options.apiVersion)
26
26
  client.observable.fetch(query, params, {
27
27
  tag: options.tag,
28
28
  filterResponse: true,
29
- })
29
+ }),
30
30
  )
31
31
 
32
32
  const listen = (
33
33
  client: SanityClient,
34
34
  query: string,
35
35
  params: ListenQueryParams,
36
- options: ListenQueryOptions
36
+ options: ListenQueryOptions,
37
37
  ) =>
38
38
  defer(() =>
39
39
  // getVersionedClient(options.apiVersion)
@@ -42,11 +42,11 @@ const listen = (
42
42
  includeResult: false,
43
43
  visibility: 'query',
44
44
  tag: options.tag,
45
- })
45
+ }),
46
46
  ) as Observable<ReconnectEvent | WelcomeEvent | MutationEvent>
47
47
 
48
48
  function isWelcomeEvent(
49
- event: MutationEvent | ReconnectEvent | WelcomeEvent
49
+ event: MutationEvent | ReconnectEvent | WelcomeEvent,
50
50
  ): event is WelcomeEvent {
51
51
  return event.type === 'welcome'
52
52
  }
@@ -56,7 +56,7 @@ export const listenQuery = (
56
56
  client: SanityClient,
57
57
  query: string | {fetch: string; listen: string},
58
58
  params: ListenQueryParams = {},
59
- options: ListenQueryOptions = {}
59
+ options: ListenQueryOptions = {},
60
60
  ) => {
61
61
  const fetchQuery = typeof query === 'string' ? query : query.fetch
62
62
  const listenerQuery = typeof query === 'string' ? query : query.listen
@@ -73,13 +73,13 @@ export const listenQuery = (
73
73
  new Error(
74
74
  ev.type === 'reconnect'
75
75
  ? 'Could not establish EventSource connection'
76
- : `Received unexpected type of first event "${ev.type}"`
77
- )
76
+ : `Received unexpected type of first event "${ev.type}"`,
77
+ ),
78
78
  )
79
79
  }
80
80
  return of(ev)
81
81
  }),
82
- share()
82
+ share(),
83
83
  )
84
84
 
85
85
  const [welcome$, mutationAndReconnect$] = partition(events$, isWelcomeEvent)
@@ -95,7 +95,7 @@ export const listenQuery = (
95
95
  welcome$.pipe(take(1)),
96
96
  mutationAndReconnect$.pipe(
97
97
  filter(isRelevantEvent),
98
- switchMap((event) => merge(of(event), of(event).pipe(delay(options.throttleTime || 1000))))
99
- )
98
+ switchMap((event) => merge(of(event), of(event).pipe(delay(options.throttleTime || 1000)))),
99
+ ),
100
100
  ).pipe(exhaustMapToWithTrailing(fetchOnce$))
101
101
  }
@@ -1,23 +1,25 @@
1
- import {Box, BoxProps, Flex, focusFirstDescendant, Spinner, Text} from '@sanity/ui'
2
- import React, {HTMLProps, useEffect, useMemo, useRef} from '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/desk'
15
+ import {useDocumentPane} from 'sanity/structure'
16
+
15
17
  import {assistFormId} from './constants'
16
18
 
17
19
  const preventDefault = (ev: React.FormEvent) => ev.preventDefault()
18
20
 
19
21
  export function DocumentForm(
20
- props: Omit<BoxProps, 'as'> & Omit<HTMLProps<HTMLDivElement>, 'as' | 'onSubmit' | 'ref'>
22
+ props: Omit<BoxProps, 'as'> & Omit<HTMLProps<HTMLDivElement>, 'as' | 'onSubmit' | 'ref'>,
21
23
  ) {
22
24
  const {
23
25
  collapsedFieldSets,
@@ -61,7 +63,7 @@ export function DocumentForm(
61
63
  if (event.type === 'rebase') {
62
64
  patchChannel.publish(prepareRebaseEvent(event))
63
65
  }
64
- })
66
+ }),
65
67
  )
66
68
  .subscribe()
67
69
 
@@ -192,7 +194,7 @@ function prepareRebaseEvent(event: DocumentRebaseEvent): PatchMsg {
192
194
  type: 'rebase',
193
195
  snapshot: event.document,
194
196
  patches: fromMutationPatches('remote', remotePatches).concat(
195
- fromMutationPatches('local', localPatches)
197
+ fromMutationPatches('local', localPatches),
196
198
  ),
197
199
  }
198
200
  }
@@ -1,4 +1,5 @@
1
1
  import {isArraySchemaType, isObjectSchemaType, ObjectItem, SchemaType} from 'sanity'
2
+
2
3
  import {randomKey} from '../randomKey'
3
4
 
4
5
  export function createProtoValue(type: SchemaType): any {
@@ -23,7 +24,7 @@ export function createProtoValue(type: SchemaType): any {
23
24
  export function createProtoArrayValue<Item extends ObjectItem>(type: SchemaType): Item {
24
25
  if (!isObjectSchemaType(type)) {
25
26
  throw new Error(
26
- `Invalid item type: "${type.type}". Default array input can only contain objects (for now)`
27
+ `Invalid item type: "${type.type}". Default array input can only contain objects (for now)`,
27
28
  )
28
29
  }
29
30
 
@@ -1,7 +1,8 @@
1
1
  import {useEffect, useRef, useState} from 'react'
2
- import {catchError, distinctUntilChanged} from 'rxjs/operators'
3
2
  import isEqual from 'react-fast-compare'
3
+ import {catchError, distinctUntilChanged} from 'rxjs/operators'
4
4
  import {ListenQueryOptions, useClient} from 'sanity'
5
+
5
6
  import {listenQuery} from './fixedListenQuery'
6
7
 
7
8
  type Params = Record<string, string | number | boolean | string[]>
@@ -22,7 +23,7 @@ const DEFAULT_OPTIONS: ListenQueryOptions = {apiVersion: `v2022-05-09`}
22
23
  export function useListeningQuery<T>(
23
24
  query: string,
24
25
  params: Params = DEFAULT_PARAMS,
25
- options: ListenQueryOptions = DEFAULT_OPTIONS
26
+ options: ListenQueryOptions = DEFAULT_OPTIONS,
26
27
  ): ReturnShape<T> {
27
28
  const [loading, setLoading] = useState(true)
28
29
  const [error, setError] = useState(false)
@@ -43,7 +44,7 @@ export function useListeningQuery<T>(
43
44
  setData(null)
44
45
 
45
46
  return err
46
- })
47
+ }),
47
48
  )
48
49
  .subscribe((documents) => {
49
50
  setData((current) => (isEqual(current, documents) ? current : documents))
@@ -1,4 +1,5 @@
1
1
  import {Fragment, useEffect, useState} from 'react'
2
+
2
3
  import {Connector, ConnectorOptions} from '../_lib/connector'
3
4
  import {ConnectorPath} from './ConnectorPath'
4
5
 
@@ -1,5 +1,6 @@
1
1
  import {rgba, useTheme} from '@sanity/ui'
2
2
  import {useMemo} from 'react'
3
+
3
4
  import {ConnectorOptions, mapConnectorToLine, Rect} from '../_lib/connector'
4
5
  import {arrowPath} from './draw/arrowPath'
5
6
  import {drawConnectorPath} from './draw/connectorPath'
@@ -35,7 +36,7 @@ export function ConnectorPath(props: {
35
36
  options,
36
37
  line.from.x + options.arrow.marginX,
37
38
  line.from.bounds.y - options.arrow.threshold + options.arrow.marginY,
38
- -1
39
+ -1,
39
40
  )}
40
41
  stroke={theme.sanity.color.base.border}
41
42
  strokeWidth={strokeWidth}
@@ -51,7 +52,7 @@ export function ConnectorPath(props: {
51
52
  line.from.bounds.h +
52
53
  options.arrow.threshold -
53
54
  options.arrow.marginY,
54
- 1
55
+ 1,
55
56
  )}
56
57
  stroke={theme.sanity.color.base.border}
57
58
  strokeWidth={strokeWidth}
@@ -4,7 +4,7 @@ export function drawArrowPath(
4
4
  options: ConnectorOptions,
5
5
  x: number,
6
6
  y: number,
7
- dir: number
7
+ dir: number,
8
8
  ): string {
9
9
  return [
10
10
  `M ${x - options.arrow.size} ${y - options.arrow.size * dir} `,
@@ -54,19 +54,19 @@ export function drawConnectorPath(options: ConnectorOptions, line: ConnectorLine
54
54
  cmds.push(
55
55
  moveTo(
56
56
  fromX + options.arrow.marginX,
57
- fromY - options.arrow.threshold + options.arrow.marginY
57
+ fromY - options.arrow.threshold + options.arrow.marginY,
58
58
  ),
59
59
  lineTo(fromX + options.arrow.marginX, fromY - r0),
60
- quadCurve(fromX + options.arrow.marginX, fromY, fromX + options.arrow.marginX + r0, fromY)
60
+ quadCurve(fromX + options.arrow.marginX, fromY, fromX + options.arrow.marginX + r0, fromY),
61
61
  )
62
62
  } else if (from.isBelow) {
63
63
  cmds.push(
64
64
  moveTo(
65
65
  fromX + options.arrow.marginX,
66
- fromY + options.arrow.threshold - options.arrow.marginY
66
+ fromY + options.arrow.threshold - options.arrow.marginY,
67
67
  ),
68
68
  lineTo(fromX + options.arrow.marginX, fromY + r0),
69
- quadCurve(fromX + options.arrow.marginX, fromY, fromX + options.arrow.marginX + r0, fromY)
69
+ quadCurve(fromX + options.arrow.marginX, fromY, fromX + options.arrow.marginX + r0, fromY),
70
70
  )
71
71
  } else {
72
72
  cmds.push(moveTo(fromX, fromY))
@@ -82,13 +82,13 @@ export function drawConnectorPath(options: ConnectorOptions, line: ConnectorLine
82
82
  quadCurve(dividerX, toY, dividerX + r1, toY),
83
83
  lineTo(dividerX - cornerRadius, toY),
84
84
  quadCurve(dividerX, toY, dividerX, toY - cornerRadius),
85
- lineTo(dividerX, toY - options.arrow.threshold + options.arrow.marginY)
85
+ lineTo(dividerX, toY - options.arrow.threshold + options.arrow.marginY),
86
86
  )
87
87
  } else {
88
88
  cmds.push(
89
89
  lineTo(dividerX - cornerRadius, fromY),
90
90
  quadCurve(dividerX, fromY, dividerX, fromY - cornerRadius),
91
- lineTo(dividerX, toY - options.arrow.threshold + options.arrow.marginY)
91
+ lineTo(dividerX, toY - options.arrow.threshold + options.arrow.marginY),
92
92
  )
93
93
  }
94
94
  } else if (to.isBelow) {
@@ -100,24 +100,24 @@ export function drawConnectorPath(options: ConnectorOptions, line: ConnectorLine
100
100
  dividerX - options.arrow.marginX,
101
101
  fromY,
102
102
  dividerX - options.arrow.marginX,
103
- fromY - r1
103
+ fromY - r1,
104
104
  ),
105
105
  lineTo(dividerX - options.arrow.marginX, toY + r1),
106
106
  quadCurve(
107
107
  dividerX - options.arrow.marginX,
108
108
  toY,
109
109
  dividerX - options.arrow.marginX + r1,
110
- toY
110
+ toY,
111
111
  ),
112
112
  lineTo(dividerX - cornerRadius, toY),
113
113
  quadCurve(dividerX, toY, dividerX, toY + cornerRadius),
114
- lineTo(dividerX, toY + options.arrow.threshold - options.arrow.marginY)
114
+ lineTo(dividerX, toY + options.arrow.threshold - options.arrow.marginY),
115
115
  )
116
116
  } else {
117
117
  cmds.push(
118
118
  lineTo(dividerX - cornerRadius, fromY),
119
119
  quadCurve(dividerX, fromY, dividerX, fromY + cornerRadius),
120
- lineTo(dividerX, toY + options.arrow.threshold - options.arrow.marginY)
120
+ lineTo(dividerX, toY + options.arrow.threshold - options.arrow.marginY),
121
121
  )
122
122
  }
123
123
  } else if (fromY < toY) {
@@ -126,7 +126,7 @@ export function drawConnectorPath(options: ConnectorOptions, line: ConnectorLine
126
126
  quadCurve(dividerX, fromY, dividerX, fromY + r1),
127
127
  lineTo(dividerX, toY - r1),
128
128
  quadCurve(dividerX, toY, dividerX + r1, toY),
129
- lineTo(toX, toY)
129
+ lineTo(toX, toY),
130
130
  )
131
131
  } else {
132
132
  cmds.push(
@@ -134,7 +134,7 @@ export function drawConnectorPath(options: ConnectorOptions, line: ConnectorLine
134
134
  quadCurve(dividerX, fromY, dividerX, fromY - Math.min(r0, r1)),
135
135
  lineTo(dividerX, toY + r1),
136
136
  quadCurve(dividerX, toY, dividerX + r1, toY),
137
- lineTo(toX, toY)
137
+ lineTo(toX, toY),
138
138
  )
139
139
  }
140
140
 
@@ -1,5 +1,6 @@
1
- import {DocumentInspector, ObjectSchemaType, PatchEvent} from 'sanity'
2
1
  import {createContext, useContext} from 'react'
2
+ import {DocumentInspector, ObjectSchemaType, PatchEvent} from 'sanity'
3
+
3
4
  import {StudioAssistDocument} from '../types'
4
5
 
5
6
  export type AssistDocumentContextValue = (
@@ -19,7 +20,7 @@ export type AssistDocumentContextValue = (
19
20
  }
20
21
 
21
22
  export const AssistDocumentContext = createContext<AssistDocumentContextValue | undefined>(
22
- undefined
23
+ undefined,
23
24
  )
24
25
 
25
26
  export function useAssistDocumentContext(): AssistDocumentContextValue {
@@ -1,7 +1,8 @@
1
+ import {PropsWithChildren} from 'react'
1
2
  import {ObjectSchemaType} from 'sanity'
3
+
2
4
  import {AssistDocumentContext} from './AssistDocumentContext'
3
5
  import {useAssistDocumentContextValue} from './hooks/useAssistDocumentContextValue'
4
- import {PropsWithChildren} from 'react'
5
6
 
6
7
  export interface AIDocumentInputProps {
7
8
  documentId: string
@@ -1,15 +1,16 @@
1
- import {InputProps, ObjectInputProps, ObjectSchemaType} from 'sanity'
2
- import {AssistDocumentContextProvider} from './AssistDocumentContextProvider'
3
- import {FirstAssistedPathProvider} from '../onboarding/FirstAssistedPathProvider'
4
- import {useInstructionToaster} from './hooks/useInstructionToaster'
5
- import {isType} from '../helpers/typeUtils'
6
1
  import {useLayer} from '@sanity/ui'
7
- import {useDocumentPane} from 'sanity/desk'
8
- import {usePathKey} from '../helpers/misc'
9
- import {ConnectFromRegion} from '../_lib/connector'
10
- import {assistDocumentTypeName} from '../types'
11
2
  import {useMemo} from 'react'
3
+ import type {InputProps, ObjectInputProps, ObjectSchemaType} from 'sanity'
4
+ import {useDocumentPane} from 'sanity/structure'
5
+
6
+ import {ConnectFromRegion} from '../_lib/connector'
12
7
  import {assistFormId} from '../_lib/form/constants'
8
+ import {usePathKey} from '../helpers/misc'
9
+ import {isType} from '../helpers/typeUtils'
10
+ import {FirstAssistedPathProvider} from '../onboarding/FirstAssistedPathProvider'
11
+ import {assistDocumentTypeName} from '../types'
12
+ import {AssistDocumentContextProvider} from './AssistDocumentContextProvider'
13
+ import {useInstructionToaster} from './hooks/useInstructionToaster'
13
14
 
14
15
  export function AssistDocumentInputWrapper(props: InputProps) {
15
16
  if (!isType(props.schemaType, 'document') && props.id !== 'root' && props.id !== assistFormId) {
@@ -1,6 +1,7 @@
1
- import {useRunInstruction} from '../assistLayout/RunInstructionProvider'
2
1
  import {useCallback, useEffect, useState} from 'react'
3
2
  import {ObjectSchemaType, PatchEvent, SanityDocument, unset} from 'sanity'
3
+
4
+ import {useRunInstruction} from '../assistLayout/RunInstructionProvider'
4
5
  import {publicId} from '../helpers/ids'
5
6
 
6
7
  export interface DraftDelayedTaskArgs<T> {
@@ -13,7 +14,7 @@ export interface DraftDelayedTaskArgs<T> {
13
14
  export function isDocAssistable(
14
15
  documentSchemaType: ObjectSchemaType,
15
16
  published?: SanityDocument | null,
16
- draft?: SanityDocument | null
17
+ draft?: SanityDocument | null,
17
18
  ) {
18
19
  return !!(documentSchemaType.liveEdit ? published : draft)
19
20
  }
@@ -61,6 +62,6 @@ export function useDraftDelayedTask<T>(args: DraftDelayedTaskArgs<T>) {
61
62
  documentOnChange(PatchEvent.from([unset(['_force_document_creation'])]))
62
63
  setQueuedArgs(taskArgs)
63
64
  },
64
- [setQueuedArgs, documentOnChange]
65
+ [setQueuedArgs, documentOnChange],
65
66
  )
66
67
  }