@sanity/assist 1.2.13 → 1.2.14

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.13",
3
+ "version": "1.2.14",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "sanity",
@@ -64,18 +64,18 @@
64
64
  "rxjs-exhaustmap-with-trailing": "^2.1.1"
65
65
  },
66
66
  "devDependencies": {
67
- "@commitlint/cli": "^17.7.2",
68
- "@commitlint/config-conventional": "^17.7.0",
67
+ "@commitlint/cli": "^17.8.1",
68
+ "@commitlint/config-conventional": "^17.8.1",
69
69
  "@rollup/plugin-image": "^3.0.3",
70
70
  "@sanity/pkg-utils": "^2.4.10",
71
71
  "@sanity/plugin-kit": "^3.1.10",
72
- "@sanity/semantic-release-preset": "^4.1.4",
73
- "@types/react": "^18.2.27",
74
- "@types/styled-components": "^5.1.28",
72
+ "@sanity/semantic-release-preset": "^4.1.6",
73
+ "@types/react": "^18.2.37",
74
+ "@types/styled-components": "^5.1.30",
75
75
  "@typescript-eslint/eslint-plugin": "^5.62.0",
76
76
  "@typescript-eslint/parser": "^5.62.0",
77
77
  "date-fns": "^2.30.0",
78
- "eslint": "^8.51.0",
78
+ "eslint": "^8.53.0",
79
79
  "eslint-config-prettier": "^8.10.0",
80
80
  "eslint-config-sanity": "^6.0.0",
81
81
  "eslint-plugin-prettier": "^4.2.1",
@@ -85,7 +85,7 @@
85
85
  "react": "^18.2.0",
86
86
  "react-dom": "^18.2.0",
87
87
  "rimraf": "^4.4.0",
88
- "sanity": "^3.19.1",
88
+ "sanity": "^3.19.3",
89
89
  "semantic-release": "^21.1.2",
90
90
  "styled-components": "^5.3.11",
91
91
  "typescript": "^5.2.2",
package/src/plugin.tsx CHANGED
@@ -45,8 +45,12 @@ export const assist = definePlugin<AssistPluginConfig | void>((config) => {
45
45
  }
46
46
  return prev
47
47
  },
48
- unstable_fieldActions: (prev) => {
49
- return [...prev, assistFieldActions]
48
+ unstable_fieldActions: (prev, {documentType, schema}) => {
49
+ const docSchema = schema.get(documentType)
50
+ if (docSchema && isSchemaAssistEnabled(docSchema)) {
51
+ return [...prev, assistFieldActions]
52
+ }
53
+ return prev
50
54
  },
51
55
  unstable_languageFilter: (prev, {documentId, schema, schemaType}) => {
52
56
  const docSchema = schema.get(schemaType)
@@ -23,7 +23,7 @@ const mockStudioTypes = [
23
23
  ]
24
24
 
25
25
  describe('serializeSchema', () => {
26
- test('should not serialize excluded document schema', () => {
26
+ test('should serialize excluded document schema to support exclude: false overrides at the field level', () => {
27
27
  const schema = Schema.compile({
28
28
  name: 'test',
29
29
  types: [
@@ -42,7 +42,20 @@ describe('serializeSchema', () => {
42
42
 
43
43
  const serializedTypes = serializeSchema(schema, {leanFormat: true})
44
44
 
45
- expect(serializedTypes).toEqual([])
45
+ expect(serializedTypes).toEqual([
46
+ {
47
+ fields: [
48
+ {
49
+ name: 'title',
50
+ title: 'Title',
51
+ type: 'string',
52
+ },
53
+ ],
54
+ name: 'article',
55
+ title: 'Article',
56
+ type: 'document',
57
+ },
58
+ ])
46
59
  })
47
60
 
48
61
  test('should serialize simple schema', () => {
@@ -29,7 +29,8 @@ 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
+ // because a field can override exclude at the type level, we have to also serialize excluded types
33
+ // so don't do this: .filter((t) => isAssistSupported(t))
33
34
  .filter((t) => !t.hidden && !t.readOnly)
34
35
  .map((t) => getSchemaStub(t, schema, options))
35
36
  .filter((t) => {