@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
@@ -0,0 +1,112 @@
1
+ import {
2
+ type BlueprintScheduledFunctionConfig,
3
+ type BlueprintScheduledFunctionConfigEvent,
4
+ type BlueprintScheduledFunctionExplicitResourceEvent,
5
+ type BlueprintScheduledFunctionExpressionResourceEvent,
6
+ type BlueprintScheduledFunctionResource,
7
+ type BlueprintScheduledFunctionResourceEvent,
8
+ validateScheduledFunction,
9
+ } from '../../index.js'
10
+ import {parseScheduledExpression} from '../../utils/schedule-parser.js'
11
+ import {runValidation} from '../../utils/validation.js'
12
+ import {defineFunction} from './index.js'
13
+
14
+ type ScheduledFunctionEventKey =
15
+ | keyof BlueprintScheduledFunctionExplicitResourceEvent
16
+ | keyof BlueprintScheduledFunctionExpressionResourceEvent
17
+ const SCHEDULED_EVENT_KEYS = new Set<ScheduledFunctionEventKey>(['minute', 'hour', 'dayOfWeek', 'month', 'dayOfMonth', 'expression'])
18
+
19
+ /**
20
+ * Defines a function that is triggered on a schedule.
21
+ * Supports cron expressions or natural language schedules.
22
+ *
23
+ * @remarks
24
+ * Using a cron expression:
25
+ * ```ts
26
+ * defineScheduledFunction({
27
+ * name: 'daily-cleanup',
28
+ * event: {expression: '0 9 * * *'},
29
+ * })
30
+ * ```
31
+ *
32
+ * Using explicit cron fields:
33
+ * ```ts
34
+ * defineScheduledFunction({
35
+ * name: 'daily-cleanup',
36
+ * event: {minute: '0', hour: '9', dayOfMonth: '*', month: '*', dayOfWeek: '*'},
37
+ * })
38
+ * ```
39
+ *
40
+ * The `event.expression` field accepts standard cron expressions or natural language:
41
+ * `'every 15 minutes'`, `'weekdays at 8am'`, `'fridays in the evening'`,
42
+ * `'mon, wed, fri at 9am'`, `'first of the month at noon'`
43
+ *
44
+ * ```ts
45
+ * defineScheduledFunction({
46
+ * name: 'daily-cleanup',
47
+ * event: {expression: 'every day at 9am'},
48
+ * })
49
+ * ```
50
+ * @public
51
+ * @alpha Deploying Scheduled Functions via Blueprints is experimental. This feature is not available publicly yet.
52
+ * @hidden
53
+ * @category Definers
54
+ * @expandType BlueprintScheduledFunctionConfig
55
+ * @param functionConfig The configuration for the scheduled function
56
+ * @returns The validated scheduled function resource
57
+ */
58
+ export function defineScheduledFunction(functionConfig: BlueprintScheduledFunctionConfig): BlueprintScheduledFunctionResource {
59
+ const {event, timezone} = functionConfig
60
+
61
+ const functionResource: BlueprintScheduledFunctionResource = {
62
+ ...defineFunction(functionConfig, {skipValidation: true, scopeType: 'organization'}),
63
+ type: 'sanity.function.cron',
64
+ event: buildScheduledFunctionEvent(event),
65
+ }
66
+
67
+ if (timezone) functionResource.timezone = timezone
68
+
69
+ // Always normalize to explicit fields (minute, hour, dayOfWeek, month, dayOfMonth)
70
+ if ('expression' in functionResource.event && typeof functionResource.event.expression === 'string') {
71
+ const cron = parseScheduledExpression(functionResource.event.expression)
72
+ functionResource.event = cronStringToExplicitEvent(cron)
73
+ }
74
+
75
+ runValidation(() => validateScheduledFunction(functionResource))
76
+
77
+ return functionResource
78
+ }
79
+
80
+ /**
81
+ * @deprecated Define scheduled functions using `defineScheduledFunction` instead
82
+ * @hidden
83
+ */
84
+ export function defineScheduleFunction(functionConfig: BlueprintScheduledFunctionConfig): BlueprintScheduledFunctionResource {
85
+ return defineScheduledFunction(functionConfig)
86
+ }
87
+
88
+ /**
89
+ * Builds a scheduled function event configuration.
90
+ * Filters out non-event properties. Does not parse expressions.
91
+ * @param event Scheduled function event configuration
92
+ * @returns Cleaned scheduled function event configuration
93
+ */
94
+ function buildScheduledFunctionEvent(event: BlueprintScheduledFunctionConfigEvent): BlueprintScheduledFunctionResourceEvent {
95
+ return Object.fromEntries(
96
+ Object.entries(event).filter(([key]) => SCHEDULED_EVENT_KEYS.has(key as ScheduledFunctionEventKey)),
97
+ ) as BlueprintScheduledFunctionResourceEvent
98
+ }
99
+
100
+ /**
101
+ * Converts a cron expression string (minute hour dayOfMonth month dayOfWeek) to explicit event fields.
102
+ * @param cron Cron string with five space-separated fields
103
+ * @returns Explicit scheduled event with minute, hour, dayOfMonth, month, dayOfWeek
104
+ */
105
+ function cronStringToExplicitEvent(cron: string): BlueprintScheduledFunctionExplicitResourceEvent {
106
+ const parts = cron.trim().split(/\s+/)
107
+ if (parts.length !== 5) {
108
+ throw new Error(`Invalid cron string: expected 5 fields, got ${parts.length}`)
109
+ }
110
+ const [minute, hour, dayOfMonth, month, dayOfWeek] = parts
111
+ return {minute, hour, dayOfMonth, month, dayOfWeek}
112
+ }
@@ -0,0 +1,51 @@
1
+ import {
2
+ type BlueprintSyncTagInvalidateFunctionConfig,
3
+ type BlueprintSyncTagInvalidateFunctionResource,
4
+ validateSyncTagInvalidateFunction,
5
+ } from '../../index.js'
6
+ import {runValidation} from '../../utils/validation.js'
7
+ import {defineFunction} from './index.js'
8
+ /**
9
+ * Defines a function that is triggered on a sync tag invalidate event.
10
+ *
11
+ * @remarks
12
+ * Using implicit event scoping to all datasets in the function project:
13
+ * ```ts
14
+ * defineSyncTagInvalidateFunction({
15
+ * name: 'bustin-caches',
16
+ * })
17
+ * ```
18
+ *
19
+ * Using explicit event scoping to a particular dataset in the function project:
20
+ * ```ts
21
+ * defineSyncTagInvalidateFunction({
22
+ * name: 'bustin-caches',
23
+ * event: {
24
+ * resource: {
25
+ * type: 'dataset',
26
+ * id: 'myProj.myDataset',
27
+ * },
28
+ * },
29
+ * })
30
+ * ```
31
+ * @public
32
+ * @category Definers
33
+ * @expandType BlueprintSyncTagInvalidateFunctionConfig
34
+ * @param functionConfig The configuration for the sync tag invalidate function
35
+ * @returns The validated sync tag invalidate function resource
36
+ */
37
+ export function defineSyncTagInvalidateFunction(
38
+ functionConfig: BlueprintSyncTagInvalidateFunctionConfig,
39
+ ): BlueprintSyncTagInvalidateFunctionResource {
40
+ const {event} = functionConfig
41
+
42
+ const functionResource: BlueprintSyncTagInvalidateFunctionResource = {
43
+ ...defineFunction(functionConfig, {skipValidation: true}),
44
+ type: 'sanity.function.sync-tag-invalidate',
45
+ ...(event?.resource ? {event} : {}),
46
+ }
47
+
48
+ runValidation(() => validateSyncTagInvalidateFunction(functionResource))
49
+
50
+ return functionResource
51
+ }
@@ -0,0 +1,34 @@
1
+ import {validateStudio} from '../index.js'
2
+ import type {BlueprintStudioConfig, BlueprintStudioResource} from '../types/studios.js'
3
+ import {runValidation} from '../utils/validation.js'
4
+
5
+ /**
6
+ * Defines a studio.
7
+ *
8
+ * ```ts
9
+ * defineStudio({
10
+ * name: 'my-studio',
11
+ * src: 'studios/my-studio',
12
+ * autoUpdates: {
13
+ * enabled: true
14
+ * }
15
+ * })
16
+ * ```
17
+ * @param parameters The studio configuration
18
+ * @public
19
+ * @beta Deploying Studios via Blueprints is experimental. This may be subject to breaking changes.
20
+ * @category Definers
21
+ * @expandType BlueprintStudioConfig
22
+ * @returns The studio resource
23
+ * @hidden
24
+ */
25
+ export function defineStudio(config: BlueprintStudioConfig): BlueprintStudioResource {
26
+ const studioResource: BlueprintStudioResource = {
27
+ ...config,
28
+ type: 'sanity.studio',
29
+ }
30
+
31
+ runValidation(() => validateStudio(studioResource))
32
+
33
+ return studioResource
34
+ }
package/src/index.ts CHANGED
@@ -10,12 +10,20 @@
10
10
  export * from './definers/blueprints.js'
