@upstash/qstash 2.7.21 → 2.7.23
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 +19 -0
- package/{chunk-QHCEWG63.mjs → chunk-G7CVCBTL.mjs} +121 -18
- package/{chunk-FGKPOZOO.mjs → chunk-JZACTABH.mjs} +1 -1
- package/{chunk-3D34OUXY.mjs → chunk-ODRYYMMA.mjs} +1 -1
- package/{client-DuOcoFUv.d.ts → client-CYwLcEcQ.d.mts} +126 -11
- package/{client-DuOcoFUv.d.mts → client-CYwLcEcQ.d.ts} +126 -11
- package/cloudflare.d.mts +1 -1
- package/cloudflare.d.ts +1 -1
- package/cloudflare.js +121 -18
- package/cloudflare.mjs +1 -1
- package/h3.d.mts +1 -1
- package/h3.d.ts +1 -1
- package/h3.js +121 -18
- package/h3.mjs +3 -3
- package/hono.d.mts +1 -1
- package/hono.d.ts +1 -1
- package/hono.js +121 -18
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +121 -18
- package/index.mjs +2 -2
- package/nextjs.d.mts +1 -1
- package/nextjs.d.ts +1 -1
- package/nextjs.js +121 -18
- package/nextjs.mjs +1 -1
- package/nuxt.mjs +3 -3
- package/package.json +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +121 -18
- package/solidjs.mjs +2 -2
- package/svelte.d.mts +1 -1
- package/svelte.d.ts +1 -1
- package/svelte.js +121 -18
- package/svelte.mjs +2 -2
- package/workflow.d.mts +1 -1
- package/workflow.d.ts +1 -1
- package/workflow.js +121 -18
- package/workflow.mjs +1 -1
package/index.js
CHANGED
|
@@ -141,7 +141,8 @@ var DLQ = class {
|
|
|
141
141
|
messages: messagesPayload.messages.map((message) => {
|
|
142
142
|
return {
|
|
143
143
|
...message,
|
|
144
|
-
urlGroup: message.topicName
|
|
144
|
+
urlGroup: message.topicName,
|
|
145
|
+
ratePerSecond: "rate" in message ? message.rate : void 0
|
|
145
146
|
};
|
|
146
147
|
}),
|
|
147
148
|
cursor: messagesPayload.cursor
|
|
@@ -258,6 +259,7 @@ var HttpClient = class {
|
|
|
258
259
|
options;
|
|
259
260
|
retry;
|
|
260
261
|
headers;
|
|
262
|
+
telemetryHeaders;
|
|
261
263
|
constructor(config) {
|
|
262
264
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
263
265
|
this.authorization = config.authorization;
|
|
@@ -270,6 +272,7 @@ var HttpClient = class {
|
|
|
270
272
|
backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
|
|
271
273
|
};
|
|
272
274
|
this.headers = config.headers;
|
|
275
|
+
this.telemetryHeaders = config.telemetryHeaders;
|
|
273
276
|
}
|
|
274
277
|
async request(request) {
|
|
275
278
|
const { response } = await this.requestWithBackoff(request);
|
|
@@ -571,7 +574,8 @@ var Messages = class {
|
|
|
571
574
|
});
|
|
572
575
|
const message = {
|
|
573
576
|
...messagePayload,
|
|
574
|
-
urlGroup: messagePayload.topicName
|
|
577
|
+
urlGroup: messagePayload.topicName,
|
|
578
|
+
ratePerSecond: "rate" in messagePayload ? messagePayload.rate : void 0
|
|
575
579
|
};
|
|
576
580
|
return message;
|
|
577
581
|
}
|
|
@@ -783,7 +787,7 @@ function prefixHeaders(headers) {
|
|
|
783
787
|
}
|
|
784
788
|
return headers;
|
|
785
789
|
}
|
|
786
|
-
function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
790
|
+
function wrapWithGlobalHeaders(headers, globalHeaders, telemetryHeaders) {
|
|
787
791
|
if (!globalHeaders) {
|
|
788
792
|
return headers;
|
|
789
793
|
}
|
|
@@ -791,6 +795,11 @@ function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
|
791
795
|
headers.forEach((value, key) => {
|
|
792
796
|
finalHeaders.set(key, value);
|
|
793
797
|
});
|
|
798
|
+
telemetryHeaders?.forEach((value, key) => {
|
|
799
|
+
if (!value)
|
|
800
|
+
return;
|
|
801
|
+
finalHeaders.append(key, value);
|
|
802
|
+
});
|
|
794
803
|
return finalHeaders;
|
|
795
804
|
}
|
|
796
805
|
function processHeaders(request) {
|
|
@@ -828,6 +837,19 @@ function processHeaders(request) {
|
|
|
828
837
|
headers.set("Upstash-Timeout", `${request.timeout}s`);
|
|
829
838
|
}
|
|
830
839
|
}
|
|
840
|
+
if (request.flowControl?.key) {
|
|
841
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
842
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
843
|
+
const controlValue = [
|
|
844
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
845
|
+
rate ? `rate=${rate}` : void 0
|
|
846
|
+
].filter(Boolean);
|
|
847
|
+
if (controlValue.length === 0) {
|
|
848
|
+
throw new QstashError("Provide at least one of parallelism or ratePerSecond for flowControl");
|
|
849
|
+
}
|
|
850
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
851
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
852
|
+
}
|
|
831
853
|
return headers;
|
|
832
854
|
}
|
|
833
855
|
function getRequestPath(request) {
|
|
@@ -862,6 +884,15 @@ function decodeBase64(base64) {
|
|
|
862
884
|
}
|
|
863
885
|
}
|
|
864
886
|
}
|
|
887
|
+
function getRuntime() {
|
|
888
|
+
if (typeof process === "object" && typeof process.versions == "object" && process.versions.bun)
|
|
889
|
+
return `bun@${process.versions.bun}`;
|
|
890
|
+
if (typeof EdgeRuntime === "string")
|
|
891
|
+
return "edge-light";
|
|
892
|
+
else if (typeof process === "object" && typeof process.version === "string")
|
|
893
|
+
return `node@${process.version}`;
|
|
894
|
+
return "";
|
|
895
|
+
}
|
|
865
896
|
|
|
866
897
|
// src/client/queue.ts
|
|
867
898
|
var Queue = class {
|
|
@@ -936,7 +967,8 @@ var Queue = class {
|
|
|
936
967
|
}
|
|
937
968
|
const headers = wrapWithGlobalHeaders(
|
|
938
969
|
processHeaders(request),
|
|
939
|
-
this.http.headers
|
|
970
|
+
this.http.headers,
|
|
971
|
+
this.http.telemetryHeaders
|
|
940
972
|
);
|
|
941
973
|
const destination = getRequestPath(request);
|
|
942
974
|
const response = await this.http.request({
|
|
@@ -1039,9 +1071,24 @@ var Schedules = class {
|
|
|
1039
1071
|
if (request.queueName !== void 0) {
|
|
1040
1072
|
headers.set("Upstash-Queue-Name", request.queueName);
|
|
1041
1073
|
}
|
|
1074
|
+
if (request.flowControl?.key) {
|
|
1075
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
1076
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
1077
|
+
const controlValue = [
|
|
1078
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
1079
|
+
rate ? `rate=${rate}` : void 0
|
|
1080
|
+
].filter(Boolean);
|
|
1081
|
+
if (controlValue.length === 0) {
|
|
1082
|
+
throw new QstashError(
|
|
1083
|
+
"Provide at least one of parallelism or ratePerSecond for flowControl"
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
1087
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
1088
|
+
}
|
|
1042
1089
|
return await this.http.request({
|
|
1043
1090
|
method: "POST",
|
|
1044
|
-
headers: wrapWithGlobalHeaders(headers, this.http.headers),
|
|
1091
|
+
headers: wrapWithGlobalHeaders(headers, this.http.headers, this.http.telemetryHeaders),
|
|
1045
1092
|
path: ["v2", "schedules", request.destination],
|
|
1046
1093
|
body: request.body
|
|
1047
1094
|
});
|
|
@@ -1050,19 +1097,27 @@ var Schedules = class {
|
|
|
1050
1097
|
* Get a schedule
|
|
1051
1098
|
*/
|
|
1052
1099
|
async get(scheduleId) {
|
|
1053
|
-
|
|
1100
|
+
const schedule = await this.http.request({
|
|
1054
1101
|
method: "GET",
|
|
1055
1102
|
path: ["v2", "schedules", scheduleId]
|
|
1056
1103
|
});
|
|
1104
|
+
if ("rate" in schedule)
|
|
1105
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1106
|
+
return schedule;
|
|
1057
1107
|
}
|
|
1058
1108
|
/**
|
|
1059
1109
|
* List your schedules
|
|
1060
1110
|
*/
|
|
1061
1111
|
async list() {
|
|
1062
|
-
|
|
1112
|
+
const schedules = await this.http.request({
|
|
1063
1113
|
method: "GET",
|
|
1064
1114
|
path: ["v2", "schedules"]
|
|
1065
1115
|
});
|
|
1116
|
+
for (const schedule of schedules) {
|
|
1117
|
+
if ("rate" in schedule)
|
|
1118
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1119
|
+
}
|
|
1120
|
+
return schedules;
|
|
1066
1121
|
}
|
|
1067
1122
|
/**
|
|
1068
1123
|
* Delete a schedule
|
|
@@ -1190,20 +1245,37 @@ var Workflow = class {
|
|
|
1190
1245
|
}
|
|
1191
1246
|
};
|
|
1192
1247
|
|
|
1248
|
+
// version.ts
|
|
1249
|
+
var VERSION = "v2.7.23";
|
|
1250
|
+
|
|
1193
1251
|
// src/client/client.ts
|
|
1194
1252
|
var Client = class {
|
|
1195
1253
|
http;
|
|
1196
1254
|
token;
|
|
1197
1255
|
constructor(config) {
|
|
1198
1256
|
const environment = typeof process === "undefined" ? {} : process.env;
|
|
1199
|
-
|
|
1257
|
+
let baseUrl = (config?.baseUrl ?? environment.QSTASH_URL ?? "https://qstash.upstash.io").replace(/\/$/, "");
|
|
1258
|
+
if (baseUrl === "https://qstash.upstash.io/v2/publish") {
|
|
1259
|
+
baseUrl = "https://qstash.upstash.io";
|
|
1260
|
+
}
|
|
1200
1261
|
const token = config?.token ?? environment.QSTASH_TOKEN;
|
|
1262
|
+
const enableTelemetry = environment.UPSTASH_DISABLE_TELEMETRY ? false : config?.enableTelemetry ?? true;
|
|
1263
|
+
const isCloudflare = typeof caches !== "undefined" && "default" in caches;
|
|
1264
|
+
const telemetryHeaders = new Headers(
|
|
1265
|
+
enableTelemetry ? {
|
|
1266
|
+
"Upstash-Telemetry-Sdk": `upstash-qstash-js@${VERSION}`,
|
|
1267
|
+
"Upstash-Telemetry-Platform": isCloudflare ? "cloudflare" : environment.VERCEL ? "vercel" : environment.AWS_REGION ? "aws" : "",
|
|
1268
|
+
"Upstash-Telemetry-Runtime": getRuntime()
|
|
1269
|
+
} : {}
|
|
1270
|
+
);
|
|
1201
1271
|
this.http = new HttpClient({
|
|
1202
1272
|
retry: config?.retry,
|
|
1203
1273
|
baseUrl,
|
|
1204
1274
|
authorization: `Bearer ${token}`,
|
|
1205
1275
|
//@ts-expect-error caused by undici and bunjs type overlap
|
|
1206
|
-
headers: prefixHeaders(new Headers(config?.headers ?? {}))
|
|
1276
|
+
headers: prefixHeaders(new Headers(config?.headers ?? {})),
|
|
1277
|
+
//@ts-expect-error caused by undici and bunjs type overlap
|
|
1278
|
+
telemetryHeaders
|
|
1207
1279
|
});
|
|
1208
1280
|
if (!token) {
|
|
1209
1281
|
console.warn(
|
|
@@ -1285,7 +1357,8 @@ var Client = class {
|
|
|
1285
1357
|
async publish(request) {
|
|
1286
1358
|
const headers = wrapWithGlobalHeaders(
|
|
1287
1359
|
processHeaders(request),
|
|
1288
|
-
this.http.headers
|
|
1360
|
+
this.http.headers,
|
|
1361
|
+
this.http.telemetryHeaders
|
|
1289
1362
|
);
|
|
1290
1363
|
const response = await this.http.request({
|
|
1291
1364
|
path: ["v2", "publish", getRequestPath(request)],
|
|
@@ -1316,7 +1389,11 @@ var Client = class {
|
|
|
1316
1389
|
async batch(request) {
|
|
1317
1390
|
const messages = [];
|
|
1318
1391
|
for (const message of request) {
|
|
1319
|
-
const headers = wrapWithGlobalHeaders(
|
|
1392
|
+
const headers = wrapWithGlobalHeaders(
|
|
1393
|
+
processHeaders(message),
|
|
1394
|
+
this.http.headers,
|
|
1395
|
+
this.http.telemetryHeaders
|
|
1396
|
+
);
|
|
1320
1397
|
const headerEntries = Object.fromEntries(headers.entries());
|
|
1321
1398
|
messages.push({
|
|
1322
1399
|
destination: getRequestPath(message),
|
|
@@ -1371,7 +1448,7 @@ var Client = class {
|
|
|
1371
1448
|
* }
|
|
1372
1449
|
* ```
|
|
1373
1450
|
*/
|
|
1374
|
-
async
|
|
1451
|
+
async logs(request) {
|
|
1375
1452
|
const query = {};
|
|
1376
1453
|
if (typeof request?.cursor === "number" && request.cursor > 0) {
|
|
1377
1454
|
query.cursor = request.cursor.toString();
|
|
@@ -1393,16 +1470,42 @@ var Client = class {
|
|
|
1393
1470
|
method: "GET",
|
|
1394
1471
|
query
|
|
1395
1472
|
});
|
|
1473
|
+
const logs = responsePayload.events.map((event) => {
|
|
1474
|
+
return {
|
|
1475
|
+
...event,
|
|
1476
|
+
urlGroup: event.topicName
|
|
1477
|
+
};
|
|
1478
|
+
});
|
|
1396
1479
|
return {
|
|
1397
1480
|
cursor: responsePayload.cursor,
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
...event,
|
|
1401
|
-
urlGroup: event.topicName
|
|
1402
|
-
};
|
|
1403
|
-
})
|
|
1481
|
+
logs,
|
|
1482
|
+
events: logs
|
|
1404
1483
|
};
|
|
1405
1484
|
}
|
|
1485
|
+
/**
|
|
1486
|
+
* @deprecated Will be removed in the next major release. Use the `logs` method instead.
|
|
1487
|
+
*
|
|
1488
|
+
* Retrieve your logs.
|
|
1489
|
+
*
|
|
1490
|
+
* The logs endpoint is paginated and returns only 100 logs at a time.
|
|
1491
|
+
* If you want to receive more logs, you can use the cursor to paginate.
|
|
1492
|
+
*
|
|
1493
|
+
* The cursor is a unix timestamp with millisecond precision
|
|
1494
|
+
*
|
|
1495
|
+
* @example
|
|
1496
|
+
* ```ts
|
|
1497
|
+
* let cursor = Date.now()
|
|
1498
|
+
* const logs: Log[] = []
|
|
1499
|
+
* while (cursor > 0) {
|
|
1500
|
+
* const res = await qstash.logs({ cursor })
|
|
1501
|
+
* logs.push(...res.logs)
|
|
1502
|
+
* cursor = res.cursor ?? 0
|
|
1503
|
+
* }
|
|
1504
|
+
* ```
|
|
1505
|
+
*/
|
|
1506
|
+
async events(request) {
|
|
1507
|
+
return await this.logs(request);
|
|
1508
|
+
}
|
|
1406
1509
|
};
|
|
1407
1510
|
|
|
1408
1511
|
// src/client/api/email.ts
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resend
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ODRYYMMA.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Chat,
|
|
6
6
|
Client,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
openai,
|
|
23
23
|
setupAnalytics,
|
|
24
24
|
upstash
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-G7CVCBTL.mjs";
|
|
26
26
|
export {
|
|
27
27
|
Chat,
|
|
28
28
|
Client,
|
package/nextjs.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextApiHandler } from 'next';
|
|
2
2
|
import { NextRequest, NextFetchEvent } from 'next/server';
|
|
3
|
-
import {
|
|
3
|
+
import { a9 as RouteFunction, aa as WorkflowServeOptions } from './client-CYwLcEcQ.mjs';
|
|
4
4
|
import 'neverthrow';
|
|
5
5
|
|
|
6
6
|
type VerifySignatureConfig = {
|
package/nextjs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextApiHandler } from 'next';
|
|
2
2
|
import { NextRequest, NextFetchEvent } from 'next/server';
|
|
3
|
-
import {
|
|
3
|
+
import { a9 as RouteFunction, aa as WorkflowServeOptions } from './client-CYwLcEcQ.js';
|
|
4
4
|
import 'neverthrow';
|
|
5
5
|
|
|
6
6
|
type VerifySignatureConfig = {
|
package/nextjs.js
CHANGED
|
@@ -125,7 +125,8 @@ var DLQ = class {
|
|
|
125
125
|
messages: messagesPayload.messages.map((message) => {
|
|
126
126
|
return {
|
|
127
127
|
...message,
|
|
128
|
-
urlGroup: message.topicName
|
|
128
|
+
urlGroup: message.topicName,
|
|
129
|
+
ratePerSecond: "rate" in message ? message.rate : void 0
|
|
129
130
|
};
|
|
130
131
|
}),
|
|
131
132
|
cursor: messagesPayload.cursor
|
|
@@ -242,6 +243,7 @@ var HttpClient = class {
|
|
|
242
243
|
options;
|
|
243
244
|
retry;
|
|
244
245
|
headers;
|
|
246
|
+
telemetryHeaders;
|
|
245
247
|
constructor(config) {
|
|
246
248
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
247
249
|
this.authorization = config.authorization;
|
|
@@ -254,6 +256,7 @@ var HttpClient = class {
|
|
|
254
256
|
backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
|
|
255
257
|
};
|
|
256
258
|
this.headers = config.headers;
|
|
259
|
+
this.telemetryHeaders = config.telemetryHeaders;
|
|
257
260
|
}
|
|
258
261
|
async request(request) {
|
|
259
262
|
const { response } = await this.requestWithBackoff(request);
|
|
@@ -555,7 +558,8 @@ var Messages = class {
|
|
|
555
558
|
});
|
|
556
559
|
const message = {
|
|
557
560
|
...messagePayload,
|
|
558
|
-
urlGroup: messagePayload.topicName
|
|
561
|
+
urlGroup: messagePayload.topicName,
|
|
562
|
+
ratePerSecond: "rate" in messagePayload ? messagePayload.rate : void 0
|
|
559
563
|
};
|
|
560
564
|
return message;
|
|
561
565
|
}
|
|
@@ -751,7 +755,7 @@ function prefixHeaders(headers) {
|
|
|
751
755
|
}
|
|
752
756
|
return headers;
|
|
753
757
|
}
|
|
754
|
-
function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
758
|
+
function wrapWithGlobalHeaders(headers, globalHeaders, telemetryHeaders) {
|
|
755
759
|
if (!globalHeaders) {
|
|
756
760
|
return headers;
|
|
757
761
|
}
|
|
@@ -759,6 +763,11 @@ function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
|
759
763
|
headers.forEach((value, key) => {
|
|
760
764
|
finalHeaders.set(key, value);
|
|
761
765
|
});
|
|
766
|
+
telemetryHeaders?.forEach((value, key) => {
|
|
767
|
+
if (!value)
|
|
768
|
+
return;
|
|
769
|
+
finalHeaders.append(key, value);
|
|
770
|
+
});
|
|
762
771
|
return finalHeaders;
|
|
763
772
|
}
|
|
764
773
|
function processHeaders(request) {
|
|
@@ -796,6 +805,19 @@ function processHeaders(request) {
|
|
|
796
805
|
headers.set("Upstash-Timeout", `${request.timeout}s`);
|
|
797
806
|
}
|
|
798
807
|
}
|
|
808
|
+
if (request.flowControl?.key) {
|
|
809
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
810
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
811
|
+
const controlValue = [
|
|
812
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
813
|
+
rate ? `rate=${rate}` : void 0
|
|
814
|
+
].filter(Boolean);
|
|
815
|
+
if (controlValue.length === 0) {
|
|
816
|
+
throw new QstashError("Provide at least one of parallelism or ratePerSecond for flowControl");
|
|
817
|
+
}
|
|
818
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
819
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
820
|
+
}
|
|
799
821
|
return headers;
|
|
800
822
|
}
|
|
801
823
|
function getRequestPath(request) {
|
|
@@ -835,6 +857,15 @@ function decodeBase64(base64) {
|
|
|
835
857
|
}
|
|
836
858
|
}
|
|
837
859
|
}
|
|
860
|
+
function getRuntime() {
|
|
861
|
+
if (typeof process === "object" && typeof process.versions == "object" && process.versions.bun)
|
|
862
|
+
return `bun@${process.versions.bun}`;
|
|
863
|
+
if (typeof EdgeRuntime === "string")
|
|
864
|
+
return "edge-light";
|
|
865
|
+
else if (typeof process === "object" && typeof process.version === "string")
|
|
866
|
+
return `node@${process.version}`;
|
|
867
|
+
return "";
|
|
868
|
+
}
|
|
838
869
|
|
|
839
870
|
// src/client/queue.ts
|
|
840
871
|
var Queue = class {
|
|
@@ -909,7 +940,8 @@ var Queue = class {
|
|
|
909
940
|
}
|
|
910
941
|
const headers = wrapWithGlobalHeaders(
|
|
911
942
|
processHeaders(request),
|
|
912
|
-
this.http.headers
|
|
943
|
+
this.http.headers,
|
|
944
|
+
this.http.telemetryHeaders
|
|
913
945
|
);
|
|
914
946
|
const destination = getRequestPath(request);
|
|
915
947
|
const response = await this.http.request({
|
|
@@ -1012,9 +1044,24 @@ var Schedules = class {
|
|
|
1012
1044
|
if (request.queueName !== void 0) {
|
|
1013
1045
|
headers.set("Upstash-Queue-Name", request.queueName);
|
|
1014
1046
|
}
|
|
1047
|
+
if (request.flowControl?.key) {
|
|
1048
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
1049
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
1050
|
+
const controlValue = [
|
|
1051
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
1052
|
+
rate ? `rate=${rate}` : void 0
|
|
1053
|
+
].filter(Boolean);
|
|
1054
|
+
if (controlValue.length === 0) {
|
|
1055
|
+
throw new QstashError(
|
|
1056
|
+
"Provide at least one of parallelism or ratePerSecond for flowControl"
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
1060
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
1061
|
+
}
|
|
1015
1062
|
return await this.http.request({
|
|
1016
1063
|
method: "POST",
|
|
1017
|
-
headers: wrapWithGlobalHeaders(headers, this.http.headers),
|
|
1064
|
+
headers: wrapWithGlobalHeaders(headers, this.http.headers, this.http.telemetryHeaders),
|
|
1018
1065
|
path: ["v2", "schedules", request.destination],
|
|
1019
1066
|
body: request.body
|
|
1020
1067
|
});
|
|
@@ -1023,19 +1070,27 @@ var Schedules = class {
|
|
|
1023
1070
|
* Get a schedule
|
|
1024
1071
|
*/
|
|
1025
1072
|
async get(scheduleId) {
|
|
1026
|
-
|
|
1073
|
+
const schedule = await this.http.request({
|
|
1027
1074
|
method: "GET",
|
|
1028
1075
|
path: ["v2", "schedules", scheduleId]
|
|
1029
1076
|
});
|
|
1077
|
+
if ("rate" in schedule)
|
|
1078
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1079
|
+
return schedule;
|
|
1030
1080
|
}
|
|
1031
1081
|
/**
|
|
1032
1082
|
* List your schedules
|
|
1033
1083
|
*/
|
|
1034
1084
|
async list() {
|
|
1035
|
-
|
|
1085
|
+
const schedules = await this.http.request({
|
|
1036
1086
|
method: "GET",
|
|
1037
1087
|
path: ["v2", "schedules"]
|
|
1038
1088
|
});
|
|
1089
|
+
for (const schedule of schedules) {
|
|
1090
|
+
if ("rate" in schedule)
|
|
1091
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1092
|
+
}
|
|
1093
|
+
return schedules;
|
|
1039
1094
|
}
|
|
1040
1095
|
/**
|
|
1041
1096
|
* Delete a schedule
|
|
@@ -1132,20 +1187,37 @@ var UrlGroups = class {
|
|
|
1132
1187
|
}
|
|
1133
1188
|
};
|
|
1134
1189
|
|
|
1190
|
+
// version.ts
|
|
1191
|
+
var VERSION = "v2.7.23";
|
|
1192
|
+
|
|
1135
1193
|
// src/client/client.ts
|
|
1136
1194
|
var Client = class {
|
|
1137
1195
|
http;
|
|
1138
1196
|
token;
|
|
1139
1197
|
constructor(config) {
|
|
1140
1198
|
const environment = typeof process === "undefined" ? {} : process.env;
|
|
1141
|
-
|
|
1199
|
+
let baseUrl = (config?.baseUrl ?? environment.QSTASH_URL ?? "https://qstash.upstash.io").replace(/\/$/, "");
|
|
1200
|
+
if (baseUrl === "https://qstash.upstash.io/v2/publish") {
|
|
1201
|
+
baseUrl = "https://qstash.upstash.io";
|
|
1202
|
+
}
|
|
1142
1203
|
const token = config?.token ?? environment.QSTASH_TOKEN;
|
|
1204
|
+
const enableTelemetry = environment.UPSTASH_DISABLE_TELEMETRY ? false : config?.enableTelemetry ?? true;
|
|
1205
|
+
const isCloudflare = typeof caches !== "undefined" && "default" in caches;
|
|
1206
|
+
const telemetryHeaders = new Headers(
|
|
1207
|
+
enableTelemetry ? {
|
|
1208
|
+
"Upstash-Telemetry-Sdk": `upstash-qstash-js@${VERSION}`,
|
|
1209
|
+
"Upstash-Telemetry-Platform": isCloudflare ? "cloudflare" : environment.VERCEL ? "vercel" : environment.AWS_REGION ? "aws" : "",
|
|
1210
|
+
"Upstash-Telemetry-Runtime": getRuntime()
|
|
1211
|
+
} : {}
|
|
1212
|
+
);
|
|
1143
1213
|
this.http = new HttpClient({
|
|
1144
1214
|
retry: config?.retry,
|
|
1145
1215
|
baseUrl,
|
|
1146
1216
|
authorization: `Bearer ${token}`,
|
|
1147
1217
|
//@ts-expect-error caused by undici and bunjs type overlap
|
|
1148
|
-
headers: prefixHeaders(new Headers(config?.headers ?? {}))
|
|
1218
|
+
headers: prefixHeaders(new Headers(config?.headers ?? {})),
|
|
1219
|
+
//@ts-expect-error caused by undici and bunjs type overlap
|
|
1220
|
+
telemetryHeaders
|
|
1149
1221
|
});
|
|
1150
1222
|
if (!token) {
|
|
1151
1223
|
console.warn(
|
|
@@ -1227,7 +1299,8 @@ var Client = class {
|
|
|
1227
1299
|
async publish(request) {
|
|
1228
1300
|
const headers = wrapWithGlobalHeaders(
|
|
1229
1301
|
processHeaders(request),
|
|
1230
|
-
this.http.headers
|
|
1302
|
+
this.http.headers,
|
|
1303
|
+
this.http.telemetryHeaders
|
|
1231
1304
|
);
|
|
1232
1305
|
const response = await this.http.request({
|
|
1233
1306
|
path: ["v2", "publish", getRequestPath(request)],
|
|
@@ -1258,7 +1331,11 @@ var Client = class {
|
|
|
1258
1331
|
async batch(request) {
|
|
1259
1332
|
const messages = [];
|
|
1260
1333
|
for (const message of request) {
|
|
1261
|
-
const headers = wrapWithGlobalHeaders(
|
|
1334
|
+
const headers = wrapWithGlobalHeaders(
|
|
1335
|
+
processHeaders(message),
|
|
1336
|
+
this.http.headers,
|
|
1337
|
+
this.http.telemetryHeaders
|
|
1338
|
+
);
|
|
1262
1339
|
const headerEntries = Object.fromEntries(headers.entries());
|
|
1263
1340
|
messages.push({
|
|
1264
1341
|
destination: getRequestPath(message),
|
|
@@ -1313,7 +1390,7 @@ var Client = class {
|
|
|
1313
1390
|
* }
|
|
1314
1391
|
* ```
|
|
1315
1392
|
*/
|
|
1316
|
-
async
|
|
1393
|
+
async logs(request) {
|
|
1317
1394
|
const query = {};
|
|
1318
1395
|
if (typeof request?.cursor === "number" && request.cursor > 0) {
|
|
1319
1396
|
query.cursor = request.cursor.toString();
|
|
@@ -1335,16 +1412,42 @@ var Client = class {
|
|
|
1335
1412
|
method: "GET",
|
|
1336
1413
|
query
|
|
1337
1414
|
});
|
|
1415
|
+
const logs = responsePayload.events.map((event) => {
|
|
1416
|
+
return {
|
|
1417
|
+
...event,
|
|
1418
|
+
urlGroup: event.topicName
|
|
1419
|
+
};
|
|
1420
|
+
});
|
|
1338
1421
|
return {
|
|
1339
1422
|
cursor: responsePayload.cursor,
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
...event,
|
|
1343
|
-
urlGroup: event.topicName
|
|
1344
|
-
};
|
|
1345
|
-
})
|
|
1423
|
+
logs,
|
|
1424
|
+
events: logs
|
|
1346
1425
|
};
|
|
1347
1426
|
}
|
|
1427
|
+
/**
|
|
1428
|
+
* @deprecated Will be removed in the next major release. Use the `logs` method instead.
|
|
1429
|
+
*
|
|
1430
|
+
* Retrieve your logs.
|
|
1431
|
+
*
|
|
1432
|
+
* The logs endpoint is paginated and returns only 100 logs at a time.
|
|
1433
|
+
* If you want to receive more logs, you can use the cursor to paginate.
|
|
1434
|
+
*
|
|
1435
|
+
* The cursor is a unix timestamp with millisecond precision
|
|
1436
|
+
*
|
|
1437
|
+
* @example
|
|
1438
|
+
* ```ts
|
|
1439
|
+
* let cursor = Date.now()
|
|
1440
|
+
* const logs: Log[] = []
|
|
1441
|
+
* while (cursor > 0) {
|
|
1442
|
+
* const res = await qstash.logs({ cursor })
|
|
1443
|
+
* logs.push(...res.logs)
|
|
1444
|
+
* cursor = res.cursor ?? 0
|
|
1445
|
+
* }
|
|
1446
|
+
* ```
|
|
1447
|
+
*/
|
|
1448
|
+
async events(request) {
|
|
1449
|
+
return await this.logs(request);
|
|
1450
|
+
}
|
|
1348
1451
|
};
|
|
1349
1452
|
|
|
1350
1453
|
// src/client/workflow/constants.ts
|
package/nextjs.mjs
CHANGED
package/nuxt.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
verifySignatureH3
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-JZACTABH.mjs";
|
|
4
|
+
import "./chunk-ODRYYMMA.mjs";
|
|
5
|
+
import "./chunk-G7CVCBTL.mjs";
|
|
6
6
|
|
|
7
7
|
// platforms/nuxt.ts
|
|
8
8
|
var verifySignatureNuxt = verifySignatureH3;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"v2.7.
|
|
1
|
+
{"version":"v2.7.23","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/sdk-qstash-ts#readme","repository":{"type":"git","url":"git+https://github.com/upstash/sdk-qstash-ts.git"},"bugs":{"url":"https://github.com/upstash/sdk-qstash-ts/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./nuxt":{"import":"./nuxt.mjs","require":"./nuxt.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"}},"keywords":["qstash","queue","events","serverless","upstash"],"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@eslint/eslintrc":"^3.1.0","@eslint/js":"^9.10.0","@solidjs/start":"^1.0.6","@sveltejs/kit":"^2.5.18","@types/bun":"^1.1.1","@types/crypto-js":"^4.2.0","@typescript-eslint/eslint-plugin":"^8.4.0","@typescript-eslint/parser":"^8.4.0","ai":"^3.1.28","bun-types":"^1.1.7","eslint":"^9.10.0","eslint-plugin-unicorn":"^51.0.1","h3":"^1.12.0","hono":"^4.5.8","husky":"^9.0.10","next":"^14.0.2","prettier":"^3.2.5","tsup":"latest","typescript":"^5.4.5","undici-types":"^6.16.0","vitest":"latest"},"dependencies":{"crypto-js":">=4.2.0","jose":"^5.2.3","neverthrow":"^7.0.1"}}
|
package/solidjs.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIHandler, APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import {
|
|
2
|
+
import { a9 as RouteFunction, aa as WorkflowServeOptions } from './client-CYwLcEcQ.mjs';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
type VerifySignatureConfig = {
|
package/solidjs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIHandler, APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import {
|
|
2
|
+
import { a9 as RouteFunction, aa as WorkflowServeOptions } from './client-CYwLcEcQ.js';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
type VerifySignatureConfig = {
|