@sanity/blueprints 0.11.0 → 0.12.1
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 -317
- package/dist/definers/blueprints.d.ts +15 -3
- package/dist/definers/blueprints.js +40 -3
- package/dist/definers/blueprints.js.map +1 -1
- package/dist/definers/cors.d.ts +5 -2
- package/dist/definers/cors.js +17 -2
- package/dist/definers/cors.js.map +1 -1
- package/dist/definers/datasets.d.ts +5 -2
- package/dist/definers/datasets.js +18 -2
- package/dist/definers/datasets.js.map +1 -1
- package/dist/definers/functions.d.ts +37 -61
- package/dist/definers/functions.js +69 -95
- package/dist/definers/functions.js.map +1 -1
- package/dist/definers/resources.d.ts +10 -0
- package/dist/definers/resources.js +21 -0
- package/dist/definers/resources.js.map +1 -1
- package/dist/definers/robotTokens.d.ts +22 -0
- package/dist/definers/robotTokens.js +53 -0
- package/dist/definers/robotTokens.js.map +1 -0
- package/dist/definers/robots.d.ts +2 -22
- package/dist/definers/robots.js +2 -33
- package/dist/definers/robots.js.map +1 -1
- package/dist/definers/roles.d.ts +16 -25
- package/dist/definers/roles.js +64 -23
- package/dist/definers/roles.js.map +1 -1
- package/dist/definers/webhooks.d.ts +5 -2
- package/dist/definers/webhooks.js +25 -2
- package/dist/definers/webhooks.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/types/cors.d.ts +2 -0
- package/dist/types/datasets.d.ts +5 -1
- package/dist/types/functions.d.ts +65 -3
- package/dist/types/functions.js.map +1 -1
- package/dist/types/resources.d.ts +25 -0
- package/dist/types/robotTokens.d.ts +45 -0
- package/dist/types/robotTokens.js +2 -0
- package/dist/types/robotTokens.js.map +1 -0
- package/dist/types/robots.d.ts +8 -39
- package/dist/types/robots.js +1 -0
- package/dist/types/robots.js.map +1 -1
- package/dist/types/roles.d.ts +1 -0
- package/dist/types/webhooks.d.ts +6 -0
- package/dist/utils/validation.d.ts +9 -0
- package/dist/utils/validation.js +12 -0
- package/dist/utils/validation.js.map +1 -1
- package/dist/validation/cors.js +7 -0
- package/dist/validation/cors.js.map +1 -1
- package/dist/validation/resources.js +8 -0
- package/dist/validation/resources.js.map +1 -1
- package/dist/validation/robotTokens.d.ts +15 -0
- package/dist/validation/robotTokens.js +104 -0
- package/dist/validation/robotTokens.js.map +1 -0
- package/dist/validation/robots.d.ts +4 -15
- package/dist/validation/robots.js +5 -103
- package/dist/validation/robots.js.map +1 -1
- package/dist/validation/webhooks.js +6 -3
- package/dist/validation/webhooks.js.map +1 -1
- package/package.json +6 -6
- package/src/definers/blueprints.ts +40 -3
- package/src/definers/cors.ts +17 -2
- package/src/definers/datasets.ts +18 -2
- package/src/definers/functions.ts +124 -132
- package/src/definers/resources.ts +21 -0
- package/src/definers/robotTokens.ts +56 -0
- package/src/definers/robots.ts +2 -37
- package/src/definers/roles.ts +64 -23
- package/src/definers/webhooks.ts +25 -2
- package/src/index.ts +3 -0
- package/src/types/cors.ts +2 -0
- package/src/types/datasets.ts +5 -1
- package/src/types/functions.ts +71 -3
- package/src/types/resources.ts +26 -1
- package/src/types/robotTokens.ts +50 -0
- package/src/types/robots.ts +10 -44
- package/src/types/roles.ts +1 -0
- package/src/types/webhooks.ts +6 -0
- package/src/utils/validation.ts +14 -0
- package/src/validation/cors.ts +6 -0
- package/src/validation/resources.ts +8 -0
- package/src/validation/robotTokens.ts +103 -0
- package/src/validation/robots.ts +5 -102
- package/src/validation/webhooks.ts +5 -3
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@sanity/blueprints`
|
|
2
2
|
|
|
3
|
-
> [!IMPORTANT]
|
|
3
|
+
> [!IMPORTANT]
|
|
4
4
|
> This package is currently in beta and may change. Refer to the [CHANGELOG](./CHANGELOG.md) for details.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
TypeScript helpers for defining and validating [Sanity Blueprints](https://www.sanity.io/docs/blueprints) — declarative infrastructure-as-code for your Sanity project.
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
@@ -13,342 +13,65 @@ npm install @sanity/blueprints
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
import {defineBlueprint, defineDocumentFunction, defineScheduleFunction} from '@sanity/blueprints'
|
|
18
|
-
|
|
19
|
-
export default defineBlueprint({
|
|
20
|
-
resources: [
|
|
21
|
-
defineDocumentFunction({
|
|
22
|
-
name: 'on-customer-change',
|
|
23
|
-
src: 'functions/on-customer-change',
|
|
24
|
-
memory: 2,
|
|
25
|
-
timeout: 360,
|
|
26
|
-
event: {
|
|
27
|
-
on: ['create', 'update'],
|
|
28
|
-
filter: "_type == 'customer'",
|
|
29
|
-
projection: '{totalSpend, lastOrderDate}',
|
|
30
|
-
},
|
|
31
|
-
env: {
|
|
32
|
-
CURRENCY: 'USD',
|
|
33
|
-
},
|
|
34
|
-
}),
|
|
35
|
-
defineScheduleFunction({
|
|
36
|
-
name: 'daily-report',
|
|
37
|
-
src: 'functions/daily-report',
|
|
38
|
-
memory: 2,
|
|
39
|
-
timeout: 300,
|
|
40
|
-
event: {
|
|
41
|
-
expression: 'every day at 9am',
|
|
42
|
-
timezone: 'America/New_York',
|
|
43
|
-
},
|
|
44
|
-
env: {
|
|
45
|
-
REPORT_EMAIL: 'team@example.com',
|
|
46
|
-
},
|
|
47
|
-
}),
|
|
48
|
-
],
|
|
49
|
-
})
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Definers
|
|
53
|
-
|
|
54
|
-
- [defineBlueprint](#defineblueprint) - Create a blueprint module
|
|
55
|
-
- [defineDocumentFunction](#definedocumentfunction) - Function triggered by document events
|
|
56
|
-
- [defineScheduleFunction](#defineschedulefunction) - Function triggered on a schedule
|
|
57
|
-
- [defineMediaLibraryAssetFunction](#definemedialibraryassetfunction) - Function triggered by media library events
|
|
58
|
-
- [defineDocumentWebhook](#definedocumentwebhook) - Webhook triggered by document events
|
|
59
|
-
- [defineDataset](#definedataset) - Dataset resource
|
|
60
|
-
- [defineCorsOrigin](#definecorsorigin) - CORS origin resource
|
|
61
|
-
- [defineRole](#definerole) - Custom role with permissions
|
|
62
|
-
- [defineProjectRole](#defineprojectrole) - Project-scoped role
|
|
63
|
-
- [defineRobot](#definerobot) - Robot (service account)
|
|
64
|
-
|
|
65
|
-
### defineBlueprint
|
|
66
|
-
|
|
67
|
-
Creates a blueprint module with resources.
|
|
68
|
-
|
|
69
|
-
```ts
|
|
70
|
-
import {defineBlueprint} from '@sanity/blueprints'
|
|
71
|
-
|
|
72
|
-
export default defineBlueprint({
|
|
73
|
-
resources: [
|
|
74
|
-
// ... your resources
|
|
75
|
-
],
|
|
76
|
-
})
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### defineDocumentFunction
|
|
80
|
-
|
|
81
|
-
Creates a function triggered by document events.
|
|
82
|
-
|
|
83
|
-
```ts
|
|
84
|
-
import {defineDocumentFunction} from '@sanity/blueprints'
|
|
85
|
-
|
|
86
|
-
defineDocumentFunction({
|
|
87
|
-
name: 'on-order-created',
|
|
88
|
-
src: 'functions/on-order-created',
|
|
89
|
-
memory: 2,
|
|
90
|
-
timeout: 360,
|
|
91
|
-
event: {
|
|
92
|
-
on: ['create', 'update', 'delete'],
|
|
93
|
-
filter: "_type == 'order'",
|
|
94
|
-
projection: '{total, items}',
|
|
95
|
-
includeDrafts: false,
|
|
96
|
-
},
|
|
97
|
-
env: {
|
|
98
|
-
API_URL: 'https://api.example.com',
|
|
99
|
-
},
|
|
100
|
-
})
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### defineScheduleFunction
|
|
104
|
-
|
|
105
|
-
Creates a function triggered on a schedule. Supports cron expressions or natural language.
|
|
106
|
-
|
|
107
|
-
```ts
|
|
108
|
-
import {defineScheduleFunction} from '@sanity/blueprints'
|
|
109
|
-
|
|
110
|
-
// Natural language schedule
|
|
111
|
-
defineScheduleFunction({
|
|
112
|
-
name: 'daily-cleanup',
|
|
113
|
-
event: {expression: 'every day at 9am'},
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
// Weekday schedules
|
|
117
|
-
defineScheduleFunction({
|
|
118
|
-
name: 'weekday-report',
|
|
119
|
-
event: {expression: 'weekdays at 8:30am'},
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
// Multiple days
|
|
123
|
-
defineScheduleFunction({
|
|
124
|
-
name: 'team-sync',
|
|
125
|
-
event: {expression: 'mon wed fri 9:00'},
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
// Intervals
|
|
129
|
-
defineScheduleFunction({
|
|
130
|
-
name: 'health-check',
|
|
131
|
-
event: {expression: 'every 15 minutes'},
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
// Standard cron expression
|
|
135
|
-
defineScheduleFunction({
|
|
136
|
-
name: 'monthly-report',
|
|
137
|
-
event: {expression: '0 9 1 * *'},
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
// Explicit cron fields
|
|
141
|
-
defineScheduleFunction({
|
|
142
|
-
name: 'custom-schedule',
|
|
143
|
-
event: {
|
|
144
|
-
minute: '0',
|
|
145
|
-
hour: '9',
|
|
146
|
-
dayOfMonth: '*',
|
|
147
|
-
month: '*',
|
|
148
|
-
dayOfWeek: '1-5',
|
|
149
|
-
},
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
// With timezone
|
|
153
|
-
defineScheduleFunction({
|
|
154
|
-
name: 'daily-digest',
|
|
155
|
-
event: {expression: 'every day at 6pm'},
|
|
156
|
-
timezone: 'America/New_York',
|
|
157
|
-
})
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
**Supported natural language patterns:**
|
|
161
|
-
- `every minute`, `every 5 minutes`, `every hour`, `every hour at :30`
|
|
162
|
-
- `every day at 9am`, `daily 14:30`
|
|
163
|
-
- `at midnight`, `at noon`
|
|
164
|
-
- `every morning`, `every afternoon`, `every evening`
|
|
165
|
-
- `mondays at 9am`, `mon wed fri 9:00`
|
|
166
|
-
- `weekdays at 8am`, `weekends at 10am`
|
|
167
|
-
- `mon-fri 9am` (day ranges)
|
|
168
|
-
- `first of the month at 9am`, `on the 15th at noon`
|
|
169
|
-
|
|
170
|
-
### defineMediaLibraryAssetFunction
|
|
171
|
-
|
|
172
|
-
Creates a function triggered by media library asset events.
|
|
173
|
-
|
|
174
|
-
```ts
|
|
175
|
-
import {defineMediaLibraryAssetFunction} from '@sanity/blueprints'
|
|
176
|
-
|
|
177
|
-
defineMediaLibraryAssetFunction({
|
|
178
|
-
name: 'on-asset-upload',
|
|
179
|
-
event: {
|
|
180
|
-
on: ['create'],
|
|
181
|
-
resource: {type: 'media-library'},
|
|
182
|
-
},
|
|
183
|
-
})
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### defineDocumentWebhook
|
|
187
|
-
|
|
188
|
-
Creates a webhook triggered by document events.
|
|
189
|
-
|
|
190
|
-
```ts
|
|
191
|
-
import {defineDocumentWebhook} from '@sanity/blueprints'
|
|
192
|
-
|
|
193
|
-
defineDocumentWebhook({
|
|
194
|
-
name: 'notify-backend',
|
|
195
|
-
url: 'https://api.example.com/webhooks/sanity',
|
|
196
|
-
on: ['create', 'update'],
|
|
197
|
-
dataset: 'production',
|
|
198
|
-
filter: "_type == 'order'",
|
|
199
|
-
projection: '{_id, total}',
|
|
200
|
-
apiVersion: 'v2025-01-01',
|
|
201
|
-
httpMethod: 'POST',
|
|
202
|
-
headers: {
|
|
203
|
-
'X-Custom-Header': 'value',
|
|
204
|
-
},
|
|
205
|
-
})
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
### defineDataset
|
|
209
|
-
|
|
210
|
-
Creates a dataset resource.
|
|
211
|
-
|
|
212
|
-
```ts
|
|
213
|
-
import {defineDataset} from '@sanity/blueprints'
|
|
214
|
-
|
|
215
|
-
defineDataset({
|
|
216
|
-
name: 'production',
|
|
217
|
-
aclMode: 'public',
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
defineDataset({
|
|
221
|
-
name: 'staging',
|
|
222
|
-
aclMode: 'private',
|
|
223
|
-
})
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### defineCorsOrigin
|
|
227
|
-
|
|
228
|
-
Creates a CORS origin resource.
|
|
229
|
-
|
|
230
|
-
```ts
|
|
231
|
-
import {defineCorsOrigin} from '@sanity/blueprints'
|
|
232
|
-
|
|
233
|
-
defineCorsOrigin({
|
|
234
|
-
name: 'production-app',
|
|
235
|
-
origin: 'https://myapp.com',
|
|
236
|
-
allowCredentials: true,
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
defineCorsOrigin({
|
|
240
|
-
name: 'local-dev',
|
|
241
|
-
origin: 'http://localhost:3000',
|
|
242
|
-
allowCredentials: false,
|
|
243
|
-
})
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### defineRole
|
|
247
|
-
|
|
248
|
-
Creates a custom role with permissions.
|
|
249
|
-
|
|
250
|
-
```ts
|
|
251
|
-
import {defineRole} from '@sanity/blueprints'
|
|
252
|
-
|
|
253
|
-
defineRole({
|
|
254
|
-
name: 'content-editor',
|
|
255
|
-
title: 'Content Editor',
|
|
256
|
-
permissions: [
|
|
257
|
-
{type: 'sanity.document.*', grant: 'read'},
|
|
258
|
-
{type: 'sanity.document.create', grant: 'create', filter: "_type == 'post'"},
|
|
259
|
-
{type: 'sanity.document.update', grant: 'update', filter: "_type == 'post'"},
|
|
260
|
-
],
|
|
261
|
-
})
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
### defineProjectRole
|
|
265
|
-
|
|
266
|
-
Creates a project-scoped role.
|
|
267
|
-
|
|
268
|
-
```ts
|
|
269
|
-
import {defineProjectRole} from '@sanity/blueprints'
|
|
270
|
-
|
|
271
|
-
defineProjectRole('your-project-id', {
|
|
272
|
-
name: 'viewer',
|
|
273
|
-
title: 'Viewer',
|
|
274
|
-
permissions: [
|
|
275
|
-
{type: 'sanity.document.*', grant: 'read'},
|
|
276
|
-
],
|
|
277
|
-
})
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### defineRobot
|
|
281
|
-
|
|
282
|
-
Creates a robot (service account) with role memberships.
|
|
283
|
-
|
|
284
|
-
```ts
|
|
285
|
-
import {defineRobot} from '@sanity/blueprints'
|
|
286
|
-
|
|
287
|
-
defineRobot({
|
|
288
|
-
name: 'ci-robot',
|
|
289
|
-
label: 'CI/CD Robot',
|
|
290
|
-
memberships: [
|
|
291
|
-
{
|
|
292
|
-
resourceType: 'project',
|
|
293
|
-
resourceId: 'your-project-id',
|
|
294
|
-
roleNames: ['editor'],
|
|
295
|
-
},
|
|
296
|
-
],
|
|
297
|
-
})
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
## Full Example
|
|
16
|
+
A blueprint is a module that declares the Sanity resources your project needs. Export it as the default from your blueprint file:
|
|
301
17
|
|
|
302
18
|
```ts
|
|
303
19
|
import {
|
|
304
20
|
defineBlueprint,
|
|
305
21
|
defineCorsOrigin,
|
|
306
|
-
defineDataset,
|
|
307
22
|
defineDocumentFunction,
|
|
308
23
|
defineDocumentWebhook,
|
|
24
|
+
defineRobotToken,
|
|
309
25
|
defineRole,
|
|
310
|
-
defineRobot,
|
|
311
|
-
defineScheduleFunction,
|
|
312
26
|
} from '@sanity/blueprints'
|
|
313
27
|
|
|
314
28
|
export default defineBlueprint({
|
|
315
29
|
resources: [
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
defineCorsOrigin({name: 'app', origin: 'https://myapp.com', allowCredentials: true}),
|
|
30
|
+
defineCorsOrigin({
|
|
31
|
+
name: 'localhost-origin',
|
|
32
|
+
origin: 'http://localhost:3333',
|
|
33
|
+
allowCredentials: true,
|
|
34
|
+
}),
|
|
322
35
|
|
|
323
|
-
// Functions
|
|
324
36
|
defineDocumentFunction({
|
|
325
|
-
name: 'on-
|
|
326
|
-
event: {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
37
|
+
name: 'on-publish',
|
|
38
|
+
event: {
|
|
39
|
+
on: ['create', 'update'],
|
|
40
|
+
filter: "_type == 'product'",
|
|
41
|
+
projection: '{_id, title, slug}',
|
|
42
|
+
},
|
|
331
43
|
}),
|
|
332
44
|
|
|
333
|
-
// Webhooks
|
|
334
45
|
defineDocumentWebhook({
|
|
335
|
-
name: '
|
|
336
|
-
url: 'https://api.example.com/
|
|
46
|
+
name: 'server-webhook',
|
|
47
|
+
url: 'https://api.example.com/webhooks/sanity',
|
|
337
48
|
on: ['create', 'update'],
|
|
338
49
|
dataset: 'production',
|
|
50
|
+
apiVersion: 'v2026-01-01',
|
|
339
51
|
}),
|
|
340
52
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
name: 'deploy-bot',
|
|
349
|
-
label: 'Deploy Bot',
|
|
350
|
-
memberships: [{resourceType: 'project', resourceId: 'proj123', roleNames: ['editor']}],
|
|
53
|
+
defineRobotToken({
|
|
54
|
+
name: 'ci-robot',
|
|
55
|
+
memberships: [{
|
|
56
|
+
resourceType: 'project',
|
|
57
|
+
resourceId: 'your-project-id',
|
|
58
|
+
roleNames: ['developer'],
|
|
59
|
+
}],
|
|
351
60
|
}),
|
|
352
61
|
],
|
|
353
62
|
})
|
|
354
63
|
```
|
|
64
|
+
|
|
65
|
+
## Available resources
|
|
66
|
+
|
|
67
|
+
| Definer | Description |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `defineBlueprint` | Top-level blueprint module containing resources |
|
|
70
|
+
| `defineDocumentFunction` | Function triggered by document events |
|
|
71
|
+
| `defineMediaLibraryAssetFunction` | Function triggered by media library events |
|
|
72
|
+
| `defineCorsOrigin` β | CORS origin allowing browser requests to your project |
|
|
73
|
+
| `defineDocumentWebhook` β | Webhook triggered by document changes |
|
|
74
|
+
| `defineRole` β | Custom role with permissions |
|
|
75
|
+
| `defineRobotToken` β | Robot token for automated access |
|
|
76
|
+
|
|
77
|
+
Each definer validates its input at call time and returns a typed resource object. See the [reference docs](https://reference.sanity.io/_sanity/blueprints) for full configuration details and additional resource types.
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { type Blueprint, type BlueprintModule, type BlueprintsApiConfig } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Define a Blueprint to manage Sanity resources
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
5
6
|
* defineBlueprint({
|
|
6
7
|
* resources: [
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* defineCorsOrigin({
|
|
9
|
+
* name: 'localhost-origin',
|
|
10
|
+
* origin: 'http://localhost:3333',
|
|
11
|
+
* }),
|
|
12
|
+
* defineDocumentFunction({
|
|
13
|
+
* name: 'update-search-index',
|
|
14
|
+
* event: {
|
|
15
|
+
* on: ['create', 'update'],
|
|
16
|
+
* filter: "_type == 'post'",
|
|
17
|
+
* projection: "{_id, title, slug}",
|
|
18
|
+
* },
|
|
19
|
+
* }),
|
|
20
|
+
* ],
|
|
9
21
|
* })
|
|
10
22
|
* ```
|
|
11
23
|
* @param blueprintConfig The blueprint configuration
|
|
@@ -1,12 +1,49 @@
|
|
|
1
1
|
import { validateBlueprint } from '../index.js';
|
|
2
2
|
import { runValidation } from '../utils/validation.js';
|
|
3
|
+
/*
|
|
4
|
+
* FUTURE example (move below @example when ready)
|
|
5
|
+
* @example With deployment API config
|
|
6
|
+
* ```ts
|
|
7
|
+
* defineBlueprint({
|
|
8
|
+
* resources: [
|
|
9
|
+
* defineCorsOrigin({
|
|
10
|
+
* name: 'cors-localhost',
|
|
11
|
+
* origin: 'http://localhost:3333'
|
|
12
|
+
* }),
|
|
13
|
+
* defineRole({
|
|
14
|
+
* name: 'role-ci',
|
|
15
|
+
* title: 'CI Role',
|
|
16
|
+
* appliesToRobots: true,
|
|
17
|
+
* permissions: []
|
|
18
|
+
* }),
|
|
19
|
+
* defineRobotToken({
|
|
20
|
+
* name: 'ci-robot',
|
|
21
|
+
* memberships: [{
|
|
22
|
+
* roleNames: ['$.resources.ci-role']}],
|
|
23
|
+
* }),
|
|
24
|
+
* ],
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
3
28
|
/**
|
|
4
29
|
* Define a Blueprint to manage Sanity resources
|
|
5
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
6
32
|
* defineBlueprint({
|
|
7
33
|
* resources: [
|
|
8
|
-
*
|
|
9
|
-
*
|
|
34
|
+
* defineCorsOrigin({
|
|
35
|
+
* name: 'localhost-origin',
|
|
36
|
+
* origin: 'http://localhost:3333',
|
|
37
|
+
* }),
|
|
38
|
+
* defineDocumentFunction({
|
|
39
|
+
* name: 'update-search-index',
|
|
40
|
+
* event: {
|
|
41
|
+
* on: ['create', 'update'],
|
|
42
|
+
* filter: "_type == 'post'",
|
|
43
|
+
* projection: "{_id, title, slug}",
|
|
44
|
+
* },
|
|
45
|
+
* }),
|
|
46
|
+
* ],
|
|
10
47
|
* })
|
|
11
48
|
* ```
|
|
12
49
|
* @param blueprintConfig The blueprint configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blueprints.js","sourceRoot":"","sources":["../../src/definers/blueprints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAC7G,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD
|
|
1
|
+
{"version":3,"file":"blueprints.js","sourceRoot":"","sources":["../../src/definers/blueprints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAC7G,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,eAAe,CAAC,eAAkE;IAChG,MAAM,EAAC,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAC,GAAG,eAAe,CAAA;IAE1G,aAAa,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAA;IAEvD,SAAS,SAAS;QAChB,OAAO;YACL,OAAO,EAAE,wEAAwE;YACjF,gBAAgB,EAAE,gBAAgB,IAAI,YAAY;YAClD,SAAS;YACT,MAAM;YACN,OAAO;SACR,CAAA;IACH,CAAC;IAED,SAAS,CAAC,cAAc,GAAG,cAAc,CAAA;IACzC,SAAS,CAAC,SAAS,GAAG,SAAS,CAAA;IAC/B,SAAS,CAAC,OAAO,GAAG,OAAO,CAAA;IAE3B,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
package/dist/definers/cors.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { type BlueprintCorsOriginConfig, type BlueprintCorsOriginResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Defines a CORS Origin to be managed in a Blueprint.
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
5
6
|
* defineCorsOrigin({
|
|
7
|
+
* name: 'my-cors-origin',
|
|
6
8
|
* origin: 'https://mydomain.com',
|
|
7
|
-
* allowCredentials: true
|
|
9
|
+
* allowCredentials: true,
|
|
8
10
|
* })
|
|
9
11
|
* ```
|
|
10
12
|
* @param parameters The CORS Origin configuration
|
|
11
13
|
* @public
|
|
12
14
|
* @beta Deploying CORS Origins via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
13
15
|
* @category Definers
|
|
16
|
+
* @expandType BlueprintCorsOriginConfig
|
|
14
17
|
* @returns The CORS Origin resource
|
|
15
18
|
*/
|
|
16
19
|
export declare function defineCorsOrigin(parameters: BlueprintCorsOriginConfig): BlueprintCorsOriginResource;
|
package/dist/definers/cors.js
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import { validateCorsOrigin } from '../index.js';
|
|
2
2
|
import { runValidation } from '../utils/validation.js';
|
|
3
|
+
/*
|
|
4
|
+
* FUTURE example (move below @example when ready)
|
|
5
|
+
* @example All options
|
|
6
|
+
* ```ts
|
|
7
|
+
* defineCorsOrigin({
|
|
8
|
+
* name: 'studio-cors',
|
|
9
|
+
* origin: 'https://my-studio.sanity.studio',
|
|
10
|
+
* allowCredentials: true,
|
|
11
|
+
* project: 'my-project-id',
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
3
15
|
/**
|
|
4
16
|
* Defines a CORS Origin to be managed in a Blueprint.
|
|
5
|
-
*
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
6
19
|
* defineCorsOrigin({
|
|
20
|
+
* name: 'my-cors-origin',
|
|
7
21
|
* origin: 'https://mydomain.com',
|
|
8
|
-
* allowCredentials: true
|
|
22
|
+
* allowCredentials: true,
|
|
9
23
|
* })
|
|
10
24
|
* ```
|
|
11
25
|
* @param parameters The CORS Origin configuration
|
|
12
26
|
* @public
|
|
13
27
|
* @beta Deploying CORS Origins via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
14
28
|
* @category Definers
|
|
29
|
+
* @expandType BlueprintCorsOriginConfig
|
|
15
30
|
* @returns The CORS Origin resource
|
|
16
31
|
*/
|
|
17
32
|
export function defineCorsOrigin(parameters) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cors.js","sourceRoot":"","sources":["../../src/definers/cors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmE,kBAAkB,EAAC,MAAM,aAAa,CAAA;AAChH,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD
|
|
1
|
+
{"version":3,"file":"cors.js","sourceRoot":"","sources":["../../src/definers/cors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmE,kBAAkB,EAAC,MAAM,aAAa,CAAA;AAChH,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;GAWG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAqC;IACpE,MAAM,YAAY,GAAgC;QAChD,GAAG,UAAU;QACb,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,IAAI,KAAK;QACtD,IAAI,EAAE,qBAAqB;KAC5B,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAA;IAErD,OAAO,YAAY,CAAA;AACrB,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type BlueprintDatasetConfig, type BlueprintDatasetResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Defines a Dataset to be managed in a Blueprint.
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
5
6
|
* defineDataset({
|
|
6
|
-
* name: '
|
|
7
|
+
* name: 'staging-dataset',
|
|
8
|
+
* datasetName: 'staging',
|
|
7
9
|
* })
|
|
8
10
|
* ```
|
|
9
11
|
* @param parameters The dataset configuration
|
|
@@ -11,6 +13,7 @@ import { type BlueprintDatasetConfig, type BlueprintDatasetResource } from '../i
|
|
|
11
13
|
* @alpha Deploying Datasets via Blueprints is experimental. This feature is subject to breaking changes.
|
|
12
14
|
* @hidden
|
|
13
15
|
* @category Definers
|
|
16
|
+
* @expandType BlueprintDatasetConfig
|
|
14
17
|
* @returns The dataset resource
|
|
15
18
|
*/
|
|
16
19
|
export declare function defineDataset(parameters: BlueprintDatasetConfig): BlueprintDatasetResource;
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { validateDataset } from '../index.js';
|
|
2
2
|
import { runValidation } from '../utils/validation.js';
|
|
3
|
+
/*
|
|
4
|
+
* FUTURE example (move below @example when ready)
|
|
5
|
+
* @example All options
|
|
6
|
+
* ```ts
|
|
7
|
+
* defineDataset({
|
|
8
|
+
* name: 'staging',
|
|
9
|
+
* datasetName: 'staging-v2',
|
|
10
|
+
* aclMode: 'private',
|
|
11
|
+
* project: 'my-project-id',
|
|
12
|
+
* lifecycle: {deletionPolicy: 'protect'},
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
3
16
|
/**
|
|
4
17
|
* Defines a Dataset to be managed in a Blueprint.
|
|
5
|
-
*
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
6
20
|
* defineDataset({
|
|
7
|
-
* name: '
|
|
21
|
+
* name: 'staging-dataset',
|
|
22
|
+
* datasetName: 'staging',
|
|
8
23
|
* })
|
|
9
24
|
* ```
|
|
10
25
|
* @param parameters The dataset configuration
|
|
@@ -12,6 +27,7 @@ import { runValidation } from '../utils/validation.js';
|
|
|
12
27
|
* @alpha Deploying Datasets via Blueprints is experimental. This feature is subject to breaking changes.
|
|
13
28
|
* @hidden
|
|
14
29
|
* @category Definers
|
|
30
|
+
* @expandType BlueprintDatasetConfig
|
|
15
31
|
* @returns The dataset resource
|
|
16
32
|
*/
|
|
17
33
|
export function defineDataset(parameters) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasets.js","sourceRoot":"","sources":["../../src/definers/datasets.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6D,eAAe,EAAC,MAAM,aAAa,CAAA;AACvG,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD
|
|
1
|
+
{"version":3,"file":"datasets.js","sourceRoot":"","sources":["../../src/definers/datasets.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6D,eAAe,EAAC,MAAM,aAAa,CAAA;AACvG,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAAC,UAAkC;IAC9D,uBAAuB;IACvB,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,IAAI,UAAU,CAAC,IAAI,CAAA;IAE7D,MAAM,eAAe,GAA6B;QAChD,GAAG,UAAU;QACb,WAAW;QACX,IAAI,EAAE,wBAAwB;KAC/B,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAAA;IAErD,OAAO,eAAe,CAAA;AACxB,CAAC"}
|