@vercel/queue 0.1.0 → 0.1.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/README.md CHANGED
@@ -19,20 +19,20 @@ npm install @vercel/queue
19
19
 
20
20
  ## Quick Start
21
21
 
22
- **1. Create a shared queue client:**
22
+ **1. Link your Vercel project and pull credentials:**
23
23
 
24
- ```typescript
25
- // lib/queue.ts
26
- import { QueueClient } from "@vercel/queue";
24
+ The SDK authenticates via OIDC. Link your project if you haven't already, then pull to get fresh tokens:
27
25
 
28
- const queue = new QueueClient();
29
- export const { send, handleCallback } = queue;
26
+ ```bash
27
+ npm i -g vercel
28
+ vc link # if you haven't already
29
+ vc env pull
30
30
  ```
31
31
 
32
32
  **2. Send a message anywhere in your app:**
33
33
 
34
34
  ```typescript
35
- import { send } from "@/lib/queue";
35
+ import { send } from "@vercel/queue";
36
36
 
37
37
  await send("my-topic", { message: "Hello world" });
38
38
  ```
@@ -41,7 +41,7 @@ await send("my-topic", { message: "Hello world" });
41
41
 
42
42
  ```typescript
43
43
  // app/api/queue/my-topic/route.ts
44
- import { handleCallback } from "@/lib/queue";
44
+ import { handleCallback } from "@vercel/queue";
45
45
 
