@sanity/assist 1.0.2 → 1.0.4

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.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "sanity",
@@ -91,9 +91,9 @@ export function AssistDocumentForm(props: ObjectInputProps) {
91
91
  }
92
92
  }, [title, documentSchema, onChange, id])
93
93
 
94
- const fieldMissing = fields?.find((f) => f._key !== pathKey)
94
+ const fieldExists = fields?.some((f) => f._key === pathKey)
95
95
  useEffect(() => {
96
- if (onChangeCalled.current || !fieldMissing || activePath || !pathKey) {
96
+ if (onChangeCalled.current || fieldExists || activePath || !pathKey) {
97
97
  return
98
98
  }
99
99
  onChange([
@@ -111,7 +111,7 @@ export function AssistDocumentForm(props: ObjectInputProps) {
111
111
  ),
112
112
  ])
113
113
  onChangeCalled.current = true
114
- }, [activePath, onChange, pathKey, fieldMissing])
114
+ }, [activePath, onChange, pathKey, fieldExists])
115
115
 
116
116
  const {onPathOpen, ...formCallbacks} = useFormCallbacks()
117
117
 
@@ -75,6 +75,18 @@ describe('serializeSchema', () => {
75
75
  ])
76
76
  })
77
77
 
78
+ test('should not serialize slug type', () => {
79
+ const schema = Schema.compile({
80
+ name: 'test',
81
+ types: mockStudioTypes,
82
+ })
83
+
84
+ const serializedTypes = serializeSchema(schema, {leanFormat: true})
85
+
86
+ //everything excluded directly or indirectly
87
+ expect(serializedTypes).toEqual([])
88
+ })
89
+
78
90
  test('should not serialize excluded fields or types or types with every member excluded', () => {
79
91
  const options: AssistOptions = {aiWritingAssistance: {exclude: true}}
80
92
 
@@ -122,19 +122,7 @@ function serializeMember(
122
122
  name: name,
123
123
  type: typeName,
124
124
  title: type.title,
125
- values:
126
- type.jsonType === 'string' && type?.options?.list
127
- ? type?.options?.list.map((v) => (typeof v === 'string' ? v : v.value ?? `${v.title}`))
128
- : undefined,
129
- of: 'of' in type && type.name === 'array' ? arrayOf(type, schema, options) : undefined,
130
- to:
131
- 'to' in type && type.name === 'reference'
132
- ? refToTypeNames(type as ReferenceSchemaType)
133
- : undefined,
134
- fields:
135
- 'fields' in type && inlineTypes.includes(typeName)
136
- ? serializeFields(schema, type, options)
137
- : undefined,
125
+ ...getBaseFields(schema, type, typeName, options),
138
126
  })
139
127
  }
140
128