@upstash/qstash 2.7.16 → 2.7.18
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-GWAFAA2M.mjs → chunk-A3H5A6JL.mjs} +38 -26
- package/{chunk-7UVG6FOM.mjs → chunk-A5VKSI7H.mjs} +1 -1
- package/{chunk-OX4OZYVD.mjs → chunk-K2ZUMNWA.mjs} +2 -1
- package/{client-RORrka04.d.ts → client-B0bFJMw6.d.mts} +27 -0
- package/{client-RORrka04.d.mts → client-B0bFJMw6.d.ts} +27 -0
- package/cloudflare.d.mts +5 -1
- package/cloudflare.d.ts +5 -1
- package/cloudflare.js +38 -26
- package/cloudflare.mjs +1 -1
- package/h3.d.mts +6 -1
- package/h3.d.ts +6 -1
- package/h3.js +38 -26
- package/h3.mjs +3 -3
- package/hono.d.mts +5 -1
- package/hono.d.ts +5 -1
- package/hono.js +38 -26
- package/hono.mjs +1 -1
- package/index.d.mts +5 -3
- package/index.d.ts +5 -3
- package/index.js +38 -25
- package/index.mjs +2 -2
- package/nextjs.d.mts +10 -1
- package/nextjs.d.ts +10 -1
- package/nextjs.js +38 -26
- package/nextjs.mjs +1 -1
- package/nuxt.d.mts +3 -1
- package/nuxt.d.ts +3 -1
- package/nuxt.mjs +3 -3
- package/package.json +1 -1
- package/solidjs.d.mts +5 -1
- package/solidjs.d.ts +5 -1
- package/solidjs.js +38 -26
- package/solidjs.mjs +2 -2
- package/svelte.d.mts +5 -1
- package/svelte.d.ts +5 -1
- package/svelte.js +38 -26
- package/svelte.mjs +2 -2
- package/workflow.d.mts +1 -1
- package/workflow.d.ts +1 -1
- package/workflow.js +38 -26
- package/workflow.mjs +1 -1
package/h3.js
CHANGED
|
@@ -476,10 +476,13 @@ var DLQ = class {
|
|
|
476
476
|
};
|
|
477
477
|
|
|
478
478
|
// src/client/error.ts
|
|
479
|
+
var RATELIMIT_STATUS = 429;
|
|
479
480
|
var QstashError = class extends Error {
|
|
480
|
-
|
|
481
|
+
status;
|
|
482
|
+
constructor(message, status) {
|
|
481
483
|
super(message);
|
|
482
484
|
this.name = "QstashError";
|
|
485
|
+
this.status = status;
|
|
483
486
|
}
|
|
484
487
|
};
|
|
485
488
|
var QstashRatelimitError = class extends QstashError {
|
|
@@ -487,7 +490,7 @@ var QstashRatelimitError = class extends QstashError {
|
|
|
487
490
|
remaining;
|
|
488
491
|
reset;
|
|
489
492
|
constructor(args) {
|
|
490
|
-
super(`Exceeded burst rate limit. ${JSON.stringify(args)}
|
|
493
|
+
super(`Exceeded burst rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
|
|
491
494
|
this.name = "QstashRatelimitError";
|
|
492
495
|
this.limit = args.limit;
|
|
493
496
|
this.remaining = args.remaining;
|
|
@@ -502,7 +505,8 @@ var QstashChatRatelimitError = class extends QstashError {
|
|
|
502
505
|
resetRequests;
|
|
503
506
|
resetTokens;
|
|
504
507
|
constructor(args) {
|
|
505
|
-
super(`Exceeded chat rate limit. ${JSON.stringify(args)}
|
|
508
|
+
super(`Exceeded chat rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
|
|
509
|
+
this.name = "QstashChatRatelimitError";
|
|
506
510
|
this.limitRequests = args["limit-requests"];
|
|
507
511
|
this.limitTokens = args["limit-tokens"];
|
|
508
512
|
this.remainingRequests = args["remaining-requests"];
|
|
@@ -516,11 +520,11 @@ var QstashDailyRatelimitError = class extends QstashError {
|
|
|
516
520
|
remaining;
|
|
517
521
|
reset;
|
|
518
522
|
constructor(args) {
|
|
519
|
-
super(`Exceeded daily rate limit. ${JSON.stringify(args)}
|
|
523
|
+
super(`Exceeded daily rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
|
|
524
|
+
this.name = "QstashDailyRatelimitError";
|
|
520
525
|
this.limit = args.limit;
|
|
521
526
|
this.remaining = args.remaining;
|
|
522
527
|
this.reset = args.reset;
|
|
523
|
-
this.name = "QstashChatRatelimitError";
|
|
524
528
|
}
|
|
525
529
|
};
|
|
526
530
|
var QStashWorkflowError = class extends QstashError {
|
|
@@ -677,7 +681,10 @@ var HttpClient = class {
|
|
|
677
681
|
}
|
|
678
682
|
if (response.status < 200 || response.status >= 300) {
|
|
679
683
|
const body = await response.text();
|
|
680
|
-
throw new QstashError(
|
|
684
|
+
throw new QstashError(
|
|
685
|
+
body.length > 0 ? body : `Error: status=${response.status}`,
|
|
686
|
+
response.status
|
|
687
|
+
);
|
|
681
688
|
}
|
|
682
689
|
}
|
|
683
690
|
};
|
|
@@ -917,6 +924,7 @@ var BaseProvider = class {
|
|
|
917
924
|
var LLMProvider = class extends BaseProvider {
|
|
918
925
|
apiKind = "llm";
|
|
919
926
|
organization;
|
|
927
|
+
method = "POST";
|
|
920
928
|
constructor(baseUrl, token, owner, organization) {
|
|
921
929
|
super(baseUrl, token, owner);
|
|
922
930
|
this.organization = organization;
|
|
@@ -977,15 +985,24 @@ var getProviderInfo = (api, upstashToken) => {
|
|
|
977
985
|
baseUrl: finalProvider.baseUrl,
|
|
978
986
|
route: finalProvider.getRoute(),
|
|
979
987
|
appendHeaders: finalProvider.getHeaders(parameters),
|
|
980
|
-
owner: finalProvider.owner
|
|
988
|
+
owner: finalProvider.owner,
|
|
989
|
+
method: finalProvider.method
|
|
981
990
|
};
|
|
982
991
|
return finalProvider.onFinish(providerInfo, parameters);
|
|
983
992
|
};
|
|
984
|
-
var
|
|
993
|
+
var safeJoinHeaders = (headers, record) => {
|
|
994
|
+
const joinedHeaders = new Headers(record);
|
|
995
|
+
for (const [header, value] of headers.entries()) {
|
|
996
|
+
joinedHeaders.set(header, value);
|
|
997
|
+
}
|
|
998
|
+
return joinedHeaders;
|
|
999
|
+
};
|
|
1000
|
+
var processApi = (request, headers, upstashToken) => {
|
|
985
1001
|
if (!request.api) {
|
|
1002
|
+
request.headers = headers;
|
|
986
1003
|
return request;
|
|
987
1004
|
}
|
|
988
|
-
const { url, appendHeaders, owner } = getProviderInfo(request.api, upstashToken);
|
|
1005
|
+
const { url, appendHeaders, owner, method } = getProviderInfo(request.api, upstashToken);
|
|
989
1006
|
if (request.api.name === "llm") {
|
|
990
1007
|
const callback = request.callback;
|
|
991
1008
|
if (!callback) {
|
|
@@ -993,21 +1010,15 @@ var processApi = (request, upstashToken) => {
|
|
|
993
1010
|
}
|
|
994
1011
|
return {
|
|
995
1012
|
...request,
|
|
996
|
-
|
|
997
|
-
headers:
|
|
998
|
-
...request.headers,
|
|
999
|
-
...appendHeaders
|
|
1000
|
-
}),
|
|
1013
|
+
method: request.method ?? method,
|
|
1014
|
+
headers: safeJoinHeaders(headers, appendHeaders),
|
|
1001
1015
|
...owner === "upstash" && !request.api.analytics ? { api: { name: "llm" }, url: void 0, callback } : { url, api: void 0 }
|
|
1002
1016
|
};
|
|
1003
1017
|
} else {
|
|
1004
1018
|
return {
|
|
1005
1019
|
...request,
|
|
1006
|
-
|
|
1007
|
-
headers:
|
|
1008
|
-
...request.headers,
|
|
1009
|
-
...appendHeaders
|
|
1010
|
-
}),
|
|
1020
|
+
method: request.method ?? method,
|
|
1021
|
+
headers: safeJoinHeaders(headers, appendHeaders),
|
|
1011
1022
|
url,
|
|
1012
1023
|
api: void 0
|
|
1013
1024
|
};
|
|
@@ -1217,9 +1228,8 @@ var Queue = class {
|
|
|
1217
1228
|
async enqueueJSON(request) {
|
|
1218
1229
|
const headers = prefixHeaders(new Headers(request.headers));
|
|
1219
1230
|
headers.set("Content-Type", "application/json");
|
|
1220
|
-
request.headers = headers;
|
|
1221
1231
|
const upstashToken = String(this.http.authorization).split("Bearer ")[1];
|
|
1222
|
-
const nonApiRequest = processApi(request, upstashToken);
|
|
1232
|
+
const nonApiRequest = processApi(request, headers, upstashToken);
|
|
1223
1233
|
const response = await this.enqueue({
|
|
1224
1234
|
...nonApiRequest,
|
|
1225
1235
|
body: JSON.stringify(nonApiRequest.body),
|
|
@@ -2003,7 +2013,7 @@ var validateParallelSteps = (lazySteps, stepsFromRequest) => {
|
|
|
2003
2013
|
};
|
|
2004
2014
|
var sortSteps = (steps) => {
|
|
2005
2015
|
const getStepId = (step) => step.targetStep ?? step.stepId;
|
|
2006
|
-
return steps.
|
|
2016
|
+
return [...steps].sort((step, stepOther) => getStepId(step) - getStepId(stepOther));
|
|
2007
2017
|
};
|
|
2008
2018
|
|
|
2009
2019
|
// src/client/workflow/steps.ts
|
|
@@ -2869,6 +2879,10 @@ var Client = class {
|
|
|
2869
2879
|
* Access the workflow API.
|
|
2870
2880
|
*
|
|
2871
2881
|
* cancel workflows.
|
|
2882
|
+
*
|
|
2883
|
+
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
|
|
2884
|
+
* Please use @upstash/workflow instead https://github.com/upstash/workflow-js
|
|
2885
|
+
* Migration Guide: https://upstash.com/docs/workflow/migration
|
|
2872
2886
|
*/
|
|
2873
2887
|
get workflow() {
|
|
2874
2888
|
return new Workflow(this.http);
|
|
@@ -2906,9 +2920,8 @@ var Client = class {
|
|
|
2906
2920
|
async publishJSON(request) {
|
|
2907
2921
|
const headers = prefixHeaders(new Headers(request.headers));
|
|
2908
2922
|
headers.set("Content-Type", "application/json");
|
|
2909
|
-
request.headers = headers;
|
|
2910
2923
|
const upstashToken = String(this.http.authorization).split("Bearer ")[1];
|
|
2911
|
-
const nonApiRequest = processApi(request, upstashToken);
|
|
2924
|
+
const nonApiRequest = processApi(request, headers, upstashToken);
|
|
2912
2925
|
const response = await this.publish({
|
|
2913
2926
|
...nonApiRequest,
|
|
2914
2927
|
body: JSON.stringify(nonApiRequest.body)
|
|
@@ -2949,9 +2962,8 @@ var Client = class {
|
|
|
2949
2962
|
if ("body" in message) {
|
|
2950
2963
|
message.body = JSON.stringify(message.body);
|
|
2951
2964
|
}
|
|
2952
|
-
message.headers = new Headers(message.headers);
|
|
2953
2965
|
const upstashToken = String(this.http.authorization).split("Bearer ")[1];
|
|
2954
|
-
const nonApiMessage = processApi(message, upstashToken);
|
|
2966
|
+
const nonApiMessage = processApi(message, new Headers(message.headers), upstashToken);
|
|
2955
2967
|
nonApiMessage.headers.set("Content-Type", "application/json");
|
|
2956
2968
|
return nonApiMessage;
|
|
2957
2969
|
});
|
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-A5VKSI7H.mjs";
|
|
5
|
+
import "./chunk-K2ZUMNWA.mjs";
|
|
6
|
+
import "./chunk-A3H5A6JL.mjs";
|
|
7
7
|
export {
|
|
8
8
|
serve,
|
|
9
9
|
verifySignatureH3
|
package/hono.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-
|
|
2
|
+
import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.mjs';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
type WorkflowBindings = {
|
|
@@ -17,6 +17,10 @@ type WorkflowBindings = {
|
|
|
17
17
|
* @param routeFunction workflow function
|
|
18
18
|
* @param options workflow options
|
|
19
19
|
* @returns
|
|
20
|
+
*
|
|
21
|
+
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
|
|
22
|
+
* Please use https://github.com/upstash/workflow-js
|
|
23
|
+
* Migration Guide: https://upstash.com/docs/workflow/migration
|
|
20
24
|
*/
|
|
21
25
|
declare const serve: <TInitialPayload = unknown, TBindings extends WorkflowBindings = WorkflowBindings>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => ((context: Context<{
|
|
22
26
|
Bindings: TBindings;
|
package/hono.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-
|
|
2
|
+
import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.js';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
type WorkflowBindings = {
|
|
@@ -17,6 +17,10 @@ type WorkflowBindings = {
|
|
|
17
17
|
* @param routeFunction workflow function
|
|
18
18
|
* @param options workflow options
|
|
19
19
|
* @returns
|
|
20
|
+
*
|
|
21
|
+
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
|
|
22
|
+
* Please use https://github.com/upstash/workflow-js
|
|
23
|
+
* Migration Guide: https://upstash.com/docs/workflow/migration
|
|
20
24
|
*/
|
|
21
25
|
declare const serve: <TInitialPayload = unknown, TBindings extends WorkflowBindings = WorkflowBindings>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => ((context: Context<{
|
|
22
26
|
Bindings: TBindings;
|
package/hono.js
CHANGED
|
@@ -152,10 +152,13 @@ var DLQ = class {
|
|
|
152
152
|
};
|
|
153
153
|
|
|
154
154
|
// src/client/error.ts
|
|
155
|
+
var RATELIMIT_STATUS = 429;
|
|
155
156
|
var QstashError = class extends Error {
|
|
156
|
-
|
|
157
|
+
status;
|
|
158
|
+
constructor(message, status) {
|
|
157
159
|
super(message);
|
|
158
160
|
this.name = "QstashError";
|
|
161
|
+
this.status = status;
|
|
159
162
|
}
|
|
160
163
|
};
|
|
161
164
|
var QstashRatelimitError = class extends QstashError {
|
|
@@ -163,7 +166,7 @@ var QstashRatelimitError = class extends QstashError {
|
|
|
163
166
|
remaining;
|
|
164
167
|
reset;
|
|
165
168
|
constructor(args) {
|
|
166
|
-
super(`Exceeded burst rate limit. ${JSON.stringify(args)}
|
|
169
|
+
super(`Exceeded burst rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
|
|
167
170
|
this.name = "QstashRatelimitError";
|
|
168
171
|
this.limit = args.limit;
|
|
169
172
|
this.remaining = args.remaining;
|
|
@@ -178,7 +181,8 @@ var QstashChatRatelimitError = class extends QstashError {
|
|
|
178
181
|
resetRequests;
|
|
179
182
|
resetTokens;
|
|
180
183
|
constructor(args) {
|
|
181
|
-
super(`Exceeded chat rate limit. ${JSON.stringify(args)}
|
|
184
|
+
super(`Exceeded chat rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
|
|
185
|
+
this.name = "QstashChatRatelimitError";
|
|
182
186
|
this.limitRequests = args["limit-requests"];
|
|
183
187
|
this.limitTokens = args["limit-tokens"];
|
|
184
188
|
this.remainingRequests = args["remaining-requests"];
|
|
@@ -192,11 +196,11 @@ var QstashDailyRatelimitError = class extends QstashError {
|
|
|
192
196
|
remaining;
|
|
193
197
|
reset;
|
|
194
198
|
constructor(args) {
|
|
195
|
-
super(`Exceeded daily rate limit. ${JSON.stringify(args)}
|
|
199
|
+
super(`Exceeded daily rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
|
|
200
|
+
this.name = "QstashDailyRatelimitError";
|
|
196
201
|
this.limit = args.limit;
|
|
197
202
|
this.remaining = args.remaining;
|
|
198
203
|
this.reset = args.reset;
|
|
199
|
-
this.name = "QstashChatRatelimitError";
|
|
200
204
|
}
|
|
201
205
|
};
|
|
202
206
|
var QStashWorkflowError = class extends QstashError {
|
|
@@ -353,7 +357,10 @@ var HttpClient = class {
|
|
|
353
357
|
}
|
|
354
358
|
if (response.status < 200 || response.status >= 300) {
|
|
355
359
|
const body = await response.text();
|
|
356
|
-
throw new QstashError(
|
|
360
|
+
throw new QstashError(
|
|
361
|
+
body.length > 0 ? body : `Error: status=${response.status}`,
|
|
362
|
+
response.status
|
|
363
|
+
);
|
|
357
364
|
}
|
|
358
365
|
}
|
|
359
366
|
};
|
|
@@ -593,6 +600,7 @@ var BaseProvider = class {
|
|
|
593
600
|
var LLMProvider = class extends BaseProvider {
|
|
594
601
|
apiKind = "llm";
|
|
595
602
|
organization;
|
|
603
|
+
method = "POST";
|
|
596
604
|
constructor(baseUrl, token, owner, organization) {
|
|
597
605
|
super(baseUrl, token, owner);
|
|
598
606
|
this.organization = organization;
|
|
@@ -653,15 +661,24 @@ var getProviderInfo = (api, upstashToken) => {
|
|
|
653
661
|
baseUrl: finalProvider.baseUrl,
|
|
654
662
|
route: finalProvider.getRoute(),
|
|
655
663
|
appendHeaders: finalProvider.getHeaders(parameters),
|
|
656
|
-
owner: finalProvider.owner
|
|
664
|
+
owner: finalProvider.owner,
|
|
665
|
+
method: finalProvider.method
|
|
657
666
|
};
|
|
658
667
|
return finalProvider.onFinish(providerInfo, parameters);
|
|
659
668
|
};
|
|
660
|
-
var
|
|
669
|
+
var safeJoinHeaders = (headers, record) => {
|
|
670
|
+
const joinedHeaders = new Headers(record);
|
|
671
|
+
for (const [header, value] of headers.entries()) {
|
|
672
|
+
joinedHeaders.set(header, value);
|
|
673
|
+
}
|
|
674
|
+
return joinedHeaders;
|
|
675
|
+
};
|
|
676
|
+
var processApi = (request, headers, upstashToken) => {
|
|
661
677
|
if (!request.api) {
|
|
678
|
+
request.headers = headers;
|
|
662
679
|
return request;
|
|
663
680
|
}
|
|
664
|
-
const { url, appendHeaders, owner } = getProviderInfo(request.api, upstashToken);
|
|
681
|
+
const { url, appendHeaders, owner, method } = getProviderInfo(request.api, upstashToken);
|
|
665
682
|
if (request.api.name === "llm") {
|
|
666
683
|
const callback = request.callback;
|
|
667
684
|
if (!callback) {
|
|
@@ -669,21 +686,15 @@ var processApi = (request, upstashToken) => {
|
|
|
669
686
|
}
|
|
670
687
|
return {
|
|
671
688
|
...request,
|
|
672
|
-
|
|
673
|
-
headers:
|
|
674
|
-
...request.headers,
|
|
675
|
-
...appendHeaders
|
|
676
|
-
}),
|
|
689
|
+
method: request.method ?? method,
|
|
690
|
+
headers: safeJoinHeaders(headers, appendHeaders),
|
|
677
691
|
...owner === "upstash" && !request.api.analytics ? { api: { name: "llm" }, url: void 0, callback } : { url, api: void 0 }
|
|
678
692
|
};
|
|
679
693
|
} else {
|
|
680
694
|
return {
|
|
681
695
|
...request,
|
|
682
|
-
|
|
683
|
-
headers:
|
|
684
|
-
...request.headers,
|
|
685
|
-
...appendHeaders
|
|
686
|
-
}),
|
|
696
|
+
method: request.method ?? method,
|
|
697
|
+
headers: safeJoinHeaders(headers, appendHeaders),
|
|
687
698
|
url,
|
|
688
699
|
api: void 0
|
|
689
700
|
};
|
|
@@ -893,9 +904,8 @@ var Queue = class {
|
|
|
893
904
|
async enqueueJSON(request) {
|
|
894
905
|
const headers = prefixHeaders(new Headers(request.headers));
|
|
895
906
|
headers.set("Content-Type", "application/json");
|
|
896
|
-
request.headers = headers;
|
|
897
907
|
const upstashToken = String(this.http.authorization).split("Bearer ")[1];
|
|
898
|
-
const nonApiRequest = processApi(request, upstashToken);
|
|
908
|
+
const nonApiRequest = processApi(request, headers, upstashToken);
|
|
899
909
|
const response = await this.enqueue({
|
|
900
910
|
...nonApiRequest,
|
|
901
911
|
body: JSON.stringify(nonApiRequest.body),
|
|
@@ -1159,6 +1169,10 @@ var Client = class {
|
|
|
1159
1169
|
* Access the workflow API.
|
|
1160
1170
|
*
|
|
1161
1171
|
* cancel workflows.
|
|
1172
|
+
*
|
|
1173
|
+
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
|
|
1174
|
+
* Please use @upstash/workflow instead https://github.com/upstash/workflow-js
|
|
1175
|
+
* Migration Guide: https://upstash.com/docs/workflow/migration
|
|
1162
1176
|
*/
|
|
1163
1177
|
get workflow() {
|
|
1164
1178
|
return new Workflow(this.http);
|
|
@@ -1196,9 +1210,8 @@ var Client = class {
|
|
|
1196
1210
|
async publishJSON(request) {
|
|
1197
1211
|
const headers = prefixHeaders(new Headers(request.headers));
|
|
1198
1212
|
headers.set("Content-Type", "application/json");
|
|
1199
|
-
request.headers = headers;
|
|
1200
1213
|
const upstashToken = String(this.http.authorization).split("Bearer ")[1];
|
|
1201
|
-
const nonApiRequest = processApi(request, upstashToken);
|
|
1214
|
+
const nonApiRequest = processApi(request, headers, upstashToken);
|
|
1202
1215
|
const response = await this.publish({
|
|
1203
1216
|
...nonApiRequest,
|
|
1204
1217
|
body: JSON.stringify(nonApiRequest.body)
|
|
@@ -1239,9 +1252,8 @@ var Client = class {
|
|
|
1239
1252
|
if ("body" in message) {
|
|
1240
1253
|
message.body = JSON.stringify(message.body);
|
|
1241
1254
|
}
|
|
1242
|
-
message.headers = new Headers(message.headers);
|
|
1243
1255
|
const upstashToken = String(this.http.authorization).split("Bearer ")[1];
|
|
1244
|
-
const nonApiMessage = processApi(message, upstashToken);
|
|
1256
|
+
const nonApiMessage = processApi(message, new Headers(message.headers), upstashToken);
|
|
1245
1257
|
nonApiMessage.headers.set("Content-Type", "application/json");
|
|
1246
1258
|
return nonApiMessage;
|
|
1247
1259
|
});
|
|
@@ -1879,7 +1891,7 @@ var validateParallelSteps = (lazySteps, stepsFromRequest) => {
|
|
|
1879
1891
|
};
|
|
1880
1892
|
var sortSteps = (steps) => {
|
|
1881
1893
|
const getStepId = (step) => step.targetStep ?? step.stepId;
|
|
1882
|
-
return steps.
|
|
1894
|
+
return [...steps].sort((step, stepOther) => getStepId(step) - getStepId(stepOther));
|
|
1883
1895
|
};
|
|
1884
1896
|
|
|
1885
1897
|
// src/client/workflow/steps.ts
|
package/hono.mjs
CHANGED
package/index.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload, L as LLMOwner, B as BaseProvider, E as EmailOwner, P as ProviderInfo } from './client-
|
|
2
|
-
export { A as AddEndpointsRequest, y as BodyInit, I as Chat, K as ChatCompletion, N as ChatCompletionChunk, J as ChatCompletionMessage, _ as ChatRequest, h as Client, p as CreateScheduleRequest, r as Endpoint, v as Event, w as EventPayload, g as EventsRequest, x as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, z as HeadersInit, M as Message, m as MessagePayload, n as Messages, Y as OpenAIChatModel, Z as PromptChatRequest, d as PublishBatchRequest, f as PublishJsonRequest, e as PublishRequest, l as PublishResponse, i as PublishToApiResponse, k as PublishToUrlGroupsResponse, j as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, s as RemoveEndpointsRequest, D as RequestOptions, o as Schedule, q as Schedules, b as SignatureError, u as State, T as StreamDisabled, O as StreamEnabled, X as StreamParameter, U as UrlGroup, t as UrlGroups, V as VerifyRequest, W as WithCursor, a1 as anthropic, a2 as custom, a0 as openai, $ as upstash } from './client-
|
|
1
|
+
import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload, L as LLMOwner, B as BaseProvider, E as EmailOwner, P as ProviderInfo } from './client-B0bFJMw6.mjs';
|
|
2
|
+
export { A as AddEndpointsRequest, y as BodyInit, I as Chat, K as ChatCompletion, N as ChatCompletionChunk, J as ChatCompletionMessage, _ as ChatRequest, h as Client, p as CreateScheduleRequest, r as Endpoint, v as Event, w as EventPayload, g as EventsRequest, x as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, z as HeadersInit, M as Message, m as MessagePayload, n as Messages, Y as OpenAIChatModel, Z as PromptChatRequest, d as PublishBatchRequest, f as PublishJsonRequest, e as PublishRequest, l as PublishResponse, i as PublishToApiResponse, k as PublishToUrlGroupsResponse, j as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, s as RemoveEndpointsRequest, D as RequestOptions, o as Schedule, q as Schedules, b as SignatureError, u as State, T as StreamDisabled, O as StreamEnabled, X as StreamParameter, U as UrlGroup, t as UrlGroups, V as VerifyRequest, W as WithCursor, a1 as anthropic, a2 as custom, a0 as openai, $ as upstash } from './client-B0bFJMw6.mjs';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Result of 500 Internal Server Error
|
|
7
7
|
*/
|
|
8
8
|
declare class QstashError extends Error {
|
|
9
|
-
|
|
9
|
+
readonly status?: number;
|
|
10
|
+
constructor(message: string, status?: number);
|
|
10
11
|
}
|
|
11
12
|
declare class QstashRatelimitError extends QstashError {
|
|
12
13
|
limit: string | null;
|
|
@@ -77,6 +78,7 @@ declare const setupAnalytics: (analytics: AnalyticsConfig | undefined, providerA
|
|
|
77
78
|
declare class EmailProvider extends BaseProvider<"email", EmailOwner> {
|
|
78
79
|
readonly apiKind = "email";
|
|
79
80
|
readonly batch: boolean;
|
|
81
|
+
readonly method = "POST";
|
|
80
82
|
constructor(baseUrl: string, token: string, owner: EmailOwner, batch: boolean);
|
|
81
83
|
getRoute(): string[];
|
|
82
84
|
getHeaders(_options: unknown): Record<string, string>;
|
package/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload, L as LLMOwner, B as BaseProvider, E as EmailOwner, P as ProviderInfo } from './client-
|
|
2
|
-
export { A as AddEndpointsRequest, y as BodyInit, I as Chat, K as ChatCompletion, N as ChatCompletionChunk, J as ChatCompletionMessage, _ as ChatRequest, h as Client, p as CreateScheduleRequest, r as Endpoint, v as Event, w as EventPayload, g as EventsRequest, x as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, z as HeadersInit, M as Message, m as MessagePayload, n as Messages, Y as OpenAIChatModel, Z as PromptChatRequest, d as PublishBatchRequest, f as PublishJsonRequest, e as PublishRequest, l as PublishResponse, i as PublishToApiResponse, k as PublishToUrlGroupsResponse, j as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, s as RemoveEndpointsRequest, D as RequestOptions, o as Schedule, q as Schedules, b as SignatureError, u as State, T as StreamDisabled, O as StreamEnabled, X as StreamParameter, U as UrlGroup, t as UrlGroups, V as VerifyRequest, W as WithCursor, a1 as anthropic, a2 as custom, a0 as openai, $ as upstash } from './client-
|
|
1
|
+
import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload, L as LLMOwner, B as BaseProvider, E as EmailOwner, P as ProviderInfo } from './client-B0bFJMw6.js';
|
|
2
|
+
export { A as AddEndpointsRequest, y as BodyInit, I as Chat, K as ChatCompletion, N as ChatCompletionChunk, J as ChatCompletionMessage, _ as ChatRequest, h as Client, p as CreateScheduleRequest, r as Endpoint, v as Event, w as EventPayload, g as EventsRequest, x as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, z as HeadersInit, M as Message, m as MessagePayload, n as Messages, Y as OpenAIChatModel, Z as PromptChatRequest, d as PublishBatchRequest, f as PublishJsonRequest, e as PublishRequest, l as PublishResponse, i as PublishToApiResponse, k as PublishToUrlGroupsResponse, j as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, s as RemoveEndpointsRequest, D as RequestOptions, o as Schedule, q as Schedules, b as SignatureError, u as State, T as StreamDisabled, O as StreamEnabled, X as StreamParameter, U as UrlGroup, t as UrlGroups, V as VerifyRequest, W as WithCursor, a1 as anthropic, a2 as custom, a0 as openai, $ as upstash } from './client-B0bFJMw6.js';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Result of 500 Internal Server Error
|
|
7
7
|
*/
|
|
8
8
|
declare class QstashError extends Error {
|
|
9
|
-
|
|
9
|
+
readonly status?: number;
|
|
10
|
+
constructor(message: string, status?: number);
|
|
10
11
|
}
|
|
11
12
|
declare class QstashRatelimitError extends QstashError {
|
|
12
13
|
limit: string | null;
|
|
@@ -77,6 +78,7 @@ declare const setupAnalytics: (analytics: AnalyticsConfig | undefined, providerA
|
|
|
77
78
|
declare class EmailProvider extends BaseProvider<"email", EmailOwner> {
|
|
78
79
|
readonly apiKind = "email";
|
|
79
80
|
readonly batch: boolean;
|
|
81
|
+
readonly method = "POST";
|
|
80
82
|
constructor(baseUrl: string, token: string, owner: EmailOwner, batch: boolean);
|
|
81
83
|
getRoute(): string[];
|
|
82
84
|
getHeaders(_options: unknown): Record<string, string>;
|
package/index.js
CHANGED
|
@@ -172,10 +172,13 @@ var DLQ = class {
|
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
// src/client/error.ts
|
|
175
|
+
var RATELIMIT_STATUS = 429;
|
|
175
176
|
var QstashError = class extends Error {
|
|
176
|
-
|
|
177
|
+
status;
|
|
178
|
+
constructor(message, status) {
|
|
177
179
|
super(message);
|
|
178
180
|
this.name = "QstashError";
|
|
181
|
+
this.status = status;
|
|
179
182
|
}
|
|
180
183
|
};
|
|
181
184
|
var QstashRatelimitError = class extends QstashError {
|
|
@@ -183,7 +186,7 @@ var QstashRatelimitError = class extends QstashError {
|
|
|
183
186
|
remaining;
|
|
184
187
|
reset;
|
|
185
188
|
constructor(args) {
|
|
186
|
-
super(`Exceeded burst rate limit. ${JSON.stringify(args)}
|
|
189
|
+
super(`Exceeded burst rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
|
|
187
190
|
this.name = "QstashRatelimitError";
|
|
188
191
|
this.limit = args.limit;
|
|
189
192
|
this.remaining = args.remaining;
|
|
@@ -198,7 +201,8 @@ var QstashChatRatelimitError = class extends QstashError {
|
|
|
198
201
|
resetRequests;
|
|
199
202
|
resetTokens;
|
|
200
203
|
constructor(args) {
|
|
201
|
-
super(`Exceeded chat rate limit. ${JSON.stringify(args)}
|
|
204
|
+
super(`Exceeded chat rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
|
|
205
|
+
this.name = "QstashChatRatelimitError";
|
|
202
206
|
this.limitRequests = args["limit-requests"];
|
|
203
207
|
this.limitTokens = args["limit-tokens"];
|
|
204
208
|
this.remainingRequests = args["remaining-requests"];
|
|
@@ -212,11 +216,11 @@ var QstashDailyRatelimitError = class extends QstashError {
|
|
|
212
216
|
remaining;
|
|
213
217
|
reset;
|
|
214
218
|
constructor(args) {
|
|
215
|
-
super(`Exceeded daily rate limit. ${JSON.stringify(args)}
|
|
219
|
+
super(`Exceeded daily rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
|
|
220
|
+
this.name = "QstashDailyRatelimitError";
|
|
216
221
|
this.limit = args.limit;
|
|
217
222
|
this.remaining = args.remaining;
|
|
218
223
|
this.reset = args.reset;
|
|
219
|
-
this.name = "QstashChatRatelimitError";
|
|
220
224
|
}
|
|
221
225
|
};
|
|
222
226
|
var QStashWorkflowError = class extends QstashError {
|
|
@@ -373,7 +377,10 @@ var HttpClient = class {
|
|
|
373
377
|
}
|
|
374
378
|
if (response.status < 200 || response.status >= 300) {
|
|
375
379
|
const body = await response.text();
|
|
376
|
-
throw new QstashError(
|
|
380
|
+
throw new QstashError(
|
|
381
|
+
body.length > 0 ? body : `Error: status=${response.status}`,
|
|
382
|
+
response.status
|
|
383
|
+
);
|
|
377
384
|
}
|
|
378
385
|
}
|
|
379
386
|
};
|
|
@@ -613,6 +620,7 @@ var BaseProvider = class {
|
|
|
613
620
|
var LLMProvider = class extends BaseProvider {
|
|
614
621
|
apiKind = "llm";
|
|
615
622
|
organization;
|
|
623
|
+
method = "POST";
|
|
616
624
|
constructor(baseUrl, token, owner, organization) {
|
|
617
625
|
super(baseUrl, token, owner);
|
|
618
626
|
this.organization = organization;
|
|
@@ -689,15 +697,24 @@ var getProviderInfo = (api, upstashToken) => {
|
|
|
689
697
|
baseUrl: finalProvider.baseUrl,
|
|
690
698
|
route: finalProvider.getRoute(),
|
|
691
699
|
appendHeaders: finalProvider.getHeaders(parameters),
|
|
692
|
-
owner: finalProvider.owner
|
|
700
|
+
owner: finalProvider.owner,
|
|
701
|
+
method: finalProvider.method
|
|
693
702
|
};
|
|
694
703
|
return finalProvider.onFinish(providerInfo, parameters);
|
|
695
704
|
};
|
|
696
|
-
var
|
|
705
|
+
var safeJoinHeaders = (headers, record) => {
|
|
706
|
+
const joinedHeaders = new Headers(record);
|
|
707
|
+
for (const [header, value] of headers.entries()) {
|
|
708
|
+
joinedHeaders.set(header, value);
|
|
709
|
+
}
|
|
710
|
+
return joinedHeaders;
|
|
711
|
+
};
|
|
712
|
+
var processApi = (request, headers, upstashToken) => {
|
|
697
713
|
if (!request.api) {
|
|
714
|
+
request.headers = headers;
|
|
698
715
|
return request;
|
|
699
716
|
}
|
|
700
|
-
const { url, appendHeaders, owner } = getProviderInfo(request.api, upstashToken);
|
|
717
|
+
const { url, appendHeaders, owner, method } = getProviderInfo(request.api, upstashToken);
|
|
701
718
|
if (request.api.name === "llm") {
|
|
702
719
|
const callback = request.callback;
|
|
703
720
|
if (!callback) {
|
|
@@ -705,21 +722,15 @@ var processApi = (request, upstashToken) => {
|
|
|
705
722
|
}
|
|
706
723
|
return {
|
|
707
724
|
...request,
|
|
708
|
-
|
|
709
|
-
headers:
|
|
710
|
-
...request.headers,
|
|
711
|
-
...appendHeaders
|
|
712
|
-
}),
|
|
725
|
+
method: request.method ?? method,
|
|
726
|
+
headers: safeJoinHeaders(headers, appendHeaders),
|
|
713
727
|
...owner === "upstash" && !request.api.analytics ? { api: { name: "llm" }, url: void 0, callback } : { url, api: void 0 }
|
|
714
728
|
};
|
|
715
729
|
} else {
|
|
716
730
|
return {
|
|
717
731
|
...request,
|
|
718
|
-
|
|
719
|
-
headers:
|
|
720
|
-
...request.headers,
|
|
721
|
-
...appendHeaders
|
|
722
|
-
}),
|
|
732
|
+
method: request.method ?? method,
|
|
733
|
+
headers: safeJoinHeaders(headers, appendHeaders),
|
|
723
734
|
url,
|
|
724
735
|
api: void 0
|
|
725
736
|
};
|
|
@@ -924,9 +935,8 @@ var Queue = class {
|
|
|
924
935
|
async enqueueJSON(request) {
|
|
925
936
|
const headers = prefixHeaders(new Headers(request.headers));
|
|
926
937
|
headers.set("Content-Type", "application/json");
|
|
927
|
-
request.headers = headers;
|
|
928
938
|
const upstashToken = String(this.http.authorization).split("Bearer ")[1];
|
|
929
|
-
const nonApiRequest = processApi(request, upstashToken);
|
|
939
|
+
const nonApiRequest = processApi(request, headers, upstashToken);
|
|
930
940
|
const response = await this.enqueue({
|
|
931
941
|
...nonApiRequest,
|
|
932
942
|
body: JSON.stringify(nonApiRequest.body),
|
|
@@ -1221,6 +1231,10 @@ var Client = class {
|
|
|
1221
1231
|
* Access the workflow API.
|
|
1222
1232
|
*
|
|
1223
1233
|
* cancel workflows.
|
|
1234
|
+
*
|
|
1235
|
+
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
|
|
1236
|
+
* Please use @upstash/workflow instead https://github.com/upstash/workflow-js
|
|
1237
|
+
* Migration Guide: https://upstash.com/docs/workflow/migration
|
|
1224
1238
|
*/
|
|
1225
1239
|
get workflow() {
|
|
1226
1240
|
return new Workflow(this.http);
|
|
@@ -1258,9 +1272,8 @@ var Client = class {
|
|
|
1258
1272
|
async publishJSON(request) {
|
|
1259
1273
|
const headers = prefixHeaders(new Headers(request.headers));
|
|
1260
1274
|
headers.set("Content-Type", "application/json");
|
|
1261
|
-
request.headers = headers;
|
|
1262
1275
|
const upstashToken = String(this.http.authorization).split("Bearer ")[1];
|
|
1263
|
-
const nonApiRequest = processApi(request, upstashToken);
|
|
1276
|
+
const nonApiRequest = processApi(request, headers, upstashToken);
|
|
1264
1277
|
const response = await this.publish({
|
|
1265
1278
|
...nonApiRequest,
|
|
1266
1279
|
body: JSON.stringify(nonApiRequest.body)
|
|
@@ -1301,9 +1314,8 @@ var Client = class {
|
|
|
1301
1314
|
if ("body" in message) {
|
|
1302
1315
|
message.body = JSON.stringify(message.body);
|
|
1303
1316
|
}
|
|
1304
|
-
message.headers = new Headers(message.headers);
|
|
1305
1317
|
const upstashToken = String(this.http.authorization).split("Bearer ")[1];
|
|
1306
|
-
const nonApiMessage = processApi(message, upstashToken);
|
|
1318
|
+
const nonApiMessage = processApi(message, new Headers(message.headers), upstashToken);
|
|
1307
1319
|
nonApiMessage.headers.set("Content-Type", "application/json");
|
|
1308
1320
|
return nonApiMessage;
|
|
1309
1321
|
});
|
|
@@ -1367,6 +1379,7 @@ var Client = class {
|
|
|
1367
1379
|
var EmailProvider = class extends BaseProvider {
|
|
1368
1380
|
apiKind = "email";
|
|
1369
1381
|
batch;
|
|
1382
|
+
method = "POST";
|
|
1370
1383
|
constructor(baseUrl, token, owner, batch) {
|
|
1371
1384
|
super(baseUrl, token, owner);
|
|
1372
1385
|
this.batch = batch;
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resend
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-K2ZUMNWA.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-A3H5A6JL.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 { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-
|
|
3
|
+
import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.mjs';
|
|
4
4
|
import 'neverthrow';
|
|
5
5
|
|
|
6
6
|
type VerifySignatureConfig = {
|
|
@@ -31,8 +31,17 @@ declare function verifySignatureAppRouter(handler: ((request: Request, params?:
|
|
|
31
31
|
* @param routeFunction workflow function
|
|
32
32
|
* @param options workflow options
|
|
33
33
|
* @returns
|
|
34
|
+
*
|
|
35
|
+
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
|
|
36
|
+
* Please use https://github.com/upstash/workflow-js
|
|
37
|
+
* Migration Guide: https://upstash.com/docs/workflow/migration
|
|
34
38
|
*/
|
|
35
39
|
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => ((request: Request) => Promise<Response>);
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
|
|
42
|
+
* Please use https://github.com/upstash/workflow-js
|
|
43
|
+
* Migration Guide: https://upstash.com/docs/workflow/migration
|
|
44
|
+
*/
|
|
36
45
|
declare const servePagesRouter: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => NextApiHandler;
|
|
37
46
|
|
|
38
47
|
export { type VerifySignatureConfig, serve, servePagesRouter, verifySignature, verifySignatureAppRouter, verifySignatureEdge };
|