11
11
  export * from './definers/cors.js'
12
12
  export * from './definers/datasets.js'
13
- export * from './definers/functions.js'
13
+ export * from './definers/functions/document.js'
14
+ export * from './definers/functions/event.js'
15
+ export * from './definers/functions/index.js'
16
+ export * from './definers/functions/media-library.js'
17
+ export * from './definers/functions/pipeline.js'
18
+ export * from './definers/functions/queue.js'
19
+ export * from './definers/functions/scheduled.js'
20
+ export * from './definers/functions/sync-tag-invalidate.js'
14
21
  export * from './definers/projects.js'
15
22
  export * from './definers/resources.js'
16
23
  export * from './definers/robots.js'
17
24
  export * from './definers/robotTokens.js'
18
25
  export * from './definers/roles.js'
26
+ export * from './definers/studios.js'
19
27
  export * from './definers/webhooks.js'
20
28
 
21
29
  // TYPES - base types for all resources
@@ -37,6 +45,7 @@ export * from './types/resources.js'
37
45
  export * from './types/robots.js'
38
46
  export * from './types/robotTokens.js'
39
47
  export * from './types/roles.js'
48
+ export * from './types/studios.js'
40
49
  export * from './types/webhooks.js'
41
50
 
42
51
  // VALIDATION - validation for all resources
