@sanity/blueprints 0.23.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.
- 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/event.d.ts +20 -0
- package/dist/definers/functions/event.js +30 -0
- package/dist/definers/functions/event.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/pipeline.d.ts +26 -0
- package/dist/definers/functions/pipeline.js +41 -0
- package/dist/definers/functions/pipeline.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/index.d.ts +8 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/types/functions/index.d.ts +51 -31
- 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/event.ts +32 -0
- package/src/definers/functions/index.ts +39 -0
- package/src/definers/functions/media-library.ts +98 -0
- package/src/definers/functions/pipeline.ts +42 -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/index.ts +8 -1
- package/src/types/functions/index.ts +64 -43
- 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
|
@@ -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
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,14 @@
|
|
|
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'
|
|
@@ -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,7 +144,7 @@ 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
149
|
/** Optional event configuration that triggers the function */
|
|
112
150
|
event?: BlueprintFunctionResourceEvent
|
|
@@ -122,7 +160,20 @@ export interface BlueprintEventFunctionResource extends BlueprintBaseFunctionRes
|
|
|
122
160
|
type: 'sanity.function.event'
|
|
123
161
|
}
|
|
124
162
|
|
|
125
|
-
|
|
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 ---
|
|
126
177
|
|
|
127
178
|
/**
|
|
128
179
|
* Configuration for defining a base function.
|
|
@@ -215,20 +266,17 @@ export type BlueprintSyncTagInvalidateFunctionConfig = Omit<BlueprintSyncTagInva
|
|
|
215
266
|
* @category Functions Types
|
|
216
267
|
* @interface
|
|
217
268
|
*/
|
|
218
|
-
export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event'> &
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
/** Optional event configuration that triggers the queue function */
|
|
226
|
-
event?: BlueprintFunctionResourceEvent
|
|
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
|
|
227
276
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
277
|
+
/** Optional event configuration that triggers the queue function */
|
|
278
|
+
event?: BlueprintFunctionResourceEvent
|
|
279
|
+
}
|
|
232
280
|
|
|
233
281
|
/**
|
|
234
282
|
* Configuration for defining an event function.
|
|
@@ -246,33 +294,6 @@ export type BlueprintEventFunctionConfig = Omit<BlueprintEventFunctionResource,
|
|
|
246
294
|
src?: string
|
|
247
295
|
}
|
|
248
296
|
|
|
249
|
-
/**
|
|
250
|
-
* A durable, step-based pipeline function.
|
|
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
297
|
/**
|
|
277
298
|
* Configuration for defining a pipeline function.
|
|
278
299
|
* @public
|
|
@@ -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;
|