@upstash/qstash 2.7.22 → 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-MQSZDXFZ.mjs → chunk-G7CVCBTL.mjs} +79 -14
- package/{chunk-3N4XI2LB.mjs → chunk-JZACTABH.mjs} +1 -1
- package/{chunk-RQQYKT2M.mjs → chunk-ODRYYMMA.mjs} +1 -1
- package/{client-vTeVVeh7.d.ts → client-CYwLcEcQ.d.mts} +77 -11
- package/{client-vTeVVeh7.d.mts → client-CYwLcEcQ.d.ts} +77 -11
- package/cloudflare.d.mts +1 -1
- package/cloudflare.d.ts +1 -1
- package/cloudflare.js +79 -14
- package/cloudflare.mjs +1 -1
- package/h3.d.mts +1 -1
- package/h3.d.ts +1 -1
- package/h3.js +79 -14
- package/h3.mjs +3 -3
- package/hono.d.mts +1 -1
- package/hono.d.ts +1 -1
- package/hono.js +79 -14
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +79 -14
- package/index.mjs +2 -2
- package/nextjs.d.mts +1 -1
- package/nextjs.d.ts +1 -1
- package/nextjs.js +79 -14
- 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 +79 -14
- package/solidjs.mjs +2 -2
- package/svelte.d.mts +1 -1
- package/svelte.d.ts +1 -1
- package/svelte.js +79 -14
- package/svelte.mjs +2 -2
- package/workflow.d.mts +1 -1
- package/workflow.d.ts +1 -1
- package/workflow.js +79 -14
- package/workflow.mjs +1 -1
package/index.js
CHANGED
|
@@ -259,6 +259,7 @@ var HttpClient = class {
|
|
|
259
259
|
options;
|
|
260
260
|
retry;
|
|
261
261
|
headers;
|
|
262
|
+
telemetryHeaders;
|
|
262
263
|
constructor(config) {
|
|
263
264
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
264
265
|
this.authorization = config.authorization;
|
|
@@ -271,6 +272,7 @@ var HttpClient = class {
|
|
|
271
272
|
backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
|
|
272
273
|
};
|
|
273
274
|
this.headers = config.headers;
|
|
275
|
+
this.telemetryHeaders = config.telemetryHeaders;
|
|
274
276
|
}
|
|
275
277
|
async request(request) {
|
|
276
278
|
const { response } = await this.requestWithBackoff(request);
|
|
@@ -785,7 +787,7 @@ function prefixHeaders(headers) {
|
|
|
785
787
|
}
|
|
786
788
|
return headers;
|
|
787
789
|
}
|
|
788
|
-
function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
790
|
+
function wrapWithGlobalHeaders(headers, globalHeaders, telemetryHeaders) {
|
|
789
791
|
if (!globalHeaders) {
|
|
790
792
|
return headers;
|
|
791
793
|
}
|
|
@@ -793,6 +795,11 @@ function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
|
793
795
|
headers.forEach((value, key) => {
|
|
794
796
|
finalHeaders.set(key, value);
|
|
795
797
|
});
|
|
798
|
+
telemetryHeaders?.forEach((value, key) => {
|
|
799
|
+
if (!value)
|
|
800
|
+
return;
|
|
801
|
+
finalHeaders.append(key, value);
|
|
802
|
+
});
|
|
796
803
|
return finalHeaders;
|
|
797
804
|
}
|
|
798
805
|
function processHeaders(request) {
|
|
@@ -877,6 +884,15 @@ function decodeBase64(base64) {
|
|
|
877
884
|
}
|
|
878
885
|
}
|
|
879
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
|
+
}
|
|
880
896
|
|
|
881
897
|
// src/client/queue.ts
|
|
882
898
|
var Queue = class {
|
|
@@ -951,7 +967,8 @@ var Queue = class {
|
|
|
951
967
|
}
|
|
952
968
|
const headers = wrapWithGlobalHeaders(
|
|
953
969
|
processHeaders(request),
|
|
954
|
-
this.http.headers
|
|
970
|
+
this.http.headers,
|
|
971
|
+
this.http.telemetryHeaders
|
|
955
972
|
);
|
|
956
973
|
const destination = getRequestPath(request);
|
|
957
974
|
const response = await this.http.request({
|
|
@@ -1071,7 +1088,7 @@ var Schedules = class {
|
|
|
1071
1088
|
}
|
|
1072
1089
|
return await this.http.request({
|
|
1073
1090
|
method: "POST",
|
|
1074
|
-
headers: wrapWithGlobalHeaders(headers, this.http.headers),
|
|
1091
|
+
headers: wrapWithGlobalHeaders(headers, this.http.headers, this.http.telemetryHeaders),
|
|
1075
1092
|
path: ["v2", "schedules", request.destination],
|
|
1076
1093
|
body: request.body
|
|
1077
1094
|
});
|
|
@@ -1228,20 +1245,37 @@ var Workflow = class {
|
|
|
1228
1245
|
}
|
|
1229
1246
|
};
|
|
1230
1247
|
|
|
1248
|
+
// version.ts
|
|
1249
|
+
var VERSION = "v2.7.23";
|
|
1250
|
+
|
|
1231
1251
|
// src/client/client.ts
|
|
1232
1252
|
var Client = class {
|
|
1233
1253
|
http;
|
|
1234
1254
|
token;
|
|
1235
1255
|
constructor(config) {
|
|
1236
1256
|
const environment = typeof process === "undefined" ? {} : process.env;
|
|
1237
|
-
|
|
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
|
+
}
|
|
1238
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
|
+
);
|
|
1239
1271
|
this.http = new HttpClient({
|
|
1240
1272
|
retry: config?.retry,
|
|
1241
1273
|
baseUrl,
|
|
1242
1274
|
authorization: `Bearer ${token}`,
|
|
1243
1275
|
//@ts-expect-error caused by undici and bunjs type overlap
|
|
1244
|
-
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
|
|
1245
1279
|
});
|
|
1246
1280
|
if (!token) {
|
|
1247
1281
|
console.warn(
|
|
@@ -1323,7 +1357,8 @@ var Client = class {
|
|
|
1323
1357
|
async publish(request) {
|
|
1324
1358
|
const headers = wrapWithGlobalHeaders(
|
|
1325
1359
|
processHeaders(request),
|
|
1326
|
-
this.http.headers
|
|
1360
|
+
this.http.headers,
|
|
1361
|
+
this.http.telemetryHeaders
|
|
1327
1362
|
);
|
|
1328
1363
|
const response = await this.http.request({
|
|
1329
1364
|
path: ["v2", "publish", getRequestPath(request)],
|
|
@@ -1354,7 +1389,11 @@ var Client = class {
|
|
|
1354
1389
|
async batch(request) {
|
|
1355
1390
|
const messages = [];
|
|
1356
1391
|
for (const message of request) {
|
|
1357
|
-
const headers = wrapWithGlobalHeaders(
|
|
1392
|
+
const headers = wrapWithGlobalHeaders(
|
|
1393
|
+
processHeaders(message),
|
|
1394
|
+
this.http.headers,
|
|
1395
|
+
this.http.telemetryHeaders
|
|
1396
|
+
);
|
|
1358
1397
|
const headerEntries = Object.fromEntries(headers.entries());
|
|
1359
1398
|
messages.push({
|
|
1360
1399
|
destination: getRequestPath(message),
|
|
@@ -1409,7 +1448,7 @@ var Client = class {
|
|
|
1409
1448
|
* }
|
|
1410
1449
|
* ```
|
|
1411
1450
|
*/
|
|
1412
|
-
async
|
|
1451
|
+
async logs(request) {
|
|
1413
1452
|
const query = {};
|
|
1414
1453
|
if (typeof request?.cursor === "number" && request.cursor > 0) {
|
|
1415
1454
|
query.cursor = request.cursor.toString();
|
|
@@ -1431,16 +1470,42 @@ var Client = class {
|
|
|
1431
1470
|
method: "GET",
|
|
1432
1471
|
query
|
|
1433
1472
|
});
|
|
1473
|
+
const logs = responsePayload.events.map((event) => {
|
|
1474
|
+
return {
|
|
1475
|
+
...event,
|
|
1476
|
+
urlGroup: event.topicName
|
|
1477
|
+
};
|
|
1478
|
+
});
|
|
1434
1479
|
return {
|
|
1435
1480
|
cursor: responsePayload.cursor,
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
...event,
|
|
1439
|
-
urlGroup: event.topicName
|
|
1440
|
-
};
|
|
1441
|
-
})
|
|
1481
|
+
logs,
|
|
1482
|
+
events: logs
|
|
1442
1483
|
};
|
|
1443
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
|
+
}
|
|
1444
1509
|
};
|
|
1445
1510
|
|
|
1446
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
|
@@ -243,6 +243,7 @@ var HttpClient = class {
|
|
|
243
243
|
options;
|
|
244
244
|
retry;
|
|
245
245
|
headers;
|
|
246
|
+
telemetryHeaders;
|
|
246
247
|
constructor(config) {
|
|
247
248
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
248
249
|
this.authorization = config.authorization;
|
|
@@ -255,6 +256,7 @@ var HttpClient = class {
|
|
|
255
256
|
backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
|
|
256
257
|
};
|
|
257
258
|
this.headers = config.headers;
|
|
259
|
+
this.telemetryHeaders = config.telemetryHeaders;
|
|
258
260
|
}
|
|
259
261
|
async request(request) {
|
|
260
262
|
const { response } = await this.requestWithBackoff(request);
|
|
@@ -753,7 +755,7 @@ function prefixHeaders(headers) {
|
|
|
753
755
|
}
|
|
754
756
|
return headers;
|
|
755
757
|
}
|
|
756
|
-
function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
758
|
+
function wrapWithGlobalHeaders(headers, globalHeaders, telemetryHeaders) {
|
|
757
759
|
if (!globalHeaders) {
|
|
758
760
|
return headers;
|
|
759
761
|
}
|
|
@@ -761,6 +763,11 @@ function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
|
761
763
|
headers.forEach((value, key) => {
|
|
762
764
|
finalHeaders.set(key, value);
|
|
763
765
|
});
|
|
766
|
+
telemetryHeaders?.forEach((value, key) => {
|
|
767
|
+
if (!value)
|
|
768
|
+
return;
|
|
769
|
+
finalHeaders.append(key, value);
|
|
770
|
+
});
|
|
764
771
|
return finalHeaders;
|
|
765
772
|
}
|
|
766
773
|
function processHeaders(request) {
|
|
@@ -850,6 +857,15 @@ function decodeBase64(base64) {
|
|
|
850
857
|
}
|
|
851
858
|
}
|
|
852
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
|
+
}
|
|
853
869
|
|
|
854
870
|
// src/client/queue.ts
|
|
855
871
|
var Queue = class {
|
|
@@ -924,7 +940,8 @@ var Queue = class {
|
|
|
924
940
|
}
|
|
925
941
|
const headers = wrapWithGlobalHeaders(
|
|
926
942
|
processHeaders(request),
|
|
927
|
-
this.http.headers
|
|
943
|
+
this.http.headers,
|
|
944
|
+
this.http.telemetryHeaders
|
|
928
945
|
);
|
|
929
946
|
const destination = getRequestPath(request);
|
|
930
947
|
const response = await this.http.request({
|
|
@@ -1044,7 +1061,7 @@ var Schedules = class {
|
|
|
1044
1061
|
}
|
|
1045
1062
|
return await this.http.request({
|
|
1046
1063
|
method: "POST",
|
|
1047
|
-
headers: wrapWithGlobalHeaders(headers, this.http.headers),
|
|
1064
|
+
headers: wrapWithGlobalHeaders(headers, this.http.headers, this.http.telemetryHeaders),
|
|
1048
1065
|
path: ["v2", "schedules", request.destination],
|
|
1049
1066
|
body: request.body
|
|
1050
1067
|
});
|
|
@@ -1170,20 +1187,37 @@ var UrlGroups = class {
|
|
|
1170
1187
|
}
|
|
1171
1188
|
};
|
|
1172
1189
|
|
|
1190
|
+
// version.ts
|
|
1191
|
+
var VERSION = "v2.7.23";
|
|
1192
|
+
|
|
1173
1193
|
// src/client/client.ts
|
|
1174
1194
|
var Client = class {
|
|
1175
1195
|
http;
|
|
1176
1196
|
token;
|
|
1177
1197
|
constructor(config) {
|
|
1178
1198
|
const environment = typeof process === "undefined" ? {} : process.env;
|
|
1179
|
-
|
|
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
|
+
}
|
|
1180
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
|
+
);
|
|
1181
1213
|
this.http = new HttpClient({
|
|
1182
1214
|
retry: config?.retry,
|
|
1183
1215
|
baseUrl,
|
|
1184
1216
|
authorization: `Bearer ${token}`,
|
|
1185
1217
|
//@ts-expect-error caused by undici and bunjs type overlap
|
|
1186
|
-
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
|
|
1187
1221
|
});
|
|
1188
1222
|
if (!token) {
|
|
1189
1223
|
console.warn(
|
|
@@ -1265,7 +1299,8 @@ var Client = class {
|
|
|
1265
1299
|
async publish(request) {
|
|
1266
1300
|
const headers = wrapWithGlobalHeaders(
|
|
1267
1301
|
processHeaders(request),
|
|
1268
|
-
this.http.headers
|
|
1302
|
+
this.http.headers,
|
|
1303
|
+
this.http.telemetryHeaders
|
|
1269
1304
|
);
|
|
1270
1305
|
const response = await this.http.request({
|
|
1271
1306
|
path: ["v2", "publish", getRequestPath(request)],
|
|
@@ -1296,7 +1331,11 @@ var Client = class {
|
|
|
1296
1331
|
async batch(request) {
|
|
1297
1332
|
const messages = [];
|
|
1298
1333
|
for (const message of request) {
|
|
1299
|
-
const headers = wrapWithGlobalHeaders(
|
|
1334
|
+
const headers = wrapWithGlobalHeaders(
|
|
1335
|
+
processHeaders(message),
|
|
1336
|
+
this.http.headers,
|
|
1337
|
+
this.http.telemetryHeaders
|
|
1338
|
+
);
|
|
1300
1339
|
const headerEntries = Object.fromEntries(headers.entries());
|
|
1301
1340
|
messages.push({
|
|
1302
1341
|
destination: getRequestPath(message),
|
|
@@ -1351,7 +1390,7 @@ var Client = class {
|
|
|
1351
1390
|
* }
|
|
1352
1391
|
* ```
|
|
1353
1392
|
*/
|
|
1354
|
-
async
|
|
1393
|
+
async logs(request) {
|
|
1355
1394
|
const query = {};
|
|
1356
1395
|
if (typeof request?.cursor === "number" && request.cursor > 0) {
|
|
1357
1396
|
query.cursor = request.cursor.toString();
|
|
@@ -1373,16 +1412,42 @@ var Client = class {
|
|
|
1373
1412
|
method: "GET",
|
|
1374
1413
|
query
|
|
1375
1414
|
});
|
|
1415
|
+
const logs = responsePayload.events.map((event) => {
|
|
1416
|
+
return {
|
|
1417
|
+
...event,
|
|
1418
|
+
urlGroup: event.topicName
|
|
1419
|
+
};
|
|
1420
|
+
});
|
|
1376
1421
|
return {
|
|
1377
1422
|
cursor: responsePayload.cursor,
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
...event,
|
|
1381
|
-
urlGroup: event.topicName
|
|
1382
|
-
};
|
|
1383
|
-
})
|
|
1423
|
+
logs,
|
|
1424
|
+
events: logs
|
|
1384
1425
|
};
|
|
1385
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
|
+
}
|
|
1386
1451
|
};
|
|
1387
1452
|
|
|
1388
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 = {
|
package/solidjs.js
CHANGED
|
@@ -240,6 +240,7 @@ var HttpClient = class {
|
|
|
240
240
|
options;
|
|
241
241
|
retry;
|
|
242
242
|
headers;
|
|
243
|
+
telemetryHeaders;
|
|
243
244
|
constructor(config) {
|
|
244
245
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
245
246
|
this.authorization = config.authorization;
|
|
@@ -252,6 +253,7 @@ var HttpClient = class {
|
|
|
252
253
|
backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
|
|
253
254
|
};
|
|
254
255
|
this.headers = config.headers;
|
|
256
|
+
this.telemetryHeaders = config.telemetryHeaders;
|
|
255
257
|
}
|
|
256
258
|
async request(request) {
|
|
257
259
|
const { response } = await this.requestWithBackoff(request);
|
|
@@ -750,7 +752,7 @@ function prefixHeaders(headers) {
|
|
|
750
752
|
}
|
|
751
753
|
return headers;
|
|
752
754
|
}
|
|
753
|
-
function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
755
|
+
function wrapWithGlobalHeaders(headers, globalHeaders, telemetryHeaders) {
|
|
754
756
|
if (!globalHeaders) {
|
|
755
757
|
return headers;
|
|
756
758
|
}
|
|
@@ -758,6 +760,11 @@ function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
|
758
760
|
headers.forEach((value, key) => {
|
|
759
761
|
finalHeaders.set(key, value);
|
|
760
762
|
});
|
|
763
|
+
telemetryHeaders?.forEach((value, key) => {
|
|
764
|
+
if (!value)
|
|
765
|
+
return;
|
|
766
|
+
finalHeaders.append(key, value);
|
|
767
|
+
});
|
|
761
768
|
return finalHeaders;
|
|
762
769
|
}
|
|
763
770
|
function processHeaders(request) {
|
|
@@ -847,6 +854,15 @@ function decodeBase64(base64) {
|
|
|
847
854
|
}
|
|
848
855
|
}
|
|
849
856
|
}
|
|
857
|
+
function getRuntime() {
|
|
858
|
+
if (typeof process === "object" && typeof process.versions == "object" && process.versions.bun)
|
|
859
|
+
return `bun@${process.versions.bun}`;
|
|
860
|
+
if (typeof EdgeRuntime === "string")
|
|
861
|
+
return "edge-light";
|
|
862
|
+
else if (typeof process === "object" && typeof process.version === "string")
|
|
863
|
+
return `node@${process.version}`;
|
|
864
|
+
return "";
|
|
865
|
+
}
|
|
850
866
|
|
|
851
867
|
// src/client/queue.ts
|
|
852
868
|
var Queue = class {
|
|
@@ -921,7 +937,8 @@ var Queue = class {
|
|
|
921
937
|
}
|
|
922
938
|
const headers = wrapWithGlobalHeaders(
|
|
923
939
|
processHeaders(request),
|
|
924
|
-
this.http.headers
|
|
940
|
+
this.http.headers,
|
|
941
|
+
this.http.telemetryHeaders
|
|
925
942
|
);
|
|
926
943
|
const destination = getRequestPath(request);
|
|
927
944
|
const response = await this.http.request({
|
|
@@ -1041,7 +1058,7 @@ var Schedules = class {
|
|
|
1041
1058
|
}
|
|
1042
1059
|
return await this.http.request({
|
|
1043
1060
|
method: "POST",
|
|
1044
|
-
headers: wrapWithGlobalHeaders(headers, this.http.headers),
|
|
1061
|
+
headers: wrapWithGlobalHeaders(headers, this.http.headers, this.http.telemetryHeaders),
|
|
1045
1062
|
path: ["v2", "schedules", request.destination],
|
|
1046
1063
|
body: request.body
|
|
1047
1064
|
});
|
|
@@ -2553,20 +2570,37 @@ var Workflow = class {
|
|
|
2553
2570
|
}
|
|
2554
2571
|
};
|
|
2555
2572
|
|
|
2573
|
+
// version.ts
|
|
2574
|
+
var VERSION = "v2.7.23";
|
|
2575
|
+
|
|
2556
2576
|
// src/client/client.ts
|
|
2557
2577
|
var Client = class {
|
|
2558
2578
|
http;
|
|
2559
2579
|
token;
|
|
2560
2580
|
constructor(config) {
|
|
2561
2581
|
const environment = typeof process === "undefined" ? {} : process.env;
|
|
2562
|
-
|
|
2582
|
+
let baseUrl = (config?.baseUrl ?? environment.QSTASH_URL ?? "https://qstash.upstash.io").replace(/\/$/, "");
|
|
2583
|
+
if (baseUrl === "https://qstash.upstash.io/v2/publish") {
|
|
2584
|
+
baseUrl = "https://qstash.upstash.io";
|
|
2585
|
+
}
|
|
2563
2586
|
const token = config?.token ?? environment.QSTASH_TOKEN;
|
|
2587
|
+
const enableTelemetry = environment.UPSTASH_DISABLE_TELEMETRY ? false : config?.enableTelemetry ?? true;
|
|
2588
|
+
const isCloudflare = typeof caches !== "undefined" && "default" in caches;
|
|
2589
|
+
const telemetryHeaders = new Headers(
|
|
2590
|
+
enableTelemetry ? {
|
|
2591
|
+
"Upstash-Telemetry-Sdk": `upstash-qstash-js@${VERSION}`,
|
|
2592
|
+
"Upstash-Telemetry-Platform": isCloudflare ? "cloudflare" : environment.VERCEL ? "vercel" : environment.AWS_REGION ? "aws" : "",
|
|
2593
|
+
"Upstash-Telemetry-Runtime": getRuntime()
|
|
2594
|
+
} : {}
|
|
2595
|
+
);
|
|
2564
2596
|
this.http = new HttpClient({
|
|
2565
2597
|
retry: config?.retry,
|
|
2566
2598
|
baseUrl,
|
|
2567
2599
|
authorization: `Bearer ${token}`,
|
|
2568
2600
|
//@ts-expect-error caused by undici and bunjs type overlap
|
|
2569
|
-
headers: prefixHeaders(new Headers(config?.headers ?? {}))
|
|
2601
|
+
headers: prefixHeaders(new Headers(config?.headers ?? {})),
|
|
2602
|
+
//@ts-expect-error caused by undici and bunjs type overlap
|
|
2603
|
+
telemetryHeaders
|
|
2570
2604
|
});
|
|
2571
2605
|
if (!token) {
|
|
2572
2606
|
console.warn(
|
|
@@ -2648,7 +2682,8 @@ var Client = class {
|
|
|
2648
2682
|
async publish(request) {
|
|
2649
2683
|
const headers = wrapWithGlobalHeaders(
|
|
2650
2684
|
processHeaders(request),
|
|
2651
|
-
this.http.headers
|
|
2685
|
+
this.http.headers,
|
|
2686
|
+
this.http.telemetryHeaders
|
|
2652
2687
|
);
|
|
2653
2688
|
const response = await this.http.request({
|
|
2654
2689
|
path: ["v2", "publish", getRequestPath(request)],
|
|
@@ -2679,7 +2714,11 @@ var Client = class {
|
|
|
2679
2714
|
async batch(request) {
|
|
2680
2715
|
const messages = [];
|
|
2681
2716
|
for (const message of request) {
|
|
2682
|
-
const headers = wrapWithGlobalHeaders(
|
|
2717
|
+
const headers = wrapWithGlobalHeaders(
|
|
2718
|
+
processHeaders(message),
|
|
2719
|
+
this.http.headers,
|
|
2720
|
+
this.http.telemetryHeaders
|
|
2721
|
+
);
|
|
2683
2722
|
const headerEntries = Object.fromEntries(headers.entries());
|
|
2684
2723
|
messages.push({
|
|
2685
2724
|
destination: getRequestPath(message),
|
|
@@ -2734,7 +2773,7 @@ var Client = class {
|
|
|
2734
2773
|
* }
|
|
2735
2774
|
* ```
|
|
2736
2775
|
*/
|
|
2737
|
-
async
|
|
2776
|
+
async logs(request) {
|
|
2738
2777
|
const query = {};
|
|
2739
2778
|
if (typeof request?.cursor === "number" && request.cursor > 0) {
|
|
2740
2779
|
query.cursor = request.cursor.toString();
|
|
@@ -2756,16 +2795,42 @@ var Client = class {
|
|
|
2756
2795
|
method: "GET",
|
|
2757
2796
|
query
|
|
2758
2797
|
});
|
|
2798
|
+
const logs = responsePayload.events.map((event) => {
|
|
2799
|
+
return {
|
|
2800
|
+
...event,
|
|
2801
|
+
urlGroup: event.topicName
|
|
2802
|
+
};
|
|
2803
|
+
});
|
|
2759
2804
|
return {
|
|
2760
2805
|
cursor: responsePayload.cursor,
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
...event,
|
|
2764
|
-
urlGroup: event.topicName
|
|
2765
|
-
};
|
|
2766
|
-
})
|
|
2806
|
+
logs,
|
|
2807
|
+
events: logs
|
|
2767
2808
|
};
|
|
2768
2809
|
}
|
|
2810
|
+
/**
|
|
2811
|
+
* @deprecated Will be removed in the next major release. Use the `logs` method instead.
|
|
2812
|
+
*
|
|
2813
|
+
* Retrieve your logs.
|
|
2814
|
+
*
|
|
2815
|
+
* The logs endpoint is paginated and returns only 100 logs at a time.
|
|
2816
|
+
* If you want to receive more logs, you can use the cursor to paginate.
|
|
2817
|
+
*
|
|
2818
|
+
* The cursor is a unix timestamp with millisecond precision
|
|
2819
|
+
*
|
|
2820
|
+
* @example
|
|
2821
|
+
* ```ts
|
|
2822
|
+
* let cursor = Date.now()
|
|
2823
|
+
* const logs: Log[] = []
|
|
2824
|
+
* while (cursor > 0) {
|
|
2825
|
+
* const res = await qstash.logs({ cursor })
|
|
2826
|
+
* logs.push(...res.logs)
|
|
2827
|
+
* cursor = res.cursor ?? 0
|
|
2828
|
+
* }
|
|
2829
|
+
* ```
|
|
2830
|
+
*/
|
|
2831
|
+
async events(request) {
|
|
2832
|
+
return await this.logs(request);
|
|
2833
|
+
}
|
|
2769
2834
|
};
|
|
2770
2835
|
|
|
2771
2836
|
// platforms/solidjs.ts
|
package/solidjs.mjs
CHANGED
package/svelte.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequestHandler } from '@sveltejs/kit';
|
|
2
|
-
import {
|
|
2
|
+
import { a9 as RouteFunction, aa as WorkflowServeOptions } from './client-CYwLcEcQ.mjs';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
type VerifySignatureConfig = {
|