@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/README.md
CHANGED
|
@@ -131,6 +131,25 @@ const result = await client.publishJSON({
|
|
|
131
131
|
|
|
132
132
|
See [the documentation](https://docs.upstash.com/qstash) for details.
|
|
133
133
|
|
|
134
|
+
## Telemetry
|
|
135
|
+
|
|
136
|
+
This sdk sends anonymous telemetry headers to help us improve your experience.
|
|
137
|
+
We collect the following:
|
|
138
|
+
|
|
139
|
+
- SDK version
|
|
140
|
+
- Platform (Cloudflare, AWS or Vercel)
|
|
141
|
+
- Runtime version (node@18.x)
|
|
142
|
+
|
|
143
|
+
You can opt out by setting the `UPSTASH_DISABLE_TELEMETRY` environment variable
|
|
144
|
+
to any truthy value. Or setting `enableTelemetry: false` in the client options.
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
const client = new Client({
|
|
148
|
+
token: "<QSTASH_TOKEN>",
|
|
149
|
+
enableTelemetry: false,
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
134
153
|
## Contributing
|
|
135
154
|
|
|
136
155
|
### Setup
|
|
@@ -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
|
|
@@ -202,6 +203,7 @@ var HttpClient = class {
|
|
|
202
203
|
options;
|
|
203
204
|
retry;
|
|
204
205
|
headers;
|
|
206
|
+
telemetryHeaders;
|
|
205
207
|
constructor(config) {
|
|
206
208
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
207
209
|
this.authorization = config.authorization;
|
|
@@ -214,6 +216,7 @@ var HttpClient = class {
|
|
|
214
216
|
backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
|
|
215
217
|
};
|
|
216
218
|
this.headers = config.headers;
|
|
219
|
+
this.telemetryHeaders = config.telemetryHeaders;
|
|
217
220
|
}
|
|
218
221
|
async request(request) {
|
|
219
222
|
const { response } = await this.requestWithBackoff(request);
|
|
@@ -515,7 +518,8 @@ var Messages = class {
|
|
|
515
518
|
});
|
|
516
519
|
const message = {
|
|
517
520
|
...messagePayload,
|
|
518
|
-
urlGroup: messagePayload.topicName
|
|
521
|
+
urlGroup: messagePayload.topicName,
|
|
522
|
+
ratePerSecond: "rate" in messagePayload ? messagePayload.rate : void 0
|
|
519
523
|
};
|
|
520
524
|
return message;
|
|
521
525
|
}
|
|
@@ -727,7 +731,7 @@ function prefixHeaders(headers) {
|
|
|
727
731
|
}
|
|
728
732
|
return headers;
|
|
729
733
|
}
|
|
730
|
-
function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
734
|
+
function wrapWithGlobalHeaders(headers, globalHeaders, telemetryHeaders) {
|
|
731
735
|
if (!globalHeaders) {
|
|
732
736
|
return headers;
|
|
733
737
|
}
|
|
@@ -735,6 +739,11 @@ function wrapWithGlobalHeaders(headers, globalHeaders) {
|
|
|
735
739
|
headers.forEach((value, key) => {
|
|
736
740
|
finalHeaders.set(key, value);
|
|
737
741
|
});
|
|
742
|
+
telemetryHeaders?.forEach((value, key) => {
|
|
743
|
+
if (!value)
|
|
744
|
+
return;
|
|
745
|
+
finalHeaders.append(key, value);
|
|
746
|
+
});
|
|
738
747
|
return finalHeaders;
|
|
739
748
|
}
|
|
740
749
|
function processHeaders(request) {
|
|
@@ -772,6 +781,19 @@ function processHeaders(request) {
|
|
|
772
781
|
headers.set("Upstash-Timeout", `${request.timeout}s`);
|
|
773
782
|
}
|
|
774
783
|
}
|
|
784
|
+
if (request.flowControl?.key) {
|
|
785
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
786
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
787
|
+
const controlValue = [
|
|
788
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
789
|
+
rate ? `rate=${rate}` : void 0
|
|
790
|
+
].filter(Boolean);
|
|
791
|
+
if (controlValue.length === 0) {
|
|
792
|
+
throw new QstashError("Provide at least one of parallelism or ratePerSecond for flowControl");
|
|
793
|
+
}
|
|
794
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
795
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
796
|
+
}
|
|
775
797
|
return headers;
|
|
776
798
|
}
|
|
777
799
|
function getRequestPath(request) {
|
|
@@ -811,6 +833,15 @@ function decodeBase64(base64) {
|
|
|
811
833
|
}
|
|
812
834
|
}
|
|
813
835
|
}
|
|
836
|
+
function getRuntime() {
|
|
837
|
+
if (typeof process === "object" && typeof process.versions == "object" && process.versions.bun)
|
|
838
|
+
return `bun@${process.versions.bun}`;
|
|
839
|
+
if (typeof EdgeRuntime === "string")
|
|
840
|
+
return "edge-light";
|
|
841
|
+
else if (typeof process === "object" && typeof process.version === "string")
|
|
842
|
+
return `node@${process.version}`;
|
|
843
|
+
return "";
|
|
844
|
+
}
|
|
814
845
|
|
|
815
846
|
// src/client/queue.ts
|
|
816
847
|
var Queue = class {
|
|
@@ -885,7 +916,8 @@ var Queue = class {
|
|
|
885
916
|
}
|
|
886
917
|
const headers = wrapWithGlobalHeaders(
|
|
887
918
|
processHeaders(request),
|
|
888
|
-
this.http.headers
|
|
919
|
+
this.http.headers,
|
|
920
|
+
this.http.telemetryHeaders
|
|
889
921
|
);
|
|
890
922
|
const destination = getRequestPath(request);
|
|
891
923
|
const response = await this.http.request({
|
|
@@ -988,9 +1020,24 @@ var Schedules = class {
|
|
|
988
1020
|
if (request.queueName !== void 0) {
|
|
989
1021
|
headers.set("Upstash-Queue-Name", request.queueName);
|
|
990
1022
|
}
|
|
1023
|
+
if (request.flowControl?.key) {
|
|
1024
|
+
const parallelism = request.flowControl.parallelism?.toString();
|
|
1025
|
+
const rate = request.flowControl.ratePerSecond?.toString();
|
|
1026
|
+
const controlValue = [
|
|
1027
|
+
parallelism ? `parallelism=${parallelism}` : void 0,
|
|
1028
|
+
rate ? `rate=${rate}` : void 0
|
|
1029
|
+
].filter(Boolean);
|
|
1030
|
+
if (controlValue.length === 0) {
|
|
1031
|
+
throw new QstashError(
|
|
1032
|
+
"Provide at least one of parallelism or ratePerSecond for flowControl"
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1035
|
+
headers.set("Upstash-Flow-Control-Key", request.flowControl.key);
|
|
1036
|
+
headers.set("Upstash-Flow-Control-Value", controlValue.join(", "));
|
|
1037
|
+
}
|
|
991
1038
|
return await this.http.request({
|
|
992
1039
|
method: "POST",
|
|
993
|
-
headers: wrapWithGlobalHeaders(headers, this.http.headers),
|
|
1040
|
+
headers: wrapWithGlobalHeaders(headers, this.http.headers, this.http.telemetryHeaders),
|
|
994
1041
|
path: ["v2", "schedules", request.destination],
|
|
995
1042
|
body: request.body
|
|
996
1043
|
});
|
|
@@ -999,19 +1046,27 @@ var Schedules = class {
|
|
|
999
1046
|
* Get a schedule
|
|
1000
1047
|
*/
|
|
1001
1048
|
async get(scheduleId) {
|
|
1002
|
-
|
|
1049
|
+
const schedule = await this.http.request({
|
|
1003
1050
|
method: "GET",
|
|
1004
1051
|
path: ["v2", "schedules", scheduleId]
|
|
1005
1052
|
});
|
|
1053
|
+
if ("rate" in schedule)
|
|
1054
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1055
|
+
return schedule;
|
|
1006
1056
|
}
|
|
1007
1057
|
/**
|
|
1008
1058
|
* List your schedules
|
|
1009
1059
|
*/
|
|
1010
1060
|
async list() {
|
|
1011
|
-
|
|
1061
|
+
const schedules = await this.http.request({
|
|
1012
1062
|
method: "GET",
|
|
1013
1063
|
path: ["v2", "schedules"]
|
|
1014
1064
|
});
|
|
1065
|
+
for (const schedule of schedules) {
|
|
1066
|
+
if ("rate" in schedule)
|
|
1067
|
+
schedule.ratePerSecond = schedule.rate;
|
|
1068
|
+
}
|
|
1069
|
+
return schedules;
|
|
1015
1070
|
}
|
|
1016
1071
|
/**
|
|
1017
1072
|
* Delete a schedule
|
|
@@ -1108,20 +1163,37 @@ var UrlGroups = class {
|
|
|
1108
1163
|
}
|
|
1109
1164
|
};
|
|
1110
1165
|
|
|
1166
|
+
// version.ts
|
|
1167
|
+
var VERSION = "v2.7.23";
|
|
1168
|
+
|
|
1111
1169
|
// src/client/client.ts
|
|
1112
1170
|
var Client = class {
|
|
1113
1171
|
http;
|
|
1114
1172
|
token;
|
|
1115
1173
|
constructor(config) {
|
|
1116
1174
|
const environment = typeof process === "undefined" ? {} : process.env;
|
|
1117
|
-
|
|
1175
|
+
let baseUrl = (config?.baseUrl ?? environment.QSTASH_URL ?? "https://qstash.upstash.io").replace(/\/$/, "");
|
|
1176
|
+
if (baseUrl === "https://qstash.upstash.io/v2/publish") {
|
|
1177
|
+
baseUrl = "https://qstash.upstash.io";
|
|
1178
|
+
}
|
|
1118
1179
|
const token = config?.token ?? environment.QSTASH_TOKEN;
|
|
1180
|
+
const enableTelemetry = environment.UPSTASH_DISABLE_TELEMETRY ? false : config?.enableTelemetry ?? true;
|
|
1181
|
+
const isCloudflare = typeof caches !== "undefined" && "default" in caches;
|
|
1182
|
+
const telemetryHeaders = new Headers(
|
|
1183
|
+
enableTelemetry ? {
|
|
1184
|
+
"Upstash-Telemetry-Sdk": `upstash-qstash-js@${VERSION}`,
|
|
1185
|
+
"Upstash-Telemetry-Platform": isCloudflare ? "cloudflare" : environment.VERCEL ? "vercel" : environment.AWS_REGION ? "aws" : "",
|
|
1186
|
+
"Upstash-Telemetry-Runtime": getRuntime()
|
|
1187
|
+
} : {}
|
|
1188
|
+
);
|
|
1119
1189
|
this.http = new HttpClient({
|
|
1120
1190
|
retry: config?.retry,
|
|
1121
1191
|
baseUrl,
|
|
1122
1192
|
authorization: `Bearer ${token}`,
|
|
1123
1193
|
//@ts-expect-error caused by undici and bunjs type overlap
|
|
1124
|
-
headers: prefixHeaders(new Headers(config?.headers ?? {}))
|
|
1194
|
+
headers: prefixHeaders(new Headers(config?.headers ?? {})),
|
|
1195
|
+
//@ts-expect-error caused by undici and bunjs type overlap
|
|
1196
|
+
telemetryHeaders
|
|
1125
1197
|
});
|
|
1126
1198
|
if (!token) {
|
|
1127
1199
|
console.warn(
|
|
@@ -1203,7 +1275,8 @@ var Client = class {
|
|
|
1203
1275
|
async publish(request) {
|
|
1204
1276
|
const headers = wrapWithGlobalHeaders(
|
|
1205
1277
|
processHeaders(request),
|
|
1206
|
-
this.http.headers
|
|
1278
|
+
this.http.headers,
|
|
1279
|
+
this.http.telemetryHeaders
|
|
1207
1280
|
);
|
|
1208
1281
|
const response = await this.http.request({
|
|
1209
1282
|
path: ["v2", "publish", getRequestPath(request)],
|
|
@@ -1234,7 +1307,11 @@ var Client = class {
|
|
|
1234
1307
|
async batch(request) {
|
|
1235
1308
|
const messages = [];
|
|
1236
1309
|
for (const message of request) {
|
|
1237
|
-
const headers = wrapWithGlobalHeaders(
|
|
1310
|
+
const headers = wrapWithGlobalHeaders(
|
|
1311
|
+
processHeaders(message),
|
|
1312
|
+
this.http.headers,
|
|
1313
|
+
this.http.telemetryHeaders
|
|
1314
|
+
);
|
|
1238
1315
|
const headerEntries = Object.fromEntries(headers.entries());
|
|
1239
1316
|
messages.push({
|
|
1240
1317
|
destination: getRequestPath(message),
|
|
@@ -1289,7 +1366,7 @@ var Client = class {
|
|
|
1289
1366
|
* }
|
|
1290
1367
|
* ```
|
|
1291
1368
|
*/
|
|
1292
|
-
async
|
|
1369
|
+
async logs(request) {
|
|
1293
1370
|
const query = {};
|
|
1294
1371
|
if (typeof request?.cursor === "number" && request.cursor > 0) {
|
|
1295
1372
|
query.cursor = request.cursor.toString();
|
|
@@ -1311,16 +1388,42 @@ var Client = class {
|
|
|
1311
1388
|
method: "GET",
|
|
1312
1389
|
query
|
|
1313
1390
|
});
|
|
1391
|
+
const logs = responsePayload.events.map((event) => {
|
|
1392
|
+
return {
|
|
1393
|
+
...event,
|
|
1394
|
+
urlGroup: event.topicName
|
|
1395
|
+
};
|
|
1396
|
+
});
|
|
1314
1397
|
return {
|
|
1315
1398
|
cursor: responsePayload.cursor,
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
...event,
|
|
1319
|
-
urlGroup: event.topicName
|
|
1320
|
-
};
|
|
1321
|
-
})
|
|
1399
|
+
logs,
|
|
1400
|
+
events: logs
|
|
1322
1401
|
};
|
|
1323
1402
|
}
|
|
1403
|
+
/**
|
|
1404
|
+
* @deprecated Will be removed in the next major release. Use the `logs` method instead.
|
|
1405
|
+
*
|
|
1406
|
+
* Retrieve your logs.
|
|
1407
|
+
*
|
|
1408
|
+
* The logs endpoint is paginated and returns only 100 logs at a time.
|
|
1409
|
+
* If you want to receive more logs, you can use the cursor to paginate.
|
|
1410
|
+
*
|
|
1411
|
+
* The cursor is a unix timestamp with millisecond precision
|
|
1412
|
+
*
|
|
1413
|
+
* @example
|
|
1414
|
+
* ```ts
|
|
1415
|
+
* let cursor = Date.now()
|
|
1416
|
+
* const logs: Log[] = []
|
|
1417
|
+
* while (cursor > 0) {
|
|
1418
|
+
* const res = await qstash.logs({ cursor })
|
|
1419
|
+
* logs.push(...res.logs)
|
|
1420
|
+
* cursor = res.cursor ?? 0
|
|
1421
|
+
* }
|
|
1422
|
+
* ```
|
|
1423
|
+
*/
|
|
1424
|
+
async events(request) {
|
|
1425
|
+
return await this.logs(request);
|
|
1426
|
+
}
|
|
1324
1427
|
};
|
|
1325
1428
|
|
|
1326
1429
|
// src/client/workflow/constants.ts
|
|
@@ -64,7 +64,7 @@ declare class Receiver {
|
|
|
64
64
|
|
|
65
65
|
type State = "CREATED" | "ACTIVE" | "DELIVERED" | "ERROR" | "RETRY" | "FAILED";
|
|
66
66
|
type HTTPMethods = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
67
|
-
type
|
|
67
|
+
type Log = {
|
|
68
68
|
time: number;
|
|
69
69
|
state: State;
|
|
70
70
|
messageId: string;
|
|
@@ -77,13 +77,31 @@ type Event = {
|
|
|
77
77
|
header?: Record<string, string>;
|
|
78
78
|
body?: string;
|
|
79
79
|
};
|
|
80
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Deprecated. Use the `Log` type instead.
|
|
82
|
+
*
|
|
83
|
+
* @deprecated
|
|
84
|
+
*/
|
|
85
|
+
type Event = Log;
|
|
86
|
+
type LogPayload = Omit<Log, "urlGroup"> & {
|
|
81
87
|
topicName: string;
|
|
82
88
|
};
|
|
83
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Deprecated. Use the `EventPayload` type instead.
|
|
91
|
+
*
|
|
92
|
+
* @deprecated
|
|
93
|
+
*/
|
|
94
|
+
type EventPayload = LogPayload;
|
|
95
|
+
type GetLogsPayload = {
|
|
84
96
|
cursor?: string;
|
|
85
|
-
events:
|
|
97
|
+
events: LogPayload[];
|
|
86
98
|
};
|
|
99
|
+
/**
|
|
100
|
+
* Deprecated. use the `GetLogsPayload` type instead.
|
|
101
|
+
*
|
|
102
|
+
* @deprecated
|
|
103
|
+
*/
|
|
104
|
+
type GetEventsPayload = GetLogsPayload;
|
|
87
105
|
type WithCursor<T> = T & {
|
|
88
106
|
cursor?: number;
|
|
89
107
|
};
|
|
@@ -105,6 +123,30 @@ type RateLimit = {
|
|
|
105
123
|
remaining: string | null;
|
|
106
124
|
reset: string | null;
|
|
107
125
|
};
|
|
126
|
+
type FlowControl = {
|
|
127
|
+
/**
|
|
128
|
+
* flow control key
|
|
129
|
+
*/
|
|
130
|
+
key: string;
|
|
131
|
+
} & ({
|
|
132
|
+
/**
|
|
133
|
+
* number of requests which can be active with the same flow control key
|
|
134
|
+
*/
|
|
135
|
+
parallelism: number;
|
|
136
|
+
/**
|
|
137
|
+
* number of requests to activate per second with the same flow control key
|
|
138
|
+
*/
|
|
139
|
+
ratePerSecond?: number;
|
|
140
|
+
} | {
|
|
141
|
+
/**
|
|
142
|
+
* number of requests which can be active with the same flow control key
|
|
143
|
+
*/
|
|
144
|
+
parallelism?: number;
|
|
145
|
+
/**
|
|
146
|
+
* number of requests to activate per second with the same flow control key
|
|
147
|
+
*/
|
|
148
|
+
ratePerSecond: number;
|
|
149
|
+
});
|
|
108
150
|
|
|
109
151
|
type ProviderInfo = {
|
|
110
152
|
/**
|
|
@@ -363,6 +405,7 @@ type Requester = {
|
|
|
363
405
|
request: <TResult = unknown>(request: UpstashRequest) => Promise<UpstashResponse<TResult>>;
|
|
364
406
|
requestStream: (request: UpstashRequest) => AsyncIterable<ChatCompletionChunk>;
|
|
365
407
|
headers?: Headers;
|
|
408
|
+
telemetryHeaders?: Headers;
|
|
366
409
|
};
|
|
367
410
|
type RetryConfig = false | {
|
|
368
411
|
/**
|
|
@@ -457,6 +500,18 @@ type Message = {
|
|
|
457
500
|
* IP address of the publisher of this message
|
|
458
501
|
*/
|
|
459
502
|
callerIp?: string;
|
|
503
|
+
/**
|
|
504
|
+
* flow control key
|
|
505
|
+
*/
|
|
506
|
+
flowControlKey: string;
|
|
507
|
+
/**
|
|
508
|
+
* number of requests which can be active with the same flow control key
|
|
509
|
+
*/
|
|
510
|
+
parallelism?: number;
|
|
511
|
+
/**
|
|
512
|
+
* number of requests to activate per second with the same flow control key
|
|
513
|
+
*/
|
|
514
|
+
ratePerSecond?: number;
|
|
460
515
|
};
|
|
461
516
|
type MessagePayload = Omit<Message, "urlGroup"> & {
|
|
462
517
|
topicName: string;
|
|
@@ -693,6 +748,9 @@ type Schedule = {
|
|
|
693
748
|
callerIp?: string;
|
|
694
749
|
isPaused: boolean;
|
|
695
750
|
queueName?: string;
|
|
751
|
+
flowControlKey?: string;
|
|
752
|
+
parallelism?: number;
|
|
753
|
+
ratePerSecond?: number;
|
|
696
754
|
};
|
|
697
755
|
type CreateScheduleRequest = {
|
|
698
756
|
/**
|
|
@@ -781,6 +839,11 @@ type CreateScheduleRequest = {
|
|
|
781
839
|
* Queue name to schedule the message over.
|
|
782
840
|
*/
|
|
783
841
|
queueName?: string;
|
|
842
|
+
/**
|
|
843
|
+
* Settings for controlling the number of active requests
|
|
844
|
+
* and number of requests per second with the same key.
|
|
845
|
+
*/
|
|
846
|
+
flowControl?: FlowControl;
|
|
784
847
|
};
|
|
785
848
|
declare class Schedules {
|
|
786
849
|
private readonly http;
|
|
@@ -1587,6 +1650,13 @@ type ClientConfig = {
|
|
|
1587
1650
|
* These can be overridden by the headers in the request.
|
|
1588
1651
|
*/
|
|
1589
1652
|
headers?: HeadersInit;
|
|
1653
|
+
/**
|
|
1654
|
+
* Enable telemetry to help us improve the SDK.
|
|
1655
|
+
* The sdk will send the sdk version, platform and node version as telemetry headers.
|
|
1656
|
+
*
|
|
1657
|
+
* @default true
|
|
1658
|
+
*/
|
|
1659
|
+
enableTelemetry?: boolean;
|
|
1590
1660
|
};
|
|
1591
1661
|
type PublishBatchRequest<TBody = BodyInit> = PublishRequest<TBody> & {
|
|
1592
1662
|
queueName?: string;
|
|
@@ -1689,6 +1759,11 @@ type PublishRequest<TBody = BodyInit> = {
|
|
|
1689
1759
|
* @default undefined
|
|
1690
1760
|
*/
|
|
1691
1761
|
timeout?: Duration | number;
|
|
1762
|
+
/**
|
|
1763
|
+
* Settings for controlling the number of active requests
|
|
1764
|
+
* and number of requests per second with the same key.
|
|
1765
|
+
*/
|
|
1766
|
+
flowControl?: FlowControl;
|
|
1692
1767
|
} & ({
|
|
1693
1768
|
/**
|
|
1694
1769
|
* The url where the message should be sent to.
|
|
@@ -1772,11 +1847,17 @@ type PublishJsonRequest = Omit<PublishRequest, "body"> & {
|
|
|
1772
1847
|
*/
|
|
1773
1848
|
body: unknown;
|
|
1774
1849
|
};
|
|
1775
|
-
type
|
|
1850
|
+
type LogsRequest = {
|
|
1776
1851
|
cursor?: string | number;
|
|
1777
|
-
filter?:
|
|
1852
|
+
filter?: LogsRequestFilter;
|
|
1778
1853
|
};
|
|
1779
|
-
|
|
1854
|
+
/**
|
|
1855
|
+
* Deprecated. Use `LogsRequest` instead.
|
|
1856
|
+
*
|
|
1857
|
+
* @deprecated
|
|
1858
|
+
*/
|
|
1859
|
+
type EventsRequest = LogsRequest;
|
|
1860
|
+
type LogsRequestFilter = {
|
|
1780
1861
|
messageId?: string;
|
|
1781
1862
|
state?: State;
|
|
1782
1863
|
url?: string;
|
|
@@ -1789,10 +1870,22 @@ type EventsRequestFilter = {
|
|
|
1789
1870
|
toDate?: number;
|
|
1790
1871
|
count?: number;
|
|
1791
1872
|
};
|
|
1792
|
-
type
|
|
1873
|
+
type GetLogsResponse = {
|
|
1793
1874
|
cursor?: string;
|
|
1794
|
-
|
|
1875
|
+
logs: Log[];
|
|
1876
|
+
/**
|
|
1877
|
+
* Deprecated. Use the `logs` field instead.
|
|
1878
|
+
*
|
|
1879
|
+
* @deprecated
|
|
1880
|
+
*/
|
|
1881
|
+
events: Log[];
|
|
1795
1882
|
};
|
|
1883
|
+
/**
|
|
1884
|
+
* Deprecated. Use `GetLogsResponse` instead.
|
|
1885
|
+
*
|
|
1886
|
+
* @deprecated
|
|
1887
|
+
*/
|
|
1888
|
+
type GetEventsResponse = GetLogsResponse;
|
|
1796
1889
|
type QueueRequest = {
|
|
1797
1890
|
queueName?: string;
|
|
1798
1891
|
};
|
|
@@ -1887,7 +1980,29 @@ declare class Client {
|
|
|
1887
1980
|
* }
|
|
1888
1981
|
* ```
|
|
1889
1982
|
*/
|
|
1890
|
-
|
|
1983
|
+
logs(request?: LogsRequest): Promise<GetLogsResponse>;
|
|
1984
|
+
/**
|
|
1985
|
+
* @deprecated Will be removed in the next major release. Use the `logs` method instead.
|
|
1986
|
+
*
|
|
1987
|
+
* Retrieve your logs.
|
|
1988
|
+
*
|
|
1989
|
+
* The logs endpoint is paginated and returns only 100 logs at a time.
|
|
1990
|
+
* If you want to receive more logs, you can use the cursor to paginate.
|
|
1991
|
+
*
|
|
1992
|
+
* The cursor is a unix timestamp with millisecond precision
|
|
1993
|
+
*
|
|
1994
|
+
* @example
|
|
1995
|
+
* ```ts
|
|
1996
|
+
* let cursor = Date.now()
|
|
1997
|
+
* const logs: Log[] = []
|
|
1998
|
+
* while (cursor > 0) {
|
|
1999
|
+
* const res = await qstash.logs({ cursor })
|
|
2000
|
+
* logs.push(...res.logs)
|
|
2001
|
+
* cursor = res.cursor ?? 0
|
|
2002
|
+
* }
|
|
2003
|
+
* ```
|
|
2004
|
+
*/
|
|
2005
|
+
events(request?: LogsRequest): Promise<GetLogsResponse>;
|
|
1891
2006
|
}
|
|
1892
2007
|
type PublishToApiResponse = {
|
|
1893
2008
|
messageId: string;
|
|
@@ -1903,4 +2018,4 @@ type PublishResponse<TRequest> = TRequest extends {
|
|
|
1903
2018
|
urlGroup: string;
|
|
1904
2019
|
} ? PublishToUrlGroupsResponse : PublishToApiResponse;
|
|
1905
2020
|
|
|
1906
|
-
export {
|
|
2021
|
+
export { type StreamEnabled as $, type AddEndpointsRequest as A, BaseProvider as B, type ChatRateLimit as C, type EventPayload as D, type EmailOwner as E, type FailureFunctionPayload as F, type GetLogsResponse as G, type HTTPMethods as H, type GetLogsPayload as I, type GetEventsPayload as J, type BodyInit as K, type LLMOwner as L, type Message as M, type HeadersInit as N, type RequestOptions as O, type ProviderInfo as P, type QueueRequest as Q, type RateLimit as R, type Step as S, type FlowControl as T, type UrlGroup as U, type VerifyRequest as V, type WithCursor as W, Chat as X, type ChatCompletionMessage as Y, type ChatCompletion as Z, type ChatCompletionChunk as _, type ReceiverConfig as a, type StreamDisabled as a0, type StreamParameter as a1, type OpenAIChatModel as a2, type PromptChatRequest as a3, type ChatRequest as a4, upstash as a5, openai as a6, anthropic as a7, custom as a8, type RouteFunction as a9, type WorkflowServeOptions as aa, Workflow as ab, processOptions as ac, serve as ad, WorkflowContext as ae, DisabledWorkflowContext as af, type WorkflowClient as ag, type WorkflowReceiver as ah, StepTypes as ai, type StepType as aj, type RawStep as ak, type SyncStepFunction as al, type AsyncStepFunction as am, type StepFunction as an, type ParallelCallState as ao, type FinishCondition as ap, type RequiredExceptFields as aq, type LogLevel as ar, type WorkflowLoggerOptions as as, WorkflowLogger as at, SignatureError as b, Receiver as c, type PublishBatchRequest as d, type PublishRequest as e, type PublishJsonRequest as f, type LogsRequest as g, type EventsRequest as h, type GetEventsResponse as i, Client as j, type PublishToApiResponse as k, type PublishToUrlResponse as l, type PublishToUrlGroupsResponse as m, type PublishResponse as n, type MessagePayload as o, Messages as p, type Schedule as q, type CreateScheduleRequest as r, Schedules as s, type Endpoint as t, type RemoveEndpointsRequest as u, UrlGroups as v, type State as w, type Log as x, type Event as y, type LogPayload as z };
|