@upstash/qstash 2.4.2 → 2.5.0

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 CHANGED
@@ -201,6 +201,47 @@ declare class DLQ {
201
201
  }>;
202
202
  }
203
203
 
204
+ type QueueResponse = {
205
+ createdAt: number;
206
+ updatedAt: number;
207
+ name: string;
208
+ parallelism: number;
209
+ lag: number;
210
+ };
211
+ type UpsertQueueRequest = {
212
+ parallelism: number;
213
+ };
214
+ type EnqueueRequest = PublishRequest;
215
+ declare class Queue {
216
+ private readonly http;
217
+ private readonly queueName;
218
+ constructor(http: Requester, queueName?: string);
219
+ /**
220
+ * Create or update the queue
221
+ */
222
+ upsert(req: UpsertQueueRequest): Promise<void>;
223
+ /**
224
+ * Get the queue details
225
+ */
226
+ get(): Promise<QueueResponse>;
227
+ /**
228
+ * List queues
229
+ */
230
+ list(): Promise<QueueResponse[]>;
231
+ /**
232
+ * Delete the queue
233
+ */
234
+ delete(): Promise<void>;
235
+ /**
236
+ * Enqueue a message to a queue.
237
+ */
238
+ enqueue(req: EnqueueRequest): Promise<PublishResponse<PublishRequest>>;
239
+ /**
240
+ * Enqueue a message to a queue, serializing the body to JSON.
241
+ */
242
+ enqueueJSON<TBody = unknown>(req: PublishRequest<TBody>): Promise<PublishResponse<PublishRequest<TBody>>>;
243
+ }
244
+
204
245
  type Schedule = {
205
246
  scheduleId: string;
206
247
  cron: string;
@@ -469,9 +510,10 @@ type PublishRequest<TBody = BodyInit> = {
469
510
  * In case your destination server is unavaialble or returns a status code outside of the 200-299
470
511
  * range, we will retry the request after a certain amount of time.
471
512
  *
472
- * Configure how many times you would like the delivery to be retried
513
+ * Configure how many times you would like the delivery to be retried up to the maxRetries limit
514
+ * defined in your plan.
473
515
  *
474
- * @default The maximum retry quota associated with your account.
516
+ * @default 3
475
517
  */
476
518
  retries?: number;
477
519
  /**
@@ -518,11 +560,26 @@ type PublishJsonRequest = Omit<PublishRequest, "body"> & {
518
560
  };
519
561
  type EventsRequest = {
520
562
  cursor?: number;
563
+ filter?: EventsRequestFilter;
564
+ };
565
+ type EventsRequestFilter = {
566
+ messageId?: string;
567
+ state?: State;
568
+ url?: string;
569
+ topicName?: string;
570
+ scheduleId?: string;
571
+ queueName?: string;
572
+ fromDate?: number;
573
+ toDate?: number;
574
+ count?: number;
521
575
  };
522
576
  type GetEventsResponse = {
523
577
  cursor?: number;
524
578
  events: Event[];
525
579
  };
580
+ type QueueRequest = {
581
+ queueName?: string;
582
+ };
526
583
  declare class Client {
527
584
  http: Requester;
528
585
  constructor(config: ClientConfig);
@@ -550,7 +607,12 @@ declare class Client {
550
607
  * Create, read or delete schedules.
551
608
  */
552
609
  get schedules(): Schedules;
553
- private processHeaders;
610
+ /**
611
+ * Access the queue API.
612
+ *
613
+ * Create, read, update or delete queues.
614
+ */
615
+ queue(req?: QueueRequest): Queue;
554
616
  publish<TRequest extends PublishRequest>(req: TRequest): Promise<PublishResponse<TRequest>>;
555
617
  /**
556
618
  * publishJSON is a utility wrapper around `publish` that automatically serializes the body
@@ -560,11 +622,11 @@ declare class Client {
560
622
  /**
561
623
  * Batch publish messages to QStash.
562
624
  */
563
- batch(req: PublishRequest[]): Promise<(PublishToUrlResponse | PublishToTopicResponse)[]>;
625
+ batch(req: PublishRequest[]): Promise<PublishResponse<PublishRequest>[]>;
564
626
  /**
565
627
  * Batch publish messages to QStash, serializing each body to JSON.
566
628
  */
567
- batchJSON<TBody = unknown, TRequest extends PublishRequest<TBody> = PublishRequest<TBody>>(req: TRequest[]): Promise<(PublishToUrlResponse | PublishToTopicResponse)[]>;
629
+ batchJSON<TBody = unknown, TRequest extends PublishRequest<TBody> = PublishRequest<TBody>>(req: TRequest[]): Promise<PublishResponse<TRequest>[]>;
568
630
  /**
569
631
  * Retrieve your logs.
570
632
  *
@@ -606,4 +668,4 @@ declare class QstashRatelimitError extends QstashError {
606
668
  constructor(args: unknown);
607
669
  }
608
670
 
609
- export { AddEndpointsRequest, Client, CreateScheduleRequest, Endpoint, Event, EventsRequest, GetEventsResponse, Message, Messages, PublishJsonRequest, PublishRequest, QstashError, QstashRatelimitError, Receiver, ReceiverConfig, RemoveEndpointsRequest, Schedule, Schedules, SignatureError, State, Topic, Topics, VerifyRequest, WithCursor };
671
+ export { AddEndpointsRequest, Client, CreateScheduleRequest, Endpoint, Event, EventsRequest, GetEventsResponse, Message, Messages, PublishJsonRequest, PublishRequest, PublishResponse, PublishToTopicResponse, PublishToUrlResponse, QstashError, QstashRatelimitError, QueueRequest, Receiver, ReceiverConfig, RemoveEndpointsRequest, Schedule, Schedules, SignatureError, State, Topic, Topics, VerifyRequest, WithCursor };
package/dist/index.d.ts CHANGED
@@ -201,6 +201,47 @@ declare class DLQ {
201
201
  }>;
202
202
  }
203
203
 
204
+ type QueueResponse = {
205
+ createdAt: number;
206
+ updatedAt: number;
207
+ name: string;
208
+ parallelism: number;
209
+ lag: number;
210
+ };
211
+ type UpsertQueueRequest = {
212
+ parallelism: number;
213
+ };
214
+ type EnqueueRequest = PublishRequest;
215
+ declare class Queue {
216
+ private readonly http;
217
+ private readonly queueName;
218
+ constructor(http: Requester, queueName?: string);
219
+ /**
220
+ * Create or update the queue
221
+ */
222
+ upsert(req: UpsertQueueRequest): Promise<void>;
223
+ /**
224
+ * Get the queue details
225
+ */
226
+ get(): Promise<QueueResponse>;
227
+ /**
228
+ * List queues
229
+ */
230
+ list(): Promise<QueueResponse[]>;
231
+ /**
232
+ * Delete the queue
233
+ */
234
+ delete(): Promise<void>;
235
+ /**
236
+ * Enqueue a message to a queue.
237
+ */
238
+ enqueue(req: EnqueueRequest): Promise<PublishResponse<PublishRequest>>;
239
+ /**
240
+ * Enqueue a message to a queue, serializing the body to JSON.
241
+ */
242
+ enqueueJSON<TBody = unknown>(req: PublishRequest<TBody>): Promise<PublishResponse<PublishRequest<TBody>>>;
243
+ }
244
+
204
245
  type Schedule = {
205
246
  scheduleId: string;
206
247
  cron: string;
@@ -469,9 +510,10 @@ type PublishRequest<TBody = BodyInit> = {
469
510
  * In case your destination server is unavaialble or returns a status code outside of the 200-299
470
511
  * range, we will retry the request after a certain amount of time.
471
512
  *
472
- * Configure how many times you would like the delivery to be retried
513
+ * Configure how many times you would like the delivery to be retried up to the maxRetries limit
514
+ * defined in your plan.
473
515
  *
474
- * @default The maximum retry quota associated with your account.
516
+ * @default 3
475
517
  */
476
518
  retries?: number;
477
519
  /**
@@ -518,11 +560,26 @@ type PublishJsonRequest = Omit<PublishRequest, "body"> & {
518
560
  };
519
561
  type EventsRequest = {
520
562
  cursor?: number;
563
+ filter?: EventsRequestFilter;
564
+ };
565
+ type EventsRequestFilter = {
566
+ messageId?: string;
567
+ state?: State;
568
+ url?: string;
569
+ topicName?: string;
570
+ scheduleId?: string;
571
+ queueName?: string;
572
+ fromDate?: number;
573
+ toDate?: number;
574
+ count?: number;
521
575
  };
522
576
  type GetEventsResponse = {
523
577
  cursor?: number;
524
578
  events: Event[];
525
579
  };
580
+ type QueueRequest = {
581
+ queueName?: string;
582
+ };
526
583
  declare class Client {
527
584
  http: Requester;
528
585
  constructor(config: ClientConfig);
@@ -550,7 +607,12 @@ declare class Client {
550
607
  * Create, read or delete schedules.
551
608
  */
552
609
  get schedules(): Schedules;
553
- private processHeaders;
610
+ /**
611
+ * Access the queue API.
612
+ *
613
+ * Create, read, update or delete queues.
614
+ */
615
+ queue(req?: QueueRequest): Queue;
554
616
  publish<TRequest extends PublishRequest>(req: TRequest): Promise<PublishResponse<TRequest>>;
555
617
  /**
556
618
  * publishJSON is a utility wrapper around `publish` that automatically serializes the body
@@ -560,11 +622,11 @@ declare class Client {
560
622
  /**
561
623
  * Batch publish messages to QStash.
562
624
  */
563
- batch(req: PublishRequest[]): Promise<(PublishToUrlResponse | PublishToTopicResponse)[]>;
625
+ batch(req: PublishRequest[]): Promise<PublishResponse<PublishRequest>[]>;
564
626
  /**
565
627
  * Batch publish messages to QStash, serializing each body to JSON.
566
628
  */
567
- batchJSON<TBody = unknown, TRequest extends PublishRequest<TBody> = PublishRequest<TBody>>(req: TRequest[]): Promise<(PublishToUrlResponse | PublishToTopicResponse)[]>;
629
+ batchJSON<TBody = unknown, TRequest extends PublishRequest<TBody> = PublishRequest<TBody>>(req: TRequest[]): Promise<PublishResponse<TRequest>[]>;
568
630
  /**
569
631
  * Retrieve your logs.
570
632
  *
@@ -606,4 +668,4 @@ declare class QstashRatelimitError extends QstashError {
606
668
  constructor(args: unknown);
607
669
  }
608
670
 
609
- export { AddEndpointsRequest, Client, CreateScheduleRequest, Endpoint, Event, EventsRequest, GetEventsResponse, Message, Messages, PublishJsonRequest, PublishRequest, QstashError, QstashRatelimitError, Receiver, ReceiverConfig, RemoveEndpointsRequest, Schedule, Schedules, SignatureError, State, Topic, Topics, VerifyRequest, WithCursor };
671
+ export { AddEndpointsRequest, Client, CreateScheduleRequest, Endpoint, Event, EventsRequest, GetEventsResponse, Message, Messages, PublishJsonRequest, PublishRequest, PublishResponse, PublishToTopicResponse, PublishToUrlResponse, QstashError, QstashRatelimitError, QueueRequest, Receiver, ReceiverConfig, RemoveEndpointsRequest, Schedule, Schedules, SignatureError, State, Topic, Topics, VerifyRequest, WithCursor };
package/dist/index.js CHANGED
@@ -183,6 +183,138 @@ function prefixHeaders(headers) {
183
183
  }
184
184
  return headers;
185
185
  }
186
+ function processHeaders(req) {
187
+ var _a;
188
+ const headers = prefixHeaders(new Headers(req.headers));
189
+ headers.set("Upstash-Method", (_a = req.method) != null ? _a : "POST");
190
+ if (typeof req.delay !== "undefined") {
191
+ headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
192
+ }
193
+ if (typeof req.notBefore !== "undefined") {
194
+ headers.set("Upstash-Not-Before", req.notBefore.toFixed());
195
+ }
196
+ if (typeof req.deduplicationId !== "undefined") {
197
+ headers.set("Upstash-Deduplication-Id", req.deduplicationId);
198
+ }
199
+ if (typeof req.contentBasedDeduplication !== "undefined") {
200
+ headers.set("Upstash-Content-Based-Deduplication", "true");
201
+ }
202
+ if (typeof req.retries !== "undefined") {
203
+ headers.set("Upstash-Retries", req.retries.toFixed());
204
+ }
205
+ if (typeof req.callback !== "undefined") {
206
+ headers.set("Upstash-Callback", req.callback);
207
+ }
208
+ if (typeof req.failureCallback !== "undefined") {
209
+ headers.set("Upstash-Failure-Callback", req.failureCallback);
210
+ }
211
+ return headers;
212
+ }
213
+
214
+ // src/client/queue.ts
215
+ var Queue = class {
216
+ constructor(http, queueName) {
217
+ this.http = http;
218
+ this.queueName = queueName;
219
+ }
220
+ /**
221
+ * Create or update the queue
222
+ */
223
+ upsert(req) {
224
+ return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
225
+ if (!this.queueName) {
226
+ throw new Error("Please provide a queue name to the Queue constructor");
227
+ }
228
+ const body = {
229
+ queueName: this.queueName,
230
+ parallelism: req.parallelism
231
+ };
232
+ yield this.http.request({
233
+ method: "POST",
234
+ path: ["v2", "queues"],
235
+ headers: {
236
+ "Content-Type": "application/json"
237
+ },
238
+ body: JSON.stringify(body),
239
+ parseResponseAsJson: false
240
+ });
241
+ });
242
+ }
243
+ /**
244
+ * Get the queue details
245
+ */
246
+ get() {
247
+ return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
248
+ if (!this.queueName) {
249
+ throw new Error("Please provide a queue name to the Queue constructor");
250
+ }
251
+ return yield this.http.request({
252
+ method: "GET",
253
+ path: ["v2", "queues", this.queueName]
254
+ });
255
+ });
256
+ }
257
+ /**
258
+ * List queues
259
+ */
260
+ list() {
261
+ return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
262
+ return yield this.http.request({
263
+ method: "GET",
264
+ path: ["v2", "queues"]
265
+ });
266
+ });
267
+ }
268
+ /**
269
+ * Delete the queue
270
+ */
271
+ delete() {
272
+ return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
273
+ if (!this.queueName) {
274
+ throw new Error("Please provide a queue name to the Queue constructor");
275
+ }
276
+ yield this.http.request({
277
+ method: "DELETE",
278
+ path: ["v2", "queues", this.queueName],
279
+ parseResponseAsJson: false
280
+ });
281
+ });
282
+ }
283
+ /**
284
+ * Enqueue a message to a queue.
285
+ */
286
+ enqueue(req) {
287
+ return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
288
+ var _a;
289
+ if (!this.queueName) {
290
+ throw new Error("Please provide a queue name to the Queue constructor");
291
+ }
292
+ const headers = processHeaders(req);
293
+ const destination = (_a = req.url) != null ? _a : req.topic;
294
+ const res = yield this.http.request({
295
+ path: ["v2", "enqueue", this.queueName, destination],
296
+ body: req.body,
297
+ headers,
298
+ method: "POST"
299
+ });
300
+ return res;
301
+ });
302
+ }
303
+ /**
304
+ * Enqueue a message to a queue, serializing the body to JSON.
305
+ */
306
+ enqueueJSON(req) {
307
+ return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
308
+ const headers = prefixHeaders(new Headers(req.headers));
309
+ headers.set("Content-Type", "application/json");
310
+ const res = yield this.enqueue(_chunkEROSIHWEjs.__spreadProps.call(void 0, _chunkEROSIHWEjs.__spreadValues.call(void 0, {}, req), {
311
+ body: JSON.stringify(req.body),
312
+ headers
313
+ }));
314
+ return res;
315
+ });
316
+ }
317
+ };
186
318
 
