@vercel/queue 0.0.0-alpha.31 → 0.0.0-alpha.33
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/index.d.mts +260 -73
- package/dist/index.d.ts +260 -73
- package/dist/index.js +319 -246
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +318 -246
- 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 +138 -120
- package/dist/nextjs-pages.js.map +1 -1
- package/dist/nextjs-pages.mjs +138 -120
- package/dist/nextjs-pages.mjs.map +1 -1
- package/dist/{types-JvOenjfT.d.mts → types-Dw29Fr9y.d.mts} +126 -2
- package/dist/{types-JvOenjfT.d.ts → types-Dw29Fr9y.d.ts} +126 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,82 +1,100 @@
|
|
|
1
|
-
import { M as
|
|
2
|
-
export {
|
|
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-Dw29Fr9y.js';
|
|
2
|
+
export { i as BadRequestError, B as BufferTransport, F as ForbiddenError, I as InternalServerError, j as InvalidLimitError, J as JsonTransport, k as MessageCorruptedError, p as MessageHandlerResult, l as MessageLockedError, q as MessageMetadata, m as MessageNotAvailableError, n as MessageNotFoundError, r as MessageTimeoutResult, o as QueueEmptyError, h as StreamTransport, U as UnauthorizedError } from './types-Dw29Fr9y.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
interface ConsumeOptions {
|
|
8
|
-
/** The specific message ID to consume (if not provided, consumes next available message) */
|
|
9
|
-
messageId?: string;
|
|
10
|
-
/** Whether to skip downloading the payload (only allowed when messageId is provided) */
|
|
11
|
-
skipPayload?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Options for the send function
|
|
5
|
+
* Internal client for interacting with the Vercel Queue Service API
|
|
6
|
+
* Use Client for the public-facing wrapper with send/handleCallback methods
|
|
16
7
|
*/
|
|
17
|
-
|
|
8
|
+
declare class QueueClient {
|
|
9
|
+
private baseUrl;
|
|
10
|
+
private basePath;
|
|
11
|
+
private customHeaders;
|
|
12
|
+
private providedToken?;
|
|
18
13
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
14
|
+
* Create a new Vercel Queue Service client
|
|
15
|
+
* @param options QueueClient configuration options
|
|
21
16
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
17
|
+
constructor(options?: QueueClientOptions);
|
|
18
|
+
private getToken;
|
|
19
|
+
/**
|
|
20
|
+
* Internal fetch wrapper that automatically handles debug logging
|
|
21
|
+
* when VERCEL_QUEUE_DEBUG is enabled
|
|
22
|
+
*/
|
|
23
|
+
private fetch;
|
|
24
|
+
/**
|
|
25
|
+
* Send a message to a queue
|
|
26
|
+
* @param options Send message options
|
|
27
|
+
* @param transport Serializer/deserializer for the payload
|
|
28
|
+
* @returns Promise with the message ID
|
|
29
|
+
* @throws {BadRequestError} When request parameters are invalid
|
|
30
|
+
* @throws {UnauthorizedError} When authentication fails
|
|
31
|
+
* @throws {ForbiddenError} When access is denied (environment mismatch)
|
|
32
|
+
* @throws {InternalServerError} When server encounters an error
|
|
33
|
+
*/
|
|
34
|
+
sendMessage<T = unknown>(options: SendMessageOptions<T>, transport: Transport<T>): Promise<SendMessageResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Receive messages from a queue
|
|
37
|
+
* @param options Receive messages options
|
|
38
|
+
* @param transport Serializer/deserializer for the payload
|
|
39
|
+
* @returns AsyncGenerator that yields messages as they arrive
|
|
40
|
+
* @throws {InvalidLimitError} When limit parameter is not between 1 and 10
|
|
41
|
+
* @throws {QueueEmptyError} When no messages are available (204)
|
|
42
|
+
* @throws {MessageLockedError} When messages are temporarily locked (423)
|
|
43
|
+
* @throws {BadRequestError} When request parameters are invalid
|
|
44
|
+
* @throws {UnauthorizedError} When authentication fails
|
|
45
|
+
* @throws {ForbiddenError} When access is denied (environment mismatch)
|
|
46
|
+
* @throws {InternalServerError} When server encounters an error
|
|
47
|
+
*/
|
|
48
|
+
receiveMessages<T = unknown>(options: ReceiveMessagesOptions<T>, transport: Transport<T>): AsyncGenerator<Message<T>, void, unknown>;
|
|
49
|
+
/**
|
|
50
|
+
* Receive a specific message by its ID from a queue
|
|
51
|
+
* @param options Receive message by ID options
|
|
52
|
+
* @param transport Serializer/deserializer for the payload
|
|
53
|
+
* @returns Promise with the message or null if not found/available
|
|
54
|
+
* @throws {MessageNotFoundError} When the message doesn't exist (404)
|
|
55
|
+
* @throws {MessageLockedError} When the message is temporarily locked (423)
|
|
56
|
+
* @throws {MessageNotAvailableError} When message exists but isn't available (409)
|
|
57
|
+
* @throws {MessageCorruptedError} When message data is corrupted
|
|
58
|
+
* @throws {BadRequestError} When request parameters are invalid
|
|
59
|
+
* @throws {UnauthorizedError} When authentication fails
|
|
60
|
+
* @throws {ForbiddenError} When access is denied (environment mismatch)
|
|
61
|
+
* @throws {InternalServerError} When server encounters an error
|
|
62
|
+
*/
|
|
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>>;
|
|
69
|
+
/**
|
|
70
|
+
* Delete a message (acknowledge processing)
|
|
71
|
+
* @param options Delete message options
|
|
72
|
+
* @returns Promise with delete status
|
|
73
|
+
* @throws {MessageNotFoundError} When the message doesn't exist (404)
|
|
74
|
+
* @throws {MessageNotAvailableError} When message can't be deleted (409)
|
|
75
|
+
* @throws {BadRequestError} When ticket is missing or invalid (400)
|
|
76
|
+
* @throws {UnauthorizedError} When authentication fails
|
|
77
|
+
* @throws {ForbiddenError} When access is denied (environment mismatch)
|
|
78
|
+
* @throws {InternalServerError} When server encounters an error
|
|
79
|
+
*/
|
|
80
|
+
deleteMessage(options: DeleteMessageOptions): Promise<DeleteMessageResponse>;
|
|
81
|
+
/**
|
|
82
|
+
* Change the visibility timeout of a message
|
|
83
|
+
* @param options Change visibility options
|
|
84
|
+
* @returns Promise with update status
|
|
85
|
+
* @throws {MessageNotFoundError} When the message doesn't exist (404)
|
|
86
|
+
* @throws {MessageNotAvailableError} When message can't be updated (409)
|
|
87
|
+
* @throws {BadRequestError} When ticket is missing or visibility timeout invalid (400)
|
|
88
|
+
* @throws {UnauthorizedError} When authentication fails
|
|
89
|
+
* @throws {ForbiddenError} When access is denied (environment mismatch)
|
|
90
|
+
* @throws {InternalServerError} When server encounters an error
|
|
91
|
+
*/
|
|
92
|
+
changeVisibility(options: ChangeVisibilityOptions): Promise<ChangeVisibilityResponse>;
|
|
43
93
|
}
|
|
94
|
+
|
|
44
95
|
/**
|
|
45
|
-
*
|
|
46
|
-
* Uses the default QueueClient with automatic OIDC token detection
|
|
47
|
-
* @param topicName Name of the topic to receive from
|
|
48
|
-
* @param consumerGroup Name of the consumer group
|
|
49
|
-
* @param handler Function to process the message
|
|
50
|
-
* @returns Promise that resolves when the message is processed
|
|
51
|
-
* @throws All the same errors as the underlying client methods
|
|
52
|
-
*/
|
|
53
|
-
declare function receive<T = unknown>(topicName: string, consumerGroup: string, handler: MessageHandler<T>, options?: ReceiveOptions<T>): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Receive a specific message by its ID with full payload
|
|
56
|
-
* @param topicName Name of the topic to receive from
|
|
57
|
-
* @param consumerGroup Name of the consumer group
|
|
58
|
-
* @param handler Function to process the message
|
|
59
|
-
* @param options Receive options with messageId specified
|
|
60
|
-
* @returns Promise that resolves when the message is processed
|
|
61
|
-
* @throws All the same errors as the underlying client methods
|
|
96
|
+
* Queue Callback utilities for handling incoming webhook payloads from Vercel triggers
|
|
62
97
|
*/
|
|
63
|
-
declare function receive<T = unknown>(topicName: string, consumerGroup: string, handler: MessageHandler<T>, options: ReceiveOptions<T> & {
|
|
64
|
-
messageId: string;
|
|
65
|
-
skipPayload?: false | undefined;
|
|
66
|
-
}): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Receive a specific message by its ID without downloading the payload (metadata only)
|
|
69
|
-
* @param topicName Name of the topic to receive from
|
|
70
|
-
* @param consumerGroup Name of the consumer group
|
|
71
|
-
* @param handler Function to process the message metadata (payload will be void)
|
|
72
|
-
* @param options Receive options with messageId and skipPayload specified
|
|
73
|
-
* @returns Promise that resolves when the message is processed
|
|
74
|
-
* @throws All the same errors as the underlying client methods
|
|
75
|
-
*/
|
|
76
|
-
declare function receive<T = unknown>(topicName: string, consumerGroup: string, handler: MessageHandler<void>, options: ReceiveOptions<T> & {
|
|
77
|
-
messageId: string;
|
|
78
|
-
skipPayload: true;
|
|
79
|
-
}): Promise<void>;
|
|
80
98
|
|
|
81
99
|
/**
|
|
82
100
|
* Configuration object with handlers for different topics and consumer groups
|
|
@@ -129,6 +147,7 @@ declare function parseCallback(request: Request): Promise<ParsedCallbackRequest>
|
|
|
129
147
|
* and routes to the appropriate handler based on topic and consumer group.
|
|
130
148
|
*
|
|
131
149
|
* @param handlers Object with topic-specific handlers organized by consumer groups
|
|
150
|
+
* @param client Optional QueueClient instance to use. If not provided, a default client is created.
|
|
132
151
|
* @returns A Next.js route handler function
|
|
133
152
|
*
|
|
134
153
|
* @example
|
|
@@ -154,6 +173,174 @@ declare function parseCallback(request: Request): Promise<ParsedCallbackRequest>
|
|
|
154
173
|
* });
|
|
155
174
|
* ```
|
|
156
175
|
*/
|
|
157
|
-
declare function handleCallback(handlers: CallbackHandlers): (request: Request) => Promise<Response>;
|
|
176
|
+
declare function handleCallback(handlers: CallbackHandlers, client?: QueueClient): (request: Request) => Promise<Response>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Client - User-facing wrapper for the Vercel Queue Service
|
|
180
|
+
*
|
|
181
|
+
* This provides a simple interface with send() and handleCallback() methods
|
|
182
|
+
* while delegating to the internal QueueClient and factory functions.
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Client provides a simple interface to the Vercel Queue Service.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* // Create a client with custom options
|
|
191
|
+
* const client = new Client({
|
|
192
|
+
* token: "my-token",
|
|
193
|
+
* headers: { "X-Custom": "header" },
|
|
194
|
+
* });
|
|
195
|
+
*
|
|
196
|
+
* // Send a message
|
|
197
|
+
* await client.send("my-topic", { hello: "world" });
|
|
198
|
+
*
|
|
199
|
+
* // Handle callbacks
|
|
200
|
+
* export const POST = client.handleCallback({
|
|
201
|
+
* "my-topic": {
|
|
202
|
+
* "my-group": async (msg, meta) => console.log(msg),
|
|
203
|
+
* },
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
declare class Client {
|
|
208
|
+
private client;
|
|
209
|
+
/**
|
|
210
|
+
* Create a new Client
|
|
211
|
+
* @param options QueueClient configuration options
|
|
212
|
+
*/
|
|
213
|
+
constructor(options?: QueueClientOptions);
|
|
214
|
+
/**
|
|
215
|
+
* Send a message to a topic
|
|
216
|
+
* @param topicName Name of the topic to send to
|
|
217
|
+
* @param payload The data to send
|
|
218
|
+
* @param options Optional publish options and transport
|
|
219
|
+
* @returns Promise with the message ID
|
|
220
|
+
* @throws {BadRequestError} When request parameters are invalid
|
|
221
|
+
* @throws {UnauthorizedError} When authentication fails
|
|
222
|
+
* @throws {ForbiddenError} When access is denied (environment mismatch)
|
|
223
|
+
* @throws {InternalServerError} When server encounters an error
|
|
224
|
+
*/
|
|
225
|
+
send<T = unknown>(topicName: string, payload: T, options?: PublishOptions & {
|
|
226
|
+
transport?: Transport<T>;
|
|
227
|
+
}): Promise<{
|
|
228
|
+
messageId: string;
|
|
229
|
+
}>;
|
|
230
|
+
/**
|
|
231
|
+
* Create a callback handler for processing queue messages
|
|
232
|
+
* Returns a Next.js route handler function that routes messages to appropriate handlers
|
|
233
|
+
* @param handlers Object with topic-specific handlers organized by consumer groups
|
|
234
|
+
* @returns A Next.js route handler function
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* export const POST = client.handleCallback({
|
|
239
|
+
* "user-events": {
|
|
240
|
+
* "welcome": (user, metadata) => console.log("Welcoming user", user),
|
|
241
|
+
* "analytics": (user, metadata) => console.log("Tracking user", user),
|
|
242
|
+
* },
|
|
243
|
+
* });
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
handleCallback(handlers: CallbackHandlers): (request: Request) => Promise<Response>;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Options for the consume method
|
|
251
|
+
*/
|
|
252
|
+
interface ConsumeOptions {
|
|
253
|
+
/** The specific message ID to consume (if not provided, consumes next available message) */
|
|
254
|
+
messageId?: string;
|
|
255
|
+
/** Whether to skip downloading the payload (only allowed when messageId is provided) */
|
|
256
|
+
skipPayload?: boolean;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Options for the send function
|
|
261
|
+
*/
|
|
262
|
+
interface SendOptions<T = unknown> extends PublishOptions {
|
|
263
|
+
/**
|
|
264
|
+
* Serializer/deserializer for the payload
|
|
265
|
+
* @default JsonTransport instance
|
|
266
|
+
*/
|
|
267
|
+
transport?: Transport<T>;
|
|
268
|
+
/**
|
|
269
|
+
* QueueClient instance to use for sending the message
|
|
270
|
+
* If not provided, a default client is created
|
|
271
|
+
*/
|
|
272
|
+
client?: QueueClient;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Send a message to a topic (shorthand for topic creation and publishing)
|
|
276
|
+
* Uses the default QueueClient with automatic OIDC token detection, or a provided client
|
|
277
|
+
* @param topicName Name of the topic to send to
|
|
278
|
+
* @param payload The data to send
|
|
279
|
+
* @param options Optional send options including transport, publish settings, and client
|
|
280
|
+
* @returns Promise with the message ID
|
|
281
|
+
* @throws {BadRequestError} When request parameters are invalid
|
|
282
|
+
* @throws {UnauthorizedError} When authentication fails
|
|
283
|
+
* @throws {ForbiddenError} When access is denied (environment mismatch)
|
|
284
|
+
* @throws {InternalServerError} When server encounters an error
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* // Using default client (OIDC token)
|
|
289
|
+
* await send("my-topic", { hello: "world" });
|
|
290
|
+
*
|
|
291
|
+
* // Using custom client
|
|
292
|
+
* const client = new QueueClient({ token: "my-token" });
|
|
293
|
+
* await send("my-topic", { hello: "world" }, { client });
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
declare function send<T = unknown>(topicName: string, payload: T, options?: SendOptions<T>): Promise<{
|
|
297
|
+
messageId: string;
|
|
298
|
+
}>;
|
|
299
|
+
/**
|
|
300
|
+
* Options for the receive function
|
|
301
|
+
*/
|
|
302
|
+
interface ReceiveOptions<T = unknown> extends ConsumerGroupOptions<T>, ConsumeOptions {
|
|
303
|
+
/**
|
|
304
|
+
* QueueClient instance to use for receiving the message
|
|
305
|
+
* If not provided, a default client is created
|
|
306
|
+
*/
|
|
307
|
+
client?: QueueClient;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Receive a message from a topic (shorthand for topic and consumer group creation)
|
|
311
|
+
* Uses the default QueueClient with automatic OIDC token detection
|
|
312
|
+
* @param topicName Name of the topic to receive from
|
|
313
|
+
* @param consumerGroup Name of the consumer group
|
|
314
|
+
* @param handler Function to process the message
|
|
315
|
+
* @returns Promise that resolves when the message is processed
|
|
316
|
+
* @throws All the same errors as the underlying client methods
|
|
317
|
+
*/
|
|
318
|
+
declare function receive<T = unknown>(topicName: string, consumerGroup: string, handler: MessageHandler<T>, options?: ReceiveOptions<T>): Promise<void>;
|
|
319
|
+
/**
|
|
320
|
+
* Receive a specific message by its ID with full payload
|
|
321
|
+
* @param topicName Name of the topic to receive from
|
|
322
|
+
* @param consumerGroup Name of the consumer group
|
|
323
|
+
* @param handler Function to process the message
|
|
324
|
+
* @param options Receive options with messageId specified
|
|
325
|
+
* @returns Promise that resolves when the message is processed
|
|
326
|
+
* @throws All the same errors as the underlying client methods
|
|
327
|
+
*/
|
|
328
|
+
declare function receive<T = unknown>(topicName: string, consumerGroup: string, handler: MessageHandler<T>, options: ReceiveOptions<T> & {
|
|
329
|
+
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
|
+
}): Promise<void>;
|
|
158
345
|
|
|
159
|
-
export { MessageHandler, type ParsedCallbackRequest, PublishOptions, type ReceiveOptions, type SendOptions, Transport, handleCallback, parseCallback, receive, send };
|
|
346
|
+
export { type CallbackHandlers, Client, Message, MessageHandler, type ParsedCallbackRequest, PublishOptions, QueueClientOptions, type ReceiveOptions, SendMessageOptions, SendMessageResponse, type SendOptions, Transport, handleCallback, parseCallback, receive, send };
|