@@ -53,6 +62,7 @@ export * from './validation/resources.js'
53
62
  export * from './validation/robots.js'
54
63
  export * from './validation/robotTokens.js'
55
64
  export * from './validation/roles.js'
65
+ export * from './validation/studios.js'
56
66
  export * from './validation/webhooks.js'
57
67
 
58
68
  // Public BLUEPRINTS INTERNALS - published bucket of misc Blueprint types
@@ -83,34 +83,15 @@ export type BlueprintScheduledFunctionConfigEvent =
83
83
  | BlueprintScheduledFunctionExplicitResourceEvent
84
84
  | BlueprintScheduledFunctionExpressionResourceEvent
85
85
 
86
- /**
87
- * Event configuration for queue functions
88
- * @category Functions Types
89
- * @alpha
90
- * @hidden
91
- */
92
- export interface BlueprintQueueFunctionResourceEvent {
93
- concurrency?: number
94
- fifo?: boolean
95
- dlq?: boolean
96
- }
97
-
98
- /**
99
- * Union type of all queue function resource event configurations
100
- * @category Functions Types
101
- */
102
- export type BlueprintQueueFunctionConfigEvent = true | BlueprintQueueFunctionResourceEvent
103
-
104
86
  /**
105
87
  * Union type of all function resource event configurations
106
88
  * @category Functions Types
107
89
  */
108
90
  export type BlueprintFunctionResourceEvent =
109
- | BlueprintDocumentFunctionResourceEvent
110
- | BlueprintMediaLibraryFunctionResourceEvent
111
- | BlueprintQueueFunctionResourceEvent
112
- | BlueprintScheduledFunctionResourceEvent
113
- | BlueprintSyncTagInvalidateFunctionResourceEvent
91
+ | ({type: 'document'} & BlueprintDocumentFunctionResourceEvent)
92
+ | ({type: 'media-library'} & BlueprintMediaLibraryFunctionResourceEvent)
93
+ | ({type: 'cron'} & BlueprintScheduledFunctionResourceEvent)
94
+ | ({type: 'sync-tag-invalidate'} & BlueprintSyncTagInvalidateFunctionResourceEvent)
114
95
 
115
96
  /**
116
97
  * Dataset resource for scoping document functions to specific datasets
@@ -137,11 +118,3 @@ export interface BlueprintFunctionResourceEventResourceMediaLibrary {
137
118
  * @category Functions Types
138
119
  */
139
120
  export type BlueprintFunctionResourceEventName = 'publish' | 'create' | 'delete' | 'update'
140
-
141
- /**
142
- * Event configuration for workflows.
143
- * @category Functions Types
144
- */
145
- export type BlueprintWorkflowFunctionResourceEvent =
146
- | ({type: 'document'} & BlueprintDocumentFunctionResourceEvent)
147
- | ({type: 'sync-tag-invalidate'} & BlueprintSyncTagInvalidateFunctionResourceEvent)
@@ -1,13 +1,11 @@
1
1
  import type {BlueprintResource} from '../../index.js'