46
46
  export const POST = handleCallback(async (message, metadata) => {
47
47
  console.log("Processing:", message);
@@ -60,28 +60,26 @@ export const POST = handleCallback(async (message, metadata) => {
60
60
  }
61
61
  ```
62
62
 
63
- **5. Link your project for local development:**
63
+ That's it. The top-level `send` and `handleCallback` use an auto-configured default client. The region is auto-detected from `VERCEL_REGION` (set automatically on Vercel). If the region can't be detected (e.g. local dev), it falls back to `iad1`.
64
64
 
65
- ```bash
66
- npm i -g vercel
67
- vc link
68
- vc env pull
69
- ```
65
+ To target a specific region for sending, pass the `region` option:
70
66
 
71
- That's it. `new QueueClient()` auto-detects the region from `VERCEL_REGION` (set automatically on Vercel). If the region can't be detected (e.g. local dev), it falls back to `iad1`.
67
+ ```typescript
68
+ await send("my-topic", payload, { region: "sfo1" });
69
+ ```
72
70
 
73
71
  ## Local Development
74
72
 
75
- **Queues just work locally.** When you `send()` messages in development mode, the library sends them to the real Vercel Queue Service, reads your `vercel.json` configuration, discovers your queue handlers, and triggers them automatically via local HTTP requests. This means your local dev environment behaves identically to production no surprising behavior differences.
73
+ **Queues just work locally.** When you `send()` messages in development mode, the library sends them to the real Vercel Queue Service, then invokes your registered `handleCallback` handlers directly in-process using the same code path as production. Your handlers are called with the exact same lifecycle (receive, visibility extension, ack) as in production.
74
+
75
+ Works with Next.js (Turbopack and webpack), Nuxt, SvelteKit, and any framework that runs server-side JavaScript. The SDK automatically discovers handlers from your `vercel.json` configuration and loads route modules on demand — no manual setup required beyond `vercel.json`.
76
76
 
77
- > **Note:** Local dev mode is enabled when `NODE_ENV=development`. Most frameworks (Next.js, etc.) set this automatically during `npm run dev`.
77
+ > **Note:** Local dev mode is enabled when `NODE_ENV=development`. Most frameworks set this automatically during `npm run dev`.
78
78
 
79
79
  ## Publishing Messages
80
80
 
81
81
  ```typescript
82
- import { QueueClient } from "@vercel/queue";
83
-
84
- const { send } = new QueueClient();
82
+ import { send } from "@vercel/queue";
85
83
 
86
84
  // Simple send
87
85
  await send("my-topic", { message: "Hello world" });
@@ -94,6 +92,7 @@ await send(
94
92
  idempotencyKey: "unique-key", // Prevent duplicate messages
95
93
  retentionSeconds: 3600, // 1 hour TTL (default: 24h)
96
94
  delaySeconds: 60, // Delay delivery by 1 minute
95
+ region: "sfo1", // Optional — target a specific region
97
96
  },
98
97
  );
99
98
  ```
@@ -102,7 +101,7 @@ Example usage in an API route:
102
101
 
103
102
  ```typescript
104
103
  // app/api/send-message/route.ts
105
- import { send } from "@/lib/queue";
104
+ import { send } from "@vercel/queue";
106
105
 
107
106
  export async function POST(request: Request) {
108
107
  const body = await request.json();
@@ -127,7 +126,7 @@ Returns `(Request) => Promise<Response>`. For frameworks that export Web API rou
127
126
 
128
127
  ```typescript
129
128
  // app/api/queue/my-topic/route.ts
130
- import { handleCallback } from "@/lib/queue";
129
+ import { handleCallback } from "@vercel/queue";
131
130
 
132
131
  export const POST = handleCallback(async (message, metadata) => {
133
132
  // metadata: { messageId, deliveryCount, createdAt, expiresAt?, topicName, consumerGroup, region }
@@ -136,11 +135,37 @@ export const POST = handleCallback(async (message, metadata) => {
136
135
  });
137
136
  ```
138
137
 
138
+ **Nuxt:**
139
+
140
+ ```typescript
141
+ // server/api/queue.ts
142
+ import { handleCallback } from "@vercel/queue";
143
+
144
+ const handler = handleCallback(async (message, metadata) => {
145
+ await processMessage(message);
146
+ });
147
+
148
+ export default defineEventHandler(async (event) => {
149
+ return handler(toWebRequest(event));
150
+ });
151
+ ```
152
+
153
+ **SvelteKit:**
154
+
155
+ ```typescript
156
+ // src/routes/api/queue/+server.ts
157
+ import { handleCallback } from "@vercel/queue";
158
+
159
+ export const POST = handleCallback(async (message, metadata) => {
160
+ await processMessage(message);
161
+ });
162
+ ```
163
+
139
164
  **Hono:**
140
165
 
141
166
  ```typescript
142
167
  import { Hono } from "hono";
143
- import { handleCallback } from "@/lib/queue";
168
+ import { handleCallback } from "@vercel/queue";
144
169
 
145
170
  const app = new Hono();
146
171
  app.post(
@@ -154,7 +179,26 @@ export default app;
154
179
 
155
180
  #### Connect-style — `handleNodeCallback`
156
181
 
157
- Returns `(req, res) => Promise<void>`. For frameworks that export Connect-style handlers (Express, Next.js Pages Router, etc.).
182
+ Returns `(req, res) => Promise<void>`. For frameworks that export Connect-style handlers (Vercel Node.js functions, Express, Next.js Pages Router, etc.). Requires a `QueueClient` instance:
183
+
184
+ ```typescript
185
+ // lib/queue.ts
186
+ import { QueueClient } from "@vercel/queue";
187
+
188
+ const queue = new QueueClient();
189
+ export const { handleNodeCallback } = queue;
190
+ ```
191
+
192
+ **Vercel Node.js Functions (plain `api/` directory):**
193
+
194
+ ```typescript
195
+ // api/queue.ts
196
+ import { handleNodeCallback } from "./lib/queue";
197
+
198
+ export default handleNodeCallback(async (message, metadata) => {
199
+ await processMessage(message);
200
+ });
201
+ ```
158
202
 
159
203
  **Next.js Pages Router:**
160
204
 
@@ -228,6 +272,8 @@ When a handler throws, the message is not acknowledged and becomes available for
228
272
  For finer control over retry timing, pass a `retry` option:
229
273
 
230
274
  ```typescript
275
+ import { handleCallback } from "@vercel/queue";
276
+
231
277
  export const POST = handleCallback(
232
278
  async (message, metadata) => {
233
279
  await processMessage(message);
@@ -246,6 +292,8 @@ When `retry` returns `{ afterSeconds: N }`, the message is rescheduled for redel
246
292
  **Exponential backoff** uses `metadata.deliveryCount` (starts at 1, increments each delivery):
247
293
 
248
294
  ```typescript
295
+ import { handleCallback } from "@vercel/queue";
296
+
249
297
  export const POST = handleCallback(
250
298
  async (message, metadata) => {
251
299
  await processMessage(message);
@@ -263,6 +311,8 @@ export const POST = handleCallback(
263
311
  **Conditional retry** — only retry transient errors:
264
312
 
265
313
  ```typescript
314
+ import { handleCallback } from "@vercel/queue";
315
+
266
316
  export const POST = handleCallback(
267
317
  async (message, metadata) => {
268
318
  await processMessage(message);
@@ -280,6 +330,8 @@ export const POST = handleCallback(
280
330
  **Acknowledging poison messages** — stop retrying messages that can never succeed:
281
331
 
282
332
  ```typescript
333
+ import { handleCallback } from "@vercel/queue";
334
+
283
335
  export const POST = handleCallback(
284
336
  async (message, metadata) => {
285
337
  await processMessage(message);
@@ -298,6 +350,8 @@ The `retry` option is available on `handleCallback`, `handleNodeCallback`, and `
298
350
 
299
351
  ## Custom Client Configuration
300
352
 
353
+ For most use cases, the top-level `send` and `handleCallback` functions are all you need. For advanced configuration (custom transports, explicit tokens, deployment pinning), create a `QueueClient` instance directly.
354
+
301
355
  ### QueueClient (push mode)
302
356
 
303
357
  For push-based workflows where Vercel delivers messages to your route handlers:
@@ -445,8 +499,8 @@ import {
445
499
  ForbiddenError,
446
500
  InternalServerError,
447
501
  UnauthorizedError,
502
+ send,
448
503
  } from "@vercel/queue";
449
- import { send } from "@/lib/queue";
450
504
 
451
505
  try {
452
506
  await send("my-topic", payload);
@@ -549,9 +603,49 @@ All error types:
549
603
 
550
604
  ## API Reference
551
605
 
606
+ ### Top-level `send(topicName, payload, options?)`
607
+
608
+ The simplest way to send a message. Uses an auto-configured default client that detects the region from `VERCEL_REGION`, falling back to `"iad1"` with a console warning on first use.
609
+
610
+ ```typescript
611
+ import { send } from "@vercel/queue";
612
+
613
+ const { messageId } = await send("my-topic", payload, {
614
+ idempotencyKey: "unique-key", // Dedup window: min(retention, 24h)
615
+ retentionSeconds: 3600, // Message TTL (default: 86400)
616
+ delaySeconds: 60, // Delay before visible (default: 0)
617
+ headers: { "X-Custom": "val" }, // Custom headers
618
+ region: "sfo1", // Optional — target a specific region
619
+ });
620
+ ```
621
+
622
+ Returns `{ messageId: string | null }`. `messageId` is `null` when the server accepted the message for deferred processing (e.g. during a server-side outage).
623
+
624
+ ### Top-level `handleCallback(handler, options?)`
625
+
626
+ The simplest way to handle incoming queue messages. Uses the same auto-configured default client as `send`.
627
+
628
+ ```typescript
629
+ import { handleCallback } from "@vercel/queue";
630
+
631
+ export const POST = handleCallback(
632
+ async (message, metadata) => {
633
+ await processMessage(message);
634
+ },
635
+ {
636
+ visibilityTimeoutSeconds: 300, // Lock duration (default: 300)
637
+ retry: (error, metadata) => {
638
+ // Optional: return { afterSeconds: N } to reschedule, { acknowledge: true } to ack, or undefined to propagate
639
+ },
640
+ },
641
+ );
642
+ ```
643
+
644
+ Returns `(request: Request) => Promise<Response>` — for frameworks that export Web API route handlers. Vercel only. The region for follow-up API calls is determined automatically from the `ce-vqsregion` header in the incoming event.
645
+
552
646
  ### `QueueClient`
553
647
 
554
- Push-based client for workflows where Vercel delivers messages to your route handlers. Region is auto-detected from `VERCEL_REGION` (set automatically on Vercel), falling back to `"iad1"` with a console warning.
648
+ Push-based client for workflows where Vercel delivers messages to your route handlers. Use this when you need custom configuration (transport, token, headers, deployment pinning). Region is auto-detected from `VERCEL_REGION` (set automatically on Vercel), falling back to `"iad1"` with a console warning.
555
649
 
556
650
  ```typescript
557
651
  import { QueueClient } from "@vercel/queue";
@@ -585,21 +679,6 @@ const queue = new PollingQueueClient({
585
679
  const { send, receive } = queue;
586
680
  ```
587
681
 
588
- ### `send(topicName, payload, options?)`
589
-
590
- Available on both `QueueClient` and `PollingQueueClient`.
591
-
592
- Returns `{ messageId: string | null }`. `messageId` is `null` when the server accepted the message for deferred processing (e.g. during a server-side outage).
593
-
594
- ```typescript
595
- const { messageId } = await send("my-topic", payload, {
596
- idempotencyKey: "unique-key", // Dedup window: min(retention, 24h)
597
- retentionSeconds: 3600, // Message TTL (default: 86400)
598
- delaySeconds: 60, // Delay before visible (default: 0)
599
- headers: { "X-Custom": "val" }, // Custom headers
600
- });
601
- ```
602
-
603
682
  ### `receive(topicName, consumerGroup, handler, options?)`
604
683
 
605
684
  Available on `PollingQueueClient` only.
@@ -626,26 +705,6 @@ const result = await receive("my-topic", "my-group", handler, {
626
705
  });
627
706
  ```
628
707
 
629
- ### `handleCallback(handler, options?)`
630
-
631
- Available on `QueueClient` only. Vercel only.
632
-
633
- Returns `(request: Request) => Promise<Response>` — for frameworks that export Web API route handlers.
634
-
635
- ```typescript
636
- export const POST = handleCallback(
637
- async (message, metadata) => {
638
- await processMessage(message);
639
- },
640
- {
641
- visibilityTimeoutSeconds: 300, // Lock duration (default: 300)
642
- retry: (error, metadata) => {
643
- // Optional: return { afterSeconds: N } to reschedule, { acknowledge: true } to ack, or undefined to propagate
644
- },
645
- },
646
- );
647
- ```
648
-
649
708
  ### `handleNodeCallback(handler, options?)`
650
709
 
651
710
  Available on `QueueClient` only. Vercel only.
@@ -653,6 +712,11 @@ Available on `QueueClient` only. Vercel only.
653
712
  Returns `(req, res) => Promise<void>` — for frameworks that export Connect-style handlers.
654
713
 
655
714
  ```typescript
715
+ import { QueueClient } from "@vercel/queue";
716
+
717
+ const queue = new QueueClient();
718
+ const { handleNodeCallback } = queue;
719
+
656
720
  // pages/api/queue/my-topic.ts
657
721
  export default handleNodeCallback(
658
722
  async (message, metadata) => {
package/dist/index.d.mts CHANGED
@@ -519,6 +519,9 @@ declare class ConsumerRegistryNotConfiguredError extends Error {
519
519
  constructor(message?: string);
520
520
  }
521
521
 
522
+ type CallbackRequestInput$1 = Request | {
523
+ request: Request;
524
+ };
522
525
  /**
523
526
  * Queue client for push-based (callback) workflows.
524
527
  *
@@ -577,12 +580,12 @@ declare class QueueClient {
577
580
  * @param options.visibilityTimeoutSeconds - Message lock duration (default: 300, max: 3600)
578
581
  * @param options.retry - Called when the handler throws. Return `{ afterSeconds: N }` to
579
582
  * reschedule the message for redelivery after N seconds.
580
- * @returns A `(request: Request) => Promise<Response>` route handler
583
+ * @returns A route handler that accepts either `Request` or `{ request: Request }`
581
584
  */
582
585
  handleCallback: <T = unknown>(handler: MessageHandler<T>, options?: {
583
586
  visibilityTimeoutSeconds?: number;
584
587
  retry?: RetryHandler;
585
- }) => ((request: Request) => Promise<Response>);
588
+ }) => ((requestOrEvent: CallbackRequestInput$1) => Promise<Response>);
586
589
  /**
587
590
  * Create a Connect-style route handler for processing queue callback messages.
588
591
  * For use on Vercel — Vercel invokes this route when messages are available.
@@ -680,6 +683,58 @@ declare class PollingQueueClient {
680
683
  receive: <T = unknown>(topicName: string, consumerGroup: string, handler: MessageHandler<T>, options?: ReceiveOptions) => Promise<ReceiveResult>;
681
684
  }
682
685
 
686
+ type CallbackRequestInput = Request | {
687
+ request: Request;
688
+ };
689
+ /**
690
+ * Send a message to a topic using the default auto-configured client.
691
+ *
692
+ * The default client auto-detects the region from `VERCEL_REGION`,
693
+ * falling back to `"iad1"` with a console warning on first use.
694
+ *
695
+ * This is an arrow function–free alternative to destructuring from a
696
+ * {@link QueueClient} instance — import and use directly:
697
+ * ```typescript
698
+ * import { send } from "@vercel/queue";
699
+ * await send("my-topic", { hello: "world" });
700
+ * ```
701
+ *
702
+ * @param topicName - Name of the topic (pattern: `[A-Za-z0-9_-]+`)
703
+ * @param payload - The data to send (serialized via JsonTransport)
704
+ * @param options - Optional send options. Pass `region` to route to a specific region.
705
+ * @returns `{ messageId }` — `messageId` is `null` when the server accepted
706
+ * the message for deferred processing
707
+ */
708
+ declare function send<T = unknown>(topicName: string, payload: T, options?: SendOptions & {
709
+ region?: VercelRegion;
710
+ }): Promise<SendResult>;
711
+ /**
712
+ * Create a Web API route handler for processing queue callback messages
713
+ * using the default auto-configured client.
714
+ *
715
+ * The default client auto-detects the region from `VERCEL_REGION`,
716
+ * falling back to `"iad1"` with a console warning on first use.
717
+ * The callback region is determined automatically from the incoming
718
+ * `ce-vqsregion` header in the v2beta event — no manual configuration needed.
719
+ *
720
+ * This is an arrow function–free alternative to destructuring from a
721
+ * {@link QueueClient} instance — import and use directly:
722
+ * ```typescript
723
+ * import { handleCallback } from "@vercel/queue";
724
+ * export const POST = handleCallback(async (message, metadata) => {
725
+ * console.log("Processing:", message);
726
+ * });
727
+ * ```
728
+ *
729
+ * @param handler - Function to process the message payload and metadata
730
+ * @param options - Optional configuration (visibilityTimeoutSeconds, retry)
731
+ * @returns A route handler that accepts either `Request` or `{ request: Request }`
732
+ */
733
+ declare function handleCallback<T = unknown>(handler: MessageHandler<T>, options?: {
734
+ visibilityTimeoutSeconds?: number;
735
+ retry?: RetryHandler;
736
+ }): (requestOrEvent: CallbackRequestInput) => Promise<Response>;
737
+
683
738
  /**
684
739
  * Core queue callback utilities for handling incoming webhook payloads
685
740
  * from Vercel triggers using the CloudEvent specification.
@@ -753,4 +808,4 @@ declare function parseRawCallback(body: unknown, headers: Record<string, string
753
808
  */
754
809
  declare function parseCallback(request: Request): Promise<ParsedCallbackRequest>;
755
810
 
756
- export { BadRequestError, type BaseUrlResolver, BufferTransport, CLOUD_EVENT_TYPE_V1BETA, CLOUD_EVENT_TYPE_V2BETA, ConsumerDiscoveryError, ConsumerRegistryNotConfiguredError, DuplicateMessageError, ForbiddenError, InternalServerError, InvalidLimitError, JsonTransport, type Message, MessageAlreadyProcessedError, MessageCorruptedError, type MessageHandler, MessageLockedError, type MessageMetadata, MessageNotAvailableError, MessageNotFoundError, type ParsedCallbackRequest, type ParsedCallbackV1, type ParsedCallbackV2, PollingQueueClient, type PollingQueueClientOptions, QueueClient, type QueueClientOptions, QueueEmptyError, type ReceiveBatchOptions, type ReceiveByIdOptions, type ReceiveOptions, type ReceiveResult, type RetryDirective, type RetryHandler, type SendOptions, type SendResult, StreamTransport, type Transport, UnauthorizedError, type VercelRegion, parseCallback, parseRawCallback };
811
+ export { BadRequestError, type BaseUrlResolver, BufferTransport, CLOUD_EVENT_TYPE_V1BETA, CLOUD_EVENT_TYPE_V2BETA, ConsumerDiscoveryError, ConsumerRegistryNotConfiguredError, DuplicateMessageError, ForbiddenError, InternalServerError, InvalidLimitError, JsonTransport, type Message, MessageAlreadyProcessedError, MessageCorruptedError, type MessageHandler, MessageLockedError, type MessageMetadata, MessageNotAvailableError, MessageNotFoundError, type ParsedCallbackRequest, type ParsedCallbackV1, type ParsedCallbackV2, PollingQueueClient, type PollingQueueClientOptions, QueueClient, type QueueClientOptions, QueueEmptyError, type ReceiveBatchOptions, type ReceiveByIdOptions, type ReceiveOptions, type ReceiveResult, type RetryDirective, type RetryHandler, type SendOptions, type SendResult, StreamTransport, type Transport, UnauthorizedError, type VercelRegion, handleCallback, parseCallback, parseRawCallback, send };
package/dist/index.d.ts CHANGED
@@ -519,6 +519,9 @@ declare class ConsumerRegistryNotConfiguredError extends Error {
519
519
  constructor(message?: string);
520
520
  }
521
521
 
522
+ type CallbackRequestInput$1 = Request | {
523
+ request: Request;
524
+ };
522
525
  /**
523
526
  * Queue client for push-based (callback) workflows.
524
527
  *
@@ -577,12 +580,12 @@ declare class QueueClient {
577
580
  * @param options.visibilityTimeoutSeconds - Message lock duration (default: 300, max: 3600)
578
581
  * @param options.retry - Called when the handler throws. Return `{ afterSeconds: N }` to
579
582
  * reschedule the message for redelivery after N seconds.
580
- * @returns A `(request: Request) => Promise<Response>` route handler
583
+ * @returns A route handler that accepts either `Request` or `{ request: Request }`
581
584
  */
582
585
  handleCallback: <T = unknown>(handler: MessageHandler<T>, options?: {
583
586
  visibilityTimeoutSeconds?: number;
584
587
  retry?: RetryHandler;
585
- }) => ((request: Request) => Promise<Response>);
588
+ }) => ((requestOrEvent: CallbackRequestInput$1) => Promise<Response>);
586
589
  /**
587
590
  * Create a Connect-style route handler for processing queue callback messages.
588
591
  * For use on Vercel — Vercel invokes this route when messages are available.
@@ -680,6 +683,58 @@ declare class PollingQueueClient {
680
683
  receive: <T = unknown>(topicName: string, consumerGroup: string, handler: MessageHandler<T>, options?: ReceiveOptions) => Promise<ReceiveResult>;
681
684
  }
682
685
 
686
+ type CallbackRequestInput = Request | {
687
+ request: Request;
688
+ };
689
+ /**
690
+ * Send a message to a topic using the default auto-configured client.
691
+ *
692
+ * The default client auto-detects the region from `VERCEL_REGION`,
693
+ * falling back to `"iad1"` with a console warning on first use.
694
+ *
695
+ * This is an arrow function–free alternative to destructuring from a
696
+ * {@link QueueClient} instance — import and use directly:
697
+ * ```typescript
698
+ * import { send } from "@vercel/queue";
699
+ * await send("my-topic", { hello: "world" });
700
+ * ```
701
+ *
702
+ * @param topicName - Name of the topic (pattern: `[A-Za-z0-9_-]+`)
703
+ * @param payload - The data to send (serialized via JsonTransport)
704
+ * @param options - Optional send options. Pass `region` to route to a specific region.
705
+ * @returns `{ messageId }` — `messageId` is `null` when the server accepted
706
+ * the message for deferred processing
707
+ */
708
+ declare function send<T = unknown>(topicName: string, payload: T, options?: SendOptions & {
709
+ region?: VercelRegion;
710
+ }): Promise<SendResult>;
711
+ /**
712
+ * Create a Web API route handler for processing queue callback messages
713
+ * using the default auto-configured client.
714
+ *
715
+ * The default client auto-detects the region from `VERCEL_REGION`,
716
+ * falling back to `"iad1"` with a console warning on first use.
717
+ * The callback region is determined automatically from the incoming
718
+ * `ce-vqsregion` header in the v2beta event — no manual configuration needed.
719
+ *
720
+ * This is an arrow function–free alternative to destructuring from a
721
+ * {@link QueueClient} instance — import and use directly:
722
+ * ```typescript
723
+ * import { handleCallback } from "@vercel/queue";
724
+ * export const POST = handleCallback(async (message, metadata) => {
725
+ * console.log("Processing:", message);
726
+ * });
727
+ * ```
728
+ *
729
+ * @param handler - Function to process the message payload and metadata
730
+ * @param options - Optional configuration (visibilityTimeoutSeconds, retry)
731
+ * @returns A route handler that accepts either `Request` or `{ request: Request }`
732
+ */
733
+ declare function handleCallback<T = unknown>(handler: MessageHandler<T>, options?: {
734
+ visibilityTimeoutSeconds?: number;
735
+ retry?: RetryHandler;
736
+ }): (requestOrEvent: CallbackRequestInput) => Promise<Response>;
737
+
683
738
  /**
684
739
  * Core queue callback utilities for handling incoming webhook payloads
685
740
  * from Vercel triggers using the CloudEvent specification.
@@ -753,4 +808,4 @@ declare function parseRawCallback(body: unknown, headers: Record<string, string
753
808
  */
754
809
  declare function parseCallback(request: Request): Promise<ParsedCallbackRequest>;
755
810
 
756
- export { BadRequestError, type BaseUrlResolver, BufferTransport, CLOUD_EVENT_TYPE_V1BETA, CLOUD_EVENT_TYPE_V2BETA, ConsumerDiscoveryError, ConsumerRegistryNotConfiguredError, DuplicateMessageError, ForbiddenError, InternalServerError, InvalidLimitError, JsonTransport, type Message, MessageAlreadyProcessedError, MessageCorruptedError, type MessageHandler, MessageLockedError, type MessageMetadata, MessageNotAvailableError, MessageNotFoundError, type ParsedCallbackRequest, type ParsedCallbackV1, type ParsedCallbackV2, PollingQueueClient, type PollingQueueClientOptions, QueueClient, type QueueClientOptions, QueueEmptyError, type ReceiveBatchOptions, type ReceiveByIdOptions, type ReceiveOptions, type ReceiveResult, type RetryDirective, type RetryHandler, type SendOptions, type SendResult, StreamTransport, type Transport, UnauthorizedError, type VercelRegion, parseCallback, parseRawCallback };
811
+ export { BadRequestError, type BaseUrlResolver, BufferTransport, CLOUD_EVENT_TYPE_V1BETA, CLOUD_EVENT_TYPE_V2BETA, ConsumerDiscoveryError, ConsumerRegistryNotConfiguredError, DuplicateMessageError, ForbiddenError, InternalServerError, InvalidLimitError, JsonTransport, type Message, MessageAlreadyProcessedError, MessageCorruptedError, type MessageHandler, MessageLockedError, type MessageMetadata, MessageNotAvailableError, MessageNotFoundError, type ParsedCallbackRequest, type ParsedCallbackV1, type ParsedCallbackV2, PollingQueueClient, type PollingQueueClientOptions, QueueClient, type QueueClientOptions, QueueEmptyError, type ReceiveBatchOptions, type ReceiveByIdOptions, type ReceiveOptions, type ReceiveResult, type RetryDirective, type RetryHandler, type SendOptions, type SendResult, StreamTransport, type Transport, UnauthorizedError, type VercelRegion, handleCallback, parseCallback, parseRawCallback, send };