@sanity/assist 4.4.0 → 4.4.1

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": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "description": "You create the instructions; Sanity AI Assist does the rest.",
5
5
  "keywords": [
6
6
  "sanity",
@@ -23,7 +23,11 @@ export function isAssistSupported(type: SchemaType) {
23
23
 
24
24
  if (type.jsonType === 'object') {
25
25
  const unsupportedObject = type.fields.every((field) => isDisabled(field.type))
26
- return !unsupportedObject
26
+ return (
27
+ !unsupportedObject ||
28
+ /* to allow attaching custom actions on fieldless images */
29
+ isType(type, 'image')
30
+ )
27
31
  }
28
32
  return true
29
33
  }
@@ -123,7 +123,7 @@ describe('serializeSchema', () => {
123
123
  expect(serializedTypes).toEqual([])
124
124
  })
125
125
 
126
- test('should not serialize excluded fields or types or types with every member excluded', () => {
126
+ test('should not serialize excluded fields or types or types with every member excluded (except images)', () => {
127
127
  const options: AssistOptions = {aiAssist: {exclude: true}}
128
128
 
129
129
  const schema = Schema.compile({
@@ -131,7 +131,7 @@ describe('serializeSchema', () => {
131
131
  types: [
132
132
  {
133
133
  type: 'document',
134
- name: 'allFieldsExcluded',
134
+ name: 'mostFieldsExcluded',
135
135
  fields: [
136
136
  defineField({type: 'string', name: 'title', options}),
137
137
  defineField({
@@ -148,7 +148,7 @@ describe('serializeSchema', () => {
148
148
  of: [{type: 'object', name: 'remove', options}, {type: 'excluded'}],
149
149
  options: {aiAssist: {exclude: true}},
150
150
  }),
151
- //image without extra fields should be excluded
151
+ //image without extra fields should NOT be excluded
152
152
  defineField({type: 'image', name: 'image'}),
153
153
  defineField({type: 'file', name: 'file'}),
154
154
  defineField({type: 'reference', name: 'reference', to: [{type: 'excluded'}]}),
@@ -174,7 +174,21 @@ describe('serializeSchema', () => {
174
174
  const serializedTypes = serializeSchema(schema, {leanFormat: true})
175
175
 
176
176
  //everything excluded directly or indirectly
177
- expect(serializedTypes).toEqual([])
177
+ expect(serializedTypes).toEqual([
178
+ {
179
+ fields: [
180
+ {
181
+ fields: [],
182
+ name: 'image',
183
+ title: 'Image',
184
+ type: 'image',
185
+ },
186
+ ],
187
+ name: 'mostFieldsExcluded',
188
+ title: 'Most Fields Excluded',
189
+ type: 'document',
190
+ },
191
+ ])
178
192
  })
179
193
 
180
194
  test('should serialize opt-in inline object using custom typeName', () => {