@vercel/queue 0.0.0-alpha.33 → 0.0.0-alpha.35
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/README.md +286 -85
- package/dist/index.d.mts +203 -127
- package/dist/index.d.ts +203 -127
- package/dist/index.js +680 -453
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +665 -453
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs-pages.d.mts +1 -1
- package/dist/nextjs-pages.d.ts +1 -1
- package/dist/nextjs-pages.js +673 -474
- package/dist/nextjs-pages.js.map +1 -1
- package/dist/nextjs-pages.mjs +663 -474
- package/dist/nextjs-pages.mjs.map +1 -1
- package/dist/types-BLG4ASI_.d.mts +504 -0
- package/dist/types-BLG4ASI_.d.ts +504 -0
- package/package.json +2 -6
- package/bin/local-discover.js +0 -196
- package/dist/types-Dw29Fr9y.d.mts +0 -380
- package/dist/types-Dw29Fr9y.d.ts +0 -380
package/dist/index.d.mts
CHANGED
|
@@ -1,95 +1,123 @@
|
|
|
1
|
-
import { Q as QueueClientOptions, S as SendMessageOptions, T as Transport, a as SendMessageResponse, R as ReceiveMessagesOptions, M as Message, b as ReceiveMessageByIdOptions, c as ReceiveMessageByIdResponse, D as DeleteMessageOptions, d as DeleteMessageResponse, C as ChangeVisibilityOptions, e as ChangeVisibilityResponse, f as MessageHandler, P as PublishOptions, g as ConsumerGroupOptions } from './types-
|
|
2
|
-
export { i as BadRequestError, B as BufferTransport, F as ForbiddenError, I as InternalServerError,
|
|
1
|
+
import { Q as QueueClientOptions, S as SendMessageOptions, T as Transport, a as SendMessageResponse, R as ReceiveMessagesOptions, M as Message, b as ReceiveMessageByIdOptions, c as ReceiveMessageByIdResponse, D as DeleteMessageOptions, d as DeleteMessageResponse, C as ChangeVisibilityOptions, e as ChangeVisibilityResponse, f as MessageHandler, P as PublishOptions, g as ConsumerGroupOptions } from './types-BLG4ASI_.mjs';
|
|
2
|
+
export { i as BadRequestError, B as BufferTransport, j as ConcurrencyLimitError, k as ConsumerDiscoveryError, l as ConsumerRegistryNotConfiguredError, m as DuplicateMessageError, F as ForbiddenError, I as InternalServerError, n as InvalidLimitError, J as JsonTransport, o as MessageAlreadyProcessedError, p as MessageCorruptedError, q as MessageLockedError, u as MessageMetadata, r as MessageNotAvailableError, s as MessageNotFoundError, t as QueueEmptyError, h as StreamTransport, U as UnauthorizedError } from './types-BLG4ASI_.mjs';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Internal client for interacting with the Vercel Queue Service API
|
|
6
|
-
* Use Client for the public-facing wrapper with send/handleCallback methods
|
|
7
|
-
*/
|
|
8
4
|
declare class QueueClient {
|
|
9
5
|
private baseUrl;
|
|
10
6
|
private basePath;
|
|
11
7
|
private customHeaders;
|
|
12
8
|
private providedToken?;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* @param options QueueClient configuration options
|
|
16
|
-
*/
|
|
9
|
+
private defaultDeploymentId?;
|
|
10
|
+
private pinToDeployment;
|
|
17
11
|
constructor(options?: QueueClientOptions);
|
|
12
|
+
private getSendDeploymentId;
|
|
13
|
+
private getConsumeDeploymentId;
|
|
18
14
|
private getToken;
|
|
19
|
-
|
|
20
|
-
* Internal fetch wrapper that automatically handles debug logging
|
|
21
|
-
* when VERCEL_QUEUE_DEBUG is enabled
|
|
22
|
-
*/
|
|
15
|
+
private buildUrl;
|
|
23
16
|
private fetch;
|
|
24
17
|
/**
|
|
25
|
-
* Send a message to a
|
|
26
|
-
*
|
|
27
|
-
* @param
|
|
28
|
-
* @
|
|
29
|
-
* @
|
|
18
|
+
* Send a message to a topic.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Message options including queue name, payload, and optional settings
|
|
21
|
+
* @param options.queueName - Topic name (pattern: `[A-Za-z0-9_-]+`)
|
|
22
|
+
* @param options.payload - Message payload
|
|
23
|
+
* @param options.idempotencyKey - Optional deduplication key (dedup window: min(retention, 24h))
|
|
24
|
+
* @param options.retentionSeconds - Message TTL (default: 86400, min: 60, max: 86400)
|
|
25
|
+
* @param options.delaySeconds - Delivery delay (default: 0, max: retentionSeconds)
|
|
26
|
+
* @param transport - Serializer for the payload
|
|
27
|
+
* @returns Promise with the generated messageId
|
|
28
|
+
* @throws {DuplicateMessageError} When idempotency key was already used
|
|
29
|
+
* @throws {ConsumerDiscoveryError} When consumer discovery fails
|
|
30
|
+
* @throws {ConsumerRegistryNotConfiguredError} When registry not configured
|
|
31
|
+
* @throws {BadRequestError} When parameters are invalid
|
|
30
32
|
* @throws {UnauthorizedError} When authentication fails
|
|
31
|
-
* @throws {ForbiddenError} When access is denied
|
|
33
|
+
* @throws {ForbiddenError} When access is denied
|
|
32
34
|
* @throws {InternalServerError} When server encounters an error
|
|
33
35
|
*/
|
|
34
36
|
sendMessage<T = unknown>(options: SendMessageOptions<T>, transport: Transport<T>): Promise<SendMessageResponse>;
|
|
35
37
|
/**
|
|
36
|
-
* Receive messages from a
|
|
37
|
-
*
|
|
38
|
-
* @param
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
42
|
-
* @
|
|
43
|
-
* @
|
|
38
|
+
* Receive messages from a topic as an async generator.
|
|
39
|
+
*
|
|
40
|
+
* @param options - Receive options
|
|
41
|
+
* @param options.queueName - Topic name (pattern: `[A-Za-z0-9_-]+`)
|
|
42
|
+
* @param options.consumerGroup - Consumer group name (pattern: `[A-Za-z0-9_-]+`)
|
|
43
|
+
* @param options.visibilityTimeoutSeconds - Lock duration (default: 30, min: 0, max: 3600)
|
|
44
|
+
* @param options.limit - Max messages to retrieve (default: 1, min: 1, max: 10)
|
|
45
|
+
* @param options.maxConcurrency - Max in-flight messages (default: unlimited, min: 1)
|
|
46
|
+
* @param transport - Deserializer for message payloads
|
|
47
|
+
* @yields Message objects with payload, messageId, receiptHandle, etc.
|
|
48
|
+
* @throws {QueueEmptyError} When no messages available
|
|
49
|
+
* @throws {InvalidLimitError} When limit is outside 1-10 range
|
|
50
|
+
* @throws {ConcurrencyLimitError} When maxConcurrency exceeded
|
|
51
|
+
* @throws {BadRequestError} When parameters are invalid
|
|
44
52
|
* @throws {UnauthorizedError} When authentication fails
|
|
45
|
-
* @throws {ForbiddenError} When access is denied
|
|
53
|
+
* @throws {ForbiddenError} When access is denied
|
|
46
54
|
* @throws {InternalServerError} When server encounters an error
|
|
47
55
|
*/
|
|
48
56
|
receiveMessages<T = unknown>(options: ReceiveMessagesOptions<T>, transport: Transport<T>): AsyncGenerator<Message<T>, void, unknown>;
|
|
49
57
|
/**
|
|
50
|
-
* Receive a specific message by its ID
|
|
51
|
-
*
|
|
52
|
-
* @param
|
|
53
|
-
* @
|
|
54
|
-
* @
|
|
55
|
-
* @
|
|
56
|
-
* @
|
|
57
|
-
* @
|
|
58
|
-
* @
|
|
58
|
+
* Receive a specific message by its ID.
|
|
59
|
+
*
|
|
60
|
+
* @param options - Receive options
|
|
61
|
+
* @param options.queueName - Topic name (pattern: `[A-Za-z0-9_-]+`)
|
|
62
|
+
* @param options.consumerGroup - Consumer group name (pattern: `[A-Za-z0-9_-]+`)
|
|
63
|
+
* @param options.messageId - Message ID to retrieve
|
|
64
|
+
* @param options.visibilityTimeoutSeconds - Lock duration (default: 30, min: 0, max: 3600)
|
|
65
|
+
* @param options.maxConcurrency - Max in-flight messages (default: unlimited, min: 1)
|
|
66
|
+
* @param transport - Deserializer for the message payload
|
|
67
|
+
* @returns Promise with the message
|
|
68
|
+
* @throws {MessageNotFoundError} When message doesn't exist
|
|
69
|
+
* @throws {MessageNotAvailableError} When message is in wrong state or was a duplicate
|
|
70
|
+
* @throws {MessageAlreadyProcessedError} When message was already processed
|
|
71
|
+
* @throws {ConcurrencyLimitError} When maxConcurrency exceeded
|
|
72
|
+
* @throws {BadRequestError} When parameters are invalid
|
|
59
73
|
* @throws {UnauthorizedError} When authentication fails
|
|
60
|
-
* @throws {ForbiddenError} When access is denied
|
|
74
|
+
* @throws {ForbiddenError} When access is denied
|
|
61
75
|
* @throws {InternalServerError} When server encounters an error
|
|
62
76
|
*/
|
|
63
|
-
receiveMessageById<T = unknown>(options: ReceiveMessageByIdOptions<T>
|
|
64
|
-
skipPayload: true;
|
|
65
|
-
}, transport?: Transport<T>): Promise<ReceiveMessageByIdResponse<T, true>>;
|
|
66
|
-
receiveMessageById<T = unknown>(options: ReceiveMessageByIdOptions<T> & {
|
|
67
|
-
skipPayload?: false | undefined;
|
|
68
|
-
}, transport: Transport<T>): Promise<ReceiveMessageByIdResponse<T, false>>;
|
|
77
|
+
receiveMessageById<T = unknown>(options: ReceiveMessageByIdOptions<T>, transport: Transport<T>): Promise<ReceiveMessageByIdResponse<T>>;
|
|
69
78
|
/**
|
|
70
|
-
* Delete a message
|
|
71
|
-
*
|
|
72
|
-
* @
|
|
73
|
-
* @
|
|
74
|
-
* @
|
|
75
|
-
* @
|
|
79
|
+
* Delete (acknowledge) a message after successful processing.
|
|
80
|
+
*
|
|
81
|
+
* @param options - Delete options
|
|
82
|
+
* @param options.queueName - Topic name
|
|
83
|
+
* @param options.consumerGroup - Consumer group name
|
|
84
|
+
* @param options.receiptHandle - Receipt handle from the received message (must use same deployment ID as receive)
|
|
85
|
+
* @returns Promise indicating deletion success
|
|
86
|
+
* @throws {MessageNotFoundError} When receipt handle not found
|
|
87
|
+
* @throws {MessageNotAvailableError} When receipt handle invalid or message already processed
|
|
88
|
+
* @throws {BadRequestError} When parameters are invalid
|
|
76
89
|
* @throws {UnauthorizedError} When authentication fails
|
|
77
|
-
* @throws {ForbiddenError} When access is denied
|
|
90
|
+
* @throws {ForbiddenError} When access is denied
|
|
78
91
|
* @throws {InternalServerError} When server encounters an error
|
|
79
92
|
*/
|
|
80
93
|
deleteMessage(options: DeleteMessageOptions): Promise<DeleteMessageResponse>;
|
|
81
94
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* @
|
|
86
|
-
* @
|
|
87
|
-
* @
|
|
95
|
+
* Extend or change the visibility timeout of a message.
|
|
96
|
+
* Used to prevent message redelivery while still processing.
|
|
97
|
+
*
|
|
98
|
+
* @param options - Visibility options
|
|
99
|
+
* @param options.queueName - Topic name
|
|
100
|
+
* @param options.consumerGroup - Consumer group name
|
|
101
|
+
* @param options.receiptHandle - Receipt handle from the received message (must use same deployment ID as receive)
|
|
102
|
+
* @param options.visibilityTimeoutSeconds - New timeout (min: 0, max: 3600, cannot exceed message expiration)
|
|
103
|
+
* @returns Promise indicating success
|
|
104
|
+
* @throws {MessageNotFoundError} When receipt handle not found
|
|
105
|
+
* @throws {MessageNotAvailableError} When receipt handle invalid or message already processed
|
|
106
|
+
* @throws {BadRequestError} When parameters are invalid
|
|
88
107
|
* @throws {UnauthorizedError} When authentication fails
|
|
89
|
-
* @throws {ForbiddenError} When access is denied
|
|
108
|
+
* @throws {ForbiddenError} When access is denied
|
|
90
109
|
* @throws {InternalServerError} When server encounters an error
|
|
91
110
|
*/
|
|
92
111
|
changeVisibility(options: ChangeVisibilityOptions): Promise<ChangeVisibilityResponse>;
|
|
112
|
+
/**
|
|
113
|
+
* Alternative endpoint for changing message visibility timeout.
|
|
114
|
+
* Uses the /visibility path suffix and expects visibilityTimeoutSeconds in the body.
|
|
115
|
+
* Functionally equivalent to changeVisibility but follows an alternative API pattern.
|
|
116
|
+
*
|
|
117
|
+
* @param options - Options for changing visibility
|
|
118
|
+
* @returns Promise resolving to change visibility response
|
|
119
|
+
*/
|
|
120
|
+
changeVisibilityAlt(options: ChangeVisibilityOptions): Promise<ChangeVisibilityResponse>;
|
|
93
121
|
}
|
|
94
122
|
|
|
95
123
|
/**
|
|
@@ -104,6 +132,24 @@ type CallbackHandlers = {
|
|
|
104
132
|
[consumerGroup: string]: MessageHandler;
|
|
105
133
|
};
|
|
106
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* Options for handleCallback.
|
|
137
|
+
*/
|
|
138
|
+
interface HandleCallbackOptions {
|
|
139
|
+
/**
|
|
140
|
+
* QueueClient instance to use for processing messages.
|
|
141
|
+
* If not provided, a default client is created with OIDC authentication.
|
|
142
|
+
*/
|
|
143
|
+
client?: QueueClient;
|
|
144
|
+
/**
|
|
145
|
+
* Time in seconds that messages will be invisible to other consumers during processing.
|
|
146
|
+
* The handler will automatically extend this timeout while processing.
|
|
147
|
+
* @default 30
|
|
148
|
+
* @minimum 0
|
|
149
|
+
* @maximum 3600 (1 hour)
|
|
150
|
+
*/
|
|
151
|
+
visibilityTimeoutSeconds?: number;
|
|
152
|
+
}
|
|
107
153
|
/**
|
|
108
154
|
* Parsed callback request information
|
|
109
155
|
*/
|
|
@@ -141,39 +187,41 @@ type ParsedCallbackRequest = {
|
|
|
141
187
|
*/
|
|
142
188
|
declare function parseCallback(request: Request): Promise<ParsedCallbackRequest>;
|
|
143
189
|
/**
|
|
144
|
-
* Simplified queue callback handler for Next.js route handlers
|
|
190
|
+
* Simplified queue callback handler for Next.js route handlers.
|
|
145
191
|
*
|
|
146
192
|
* Automatically extracts queue information from CloudEvent format
|
|
147
193
|
* and routes to the appropriate handler based on topic and consumer group.
|
|
148
194
|
*
|
|
149
|
-
* @param handlers Object with topic-specific handlers organized by consumer groups
|
|
150
|
-
* @param
|
|
195
|
+
* @param handlers - Object with topic-specific handlers organized by consumer groups
|
|
196
|
+
* @param options - Optional configuration
|
|
197
|
+
* @param options.client - QueueClient instance (default: new client with OIDC auth)
|
|
198
|
+
* @param options.visibilityTimeoutSeconds - Message lock duration (default: 30, max: 3600)
|
|
151
199
|
* @returns A Next.js route handler function
|
|
152
200
|
*
|
|
153
201
|
* @example
|
|
154
202
|
* ```typescript
|
|
155
|
-
* //
|
|
203
|
+
* // Basic usage
|
|
156
204
|
* export const POST = handleCallback({
|
|
157
205
|
* "image-processing": {
|
|
158
|
-
* "compress": (message, metadata) => console.log("Compressing
|
|
159
|
-
* "resize": (message, metadata) => console.log("Resizing
|
|
206
|
+
* "compress": (message, metadata) => console.log("Compressing", message),
|
|
207
|
+
* "resize": (message, metadata) => console.log("Resizing", message),
|
|
160
208
|
* }
|
|
161
209
|
* });
|
|
162
210
|
*
|
|
163
|
-
* //
|
|
211
|
+
* // With custom visibility timeout for long-running handlers
|
|
164
212
|
* export const POST = handleCallback({
|
|
165
|
-
* "
|
|
166
|
-
* "
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* "fulfillment": (order, metadata) => console.log("Fulfilling order", order),
|
|
171
|
-
* "notifications": (order, metadata) => console.log("Notifying order", order),
|
|
213
|
+
* "video-processing": {
|
|
214
|
+
* "transcode": async (video, metadata) => {
|
|
215
|
+
* // Long-running transcoding operation
|
|
216
|
+
* await transcodeVideo(video);
|
|
217
|
+
* },
|
|
172
218
|
* }
|
|
219
|
+
* }, {
|
|
220
|
+
* visibilityTimeoutSeconds: 300, // 5 minutes
|
|
173
221
|
* });
|
|
174
222
|
* ```
|
|
175
223
|
*/
|
|
176
|
-
declare function handleCallback(handlers: CallbackHandlers,
|
|
224
|
+
declare function handleCallback(handlers: CallbackHandlers, options?: HandleCallbackOptions): (request: Request) => Promise<Response>;
|
|
177
225
|
|
|
178
226
|
/**
|
|
179
227
|
* Client - User-facing wrapper for the Vercel Queue Service
|
|
@@ -228,22 +276,35 @@ declare class Client {
|
|
|
228
276
|
messageId: string;
|
|
229
277
|
}>;
|
|
230
278
|
/**
|
|
231
|
-
* Create a callback handler for processing queue messages
|
|
232
|
-
* Returns a Next.js route handler function that routes messages to appropriate handlers
|
|
233
|
-
*
|
|
279
|
+
* Create a callback handler for processing queue messages.
|
|
280
|
+
* Returns a Next.js route handler function that routes messages to appropriate handlers.
|
|
281
|
+
*
|
|
282
|
+
* @param handlers - Object with topic-specific handlers organized by consumer groups
|
|
283
|
+
* @param options - Optional configuration
|
|
284
|
+
* @param options.visibilityTimeoutSeconds - Message lock duration (default: 30, max: 3600)
|
|
234
285
|
* @returns A Next.js route handler function
|
|
235
286
|
*
|
|
236
287
|
* @example
|
|
237
288
|
* ```typescript
|
|
289
|
+
* // Basic usage
|
|
238
290
|
* export const POST = client.handleCallback({
|
|
239
291
|
* "user-events": {
|
|
240
292
|
* "welcome": (user, metadata) => console.log("Welcoming user", user),
|
|
241
293
|
* "analytics": (user, metadata) => console.log("Tracking user", user),
|
|
242
294
|
* },
|
|
243
295
|
* });
|
|
296
|
+
*
|
|
297
|
+
* // With custom visibility timeout
|
|
298
|
+
* export const POST = client.handleCallback({
|
|
299
|
+
* "video-processing": {
|
|
300
|
+
* "transcode": async (video) => await transcodeVideo(video),
|
|
301
|
+
* },
|
|
302
|
+
* }, {
|
|
303
|
+
* visibilityTimeoutSeconds: 300, // 5 minutes for long operations
|
|
304
|
+
* });
|
|
244
305
|
* ```
|
|
245
306
|
*/
|
|
246
|
-
handleCallback(handlers: CallbackHandlers): (request: Request) => Promise<Response>;
|
|
307
|
+
handleCallback(handlers: CallbackHandlers, options?: Omit<HandleCallbackOptions, "client">): (request: Request) => Promise<Response>;
|
|
247
308
|
}
|
|
248
309
|
|
|
249
310
|
/**
|
|
@@ -252,95 +313,110 @@ declare class Client {
|
|
|
252
313
|
interface ConsumeOptions {
|
|
253
314
|
/** The specific message ID to consume (if not provided, consumes next available message) */
|
|
254
315
|
messageId?: string;
|
|
255
|
-
/** Whether to skip downloading the payload (only allowed when messageId is provided) */
|
|
256
|
-
skipPayload?: boolean;
|
|
257
316
|
}
|
|
258
317
|
|
|
259
318
|
/**
|
|
260
|
-
* Options for the send function
|
|
319
|
+
* Options for the send function.
|
|
261
320
|
*/
|
|
262
321
|
interface SendOptions<T = unknown> extends PublishOptions {
|
|
263
322
|
/**
|
|
264
|
-
* Serializer
|
|
265
|
-
* @default JsonTransport
|
|
323
|
+
* Serializer for the payload.
|
|
324
|
+
* @default JsonTransport
|
|
266
325
|
*/
|
|
267
326
|
transport?: Transport<T>;
|
|
268
327
|
/**
|
|
269
|
-
* QueueClient instance to use for sending the message
|
|
270
|
-
* If not provided, a default client is created
|
|
328
|
+
* QueueClient instance to use for sending the message.
|
|
329
|
+
* If not provided, a default client is created with OIDC authentication.
|
|
271
330
|
*/
|
|
272
331
|
client?: QueueClient;
|
|
273
332
|
}
|
|
274
333
|
/**
|
|
275
|
-
* Send a message to a topic
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
* @param
|
|
280
|
-
* @
|
|
281
|
-
* @
|
|
334
|
+
* Send a message to a topic.
|
|
335
|
+
*
|
|
336
|
+
* Uses the default QueueClient with automatic OIDC token detection, or a provided client.
|
|
337
|
+
*
|
|
338
|
+
* @param topicName - Name of the topic (pattern: `[A-Za-z0-9_-]+`)
|
|
339
|
+
* @param payload - The data to send
|
|
340
|
+
* @param options - Optional send options
|
|
341
|
+
* @param options.idempotencyKey - Deduplication key (dedup window: min(retention, 24h))
|
|
342
|
+
* @param options.retentionSeconds - Message TTL (default: 86400, min: 60, max: 86400)
|
|
343
|
+
* @param options.delaySeconds - Delivery delay (default: 0, max: retentionSeconds)
|
|
344
|
+
* @param options.transport - Payload serializer (default: JsonTransport)
|
|
345
|
+
* @param options.client - Custom QueueClient instance
|
|
346
|
+
* @returns Promise with the generated messageId
|
|
347
|
+
* @throws {DuplicateMessageError} When idempotency key was already used
|
|
348
|
+
* @throws {BadRequestError} When parameters are invalid
|
|
282
349
|
* @throws {UnauthorizedError} When authentication fails
|
|
283
|
-
* @throws {ForbiddenError} When access is denied
|
|
350
|
+
* @throws {ForbiddenError} When access is denied
|
|
284
351
|
* @throws {InternalServerError} When server encounters an error
|
|
285
352
|
*
|
|
286
353
|
* @example
|
|
287
354
|
* ```typescript
|
|
288
|
-
* //
|
|
355
|
+
* // Basic usage (OIDC auth)
|
|
289
356
|
* await send("my-topic", { hello: "world" });
|
|
290
357
|
*
|
|
358
|
+
* // With options
|
|
359
|
+
* await send("my-topic", payload, {
|
|
360
|
+
* idempotencyKey: "unique-key",
|
|
361
|
+
* retentionSeconds: 3600, // 1 hour TTL
|
|
362
|
+
* delaySeconds: 60, // Delay 1 minute
|
|
363
|
+
* });
|
|
364
|
+
*
|
|
291
365
|
* // Using custom client
|
|
292
366
|
* const client = new QueueClient({ token: "my-token" });
|
|
293
|
-
* await send("my-topic",
|
|
367
|
+
* await send("my-topic", payload, { client });
|
|
294
368
|
* ```
|
|
295
369
|
*/
|
|
296
370
|
declare function send<T = unknown>(topicName: string, payload: T, options?: SendOptions<T>): Promise<{
|
|
297
371
|
messageId: string;
|
|
298
372
|
}>;
|
|
299
373
|
/**
|
|
300
|
-
* Options for the receive function
|
|
374
|
+
* Options for the receive function.
|
|
301
375
|
*/
|
|
302
376
|
interface ReceiveOptions<T = unknown> extends ConsumerGroupOptions<T>, ConsumeOptions {
|
|
303
377
|
/**
|
|
304
|
-
* QueueClient instance to use for receiving the message
|
|
305
|
-
* If not provided, a default client is created
|
|
378
|
+
* QueueClient instance to use for receiving the message.
|
|
379
|
+
* If not provided, a default client is created with OIDC authentication.
|
|
306
380
|
*/
|
|
307
381
|
client?: QueueClient;
|
|
308
382
|
}
|
|
309
383
|
/**
|
|
310
|
-
* Receive a message from a topic
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
384
|
+
* Receive a message from a topic.
|
|
385
|
+
*
|
|
386
|
+
* Shorthand for creating a topic and consumer group. The message is automatically:
|
|
387
|
+
* - Locked with the configured visibility timeout
|
|
388
|
+
* - Kept alive via periodic visibility extensions during processing
|
|
389
|
+
* - Deleted upon successful handler completion
|
|
390
|
+
*
|
|
391
|
+
* @param topicName - Name of the topic (pattern: `[A-Za-z0-9_-]+`)
|
|
392
|
+
* @param consumerGroup - Name of the consumer group (pattern: `[A-Za-z0-9_-]+`)
|
|
393
|
+
* @param handler - Function to process the message payload and metadata
|
|
394
|
+
* @param options - Optional receive options
|
|
395
|
+
* @param options.visibilityTimeoutSeconds - Message lock duration (default: 30, max: 3600)
|
|
396
|
+
* @param options.visibilityRefreshInterval - Lock refresh interval (default: visibilityTimeout / 3)
|
|
397
|
+
* @param options.transport - Payload deserializer (default: JsonTransport)
|
|
398
|
+
* @returns Promise that resolves when the message is processed and deleted
|
|
399
|
+
* @throws {QueueEmptyError} When no messages available
|
|
400
|
+
* @throws {ConcurrencyLimitError} When maxConcurrency exceeded
|
|
317
401
|
*/
|
|
318
402
|
declare function receive<T = unknown>(topicName: string, consumerGroup: string, handler: MessageHandler<T>, options?: ReceiveOptions<T>): Promise<void>;
|
|
319
403
|
/**
|
|
320
|
-
* Receive a specific message by its ID
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
* @param
|
|
325
|
-
* @
|
|
326
|
-
* @
|
|
404
|
+
* Receive a specific message by its ID.
|
|
405
|
+
*
|
|
406
|
+
* Used for targeted message processing, typically from webhook callbacks.
|
|
407
|
+
*
|
|
408
|
+
* @param topicName - Name of the topic (pattern: `[A-Za-z0-9_-]+`)
|
|
409
|
+
* @param consumerGroup - Name of the consumer group (pattern: `[A-Za-z0-9_-]+`)
|
|
410
|
+
* @param handler - Function to process the message payload and metadata
|
|
411
|
+
* @param options - Receive options with messageId
|
|
412
|
+
* @param options.messageId - Specific message ID to consume
|
|
413
|
+
* @returns Promise that resolves when the message is processed and deleted
|
|
414
|
+
* @throws {MessageNotFoundError} When message doesn't exist
|
|
415
|
+
* @throws {MessageNotAvailableError} When message in wrong state
|
|
416
|
+
* @throws {MessageAlreadyProcessedError} When already processed
|
|
327
417
|
*/
|
|
328
418
|
declare function receive<T = unknown>(topicName: string, consumerGroup: string, handler: MessageHandler<T>, options: ReceiveOptions<T> & {
|
|
329
419
|
messageId: string;
|
|
330
|
-
skipPayload?: false | undefined;
|
|
331
|
-
}): Promise<void>;
|
|
332
|
-
/**
|
|
333
|
-
* Receive a specific message by its ID without downloading the payload (metadata only)
|
|
334
|
-
* @param topicName Name of the topic to receive from
|
|
335
|
-
* @param consumerGroup Name of the consumer group
|
|
336
|
-
* @param handler Function to process the message metadata (payload will be void)
|
|
337
|
-
* @param options Receive options with messageId and skipPayload specified
|
|
338
|
-
* @returns Promise that resolves when the message is processed
|
|
339
|
-
* @throws All the same errors as the underlying client methods
|
|
340
|
-
*/
|
|
341
|
-
declare function receive<T = unknown>(topicName: string, consumerGroup: string, handler: MessageHandler<void>, options: ReceiveOptions<T> & {
|
|
342
|
-
messageId: string;
|
|
343
|
-
skipPayload: true;
|
|
344
420
|
}): Promise<void>;
|
|
345
421
|
|
|
346
|
-
export { type CallbackHandlers, Client, Message, MessageHandler, type ParsedCallbackRequest, PublishOptions, QueueClientOptions, type ReceiveOptions, SendMessageOptions, SendMessageResponse, type SendOptions, Transport, handleCallback, parseCallback, receive, send };
|
|
422
|
+
export { type CallbackHandlers, Client, type HandleCallbackOptions, Message, MessageHandler, type ParsedCallbackRequest, PublishOptions, QueueClientOptions, type ReceiveOptions, SendMessageOptions, SendMessageResponse, type SendOptions, Transport, handleCallback, parseCallback, receive, send };
|