@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.
@@ -50,7 +50,7 @@ declare class BufferTransport implements Transport<Buffer> {
50
50
  *
51
51
  * IMPORTANT: When using StreamTransport, you must call finalize(payload) when done
52
52
  * processing the message to prevent resource leaks, especially in error cases.
53
- * ConsumerGroup handles this automatically, but direct QueueClient usage requires manual cleanup.
53
+ * ConsumerGroup handles this automatically, but direct Client usage requires manual cleanup.
54
54
  *
55
55
  * Example usage:
56
56
  * ```typescript
@@ -77,6 +77,29 @@ declare class StreamTransport implements Transport<ReadableStream<Uint8Array>> {
77
77
  * Vercel Queue Service client types
78
78
  */
79
79
 
80
+ interface QueueClientOptions {
81
+ /**
82
+ * Base URL for the Vercel Queue Service API
83
+ * Can also be set via VERCEL_QUEUE_BASE_URL environment variable
84
+ * @default "https://vercel-queue.com"
85
+ */
86
+ baseUrl?: string;
87
+ /**
88
+ * Base path for API endpoints
89
+ * Can also be set via VERCEL_QUEUE_BASE_PATH environment variable
90
+ * @default "/api/v2/messages"
91
+ */
92
+ basePath?: string;
93
+ /**
94
+ * Authentication token for the Vercel Queue Service API
95
+ * If not provided, the client will attempt to get a token via OIDC
96
+ */
97
+ token?: string;
98
+ /**
99
+ * Custom headers to include in all requests
100
+ */
101
+ headers?: Record<string, string>;
102
+ }
80
103
  /**
81
104
  * Shared options for publishing messages
82
105
  */
@@ -143,6 +166,79 @@ interface Message<T = unknown> {
143
166
  */
144
167
  ticket: string;
145
168
  }
169
+ interface ReceiveMessagesOptions<T = unknown> {
170
+ /**
171
+ * The queue name to receive messages from
172
+ */
173
+ queueName: string;
174
+ /**
175
+ * Consumer group name
176
+ */
177
+ consumerGroup: string;
178
+ /**
179
+ * Time in seconds that messages will be invisible to other consumers
180
+ * @default 900 (15 minutes)
181
+ */
182
+ visibilityTimeoutSeconds?: number;
183
+ /**
184
+ * Maximum number of messages to retrieve
185
+ * @default 10
186
+ * @max 10
187
+ */
188
+ limit?: number;
189
+ }
190
+ interface DeleteMessageOptions {
191
+ /**
192
+ * The queue name the message belongs to
193
+ */
194
+ queueName: string;
195
+ /**
196
+ * Consumer group name
197
+ */
198
+ consumerGroup: string;
199
+ /**
200
+ * The message ID to delete
201
+ */
202
+ messageId: string;
203
+ /**
204
+ * Ticket received from the message
205
+ */
206
+ ticket: string;
207
+ }
208
+ interface DeleteMessageResponse {
209
+ /**
210
+ * Whether the message was successfully deleted
211
+ */
212
+ deleted: boolean;
213
+ }
214
+ interface ChangeVisibilityOptions {
215
+ /**
216
+ * The queue name the message belongs to
217
+ */
218
+ queueName: string;
219
+ /**
220
+ * Consumer group name
221
+ */
222
+ consumerGroup: string;
223
+ /**
224
+ * The message ID to update
225
+ */
226
+ messageId: string;
227
+ /**
228
+ * Ticket received from the message
229
+ */
230
+ ticket: string;
231
+ /**
232
+ * New visibility timeout in seconds
233
+ */
234
+ visibilityTimeoutSeconds: number;
235
+ }
236
+ interface ChangeVisibilityResponse {
237
+ /**
238
+ * Whether the visibility was successfully updated
239
+ */
240
+ updated: boolean;
241
+ }
146
242
  /**
147
243
  * Result indicating the message should be timed out for retry later
148
244
  */
@@ -190,6 +286,34 @@ interface ConsumerGroupOptions<T = unknown> {
190
286
  */
191
287
  refreshInterval?: number;
192
288
  }
289
+ interface ReceiveMessageByIdOptions<T = unknown> {
290
+ /**
291
+ * The queue name to receive the message from
292
+ */
293
+ queueName: string;
294
+ /**
295
+ * Consumer group name
296
+ */
297
+ consumerGroup: string;
298
+ /**
299
+ * The message ID to retrieve
300
+ */
301
+ messageId: string;
302
+ /**
303
+ * Time in seconds that the message will be invisible to other consumers
304
+ * @default 900 (15 minutes)
305
+ */
306
+ visibilityTimeoutSeconds?: number;
307
+ /**
308
+ * Skip payload content and only return message metadata
309
+ * When true, the server returns a 204 status with headers containing message metadata
310
+ * @default false
311
+ */
312
+ skipPayload?: boolean;
313
+ }
314
+ interface ReceiveMessageByIdResponse<T = unknown, TSkipPayload extends boolean = false> {
315
+ message: TSkipPayload extends true ? Message<void> : Message<T>;
316
+ }
193
317
  /**
194
318
  * Error thrown when a message is not found (404)
195
319
  */
@@ -253,4 +377,4 @@ declare class InvalidLimitError extends Error {
253
377
  constructor(limit: number, min?: number, max?: number);
254
378
  }
255
379
 
256
- export { BufferTransport as B, type ConsumerGroupOptions as C, ForbiddenError as F, InternalServerError as I, JsonTransport as J, type MessageHandler as M, type PublishOptions as P, QueueEmptyError as Q, StreamTransport as S, type Transport as T, UnauthorizedError as U, BadRequestError as a, InvalidLimitError as b, MessageCorruptedError as c, MessageLockedError as d, MessageNotAvailableError as e, MessageNotFoundError as f, type Message as g, type MessageHandlerResult as h, type MessageMetadata as i, type MessageTimeoutResult as j, type SendMessageOptions as k, type SendMessageResponse as l };
380
+ export { BufferTransport as B, type ChangeVisibilityOptions as C, type DeleteMessageOptions as D, ForbiddenError as F, InternalServerError as I, JsonTransport as J, type Message as M, type PublishOptions as P, type QueueClientOptions as Q, type ReceiveMessagesOptions as R, type SendMessageOptions as S, type Transport as T, UnauthorizedError as U, type SendMessageResponse as a, type ReceiveMessageByIdOptions as b, type ReceiveMessageByIdResponse as c, type DeleteMessageResponse as d, type ChangeVisibilityResponse as e, type MessageHandler as f, type ConsumerGroupOptions as g, StreamTransport as h, BadRequestError as i, InvalidLimitError as j, MessageCorruptedError as k, MessageLockedError as l, MessageNotAvailableError as m, MessageNotFoundError as n, QueueEmptyError as o, type MessageHandlerResult as p, type MessageMetadata as q, type MessageTimeoutResult as r };
@@ -50,7 +50,7 @@ declare class BufferTransport implements Transport<Buffer> {
50
50
  *
51
51
  * IMPORTANT: When using StreamTransport, you must call finalize(payload) when done
52
52
  * processing the message to prevent resource leaks, especially in error cases.
53
- * ConsumerGroup handles this automatically, but direct QueueClient usage requires manual cleanup.
53
+ * ConsumerGroup handles this automatically, but direct Client usage requires manual cleanup.
54
54
  *
55
55
  * Example usage:
56
56
  * ```typescript
@@ -77,6 +77,29 @@ declare class StreamTransport implements Transport<ReadableStream<Uint8Array>> {
77
77
  * Vercel Queue Service client types
78
78
  */
79
79
 
80
+ interface QueueClientOptions {
81
+ /**
82
+ * Base URL for the Vercel Queue Service API
83
+ * Can also be set via VERCEL_QUEUE_BASE_URL environment variable
84
+ * @default "https://vercel-queue.com"
85
+ */
86
+ baseUrl?: string;
87
+ /**
88
+ * Base path for API endpoints
89
+ * Can also be set via VERCEL_QUEUE_BASE_PATH environment variable
90
+ * @default "/api/v2/messages"
91
+ */
92
+ basePath?: string;
93
+ /**
94
+ * Authentication token for the Vercel Queue Service API
95
+ * If not provided, the client will attempt to get a token via OIDC
96
+ */
97
+ token?: string;
98
+ /**
99
+ * Custom headers to include in all requests
100
+ */
101
+ headers?: Record<string, string>;
102
+ }
80
103
  /**
81
104
  * Shared options for publishing messages
82
105
  */
@@ -143,6 +166,79 @@ interface Message<T = unknown> {
143
166
  */
144
167
  ticket: string;
145
168
  }
169
+ interface ReceiveMessagesOptions<T = unknown> {
170
+ /**
171
+ * The queue name to receive messages from
172
+ */
173
+ queueName: string;
174
+ /**
175
+ * Consumer group name
176
+ */
177
+ consumerGroup: string;
178
+ /**
179
+ * Time in seconds that messages will be invisible to other consumers
180
+ * @default 900 (15 minutes)
181
+ */
182
+ visibilityTimeoutSeconds?: number;
183
+ /**
184
+ * Maximum number of messages to retrieve
185
+ * @default 10
186
+ * @max 10
187
+ */
188
+ limit?: number;
189
+ }
190
+ interface DeleteMessageOptions {
191
+ /**
192
+ * The queue name the message belongs to
193
+ */
194
+ queueName: string;
195
+ /**
196
+ * Consumer group name
197
+ */
198
+ consumerGroup: string;
199
+ /**
200
+ * The message ID to delete
201
+ */
202
+ messageId: string;
203
+ /**
204
+ * Ticket received from the message
205
+ */
206
+ ticket: string;
207
+ }
208
+ interface DeleteMessageResponse {
209
+ /**
210
+ * Whether the message was successfully deleted
211
+ */
212
+ deleted: boolean;
213
+ }
214
+ interface ChangeVisibilityOptions {
215
+ /**
216
+ * The queue name the message belongs to
217
+ */
218
+ queueName: string;
219
+ /**
220
+ * Consumer group name
221
+ */
222
+ consumerGroup: string;
223
+ /**
224
+ * The message ID to update
225
+ */
226
+ messageId: string;
227
+ /**
228
+ * Ticket received from the message
229
+ */
230
+ ticket: string;
231
+ /**
232
+ * New visibility timeout in seconds
233
+ */
234
+ visibilityTimeoutSeconds: number;
235
+ }
236
+ interface ChangeVisibilityResponse {
237
+ /**
238
+ * Whether the visibility was successfully updated
239
+ */
240
+ updated: boolean;
241
+ }
146
242
  /**
147
243
  * Result indicating the message should be timed out for retry later
148
244
  */
@@ -190,6 +286,34 @@ interface ConsumerGroupOptions<T = unknown> {
190
286
  */
191
287
  refreshInterval?: number;
192
288
  }
289
+ interface ReceiveMessageByIdOptions<T = unknown> {
290
+ /**
291
+ * The queue name to receive the message from
292
+ */
293
+ queueName: string;
294
+ /**
295
+ * Consumer group name
296
+ */
297
+ consumerGroup: string;
298
+ /**
299
+ * The message ID to retrieve
300
+ */
301
+ messageId: string;
302
+ /**
303
+ * Time in seconds that the message will be invisible to other consumers
304
+ * @default 900 (15 minutes)
305
+ */
306
+ visibilityTimeoutSeconds?: number;
307
+ /**
308
+ * Skip payload content and only return message metadata
309
+ * When true, the server returns a 204 status with headers containing message metadata
310
+ * @default false
311
+ */
312
+ skipPayload?: boolean;
313
+ }
314
+ interface ReceiveMessageByIdResponse<T = unknown, TSkipPayload extends boolean = false> {
315
+ message: TSkipPayload extends true ? Message<void> : Message<T>;
316
+ }
193
317
  /**
194
318
  * Error thrown when a message is not found (404)
195
319
  */
@@ -253,4 +377,4 @@ declare class InvalidLimitError extends Error {
253
377
  constructor(limit: number, min?: number, max?: number);
254
378
  }
255
379
 
256
- export { BufferTransport as B, type ConsumerGroupOptions as C, ForbiddenError as F, InternalServerError as I, JsonTransport as J, type MessageHandler as M, type PublishOptions as P, QueueEmptyError as Q, StreamTransport as S, type Transport as T, UnauthorizedError as U, BadRequestError as a, InvalidLimitError as b, MessageCorruptedError as c, MessageLockedError as d, MessageNotAvailableError as e, MessageNotFoundError as f, type Message as g, type MessageHandlerResult as h, type MessageMetadata as i, type MessageTimeoutResult as j, type SendMessageOptions as k, type SendMessageResponse as l };
380
+ export { BufferTransport as B, type ChangeVisibilityOptions as C, type DeleteMessageOptions as D, ForbiddenError as F, InternalServerError as I, JsonTransport as J, type Message as M, type PublishOptions as P, type QueueClientOptions as Q, type ReceiveMessagesOptions as R, type SendMessageOptions as S, type Transport as T, UnauthorizedError as U, type SendMessageResponse as a, type ReceiveMessageByIdOptions as b, type ReceiveMessageByIdResponse as c, type DeleteMessageResponse as d, type ChangeVisibilityResponse as e, type MessageHandler as f, type ConsumerGroupOptions as g, StreamTransport as h, BadRequestError as i, InvalidLimitError as j, MessageCorruptedError as k, MessageLockedError as l, MessageNotAvailableError as m, MessageNotFoundError as n, QueueEmptyError as o, type MessageHandlerResult as p, type MessageMetadata as q, type MessageTimeoutResult as r };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/queue",
3
- "version": "0.0.0-alpha.31",
3
+ "version": "0.0.0-alpha.33",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },