@sanity/blueprints 0.23.0 → 0.23.2
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/dist/definers/functions/base-event.d.ts +2 -0
- package/dist/definers/functions/base-event.js +2 -0
- package/dist/definers/functions/base-event.js.map +1 -0
- package/dist/definers/functions/document.d.ts +26 -0
- package/dist/definers/functions/document.js +43 -0
- package/dist/definers/functions/document.js.map +1 -0
- package/dist/definers/functions/durable.d.ts +26 -0
- package/dist/definers/functions/durable.js +41 -0
- package/dist/definers/functions/durable.js.map +1 -0
- package/dist/definers/functions/index.d.ts +15 -0
- package/dist/definers/functions/index.js +34 -0
- package/dist/definers/functions/index.js.map +1 -0
- package/dist/definers/functions/media-library.d.ts +23 -0
- package/dist/definers/functions/media-library.js +83 -0
- package/dist/definers/functions/media-library.js.map +1 -0
- package/dist/definers/functions/pubsub.d.ts +20 -0
- package/dist/definers/functions/pubsub.js +30 -0
- package/dist/definers/functions/pubsub.js.map +1 -0
- package/dist/definers/functions/queue.d.ts +30 -0
- package/dist/definers/functions/queue.js +47 -0
- package/dist/definers/functions/queue.js.map +1 -0
- package/dist/definers/functions/scheduled.d.ts +46 -0
- package/dist/definers/functions/scheduled.js +91 -0
- package/dist/definers/functions/scheduled.js.map +1 -0
- package/dist/definers/functions/sync-tag-invalidate.d.ts +31 -0
- package/dist/definers/functions/sync-tag-invalidate.js +43 -0
- package/dist/definers/functions/sync-tag-invalidate.js.map +1 -0
- package/dist/definers/studios.js +5 -0
- package/dist/definers/studios.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/types/functions/event.d.ts +2 -4
- package/dist/types/functions/index.d.ts +61 -43
- package/dist/types/studios.d.ts +36 -7
- package/dist/types/studios.js +7 -1
- package/dist/types/studios.js.map +1 -1
- package/dist/validation/functions.d.ts +3 -3
- package/dist/validation/functions.js +11 -13
- package/dist/validation/functions.js.map +1 -1
- package/dist/validation/studios.js +29 -5
- package/dist/validation/studios.js.map +1 -1
- package/package.json +1 -1
- package/src/definers/functions/base-event.ts +4 -0
- package/src/definers/functions/document.ts +129 -0
- package/src/definers/functions/durable.ts +42 -0
- package/src/definers/functions/index.ts +39 -0
- package/src/definers/functions/media-library.ts +98 -0
- package/src/definers/functions/pubsub.ts +32 -0
- package/src/definers/functions/queue.ts +49 -0
- package/src/definers/functions/scheduled.ts +112 -0
- package/src/definers/functions/sync-tag-invalidate.ts +51 -0
- package/src/definers/studios.ts +5 -0
- package/src/index.ts +8 -1
- package/src/types/functions/event.ts +2 -3
- package/src/types/functions/index.ts +73 -54
- package/src/types/studios.ts +46 -8
- package/src/validation/functions.ts +11 -13
- package/src/validation/studios.ts +33 -6
- package/dist/definers/functions.d.ts +0 -210
- package/dist/definers/functions.js +0 -381
- package/dist/definers/functions.js.map +0 -1
- package/src/definers/functions.ts +0 -540
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {BlueprintResource} from '../../index.js'
|
|
2
2
|
import type {
|
|
3
3
|
BlueprintDocumentFunctionResourceEvent,
|
|
4
|
-
|
|
4
|
+
BlueprintFunctionResourceContentLakeEvent,
|
|
5
5
|
BlueprintMediaLibraryFunctionResourceEvent,
|
|
6
6
|
BlueprintScheduledFunctionConfigEvent,
|
|
7
7
|
BlueprintScheduledFunctionResourceEvent,
|
|
@@ -22,7 +22,7 @@ export const VALID_RUNTIMES = ['node', 'nodejs22.x', 'nodejs24.x'] as const
|
|
|
22
22
|
*/
|
|
23
23
|
export type FunctionRuntimes = (typeof VALID_RUNTIMES)[number]
|
|
24
24
|
|
|
25
|
-
// ---
|
|
25
|
+
// --- Function Resource (Output) Types: `define*Function` method return types ---
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Base function resource with common properties for all function types
|
|
@@ -49,6 +49,44 @@ interface BlueprintCommonFunctionResource extends BlueprintResource {
|
|
|
49
49
|
runtime?: FunctionRuntimes
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Configuration used for Queue or Workflow function types.
|
|
54
|
+
* @todo: not implemented
|
|
55
|
+
* @category Functions Types
|
|
56
|
+
* @alpha
|
|
57
|
+
* @hidden
|
|
58
|
+
*/
|
|
59
|
+
interface QueueConfig {
|
|
60
|
+
/**
|
|
61
|
+
* Maximum number of concurrent invocations in progress from queue to Function
|
|
62
|
+
* @todo: not implemented, what is the default anyways?
|
|
63
|
+
*/
|
|
64
|
+
concurrency?: number
|
|
65
|
+
/**
|
|
66
|
+
* Debounce window in seconds
|
|
67
|
+
* @todo: not implemented - and should this always be provided with debounceKey?
|
|
68
|
+
*/
|
|
69
|
+
debounce?: number
|
|
70
|
+
/**
|
|
71
|
+
* Path used to group debounced events, e.g. 'document._id'
|
|
72
|
+
* @todo: not implemented - and should this always be provided with debounce window?
|
|
73
|
+
*/
|
|
74
|
+
debounceKey?: string
|
|
75
|
+
/**
|
|
76
|
+
* Whether to place messages that failed processing into a Dead Letter Queue.
|
|
77
|
+
* @todo: not implemented
|
|
78
|
+
* @default `false`
|
|
79
|
+
*/
|
|
80
|
+
dlq?: boolean
|
|
81
|
+
/**
|
|
82
|
+
* By default, queues employ at-least once delivery. When set to `true`, employs first-in-first-out ordering and exactly-once delivery.
|
|
83
|
+
* FIFO queues have a lower transaction-per-second limit.
|
|
84
|
+
* @todo: not implemented
|
|
85
|
+
* @default `false`
|
|
86
|
+
*/
|
|
87
|
+
fifo?: boolean
|
|
88
|
+
}
|
|
89
|
+
|
|
52
90
|
/**
|
|
53
91
|
* Base function resource with common properties for all function types that can belong to projects.
|
|
54
92
|
* @category Functions Types
|
|
@@ -106,10 +144,10 @@ export interface BlueprintSyncTagInvalidateFunctionResource extends BlueprintBas
|
|
|
106
144
|
* @alpha
|
|
107
145
|
* @hidden
|
|
108
146
|
*/
|
|
109
|
-
export interface BlueprintQueueFunctionResource extends BlueprintBaseFunctionResource {
|
|
147
|
+
export interface BlueprintQueueFunctionResource extends BlueprintBaseFunctionResource, QueueConfig {
|
|
110
148
|
type: 'sanity.function.queue'
|
|
111
|
-
/** Optional event
|
|
112
|
-
event?:
|
|
149
|
+
/** Optional Content Lake event source that triggers the function */
|
|
150
|
+
event?: BlueprintFunctionResourceContentLakeEvent
|
|
113
151
|
}
|
|
114
152
|
|
|
115
153
|
/**
|
|
@@ -118,11 +156,22 @@ export interface BlueprintQueueFunctionResource extends BlueprintBaseFunctionRes
|
|
|
118
156
|
* @alpha
|
|
119
157
|
* @hidden
|
|
120
158
|
*/
|
|
121
|
-
export interface
|
|
122
|
-
type: 'sanity.function.
|
|
159
|
+
export interface BlueprintPubSubFunctionResource extends BlueprintBaseFunctionResource {
|
|
160
|
+
type: 'sanity.function.pubsub'
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* A durable, step-based function.
|
|
165
|
+
* @alpha Deploying Durable Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
166
|
+
* @hidden
|
|
167
|
+
* @category Functions Types
|
|
168
|
+
*/
|
|
169
|
+
export interface BlueprintDurableFunctionResource extends BlueprintBaseFunctionResource, QueueConfig {
|
|
170
|
+
type: 'sanity.function.durable'
|
|
171
|
+
event?: BlueprintFunctionResourceContentLakeEvent
|
|
123
172
|
}
|
|
124
173
|
|
|
125
|
-
// --- Function Config Types ---
|
|
174
|
+
// --- Function Config (Input) Types: : `define*Function` method parameter types ---
|
|
126
175
|
|
|
127
176
|
/**
|
|
128
177
|
* Configuration for defining a base function.
|
|
@@ -215,20 +264,17 @@ export type BlueprintSyncTagInvalidateFunctionConfig = Omit<BlueprintSyncTagInva
|
|
|
215
264
|
* @category Functions Types
|
|
216
265
|
* @interface
|
|
217
266
|
*/
|
|
218
|
-
export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event'> &
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
267
|
+
export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event'> &
|
|
268
|
+
QueueConfig & {
|
|
269
|
+
/**
|
|
270
|
+
* Path to the function source code
|
|
271
|
+
* @defaultValue `functions/${name}`
|
|
272
|
+
*/
|
|
273
|
+
src?: string
|
|
224
274
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
concurrency?: number
|
|
229
|
-
fifo?: boolean
|
|
230
|
-
dlq?: boolean
|
|
231
|
-
}
|
|
275
|
+
/** Optional event configuration that triggers the queue function */
|
|
276
|
+
event?: BlueprintFunctionResourceContentLakeEvent
|
|
277
|
+
}
|
|
232
278
|
|
|
233
279
|
/**
|
|
234
280
|
* Configuration for defining an event function.
|
|
@@ -238,7 +284,7 @@ export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource,
|
|
|
238
284
|
* @category Functions Types
|
|
239
285
|
* @interface
|
|
240
286
|
*/
|
|
241
|
-
export type
|
|
287
|
+
export type BlueprintPubSubFunctionConfig = Omit<BlueprintPubSubFunctionResource, 'type' | 'src'> & {
|
|
242
288
|
/**
|
|
243
289
|
* Path to the function source code
|
|
244
290
|
* @defaultValue `functions/${name}`
|
|
@@ -247,48 +293,21 @@ export type BlueprintEventFunctionConfig = Omit<BlueprintEventFunctionResource,
|
|
|
247
293
|
}
|
|
248
294
|
|
|
249
295
|
/**
|
|
250
|
-
*
|
|
251
|
-
* @public
|
|
252
|
-
* @alpha Deploying Pipeline Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
253
|
-
* @hidden
|
|
254
|
-
* @category Functions Types
|
|
255
|
-
* @interface
|
|
256
|
-
*/
|
|
257
|
-
export interface BlueprintPipelineResource extends BlueprintBaseFunctionResource {
|
|
258
|
-
type: 'sanity.function.pipeline'
|
|
259
|
-
event?: BlueprintFunctionResourceEvent
|
|
260
|
-
/**
|
|
261
|
-
* Concurrent executions
|
|
262
|
-
* Min 1
|
|
263
|
-
* Max 500
|
|
264
|
-
*/
|
|
265
|
-
concurrency?: number
|
|
266
|
-
/**
|
|
267
|
-
* Debounce window in seconds
|
|
268
|
-
*/
|
|
269
|
-
debounce?: number
|
|
270
|
-
/**
|
|
271
|
-
* Path used to group debounced events, e.g. 'document._id'
|
|
272
|
-
*/
|
|
273
|
-
debounceKey?: string
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Configuration for defining a pipeline function.
|
|
296
|
+
* Configuration for defining a durable function.
|
|
278
297
|
* @public
|
|
279
|
-
* @alpha Deploying
|
|
298
|
+
* @alpha Deploying Durable Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
280
299
|
* @hidden
|
|
281
300
|
* @category Functions Types
|
|
282
301
|
* @interface
|
|
283
302
|
*/
|
|
284
|
-
export type
|
|
303
|
+
export type BlueprintDurableConfig = Omit<BlueprintDurableFunctionResource, 'type' | 'src' | 'event'> & {
|
|
285
304
|
/**
|
|
286
|
-
* Path to the
|
|
305
|
+
* Path to the function source code
|
|
287
306
|
* @defaultValue `functions/${name}`
|
|
288
307
|
*/
|
|
289
308
|
src?: string
|
|
290
309
|
/**
|
|
291
310
|
* Trigger configuration
|
|
292
311
|
*/
|
|
293
|
-
event?:
|
|
312
|
+
event?: BlueprintFunctionResourceContentLakeEvent
|
|
294
313
|
}
|
package/src/types/studios.ts
CHANGED
|
@@ -10,6 +10,22 @@ import type {BlueprintProjectResourceLifecycle, BlueprintResource} from '../inde
|
|
|
10
10
|
*/
|
|
11
11
|
export type UserViteConfig = ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>) | InlineConfig
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* The set of valid application visibilities.
|
|
15
|
+
* @beta This feature is subject to breaking changes.
|
|
16
|
+
* @category Resource Types
|
|
17
|
+
* @hidden
|
|
18
|
+
*/
|
|
19
|
+
export const APPLICATION_VISIBILITIES = ['default', 'unlisted', 'disabled'] as const
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The visibility of the studio in the dashboard.
|
|
23
|
+
* @beta This feature is subject to breaking changes.
|
|
24
|
+
* @category Resource Types
|
|
25
|
+
* @hidden
|
|
26
|
+
*/
|
|
27
|
+
export type ApplicationVisibility = (typeof APPLICATION_VISIBILITIES)[number]
|
|
28
|
+
|
|
13
29
|
/**
|
|
14
30
|
* Represents a Studio resource.
|
|
15
31
|
* @see https://www.sanity.io/docs/studio
|
|
@@ -23,6 +39,21 @@ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProj
|
|
|
23
39
|
/** The relative location of the studio source code. */
|
|
24
40
|
src: string
|
|
25
41
|
|
|
42
|
+
/** The project ID of the project that contains your Studio. */
|
|
43
|
+
project: string
|
|
44
|
+
|
|
45
|
+
/** The slug to be used in the studio hostname. */
|
|
46
|
+
slug: string
|
|
47
|
+
|
|
48
|
+
/** Title for the studio. */
|
|
49
|
+
title: string
|
|
50
|
+
|
|
51
|
+
/** Icon for the studio in the browser. */
|
|
52
|
+
icon?: string
|
|
53
|
+
|
|
54
|
+
/** Dashboard visibility */
|
|
55
|
+
visibility?: ApplicationVisibility
|
|
56
|
+
|
|
26
57
|
/**
|
|
27
58
|
* Auto update settings for the studio.
|
|
28
59
|
*/
|
|
@@ -48,13 +79,6 @@ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProj
|
|
|
48
79
|
|
|
49
80
|
/** Custom Vite configuration for the Studio so it can be changed and extended. */
|
|
50
81
|
vite?: UserViteConfig
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The project ID of the project that contains your Studio.
|
|
54
|
-
*
|
|
55
|
-
* The `project` attribute must be defined if your blueprint is scoped to an organization.
|
|
56
|
-
*/
|
|
57
|
-
project?: string
|
|
58
82
|
}
|
|
59
83
|
|
|
60
84
|
/**
|
|
@@ -65,4 +89,18 @@ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProj
|
|
|
65
89
|
* @interface
|
|
66
90
|
* @hidden
|
|
67
91
|
*/
|
|
68
|
-
export interface BlueprintStudioConfig extends Omit<BlueprintStudioResource, 'type'> {
|
|
92
|
+
export interface BlueprintStudioConfig extends Omit<BlueprintStudioResource, 'type' | 'title' | 'autoUpdates'> {
|
|
93
|
+
/** Title for the studio. Defaults to the name of the resource. */
|
|
94
|
+
title?: string
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Auto update settings for the studio.
|
|
98
|
+
*/
|
|
99
|
+
autoUpdates?: {
|
|
100
|
+
/** Whether auto updates are enabled for the studio. Defaults to true if autoUpdates is not provided. */
|
|
101
|
+
enabled: boolean
|
|
102
|
+
|
|
103
|
+
/** What "version"/"channel" to use for auto updates */
|
|
104
|
+
version?: string // 'next', 'stable', 'latest' or a semantic version (e.g., "1.2.3", "2.0.0-beta.1")
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -468,7 +468,7 @@ export function validateQueueFunction(functionResource: unknown): BlueprintError
|
|
|
468
468
|
}
|
|
469
469
|
|
|
470
470
|
if ('event' in functionResource && typeof functionResource.event !== 'undefined') {
|
|
471
|
-
errors.push(...
|
|
471
|
+
errors.push(...validateFunctionContentLakeEvent(functionResource.event))
|
|
472
472
|
}
|
|
473
473
|
|
|
474
474
|
errors.push(...validateFunction(functionResource))
|
|
@@ -483,7 +483,7 @@ export function validateQueueFunction(functionResource: unknown): BlueprintError
|
|
|
483
483
|
* @param event The event configuration to validate
|
|
484
484
|
* @returns Array of validation errors, empty if valid
|
|
485
485
|
*/
|
|
486
|
-
function
|
|
486
|
+
function validateFunctionContentLakeEvent(event: unknown): BlueprintError[] {
|
|
487
487
|
if (!event || typeof event !== 'object') return [{type: 'invalid_type', message: '`event` must be an object'}]
|
|
488
488
|
if (!('type' in event)) return [{type: 'missing_parameter', message: '`event.type` is required'}]
|
|
489
489
|
|
|
@@ -492,15 +492,13 @@ function validateFunctionEvent(event: unknown): BlueprintError[] {
|
|
|
492
492
|
return validateDocumentFunctionEvent(event)
|
|
493
493
|
case 'media-library':
|
|
494
494
|
return validateMediaLibraryFunctionEvent(event)
|
|
495
|
-
case 'cron':
|
|
496
|
-
return validateScheduledFunctionEvent(event)
|
|
497
495
|
case 'sync-tag-invalidate':
|
|
498
496
|
return validateFunctionEventResourceDataset(event)
|
|
499
497
|
default:
|
|
500
498
|
return [
|
|
501
499
|
{
|
|
502
500
|
type: 'invalid_value',
|
|
503
|
-
message: '`event.type` must be either `
|
|
501
|
+
message: '`event.type` must be either `document`, `sync-tag-invalidate`, or `media-library`',
|
|
504
502
|
},
|
|
505
503
|
]
|
|
506
504
|
}
|
|
@@ -515,14 +513,14 @@ function validateFunctionEvent(event: unknown): BlueprintError[] {
|
|
|
515
513
|
* @returns Array of validation errors, empty if valid
|
|
516
514
|
*/
|
|
517
515
|
|
|
518
|
-
export function
|
|
516
|
+
export function validatePubSubFunction(functionResource: unknown): BlueprintError[] {
|
|
519
517
|
if (!functionResource) return [{type: 'invalid_value', message: 'Function config must be provided'}]
|
|
520
518
|
if (typeof functionResource !== 'object') return [{type: 'invalid_type', message: 'Function config must be an object'}]
|
|
521
519
|
|
|
522
520
|
const errors: BlueprintError[] = []
|
|
523
521
|
|
|
524
|
-
if ('type' in functionResource && functionResource.type !== 'sanity.function.
|
|
525
|
-
errors.push({type: 'invalid_value', message: '`type` must be `sanity.function.
|
|
522
|
+
if ('type' in functionResource && functionResource.type !== 'sanity.function.pubsub') {
|
|
523
|
+
errors.push({type: 'invalid_value', message: '`type` must be `sanity.function.pubsub`'})
|
|
526
524
|
}
|
|
527
525
|
|
|
528
526
|
errors.push(...validateFunction(functionResource))
|
|
@@ -531,21 +529,21 @@ export function validateEventFunction(functionResource: unknown): BlueprintError
|
|
|
531
529
|
}
|
|
532
530
|
|
|
533
531
|
/**
|
|
534
|
-
* Validates a
|
|
532
|
+
* Validates a durable function resource configuration.
|
|
535
533
|
* @param functionResource The function resource to validate
|
|
536
534
|
* @alpha
|
|
537
535
|
* @hidden
|
|
538
536
|
* @category Functions Types
|
|
539
537
|
* @returns Array of validation errors, empty if valid
|
|
540
538
|
*/
|
|
541
|
-
export function
|
|
539
|
+
export function validateDurableFunction(functionResource: unknown): BlueprintError[] {
|
|
542
540
|
if (!functionResource) return [{type: 'invalid_value', message: 'Function config must be provided'}]
|
|
543
541
|
if (typeof functionResource !== 'object') return [{type: 'invalid_type', message: 'Function config must be an object'}]
|
|
544
542
|
|
|
545
543
|
const errors: BlueprintError[] = []
|
|
546
544
|
|
|
547
|
-
if ('type' in functionResource && functionResource.type !== 'sanity.function.
|
|
548
|
-
errors.push({type: 'invalid_value', message: '`type` must be `sanity.function.
|
|
545
|
+
if ('type' in functionResource && functionResource.type !== 'sanity.function.durable') {
|
|
546
|
+
errors.push({type: 'invalid_value', message: '`type` must be `sanity.function.durable`'})
|
|
549
547
|
}
|
|
550
548
|
|
|
551
549
|
if ('debounceKey' in functionResource && typeof functionResource.debounceKey !== 'string') {
|
|
@@ -573,7 +571,7 @@ export function validatePipelineFunction(functionResource: unknown): BlueprintEr
|
|
|
573
571
|
}
|
|
574
572
|
|
|
575
573
|
if ('event' in functionResource) {
|
|
576
|
-
errors.push(...
|
|
574
|
+
errors.push(...validateFunctionContentLakeEvent(functionResource.event))
|
|
577
575
|
}
|
|
578
576
|
|
|
579
577
|
errors.push(...validateFunction(functionResource))
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {BlueprintError} from '../types/errors.js'
|
|
2
|
+
import {APPLICATION_VISIBILITIES} from '../types/studios.js'
|
|
2
3
|
import {validateResource} from './resources.js'
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -24,6 +25,38 @@ export function validateStudio(resource: unknown): BlueprintError[] {
|
|
|
24
25
|
errors.push({type: 'invalid_type', message: 'Studio src must be a string'})
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
if (!('project' in resource) || !resource.project) {
|
|
29
|
+
errors.push({type: 'missing_parameter', message: 'Studio project is required'})
|
|
30
|
+
} else if (typeof resource.project !== 'string') {
|
|
31
|
+
errors.push({type: 'invalid_type', message: 'Studio project must be a string'})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!('slug' in resource) || !resource.slug) {
|
|
35
|
+
errors.push({type: 'missing_parameter', message: 'Studio slug is required'})
|
|
36
|
+
} else if (typeof resource.slug !== 'string') {
|
|
37
|
+
errors.push({type: 'invalid_type', message: 'Studio slug must be a string'})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!('title' in resource) || !resource.title) {
|
|
41
|
+
errors.push({type: 'missing_parameter', message: 'Studio title is required'})
|
|
42
|
+
} else if (typeof resource.title !== 'string') {
|
|
43
|
+
errors.push({type: 'invalid_type', message: 'Studio title must be a string'})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if ('icon' in resource) {
|
|
47
|
+
if (typeof resource.icon !== 'string') {
|
|
48
|
+
errors.push({type: 'invalid_type', message: 'Studio icon must be a string'})
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
'visibility' in resource &&
|
|
54
|
+
typeof resource.visibility !== 'undefined' &&
|
|
55
|
+
!APPLICATION_VISIBILITIES.some((av) => av === resource.visibility)
|
|
56
|
+
) {
|
|
57
|
+
errors.push({type: 'invalid_value', message: 'visibility must be one of `default`, `unlisted`, or `disabled`'})
|
|
58
|
+
}
|
|
59
|
+
|
|
27
60
|
if (!('autoUpdates' in resource) || !resource.autoUpdates) {
|
|
28
61
|
errors.push({type: 'missing_parameter', message: 'Studio autoUpdates is required'})
|
|
29
62
|
} else if (typeof resource.autoUpdates !== 'object') {
|
|
@@ -66,11 +99,5 @@ export function validateStudio(resource: unknown): BlueprintError[] {
|
|
|
66
99
|
}
|
|
67
100
|
}
|
|
68
101
|
|
|
69
|
-
if ('project' in resource) {
|
|
70
|
-
if (typeof resource.project !== 'string') {
|
|
71
|
-
errors.push({type: 'invalid_type', message: 'Studio project must be a string'})
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
102
|
return errors
|
|
76
103
|
}
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { type BlueprintBaseFunctionConfig, type BlueprintBaseFunctionResource, type BlueprintDocumentFunctionConfig, type BlueprintDocumentFunctionResource, type BlueprintDocumentFunctionResourceEvent, type BlueprintEventFunctionConfig, type BlueprintEventFunctionResource, type BlueprintMediaLibraryAssetFunctionConfig, type BlueprintMediaLibraryAssetFunctionResource, type BlueprintPipelineConfig, type BlueprintPipelineResource, type BlueprintQueueFunctionConfig, type BlueprintQueueFunctionResource, type BlueprintScheduledFunctionConfig, type BlueprintScheduledFunctionResource, type BlueprintSyncTagInvalidateFunctionConfig, type BlueprintSyncTagInvalidateFunctionResource } from '../index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Defines a function that is triggered by document events in Sanity datasets.
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* defineDocumentFunction({
|
|
7
|
-
* name: 'my-document-function',
|
|
8
|
-
* event: {
|
|
9
|
-
* on: ['create', 'update'],
|
|
10
|
-
* filter: "_type == 'post'",
|
|
11
|
-
* projection: "{_id, title, slug}",
|
|
12
|
-
* },
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
15
|
-
* @param functionConfig The configuration for the document function
|
|
16
|
-
* @public
|
|
17
|
-
* @category Definers
|
|
18
|
-
* @expandType BlueprintDocumentFunctionConfig
|
|
19
|
-
* @returns The validated document function resource
|
|
20
|
-
*/
|
|
21
|
-
export declare function defineDocumentFunction(functionConfig: BlueprintDocumentFunctionConfig): BlueprintDocumentFunctionResource;
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated Define event properties under the 'event' key instead of specifying them at the top level
|
|
24
|
-
* @hidden
|
|
25
|
-
*/
|
|
26
|
-
export declare function defineDocumentFunction(functionConfig: BlueprintDocumentFunctionConfig & Partial<BlueprintDocumentFunctionResourceEvent>): BlueprintDocumentFunctionResource;
|
|
27
|
-
/**
|
|
28
|
-
* Defines a function that is triggered by media library events.
|
|
29
|
-
*
|
|
30
|
-
* ```ts
|
|
31
|
-
* defineMediaLibraryAssetFunction({
|
|
32
|
-
* name: 'my-media-library-function',
|
|
33
|
-
* event: {
|
|
34
|
-
* on: ['create'],
|
|
35
|
-
* resource: {
|
|
36
|
-
* type: 'media-library',
|
|
37
|
-
* id: 'my-media-library-id',
|
|
38
|
-
* },
|
|
39
|
-
* },
|
|
40
|
-
* })
|
|
41
|
-
* ```
|
|
42
|
-
* @param functionConfig The configuration for the media library asset function
|
|
43
|
-
* @public
|
|
44
|
-
* @category Definers
|
|
45
|
-
* @expandType BlueprintMediaLibraryAssetFunctionConfig
|
|
46
|
-
* @returns The validated media library asset function resource
|
|
47
|
-
*/
|
|
48
|
-
export declare function defineMediaLibraryAssetFunction(functionConfig: BlueprintMediaLibraryAssetFunctionConfig): BlueprintMediaLibraryAssetFunctionResource;
|
|
49
|
-
/**
|
|
50
|
-
* Defines a function that is triggered on a schedule.
|
|
51
|
-
* Supports cron expressions or natural language schedules.
|
|
52
|
-
*
|
|
53
|
-
* @remarks
|
|
54
|
-
* Using a cron expression:
|
|
55
|
-
* ```ts
|
|
56
|
-
* defineScheduledFunction({
|
|
57
|
-
* name: 'daily-cleanup',
|
|
58
|
-
* event: {expression: '0 9 * * *'},
|
|
59
|
-
* })
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* Using explicit cron fields:
|
|
63
|
-
* ```ts
|
|
64
|
-
* defineScheduledFunction({
|
|
65
|
-
* name: 'daily-cleanup',
|
|
66
|
-
* event: {minute: '0', hour: '9', dayOfMonth: '*', month: '*', dayOfWeek: '*'},
|
|
67
|
-
* })
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* The `event.expression` field accepts standard cron expressions or natural language:
|
|
71
|
-
* `'every 15 minutes'`, `'weekdays at 8am'`, `'fridays in the evening'`,
|
|
72
|
-
* `'mon, wed, fri at 9am'`, `'first of the month at noon'`
|
|
73
|
-
*
|
|
74
|
-
* ```ts
|
|
75
|
-
* defineScheduledFunction({
|
|
76
|
-
* name: 'daily-cleanup',
|
|
77
|
-
* event: {expression: 'every day at 9am'},
|
|
78
|
-
* })
|
|
79
|
-
* ```
|
|
80
|
-
* @public
|
|
81
|
-
* @alpha Deploying Scheduled Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
82
|
-
* @hidden
|
|
83
|
-
* @category Definers
|
|
84
|
-
* @expandType BlueprintScheduledFunctionConfig
|
|
85
|
-
* @param functionConfig The configuration for the scheduled function
|
|
86
|
-
* @returns The validated scheduled function resource
|
|
87
|
-
*/
|
|
88
|
-
export declare function defineScheduledFunction(functionConfig: BlueprintScheduledFunctionConfig): BlueprintScheduledFunctionResource;
|
|
89
|
-
/**
|
|
90
|
-
* @deprecated Define scheduled functions using `defineScheduledFunction` instead
|
|
91
|
-
* @hidden
|
|
92
|
-
*/
|
|
93
|
-
export declare function defineScheduleFunction(functionConfig: BlueprintScheduledFunctionConfig): BlueprintScheduledFunctionResource;
|
|
94
|
-
/**
|
|
95
|
-
* Defines a function that is triggered on a sync tag invalidate event.
|
|
96
|
-
*
|
|
97
|
-
* @remarks
|
|
98
|
-
* Using implicit event scoping to all datasets in the function project:
|
|
99
|
-
* ```ts
|
|
100
|
-
* defineSyncTagInvalidateFunction({
|
|
101
|
-
* name: 'bustin-caches',
|
|
102
|
-
* })
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* Using explicit event scoping to a particular dataset in the function project:
|
|
106
|
-
* ```ts
|
|
107
|
-
* defineSyncTagInvalidateFunction({
|
|
108
|
-
* name: 'bustin-caches',
|
|
109
|
-
* event: {
|
|
110
|
-
* resource: {
|
|
111
|
-
* type: 'dataset',
|
|
112
|
-
* id: 'myProj.myDataset',
|
|
113
|
-
* },
|
|
114
|
-
* },
|
|
115
|
-
* })
|
|
116
|
-
* ```
|
|
117
|
-
* @public
|
|
118
|
-
* @category Definers
|
|
119
|
-
* @expandType BlueprintSyncTagInvalidateFunctionConfig
|
|
120
|
-
* @param functionConfig The configuration for the sync tag invalidate function
|
|
121
|
-
* @returns The validated sync tag invalidate function resource
|
|
122
|
-
*/
|
|
123
|
-
export declare function defineSyncTagInvalidateFunction(functionConfig: BlueprintSyncTagInvalidateFunctionConfig): BlueprintSyncTagInvalidateFunctionResource;
|
|
124
|
-
/**
|
|
125
|
-
* Defines a function that provide queueing behaviour.
|
|
126
|
-
*
|
|
127
|
-
* @remarks
|
|
128
|
-
* Using the reasonable defaults of concurrency: 1, fifo: true, and dlq: true
|
|
129
|
-
* ```ts
|
|
130
|
-
* defineQueueFunction({
|
|
131
|
-
* name: 'send-email',
|
|
132
|
-
* })
|
|
133
|
-
* ```
|
|
134
|
-
*
|
|
135
|
-
* Specifying a concurrency of 5
|
|
136
|
-
* ```ts
|
|
137
|
-
* defineQueueFunction({
|
|
138
|
-
* name: 'bustin-caches',
|
|
139
|
-
* concurrency: 5,
|
|
140
|
-
* fifo: true,
|
|
141
|
-
* dlq: true,
|
|
142
|
-
* })
|
|
143
|
-
* ```
|
|
144
|
-
* @public
|
|
145
|
-
* @alpha Deploying Queue Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
146
|
-
* @hidden
|
|
147
|
-
* @category Definers
|
|
148
|
-
* @expandType BlueprintQueueFunctionConfig
|
|
149
|
-
* @param functionConfig The configuration for the queue function
|
|
150
|
-
* @returns The validated queue function resource
|
|
151
|
-
*/
|
|
152
|
-
export declare function defineQueueFunction(functionConfig: BlueprintQueueFunctionConfig): BlueprintQueueFunctionResource;
|
|
153
|
-
/**
|
|
154
|
-
* Defines a function that provide event behaviour.
|
|
155
|
-
*
|
|
156
|
-
* @remarks
|
|
157
|
-
* A barebones event function
|
|
158
|
-
* ```ts
|
|
159
|
-
* defineEventFunction({
|
|
160
|
-
* name: 'send-email',
|
|
161
|
-
* })
|
|
162
|
-
* ```
|
|
163
|
-
* @public
|
|
164
|
-
* @alpha Deploying Event Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
165
|
-
* @hidden
|
|
166
|
-
* @category Definers
|
|
167
|
-
* @expandType BlueprintEventFunctionConfig
|
|
168
|
-
* @param functionConfig The configuration for the event function
|
|
169
|
-
* @returns The validated event function resource
|
|
170
|
-
*/
|
|
171
|
-
export declare function defineEventFunction(functionConfig: BlueprintEventFunctionConfig): BlueprintEventFunctionResource;
|
|
172
|
-
/**
|
|
173
|
-
* Defines a base function resource with common properties.
|
|
174
|
-
*
|
|
175
|
-
* @param functionConfig The configuration for the function
|
|
176
|
-
* @param options Optional configuration including validation options
|
|
177
|
-
* @category Definers
|
|
178
|
-
* @internal
|
|
179
|
-
* @expandType BlueprintBaseFunctionConfig
|
|
180
|
-
* @returns The validated function resource
|
|
181
|
-
*/
|
|
182
|
-
export declare function defineFunction(functionConfig: BlueprintBaseFunctionConfig, options?: {
|
|
183
|
-
skipValidation?: boolean;
|
|
184
|
-
scopeType?: 'organization';
|
|
185
|
-
}): BlueprintBaseFunctionResource;
|
|
186
|
-
/**
|
|
187
|
-
* Defines a pipeline function resource.
|
|
188
|
-
*
|
|
189
|
-
* @remarks
|
|
190
|
-
*
|
|
191
|
-
* ```ts
|
|
192
|
-
* definePipeline({
|
|
193
|
-
* name: 'daily-cleanup',
|
|
194
|
-
* event: {type: 'document', on: ['create'], filter: "_type == 'post'"},
|
|
195
|
-
* concurrency: 5,
|
|
196
|
-
* debounce: 10,
|
|
197
|
-
* debounceKey: 'document._id',
|
|
198
|
-
* })
|
|
199
|
-
* ```
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* @param functionConfig The configuration for the function
|
|
203
|
-
* @category Definers
|
|
204
|
-
* @alpha Deploying Pipeline Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
205
|
-
* @public
|
|
206
|
-
* @hidden
|
|
207
|
-
* @expandType BlueprintPipelineConfig
|
|
208
|
-
* @returns The validated pipeline function resource
|
|
209
|
-
*/
|
|
210
|
-
export declare function definePipeline(functionConfig: BlueprintPipelineConfig): BlueprintPipelineResource;
|