Skip to content

Commit 4c60ff8

Browse files
committed
fix: add queue props to output BlueprintQueueFunctionResource type
also DRY the queue props up for reuse
1 parent b90dfda commit 4c60ff8

1 file changed

Lines changed: 63 additions & 42 deletions

File tree

src/types/functions/index.ts

Lines changed: 63 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const VALID_RUNTIMES = ['node', 'nodejs22.x', 'nodejs24.x'] as const
2222
*/
2323
export type FunctionRuntimes = (typeof VALID_RUNTIMES)[number]
2424

25-
// --- Main Function Types ---
25+
// --- Function Resource (Output) Types: `define*Function` method return types ---
2626

2727
/**
2828
* Base function resource with common properties for all function types
@@ -49,6 +49,44 @@ interface BlueprintCommonFunctionResource extends BlueprintResource {
4949
runtime?: FunctionRuntimes
5050
}
5151

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+
5290
/**
5391
* Base function resource with common properties for all function types that can belong to projects.
5492
* @category Functions Types
@@ -122,7 +160,20 @@ export interface BlueprintEventFunctionResource extends BlueprintBaseFunctionRes
122160
type: 'sanity.function.event'
123161
}
124162

125-
// --- 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 ---
126177

127178
/**
128179
* Configuration for defining a base function.
@@ -215,20 +266,17 @@ export type BlueprintSyncTagInvalidateFunctionConfig = Omit<BlueprintSyncTagInva
215266
* @category Functions Types
216267
* @interface
217268
*/
218-
export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event'> & {
219-
/**
220-
* Path to the function source code
221-
* @defaultValue `functions/${name}`
222-
*/
223-
src?: string
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
227276

228-
concurrency?: number
229-
fifo?: boolean
230-
dlq?: boolean
231-
}
277+
/** Optional event configuration that triggers the queue function */
278+
event?: BlueprintFunctionResourceEvent
279+
}
232280

233281
/**
234282
* Configuration for defining an event function.
@@ -246,33 +294,6 @@ export type BlueprintEventFunctionConfig = Omit<BlueprintEventFunctionResource,
246294
src?: string
247295
}
248296

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-
276297
/**
277298
* Configuration for defining a pipeline function.
278299
* @public

0 commit comments

Comments
 (0)