2
2
  import type {
3
3
  BlueprintDocumentFunctionResourceEvent,
4
+ BlueprintFunctionResourceEvent,
4
5
  BlueprintMediaLibraryFunctionResourceEvent,
5
- BlueprintQueueFunctionConfigEvent,
6
- BlueprintQueueFunctionResourceEvent,
7
6
  BlueprintScheduledFunctionConfigEvent,
8
7
  BlueprintScheduledFunctionResourceEvent,
9
8
  BlueprintSyncTagInvalidateFunctionResourceEvent,
10
- BlueprintWorkflowFunctionResourceEvent,
11
9
  } from './event.js'
12
10
  import type {IanaTimezone} from './timezone.js'
13
11
 
@@ -24,7 +22,7 @@ export const VALID_RUNTIMES = ['node', 'nodejs22.x', 'nodejs24.x'] as const
24
22
  */
25
23
  export type FunctionRuntimes = (typeof VALID_RUNTIMES)[number]
26
24
 
27
- // --- Main Function Types ---
25
+ // --- Function Resource (Output) Types: `define*Function` method return types ---
28
26
 
29
27
  /**
30
28
  * Base function resource with common properties for all function types
@@ -51,6 +49,44 @@ interface BlueprintCommonFunctionResource extends BlueprintResource {
51
49
  runtime?: FunctionRuntimes
52
50
  }
53
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
+
54
90
  /**
55
91
  * Base function resource with common properties for all function types that can belong to projects.
56
92
  * @category Functions Types
@@ -108,9 +144,10 @@ export interface BlueprintSyncTagInvalidateFunctionResource extends BlueprintBas
108
144
  * @alpha
109
145
  * @hidden
110
146
  */
111
- export interface BlueprintQueueFunctionResource extends BlueprintBaseFunctionResource {
147
+ export interface BlueprintQueueFunctionResource extends BlueprintBaseFunctionResource, QueueConfig {
112
148
  type: 'sanity.function.queue'
113
- event?: BlueprintQueueFunctionResourceEvent
149
+ /** Optional event configuration that triggers the function */
150
+ event?: BlueprintFunctionResourceEvent
114
151
  }
115
152
 
116
153
  /**
@@ -123,7 +160,20 @@ export interface BlueprintEventFunctionResource extends BlueprintBaseFunctionRes
123
160
  type: 'sanity.function.event'
124
161
  }
125
162
 
126
- // --- Function Config Types ---
163
+ /**
164
+ * A durable, step-based pipeline function.
165
+ * @public
166
+ * @alpha Deploying Pipeline Functions via Blueprints is experimental. This feature is not available publicly yet.
167
+ * @hidden
168
+ * @category Functions Types
169
+ * @interface
170
+ */
171
+ export interface BlueprintPipelineResource extends BlueprintBaseFunctionResource, QueueConfig {
172
+ type: 'sanity.function.pipeline'
173
+ event?: BlueprintFunctionResourceEvent
174
+ }
175
+
176
+ // --- Function Config (Input) Types: : `define*Function` method parameter types ---
127
177
 
128
178
  /**
129
179
  * Configuration for defining a base function.
@@ -216,29 +266,22 @@ export type BlueprintSyncTagInvalidateFunctionConfig = Omit<BlueprintSyncTagInva
216
266
  * @category Functions Types
217
267
  * @interface
218
268
  */
219
- export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event'> & {
220
- /**
221
- * Path to the function source code
222
- * @defaultValue `functions/${name}`
223
- */
224
- src?: string
225
- /**
226
- * Queue configuration.
227
- *
228
- * Omit this property or set it to `true` to use the defaults:
229
- * concurrency: 1, fifo: true, dlq: true.
230
- *
231
- * Provide an object to override specific settings.
232
- *
233
- * @defaultValue true
234
- */
235
- queue?: BlueprintQueueFunctionConfigEvent
236
- }
269
+ export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event'> &
270
+ QueueConfig & {
271
+ /**
272
+ * Path to the function source code
273
+ * @defaultValue `functions/${name}`
274
+ */
275
+ src?: string
276
+
277
+ /** Optional event configuration that triggers the queue function */
278
+ event?: BlueprintFunctionResourceEvent
279
+ }
237
280
 
