@sanity/assist 3.0.6 → 3.0.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": "3.0.6",
3
+ "version": "3.0.8",
4
4
  "description": "You create the instructions; Sanity AI Assist does the rest.",
5
5
  "keywords": [
6
6
  "sanity",
@@ -59,6 +59,34 @@ describe('conditionalMembers', () => {
59
59
  expect(conditionalMembers).toEqual([{path: 'title', hidden: false, readOnly: false}])
60
60
  })
61
61
 
62
+ test('regression test: should include document path with conditional readonly and no hidden', () => {
63
+ const docSchema: ObjectSchemaType = Schema.compile({
64
+ name: 'test',
65
+ types: [
66
+ defineType({
67
+ type: 'document',
68
+ name: 'article',
69
+ readOnly: () => false,
70
+ fields: [{type: 'string', name: 'title'}],
71
+ }),
72
+ ],
73
+ }).get('article')
74
+
75
+ const docState = {
76
+ path: [],
77
+ schemaType: docSchema,
78
+ members: [
79
+ {
80
+ kind: 'field',
81
+ field: {path: [docSchema.fields[0].name], schemaType: docSchema.fields[0].type},
82
+ },
83
+ ],
84
+ } as any
85
+ const conditionalMembers = getConditionalMembers(docState)
86
+
87
+ expect(conditionalMembers).toEqual([{path: '', hidden: false, readOnly: false}])
88
+ })
89
+
62
90
  test('should include array item path with conditional readonly', () => {
63
91
  const docSchema: ObjectSchemaType = Schema.compile({
64
92
  name: 'test',
@@ -42,7 +42,7 @@ export function getConditionalMembers(docState: DocumentFormNode): ConditionalMe
42
42
  path: '',
43
43
  hidden: false,
44
44
  readOnly: !!docState.readOnly,
45
- conditional: typeof docState.schemaType.hidden === 'function',
45
+ conditional: isConditional(docState.schemaType),
46
46
  }
47
47
  return (
48
48
  [doc, ...extractConditionalPaths(docState, MAX_DEPTH)]