@upstash/qstash 2.7.20 → 2.7.22
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/{chunk-3XWIKEL6.mjs → chunk-3N4XI2LB.mjs} +1 -1
- package/{chunk-WXLHIS4A.mjs → chunk-MQSZDXFZ.mjs} +55 -9
- package/{chunk-JSD5ZIXP.mjs → chunk-RQQYKT2M.mjs} +1 -1
- package/{client-CdYtp0E1.d.ts → client-vTeVVeh7.d.mts} +59 -3
- package/{client-CdYtp0E1.d.mts → client-vTeVVeh7.d.ts} +59 -3
- package/cloudflare.d.mts +1 -1
- package/cloudflare.d.ts +1 -1
- package/cloudflare.js +55 -9
- package/cloudflare.mjs +1 -1
- package/h3.d.mts +1 -1
- package/h3.d.ts +1 -1
- package/h3.js +55 -9
- package/h3.mjs +3 -3
- package/hono.d.mts +1 -1
- package/hono.d.ts +1 -1
- package/hono.js +55 -9
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +55 -9
- package/index.mjs +2 -2
- package/nextjs.d.mts +1 -1
- package/nextjs.d.ts +1 -1
- package/nextjs.js +55 -9
- 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 +55 -9
- package/solidjs.mjs +2 -2
- package/svelte.d.mts +1 -1
- package/svelte.d.ts +1 -1
- package/svelte.js +55 -9
- package/svelte.mjs +2 -2
- package/workflow.d.mts +1 -1
- package/workflow.d.ts +1 -1
- package/workflow.js +55 -9
- package/workflow.mjs +1 -1
|
@@ -85,7 +85,8 @@ var DLQ = class {
|
|
|
85
85
|
messages: messagesPayload.messages.map((message) => {
|
|
86
86
|
return {
|
|
87
87
|
...message,
|
|
88
|
-
urlGroup: message.topicName
|
|
88
|
+
urlGroup: message.topicName,
|
|
89
|
+
ratePerSecond: "rate" in message ? message.rate : void 0
|
|
89
90
|
};
|
|
90
91
|
}),
|
|
91
92
|
cursor: messagesPayload.cursor
|
|
@@ -515,7 +516,8 @@ var Messages = class {
|
|
|
515
516
|
});
|
|
516
517
|
const message = {
|
|
517
518
|
...messagePayload,
|
|
518
|
-
urlGroup: messagePayload.topicName
|
|
519
|
+
urlGroup: messagePayload.topicName,
|
|
520
|
+
ratePerSecond: "rate" in messagePayload ? messagePayload.rate : void 0
|
|
519
521
|
};
|
|
520
522
|
return message;
|
|
521
523
|
}
|
|
@@ -772,6 +774,19 @@ function processHeaders(request) {
|
|
|
772
774
|
headers.set("Upstash-Timeout", `${request.timeout}s`);
|
|
773
775
|
}
|
|
774
776
|
}
|
|
777
|
+
if (request.flowControl?.key) {
|
|
778
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
779
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
780
|
+
const controlValue = [
|
|
781
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
782
|
+
rate ? `rate=${rate}` : void 0
|
|
783
|
+
].filter(Boolean);
|
|
784
|
+
if (controlValue.length === 0) {
|
|
785
|
+
throw new QstashError("Provide at least one of parallelism or ratePerSecond for flowControl");
|
|
786
|
+
}
|
|
787
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
788
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
789
|
+
}
|
|
775
790
|
return headers;
|
|
776
791
|
}
|
|
777
792
|
function getRequestPath(request) {
|
|
@@ -988,6 +1003,21 @@ var Schedules = class {
|
|
|
988
1003
|
if (request.queueName !== void 0) {
|
|
989
1004
|
headers.set("Upstash-Queue-Name", request.queueName);
|
|
990
1005
|
}
|
|
1006
|
+
if (request.flowControl?.key) {
|
|
1007
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
1008
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
1009
|
+
const controlValue = [
|
|
1010
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
1011
|
+
rate ? `rate=${rate}` : void 0
|
|
1012
|
+
].filter(Boolean);
|
|
1013
|
+
if (controlValue.length === 0) {
|
|
1014
|
+
throw new QstashError(
|
|
1015
|
+
"Provide at least one of parallelism or ratePerSecond for flowControl"
|
|
1016
|
+
);
|
|
1017
|
+
}
|
|
1018
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
1019
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
1020
|
+
}
|
|
991
1021
|
return await this.http.request({
|
|
992
1022
|
method: "POST",
|
|
993
1023
|
headers: wrapWithGlobalHeaders(headers, this.http.headers),
|
|
@@ -999,19 +1029,27 @@ var Schedules = class {
|
|
|
999
1029
|
* Get a schedule
|
|
1000
1030
|
*/
|
|
1001
1031
|
async get(scheduleId) {
|
|
1002
|
-
|
|
1032
|
+
const schedule = await this.http.request({
|
|
1003
1033
|
method: "GET",
|
|
1004
1034
|
path: ["v2", "schedules", scheduleId]
|
|
1005
1035
|
});
|
|
1036
|
+
if ("rate" in schedule)
|
|
1037
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1038
|
+
return schedule;
|
|
1006
1039
|
}
|
|
1007
1040
|
/**
|
|
1008
1041
|
* List your schedules
|
|
1009
1042
|
*/
|
|
1010
1043
|
async list() {
|
|
1011
|
-
|
|
1044
|
+
const schedules = await this.http.request({
|
|
1012
1045
|
method: "GET",
|
|
1013
1046
|
path: ["v2", "schedules"]
|
|
1014
1047
|
});
|
|
1048
|
+
for (const schedule of schedules) {
|
|
1049
|
+
if ("rate" in schedule)
|
|
1050
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1051
|
+
}
|
|
1052
|
+
return schedules;
|
|
1015
1053
|
}
|
|
1016
1054
|
/**
|
|
1017
1055
|
* Delete a schedule
|
|
@@ -1113,14 +1151,22 @@ var Client = class {
|
|
|
1113
1151
|
http;
|
|
1114
1152
|
token;
|
|
1115
1153
|
constructor(config) {
|
|
1154
|
+
const environment = typeof process === "undefined" ? {} : process.env;
|
|
1155
|
+
const baseUrl = config?.baseUrl ? config.baseUrl.replace(/\/$/, "") : environment.QSTASH_URL ?? "https://qstash.upstash.io";
|
|
1156
|
+
const token = config?.token ?? environment.QSTASH_TOKEN;
|
|
1116
1157
|
this.http = new HttpClient({
|
|
1117
|
-
retry: config
|
|
1118
|
-
baseUrl
|
|
1119
|
-
authorization: `Bearer ${
|
|
1158
|
+
retry: config?.retry,
|
|
1159
|
+
baseUrl,
|
|
1160
|
+
authorization: `Bearer ${token}`,
|
|
1120
1161
|
//@ts-expect-error caused by undici and bunjs type overlap
|
|
1121
|
-
headers: prefixHeaders(new Headers(config
|
|
1162
|
+
headers: prefixHeaders(new Headers(config?.headers ?? {}))
|
|
1122
1163
|
});
|
|
1123
|
-
|
|
1164
|
+
if (!token) {
|
|
1165
|
+
console.warn(
|
|
1166
|
+
"[Upstash QStash] client token is not set. Either pass a token or set QSTASH_TOKEN env variable."
|
|
1167
|
+
);
|
|
1168
|
+
}
|
|
1169
|
+
this.token = token;
|
|
1124
1170
|
}
|
|
1125
1171
|
/**
|
|
1126
1172
|
* Access the urlGroup API.
|
|
@@ -105,6 +105,30 @@ type RateLimit = {
|
|
|
105
105
|
remaining: string | null;
|
|
106
106
|
reset: string | null;
|
|
107
107
|
};
|
|
108
|
+
type FlowControl = {
|
|
109
|
+
/**
|
|
110
|
+
* flow control key
|
|
111
|
+
*/
|
|
112
|
+
key: string;
|
|
113
|
+
} & ({
|
|
114
|
+
/**
|
|
115
|
+
* number of requests which can be active with the same flow control key
|
|
116
|
+
*/
|
|
117
|
+
parallelism: number;
|
|
118
|
+
/**
|
|
119
|
+
* number of requests to activate per second with the same flow control key
|
|
120
|
+
*/
|
|
121
|
+
ratePerSecond?: number;
|
|
122
|
+
} | {
|
|
123
|
+
/**
|
|
124
|
+
* number of requests which can be active with the same flow control key
|
|
125
|
+
*/
|
|
126
|
+
parallelism?: number;
|
|
127
|
+
/**
|
|
128
|
+
* number of requests to activate per second with the same flow control key
|
|
129
|
+
*/
|
|
130
|
+
ratePerSecond: number;
|
|
131
|
+
});
|
|
108
132
|
|
|
109
133
|
type ProviderInfo = {
|
|
110
134
|
/**
|
|
@@ -457,6 +481,18 @@ type Message = {
|
|
|
457
481
|
* IP address of the publisher of this message
|
|
458
482
|
*/
|
|
459
483
|
callerIp?: string;
|
|
484
|
+
/**
|
|
485
|
+
* flow control key
|
|
486
|
+
*/
|
|
487
|
+
flowControlKey: string;
|
|
488
|
+
/**
|
|
489
|
+
* number of requests which can be active with the same flow control key
|
|
490
|
+
*/
|
|
491
|
+
parallelism?: number;
|
|
492
|
+
/**
|
|
493
|
+
* number of requests to activate per second with the same flow control key
|
|
494
|
+
*/
|
|
495
|
+
ratePerSecond?: number;
|
|
460
496
|
};
|
|
461
497
|
type MessagePayload = Omit<Message, "urlGroup"> & {
|
|
462
498
|
topicName: string;
|
|
@@ -693,6 +729,9 @@ type Schedule = {
|
|
|
693
729
|
callerIp?: string;
|
|
694
730
|
isPaused: boolean;
|
|
695
731
|
queueName?: string;
|
|
732
|
+
flowControlKey?: string;
|
|
733
|
+
parallelism?: number;
|
|
734
|
+
ratePerSecond?: number;
|
|
696
735
|
};
|
|
697
736
|
type CreateScheduleRequest = {
|
|
698
737
|
/**
|
|
@@ -781,6 +820,11 @@ type CreateScheduleRequest = {
|
|
|
781
820
|
* Queue name to schedule the message over.
|
|
782
821
|
*/
|
|
783
822
|
queueName?: string;
|
|
823
|
+
/**
|
|
824
|
+
* Settings for controlling the number of active requests
|
|
825
|
+
* and number of requests per second with the same key.
|
|
826
|
+
*/
|
|
827
|
+
flowControl?: FlowControl;
|
|
784
828
|
};
|
|
785
829
|
declare class Schedules {
|
|
786
830
|
private readonly http;
|
|
@@ -1564,13 +1608,20 @@ type ClientConfig = {
|
|
|
1564
1608
|
*
|
|
1565
1609
|
* This is only used for testing.
|
|
1566
1610
|
*
|
|
1611
|
+
* If not provided, value of the QSTASH_URL environment
|
|
1612
|
+
* variable will be used if it exists. If the QSTASH_URL
|
|
1613
|
+
* environment variable isn't set either, default is used.
|
|
1614
|
+
*
|
|
1567
1615
|
* @default "https://qstash.upstash.io"
|
|
1568
1616
|
*/
|
|
1569
1617
|
baseUrl?: string;
|
|
1570
1618
|
/**
|
|
1571
1619
|
* The authorization token from the upstash console.
|
|
1620
|
+
*
|
|
1621
|
+
* If not provided, value of the QSTASH_TOKEN environment
|
|
1622
|
+
* variable will be used if it exists.
|
|
1572
1623
|
*/
|
|
1573
|
-
token
|
|
1624
|
+
token?: string;
|
|
1574
1625
|
/**
|
|
1575
1626
|
* Configure how the client should retry requests.
|
|
1576
1627
|
*/
|
|
@@ -1682,6 +1733,11 @@ type PublishRequest<TBody = BodyInit> = {
|
|
|
1682
1733
|
* @default undefined
|
|
1683
1734
|
*/
|
|
1684
1735
|
timeout?: Duration | number;
|
|
1736
|
+
/**
|
|
1737
|
+
* Settings for controlling the number of active requests
|
|
1738
|
+
* and number of requests per second with the same key.
|
|
1739
|
+
*/
|
|
1740
|
+
flowControl?: FlowControl;
|
|
1685
1741
|
} & ({
|
|
1686
1742
|
/**
|
|
1687
1743
|
* The url where the message should be sent to.
|
|
@@ -1792,7 +1848,7 @@ type QueueRequest = {
|
|
|
1792
1848
|
declare class Client {
|
|
1793
1849
|
http: Requester;
|
|
1794
1850
|
private token;
|
|
1795
|
-
constructor(config
|
|
1851
|
+
constructor(config?: ClientConfig);
|
|
1796
1852
|
/**
|
|
1797
1853
|
* Access the urlGroup API.
|
|
1798
1854
|
*
|
|
@@ -1896,4 +1952,4 @@ type PublishResponse<TRequest> = TRequest extends {
|
|
|
1896
1952
|
urlGroup: string;
|
|
1897
1953
|
} ? PublishToUrlGroupsResponse : PublishToApiResponse;
|
|
1898
1954
|
|
|
1899
|
-
export {
|
|
1955
|
+
export { type ChatRequest as $, type AddEndpointsRequest as A, BaseProvider as B, type ChatRateLimit as C, type RequestOptions as D, type EmailOwner as E, type FailureFunctionPayload as F, type GetEventsResponse as G, type HTTPMethods as H, type FlowControl as I, Chat as J, type ChatCompletionMessage as K, type LLMOwner as L, type Message as M, type ChatCompletion as N, type ChatCompletionChunk as O, type ProviderInfo as P, type QueueRequest as Q, type RateLimit as R, type Step as S, type StreamEnabled as T, type UrlGroup as U, type VerifyRequest as V, type WithCursor as W, type StreamDisabled as X, type StreamParameter as Y, type OpenAIChatModel as Z, type PromptChatRequest as _, type ReceiverConfig as a, upstash as a0, openai as a1, anthropic as a2, custom as a3, type RouteFunction as a4, type WorkflowServeOptions as a5, Workflow as a6, processOptions as a7, serve as a8, WorkflowContext as a9, DisabledWorkflowContext as aa, type WorkflowClient as ab, type WorkflowReceiver as ac, StepTypes as ad, type StepType as ae, type RawStep as af, type SyncStepFunction as ag, type AsyncStepFunction as ah, type StepFunction as ai, type ParallelCallState as aj, type FinishCondition as ak, type RequiredExceptFields as al, type LogLevel as am, type WorkflowLoggerOptions as an, WorkflowLogger as ao, SignatureError as b, Receiver as c, type PublishBatchRequest as d, type PublishRequest as e, type PublishJsonRequest as f, type EventsRequest as g, Client as h, type PublishToApiResponse as i, type PublishToUrlResponse as j, type PublishToUrlGroupsResponse as k, type PublishResponse as l, type MessagePayload as m, Messages as n, type Schedule as o, type CreateScheduleRequest as p, Schedules as q, type Endpoint as r, type RemoveEndpointsRequest as s, UrlGroups as t, type State as u, type Event as v, type EventPayload as w, type GetEventsPayload as x, type BodyInit as y, type HeadersInit as z };
|
|
@@ -105,6 +105,30 @@ type RateLimit = {
|
|
|
105
105
|
remaining: string | null;
|
|
106
106
|
reset: string | null;
|
|
107
107
|
};
|
|
108
|
+
type FlowControl = {
|
|
109
|
+
/**
|
|
110
|
+
* flow control key
|
|
111
|
+
*/
|
|
112
|
+
key: string;
|
|
113
|
+
} & ({
|
|
114
|
+
/**
|
|
115
|
+
* number of requests which can be active with the same flow control key
|
|
116
|
+
*/
|
|
117
|
+
parallelism: number;
|
|
118
|
+
/**
|
|
119
|
+
* number of requests to activate per second with the same flow control key
|
|
120
|
+
*/
|
|
121
|
+
ratePerSecond?: number;
|
|
122
|
+
} | {
|
|
123
|
+
/**
|
|
124
|
+
* number of requests which can be active with the same flow control key
|
|
125
|
+
*/
|
|
126
|
+
parallelism?: number;
|
|
127
|
+
/**
|
|
128
|
+
* number of requests to activate per second with the same flow control key
|
|
129
|
+
*/
|
|
130
|
+
ratePerSecond: number;
|
|
131
|
+
});
|
|
108
132
|
|
|
109
133
|
type ProviderInfo = {
|
|
110
134
|
/**
|
|
@@ -457,6 +481,18 @@ type Message = {
|
|
|
457
481
|
* IP address of the publisher of this message
|
|
458
482
|
*/
|
|
459
483
|
callerIp?: string;
|
|
484
|
+
/**
|
|
485
|
+
* flow control key
|
|
486
|
+
*/
|
|
487
|
+
flowControlKey: string;
|
|
488
|
+
/**
|
|
489
|
+
* number of requests which can be active with the same flow control key
|
|
490
|
+
*/
|
|
491
|
+
parallelism?: number;
|
|
492
|
+
/**
|
|
493
|
+
* number of requests to activate per second with the same flow control key
|
|
494
|
+
*/
|
|
495
|
+
ratePerSecond?: number;
|
|
460
496
|
};
|
|
461
497
|
type MessagePayload = Omit<Message, "urlGroup"> & {
|
|
462
498
|
topicName: string;
|
|
@@ -693,6 +729,9 @@ type Schedule = {
|
|
|
693
729
|
callerIp?: string;
|
|
694
730
|
isPaused: boolean;
|
|
695
731
|
queueName?: string;
|
|
732
|
+
flowControlKey?: string;
|
|
733
|
+
parallelism?: number;
|
|
734
|
+
ratePerSecond?: number;
|
|
696
735
|
};
|
|
697
736
|
type CreateScheduleRequest = {
|
|
698
737
|
/**
|
|
@@ -781,6 +820,11 @@ type CreateScheduleRequest = {
|
|
|
781
820
|
* Queue name to schedule the message over.
|
|
782
821
|
*/
|
|
783
822
|
queueName?: string;
|
|
823
|
+
/**
|
|
824
|
+
* Settings for controlling the number of active requests
|
|
825
|
+
* and number of requests per second with the same key.
|
|
826
|
+
*/
|
|
827
|
+
flowControl?: FlowControl;
|
|
784
828
|
};
|
|
785
829
|
declare class Schedules {
|
|
786
830
|
private readonly http;
|
|
@@ -1564,13 +1608,20 @@ type ClientConfig = {
|
|
|
1564
1608
|
*
|
|
1565
1609
|
* This is only used for testing.
|
|
1566
1610
|
*
|
|
1611
|
+
* If not provided, value of the QSTASH_URL environment
|
|
1612
|
+
* variable will be used if it exists. If the QSTASH_URL
|
|
1613
|
+
* environment variable isn't set either, default is used.
|
|
1614
|
+
*
|
|
1567
1615
|
* @default "https://qstash.upstash.io"
|
|
1568
1616
|
*/
|
|
1569
1617
|
baseUrl?: string;
|
|
1570
1618
|
/**
|
|
1571
1619
|
* The authorization token from the upstash console.
|
|
1620
|
+
*
|
|
1621
|
+
* If not provided, value of the QSTASH_TOKEN environment
|
|
1622
|
+
* variable will be used if it exists.
|
|
1572
1623
|
*/
|
|
1573
|
-
token
|
|
1624
|
+
token?: string;
|
|
1574
1625
|
/**
|
|
1575
1626
|
* Configure how the client should retry requests.
|
|
1576
1627
|
*/
|
|
@@ -1682,6 +1733,11 @@ type PublishRequest<TBody = BodyInit> = {
|
|
|
1682
1733
|
* @default undefined
|
|
1683
1734
|
*/
|
|
1684
1735
|
timeout?: Duration | number;
|
|
1736
|
+
/**
|
|
1737
|
+
* Settings for controlling the number of active requests
|
|
1738
|
+
* and number of requests per second with the same key.
|
|
1739
|
+
*/
|
|
1740
|
+
flowControl?: FlowControl;
|
|
1685
1741
|
} & ({
|
|
1686
1742
|
/**
|
|
1687
1743
|
* The url where the message should be sent to.
|
|
@@ -1792,7 +1848,7 @@ type QueueRequest = {
|
|
|
1792
1848
|
declare class Client {
|
|
1793
1849
|
http: Requester;
|
|
1794
1850
|
private token;
|
|
1795
|
-
constructor(config
|
|
1851
|
+
constructor(config?: ClientConfig);
|
|
1796
1852
|
/**
|
|
1797
1853
|
* Access the urlGroup API.
|
|
1798
1854
|
*
|
|
@@ -1896,4 +1952,4 @@ type PublishResponse<TRequest> = TRequest extends {
|
|
|
1896
1952
|
urlGroup: string;
|
|
1897
1953
|
} ? PublishToUrlGroupsResponse : PublishToApiResponse;
|
|
1898
1954
|
|
|
1899
|
-
export {
|
|
1955
|
+
export { type ChatRequest as $, type AddEndpointsRequest as A, BaseProvider as B, type ChatRateLimit as C, type RequestOptions as D, type EmailOwner as E, type FailureFunctionPayload as F, type GetEventsResponse as G, type HTTPMethods as H, type FlowControl as I, Chat as J, type ChatCompletionMessage as K, type LLMOwner as L, type Message as M, type ChatCompletion as N, type ChatCompletionChunk as O, type ProviderInfo as P, type QueueRequest as Q, type RateLimit as R, type Step as S, type StreamEnabled as T, type UrlGroup as U, type VerifyRequest as V, type WithCursor as W, type StreamDisabled as X, type StreamParameter as Y, type OpenAIChatModel as Z, type PromptChatRequest as _, type ReceiverConfig as a, upstash as a0, openai as a1, anthropic as a2, custom as a3, type RouteFunction as a4, type WorkflowServeOptions as a5, Workflow as a6, processOptions as a7, serve as a8, WorkflowContext as a9, DisabledWorkflowContext as aa, type WorkflowClient as ab, type WorkflowReceiver as ac, StepTypes as ad, type StepType as ae, type RawStep as af, type SyncStepFunction as ag, type AsyncStepFunction as ah, type StepFunction as ai, type ParallelCallState as aj, type FinishCondition as ak, type RequiredExceptFields as al, type LogLevel as am, type WorkflowLoggerOptions as an, WorkflowLogger as ao, SignatureError as b, Receiver as c, type PublishBatchRequest as d, type PublishRequest as e, type PublishJsonRequest as f, type EventsRequest as g, Client as h, type PublishToApiResponse as i, type PublishToUrlResponse as j, type PublishToUrlGroupsResponse as k, type PublishResponse as l, type MessagePayload as m, Messages as n, type Schedule as o, type CreateScheduleRequest as p, Schedules as q, type Endpoint as r, type RemoveEndpointsRequest as s, UrlGroups as t, type State as u, type Event as v, type EventPayload as w, type GetEventsPayload as x, type BodyInit as y, type HeadersInit as z };
|
package/cloudflare.d.mts
CHANGED
package/cloudflare.d.ts
CHANGED
package/cloudflare.js
CHANGED
|
@@ -121,7 +121,8 @@ var DLQ = class {
|
|
|
121
121
|
messages: messagesPayload.messages.map((message) => {
|
|
122
122
|
return {
|
|
123
123
|
...message,
|
|
124
|
-
urlGroup: message.topicName
|
|
124
|
+
urlGroup: message.topicName,
|
|
125
|
+
ratePerSecond: "rate" in message ? message.rate : void 0
|
|
125
126
|
};
|
|
126
127
|
}),
|
|
127
128
|
cursor: messagesPayload.cursor
|
|
@@ -551,7 +552,8 @@ var Messages = class {
|
|
|
551
552
|
});
|
|
552
553
|
const message = {
|
|
553
554
|
...messagePayload,
|
|
554
|
-
urlGroup: messagePayload.topicName
|
|
555
|
+
urlGroup: messagePayload.topicName,
|
|
556
|
+
ratePerSecond: "rate" in messagePayload ? messagePayload.rate : void 0
|
|
555
557
|
};
|
|
556
558
|
return message;
|
|
557
559
|
}
|
|
@@ -792,6 +794,19 @@ function processHeaders(request) {
|
|
|
792
794
|
headers.set("Upstash-Timeout", `${request.timeout}s`);
|
|
793
795
|
}
|
|
794
796
|
}
|
|
797
|
+
if (request.flowControl?.key) {
|
|
798
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
799
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
800
|
+
const controlValue = [
|
|
801
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
802
|
+
rate ? `rate=${rate}` : void 0
|
|
803
|
+
].filter(Boolean);
|
|
804
|
+
if (controlValue.length === 0) {
|
|
805
|
+
throw new QstashError("Provide at least one of parallelism or ratePerSecond for flowControl");
|
|
806
|
+
}
|
|
807
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
808
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
809
|
+
}
|
|
795
810
|
return headers;
|
|
796
811
|
}
|
|
797
812
|
function getRequestPath(request) {
|
|
@@ -1008,6 +1023,21 @@ var Schedules = class {
|
|
|
1008
1023
|
if (request.queueName !== void 0) {
|
|
1009
1024
|
headers.set("Upstash-Queue-Name", request.queueName);
|
|
1010
1025
|
}
|
|
1026
|
+
if (request.flowControl?.key) {
|
|
1027
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
1028
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
1029
|
+
const controlValue = [
|
|
1030
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
1031
|
+
rate ? `rate=${rate}` : void 0
|
|
1032
|
+
].filter(Boolean);
|
|
1033
|
+
if (controlValue.length === 0) {
|
|
1034
|
+
throw new QstashError(
|
|
1035
|
+
"Provide at least one of parallelism or ratePerSecond for flowControl"
|
|
1036
|
+
);
|
|
1037
|
+
}
|
|
1038
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
1039
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
1040
|
+
}
|
|
1011
1041
|
return await this.http.request({
|
|
1012
1042
|
method: "POST",
|
|
1013
1043
|
headers: wrapWithGlobalHeaders(headers, this.http.headers),
|
|
@@ -1019,19 +1049,27 @@ var Schedules = class {
|
|
|
1019
1049
|
* Get a schedule
|
|
1020
1050
|
*/
|
|
1021
1051
|
async get(scheduleId) {
|
|
1022
|
-
|
|
1052
|
+
const schedule = await this.http.request({
|
|
1023
1053
|
method: "GET",
|
|
1024
1054
|
path: ["v2", "schedules", scheduleId]
|
|
1025
1055
|
});
|
|
1056
|
+
if ("rate" in schedule)
|
|
1057
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1058
|
+
return schedule;
|
|
1026
1059
|
}
|
|
1027
1060
|
/**
|
|
1028
1061
|
* List your schedules
|
|
1029
1062
|
*/
|
|
1030
1063
|
async list() {
|
|
1031
|
-
|
|
1064
|
+
const schedules = await this.http.request({
|
|
1032
1065
|
method: "GET",
|
|
1033
1066
|
path: ["v2", "schedules"]
|
|
1034
1067
|
});
|
|
1068
|
+
for (const schedule of schedules) {
|
|
1069
|
+
if ("rate" in schedule)
|
|
1070
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1071
|
+
}
|
|
1072
|
+
return schedules;
|
|
1035
1073
|
}
|
|
1036
1074
|
/**
|
|
1037
1075
|
* Delete a schedule
|
|
@@ -1133,14 +1171,22 @@ var Client = class {
|
|
|
1133
1171
|
http;
|
|
1134
1172
|
token;
|
|
1135
1173
|
constructor(config) {
|
|
1174
|
+
const environment = typeof process === "undefined" ? {} : process.env;
|
|
1175
|
+
const baseUrl = config?.baseUrl ? config.baseUrl.replace(/\/$/, "") : environment.QSTASH_URL ?? "https://qstash.upstash.io";
|
|
1176
|
+
const token = config?.token ?? environment.QSTASH_TOKEN;
|
|
1136
1177
|
this.http = new HttpClient({
|
|
1137
|
-
retry: config
|
|
1138
|
-
baseUrl
|
|
1139
|
-
authorization: `Bearer ${
|
|
1178
|
+
retry: config?.retry,
|
|
1179
|
+
baseUrl,
|
|
1180
|
+
authorization: `Bearer ${token}`,
|
|
1140
1181
|
//@ts-expect-error caused by undici and bunjs type overlap
|
|
1141
|
-
headers: prefixHeaders(new Headers(config
|
|
1182
|
+
headers: prefixHeaders(new Headers(config?.headers ?? {}))
|
|
1142
1183
|
});
|
|
1143
|
-
|
|
1184
|
+
if (!token) {
|
|
1185
|
+
console.warn(
|
|
1186
|
+
"[Upstash QStash] client token is not set. Either pass a token or set QSTASH_TOKEN env variable."
|
|
1187
|
+
);
|
|
1188
|
+
}
|
|
1189
|
+
this.token = token;
|
|
1144
1190
|
}
|
|
1145
1191
|
/**
|
|
1146
1192
|
* Access the urlGroup API.
|
package/cloudflare.mjs
CHANGED
package/h3.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as h3 from 'h3';
|
|
2
2
|
import { H3Event } from 'h3';
|
|
3
|
-
import {
|
|
3
|
+
import { a4 as RouteFunction, a5 as WorkflowServeOptions } from './client-vTeVVeh7.mjs';
|
|
4
4
|
import 'neverthrow';
|
|
5
5
|
|
|
6
6
|
type VerifySignatureConfig = {
|
package/h3.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as h3 from 'h3';
|
|
2
2
|
import { H3Event } from 'h3';
|
|
3
|
-
import {
|
|
3
|
+
import { a4 as RouteFunction, a5 as WorkflowServeOptions } from './client-vTeVVeh7.js';
|
|
4
4
|
import 'neverthrow';
|
|
5
5
|
|
|
6
6
|
type VerifySignatureConfig = {
|
package/h3.js
CHANGED
|
@@ -445,7 +445,8 @@ var DLQ = class {
|
|
|
445
445
|
messages: messagesPayload.messages.map((message) => {
|
|
446
446
|
return {
|
|
447
447
|
...message,
|
|
448
|
-
urlGroup: message.topicName
|
|
448
|
+
urlGroup: message.topicName,
|
|
449
|
+
ratePerSecond: "rate" in message ? message.rate : void 0
|
|
449
450
|
};
|
|
450
451
|
}),
|
|
451
452
|
cursor: messagesPayload.cursor
|
|
@@ -875,7 +876,8 @@ var Messages = class {
|
|
|
875
876
|
});
|
|
876
877
|
const message = {
|
|
877
878
|
...messagePayload,
|
|
878
|
-
urlGroup: messagePayload.topicName
|
|
879
|
+
urlGroup: messagePayload.topicName,
|
|
880
|
+
ratePerSecond: "rate" in messagePayload ? messagePayload.rate : void 0
|
|
879
881
|
};
|
|
880
882
|
return message;
|
|
881
883
|
}
|
|
@@ -1116,6 +1118,19 @@ function processHeaders(request) {
|
|
|
1116
1118
|
headers.set("Upstash-Timeout", `${request.timeout}s`);
|
|
1117
1119
|
}
|
|
1118
1120
|
}
|
|
1121
|
+
if (request.flowControl?.key) {
|
|
1122
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
1123
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
1124
|
+
const controlValue = [
|
|
1125
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
1126
|
+
rate ? `rate=${rate}` : void 0
|
|
1127
|
+
].filter(Boolean);
|
|
1128
|
+
if (controlValue.length === 0) {
|
|
1129
|
+
throw new QstashError("Provide at least one of parallelism or ratePerSecond for flowControl");
|
|
1130
|
+
}
|
|
1131
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
1132
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
1133
|
+
}
|
|
1119
1134
|
return headers;
|
|
1120
1135
|
}
|
|
1121
1136
|
function getRequestPath(request) {
|
|
@@ -1332,6 +1347,21 @@ var Schedules = class {
|
|
|
1332
1347
|
if (request.queueName !== void 0) {
|
|
1333
1348
|
headers.set("Upstash-Queue-Name", request.queueName);
|
|
1334
1349
|
}
|
|
1350
|
+
if (request.flowControl?.key) {
|
|
1351
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
1352
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
1353
|
+
const controlValue = [
|
|
1354
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
1355
|
+
rate ? `rate=${rate}` : void 0
|
|
1356
|
+
].filter(Boolean);
|
|
1357
|
+
if (controlValue.length === 0) {
|
|
1358
|
+
throw new QstashError(
|
|
1359
|
+
"Provide at least one of parallelism or ratePerSecond for flowControl"
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
1363
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
1364
|
+
}
|
|
1335
1365
|
return await this.http.request({
|
|
1336
1366
|
method: "POST",
|
|
1337
1367
|
headers: wrapWithGlobalHeaders(headers, this.http.headers),
|
|
@@ -1343,19 +1373,27 @@ var Schedules = class {
|
|
|
1343
1373
|
* Get a schedule
|
|
1344
1374
|
*/
|
|
1345
1375
|
async get(scheduleId) {
|
|
1346
|
-
|
|
1376
|
+
const schedule = await this.http.request({
|
|
1347
1377
|
method: "GET",
|
|
1348
1378
|
path: ["v2", "schedules", scheduleId]
|
|
1349
1379
|
});
|
|
1380
|
+
if ("rate" in schedule)
|
|
1381
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1382
|
+
return schedule;
|
|
1350
1383
|
}
|
|
1351
1384
|
/**
|
|
1352
1385
|
* List your schedules
|
|
1353
1386
|
*/
|
|
1354
1387
|
async list() {
|
|
1355
|
-
|
|
1388
|
+
const schedules = await this.http.request({
|
|
1356
1389
|
method: "GET",
|
|
1357
1390
|
path: ["v2", "schedules"]
|
|
1358
1391
|
});
|
|
1392
|
+
for (const schedule of schedules) {
|
|
1393
|
+
if ("rate" in schedule)
|
|
1394
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1395
|
+
}
|
|
1396
|
+
return schedules;
|
|
1359
1397
|
}
|
|
1360
1398
|
/**
|
|
1361
1399
|
* Delete a schedule
|
|
@@ -2843,14 +2881,22 @@ var Client = class {
|
|
|
2843
2881
|
http;
|
|
2844
2882
|
token;
|
|
2845
2883
|
constructor(config) {
|
|
2884
|
+
const environment = typeof process === "undefined" ? {} : process.env;
|
|
2885
|
+
const baseUrl = config?.baseUrl ? config.baseUrl.replace(/\/$/, "") : environment.QSTASH_URL ?? "https://qstash.upstash.io";
|
|
2886
|
+
const token = config?.token ?? environment.QSTASH_TOKEN;
|
|
2846
2887
|
this.http = new HttpClient({
|
|
2847
|
-
retry: config
|
|
2848
|
-
baseUrl
|
|
2849
|
-
authorization: `Bearer ${
|
|
2888
|
+
retry: config?.retry,
|
|
2889
|
+
baseUrl,
|
|
2890
|
+
authorization: `Bearer ${token}`,
|
|
2850
2891
|
//@ts-expect-error caused by undici and bunjs type overlap
|
|
2851
|
-
headers: prefixHeaders(new Headers(config
|
|
2892
|
+
headers: prefixHeaders(new Headers(config?.headers ?? {}))
|
|
2852
2893
|
});
|
|
2853
|
-
|
|
2894
|
+
if (!token) {
|
|
2895
|
+
console.warn(
|
|
2896
|
+
"[Upstash QStash] client token is not set. Either pass a token or set QSTASH_TOKEN env variable."
|
|
2897
|
+
);
|
|
2898
|
+
}
|
|
2899
|
+
this.token = token;
|
|
2854
2900
|
}
|
|
2855
2901
|
/**
|
|
2856
2902
|
* Access the urlGroup API.
|
package/h3.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
serve,
|
|
3
3
|
verifySignatureH3
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-3N4XI2LB.mjs";
|
|
5
|
+
import "./chunk-RQQYKT2M.mjs";
|
|
6
|
+
import "./chunk-MQSZDXFZ.mjs";
|
|
7
7
|
export {
|
|
8
8
|
serve,
|
|
9
9
|
verifySignatureH3
|