@sanity/assist 1.2.5 → 1.2.7

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.5",
3
+ "version": "1.2.7",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "sanity",
@@ -22,6 +22,10 @@
22
22
  "types": "./dist/index.d.ts",
23
23
  "source": "./src/index.ts",
24
24
  "require": "./dist/index.js",
25
+ "node": {
26
+ "module": "./dist/index.esm.js",
27
+ "import": "./dist/index.cjs.mjs"
28
+ },
25
29
  "import": "./dist/index.esm.js",
26
30
  "default": "./dist/index.esm.js"
27
31
  },
@@ -60,32 +64,32 @@
60
64
  "rxjs-exhaustmap-with-trailing": "^2.1.1"
61
65
  },
62
66
  "devDependencies": {
63
- "@commitlint/cli": "^17.6.6",
64
- "@commitlint/config-conventional": "^17.6.6",
65
- "@rollup/plugin-image": "^3.0.2",
66
- "@sanity/pkg-utils": "^2.2.13",
67
- "@sanity/plugin-kit": "^3.1.7",
68
- "@sanity/semantic-release-preset": "^4.1.1",
69
- "@types/react": "^18.0.28",
70
- "@types/styled-components": "^5.1.26",
71
- "@typescript-eslint/eslint-plugin": "^5.56.0",
72
- "@typescript-eslint/parser": "^5.56.0",
67
+ "@commitlint/cli": "^17.7.2",
68
+ "@commitlint/config-conventional": "^17.7.0",
69
+ "@rollup/plugin-image": "^3.0.3",
70
+ "@sanity/pkg-utils": "^2.4.10",
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",
75
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
76
+ "@typescript-eslint/parser": "^5.62.0",
73
77
  "date-fns": "^2.30.0",
74
- "eslint": "^8.36.0",
75
- "eslint-config-prettier": "^8.8.0",
78
+ "eslint": "^8.51.0",
79
+ "eslint-config-prettier": "^8.10.0",
76
80
  "eslint-config-sanity": "^6.0.0",
77
81
  "eslint-plugin-prettier": "^4.2.1",
78
- "eslint-plugin-react": "^7.32.2",
82
+ "eslint-plugin-react": "^7.33.2",
79
83
  "eslint-plugin-react-hooks": "^4.6.0",
80
84
  "npm-run-all": "^4.1.5",
81
85
  "react": "^18.2.0",
82
86
  "react-dom": "^18.2.0",
83
87
  "rimraf": "^4.4.0",
84
- "sanity": "^3.16.7",
85
- "semantic-release": "^21.0.5",
86
- "styled-components": "^5.3.9",
87
- "typescript": "^5.1.3",
88
- "vitest": "^0.32.2"
88
+ "sanity": "^3.17.0",
89
+ "semantic-release": "^21.1.2",
90
+ "styled-components": "^5.3.11",
91
+ "typescript": "^5.2.2",
92
+ "vitest": "^0.34.6"
89
93
  },
90
94
  "peerDependencies": {
91
95
  "react": "^18",
@@ -422,6 +422,33 @@ describe('serializeSchema', () => {
422
422
  ])
423
423
  })
424
424
 
425
+ test('should not try to serialize list values if list values are not an array', () => {
426
+ const schema = Schema.compile({
427
+ name: 'test',
428
+ types: [
429
+ defineType({
430
+ type: 'array',
431
+ name: 'list',
432
+ of: [{type: 'string'}],
433
+ options: {
434
+ list: new Promise(() => {}) as any, // Type usually only accepts array, but some plugins might use other types
435
+ },
436
+ }),
437
+ ],
438
+ })
439
+
440
+ const serializedTypes = serializeSchema(schema, {leanFormat: true})
441
+
442
+ expect(serializedTypes).toEqual([
443
+ {
444
+ name: 'list',
445
+ type: 'array',
446
+ of: [{type: 'string', name: 'string', title: 'String'}],
447
+ values: undefined,
448
+ },
449
+ ])
450
+ })
451
+
425
452
  test('should exclude truthy hidden and readonly', () => {
426
453
  const schema = Schema.compile({
427
454
  name: 'test',
@@ -83,7 +83,7 @@ function getBaseFields(
83
83
  imagePromptField: imagePromptField,
84
84
  }
85
85
  : undefined,
86
- values: type?.options?.list
86
+ values: Array.isArray(type?.options?.list)
87
87
  ? type?.options?.list.map((v: string | {value: string; title: string}) =>
88
88
  typeof v === 'string' ? v : v.value ?? `${v.title}`
89
89
  )