@sanity/blueprints 0.22.0 → 0.23.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.
Files changed (67) hide show
  1. package/README.md +1 -0
  2. package/dist/definers/functions/base-event.d.ts +2 -0
  3. package/dist/definers/functions/base-event.js +2 -0
  4. package/dist/definers/functions/base-event.js.map +1 -0
  5. package/dist/definers/functions/document.d.ts +26 -0
  6. package/dist/definers/functions/document.js +43 -0
  7. package/dist/definers/functions/document.js.map +1 -0
  8. package/dist/definers/functions/event.d.ts +20 -0
  9. package/dist/definers/functions/event.js +30 -0
  10. package/dist/definers/functions/event.js.map +1 -0
  11. package/dist/definers/functions/index.d.ts +15 -0
  12. package/dist/definers/functions/index.js +34 -0
  13. package/dist/definers/functions/index.js.map +1 -0
  14. package/dist/definers/functions/media-library.d.ts +23 -0
  15. package/dist/definers/functions/media-library.js +83 -0
  16. package/dist/definers/functions/media-library.js.map +1 -0
  17. package/dist/definers/functions/pipeline.d.ts +26 -0
  18. package/dist/definers/functions/pipeline.js +41 -0
  19. package/dist/definers/functions/pipeline.js.map +1 -0
  20. package/dist/definers/functions/queue.d.ts +30 -0
  21. package/dist/definers/functions/queue.js +47 -0
  22. package/dist/definers/functions/queue.js.map +1 -0
  23. package/dist/definers/functions/scheduled.d.ts +46 -0
  24. package/dist/definers/functions/scheduled.js +91 -0
  25. package/dist/definers/functions/scheduled.js.map +1 -0
  26. package/dist/definers/functions/sync-tag-invalidate.d.ts +31 -0
  27. package/dist/definers/functions/sync-tag-invalidate.js +43 -0
  28. package/dist/definers/functions/sync-tag-invalidate.js.map +1 -0
  29. package/dist/definers/studios.d.ts +22 -0
  30. package/dist/definers/studios.js +31 -0
  31. package/dist/definers/studios.js.map +1 -0
  32. package/dist/index.d.ts +11 -1
  33. package/dist/index.js +11 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/types/functions/event.d.ts +9 -26
  36. package/dist/types/functions/index.d.ts +64 -47
  37. package/dist/types/functions/index.js.map +1 -1
  38. package/dist/types/studios.d.ts +57 -0
  39. package/dist/types/studios.js +2 -0
  40. package/dist/types/studios.js.map +1 -0
  41. package/dist/validation/functions.d.ts +10 -1
  42. package/dist/validation/functions.js +91 -19
  43. package/dist/validation/functions.js.map +1 -1
  44. package/dist/validation/studios.d.ts +9 -0
  45. package/dist/validation/studios.js +70 -0
  46. package/dist/validation/studios.js.map +1 -0
  47. package/package.json +19 -9
  48. package/src/definers/functions/base-event.ts +4 -0
  49. package/src/definers/functions/document.ts +129 -0
  50. package/src/definers/functions/event.ts +32 -0
  51. package/src/definers/functions/index.ts +39 -0
  52. package/src/definers/functions/media-library.ts +98 -0
  53. package/src/definers/functions/pipeline.ts +42 -0
  54. package/src/definers/functions/queue.ts +49 -0
  55. package/src/definers/functions/scheduled.ts +112 -0
  56. package/src/definers/functions/sync-tag-invalidate.ts +51 -0
  57. package/src/definers/studios.ts +34 -0
  58. package/src/index.ts +11 -1
  59. package/src/types/functions/event.ts +4 -31
  60. package/src/types/functions/index.ts +75 -57
  61. package/src/types/studios.ts +68 -0
  62. package/src/validation/functions.ts +98 -21
  63. package/src/validation/studios.ts +76 -0
  64. package/dist/definers/functions.d.ts +0 -195
  65. package/dist/definers/functions.js +0 -368
  66. package/dist/definers/functions.js.map +0 -1
  67. package/src/definers/functions.ts +0 -526
