@upstash/qstash 2.3.1 → 2.4.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/dist/index.d.mts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +86 -25
- package/dist/index.mjs +86 -25
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -191,6 +191,14 @@ declare class DLQ {
|
|
|
191
191
|
* Remove a message from the dlq using it's `dlqId`
|
|
192
192
|
*/
|
|
193
193
|
delete(dlqMessageId: string): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Remove multiple messages from the dlq using their `dlqId`s
|
|
196
|
+
*/
|
|
197
|
+
deleteMany(req: {
|
|
198
|
+
dlqIds: string[];
|
|
199
|
+
}): Promise<{
|
|
200
|
+
deleted: number;
|
|
201
|
+
}>;
|
|
194
202
|
}
|
|
195
203
|
|
|
196
204
|
type Schedule = {
|
|
@@ -542,12 +550,21 @@ declare class Client {
|
|
|
542
550
|
* Create, read or delete schedules.
|
|
543
551
|
*/
|
|
544
552
|
get schedules(): Schedules;
|
|
553
|
+
private processHeaders;
|
|
545
554
|
publish<TRequest extends PublishRequest>(req: TRequest): Promise<PublishResponse<TRequest>>;
|
|
546
555
|
/**
|
|
547
556
|
* publishJSON is a utility wrapper around `publish` that automatically serializes the body
|
|
548
557
|
* and sets the `Content-Type` header to `application/json`.
|
|
549
558
|
*/
|
|
550
559
|
publishJSON<TBody = unknown, TRequest extends PublishRequest<TBody> = PublishRequest<TBody>>(req: TRequest): Promise<PublishResponse<TRequest>>;
|
|
560
|
+
/**
|
|
561
|
+
* Batch publish messages to QStash.
|
|
562
|
+
*/
|
|
563
|
+
batch(req: PublishRequest[]): Promise<(PublishToUrlResponse | PublishToTopicResponse)[]>;
|
|
564
|
+
/**
|
|
565
|
+
* Batch publish messages to QStash, serializing each body to JSON.
|
|
566
|
+
*/
|
|
567
|
+
batchJSON<TBody extends BodyInit = BodyInit, TRequest extends PublishRequest<TBody> = PublishRequest<TBody>>(req: TRequest[]): Promise<(PublishToUrlResponse | PublishToTopicResponse)[]>;
|
|
551
568
|
/**
|
|
552
569
|
* Retrieve your logs.
|
|
553
570
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -191,6 +191,14 @@ declare class DLQ {
|
|
|
191
191
|
* Remove a message from the dlq using it's `dlqId`
|
|
192
192
|
*/
|
|
193
193
|
delete(dlqMessageId: string): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Remove multiple messages from the dlq using their `dlqId`s
|
|
196
|
+
*/
|
|
197
|
+
deleteMany(req: {
|
|
198
|
+
dlqIds: string[];
|
|
199
|
+
}): Promise<{
|
|
200
|
+
deleted: number;
|
|
201
|
+
}>;
|
|
194
202
|
}
|
|
195
203
|
|
|
196
204
|
type Schedule = {
|
|
@@ -542,12 +550,21 @@ declare class Client {
|
|
|
542
550
|
* Create, read or delete schedules.
|
|
543
551
|
*/
|
|
544
552
|
get schedules(): Schedules;
|
|
553
|
+
private processHeaders;
|
|
545
554
|
publish<TRequest extends PublishRequest>(req: TRequest): Promise<PublishResponse<TRequest>>;
|
|
546
555
|
/**
|
|
547
556
|
* publishJSON is a utility wrapper around `publish` that automatically serializes the body
|
|
548
557
|
* and sets the `Content-Type` header to `application/json`.
|
|
549
558
|
*/
|
|
550
559
|
publishJSON<TBody = unknown, TRequest extends PublishRequest<TBody> = PublishRequest<TBody>>(req: TRequest): Promise<PublishResponse<TRequest>>;
|
|
560
|
+
/**
|
|
561
|
+
* Batch publish messages to QStash.
|
|
562
|
+
*/
|
|
563
|
+
batch(req: PublishRequest[]): Promise<(PublishToUrlResponse | PublishToTopicResponse)[]>;
|
|
564
|
+
/**
|
|
565
|
+
* Batch publish messages to QStash, serializing each body to JSON.
|
|
566
|
+
*/
|
|
567
|
+
batchJSON<TBody extends BodyInit = BodyInit, TRequest extends PublishRequest<TBody> = PublishRequest<TBody>>(req: TRequest[]): Promise<(PublishToUrlResponse | PublishToTopicResponse)[]>;
|
|
551
568
|
/**
|
|
552
569
|
* Retrieve your logs.
|
|
553
570
|
*
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,19 @@ var DLQ = class {
|
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Remove multiple messages from the dlq using their `dlqId`s
|
|
41
|
+
*/
|
|
42
|
+
deleteMany(req) {
|
|
43
|
+
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
|
|
44
|
+
return yield this.http.request({
|
|
45
|
+
method: "DELETE",
|
|
46
|
+
path: ["v2", "dlq"],
|
|
47
|
+
headers: { "Content-Type": "application/json" },
|
|
48
|
+
body: JSON.stringify({ dlqIds: req.dlqIds })
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
39
52
|
};
|
|
40
53
|
|
|
41
54
|
// src/client/error.ts
|
|
@@ -355,34 +368,39 @@ var Client = class {
|
|
|
355
368
|
get schedules() {
|
|
356
369
|
return new Schedules(this.http);
|
|
357
370
|
}
|
|
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;
|
|
397
|
+
}
|
|
358
398
|
publish(req) {
|
|
359
399
|
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
|
|
360
|
-
var _a
|
|
361
|
-
const headers =
|
|
362
|
-
headers.set("Upstash-Method", (_a = req.method) != null ? _a : "POST");
|
|
363
|
-
if (typeof req.delay !== "undefined") {
|
|
364
|
-
headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
|
|
365
|
-
}
|
|
366
|
-
if (typeof req.notBefore !== "undefined") {
|
|
367
|
-
headers.set("Upstash-Not-Before", req.notBefore.toFixed());
|
|
368
|
-
}
|
|
369
|
-
if (typeof req.deduplicationId !== "undefined") {
|
|
370
|
-
headers.set("Upstash-Deduplication-Id", req.deduplicationId);
|
|
371
|
-
}
|
|
372
|
-
if (typeof req.contentBasedDeduplication !== "undefined") {
|
|
373
|
-
headers.set("Upstash-Content-Based-Deduplication", "true");
|
|
374
|
-
}
|
|
375
|
-
if (typeof req.retries !== "undefined") {
|
|
376
|
-
headers.set("Upstash-Retries", req.retries.toFixed());
|
|
377
|
-
}
|
|
378
|
-
if (typeof req.callback !== "undefined") {
|
|
379
|
-
headers.set("Upstash-Callback", req.callback);
|
|
380
|
-
}
|
|
381
|
-
if (typeof req.failureCallback !== "undefined") {
|
|
382
|
-
headers.set("Upstash-Failure-Callback", req.failureCallback);
|
|
383
|
-
}
|
|
400
|
+
var _a;
|
|
401
|
+
const headers = this.processHeaders(req);
|
|
384
402
|
const res = yield this.http.request({
|
|
385
|
-
path: ["v2", "publish", (
|
|
403
|
+
path: ["v2", "publish", (_a = req.url) != null ? _a : req.topic],
|
|
386
404
|
body: req.body,
|
|
387
405
|
headers,
|
|
388
406
|
method: "POST"
|
|
@@ -405,6 +423,49 @@ var Client = class {
|
|
|
405
423
|
return res;
|
|
406
424
|
});
|
|
407
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Batch publish messages to QStash.
|
|
428
|
+
*/
|
|
429
|
+
batch(req) {
|
|
430
|
+
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
|
|
431
|
+
var _a;
|
|
432
|
+
const messages = [];
|
|
433
|
+
for (const message of req) {
|
|
434
|
+
const headers = this.processHeaders(message);
|
|
435
|
+
const headerEntries = Object.fromEntries(headers.entries());
|
|
436
|
+
messages.push({
|
|
437
|
+
destination: (_a = message.url) != null ? _a : message.topic,
|
|
438
|
+
headers: headerEntries,
|
|
439
|
+
body: message.body
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
const res = yield this.http.request({
|
|
443
|
+
path: ["v2", "batch"],
|
|
444
|
+
body: JSON.stringify(messages),
|
|
445
|
+
headers: {
|
|
446
|
+
"Content-Type": "application/json"
|
|
447
|
+
},
|
|
448
|
+
method: "POST"
|
|
449
|
+
});
|
|
450
|
+
return res;
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Batch publish messages to QStash, serializing each body to JSON.
|
|
455
|
+
*/
|
|
456
|
+
batchJSON(req) {
|
|
457
|
+
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
|
|
458
|
+
for (const message of req) {
|
|
459
|
+
if ("body" in message) {
|
|
460
|
+
message.body = JSON.stringify(message.body);
|
|
461
|
+
}
|
|
462
|
+
message.headers = new Headers(message.headers);
|
|
463
|
+
message.headers.set("Content-Type", "application/json");
|
|
464
|
+
}
|
|
465
|
+
const res = yield this.batch(req);
|
|
466
|
+
return res;
|
|
467
|
+
});
|
|
468
|
+
}
|
|
408
469
|
/**
|
|
409
470
|
* Retrieve your logs.
|
|
410
471
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -36,6 +36,19 @@ var DLQ = class {
|
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Remove multiple messages from the dlq using their `dlqId`s
|
|
41
|
+
*/
|
|
42
|
+
deleteMany(req) {
|
|
43
|
+
return __async(this, null, function* () {
|
|
44
|
+
return yield this.http.request({
|
|
45
|
+
method: "DELETE",
|
|
46
|
+
path: ["v2", "dlq"],
|
|
47
|
+
headers: { "Content-Type": "application/json" },
|
|
48
|
+
body: JSON.stringify({ dlqIds: req.dlqIds })
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
39
52
|
};
|
|
40
53
|
|
|
41
54
|
// src/client/error.ts
|
|
@@ -355,34 +368,39 @@ var Client = class {
|
|
|
355
368
|
get schedules() {
|
|
356
369
|
return new Schedules(this.http);
|
|
357
370
|
}
|
|
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;
|
|
397
|
+
}
|
|
358
398
|
publish(req) {
|
|
359
399
|
return __async(this, null, function* () {
|
|
360
|
-
var _a
|
|
361
|
-
const headers =
|
|
362
|
-
headers.set("Upstash-Method", (_a = req.method) != null ? _a : "POST");
|
|
363
|
-
if (typeof req.delay !== "undefined") {
|
|
364
|
-
headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
|
|
365
|
-
}
|
|
366
|
-
if (typeof req.notBefore !== "undefined") {
|
|
367
|
-
headers.set("Upstash-Not-Before", req.notBefore.toFixed());
|
|
368
|
-
}
|
|
369
|
-
if (typeof req.deduplicationId !== "undefined") {
|
|
370
|
-
headers.set("Upstash-Deduplication-Id", req.deduplicationId);
|
|
371
|
-
}
|
|
372
|
-
if (typeof req.contentBasedDeduplication !== "undefined") {
|
|
373
|
-
headers.set("Upstash-Content-Based-Deduplication", "true");
|
|
374
|
-
}
|
|
375
|
-
if (typeof req.retries !== "undefined") {
|
|
376
|
-
headers.set("Upstash-Retries", req.retries.toFixed());
|
|
377
|
-
}
|
|
378
|
-
if (typeof req.callback !== "undefined") {
|
|
379
|
-
headers.set("Upstash-Callback", req.callback);
|
|
380
|
-
}
|
|
381
|
-
if (typeof req.failureCallback !== "undefined") {
|
|
382
|
-
headers.set("Upstash-Failure-Callback", req.failureCallback);
|
|
383
|
-
}
|
|
400
|
+
var _a;
|
|
401
|
+
const headers = this.processHeaders(req);
|
|
384
402
|
const res = yield this.http.request({
|
|
385
|
-
path: ["v2", "publish", (
|
|
403
|
+
path: ["v2", "publish", (_a = req.url) != null ? _a : req.topic],
|
|
386
404
|
body: req.body,
|
|
387
405
|
headers,
|
|
388
406
|
method: "POST"
|
|
@@ -405,6 +423,49 @@ var Client = class {
|
|
|
405
423
|
return res;
|
|
406
424
|
});
|
|
407
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Batch publish messages to QStash.
|
|
428
|
+
*/
|
|
429
|
+
batch(req) {
|
|
430
|
+
return __async(this, null, function* () {
|
|
431
|
+
var _a;
|
|
432
|
+
const messages = [];
|
|
433
|
+
for (const message of req) {
|
|
434
|
+
const headers = this.processHeaders(message);
|
|
435
|
+
const headerEntries = Object.fromEntries(headers.entries());
|
|
436
|
+
messages.push({
|
|
437
|
+
destination: (_a = message.url) != null ? _a : message.topic,
|
|
438
|
+
headers: headerEntries,
|
|
439
|
+
body: message.body
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
const res = yield this.http.request({
|
|
443
|
+
path: ["v2", "batch"],
|
|
444
|
+
body: JSON.stringify(messages),
|
|
445
|
+
headers: {
|
|
446
|
+
"Content-Type": "application/json"
|
|
447
|
+
},
|
|
448
|
+
method: "POST"
|
|
449
|
+
});
|
|
450
|
+
return res;
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Batch publish messages to QStash, serializing each body to JSON.
|
|
455
|
+
*/
|
|
456
|
+
batchJSON(req) {
|
|
457
|
+
return __async(this, null, function* () {
|
|
458
|
+
for (const message of req) {
|
|
459
|
+
if ("body" in message) {
|
|
460
|
+
message.body = JSON.stringify(message.body);
|
|
461
|
+
}
|
|
462
|
+
message.headers = new Headers(message.headers);
|
|
463
|
+
message.headers.set("Content-Type", "application/json");
|
|
464
|
+
}
|
|
465
|
+
const res = yield this.batch(req);
|
|
466
|
+
return res;
|
|
467
|
+
});
|
|
468
|
+
}
|
|
408
469
|
/**
|
|
409
470
|
* Retrieve your logs.
|
|
410
471
|
*
|