@vercel/queue 0.0.0-alpha.5 → 0.0.0-alpha.6
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 +151 -313
- package/dist/index.d.mts +52 -104
- package/dist/index.d.ts +52 -104
- package/dist/index.js +44 -224
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -221
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -84,23 +84,6 @@ interface QueueClientOptions {
|
|
|
84
84
|
*/
|
|
85
85
|
token?: string;
|
|
86
86
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Callback configuration for a consumer group
|
|
89
|
-
*/
|
|
90
|
-
interface CallbackConfig {
|
|
91
|
-
/**
|
|
92
|
-
* Webhook URL to notify when messages are available
|
|
93
|
-
*/
|
|
94
|
-
url: string;
|
|
95
|
-
/**
|
|
96
|
-
* Delay in seconds before sending the first callback
|
|
97
|
-
*/
|
|
98
|
-
delay?: number;
|
|
99
|
-
/**
|
|
100
|
-
* Delay in seconds between retry attempts when the callback fails
|
|
101
|
-
*/
|
|
102
|
-
frequency?: number;
|
|
103
|
-
}
|
|
104
87
|
/**
|
|
105
88
|
* Shared options for publishing messages
|
|
106
89
|
*/
|
|
@@ -117,12 +100,6 @@ interface PublishOptions {
|
|
|
117
100
|
* @max 86400
|
|
118
101
|
*/
|
|
119
102
|
retentionSeconds?: number;
|
|
120
|
-
/**
|
|
121
|
-
* Callback configuration
|
|
122
|
-
* - If a single CallbackConfig is provided, it will use the "default" consumer group
|
|
123
|
-
* - If an object is provided, keys are consumer group names with their respective callback configs
|
|
124
|
-
*/
|
|
125
|
-
callback?: Record<string, CallbackConfig> | CallbackConfig;
|
|
126
103
|
}
|
|
127
104
|
interface SendMessageOptions<T = unknown> extends PublishOptions {
|
|
128
105
|
/**
|
|
@@ -186,7 +163,6 @@ interface ReceiveMessagesOptions<T = unknown> {
|
|
|
186
163
|
* Maximum number of messages to retrieve
|
|
187
164
|
* @default 10
|
|
188
165
|
* @max 10
|
|
189
|
-
* @note FIFO queues must use limit=1
|
|
190
166
|
*/
|
|
191
167
|
limit?: number;
|
|
192
168
|
}
|
|
@@ -328,12 +304,6 @@ declare class MessageNotFoundError extends Error {
|
|
|
328
304
|
declare class MessageNotAvailableError extends Error {
|
|
329
305
|
constructor(messageId: string, reason?: string);
|
|
330
306
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Error thrown when there's a FIFO ordering violation (409)
|
|
333
|
-
*/
|
|
334
|
-
declare class FifoOrderingViolationError extends Error {
|
|
335
|
-
constructor(messageId: string, reason: string);
|
|
336
|
-
}
|
|
337
307
|
/**
|
|
338
308
|
* Error thrown when message data is corrupted or can't be parsed
|
|
339
309
|
*/
|
|
@@ -347,7 +317,7 @@ declare class QueueEmptyError extends Error {
|
|
|
347
317
|
constructor(queueName: string, consumerGroup: string);
|
|
348
318
|
}
|
|
349
319
|
/**
|
|
350
|
-
* Error thrown when a message is temporarily locked
|
|
320
|
+
* Error thrown when a message is temporarily locked (423)
|
|
351
321
|
*/
|
|
352
322
|
declare class MessageLockedError extends Error {
|
|
353
323
|
readonly retryAfter?: number;
|
|
@@ -371,12 +341,6 @@ declare class ForbiddenError extends Error {
|
|
|
371
341
|
declare class BadRequestError extends Error {
|
|
372
342
|
constructor(message: string);
|
|
373
343
|
}
|
|
374
|
-
/**
|
|
375
|
-
* Error thrown when there's a failed dependency (424) - FIFO ordering violation in receive by ID
|
|
376
|
-
*/
|
|
377
|
-
declare class FailedDependencyError extends Error {
|
|
378
|
-
constructor(messageId: string);
|
|
379
|
-
}
|
|
380
344
|
/**
|
|
381
345
|
* Error thrown for internal server errors (500)
|
|
382
346
|
*/
|
|
@@ -389,29 +353,6 @@ declare class InternalServerError extends Error {
|
|
|
389
353
|
declare class InvalidLimitError extends Error {
|
|
390
354
|
constructor(limit: number, min?: number, max?: number);
|
|
391
355
|
}
|
|
392
|
-
/**
|
|
393
|
-
* Options extracted from a queue callback request
|
|
394
|
-
*/
|
|
395
|
-
interface CallbackMessageOptions {
|
|
396
|
-
/**
|
|
397
|
-
* The queue name extracted from Vqs-Queue-Name header
|
|
398
|
-
*/
|
|
399
|
-
queueName: string;
|
|
400
|
-
/**
|
|
401
|
-
* The consumer group extracted from Vqs-Consumer-Group header
|
|
402
|
-
*/
|
|
403
|
-
consumerGroup: string;
|
|
404
|
-
/**
|
|
405
|
-
* The message ID extracted from Vqs-Message-Id header
|
|
406
|
-
*/
|
|
407
|
-
messageId: string;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Error thrown when queue callback headers are missing or invalid
|
|
411
|
-
*/
|
|
412
|
-
declare class InvalidCallbackError extends Error {
|
|
413
|
-
constructor(message: string);
|
|
414
|
-
}
|
|
415
356
|
|
|
416
357
|
/**
|
|
417
358
|
* Client for interacting with the Vercel Queue Service API
|
|
@@ -457,7 +398,7 @@ declare class QueueClient {
|
|
|
457
398
|
* @returns AsyncGenerator that yields messages as they arrive
|
|
458
399
|
* @throws {InvalidLimitError} When limit parameter is not between 1 and 10
|
|
459
400
|
* @throws {QueueEmptyError} When no messages are available (204)
|
|
460
|
-
* @throws {MessageLockedError} When
|
|
401
|
+
* @throws {MessageLockedError} When messages are temporarily locked (423)
|
|
461
402
|
* @throws {BadRequestError} When request parameters are invalid
|
|
462
403
|
* @throws {UnauthorizedError} When authentication fails
|
|
463
404
|
* @throws {ForbiddenError} When access is denied (environment mismatch)
|
|
@@ -471,7 +412,6 @@ declare class QueueClient {
|
|
|
471
412
|
* @returns Promise with the message or null if not found/available
|
|
472
413
|
* @throws {MessageNotFoundError} When the message doesn't exist (404)
|
|
473
414
|
* @throws {MessageLockedError} When the message is temporarily locked (423)
|
|
474
|
-
* @throws {FailedDependencyError} When FIFO ordering is violated (424)
|
|
475
415
|
* @throws {MessageNotAvailableError} When message exists but isn't available (409)
|
|
476
416
|
* @throws {MessageCorruptedError} When message data is corrupted
|
|
477
417
|
* @throws {BadRequestError} When request parameters are invalid
|
|
@@ -722,77 +662,85 @@ declare function receive<T = unknown>(topicName: string, consumerGroup: string,
|
|
|
722
662
|
}): Promise<void>;
|
|
723
663
|
|
|
724
664
|
/**
|
|
725
|
-
* Queue Callback utilities for handling incoming webhook payloads
|
|
665
|
+
* Queue Callback utilities for handling incoming webhook payloads from Vercel triggers
|
|
726
666
|
*/
|
|
727
667
|
|
|
728
668
|
/**
|
|
729
|
-
*
|
|
669
|
+
* Configuration object with handlers for different topics and consumer groups
|
|
670
|
+
*/
|
|
671
|
+
type CallbackHandlers = {
|
|
672
|
+
[topicName: string]: {
|
|
673
|
+
[consumerGroup: string]: MessageHandler;
|
|
674
|
+
};
|
|
675
|
+
};
|
|
676
|
+
/**
|
|
677
|
+
* Parsed callback request information
|
|
678
|
+
*/
|
|
679
|
+
type ParsedCallbackRequest = {
|
|
680
|
+
queueName: string;
|
|
681
|
+
consumerGroup: string;
|
|
682
|
+
messageId: string;
|
|
683
|
+
};
|
|
684
|
+
/**
|
|
685
|
+
* Parse and validate callback request headers
|
|
730
686
|
*
|
|
731
|
-
*
|
|
732
|
-
*
|
|
733
|
-
*
|
|
687
|
+
* Extracts queue information from Vercel-provided headers and validates
|
|
688
|
+
* that all required headers are present.
|
|
689
|
+
*
|
|
690
|
+
* @param request The incoming webhook request
|
|
691
|
+
* @returns Parsed queue information
|
|
692
|
+
* @throws Error if required headers are missing
|
|
734
693
|
*
|
|
735
694
|
* @example
|
|
736
695
|
* ```typescript
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
* // In your webhook handler
|
|
696
|
+
* // In Next.js API route
|
|
740
697
|
* export async function POST(request: Request) {
|
|
741
698
|
* try {
|
|
742
|
-
* const
|
|
699
|
+
* const { queueName, consumerGroup, messageId } = parseCallbackRequest(request);
|
|
743
700
|
*
|
|
744
|
-
* // Use
|
|
745
|
-
*
|
|
746
|
-
* ...callbackOptions,
|
|
747
|
-
* visibilityTimeoutSeconds: 30
|
|
748
|
-
* }, transport);
|
|
701
|
+
* // Use the parsed information...
|
|
702
|
+
* await myWorkflow.handleWebhook(queueName, consumerGroup, messageId);
|
|
749
703
|
*
|
|
750
|
-
*
|
|
704
|
+
* return Response.json({ status: "success" });
|
|
751
705
|
* } catch (error) {
|
|
752
|
-
*
|
|
753
|
-
* return new Response('Invalid callback', { status: 400 });
|
|
754
|
-
* }
|
|
755
|
-
* throw error;
|
|
706
|
+
* return Response.json({ error: error.message }, { status: 400 });
|
|
756
707
|
* }
|
|
757
708
|
* }
|
|
758
709
|
* ```
|
|
759
710
|
*/
|
|
760
|
-
declare function parseCallbackRequest(request: Request):
|
|
761
|
-
/**
|
|
762
|
-
* Configuration object with handlers for different topics
|
|
763
|
-
* Each topic can have either:
|
|
764
|
-
* - A single handler function (uses 'default' consumer group)
|
|
765
|
-
* - An object with handlers for specific consumer groups
|
|
766
|
-
*/
|
|
767
|
-
type CallbackHandlers = {
|
|
768
|
-
[topicName: string]: MessageHandler | {
|
|
769
|
-
[consumerGroup: string]: MessageHandler;
|
|
770
|
-
};
|
|
771
|
-
};
|
|
711
|
+
declare function parseCallbackRequest(request: Request): ParsedCallbackRequest;
|
|
772
712
|
/**
|
|
773
|
-
* Simplified queue callback handler for
|
|
713
|
+
* Simplified queue callback handler for Next.js route handlers
|
|
774
714
|
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
715
|
+
* Automatically extracts queue information from Vercel-provided headers
|
|
716
|
+
* and routes to the appropriate handler based on topic and consumer group.
|
|
717
|
+
*
|
|
718
|
+
* @param handlers Object with topic-specific handlers organized by consumer groups
|
|
719
|
+
* @returns A Next.js route handler function
|
|
777
720
|
*
|
|
778
721
|
* @example
|
|
779
722
|
* ```typescript
|
|
780
|
-
* //
|
|
723
|
+
* // Single topic with multiple consumer groups
|
|
781
724
|
* export const POST = handleCallback({
|
|
782
|
-
* "
|
|
783
|
-
* console.log(
|
|
725
|
+
* "image-processing": {
|
|
726
|
+
* "compress": (message, metadata) => console.log("Compressing image", message),
|
|
727
|
+
* "resize": (message, metadata) => console.log("Resizing image", message),
|
|
784
728
|
* }
|
|
785
729
|
* });
|
|
786
730
|
*
|
|
787
|
-
* //
|
|
731
|
+
* // Multiple topics with consumer groups
|
|
788
732
|
* export const POST = handleCallback({
|
|
789
|
-
* "
|
|
790
|
-
* "
|
|
791
|
-
* "
|
|
733
|
+
* "user-events": {
|
|
734
|
+
* "welcome": (user, metadata) => console.log("Welcoming user", user),
|
|
735
|
+
* "analytics": (user, metadata) => console.log("Tracking user", user),
|
|
736
|
+
* },
|
|
737
|
+
* "order-events": {
|
|
738
|
+
* "fulfillment": (order, metadata) => console.log("Fulfilling order", order),
|
|
739
|
+
* "notifications": (order, metadata) => console.log("Notifying order", order),
|
|
792
740
|
* }
|
|
793
741
|
* });
|
|
794
742
|
* ```
|
|
795
743
|
*/
|
|
796
744
|
declare function handleCallback(handlers: CallbackHandlers): (request: Request) => Promise<Response>;
|
|
797
745
|
|
|
798
|
-
export { BadRequestError, BufferTransport, type
|
|
746
|
+
export { BadRequestError, BufferTransport, type ChangeVisibilityOptions, type ChangeVisibilityResponse, type ConsumeOptions, ConsumerGroup, type ConsumerGroupOptions, type DeleteMessageOptions, type DeleteMessageResponse, ForbiddenError, InternalServerError, InvalidLimitError, JsonTransport, type Message, MessageCorruptedError, type MessageHandler, type MessageHandlerResult, MessageLockedError, type MessageMetadata, MessageNotAvailableError, MessageNotFoundError, type MessageTimeoutResult, type ParsedCallbackRequest, type PublishOptions, QueueClient, type QueueClientOptions, QueueEmptyError, type ReceiveMessageByIdOptions, type ReceiveMessageByIdResponse, type ReceiveMessagesOptions, type ReceiveOptions, type SendMessageOptions, type SendMessageResponse, type SendOptions, StreamTransport, Topic, type Transport, UnauthorizedError, createTopic, handleCallback, parseCallbackRequest, receive, send };
|
package/dist/index.d.ts
CHANGED
|
@@ -84,23 +84,6 @@ interface QueueClientOptions {
|
|
|
84
84
|
*/
|
|
85
85
|
token?: string;
|
|
86
86
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Callback configuration for a consumer group
|
|
89
|
-
*/
|
|
90
|
-
interface CallbackConfig {
|
|
91
|
-
/**
|
|
92
|
-
* Webhook URL to notify when messages are available
|
|
93
|
-
*/
|
|
94
|
-
url: string;
|
|
95
|
-
/**
|
|
96
|
-
* Delay in seconds before sending the first callback
|
|
97
|
-
*/
|
|
98
|
-
delay?: number;
|
|
99
|
-
/**
|
|
100
|
-
* Delay in seconds between retry attempts when the callback fails
|
|
101
|
-
*/
|
|
102
|
-
frequency?: number;
|
|
103
|
-
}
|
|
104
87
|
/**
|
|
105
88
|
* Shared options for publishing messages
|
|
106
89
|
*/
|
|
@@ -117,12 +100,6 @@ interface PublishOptions {
|
|
|
117
100
|
* @max 86400
|
|
118
101
|
*/
|
|
119
102
|
retentionSeconds?: number;
|
|
120
|
-
/**
|
|
121
|
-
* Callback configuration
|
|
122
|
-
* - If a single CallbackConfig is provided, it will use the "default" consumer group
|
|
123
|
-
* - If an object is provided, keys are consumer group names with their respective callback configs
|
|
124
|
-
*/
|
|
125
|
-
callback?: Record<string, CallbackConfig> | CallbackConfig;
|
|
126
103
|
}
|
|
127
104
|
interface SendMessageOptions<T = unknown> extends PublishOptions {
|
|
128
105
|
/**
|
|
@@ -186,7 +163,6 @@ interface ReceiveMessagesOptions<T = unknown> {
|
|
|
186
163
|
* Maximum number of messages to retrieve
|
|
187
164
|
* @default 10
|
|
188
165
|
* @max 10
|
|
189
|
-
* @note FIFO queues must use limit=1
|
|
190
166
|
*/
|
|
191
167
|
limit?: number;
|
|
192
168
|
}
|
|
@@ -328,12 +304,6 @@ declare class MessageNotFoundError extends Error {
|
|
|
328
304
|
declare class MessageNotAvailableError extends Error {
|
|
329
305
|
constructor(messageId: string, reason?: string);
|
|
330
306
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Error thrown when there's a FIFO ordering violation (409)
|
|
333
|
-
*/
|
|
334
|
-
declare class FifoOrderingViolationError extends Error {
|
|
335
|
-
constructor(messageId: string, reason: string);
|
|
336
|
-
}
|
|
337
307
|
/**
|
|
338
308
|
* Error thrown when message data is corrupted or can't be parsed
|
|
339
309
|
*/
|
|
@@ -347,7 +317,7 @@ declare class QueueEmptyError extends Error {
|
|
|
347
317
|
constructor(queueName: string, consumerGroup: string);
|
|
348
318
|
}
|
|
349
319
|
/**
|
|
350
|
-
* Error thrown when a message is temporarily locked
|
|
320
|
+
* Error thrown when a message is temporarily locked (423)
|
|
351
321
|
*/
|
|
352
322
|
declare class MessageLockedError extends Error {
|
|
353
323
|
readonly retryAfter?: number;
|
|
@@ -371,12 +341,6 @@ declare class ForbiddenError extends Error {
|
|
|
371
341
|
declare class BadRequestError extends Error {
|
|
372
342
|
constructor(message: string);
|
|
373
343
|
}
|
|
374
|
-
/**
|
|
375
|
-
* Error thrown when there's a failed dependency (424) - FIFO ordering violation in receive by ID
|
|
376
|
-
*/
|
|
377
|
-
declare class FailedDependencyError extends Error {
|
|
378
|
-
constructor(messageId: string);
|
|
379
|
-
}
|
|
380
344
|
/**
|
|
381
345
|
* Error thrown for internal server errors (500)
|
|
382
346
|
*/
|
|
@@ -389,29 +353,6 @@ declare class InternalServerError extends Error {
|
|
|
389
353
|
declare class InvalidLimitError extends Error {
|
|
390
354
|
constructor(limit: number, min?: number, max?: number);
|
|
391
355
|
}
|
|
392
|
-
/**
|
|
393
|
-
* Options extracted from a queue callback request
|
|
394
|
-
*/
|
|
395
|
-
interface CallbackMessageOptions {
|
|
396
|
-
/**
|
|
397
|
-
* The queue name extracted from Vqs-Queue-Name header
|
|
398
|
-
*/
|
|
399
|
-
queueName: string;
|
|
400
|
-
/**
|
|
401
|
-
* The consumer group extracted from Vqs-Consumer-Group header
|
|
402
|
-
*/
|
|
403
|
-
consumerGroup: string;
|
|
404
|
-
/**
|
|
405
|
-
* The message ID extracted from Vqs-Message-Id header
|
|
406
|
-
*/
|
|
407
|
-
messageId: string;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Error thrown when queue callback headers are missing or invalid
|
|
411
|
-
*/
|
|
412
|
-
declare class InvalidCallbackError extends Error {
|
|
413
|
-
constructor(message: string);
|
|
414
|
-
}
|
|
415
356
|
|
|
416
357
|
/**
|
|
417
358
|
* Client for interacting with the Vercel Queue Service API
|
|
@@ -457,7 +398,7 @@ declare class QueueClient {
|
|
|
457
398
|
* @returns AsyncGenerator that yields messages as they arrive
|
|
458
399
|
* @throws {InvalidLimitError} When limit parameter is not between 1 and 10
|
|
459
400
|
* @throws {QueueEmptyError} When no messages are available (204)
|
|
460
|
-
* @throws {MessageLockedError} When
|
|
401
|
+
* @throws {MessageLockedError} When messages are temporarily locked (423)
|
|
461
402
|
* @throws {BadRequestError} When request parameters are invalid
|
|
462
403
|
* @throws {UnauthorizedError} When authentication fails
|
|
463
404
|
* @throws {ForbiddenError} When access is denied (environment mismatch)
|
|
@@ -471,7 +412,6 @@ declare class QueueClient {
|
|
|
471
412
|
* @returns Promise with the message or null if not found/available
|
|
472
413
|
* @throws {MessageNotFoundError} When the message doesn't exist (404)
|
|
473
414
|
* @throws {MessageLockedError} When the message is temporarily locked (423)
|
|
474
|
-
* @throws {FailedDependencyError} When FIFO ordering is violated (424)
|
|
475
415
|
* @throws {MessageNotAvailableError} When message exists but isn't available (409)
|
|
476
416
|
* @throws {MessageCorruptedError} When message data is corrupted
|
|
477
417
|
* @throws {BadRequestError} When request parameters are invalid
|
|
@@ -722,77 +662,85 @@ declare function receive<T = unknown>(topicName: string, consumerGroup: string,
|
|
|
722
662
|
}): Promise<void>;
|
|
723
663
|
|
|
724
664
|
/**
|
|
725
|
-
* Queue Callback utilities for handling incoming webhook payloads
|
|
665
|
+
* Queue Callback utilities for handling incoming webhook payloads from Vercel triggers
|
|
726
666
|
*/
|
|
727
667
|
|
|
728
668
|
/**
|
|
729
|
-
*
|
|
669
|
+
* Configuration object with handlers for different topics and consumer groups
|
|
670
|
+
*/
|
|
671
|
+
type CallbackHandlers = {
|
|
672
|
+
[topicName: string]: {
|
|
673
|
+
[consumerGroup: string]: MessageHandler;
|
|
674
|
+
};
|
|
675
|
+
};
|
|
676
|
+
/**
|
|
677
|
+
* Parsed callback request information
|
|
678
|
+
*/
|
|
679
|
+
type ParsedCallbackRequest = {
|
|
680
|
+
queueName: string;
|
|
681
|
+
consumerGroup: string;
|
|
682
|
+
messageId: string;
|
|
683
|
+
};
|
|
684
|
+
/**
|
|
685
|
+
* Parse and validate callback request headers
|
|
730
686
|
*
|
|
731
|
-
*
|
|
732
|
-
*
|
|
733
|
-
*
|
|
687
|
+
* Extracts queue information from Vercel-provided headers and validates
|
|
688
|
+
* that all required headers are present.
|
|
689
|
+
*
|
|
690
|
+
* @param request The incoming webhook request
|
|
691
|
+
* @returns Parsed queue information
|
|
692
|
+
* @throws Error if required headers are missing
|
|
734
693
|
*
|
|
735
694
|
* @example
|
|
736
695
|
* ```typescript
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
* // In your webhook handler
|
|
696
|
+
* // In Next.js API route
|
|
740
697
|
* export async function POST(request: Request) {
|
|
741
698
|
* try {
|
|
742
|
-
* const
|
|
699
|
+
* const { queueName, consumerGroup, messageId } = parseCallbackRequest(request);
|
|
743
700
|
*
|
|
744
|
-
* // Use
|
|
745
|
-
*
|
|
746
|
-
* ...callbackOptions,
|
|
747
|
-
* visibilityTimeoutSeconds: 30
|
|
748
|
-
* }, transport);
|
|
701
|
+
* // Use the parsed information...
|
|
702
|
+
* await myWorkflow.handleWebhook(queueName, consumerGroup, messageId);
|
|
749
703
|
*
|
|
750
|
-
*
|
|
704
|
+
* return Response.json({ status: "success" });
|
|
751
705
|
* } catch (error) {
|
|
752
|
-
*
|
|
753
|
-
* return new Response('Invalid callback', { status: 400 });
|
|
754
|
-
* }
|
|
755
|
-
* throw error;
|
|
706
|
+
* return Response.json({ error: error.message }, { status: 400 });
|
|
756
707
|
* }
|
|
757
708
|
* }
|
|
758
709
|
* ```
|
|
759
710
|
*/
|
|
760
|
-
declare function parseCallbackRequest(request: Request):
|
|
761
|
-
/**
|
|
762
|
-
* Configuration object with handlers for different topics
|
|
763
|
-
* Each topic can have either:
|
|
764
|
-
* - A single handler function (uses 'default' consumer group)
|
|
765
|
-
* - An object with handlers for specific consumer groups
|
|
766
|
-
*/
|
|
767
|
-
type CallbackHandlers = {
|
|
768
|
-
[topicName: string]: MessageHandler | {
|
|
769
|
-
[consumerGroup: string]: MessageHandler;
|
|
770
|
-
};
|
|
771
|
-
};
|
|
711
|
+
declare function parseCallbackRequest(request: Request): ParsedCallbackRequest;
|
|
772
712
|
/**
|
|
773
|
-
* Simplified queue callback handler for
|
|
713
|
+
* Simplified queue callback handler for Next.js route handlers
|
|
774
714
|
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
715
|
+
* Automatically extracts queue information from Vercel-provided headers
|
|
716
|
+
* and routes to the appropriate handler based on topic and consumer group.
|
|
717
|
+
*
|
|
718
|
+
* @param handlers Object with topic-specific handlers organized by consumer groups
|
|
719
|
+
* @returns A Next.js route handler function
|
|
777
720
|
*
|
|
778
721
|
* @example
|
|
779
722
|
* ```typescript
|
|
780
|
-
* //
|
|
723
|
+
* // Single topic with multiple consumer groups
|
|
781
724
|
* export const POST = handleCallback({
|
|
782
|
-
* "
|
|
783
|
-
* console.log(
|
|
725
|
+
* "image-processing": {
|
|
726
|
+
* "compress": (message, metadata) => console.log("Compressing image", message),
|
|
727
|
+
* "resize": (message, metadata) => console.log("Resizing image", message),
|
|
784
728
|
* }
|
|
785
729
|
* });
|
|
786
730
|
*
|
|
787
|
-
* //
|
|
731
|
+
* // Multiple topics with consumer groups
|
|
788
732
|
* export const POST = handleCallback({
|
|
789
|
-
* "
|
|
790
|
-
* "
|
|
791
|
-
* "
|
|
733
|
+
* "user-events": {
|
|
734
|
+
* "welcome": (user, metadata) => console.log("Welcoming user", user),
|
|
735
|
+
* "analytics": (user, metadata) => console.log("Tracking user", user),
|
|
736
|
+
* },
|
|
737
|
+
* "order-events": {
|
|
738
|
+
* "fulfillment": (order, metadata) => console.log("Fulfilling order", order),
|
|
739
|
+
* "notifications": (order, metadata) => console.log("Notifying order", order),
|
|
792
740
|
* }
|
|
793
741
|
* });
|
|
794
742
|
* ```
|
|
795
743
|
*/
|
|
796
744
|
declare function handleCallback(handlers: CallbackHandlers): (request: Request) => Promise<Response>;
|
|
797
745
|
|
|
798
|
-
export { BadRequestError, BufferTransport, type
|
|
746
|
+
export { BadRequestError, BufferTransport, type ChangeVisibilityOptions, type ChangeVisibilityResponse, type ConsumeOptions, ConsumerGroup, type ConsumerGroupOptions, type DeleteMessageOptions, type DeleteMessageResponse, ForbiddenError, InternalServerError, InvalidLimitError, JsonTransport, type Message, MessageCorruptedError, type MessageHandler, type MessageHandlerResult, MessageLockedError, type MessageMetadata, MessageNotAvailableError, MessageNotFoundError, type MessageTimeoutResult, type ParsedCallbackRequest, type PublishOptions, QueueClient, type QueueClientOptions, QueueEmptyError, type ReceiveMessageByIdOptions, type ReceiveMessageByIdResponse, type ReceiveMessagesOptions, type ReceiveOptions, type SendMessageOptions, type SendMessageResponse, type SendOptions, StreamTransport, Topic, type Transport, UnauthorizedError, createTopic, handleCallback, parseCallbackRequest, receive, send };
|