187
319
  // src/client/schedules.ts
188
320
  var Schedules = class {
@@ -368,37 +500,18 @@ var Client = class {
368
500
  get schedules() {
369
501
  return new Schedules(this.http);
370
502
  }
371
- processHeaders(req) {
372
- var _a;
373
- const headers = prefixHeaders(new Headers(req.headers));
374
- headers.set("Upstash-Method", (_a = req.method) != null ? _a : "POST");
375
- if (typeof req.delay !== "undefined") {
376
- headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
377
- }
378
- if (typeof req.notBefore !== "undefined") {
379
- headers.set("Upstash-Not-Before", req.notBefore.toFixed());
380
- }
381
- if (typeof req.deduplicationId !== "undefined") {
382
- headers.set("Upstash-Deduplication-Id", req.deduplicationId);
383
- }
384
- if (typeof req.contentBasedDeduplication !== "undefined") {
385
- headers.set("Upstash-Content-Based-Deduplication", "true");
386
- }
387
- if (typeof req.retries !== "undefined") {
388
- headers.set("Upstash-Retries", req.retries.toFixed());
389
- }
390
- if (typeof req.callback !== "undefined") {
391
- headers.set("Upstash-Callback", req.callback);
392
- }
393
- if (typeof req.failureCallback !== "undefined") {
394
- headers.set("Upstash-Failure-Callback", req.failureCallback);
395
- }
396
- return headers;
503
+ /**
504
+ * Access the queue API.
505
+ *
506
+ * Create, read, update or delete queues.
507
+ */
508
+ queue(req) {
509
+ return new Queue(this.http, req == null ? void 0 : req.queueName);
397
510
  }
398
511
  publish(req) {
399
512
  return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
400
513
  var _a;
401
- const headers = this.processHeaders(req);
514
+ const headers = processHeaders(req);
402
515
  const res = yield this.http.request({
403
516
  path: ["v2", "publish", (_a = req.url) != null ? _a : req.topic],
404
517
  body: req.body,
@@ -431,7 +544,7 @@ var Client = class {
431
544
  var _a;
432
545
  const messages = [];
433
546
  for (const message of req) {
434
- const headers = this.processHeaders(message);
547
+ const headers = processHeaders(message);
435
548
  const headerEntries = Object.fromEntries(headers.entries());
436
549
  messages.push({
437
550
  destination: (_a = message.url) != null ? _a : message.topic,
@@ -487,9 +600,18 @@ var Client = class {
487
600
  */
488
601
  events(req) {
489
602
  return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
603
+ var _a;
490
604
  const query = {};
491
605
  if ((req == null ? void 0 : req.cursor) && req.cursor > 0) {
492
- query.cursor = req.cursor;
606
+ query.cursor = req.cursor.toString();
607
+ }
608
+ for (const [key, value] of Object.entries((_a = req == null ? void 0 : req.filter) != null ? _a : {})) {
609
+ if (typeof value === "number" && value < 0) {
610
+ continue;
611
+ }
612
+ if (typeof value !== "undefined") {
613
+ query[key] = value.toString();
614
+ }
493
615
  }
494
616
  const res = yield this.http.request({
495
617
  path: ["v2", "events"],
package/dist/index.mjs CHANGED
@@ -183,6 +183,138 @@ function prefixHeaders(headers) {
183
183
  }
184
184
  return headers;
185
185
  }
186
+ function processHeaders(req) {
187
+ var _a;
188
+ const headers = prefixHeaders(new Headers(req.headers));
189
+ headers.set("Upstash-Method", (_a = req.method) != null ? _a : "POST");
190
+ if (typeof req.delay !== "undefined") {
191
+ headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
192
+ }
193
+ if (typeof req.notBefore !== "undefined") {
194
+ headers.set("Upstash-Not-Before", req.notBefore.toFixed());
195
+ }
196
+ if (typeof req.deduplicationId !== "undefined") {
197
+ headers.set("Upstash-Deduplication-Id", req.deduplicationId);
198
+ }
199
+ if (typeof req.contentBasedDeduplication !== "undefined") {
200
+ headers.set("Upstash-Content-Based-Deduplication", "true");
201
+ }
202
+ if (typeof req.retries !== "undefined") {
203
+ headers.set("Upstash-Retries", req.retries.toFixed());
204
+ }
205
+ if (typeof req.callback !== "undefined") {
206
+ headers.set("Upstash-Callback", req.callback);
207
+ }
208
+ if (typeof req.failureCallback !== "undefined") {
209
+ headers.set("Upstash-Failure-Callback", req.failureCallback);
210
+ }
211
+ return headers;
212
+ }
213
+
214
+ // src/client/queue.ts
215
+ var Queue = class {
216
+ constructor(http, queueName) {
217
+ this.http = http;
218
+ this.queueName = queueName;
219
+ }
220
+ /**
221
+ * Create or update the queue
222
+ */
223
+ upsert(req) {
224
+ return __async(this, null, function* () {
225
+ if (!this.queueName) {
226
+ throw new Error("Please provide a queue name to the Queue constructor");
227
+ }
228
+ const body = {
229
+ queueName: this.queueName,
230
+ parallelism: req.parallelism
231
+ };
232
+ yield this.http.request({
233
+ method: "POST",
234
+ path: ["v2", "queues"],
235
+ headers: {
236
+ "Content-Type": "application/json"
237
+ },
238
+ body: JSON.stringify(body),
239
+ parseResponseAsJson: false
240
+ });
241
+ });
242
+ }
243
+ /**
244
+ * Get the queue details
245
+ */
246
+ get() {
247
+ return __async(this, null, function* () {
248
+ if (!this.queueName) {
249
+ throw new Error("Please provide a queue name to the Queue constructor");
250
+ }
251
+ return yield this.http.request({
252
+ method: "GET",
253
+ path: ["v2", "queues", this.queueName]
254
+ });
255
+ });
256
+ }
257
+ /**
258
+ * List queues
259
+ */
260
+ list() {
261
+ return __async(this, null, function* () {
262
+ return yield this.http.request({
263
+ method: "GET",
264
+ path: ["v2", "queues"]
265
+ });
266
+ });
267
+ }
268
+ /**
269
+ * Delete the queue
270
+ */
271
+ delete() {
272
+ return __async(this, null, function* () {
273
+ if (!this.queueName) {
274
+ throw new Error("Please provide a queue name to the Queue constructor");
275
+ }
276
+ yield this.http.request({
277
+ method: "DELETE",
278
+ path: ["v2", "queues", this.queueName],
279
+ parseResponseAsJson: false
280
+ });
281
+ });
282
+ }
283
+ /**
284
+ * Enqueue a message to a queue.
285
+ */
286
+ enqueue(req) {
287
+ return __async(this, null, function* () {
288
+ var _a;
289
+ if (!this.queueName) {
290
+ throw new Error("Please provide a queue name to the Queue constructor");
291
+ }
292
+ const headers = processHeaders(req);
293
+ const destination = (_a = req.url) != null ? _a : req.topic;
294
+ const res = yield this.http.request({
295
+ path: ["v2", "enqueue", this.queueName, destination],
296
+ body: req.body,
297
+ headers,
298
+ method: "POST"
299
+ });
300
+ return res;
301
+ });
302
+ }
303
+ /**
304
+ * Enqueue a message to a queue, serializing the body to JSON.
305
+ */
306
+ enqueueJSON(req) {
307
+ return __async(this, null, function* () {
308
+ const headers = prefixHeaders(new Headers(req.headers));
309
+ headers.set("Content-Type", "application/json");
310
+ const res = yield this.enqueue(__spreadProps(__spreadValues({}, req), {
311
+ body: JSON.stringify(req.body),
312
+ headers
313
+ }));
314
+ return res;
315
+ });
316
+ }
317
+ };
186
318
 
187
319
  // src/client/schedules.ts
188
320
  var Schedules = class {
@@ -368,37 +500,18 @@ var Client = class {
368
500
  get schedules() {
369
501
  return new Schedules(this.http);
370
502
  }
371
- processHeaders(req) {
372
- var _a;
373
- const headers = prefixHeaders(new Headers(req.headers));
374
- headers.set("Upstash-Method", (_a = req.method) != null ? _a : "POST");
375
- if (typeof req.delay !== "undefined") {
376
- headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
377
- }
378
- if (typeof req.notBefore !== "undefined") {
379
- headers.set("Upstash-Not-Before", req.notBefore.toFixed());
380
- }
381
- if (typeof req.deduplicationId !== "undefined") {
382
- headers.set("Upstash-Deduplication-Id", req.deduplicationId);
383
- }
384
- if (typeof req.contentBasedDeduplication !== "undefined") {
385
- headers.set("Upstash-Content-Based-Deduplication", "true");
386
- }
387
- if (typeof req.retries !== "undefined") {
388
- headers.set("Upstash-Retries", req.retries.toFixed());
389
- }
390
- if (typeof req.callback !== "undefined") {
391
- headers.set("Upstash-Callback", req.callback);
392
- }
393
- if (typeof req.failureCallback !== "undefined") {
394
- headers.set("Upstash-Failure-Callback", req.failureCallback);
395
- }
396
- return headers;
503
+ /**
504
+ * Access the queue API.
505
+ *
506
+ * Create, read, update or delete queues.
507
+ */
508
+ queue(req) {
509
+ return new Queue(this.http, req == null ? void 0 : req.queueName);
397
510
  }
398
511
  publish(req) {
399
512
  return __async(this, null, function* () {
400
513
  var _a;
401
- const headers = this.processHeaders(req);
514
+ const headers = processHeaders(req);
402
515
  const res = yield this.http.request({
403
516
  path: ["v2", "publish", (_a = req.url) != null ? _a : req.topic],
404
517
  body: req.body,
@@ -431,7 +544,7 @@ var Client = class {
431
544
  var _a;
432
545
  const messages = [];
433
546
  for (const message of req) {
434
- const headers = this.processHeaders(message);
547
+ const headers = processHeaders(message);
435
548
  const headerEntries = Object.fromEntries(headers.entries());
436
549
  messages.push({
437
550
  destination: (_a = message.url) != null ? _a : message.topic,
@@ -487,9 +600,18 @@ var Client = class {
487
600
  */
488
601
  events(req) {
489
602
  return __async(this, null, function* () {
603
+ var _a;
490
604
  const query = {};
491
605
  if ((req == null ? void 0 : req.cursor) && req.cursor > 0) {
492
- query.cursor = req.cursor;
606
+ query.cursor = req.cursor.toString();
607
+ }
608
+ for (const [key, value] of Object.entries((_a = req == null ? void 0 : req.filter) != null ? _a : {})) {
609
+ if (typeof value === "number" && value < 0) {
610
+ continue;
611
+ }
612
+ if (typeof value !== "undefined") {
613
+ query[key] = value.toString();
614
+ }
493
615
  }
494
616
  const res = yield this.http.request({
495
617
  path: ["v2", "events"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upstash/qstash",
3
- "version": "v2.4.2",
3
+ "version": "v2.5.0",
4
4
  "description": "Official Typescript client for QStash",
5
5
  "repository": {
6
6
  "type": "git",