@sanity/assist 3.2.0 → 3.2.2
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/dist/index.esm.js +3 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
- package/src/helpers/assistSupported.ts +1 -0
- package/src/plugin.tsx +3 -1
- package/src/schemas/serialize/schemaUtils.ts +1 -0
- package/src/schemas/serialize/serializeSchema.test.ts +59 -0
- package/src/schemas/serialize/serializeSchema.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/assist",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "You create the instructions; Sanity AI Assist does the rest.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@rollup/plugin-image": "^3.0.3",
|
|
66
66
|
"@sanity/pkg-utils": "^6.1.0",
|
|
67
67
|
"@sanity/plugin-kit": "^3.1.10",
|
|
68
|
+
"@sanity/schema": "^3.80.0",
|
|
68
69
|
"@sanity/semantic-release-preset": "^4.1.7",
|
|
69
70
|
"@types/lodash": "^4.17.0",
|
|
70
71
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -75,13 +76,14 @@
|
|
|
75
76
|
"eslint-config-prettier": "^9.1.0",
|
|
76
77
|
"eslint-config-sanity": "^7.1.2",
|
|
77
78
|
"eslint-plugin-prettier": "^5.1.3",
|
|
79
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
78
80
|
"eslint-plugin-react": "^7.34.1",
|
|
79
81
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
80
82
|
"npm-run-all2": "^5.0.2",
|
|
81
83
|
"react": "^18.2.0",
|
|
82
84
|
"react-dom": "^18.2.0",
|
|
83
85
|
"rimraf": "^5.0.5",
|
|
84
|
-
"sanity": "^3.
|
|
86
|
+
"sanity": "^3.80.0",
|
|
85
87
|
"semantic-release": "^23.0.8",
|
|
86
88
|
"styled-components": "^6.1.8",
|
|
87
89
|
"typescript": "^5.7.2",
|
|
@@ -37,6 +37,7 @@ function isUnsupportedType(type: SchemaType) {
|
|
|
37
37
|
type.jsonType === 'number' ||
|
|
38
38
|
type.name === 'sanity.imageCrop' ||
|
|
39
39
|
type.name === 'sanity.imageHotspot' ||
|
|
40
|
+
isType(type, 'globalDocumentReference') ||
|
|
40
41
|
(isType(type, 'reference') &&
|
|
41
42
|
!(type?.options as ReferenceOptions)?.aiAssist?.embeddingsIndex) ||
|
|
42
43
|
isType(type, 'crossDatasetReference') ||
|
package/src/plugin.tsx
CHANGED
|
@@ -46,7 +46,9 @@ export const assist = definePlugin<AssistPluginConfig | void>((config) => {
|
|
|
46
46
|
|
|
47
47
|
return {
|
|
48
48
|
name: packageName,
|
|
49
|
-
|
|
49
|
+
// the addition of global references broke auto updating studios
|
|
50
|
+
// new versions of studio know to look for this prop on assist plugin, and filter + console.warn if it is missing
|
|
51
|
+
...({handlesGDR: true} as any),
|
|
50
52
|
schema: {
|
|
51
53
|
types: schemaTypes,
|
|
52
54
|
},
|
|
@@ -741,4 +741,63 @@ describe('serializeSchema', () => {
|
|
|
741
741
|
},
|
|
742
742
|
])
|
|
743
743
|
})
|
|
744
|
+
|
|
745
|
+
test('should no serialize global document reference types (for now)', () => {
|
|
746
|
+
const schema = Schema.compile({
|
|
747
|
+
name: 'test',
|
|
748
|
+
types: [
|
|
749
|
+
defineType({
|
|
750
|
+
type: 'object',
|
|
751
|
+
name: 'author',
|
|
752
|
+
fields: [
|
|
753
|
+
defineField({
|
|
754
|
+
type: 'string',
|
|
755
|
+
name: 'name',
|
|
756
|
+
}),
|
|
757
|
+
defineField({
|
|
758
|
+
type: 'globalDocumentReference',
|
|
759
|
+
name: 'person',
|
|
760
|
+
title: 'Person',
|
|
761
|
+
resourceType: 'dataset',
|
|
762
|
+
resourceId: 'exx11uqh.blog',
|
|
763
|
+
to: [
|
|
764
|
+
{
|
|
765
|
+
type: 'person',
|
|
766
|
+
preview: {
|
|
767
|
+
select: {
|
|
768
|
+
title: 'title',
|
|
769
|
+
media: 'coverImage',
|
|
770
|
+
},
|
|
771
|
+
prepare(val: any) {
|
|
772
|
+
return {
|
|
773
|
+
title: val.title,
|
|
774
|
+
media: val.coverImage,
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
},
|
|
778
|
+
},
|
|
779
|
+
],
|
|
780
|
+
}),
|
|
781
|
+
],
|
|
782
|
+
}),
|
|
783
|
+
],
|
|
784
|
+
})
|
|
785
|
+
|
|
786
|
+
const serializedTypes = serializeSchema(schema, {leanFormat: true})
|
|
787
|
+
|
|
788
|
+
expect(serializedTypes).toEqual([
|
|
789
|
+
{
|
|
790
|
+
fields: [
|
|
791
|
+
{
|
|
792
|
+
name: 'name',
|
|
793
|
+
title: 'Name',
|
|
794
|
+
type: 'string',
|
|
795
|
+
},
|
|
796
|
+
],
|
|
797
|
+
name: 'author',
|
|
798
|
+
title: 'Author',
|
|
799
|
+
type: 'object',
|
|
800
|
+
},
|
|
801
|
+
])
|
|
802
|
+
})
|
|
744
803
|
})
|
|
@@ -58,6 +58,7 @@ function getSchemaStub(
|
|
|
58
58
|
options?: Options,
|
|
59
59
|
): SerializedSchemaType {
|
|
60
60
|
if (!schemaType.type?.name) {
|
|
61
|
+
// eslint-disable-next-line no-console -- log error
|
|
61
62
|
console.error('Missing type name', schemaType.type)
|
|
62
63
|
throw new Error('Type is missing name!')
|
|
63
64
|
}
|