238
281
  /**
239
282
  * Configuration for defining an event function.
240
283
  * @public
241
- * @alpha Deploying Queue Functions via Blueprints is experimental. This feature is not available publicly yet.
284
+ * @alpha Deploying Event Functions via Blueprints is experimental. This feature is not available publicly yet.
242
285
  * @hidden
243
286
  * @category Functions Types
244
287
  * @interface
@@ -252,46 +295,21 @@ export type BlueprintEventFunctionConfig = Omit<BlueprintEventFunctionResource,
252
295
  }
253
296
 
254
297
  /**
255
- * A durable, step-based workflow function.
256
- * @public
257
- * @alpha Deploying Workflows via Blueprints is experimental. This feature is not available publicly yet.
258
- * @hidden
259
- * @category Functions Types
260
- * @interface
261
- */
262
- export interface BlueprintWorkflowFunctionResource extends BlueprintBaseFunctionResource {
263
- type: 'sanity.function.workflow'
264
- event: BlueprintWorkflowFunctionResourceEvent
265
- /**
266
- * Max concurrent executions
267
- */
268
- concurrency?: number
269
- /**
270
- * Debounce window in minutes
271
- */
272
- debounce?: number
273
- /**
274
- * Path used to group debounced events, e.g. 'document._id'
275
- */
276
- debounceKey?: string
277
- }
278
-
279
- /**
280
- * Configuration for defining a workflow function.
298
+ * Configuration for defining a pipeline function.
281
299
  * @public
282
- * @alpha Deploying Workflows via Blueprints is experimental.
300
+ * @alpha Deploying Pipeline Functions via Blueprints is experimental. This feature is not available publicly yet.
283
301
  * @hidden
284
302
  * @category Functions Types
285
303
  * @interface
286
304
  */
287
- export type BlueprintWorkflowFunctionConfig = Omit<BlueprintWorkflowFunctionResource, 'type' | 'src' | 'event'> & {
305
+ export type BlueprintPipelineConfig = Omit<BlueprintPipelineResource, 'type' | 'src' | 'event'> & {
288
306
  /**
289
- * Path to the workflow source code
290
- * @defaultValue `workflows/${name}`
307
+ * Path to the pipeline source code
308
+ * @defaultValue `functions/${name}`
291
309
  */
292
310
  src?: string
293
311
  /**
294
312
  * Trigger configuration
295
313
  */
296
- event: BlueprintWorkflowFunctionResourceEvent
314
+ event?: BlueprintFunctionResourceEvent
297
315
  }
@@ -0,0 +1,68 @@
1
+ import type {ConfigEnv, InlineConfig} from 'vite'
2
+ import type {BlueprintProjectResourceLifecycle, BlueprintResource} from '../index.js'
3
+
4
+ /**
5
+ * Custom Vite configuration for the Studio so it can be changed and extended.
6
+ * This type matches the type in @sanity/cli-core and must continue to remain compatible.
7
+ * @beta This feature is subject to breaking changes.
8
+ * @category Resource Types
9
+ * @hidden
10
+ */
11
+ export type UserViteConfig = ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>) | InlineConfig
12
+
13
+ /**
14
+ * Represents a Studio resource.
15
+ * @see https://www.sanity.io/docs/studio
16
+ * @beta This feature is subject to breaking changes.
17
+ * @category Resource Types
18
+ * @hidden
19
+ */
20
+ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
21
+ type: 'sanity.studio'
22
+
23
+ /** The relative location of the studio source code. */
24
+ src: string
25
+
26
+ /**
27
+ * Auto update settings for the studio.
28
+ */
29
+ autoUpdates: {
30
+ /** Whether auto updates are enabled for the studio */
31
+ enabled: boolean
32
+
33
+ /** What "version"/"channel" to use for auto updates */
34
+ version?: string // 'next', 'stable', 'latest' or a semantic version (e.g., "1.2.3", "2.0.0-beta.1")
35
+ }
36
+
37
+ /** The base path of the studio URL. Defaults to '/' */
38
+ basePath?: string
39
+
40
+ /** Whether or not to minify the source code. Defaults to true. */
41
+ minify?: boolean
42
+
43
+ /** Whether or not to configure the reactCompiler. Defaults to false. */
44
+ reactCompiler?: boolean
45
+
46
+ /** Whether or not to generate source maps. Defaults to false. */
47
+ sourceMap?: boolean
48
+
49
+ /** Custom Vite configuration for the Studio so it can be changed and extended. */
50
+ 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
+ }
59
+
60
+ /**
61
+ * Configuration for a Studio resource.
62
+ * @see https://www.sanity.io/docs/studio
63
+ * @beta This feature is subject to breaking changes.
64
+ * @category Resource Types
65
+ * @interface
66
+ * @hidden
67
+ */
68
+ export interface BlueprintStudioConfig extends Omit<BlueprintStudioResource, 'type'> {}