@sanity/assist 3.0.2 → 3.0.4
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/README.md +40 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
- [Add the plugin](#add-the-plugin)
|
|
12
12
|
- [Enabling the AI Assist API](#enabling-the-ai-assist-api)
|
|
13
13
|
- [Permissions](#permissions)
|
|
14
|
+
- [Conditional user access](#conditional-user-access)
|
|
14
15
|
- [Schema configuration](#schema-configuration)
|
|
15
16
|
- [Disable AI Assist for a schema type](#disable-ai-assist-for-a-schema-type)
|
|
16
17
|
- [Disable for a field](#disable-for-a-field)
|
|
@@ -113,6 +114,45 @@ To edit instructions, users will need read and write access to documents of `_ty
|
|
|
113
114
|
Note that instructions run using the permissions of the user invoking it, so only fields that the user
|
|
114
115
|
themselves can edit can be changed by the instruction instance.
|
|
115
116
|
|
|
117
|
+
### Conditional user access
|
|
118
|
+
To limit which users can see the AI Assist actions in the Studio, use a custom-plugin after `assist()`
|
|
119
|
+
that filters out the inspector and actions, based on user properties:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
import {CurrentUser, defineConfig} from 'sanity'
|
|
123
|
+
import {assist} from '@sanity/assist'
|
|
124
|
+
|
|
125
|
+
export default defineConfig({
|
|
126
|
+
// ...
|
|
127
|
+
|
|
128
|
+
plugins: [
|
|
129
|
+
// ...
|
|
130
|
+
assist(),
|
|
131
|
+
{
|
|
132
|
+
name: 'disable-ai-assist',
|
|
133
|
+
document: {
|
|
134
|
+
inspectors: (prev, {currentUser}) =>
|
|
135
|
+
isAiAssistAllowed(currentUser)
|
|
136
|
+
? prev
|
|
137
|
+
: prev.filter((inspector) => inspector.name !== 'ai-assistance'),
|
|
138
|
+
|
|
139
|
+
unstable_fieldActions: (prev, {currentUser}) =>
|
|
140
|
+
isAiAssistAllowed(currentUser)
|
|
141
|
+
? prev
|
|
142
|
+
: prev.filter((fieldActions) => fieldActions.name !== 'sanity-assist-actions'),
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
const ALLOWED_ROLES = ['administrator']
|
|
150
|
+
|
|
151
|
+
function isAiAssistAllowed(user?: CurrentUser | null) {
|
|
152
|
+
return user && user.roles.some((role) => ALLOWED_ROLES.includes(role.name))
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
116
156
|
## Schema configuration
|
|
117
157
|
|
|
118
158
|
By default, most string, object, and array field types (including Portable Text!) have AI writing assistance enabled. Your assistant can write to all compatible fields that it detects.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/assist",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "You create the instructions; Sanity AI Assist does the rest.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"react": "^18.2.0",
|
|
83
83
|
"react-dom": "^18.2.0",
|
|
84
84
|
"rimraf": "^5.0.5",
|
|
85
|
-
"sanity": "^3.37.
|
|
86
|
-
"semantic-release": "^23.0.
|
|
85
|
+
"sanity": "^3.37.2",
|
|
86
|
+
"semantic-release": "^23.0.8",
|
|
87
87
|
"styled-components": "^6.1.8",
|
|
88
88
|
"typescript": "5.4.2",
|
|
89
89
|
"vitest": "^1.4.0"
|