@portabletext/sanity-bridge 1.1.9 → 1.1.10

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": "@portabletext/sanity-bridge",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "Convert a Sanity Schema to a Portable Text Schema",
5
5
  "keywords": [
6
6
  "sanity",
@@ -42,15 +42,15 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@sanity/pkg-utils": "^8.1.4",
45
- "@sanity/schema": "^4.8.1",
46
- "@sanity/types": "^4.8.1",
45
+ "@sanity/schema": "^4.9.0",
46
+ "@sanity/types": "^4.9.0",
47
47
  "@types/lodash.startcase": "^4.4.9",
48
48
  "typescript": "5.9.2",
49
49
  "vitest": "^3.2.4"
50
50
  },
51
51
  "peerDependencies": {
52
- "@sanity/schema": "^4.8.1",
53
- "@sanity/types": "^4.8.1"
52
+ "@sanity/schema": "^4.9.0",
53
+ "@sanity/types": "^4.9.0"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">=20.19 <22 || >=22.12"
@@ -1,5 +1,6 @@
1
1
  import type {Schema} from '@portabletext/schema'
2
2
  import {Schema as SanitySchema} from '@sanity/schema'
3
+ import {builtinTypes} from '@sanity/schema/_internal'
3
4
  import {
4
5
  defineArrayMember,
5
6
  defineField,
@@ -135,6 +136,58 @@ describe(sanitySchemaToPortableTextSchema.name, () => {
135
136
  ).toEqual(defaultSchema)
136
137
  })
137
138
 
139
+ test('schema with built-in types', () => {
140
+ const sanitySchema = SanitySchema.compile({
141
+ name: 'test',
142
+ types: [
143
+ defineArrayMember({
144
+ type: 'array',
145
+ name: 'content',
146
+ of: [
147
+ defineField({
148
+ type: 'block',
149
+ name: 'block',
150
+ }),
151
+ defineField({type: 'image', name: 'image'}),
152
+ ],
153
+ }),
154
+ ...builtinTypes,
155
+ ],
156
+ })
157
+
158
+ expect(
159
+ sanitySchemaToPortableTextSchema(sanitySchema.get('content'))
160
+ .blockObjects,
161
+ ).toEqual([
162
+ {
163
+ name: 'image',
164
+ title: 'Image',
165
+ fields: [
166
+ {
167
+ name: 'asset',
168
+ title: 'Asset',
169
+ type: 'object',
170
+ },
171
+ {
172
+ name: 'media',
173
+ title: 'Media',
174
+ type: 'object',
175
+ },
176
+ {
177
+ name: 'hotspot',
178
+ title: 'Hotspot',
179
+ type: 'object',
180
+ },
181
+ {
182
+ name: 'crop',
183
+ title: 'Crop',
184
+ type: 'object',
185
+ },
186
+ ],
187
+ },
188
+ ])
189
+ })
190
+
138
191
  test('simple array definition', () => {
139
192
  const sanitySchema: ArrayDefinition = {
140
193
  type: 'array',