@sanity/assist 3.0.3 → 3.0.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/README.md +41 -3
- package/package.json +1 -1
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)
|
|
@@ -58,9 +59,7 @@ This plugin requires `sanity` version `3.26` or greater.
|
|
|
58
59
|
|
|
59
60
|
## Setup
|
|
60
61
|
|
|
61
|
-
> **Note:**
|
|
62
|
-
>
|
|
63
|
-
> Contact your Sanity enterprise representative to get started, or [contact the sales team](https://www.sanity.io/contact/sales?utm_source=github.com&utm_medium=organic_social&utm_campaign=ai-assist&utm_content=).
|
|
62
|
+
> **Note:** AI Assist is available for all projects on the Growth plan and up.
|
|
64
63
|
|
|
65
64
|
### Add the plugin
|
|
66
65
|
|
|
@@ -113,6 +112,45 @@ To edit instructions, users will need read and write access to documents of `_ty
|
|
|
113
112
|
Note that instructions run using the permissions of the user invoking it, so only fields that the user
|
|
114
113
|
themselves can edit can be changed by the instruction instance.
|
|
115
114
|
|
|
115
|
+
### Conditional user access
|
|
116
|
+
To limit which users can see the AI Assist actions in the Studio, use a custom-plugin after `assist()`
|
|
117
|
+
that filters out the inspector and actions, based on user properties:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import {CurrentUser, defineConfig} from 'sanity'
|
|
121
|
+
import {assist} from '@sanity/assist'
|
|
122
|
+
|
|
123
|
+
export default defineConfig({
|
|
124
|
+
// ...
|
|
125
|
+
|
|
126
|
+
plugins: [
|
|
127
|
+
// ...
|
|
128
|
+
assist(),
|
|
129
|
+
{
|
|
130
|
+
name: 'disable-ai-assist',
|
|
131
|
+
document: {
|
|
132
|
+
inspectors: (prev, {currentUser}) =>
|
|
133
|
+
isAiAssistAllowed(currentUser)
|
|
134
|
+
? prev
|
|
135
|
+
: prev.filter((inspector) => inspector.name !== 'ai-assistance'),
|
|
136
|
+
|
|
137
|
+
unstable_fieldActions: (prev, {currentUser}) =>
|
|
138
|
+
isAiAssistAllowed(currentUser)
|
|
139
|
+
? prev
|
|
140
|
+
: prev.filter((fieldActions) => fieldActions.name !== 'sanity-assist-actions'),
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
const ALLOWED_ROLES = ['administrator']
|
|
148
|
+
|
|
149
|
+
function isAiAssistAllowed(user?: CurrentUser | null) {
|
|
150
|
+
return user && user.roles.some((role) => ALLOWED_ROLES.includes(role.name))
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
116
154
|
## Schema configuration
|
|
117
155
|
|
|
118
156
|
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.
|