@sanity/assist 1.2.7 → 1.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/assist",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "sanity",
@@ -23,6 +23,7 @@ import {PrivateIcon} from './PrivateIcon'
23
23
  import {generateCaptionsActions} from './generateCaptionActions'
24
24
  import {useDocumentPane} from 'sanity/desk'
25
25
  import {useSelectedField, useTypePath} from '../assistInspector/helpers'
26
+ import {isSchemaAssistEnabled} from '../helpers/assistSupported'
26
27
 
27
28
  function node(node: DocumentFieldActionItem | DocumentFieldActionGroup) {
28
29
  return node
@@ -69,7 +70,10 @@ export const assistFieldActions: DocumentFieldAction = {
69
70
  })
70
71
 
71
72
  const isSelectable = !!useSelectedField(documentSchemaType, typePath)
72
- const assistSupported = useAssistSupported(props.path, schemaType) && isSelectable
73
+ const assistSupported =
74
+ useAssistSupported(props.path, schemaType) &&
75
+ isSelectable &&
76
+ isSchemaAssistEnabled(documentSchemaType)
73
77
 
74
78
  const fieldAssist = useMemo(
75
79
  () =>
package/src/plugin.tsx CHANGED
@@ -50,7 +50,10 @@ export const assist = definePlugin<AssistPluginConfig | void>((config) => {
50
50
  },
51
51
  unstable_languageFilter: (prev, {documentId, schema, schemaType}) => {
52
52
  const docSchema = schema.get(schemaType) as ObjectSchemaType
53
- return [...prev, createAssistDocumentPresence(documentId, docSchema)]
53
+ if (isSchemaAssistEnabled(docSchema)) {
54
+ return [...prev, createAssistDocumentPresence(documentId, docSchema)]
55
+ }
56
+ return prev
54
57
  },
55
58
  },
56
59
 
@@ -23,6 +23,28 @@ const mockStudioTypes = [
23
23
  ]
24
24
 
25
25
  describe('serializeSchema', () => {
26
+ test('should not serialize excluded document schema', () => {
27
+ const schema = Schema.compile({
28
+ name: 'test',
29
+ types: [
30
+ defineType({
31
+ type: 'document',
32
+ name: 'article',
33
+ fields: [{type: 'string', name: 'title'}],
34
+ options: {
35
+ aiWritingAssistance: {
36
+ exclude: true,
37
+ },
38
+ },
39
+ }),
40
+ ],
41
+ })
42
+
43
+ const serializedTypes = serializeSchema(schema, {leanFormat: true})
44
+
45
+ expect(serializedTypes).toEqual([])
46
+ })
47
+
26
48
  test('should serialize simple schema', () => {
27
49
  const schema = Schema.compile({
28
50
  name: 'test',
@@ -29,6 +29,7 @@ export function serializeSchema(schema: Schema, options?: Options): SerializedSc
29
29
  .filter((t) => !(hiddenTypes.includes(t) || t.startsWith('sanity.')))
30
30
  .map((t) => schema.get(t))
31
31
  .filter((t): t is SchemaType => !!t)
32
+ .filter((t) => isAssistSupported(t))
32
33
  .filter((t) => !t.hidden && !t.readOnly)
33
34
  .map((t) => getSchemaStub(t, schema, options))
34
35
  .filter((t) => {