@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.
@@ -116,10 +116,13 @@ var DLQ = class {
116
116
  };
117
117
 
118
118
  // src/client/error.ts
119
+ var RATELIMIT_STATUS = 429;
119
120
  var QstashError = class extends Error {
120
- constructor(message) {
121
+ status;
122
+ constructor(message, status) {
121
123
  super(message);
122
124
  this.name = "QstashError";
125
+ this.status = status;
123
126
  }
124
127
  };
125
128
  var QstashRatelimitError = class extends QstashError {
@@ -127,7 +130,7 @@ var QstashRatelimitError = class extends QstashError {
127
130
  remaining;
128
131
  reset;
129
132
  constructor(args) {
130
- super(`Exceeded burst rate limit. ${JSON.stringify(args)} `);
133
+ super(`Exceeded burst rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
131
134
  this.name = "QstashRatelimitError";
132
135
  this.limit = args.limit;
133
136
  this.remaining = args.remaining;
@@ -142,7 +145,8 @@ var QstashChatRatelimitError = class extends QstashError {
142
145
  resetRequests;
143
146
  resetTokens;
144
147
  constructor(args) {
145
- super(`Exceeded chat rate limit. ${JSON.stringify(args)} `);
148
+ super(`Exceeded chat rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
149
+ this.name = "QstashChatRatelimitError";
146
150
  this.limitRequests = args["limit-requests"];
147
151
  this.limitTokens = args["limit-tokens"];
148
152
  this.remainingRequests = args["remaining-requests"];
@@ -156,11 +160,11 @@ var QstashDailyRatelimitError = class extends QstashError {
156
160
  remaining;
157
161
  reset;
158
162
  constructor(args) {
159
- super(`Exceeded daily rate limit. ${JSON.stringify(args)} `);
163
+ super(`Exceeded daily rate limit. ${JSON.stringify(args)}`, RATELIMIT_STATUS);
164
+ this.name = "QstashDailyRatelimitError";
160
165
  this.limit = args.limit;
161
166
  this.remaining = args.remaining;
162
167
  this.reset = args.reset;
163
- this.name = "QstashChatRatelimitError";
164
168
  }
165
169
  };
166
170
  var QStashWorkflowError = class extends QstashError {
@@ -317,7 +321,10 @@ var HttpClient = class {
317
321
  }
318
322
  if (response.status < 200 || response.status >= 300) {
319
323
  const body = await response.text();
320
- throw new QstashError(body.length > 0 ? body : `Error: status=${response.status}`);
324
+ throw new QstashError(
325
+ body.length > 0 ? body : `Error: status=${response.status}`,
326
+ response.status
327
+ );
321
328
  }
322
329
  }
323
330
  };
@@ -557,6 +564,7 @@ var BaseProvider = class {
557
564
  var LLMProvider = class extends BaseProvider {
558
565
  apiKind = "llm";
559
566
  organization;
567
+ method = "POST";
560
568
  constructor(baseUrl, token, owner, organization) {
561
569
  super(baseUrl, token, owner);
562
570
  this.organization = organization;
@@ -633,15 +641,24 @@ var getProviderInfo = (api, upstashToken) => {
633
641
  baseUrl: finalProvider.baseUrl,
634
642
  route: finalProvider.getRoute(),
635
643
  appendHeaders: finalProvider.getHeaders(parameters),
636
- owner: finalProvider.owner
644
+ owner: finalProvider.owner,
645
+ method: finalProvider.method
637
646
  };
638
647
  return finalProvider.onFinish(providerInfo, parameters);
639
648
  };
640
- var processApi = (request, upstashToken) => {
649
+ var safeJoinHeaders = (headers, record) => {
650
+ const joinedHeaders = new Headers(record);
651
+ for (const [header, value] of headers.entries()) {
652
+ joinedHeaders.set(header, value);
653
+ }
654
+ return joinedHeaders;
655
+ };
656
+ var processApi = (request, headers, upstashToken) => {
641
657
  if (!request.api) {
658
+ request.headers = headers;
642
659
  return request;
643
660
  }
644
- const { url, appendHeaders, owner } = getProviderInfo(request.api, upstashToken);
661
+ const { url, appendHeaders, owner, method } = getProviderInfo(request.api, upstashToken);
645
662
  if (request.api.name === "llm") {
646
663
  const callback = request.callback;
647
664
  if (!callback) {
@@ -649,21 +666,15 @@ var processApi = (request, upstashToken) => {
649
666
  }
650
667
  return {
651
668
  ...request,
652
- // @ts-expect-error undici header conflict
653
- headers: new Headers({
654
- ...request.headers,
655
- ...appendHeaders
656
- }),
669
+ method: request.method ?? method,
670
+ headers: safeJoinHeaders(headers, appendHeaders),
657
671
  ...owner === "upstash" && !request.api.analytics ? { api: { name: "llm" }, url: void 0, callback } : { url, api: void 0 }
658
672
  };
659
673
  } else {
660
674
  return {
661
675
  ...request,
662
- // @ts-expect-error undici header conflict
663
- headers: new Headers({
664
- ...request.headers,
665
- ...appendHeaders
666
- }),
676
+ method: request.method ?? method,
677
+ headers: safeJoinHeaders(headers, appendHeaders),
667
678
  url,
668
679
  api: void 0
669
680
  };
@@ -873,9 +884,8 @@ var Queue = class {
873
884
  async enqueueJSON(request) {
874
885
  const headers = prefixHeaders(new Headers(request.headers));
875
886
  headers.set("Content-Type", "application/json");
876
- request.headers = headers;
877
887
  const upstashToken = String(this.http.authorization).split("Bearer ")[1];
878
- const nonApiRequest = processApi(request, upstashToken);
888
+ const nonApiRequest = processApi(request, headers, upstashToken);
879
889
  const response = await this.enqueue({
880
890
  ...nonApiRequest,
881
891
  body: JSON.stringify(nonApiRequest.body),
@@ -1139,6 +1149,10 @@ var Client = class {
1139
1149
  * Access the workflow API.
1140
1150
  *
1141
1151
  * cancel workflows.
1152
+ *
1153
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
1154
+ * Please use @upstash/workflow instead https://github.com/upstash/workflow-js
1155
+ * Migration Guide: https://upstash.com/docs/workflow/migration
1142
1156
  */
1143
1157
  get workflow() {
1144
1158
  return new Workflow(this.http);
@@ -1176,9 +1190,8 @@ var Client = class {
1176
1190
  async publishJSON(request) {
1177
1191
  const headers = prefixHeaders(new Headers(request.headers));
1178
1192
  headers.set("Content-Type", "application/json");
1179
- request.headers = headers;
1180
1193
  const upstashToken = String(this.http.authorization).split("Bearer ")[1];
1181
- const nonApiRequest = processApi(request, upstashToken);
1194
+ const nonApiRequest = processApi(request, headers, upstashToken);
1182
1195
  const response = await this.publish({
1183
1196
  ...nonApiRequest,
1184
1197
  body: JSON.stringify(nonApiRequest.body)
@@ -1219,9 +1232,8 @@ var Client = class {
1219
1232
  if ("body" in message) {
1220
1233
  message.body = JSON.stringify(message.body);
1221
1234
  }
1222
- message.headers = new Headers(message.headers);
1223
1235
  const upstashToken = String(this.http.authorization).split("Bearer ")[1];
1224
- const nonApiMessage = processApi(message, upstashToken);
1236
+ const nonApiMessage = processApi(message, new Headers(message.headers), upstashToken);
1225
1237
  nonApiMessage.headers.set("Content-Type", "application/json");
1226
1238
  return nonApiMessage;
1227
1239
  });
@@ -1859,7 +1871,7 @@ var validateParallelSteps = (lazySteps, stepsFromRequest) => {
1859
1871
  };
1860
1872
  var sortSteps = (steps) => {
1861
1873
  const getStepId = (step) => step.targetStep ?? step.stepId;
1862
- return steps.toSorted((step, stepOther) => getStepId(step) - getStepId(stepOther));
1874
+ return [...steps].sort((step, stepOther) => getStepId(step) - getStepId(stepOther));
1863
1875
  };
1864
1876
 
1865
1877
  // src/client/workflow/steps.ts
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Receiver,
3
3
  serve
4
- } from "./chunk-GWAFAA2M.mjs";
4
+ } from "./chunk-A3H5A6JL.mjs";
5
5
 
6
6
  // node_modules/defu/dist/defu.mjs
7
7
  function isPlainObject(value) {
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  BaseProvider
3
- } from "./chunk-GWAFAA2M.mjs";
3
+ } from "./chunk-A3H5A6JL.mjs";
4
4
 
5
5
  // src/client/api/email.ts
6
6
  var EmailProvider = class extends BaseProvider {
7
7
  apiKind = "email";
8
8
  batch;
9
+ method = "POST";
9
10
  constructor(baseUrl, token, owner, batch) {
10
11
  super(baseUrl, token, owner);
11
12
  this.batch = batch;
@@ -127,6 +127,10 @@ type ProviderInfo = {
127
127
  * provider owner
128
128
  */
129
129
  owner: Owner;
130
+ /**
131
+ * method to use in the request
132
+ */
133
+ method: HTTPMethods;
130
134
  };
131
135
  type ApiKind = "llm" | "email";
132
136
  type Owner = EmailOwner | LLMOwner;
@@ -153,6 +157,7 @@ type PublishLLMApi = PublishApi<"llm", BaseProvider<"llm", LLMOwner>> & LLMOptio
153
157
 
154
158
  declare abstract class BaseProvider<TName extends ApiKind, TOwner = Owner> {
155
159
  abstract readonly apiKind: TName;
160
+ abstract readonly method: HTTPMethods;
156
161
  readonly baseUrl: string;
157
162
  token: string;
158
163
  readonly owner: TOwner;
@@ -171,6 +176,7 @@ declare abstract class BaseProvider<TName extends ApiKind, TOwner = Owner> {
171
176
  declare class LLMProvider<TOwner extends LLMOwner> extends BaseProvider<"llm", LLMOwner> {
172
177
  readonly apiKind = "llm";
173
178
  readonly organization?: string;
179
+ readonly method = "POST";
174
180
  constructor(baseUrl: string, token: string, owner: TOwner, organization?: string);
175
181
  getRoute(): string[];
176
182
  getHeaders(options: LLMOptions): Record<string, string>;
@@ -182,6 +188,14 @@ declare class LLMProvider<TOwner extends LLMOwner> extends BaseProvider<"llm", L
182
188
  */
183
189
  onFinish(providerInfo: ProviderInfo, options: LLMOptions): ProviderInfo;
184
190
  }
191
+ /**
192
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
193
+ *
194
+ * Please use an alternative LLM provider.
195
+ *
196
+ * openai: https://upstash.com/docs/qstash/integrations/llm
197
+ * anthropic: https://upstash.com/docs/qstash/integrations/anthropic
198
+ */
185
199
  declare const upstash: () => LLMProvider<"upstash">;
186
200
  declare const openai: ({ token, organization, }: {
187
201
  token: string;
@@ -1517,9 +1531,18 @@ declare const processOptions: <TResponse extends Response = Response, TInitialPa
1517
1531
  * @param routeFunction - A function that uses WorkflowContext as a parameter and runs a workflow.
1518
1532
  * @param options - Options including the client, onFinish callback, and initialPayloadParser.
1519
1533
  * @returns An async method that consumes incoming requests and runs the workflow.
1534
+ *
1535
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
1536
+ * Please use https://github.com/upstash/workflow-js
1537
+ * Migration Guide: https://upstash.com/docs/workflow/migration
1520
1538
  */
1521
1539
  declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => ((request: TRequest) => Promise<TResponse>);
1522
1540
 
1541
+ /**
1542
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
1543
+ * Please use https://github.com/upstash/workflow-js
1544
+ * Migration Guide: https://upstash.com/docs/workflow/migration
1545
+ */
1523
1546
  declare class Workflow {
1524
1547
  private readonly http;
1525
1548
  constructor(http: Requester);
@@ -1800,6 +1823,10 @@ declare class Client {
1800
1823
  * Access the workflow API.
1801
1824
  *
1802
1825
  * cancel workflows.
1826
+ *
1827
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
1828
+ * Please use @upstash/workflow instead https://github.com/upstash/workflow-js
1829
+ * Migration Guide: https://upstash.com/docs/workflow/migration
1803
1830
  */
1804
1831
  get workflow(): Workflow;
1805
1832
  /**
@@ -127,6 +127,10 @@ type ProviderInfo = {
127
127
  * provider owner
128
128
  */
129
129
  owner: Owner;
130
+ /**
131
+ * method to use in the request
132
+ */
133
+ method: HTTPMethods;
130
134
  };
131
135
  type ApiKind = "llm" | "email";
132
136
  type Owner = EmailOwner | LLMOwner;
@@ -153,6 +157,7 @@ type PublishLLMApi = PublishApi<"llm", BaseProvider<"llm", LLMOwner>> & LLMOptio
153
157
 
154
158
  declare abstract class BaseProvider<TName extends ApiKind, TOwner = Owner> {
155
159
  abstract readonly apiKind: TName;
160
+ abstract readonly method: HTTPMethods;
156
161
  readonly baseUrl: string;
157
162
  token: string;
158
163
  readonly owner: TOwner;
@@ -171,6 +176,7 @@ declare abstract class BaseProvider<TName extends ApiKind, TOwner = Owner> {
171
176
  declare class LLMProvider<TOwner extends LLMOwner> extends BaseProvider<"llm", LLMOwner> {
172
177
  readonly apiKind = "llm";
173
178
  readonly organization?: string;
179
+ readonly method = "POST";
174
180
  constructor(baseUrl: string, token: string, owner: TOwner, organization?: string);
175
181
  getRoute(): string[];
176
182
  getHeaders(options: LLMOptions): Record<string, string>;
@@ -182,6 +188,14 @@ declare class LLMProvider<TOwner extends LLMOwner> extends BaseProvider<"llm", L
182
188
  */
183
189
  onFinish(providerInfo: ProviderInfo, options: LLMOptions): ProviderInfo;
184
190
  }
191
+ /**
192
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
193
+ *
194
+ * Please use an alternative LLM provider.
195
+ *
196
+ * openai: https://upstash.com/docs/qstash/integrations/llm
197
+ * anthropic: https://upstash.com/docs/qstash/integrations/anthropic
198
+ */
185
199
  declare const upstash: () => LLMProvider<"upstash">;
186
200
  declare const openai: ({ token, organization, }: {
187
201
  token: string;
@@ -1517,9 +1531,18 @@ declare const processOptions: <TResponse extends Response = Response, TInitialPa
1517
1531
  * @param routeFunction - A function that uses WorkflowContext as a parameter and runs a workflow.
1518
1532
  * @param options - Options including the client, onFinish callback, and initialPayloadParser.
1519
1533
  * @returns An async method that consumes incoming requests and runs the workflow.
1534
+ *
1535
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
1536
+ * Please use https://github.com/upstash/workflow-js
1537
+ * Migration Guide: https://upstash.com/docs/workflow/migration
1520
1538
  */
1521
1539
  declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => ((request: TRequest) => Promise<TResponse>);
1522
1540
 
1541
+ /**
1542
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
1543
+ * Please use https://github.com/upstash/workflow-js
1544
+ * Migration Guide: https://upstash.com/docs/workflow/migration
1545
+ */
1523
1546
  declare class Workflow {
1524
1547
  private readonly http;
1525
1548
  constructor(http: Requester);
@@ -1800,6 +1823,10 @@ declare class Client {
1800
1823
  * Access the workflow API.
1801
1824
  *
1802
1825
  * cancel workflows.
1826
+ *
1827
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
1828
+ * Please use @upstash/workflow instead https://github.com/upstash/workflow-js
1829
+ * Migration Guide: https://upstash.com/docs/workflow/migration
1803
1830
  */
1804
1831
  get workflow(): Workflow;
1805
1832
  /**
package/cloudflare.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-RORrka04.mjs';
1
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.mjs';
2
2
  import 'neverthrow';
3
3
 
4
4
  type WorkflowBindings = {
@@ -27,6 +27,10 @@ type WorkersHandlerArgs = [Request, Record<string, string | undefined>];
27
27
  * @param routeFunction workflow function
28
28
  * @param options workflow options
29
29
  * @returns
30
+ *
31
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
32
+ * Please use https://github.com/upstash/workflow-js
33
+ * Migration Guide: https://upstash.com/docs/workflow/migration
30
34
  */
31
35
  declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => ((...args: PagesHandlerArgs | WorkersHandlerArgs) => Promise<Response>);
32
36
 
package/cloudflare.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-RORrka04.js';
1
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.js';
2
2
  import 'neverthrow';
3
3
 
4
4
  type WorkflowBindings = {
@@ -27,6 +27,10 @@ type WorkersHandlerArgs = [Request, Record<string, string | undefined>];
27
27
  * @param routeFunction workflow function
28
28
  * @param options workflow options
29
29
  * @returns
30
+ *
31
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
32
+ * Please use https://github.com/upstash/workflow-js
33
+ * Migration Guide: https://upstash.com/docs/workflow/migration
30
34
  */
31
35
  declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => ((...args: PagesHandlerArgs | WorkersHandlerArgs) => Promise<Response>);
32
36
 
package/cloudflare.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
- constructor(message) {
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(body.length > 0 ? body : `Error: status=${response.status}`);
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 processApi = (request, upstashToken) => {
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
- // @ts-expect-error undici header conflict
673
- headers: new 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
- // @ts-expect-error undici header conflict
683
- headers: new 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.toSorted((step, stepOther) => getStepId(step) - getStepId(stepOther));
1894
+ return [...steps].sort((step, stepOther) => getStepId(step) - getStepId(stepOther));
1883
1895
  };
1884
1896
 
1885
1897
  // src/client/workflow/steps.ts
package/cloudflare.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serve
3
- } from "./chunk-GWAFAA2M.mjs";
3
+ } from "./chunk-A3H5A6JL.mjs";
4
4
 
5
5
  // platforms/cloudflare.ts
6
6
  var getArgs = (args) => {
package/h3.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as h3 from 'h3';
2
2
  import { H3Event } from 'h3';
3
- import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-RORrka04.mjs';
3
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.mjs';
4
4
  import 'neverthrow';
5
5
 
6
6
  type VerifySignatureConfig = {
@@ -9,6 +9,11 @@ type VerifySignatureConfig = {
9
9
  clockTolerance?: number;
10
10
  };
11
11
  declare const verifySignatureH3: (handler: (event: H3Event) => Promise<unknown>, config?: VerifySignatureConfig) => h3.EventHandler<h3.EventHandlerRequest, Promise<unknown>>;
12
+ /**
13
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
14
+ * Please use https://github.com/upstash/workflow-js
15
+ * Migration Guide: https://upstash.com/docs/workflow/migration
16
+ */
12
17
  declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => h3.EventHandler<h3.EventHandlerRequest, Promise<Response | {
13
18
  status: number;
14
19
  body: string;
package/h3.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as h3 from 'h3';
2
2
  import { H3Event } from 'h3';
3
- import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-RORrka04.js';
3
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.js';
4
4
  import 'neverthrow';
5
5
 
6
6
  type VerifySignatureConfig = {
@@ -9,6 +9,11 @@ type VerifySignatureConfig = {
9
9
  clockTolerance?: number;
10
10
  };
11
11
  declare const verifySignatureH3: (handler: (event: H3Event) => Promise<unknown>, config?: VerifySignatureConfig) => h3.EventHandler<h3.EventHandlerRequest, Promise<unknown>>;
12
+ /**
13
+ * @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
14
+ * Please use https://github.com/upstash/workflow-js
15
+ * Migration Guide: https://upstash.com/docs/workflow/migration
16
+ */
12
17
  declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => h3.EventHandler<h3.EventHandlerRequest, Promise<Response | {
13
18
  status: number;
14
19
  body: string;