@@ -1,526 +0,0 @@
1
- import {
2
- type BlueprintBaseFunctionConfig,
3
- type BlueprintBaseFunctionResource,
4
- type BlueprintDocumentFunctionConfig,
5
- type BlueprintDocumentFunctionResource,
6
- type BlueprintDocumentFunctionResourceEvent,
7
- type BlueprintEventFunctionConfig,
8
- type BlueprintEventFunctionResource,
9
- type BlueprintFunctionBaseResourceEvent,
10
- type BlueprintMediaLibraryAssetFunctionConfig,
11
- type BlueprintMediaLibraryAssetFunctionResource,
12
- type BlueprintMediaLibraryFunctionResourceEvent,
13
- type BlueprintQueueFunctionConfig,
14
- type BlueprintQueueFunctionConfigEvent,
15
- type BlueprintQueueFunctionResource,
16
- type BlueprintQueueFunctionResourceEvent,
17
- type BlueprintScheduledFunctionConfig,
18
- type BlueprintScheduledFunctionConfigEvent,
19
- type BlueprintScheduledFunctionExplicitResourceEvent,
20
- type BlueprintScheduledFunctionExpressionResourceEvent,
21
- type BlueprintScheduledFunctionResource,
22
- type BlueprintScheduledFunctionResourceEvent,
23
- type BlueprintSyncTagInvalidateFunctionConfig,
24
- type BlueprintSyncTagInvalidateFunctionResource,
25
- validateDocumentFunction,
26
- validateEventFunction,
27
- validateFunction,
28
- validateMediaLibraryAssetFunction,
29
- validateQueueFunction,
30
- validateScheduledFunction,
31
- validateSyncTagInvalidateFunction,
32
- } from '../index.js'
33
- import {parseScheduledExpression} from '../utils/schedule-parser.js'
34
- import {runValidation} from '../utils/validation.js'
35
-
36
- type BaseFunctionEventKey = keyof BlueprintFunctionBaseResourceEvent
37
- const BASE_EVENT_KEYS = new Set<BaseFunctionEventKey>(['on', 'filter', 'projection', 'includeDrafts'])
38
- type DocumentFunctionEventKey = keyof BlueprintDocumentFunctionResourceEvent
39
- const DOCUMENT_EVENT_KEYS = new Set<DocumentFunctionEventKey>(['includeAllVersions', 'resource', ...BASE_EVENT_KEYS.values()])
40
- type MediaLibraryFunctionEventKey = keyof BlueprintMediaLibraryFunctionResourceEvent
41
- const MEDIA_LIBRARY_EVENT_KEYS = new Set<MediaLibraryFunctionEventKey>(['resource', ...BASE_EVENT_KEYS.values()])
42
- type ScheduledFunctionEventKey =
43
- | keyof BlueprintScheduledFunctionExplicitResourceEvent
44
- | keyof BlueprintScheduledFunctionExpressionResourceEvent
45
- const SCHEDULED_EVENT_KEYS = new Set<ScheduledFunctionEventKey>(['minute', 'hour', 'dayOfWeek', 'month', 'dayOfMonth', 'expression'])
46
- type QueueFunctionEventKey = keyof BlueprintQueueFunctionResourceEvent
47
- const QUEUE_EVENT_KEYS = new Set<QueueFunctionEventKey>(['concurrency', 'fifo', 'dlq'])
48
-
49
- /*
50
- * FUTURE example (move below @example when ready)
51
- * @example With robot token reference
52
- * ```ts
53
- * defineRole({
54
- * name: 'fn-role',
55
- * title: 'Function Role',
56
- * appliesToRobots: true,
57
- * permissions: [{name: 'sanity-project-dataset', action: 'read'}],
58
- * })
59
- *
60
- * defineRobotToken({
61
- * name: 'fn-robot',
62
- * memberships: [{
63
- * roleNames: ['$.resources.fn-role'],
64
- * }],
65
- * })
66
- *
67
- * defineDocumentFunction({
68
- * name: 'sync-to-external',
69
- * src: 'functions/sync',
70
- * memory: 3,
71
- * timeout: 300,
72
- * robotToken: '$.resources.fn-robot',
73
- * event: {
74
- * on: ['create', 'update'],
75
- * filter: "_type == 'product'",
76
- * projection: "{_id, title, slug}",
77
- * includeDrafts: false,
78
- * },
79
- * env: {
80
- * EXTERNAL_API_URL: 'https://api.example.com',
81
- * SUPER_SECRET: process.env.SUPER_SECRET,
82
- * },
83
- * })
84
- * ```
85
- */
86
- /**
87
- * Defines a function that is triggered by document events in Sanity datasets.
88
- *
89
- * ```ts
90
- * defineDocumentFunction({
91
- * name: 'my-document-function',
92
- * event: {
93
- * on: ['create', 'update'],
94
- * filter: "_type == 'post'",
95
- * projection: "{_id, title, slug}",
96
- * },
97
- * })
98
- * ```
99
- * @param functionConfig The configuration for the document function
100
- * @public
101
- * @category Definers
102
- * @expandType BlueprintDocumentFunctionConfig
103
- * @returns The validated document function resource
104
- */
105
- export function defineDocumentFunction(functionConfig: BlueprintDocumentFunctionConfig): BlueprintDocumentFunctionResource
106
- /**
107
- * @deprecated Define event properties under the 'event' key instead of specifying them at the top level
108
- * @hidden
109
- */
110
- export function defineDocumentFunction(
111
- functionConfig: BlueprintDocumentFunctionConfig & Partial<BlueprintDocumentFunctionResourceEvent>,
112
- ): BlueprintDocumentFunctionResource
113
-
114
- export function defineDocumentFunction(
115
- functionConfig: BlueprintDocumentFunctionConfig & Partial<BlueprintDocumentFunctionResourceEvent>,
116
- ): BlueprintDocumentFunctionResource {
117
- let {name, src, event, timeout, memory, env, robotToken, project, runtime, ...maybeEvent} = functionConfig
118
-
119
- // event validation and normalization
120
- if (event) {
121
- // `event` was specified, but event keys (aggregated in `maybeEvent`) were also specified at the top level. ambiguous and deprecated usage.
122
- const duplicateKeys = Array.from(DOCUMENT_EVENT_KEYS).filter((key) => key in maybeEvent)
123
- if (duplicateKeys.length > 0) {
124
- throw new Error(
125
- `\`event\` properties should be specified under the \`event\` key - specifying them at the top level is deprecated. The following keys were specified at the top level: ${duplicateKeys.map((k) => `\`${k}\``).join(', ')}`,
126
- )
127
- }
128
-
129
- event = buildDocumentFunctionEvent(event)
130
- } else {
131
- event = buildDocumentFunctionEvent(maybeEvent)
132
- // deprecated usage of putting event properties at the top level, warn about this.
133
- console.warn(
134
- '⚠️ Deprecated usage of `defineDocumentFunction`: prefer to put `event` properties under the `event` key rather than at the top level.',
135
- )
136
- }
137
-
138
- const functionResource: BlueprintDocumentFunctionResource = {
139
- ...defineFunction(functionConfig, {skipValidation: true}),
140
- type: 'sanity.function.document',
141
- event,
142
- }
143
-
144
- runValidation(() => validateDocumentFunction(functionResource))
145
-
146
- return functionResource
147
- }
148
-
149
- /*
150
- * FUTURE example (move below @example when ready)
151
- * @example With robot token reference
152
- * ```ts
153
- * defineRobotToken({
154
- * name: 'media-robot',
155
- * memberships: [{
156
- * resourceType: 'project',
157
- * resourceId: projectId,
158
- * roleNames: ['editor'],
159
- * }],
160
- * })
161
- *
162
- * defineMediaLibraryAssetFunction({
163
- * name: 'process-uploads',
164
- * src: 'functions/process-uploads-v2',
165
- * robotToken: '$.resources.media-robot',
166
- * event: {
167
- * on: ['create', 'update'],
168
- * resource: {
169
- * type: 'media-library',
170
- * id: 'my-media-library-id',
171
- * },
172
- * filter: "type == 'image'",
173
- * projection: "{_id}",
174
- * },
175
- * env: {
176
- * CDN_BUCKET: 'my-cdn-bucket',
177
- * },
178
- * })
179
- * ```
180
- */
181
- /**
182
- * Defines a function that is triggered by media library events.
183
- *
184
- * ```ts
185
- * defineMediaLibraryAssetFunction({
186
- * name: 'my-media-library-function',
187
- * event: {
188
- * on: ['create'],
189
- * resource: {
190
- * type: 'media-library',
191
- * id: 'my-media-library-id',
192
- * },
193
- * },
194
- * })
195
- * ```
196
- * @param functionConfig The configuration for the media library asset function
197
- * @public
198
- * @category Definers
199
- * @expandType BlueprintMediaLibraryAssetFunctionConfig
200
- * @returns The validated media library asset function resource
201
- */
202
- export function defineMediaLibraryAssetFunction(
203
- functionConfig: BlueprintMediaLibraryAssetFunctionConfig,
204
- ): BlueprintMediaLibraryAssetFunctionResource {
205
- const {event} = functionConfig
206
-
207
- const functionResource: BlueprintMediaLibraryAssetFunctionResource = {
208
- ...defineFunction(functionConfig, {skipValidation: true}),
209
- type: 'sanity.function.media-library.asset',
210
- event: buildMediaLibraryFunctionEvent(event),
211
- }
212
-
213
- runValidation(() => validateMediaLibraryAssetFunction(functionResource))
214
-
215
- return functionResource
216
- }
217
-
218
- /**
219
- * Defines a function that is triggered on a schedule.
220
- * Supports cron expressions or natural language schedules.
221
- *
222
- * @remarks
223
- * Using a cron expression:
224
- * ```ts
225
- * defineScheduledFunction({
226
- * name: 'daily-cleanup',
227
- * event: {expression: '0 9 * * *'},
228
- * })
229
- * ```
230
- *
231
- * Using explicit cron fields:
232
- * ```ts
233
- * defineScheduledFunction({
234
- * name: 'daily-cleanup',
235
- * event: {minute: '0', hour: '9', dayOfMonth: '*', month: '*', dayOfWeek: '*'},
236
- * })
237
- * ```
238
- *
239
- * The `event.expression` field accepts standard cron expressions or natural language:
240
- * `'every 15 minutes'`, `'weekdays at 8am'`, `'fridays in the evening'`,
241
- * `'mon, wed, fri at 9am'`, `'first of the month at noon'`
242
- *
243
- * ```ts
244
- * defineScheduledFunction({
245
- * name: 'daily-cleanup',
246
- * event: {expression: 'every day at 9am'},
247
- * })
248
- * ```
249
- * @public
250
- * @alpha Deploying Scheduled Functions via Blueprints is experimental. This feature is not available publicly yet.
251
- * @hidden
252
- * @category Definers
253
- * @expandType BlueprintScheduledFunctionConfig
254
- * @param functionConfig The configuration for the scheduled function
255
- * @returns The validated scheduled function resource
256
- */
257
- export function defineScheduledFunction(functionConfig: BlueprintScheduledFunctionConfig): BlueprintScheduledFunctionResource {
258
- const {event, timezone} = functionConfig
259
-
260
- const functionResource: BlueprintScheduledFunctionResource = {
261
- ...defineFunction(functionConfig, {skipValidation: true, scopeType: 'organization'}),
262
- type: 'sanity.function.cron',
263
- event: buildScheduledFunctionEvent(event),
264
- }
265
-
266
- if (timezone) functionResource.timezone = timezone
267
-
268
- // Always normalize to explicit fields (minute, hour, dayOfWeek, month, dayOfMonth)
269
- if ('expression' in functionResource.event && typeof functionResource.event.expression === 'string') {
270
- const cron = parseScheduledExpression(functionResource.event.expression)
271
- functionResource.event = cronStringToExplicitEvent(cron)
272
- }
273
-
274
- runValidation(() => validateScheduledFunction(functionResource))
275
-
276
- return functionResource
277
- }
278
-
279
- /**
280
- * @deprecated Define scheduled functions using `defineScheduledFunction` instead
281
- * @hidden
282
- */
283
- export function defineScheduleFunction(functionConfig: BlueprintScheduledFunctionConfig): BlueprintScheduledFunctionResource {
284
- return defineScheduledFunction(functionConfig)
285
- }
286
-
287
- /**
288
- * Defines a function that is triggered on a sync tag invalidate event.
289
- *
290
- * @remarks
291
- * Using implicit event scoping to all datasets in the function project:
292
- * ```ts
293
- * defineSyncTagInvalidateFunction({
294
- * name: 'bustin-caches',
295
- * })
296
- * ```
297
- *
298
- * Using explicit event scoping to a particular dataset in the function project:
299
- * ```ts
300
- * defineSyncTagInvalidateFunction({
301
- * name: 'bustin-caches',
302
- * event: {
303
- * resource: {
304
- * type: 'dataset',
305
- * id: 'myProj.myDataset',
306
- * },
307
- * },
308
- * })
309
- * ```
310
- * @public
311
- * @category Definers
312
- * @expandType BlueprintSyncTagInvalidateFunctionConfig
313
- * @param functionConfig The configuration for the sync tag invalidate function
314
- * @returns The validated sync tag invalidate function resource
315
- */
316
- export function defineSyncTagInvalidateFunction(
317
- functionConfig: BlueprintSyncTagInvalidateFunctionConfig,
318
- ): BlueprintSyncTagInvalidateFunctionResource {
319
- const {event} = functionConfig
320
-
321
- const functionResource: BlueprintSyncTagInvalidateFunctionResource = {
322
- ...defineFunction(functionConfig, {skipValidation: true}),
323
- type: 'sanity.function.sync-tag-invalidate',
324
- ...(event?.resource ? {event} : {}),
325
- }
326
-
327
- runValidation(() => validateSyncTagInvalidateFunction(functionResource))
328
-
329
- return functionResource
330
- }
331
-
332
- /**
333
- * Defines a function that provide queueing behaviour.
334
- *
335
- * @remarks
336
- * Using the reasonable defaults of concurrency: 1, fifo: true, and dlq: true
337
- * ```ts
338
- * defineQueueFunction({
339
- * name: 'send-email',
340
- * })
341
- * ```
342
- *
343
- * Using the reasonable defaults of concurrency: 1, fifo: true, and dlq: true
344
- * ```ts
345
- * defineQueueFunction({
346
- * name: 'bustin-caches',
347
- * queue: true,
348
- * })
349
- * ```
350
- *
351
- * Specifying a concurrency of 5
352
- * ```ts
353
- * defineQueueFunction({
354
- * name: 'bustin-caches',
355
- * queue: {
356
- * concurrency: 5,
357
- * fifo: true,
358
- * dlq: true,
359
- * },
360
- * })
361
- * ```
362
- * @public
363
- * @alpha Deploying Queue Functions via Blueprints is experimental. This feature is not available publicly yet.
364
- * @hidden
365
- * @category Definers
366
- * @expandType BlueprintQueueFunctionConfig
367
- * @param functionConfig The configuration for the queue function
368
- * @returns The validated queue function resource
369
- */
370
- export function defineQueueFunction(functionConfig: BlueprintQueueFunctionConfig): BlueprintQueueFunctionResource {
371
- const {queue = true} = functionConfig
372
-
373
- const functionResource: BlueprintQueueFunctionResource = {
374
- ...defineFunction(functionConfig, {skipValidation: true}),
375
- type: 'sanity.function.queue',
376
- event: buildQueueFunctionEvent(queue),
377
- }
378
-
379
- runValidation(() => validateQueueFunction(functionResource))
380
-
381
- return functionResource
382
- }
383
-
384
- /**
385
- * Defines a function that provide event behaviour.
386
- *
387
- * @remarks
388
- * A barebones event function
389
- * ```ts
390
- * defineEventFunction({
391
- * name: 'send-email',
392
- * })
393
- * ```
394
- * @public
395
- * @alpha Deploying Event Functions via Blueprints is experimental. This feature is not available publicly yet.
396
- * @hidden
397
- * @category Definers
398
- * @expandType BlueprintEventFunctionConfig
399
- * @param functionConfig The configuration for the event function
400
- * @returns The validated event function resource
401
- */
402
- export function defineEventFunction(functionConfig: BlueprintEventFunctionConfig): BlueprintEventFunctionResource {
403
- const functionResource: BlueprintEventFunctionResource = {
404
- ...defineFunction(functionConfig, {skipValidation: true}),
405
- type: 'sanity.function.event',
406
- }
407
-
408
- runValidation(() => validateEventFunction(functionResource))
409
-
410
- return functionResource
411
- }
412
-
413
- /**
414
- * Defines a base function resource with common properties.
415
- *
416
- * @param functionConfig The configuration for the function
417
- * @param options Optional configuration including validation options
418
- * @category Definers
419
- * @internal
420
- * @expandType BlueprintBaseFunctionConfig
421
- * @returns The validated function resource
422
- */
423
- export function defineFunction(
424
- functionConfig: BlueprintBaseFunctionConfig,
425
- options?: {skipValidation?: boolean; scopeType?: 'organization'},
426
- ): BlueprintBaseFunctionResource {
427
- const {name, displayName, src, timeout, memory, env, robotToken, project, runtime, lifecycle} = functionConfig
428
-
429
- const functionResource: BlueprintBaseFunctionResource = {
430
- type: 'sanity.function.document',
431
- name,
432
- src: src ?? `functions/${name}`,
433
- displayName,
434
- timeout,
435
- memory,
436
- env,
437
- robotToken,
438
- runtime,
439
- }
440
-
441
- if (options?.scopeType !== 'organization' && project) functionResource.project = project
442
-
443
- if (lifecycle) functionResource.lifecycle = lifecycle
444
-
445
- if (options?.skipValidation !== true) runValidation(() => validateFunction(functionResource))
446
-
447
- return functionResource
448
- }
449
-
450
- /**
451
- * Builds a document function event configuration from partial event properties.
452
- * Filters out non-event properties and applies defaults.
453
- * @param event Partial document function event configuration
454
- * @returns Complete document function event configuration
455
- */
456
- function buildDocumentFunctionEvent(event: Partial<BlueprintDocumentFunctionResourceEvent>): BlueprintDocumentFunctionResourceEvent {
457
- const cleanEvent = Object.fromEntries(
458
- Object.entries(event).filter(([key]) => DOCUMENT_EVENT_KEYS.has(key as DocumentFunctionEventKey)),
459
- ) as Partial<BlueprintDocumentFunctionResourceEvent>
460
-
461
- return {
462
- on: cleanEvent.on || ['publish'],
463
- ...cleanEvent,
464
- }
465
- }
466
-
467
- /**
468
- * Builds a media library function event configuration.
469
- * Filters out non-event properties and applies defaults.
470
- * @param event Media library function event configuration
471
- * @returns Complete media library function event configuration
472
- */
473
- function buildMediaLibraryFunctionEvent(event: BlueprintMediaLibraryFunctionResourceEvent): BlueprintMediaLibraryFunctionResourceEvent {
474
- const cleanEvent = Object.fromEntries(
475
- Object.entries(event).filter(([key]) => MEDIA_LIBRARY_EVENT_KEYS.has(key as MediaLibraryFunctionEventKey)),
476
- ) as BlueprintMediaLibraryFunctionResourceEvent
477
-
478
- const fullEvent = {
479
- on: cleanEvent.on || ['publish'],
480
- ...cleanEvent,
481
- }
482
- return fullEvent
483
- }
484
-
485
- /**
486
- * Builds a scheduled function event configuration.
487
- * Filters out non-event properties. Does not parse expressions.
488
- * @param event Scheduled function event configuration
489
- * @returns Cleaned scheduled function event configuration
490
- */
491
- function buildScheduledFunctionEvent(event: BlueprintScheduledFunctionConfigEvent): BlueprintScheduledFunctionResourceEvent {
492
- return Object.fromEntries(
493
- Object.entries(event).filter(([key]) => SCHEDULED_EVENT_KEYS.has(key as ScheduledFunctionEventKey)),
494
- ) as BlueprintScheduledFunctionResourceEvent
495
- }
496
-
497
- /**
498
- * Converts a cron expression string (minute hour dayOfMonth month dayOfWeek) to explicit event fields.
499
- * @param cron Cron string with five space-separated fields
500
- * @returns Explicit scheduled event with minute, hour, dayOfMonth, month, dayOfWeek
501
- */
502
- function cronStringToExplicitEvent(cron: string): BlueprintScheduledFunctionExplicitResourceEvent {
503
- const parts = cron.trim().split(/\s+/)
504
- if (parts.length !== 5) {
505
- throw new Error(`Invalid cron string: expected 5 fields, got ${parts.length}`)
506
- }
507
- const [minute, hour, dayOfMonth, month, dayOfWeek] = parts
508
- return {minute, hour, dayOfMonth, month, dayOfWeek}
509
- }
510
-
511
- /**
512
- * Builds a queue function event configuration.
513
- * @param event Queue function event configuration
514
- * @returns Cleaned queue function event configuration
515
- */
516
- function buildQueueFunctionEvent(event: BlueprintQueueFunctionConfigEvent): BlueprintQueueFunctionResourceEvent {
517
- const defaultEvent = {concurrency: 1, fifo: true, dlq: true}
518
- if (typeof event === 'boolean') {
519
- return defaultEvent
520
- }
521
- const userProvidedEvent = Object.fromEntries(Object.entries(event).filter(([key]) => QUEUE_EVENT_KEYS.has(key as QueueFunctionEventKey)))
522
- return {
523
- ...defaultEvent,
524
- ...userProvidedEvent,
525
- } as BlueprintQueueFunctionResourceEvent
526
- }