@sanity/assist 1.2.3 → 1.2.5

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.3",
3
+ "version": "1.2.5",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "sanity",
@@ -392,6 +392,36 @@ describe('serializeSchema', () => {
392
392
  ])
393
393
  })
394
394
 
395
+ test('should serialize list values in string array', () => {
396
+ const schema = Schema.compile({
397
+ name: 'test',
398
+ types: [
399
+ defineType({
400
+ type: 'array',
401
+ name: 'list',
402
+ of: [{type: 'string'}],
403
+ options: {
404
+ list: [
405
+ {title: 'A', value: 'a'},
406
+ {title: 'B', value: 'b'},
407
+ ],
408
+ },
409
+ }),
410
+ ],
411
+ })
412
+
413
+ const serializedTypes = serializeSchema(schema, {leanFormat: true})
414
+
415
+ expect(serializedTypes).toEqual([
416
+ {
417
+ name: 'list',
418
+ type: 'array',
419
+ of: [{type: 'string', name: 'string', title: 'String'}],
420
+ values: ['a', 'b'],
421
+ },
422
+ ])
423
+ })
424
+
395
425
  test('should exclude truthy hidden and readonly', () => {
396
426
  const schema = Schema.compile({
397
427
  name: 'test',
@@ -83,10 +83,11 @@ function getBaseFields(
83
83
  imagePromptField: imagePromptField,
84
84
  }
85
85
  : undefined,
86
- values:
87
- type.jsonType === 'string' && type?.options?.list
88
- ? type?.options?.list.map((v) => (typeof v === 'string' ? v : v.value ?? `${v.title}`))
89
- : undefined,
86
+ values: type?.options?.list
87
+ ? type?.options?.list.map((v: string | {value: string; title: string}) =>
88
+ typeof v === 'string' ? v : v.value ?? `${v.title}`
89
+ )
90
+ : undefined,
90
91
  of: 'of' in type && typeName === 'array' ? arrayOf(type, schema, options) : undefined,
91
92
  to:
92
93
  'to' in type && typeName === 'reference'