@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/solidjs.js
CHANGED
|
@@ -122,7 +122,8 @@ var DLQ = class {
|
|
|
122
122
|
messages: messagesPayload.messages.map((message) => {
|
|
123
123
|
return {
|
|
124
124
|
...message,
|
|
125
|
-
urlGroup: message.topicName
|
|
125
|
+
urlGroup: message.topicName,
|
|
126
|
+
ratePerSecond: "rate" in message ? message.rate : void 0
|
|
126
127
|
};
|
|
127
128
|
}),
|
|
128
129
|
cursor: messagesPayload.cursor
|
|
@@ -239,6 +240,7 @@ var HttpClient = class {
|
|
|
239
240
|
options;
|
|
240
241
|
retry;
|
|
241
242
|
headers;
|
|
243
|
+
telemetryHeaders;
|
|
242
244
|
constructor(config) {
|
|
243
245
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
244
246
|
this.authorization = config.authorization;
|
|
@@ -251,6 +253,7 @@ var HttpClient = class {
|
|
|
251
253
|
backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
|
|
252
254
|
};
|
|
253
255
|
this.headers = config.headers;
|
|
256
|
+
this.telemetryHeaders = config.telemetryHeaders;
|
|
254
257
|
}
|
|
255
258
|
async request(request) {
|
|
256
259
|
const { response } = await this.requestWithBackoff(request);
|
|
@@ -552,7 +555,8 @@ var Messages = class {
|
|
|
552
555
|
});
|
|
553
556
|
const message = {
|
|
554
557
|
...messagePayload,
|
|
555
|
-
urlGroup: messagePayload.topicName
|
|
558
|
+
urlGroup: messagePayload.topicName,
|
|
559
|
+
ratePerSecond: "rate" in messagePayload ? messagePayload.rate : void 0
|
|
556
560
|
};
|
|
557
561
|
return message;
|
|
558
562
|
}
|
|
@@ -748,7 +752,7 @@ function prefixHeaders(headers) {
|
|
|
748
752
|
}
|
|
749
753
|
return headers;
|
|
750
754
|
}
|
|
751
|
-
function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
755
|
+
function wrapWithGlobalHeaders(headers, globalHeaders, telemetryHeaders) {
|
|
752
756
|
if (!globalHeaders) {
|
|
753
757
|
return headers;
|
|
754
758
|
}
|
|
@@ -756,6 +760,11 @@ function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
|
756
760
|
headers.forEach((value, key) => {
|
|
757
761
|
finalHeaders.set(key, value);
|
|
758
762
|
});
|
|
763
|
+
telemetryHeaders?.forEach((value, key) => {
|
|
764
|
+
if (!value)
|
|
765
|
+
return;
|
|
766
|
+
finalHeaders.append(key, value);
|
|
767
|
+
});
|
|
759
768
|
return finalHeaders;
|
|
760
769
|
}
|
|
761
770
|
function processHeaders(request) {
|
|
@@ -793,6 +802,19 @@ function processHeaders(request) {
|
|
|
793
802
|
headers.set("Upstash-Timeout", `${request.timeout}s`);
|
|
794
803
|
}
|
|
795
804
|
}
|
|
805
|
+
if (request.flowControl?.key) {
|
|
806
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
807
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
808
|
+
const controlValue = [
|
|
809
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
810
|
+
rate ? `rate=${rate}` : void 0
|
|
811
|
+
].filter(Boolean);
|
|
812
|
+
if (controlValue.length === 0) {
|
|
813
|
+
throw new QstashError("Provide at least one of parallelism or ratePerSecond for flowControl");
|
|
814
|
+
}
|
|
815
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
816
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
817
|
+
}
|
|
796
818
|
return headers;
|
|
797
819
|
}
|
|
798
820
|
function getRequestPath(request) {
|
|
@@ -832,6 +854,15 @@ function decodeBase64(base64) {
|
|
|
832
854
|
}
|
|
833
855
|
}
|
|
834
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
|
+
}
|
|
835
866
|
|
|
836
867
|
// src/client/queue.ts
|
|
837
868
|
var Queue = class {
|
|
@@ -906,7 +937,8 @@ var Queue = class {
|
|
|
906
937
|
}
|
|
907
938
|
const headers = wrapWithGlobalHeaders(
|
|
908
939
|
processHeaders(request),
|
|
909
|
-
this.http.headers
|
|
940
|
+
this.http.headers,
|
|
941
|
+
this.http.telemetryHeaders
|
|
910
942
|
);
|
|
911
943
|
const destination = getRequestPath(request);
|
|
912
944
|
const response = await this.http.request({
|
|
@@ -1009,9 +1041,24 @@ var Schedules = class {
|
|
|
1009
1041
|
if (request.queueName !== void 0) {
|
|
1010
1042
|
headers.set("Upstash-Queue-Name", request.queueName);
|
|
1011
1043
|
}
|
|
1044
|
+
if (request.flowControl?.key) {
|
|
1045
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
1046
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
1047
|
+
const controlValue = [
|
|
1048
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
1049
|
+
rate ? `rate=${rate}` : void 0
|
|
1050
|
+
].filter(Boolean);
|
|
1051
|
+
if (controlValue.length === 0) {
|
|
1052
|
+
throw new QstashError(
|
|
1053
|
+
"Provide at least one of parallelism or ratePerSecond for flowControl"
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
1057
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
1058
|
+
}
|
|
1012
1059
|
return await this.http.request({
|
|
1013
1060
|
method: "POST",
|
|
1014
|
-
headers: wrapWithGlobalHeaders(headers, this.http.headers),
|
|
1061
|
+
headers: wrapWithGlobalHeaders(headers, this.http.headers, this.http.telemetryHeaders),
|
|
1015
1062
|
path: ["v2", "schedules", request.destination],
|
|
1016
1063
|
body: request.body
|
|
1017
1064
|
});
|
|
@@ -1020,19 +1067,27 @@ var Schedules = class {
|
|
|
1020
1067
|
* Get a schedule
|
|
1021
1068
|
*/
|
|
1022
1069
|
async get(scheduleId) {
|
|
1023
|
-
|
|
1070
|
+
const schedule = await this.http.request({
|
|
1024
1071
|
method: "GET",
|
|
1025
1072
|
path: ["v2", "schedules", scheduleId]
|
|
1026
1073
|
});
|
|
1074
|
+
if ("rate" in schedule)
|
|
1075
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1076
|
+
return schedule;
|
|
1027
1077
|
}
|
|
1028
1078
|
/**
|
|
1029
1079
|
* List your schedules
|
|
1030
1080
|
*/
|
|
1031
1081
|
async list() {
|
|
1032
|
-
|
|
1082
|
+
const schedules = await this.http.request({
|
|
1033
1083
|
method: "GET",
|
|
1034
1084
|
path: ["v2", "schedules"]
|
|
1035
1085
|
});
|
|
1086
|
+
for (const schedule of schedules) {
|
|
1087
|
+
if ("rate" in schedule)
|
|
1088
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1089
|
+
}
|
|
1090
|
+
return schedules;
|
|
1036
1091
|
}
|
|
1037
1092
|
/**
|
|
1038
1093
|
* Delete a schedule
|
|
@@ -2515,20 +2570,37 @@ var Workflow = class {
|
|
|
2515
2570
|
}
|
|
2516
2571
|
};
|
|
2517
2572
|
|
|
2573
|
+
// version.ts
|
|
2574
|
+
var VERSION = "v2.7.23";
|
|
2575
|
+
|
|
2518
2576
|
// src/client/client.ts
|
|
2519
2577
|
var Client = class {
|
|
2520
2578
|
http;
|
|
2521
2579
|
token;
|
|
2522
2580
|
constructor(config) {
|
|
2523
2581
|
const environment = typeof process === "undefined" ? {} : process.env;
|
|
2524
|
-
|
|
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
|
+
}
|
|
2525
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
|
+
);
|
|
2526
2596
|
this.http = new HttpClient({
|
|
2527
2597
|
retry: config?.retry,
|
|
2528
2598
|
baseUrl,
|
|
2529
2599
|
authorization: `Bearer ${token}`,
|
|
2530
2600
|
//@ts-expect-error caused by undici and bunjs type overlap
|
|
2531
|
-
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
|
|
2532
2604
|
});
|
|
2533
2605
|
if (!token) {
|
|
2534
2606
|
console.warn(
|
|
@@ -2610,7 +2682,8 @@ var Client = class {
|
|
|
2610
2682
|
async publish(request) {
|
|
2611
2683
|
const headers = wrapWithGlobalHeaders(
|
|
2612
2684
|
processHeaders(request),
|
|
2613
|
-
this.http.headers
|
|
2685
|
+
this.http.headers,
|
|
2686
|
+
this.http.telemetryHeaders
|
|
2614
2687
|
);
|
|
2615
2688
|
const response = await this.http.request({
|
|
2616
2689
|
path: ["v2", "publish", getRequestPath(request)],
|
|
@@ -2641,7 +2714,11 @@ var Client = class {
|
|
|
2641
2714
|
async batch(request) {
|
|
2642
2715
|
const messages = [];
|
|
2643
2716
|
for (const message of request) {
|
|
2644
|
-
const headers = wrapWithGlobalHeaders(
|
|
2717
|
+
const headers = wrapWithGlobalHeaders(
|
|
2718
|
+
processHeaders(message),
|
|
2719
|
+
this.http.headers,
|
|
2720
|
+
this.http.telemetryHeaders
|
|
2721
|
+
);
|
|
2645
2722
|
const headerEntries = Object.fromEntries(headers.entries());
|
|
2646
2723
|
messages.push({
|
|
2647
2724
|
destination: getRequestPath(message),
|
|
@@ -2696,7 +2773,7 @@ var Client = class {
|
|
|
2696
2773
|
* }
|
|
2697
2774
|
* ```
|
|
2698
2775
|
*/
|
|
2699
|
-
async
|
|
2776
|
+
async logs(request) {
|
|
2700
2777
|
const query = {};
|
|
2701
2778
|
if (typeof request?.cursor === "number" && request.cursor > 0) {
|
|
2702
2779
|
query.cursor = request.cursor.toString();
|
|
@@ -2718,16 +2795,42 @@ var Client = class {
|
|
|
2718
2795
|
method: "GET",
|
|
2719
2796
|
query
|
|
2720
2797
|
});
|
|
2798
|
+
const logs = responsePayload.events.map((event) => {
|
|
2799
|
+
return {
|
|
2800
|
+
...event,
|
|
2801
|
+
urlGroup: event.topicName
|
|
2802
|
+
};
|
|
2803
|
+
});
|
|
2721
2804
|
return {
|
|
2722
2805
|
cursor: responsePayload.cursor,
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
...event,
|
|
2726
|
-
urlGroup: event.topicName
|
|
2727
|
-
};
|
|
2728
|
-
})
|
|
2806
|
+
logs,
|
|
2807
|
+
events: logs
|
|
2729
2808
|
};
|
|
2730
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
|
+
}
|
|
2731
2834
|
};
|
|
2732
2835
|
|
|
2733
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 = {
|
package/svelte.d.ts
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.js';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
type VerifySignatureConfig = {
|
package/svelte.js
CHANGED
|
@@ -122,7 +122,8 @@ var DLQ = class {
|
|
|
122
122
|
messages: messagesPayload.messages.map((message) => {
|
|
123
123
|
return {
|
|
124
124
|
...message,
|
|
125
|
-
urlGroup: message.topicName
|
|
125
|
+
urlGroup: message.topicName,
|
|
126
|
+
ratePerSecond: "rate" in message ? message.rate : void 0
|
|
126
127
|
};
|
|
127
128
|
}),
|
|
128
129
|
cursor: messagesPayload.cursor
|
|
@@ -239,6 +240,7 @@ var HttpClient = class {
|
|
|
239
240
|
options;
|
|
240
241
|
retry;
|
|
241
242
|
headers;
|
|
243
|
+
telemetryHeaders;
|
|
242
244
|
constructor(config) {
|
|
243
245
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
244
246
|
this.authorization = config.authorization;
|
|
@@ -251,6 +253,7 @@ var HttpClient = class {
|
|
|
251
253
|
backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
|
|
252
254
|
};
|
|
253
255
|
this.headers = config.headers;
|
|
256
|
+
this.telemetryHeaders = config.telemetryHeaders;
|
|
254
257
|
}
|
|
255
258
|
async request(request) {
|
|
256
259
|
const { response } = await this.requestWithBackoff(request);
|
|
@@ -552,7 +555,8 @@ var Messages = class {
|
|
|
552
555
|
});
|
|
553
556
|
const message = {
|
|
554
557
|
...messagePayload,
|
|
555
|
-
urlGroup: messagePayload.topicName
|
|
558
|
+
urlGroup: messagePayload.topicName,
|
|
559
|
+
ratePerSecond: "rate" in messagePayload ? messagePayload.rate : void 0
|
|
556
560
|
};
|
|
557
561
|
return message;
|
|
558
562
|
}
|
|
@@ -748,7 +752,7 @@ function prefixHeaders(headers) {
|
|
|
748
752
|
}
|
|
749
753
|
return headers;
|
|
750
754
|
}
|
|
751
|
-
function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
755
|
+
function wrapWithGlobalHeaders(headers, globalHeaders, telemetryHeaders) {
|
|
752
756
|
if (!globalHeaders) {
|
|
753
757
|
return headers;
|
|
754
758
|
}
|
|
@@ -756,6 +760,11 @@ function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
|
756
760
|
headers.forEach((value, key) => {
|
|
757
761
|
finalHeaders.set(key, value);
|
|
758
762
|
});
|
|
763
|
+
telemetryHeaders?.forEach((value, key) => {
|
|
764
|
+
if (!value)
|
|
765
|
+
return;
|
|
766
|
+
finalHeaders.append(key, value);
|
|
767
|
+
});
|
|
759
768
|
return finalHeaders;
|
|
760
769
|
}
|
|
761
770
|
function processHeaders(request) {
|
|
@@ -793,6 +802,19 @@ function processHeaders(request) {
|
|
|
793
802
|
headers.set("Upstash-Timeout", `${request.timeout}s`);
|
|
794
803
|
}
|
|
795
804
|
}
|
|
805
|
+
if (request.flowControl?.key) {
|
|
806
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
807
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
808
|
+
const controlValue = [
|
|
809
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
810
|
+
rate ? `rate=${rate}` : void 0
|
|
811
|
+
].filter(Boolean);
|
|
812
|
+
if (controlValue.length === 0) {
|
|
813
|
+
throw new QstashError("Provide at least one of parallelism or ratePerSecond for flowControl");
|
|
814
|
+
}
|
|
815
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
816
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
817
|
+
}
|
|
796
818
|
return headers;
|
|
797
819
|
}
|
|
798
820
|
function getRequestPath(request) {
|
|
@@ -832,6 +854,15 @@ function decodeBase64(base64) {
|
|
|
832
854
|
}
|
|
833
855
|
}
|
|
834
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
|
+
}
|
|
835
866
|
|
|
836
867
|
// src/client/queue.ts
|
|
837
868
|
var Queue = class {
|
|
@@ -906,7 +937,8 @@ var Queue = class {
|
|
|
906
937
|
}
|
|
907
938
|
const headers = wrapWithGlobalHeaders(
|
|
908
939
|
processHeaders(request),
|
|
909
|
-
this.http.headers
|
|
940
|
+
this.http.headers,
|
|
941
|
+
this.http.telemetryHeaders
|
|
910
942
|
);
|
|
911
943
|
const destination = getRequestPath(request);
|
|
912
944
|
const response = await this.http.request({
|
|
@@ -1009,9 +1041,24 @@ var Schedules = class {
|
|
|
1009
1041
|
if (request.queueName !== void 0) {
|
|
1010
1042
|
headers.set("Upstash-Queue-Name", request.queueName);
|
|
1011
1043
|
}
|
|
1044
|
+
if (request.flowControl?.key) {
|
|
1045
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
1046
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
1047
|
+
const controlValue = [
|
|
1048
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
1049
|
+
rate ? `rate=${rate}` : void 0
|
|
1050
|
+
].filter(Boolean);
|
|
1051
|
+
if (controlValue.length === 0) {
|
|
1052
|
+
throw new QstashError(
|
|
1053
|
+
"Provide at least one of parallelism or ratePerSecond for flowControl"
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
1057
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
1058
|
+
}
|
|
1012
1059
|
return await this.http.request({
|
|
1013
1060
|
method: "POST",
|
|
1014
|
-
headers: wrapWithGlobalHeaders(headers, this.http.headers),
|
|
1061
|
+
headers: wrapWithGlobalHeaders(headers, this.http.headers, this.http.telemetryHeaders),
|
|
1015
1062
|
path: ["v2", "schedules", request.destination],
|
|
1016
1063
|
body: request.body
|
|
1017
1064
|
});
|
|
@@ -1020,19 +1067,27 @@ var Schedules = class {
|
|
|
1020
1067
|
* Get a schedule
|
|
1021
1068
|
*/
|
|
1022
1069
|
async get(scheduleId) {
|
|
1023
|
-
|
|
1070
|
+
const schedule = await this.http.request({
|
|
1024
1071
|
method: "GET",
|
|
1025
1072
|
path: ["v2", "schedules", scheduleId]
|
|
1026
1073
|
});
|
|
1074
|
+
if ("rate" in schedule)
|
|
1075
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1076
|
+
return schedule;
|
|
1027
1077
|
}
|
|
1028
1078
|
/**
|
|
1029
1079
|
* List your schedules
|
|
1030
1080
|
*/
|
|
1031
1081
|
async list() {
|
|
1032
|
-
|
|
1082
|
+
const schedules = await this.http.request({
|
|
1033
1083
|
method: "GET",
|
|
1034
1084
|
path: ["v2", "schedules"]
|
|
1035
1085
|
});
|
|
1086
|
+
for (const schedule of schedules) {
|
|
1087
|
+
if ("rate" in schedule)
|
|
1088
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1089
|
+
}
|
|
1090
|
+
return schedules;
|
|
1036
1091
|
}
|
|
1037
1092
|
/**
|
|
1038
1093
|
* Delete a schedule
|
|
@@ -2515,20 +2570,37 @@ var Workflow = class {
|
|
|
2515
2570
|
}
|
|
2516
2571
|
};
|
|
2517
2572
|
|
|
2573
|
+
// version.ts
|
|
2574
|
+
var VERSION = "v2.7.23";
|
|
2575
|
+
|
|
2518
2576
|
// src/client/client.ts
|
|
2519
2577
|
var Client = class {
|
|
2520
2578
|
http;
|
|
2521
2579
|
token;
|
|
2522
2580
|
constructor(config) {
|
|
2523
2581
|
const environment = typeof process === "undefined" ? {} : process.env;
|
|
2524
|
-
|
|
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
|
+
}
|
|
2525
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
|
+
);
|
|
2526
2596
|
this.http = new HttpClient({
|
|
2527
2597
|
retry: config?.retry,
|
|
2528
2598
|
baseUrl,
|
|
2529
2599
|
authorization: `Bearer ${token}`,
|
|
2530
2600
|
//@ts-expect-error caused by undici and bunjs type overlap
|
|
2531
|
-
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
|
|
2532
2604
|
});
|
|
2533
2605
|
if (!token) {
|
|
2534
2606
|
console.warn(
|
|
@@ -2610,7 +2682,8 @@ var Client = class {
|
|
|
2610
2682
|
async publish(request) {
|
|
2611
2683
|
const headers = wrapWithGlobalHeaders(
|
|
2612
2684
|
processHeaders(request),
|
|
2613
|
-
this.http.headers
|
|
2685
|
+
this.http.headers,
|
|
2686
|
+
this.http.telemetryHeaders
|
|
2614
2687
|
);
|
|
2615
2688
|
const response = await this.http.request({
|
|
2616
2689
|
path: ["v2", "publish", getRequestPath(request)],
|
|
@@ -2641,7 +2714,11 @@ var Client = class {
|
|
|
2641
2714
|
async batch(request) {
|
|
2642
2715
|
const messages = [];
|
|
2643
2716
|
for (const message of request) {
|
|
2644
|
-
const headers = wrapWithGlobalHeaders(
|
|
2717
|
+
const headers = wrapWithGlobalHeaders(
|
|
2718
|
+
processHeaders(message),
|
|
2719
|
+
this.http.headers,
|
|
2720
|
+
this.http.telemetryHeaders
|
|
2721
|
+
);
|
|
2645
2722
|
const headerEntries = Object.fromEntries(headers.entries());
|
|
2646
2723
|
messages.push({
|
|
2647
2724
|
destination: getRequestPath(message),
|
|
@@ -2696,7 +2773,7 @@ var Client = class {
|
|
|
2696
2773
|
* }
|
|
2697
2774
|
* ```
|
|
2698
2775
|
*/
|
|
2699
|
-
async
|
|
2776
|
+
async logs(request) {
|
|
2700
2777
|
const query = {};
|
|
2701
2778
|
if (typeof request?.cursor === "number" && request.cursor > 0) {
|
|
2702
2779
|
query.cursor = request.cursor.toString();
|
|
@@ -2718,16 +2795,42 @@ var Client = class {
|
|
|
2718
2795
|
method: "GET",
|
|
2719
2796
|
query
|
|
2720
2797
|
});
|
|
2798
|
+
const logs = responsePayload.events.map((event) => {
|
|
2799
|
+
return {
|
|
2800
|
+
...event,
|
|
2801
|
+
urlGroup: event.topicName
|
|
2802
|
+
};
|
|
2803
|
+
});
|
|
2721
2804
|
return {
|
|
2722
2805
|
cursor: responsePayload.cursor,
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
...event,
|
|
2726
|
-
urlGroup: event.topicName
|
|
2727
|
-
};
|
|
2728
|
-
})
|
|
2806
|
+
logs,
|
|
2807
|
+
events: logs
|
|
2729
2808
|
};
|
|
2730
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
|
+
}
|
|
2731
2834
|
};
|
|
2732
2835
|
|
|
2733
2836
|
// platforms/svelte.ts
|
package/svelte.mjs
CHANGED
package/workflow.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { am as AsyncStepFunction, af as DisabledWorkflowContext, F as FailureFunctionPayload, ap as FinishCondition, ar as LogLevel, ao as ParallelCallState, ak as RawStep, aq as RequiredExceptFields, a9 as RouteFunction, S as Step, an as StepFunction, aj as StepType, ai as StepTypes, al as SyncStepFunction, ab as Workflow, ag as WorkflowClient, ae as WorkflowContext, at as WorkflowLogger, as as WorkflowLoggerOptions, ah as WorkflowReceiver, aa as WorkflowServeOptions, ac as processOptions, ad as serve } from './client-CYwLcEcQ.mjs';
|
|
2
2
|
import 'neverthrow';
|
package/workflow.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { am as AsyncStepFunction, af as DisabledWorkflowContext, F as FailureFunctionPayload, ap as FinishCondition, ar as LogLevel, ao as ParallelCallState, ak as RawStep, aq as RequiredExceptFields, a9 as RouteFunction, S as Step, an as StepFunction, aj as StepType, ai as StepTypes, al as SyncStepFunction, ab as Workflow, ag as WorkflowClient, ae as WorkflowContext, at as WorkflowLogger, as as WorkflowLoggerOptions, ah as WorkflowReceiver, aa as WorkflowServeOptions, ac as processOptions, ad as serve } from './client-CYwLcEcQ.js';
|
|
2
2
|
import 'neverthrow';
|