@sanity/blueprints 0.9.0 → 0.11.0
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 +326 -14
- package/dist/definers/blueprints.d.ts +2 -0
- package/dist/definers/blueprints.js +2 -0
- package/dist/definers/blueprints.js.map +1 -1
- package/dist/definers/cors.d.ts +4 -0
- package/dist/definers/cors.js +4 -0
- package/dist/definers/cors.js.map +1 -1
- package/dist/definers/datasets.d.ts +5 -0
- package/dist/definers/datasets.js +5 -0
- package/dist/definers/datasets.js.map +1 -1
- package/dist/definers/functions.d.ts +41 -12
- package/dist/definers/functions.js +60 -16
- package/dist/definers/functions.js.map +1 -1
- package/dist/definers/resources.d.ts +2 -0
- package/dist/definers/resources.js +2 -0
- package/dist/definers/resources.js.map +1 -1
- package/dist/definers/robots.d.ts +4 -0
- package/dist/definers/robots.js +4 -0
- package/dist/definers/robots.js.map +1 -1
- package/dist/definers/roles.d.ts +6 -0
- package/dist/definers/roles.js +6 -0
- package/dist/definers/roles.js.map +1 -1
- package/dist/definers/webhooks.d.ts +4 -0
- package/dist/definers/webhooks.js +4 -0
- package/dist/definers/webhooks.js.map +1 -1
- package/dist/index.d.ts +20 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/dist/types/blueprints.d.ts +16 -4
- package/dist/types/cors.d.ts +4 -0
- package/dist/types/datasets.d.ts +14 -2
- package/dist/types/errors.d.ts +4 -1
- package/dist/types/functions.d.ts +81 -16
- package/dist/types/functions.js +5 -1
- package/dist/types/functions.js.map +1 -1
- package/dist/types/resources.d.ts +16 -1
- package/dist/types/robots.d.ts +12 -3
- package/dist/types/roles.d.ts +11 -3
- package/dist/types/webhooks.d.ts +18 -6
- package/dist/utils/schedule-parser.d.ts +42 -0
- package/dist/utils/schedule-parser.js +450 -0
- package/dist/utils/schedule-parser.js.map +1 -0
- package/dist/utils/validation.d.ts +1 -0
- package/dist/utils/validation.js +1 -0
- package/dist/utils/validation.js.map +1 -1
- package/dist/validation/blueprints.d.ts +1 -0
- package/dist/validation/blueprints.js +1 -0
- package/dist/validation/blueprints.js.map +1 -1
- package/dist/validation/cors.d.ts +1 -0
- package/dist/validation/cors.js +1 -0
- package/dist/validation/cors.js.map +1 -1
- package/dist/validation/datasets.d.ts +2 -0
- package/dist/validation/datasets.js +2 -0
- package/dist/validation/datasets.js.map +1 -1
- package/dist/validation/functions.d.ts +11 -0
- package/dist/validation/functions.js +37 -1
- package/dist/validation/functions.js.map +1 -1
- package/dist/validation/resources.d.ts +7 -1
- package/dist/validation/resources.js +23 -16
- package/dist/validation/resources.js.map +1 -1
- package/dist/validation/robots.d.ts +7 -0
- package/dist/validation/robots.js +7 -0
- package/dist/validation/robots.js.map +1 -1
- package/dist/validation/roles.d.ts +3 -1
- package/dist/validation/roles.js +3 -1
- package/dist/validation/roles.js.map +1 -1
- package/dist/validation/webhooks.d.ts +1 -0
- package/dist/validation/webhooks.js +1 -0
- package/dist/validation/webhooks.js.map +1 -1
- package/package.json +4 -1
- package/src/definers/blueprints.ts +2 -0
- package/src/definers/cors.ts +4 -0
- package/src/definers/datasets.ts +5 -0
- package/src/definers/functions.ts +65 -18
- package/src/definers/resources.ts +2 -0
- package/src/definers/robots.ts +4 -0
- package/src/definers/roles.ts +6 -0
- package/src/definers/webhooks.ts +4 -0
- package/src/index.ts +22 -0
- package/src/types/blueprints.ts +16 -4
- package/src/types/cors.ts +4 -0
- package/src/types/datasets.ts +14 -2
- package/src/types/errors.ts +4 -1
- package/src/types/functions.ts +93 -15
- package/src/types/resources.ts +16 -1
- package/src/types/robots.ts +12 -3
- package/src/types/roles.ts +11 -3
- package/src/types/webhooks.ts +18 -6
- package/src/utils/schedule-parser.ts +502 -0
- package/src/utils/validation.ts +1 -0
- package/src/validation/blueprints.ts +1 -0
- package/src/validation/cors.ts +1 -0
- package/src/validation/datasets.ts +2 -0
- package/src/validation/functions.ts +37 -0
- package/src/validation/resources.ts +24 -16
- package/src/validation/robots.ts +7 -0
- package/src/validation/roles.ts +3 -1
- package/src/validation/webhooks.ts +1 -0
package/README.md
CHANGED
|
@@ -5,38 +5,350 @@
|
|
|
5
5
|
|
|
6
6
|
Helper methods for building valid Sanity Blueprints.
|
|
7
7
|
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @sanity/blueprints
|
|
12
|
+
```
|
|
13
|
+
|
|
8
14
|
## Usage
|
|
9
15
|
|
|
10
16
|
```ts
|
|
11
|
-
import {
|
|
12
|
-
defineBlueprint,
|
|
13
|
-
defineDocumentFunction,
|
|
14
|
-
defineDocumentWebhook
|
|
15
|
-
} from '@sanity/blueprints'
|
|
17
|
+
import {defineBlueprint, defineDocumentFunction, defineScheduleFunction} from '@sanity/blueprints'
|
|
16
18
|
|
|
17
19
|
export default defineBlueprint({
|
|
18
20
|
resources: [
|
|
19
21
|
defineDocumentFunction({
|
|
20
|
-
name: '
|
|
21
|
-
src: 'functions/
|
|
22
|
+
name: 'on-customer-change',
|
|
23
|
+
src: 'functions/on-customer-change',
|
|
22
24
|
memory: 2,
|
|
23
25
|
timeout: 360,
|
|
24
26
|
event: {
|
|
25
27
|
on: ['create', 'update'],
|
|
26
28
|
filter: "_type == 'customer'",
|
|
27
|
-
projection:
|
|
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',
|
|
28
43
|
},
|
|
29
44
|
env: {
|
|
30
|
-
|
|
45
|
+
REPORT_EMAIL: 'team@example.com',
|
|
31
46
|
},
|
|
32
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
|
|
301
|
+
|
|
302
|
+
```ts
|
|
303
|
+
import {
|
|
304
|
+
defineBlueprint,
|
|
305
|
+
defineCorsOrigin,
|
|
306
|
+
defineDataset,
|
|
307
|
+
defineDocumentFunction,
|
|
308
|
+
defineDocumentWebhook,
|
|
309
|
+
defineRole,
|
|
310
|
+
defineRobot,
|
|
311
|
+
defineScheduleFunction,
|
|
312
|
+
} from '@sanity/blueprints'
|
|
313
|
+
|
|
314
|
+
export default defineBlueprint({
|
|
315
|
+
resources: [
|
|
316
|
+
// Datasets
|
|
317
|
+
defineDataset({name: 'production', aclMode: 'public'}),
|
|
318
|
+
defineDataset({name: 'staging', aclMode: 'private'}),
|
|
319
|
+
|
|
320
|
+
// CORS
|
|
321
|
+
defineCorsOrigin({name: 'app', origin: 'https://myapp.com', allowCredentials: true}),
|
|
322
|
+
|
|
323
|
+
// Functions
|
|
324
|
+
defineDocumentFunction({
|
|
325
|
+
name: 'on-order',
|
|
326
|
+
event: {on: ['create'], filter: "_type == 'order'"},
|
|
327
|
+
}),
|
|
328
|
+
defineScheduleFunction({
|
|
329
|
+
name: 'daily-sync',
|
|
330
|
+
event: {expression: 'every day at 6am'},
|
|
331
|
+
}),
|
|
332
|
+
|
|
333
|
+
// Webhooks
|
|
33
334
|
defineDocumentWebhook({
|
|
34
|
-
name: '
|
|
35
|
-
url: '
|
|
36
|
-
on: ['create'],
|
|
335
|
+
name: 'notify',
|
|
336
|
+
url: 'https://api.example.com/webhook',
|
|
337
|
+
on: ['create', 'update'],
|
|
37
338
|
dataset: 'production',
|
|
38
|
-
|
|
39
|
-
|
|
339
|
+
}),
|
|
340
|
+
|
|
341
|
+
// Access control
|
|
342
|
+
defineRole({
|
|
343
|
+
name: 'content-editor',
|
|
344
|
+
title: 'Content Editor',
|
|
345
|
+
permissions: [{type: 'sanity.document.*', grant: 'read'}],
|
|
346
|
+
}),
|
|
347
|
+
defineRobot({
|
|
348
|
+
name: 'deploy-bot',
|
|
349
|
+
label: 'Deploy Bot',
|
|
350
|
+
memberships: [{resourceType: 'project', resourceId: 'proj123', roleNames: ['editor']}],
|
|
351
|
+
}),
|
|
40
352
|
],
|
|
41
353
|
})
|
|
42
354
|
```
|
|
@@ -9,6 +9,8 @@ import { type Blueprint, type BlueprintModule, type BlueprintsApiConfig } from '
|
|
|
9
9
|
* })
|
|
10
10
|
* ```
|
|
11
11
|
* @param blueprintConfig The blueprint configuration
|
|
12
|
+
* @public
|
|
13
|
+
* @category Definers
|
|
12
14
|
* @returns A blueprint module
|
|
13
15
|
*/
|
|
14
16
|
export declare function defineBlueprint(blueprintConfig: Partial<Blueprint> & Partial<BlueprintsApiConfig>): BlueprintModule;
|
|
@@ -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;;;;;;;;;;;;;GAaG;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
|
@@ -8,5 +8,9 @@ import { type BlueprintCorsOriginConfig, type BlueprintCorsOriginResource } from
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
* @param parameters The CORS Origin configuration
|
|
11
|
+
* @public
|
|
12
|
+
* @beta Deploying CORS Origins via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
13
|
+
* @category Definers
|
|
14
|
+
* @returns The CORS Origin resource
|
|
11
15
|
*/
|
|
12
16
|
export declare function defineCorsOrigin(parameters: BlueprintCorsOriginConfig): BlueprintCorsOriginResource;
|
package/dist/definers/cors.js
CHANGED
|
@@ -9,6 +9,10 @@ import { runValidation } from '../utils/validation.js';
|
|
|
9
9
|
* })
|
|
10
10
|
* ```
|
|
11
11
|
* @param parameters The CORS Origin configuration
|
|
12
|
+
* @public
|
|
13
|
+
* @beta Deploying CORS Origins via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
14
|
+
* @category Definers
|
|
15
|
+
* @returns The CORS Origin resource
|
|
12
16
|
*/
|
|
13
17
|
export function defineCorsOrigin(parameters) {
|
|
14
18
|
const corsResource = {
|
|
@@ -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;;;;;;;;;;;;;GAaG;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"}
|
|
@@ -7,5 +7,10 @@ import { type BlueprintDatasetConfig, type BlueprintDatasetResource } from '../i
|
|
|
7
7
|
* })
|
|
8
8
|
* ```
|
|
9
9
|
* @param parameters The dataset configuration
|
|
10
|
+
* @public
|
|
11
|
+
* @alpha Deploying Datasets via Blueprints is experimental. This feature is subject to breaking changes.
|
|
12
|
+
* @hidden
|
|
13
|
+
* @category Definers
|
|
14
|
+
* @returns The dataset resource
|
|
10
15
|
*/
|
|
11
16
|
export declare function defineDataset(parameters: BlueprintDatasetConfig): BlueprintDatasetResource;
|
|
@@ -8,6 +8,11 @@ import { runValidation } from '../utils/validation.js';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
* @param parameters The dataset configuration
|
|
11
|
+
* @public
|
|
12
|
+
* @alpha Deploying Datasets via Blueprints is experimental. This feature is subject to breaking changes.
|
|
13
|
+
* @hidden
|
|
14
|
+
* @category Definers
|
|
15
|
+
* @returns The dataset resource
|
|
11
16
|
*/
|
|
12
17
|
export function defineDataset(parameters) {
|
|
13
18
|
// default dataset name
|
|
@@ -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;;;;;;;;;;;;;GAaG;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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type BlueprintBaseFunctionResource, type BlueprintDocumentFunctionResource, type BlueprintDocumentFunctionResourceEvent, type BlueprintMediaLibraryAssetFunctionResource, type BlueprintMediaLibraryFunctionResourceEvent, type BlueprintScheduleFunctionResource, type BlueprintScheduleFunctionResourceEvent } from '../index.js';
|
|
2
|
-
|
|
2
|
+
/** @internal */
|
|
3
|
+
export interface RequiredFunctionProperties {
|
|
3
4
|
name: string;
|
|
4
5
|
}
|
|
5
6
|
/**
|
|
@@ -22,6 +23,8 @@ interface RequiredFunctionProperties {
|
|
|
22
23
|
* })
|
|
23
24
|
* ```
|
|
24
25
|
* @param functionConfig The configuration for the document function
|
|
26
|
+
* @public
|
|
27
|
+
* @category Definers
|
|
25
28
|
* @returns The validated document function resource
|
|
26
29
|
*/
|
|
27
30
|
export declare function defineDocumentFunction(functionConfig: Partial<BlueprintDocumentFunctionResource> & RequiredFunctionProperties): BlueprintDocumentFunctionResource;
|
|
@@ -48,28 +51,52 @@ export declare function defineDocumentFunction(functionConfig: Partial<Blueprint
|
|
|
48
51
|
* })
|
|
49
52
|
* ```
|
|
50
53
|
* @param functionConfig The configuration for the media library asset function
|
|
54
|
+
* @public
|
|
55
|
+
* @category Definers
|
|
51
56
|
* @returns The validated media library asset function resource
|
|
52
57
|
*/
|
|
53
58
|
export declare function defineMediaLibraryAssetFunction(functionConfig: Partial<BlueprintMediaLibraryAssetFunctionResource> & RequiredFunctionProperties & Pick<BlueprintMediaLibraryAssetFunctionResource, 'event'> & Partial<BlueprintMediaLibraryFunctionResourceEvent>): BlueprintMediaLibraryAssetFunctionResource;
|
|
54
59
|
/**
|
|
55
60
|
* Defines a function that is triggered on a schedule.
|
|
61
|
+
* Supports cron expressions or natural language schedules.
|
|
62
|
+
*
|
|
56
63
|
* ```
|
|
64
|
+
* // Using cron expression
|
|
65
|
+
* defineScheduleFunction({
|
|
66
|
+
* name: 'daily-cleanup',
|
|
67
|
+
* event: {expression: '0 9 * * *'},
|
|
68
|
+
* })
|
|
69
|
+
*
|
|
70
|
+
* // Using natural language
|
|
71
|
+
* defineScheduleFunction({
|
|
72
|
+
* name: 'daily-report',
|
|
73
|
+
* event: {expression: 'every day at 9am'},
|
|
74
|
+
* })
|
|
75
|
+
*
|
|
76
|
+
* // More natural language examples:
|
|
77
|
+
* // 'every 15 minutes'
|
|
78
|
+
* // 'weekdays at 8am'
|
|
79
|
+
* // 'fridays in the evening'
|
|
80
|
+
* // 'mon, wed, fri at 9am'
|
|
81
|
+
* // 'first of the month at noon'
|
|
82
|
+
*
|
|
83
|
+
* // Using explicit cron fields
|
|
57
84
|
* defineScheduleFunction({
|
|
58
85
|
* name: 'my-schedule-function',
|
|
59
|
-
* src: 'functions/schedule-function',
|
|
60
|
-
* memory: 3,
|
|
61
|
-
* timeout: 300,
|
|
62
86
|
* event: {
|
|
63
|
-
* minute:
|
|
64
|
-
* hour:
|
|
65
|
-
* dayOfMonth:
|
|
66
|
-
* month:
|
|
67
|
-
* dayOfWeek:
|
|
87
|
+
* minute: '0',
|
|
88
|
+
* hour: '9',
|
|
89
|
+
* dayOfMonth: '*',
|
|
90
|
+
* month: '*',
|
|
91
|
+
* dayOfWeek: '*',
|
|
68
92
|
* },
|
|
69
93
|
* })
|
|
70
94
|
* ```
|
|
71
|
-
* @
|
|
72
|
-
* @
|
|
95
|
+
* @public
|
|
96
|
+
* @alpha Deploying Schedule Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
97
|
+
* @hidden
|
|
98
|
+
* @category Definers
|
|
99
|
+
* @param functionConfig The configuration for the schedule function
|
|
73
100
|
* @returns The validated schedule function resource
|
|
74
101
|
*/
|
|
75
102
|
export declare function defineScheduleFunction(functionConfig: Partial<BlueprintScheduleFunctionResource> & RequiredFunctionProperties & Pick<BlueprintScheduleFunctionResource, 'event'> & Partial<BlueprintScheduleFunctionResourceEvent>): BlueprintScheduleFunctionResource;
|
|
@@ -81,6 +108,7 @@ export declare function defineScheduleFunction(functionConfig: Partial<Blueprint
|
|
|
81
108
|
* src: 'functions/my-function',
|
|
82
109
|
* timeout: 300,
|
|
83
110
|
* memory: 1,
|
|
111
|
+
* runtime: 'nodejs24.x',
|
|
84
112
|
* env: {
|
|
85
113
|
* MY_ENV_VAR: 'my-custom-value'
|
|
86
114
|
* },
|
|
@@ -88,9 +116,10 @@ export declare function defineScheduleFunction(functionConfig: Partial<Blueprint
|
|
|
88
116
|
* ```
|
|
89
117
|
* @param functionConfig The configuration for the function
|
|
90
118
|
* @param options Optional configuration including validation options
|
|
119
|
+
* @category Definers
|
|
120
|
+
* @internal
|
|
91
121
|
* @returns The validated function resource
|
|
92
122
|
*/
|
|
93
123
|
export declare function defineFunction(functionConfig: Partial<BlueprintBaseFunctionResource> & RequiredFunctionProperties, options?: {
|
|
94
124
|
skipValidation?: boolean;
|
|
95
125
|
}): BlueprintBaseFunctionResource;
|
|
96
|
-
export {};
|